[libbluray-devel] Fill BD-J title info from disc info
hpi1
git at videolan.org
Thu Nov 6 13:05:09 CET 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Nov 6 12:38:20 2014 +0200| [03cd2e585ab105812f29ab16cc9e2f30e2698131] | committer: hpi1
Fill BD-J title info from disc info
Simpler. No need to re-read disc index.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=03cd2e585ab105812f29ab16cc9e2f30e2698131
---
src/libbluray/bdj/bdj.c | 2 -
src/libbluray/bdj/bdj_private.h | 2 -
src/libbluray/bdj/java/org/videolan/TitleInfo.java | 16 ++--
src/libbluray/bdj/native/org_videolan_Libbluray.c | 87 +++++---------------
4 files changed, 26 insertions(+), 81 deletions(-)
diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index 4b5cd28..2b23113 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -33,7 +33,6 @@
#include "util/macro.h"
#include "util/logging.h"
-#include "libbluray/bdnav/index_parse.h"
#include <jni.h>
#include <stdio.h>
@@ -573,7 +572,6 @@ void bdj_close(BDJAVA *bdjava)
dl_dlclose(bdjava->h_libjvm);
}
- indx_free(&bdjava->index);
X_FREE(bdjava);
}
diff --git a/src/libbluray/bdj/bdj_private.h b/src/libbluray/bdj/bdj_private.h
index a6fb6e6..e5b0bae 100644
--- a/src/libbluray/bdj/bdj_private.h
+++ b/src/libbluray/bdj/bdj_private.h
@@ -26,13 +26,11 @@
struct bluray;
struct bd_argb_buffer_s;
-struct indx_root_s;
struct bdjava_s {
struct bluray *bd;
const char *path;
- struct indx_root_s *index;
bdj_overlay_cb osd_cb;
struct bd_argb_buffer_s *buf;
diff --git a/src/libbluray/bdj/java/org/videolan/TitleInfo.java b/src/libbluray/bdj/java/org/videolan/TitleInfo.java
index decc41b..1c1075b 100644
--- a/src/libbluray/bdj/java/org/videolan/TitleInfo.java
+++ b/src/libbluray/bdj/java/org/videolan/TitleInfo.java
@@ -19,22 +19,20 @@
package org.videolan;
public class TitleInfo {
- public TitleInfo(int title, int objType, int playbackType, String bdjoName, int hdmvOID) {
+ public TitleInfo(int title, int objType, int playbackType, int idRef) {
this.title = title;
this.objType = objType;
this.playbackType = playbackType;
- this.bdjoName = bdjoName;
- this.hdmvOID = hdmvOID;
+ if (objType == OBJ_TYPE_BDJ)
+ this.bdjoName = (new java.text.DecimalFormat("00000")).format(idRef);
+ else
+ this.hdmvOID = idRef;
}
public int getTitleNum() {
return title;
}
- public int getObjType() {
- return objType;
- }
-
public int getPlaybackType() {
return playbackType;
}
@@ -58,8 +56,8 @@ public class TitleInfo {
private int title;
private int objType;
private int playbackType;
- private String bdjoName;
- private int hdmvOID;
+ private String bdjoName = null;
+ private int hdmvOID = -1;
public static final int OBJ_TYPE_HDMV = 1;
public static final int OBJ_TYPE_BDJ = 2;
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index 14d893b..56452d6 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -56,52 +56,26 @@
* build org.videolan.TitleInfo
*/
-static jobject _make_title_info(JNIEnv* env, int title, int objType, int playbackType, const char* bdjoName, int hdmvOID)
+static jobject _make_title_info(JNIEnv* env, const BLURAY_TITLE *title, int title_number)
{
- jstring name = bdjoName ? (*env)->NewStringUTF(env, bdjoName) : NULL;
- jobject ti = bdj_make_object(env, "org/videolan/TitleInfo",
- "(IIILjava/lang/String;I)V",
- title, objType, playbackType, name, hdmvOID);
- if (name)
- (*env)->DeleteLocalRef(env, name);
+ jobject ti = NULL;
+ if (title) {
+ int title_type = title->bdj ? 2 : 1;
+ int playback_type = (!!title->interactive) + ((!!title->bdj) << 1);
+ ti = bdj_make_object(env, "org/videolan/TitleInfo",
+ "(IIII)V",
+ title_number, title_type, playback_type, title->id_ref);
+ }
return ti;
}
-static jobject _get_title_info(JNIEnv * env, BDJAVA *bdj, jint title)
+static jobject _get_title_info(JNIEnv * env, const BLURAY_DISC_INFO *disc_info, jint title_number)
{
- if (title == 65535) {
- if (bdj->index->first_play.object_type == indx_object_type_hdmv)
- return _make_title_info(env, 65535, indx_object_type_hdmv,
- bdj->index->first_play.hdmv.playback_type,
- NULL,
- bdj->index->first_play.hdmv.id_ref);
- else
- return _make_title_info(env, 65535, indx_object_type_bdj,
- bdj->index->first_play.bdj.playback_type,
- bdj->index->first_play.bdj.name,
- -1);
- } else if (title == 0) {
- if (bdj->index->top_menu.object_type == indx_object_type_hdmv)
- return _make_title_info(env, 0, indx_object_type_hdmv,
- bdj->index->top_menu.hdmv.playback_type,
- NULL,
- bdj->index->top_menu.hdmv.id_ref);
- else
- return _make_title_info(env, 0, indx_object_type_bdj,
- bdj->index->top_menu.bdj.playback_type,
- bdj->index->top_menu.bdj.name,
- -1);
- } else if ((title > 0) && (title <= bdj->index->num_titles)) {
- if (bdj->index->titles[title - 1].object_type == indx_object_type_hdmv)
- return _make_title_info(env, title, indx_object_type_hdmv,
- bdj->index->titles[title - 1].hdmv.playback_type,
- NULL,
- bdj->index->titles[title - 1].hdmv.id_ref);
- else
- return _make_title_info(env, title, indx_object_type_bdj,
- bdj->index->titles[title - 1].bdj.playback_type,
- bdj->index->titles[title - 1].bdj.name,
- -1);
+ if (title_number == 65535) {
+ return _make_title_info(env, disc_info->first_play, 65535);
+ }
+ if (title_number >= 0 && (unsigned)title_number <= disc_info->num_titles) {
+ return _make_title_info(env, disc_info->titles[title_number], title_number);
}
return NULL;
}
@@ -178,35 +152,15 @@ static jobject _make_playlist_info(JNIEnv* env, BLURAY_TITLE_INFO* ti)
*
*/
-static int _read_index(BDJAVA *bdj)
-{
- if (!bdj) {
- return 0;
- }
-
- if (!bdj->index) {
- bdj->index = indx_parse(bdj->path);
- }
-
- return !!bdj->index;
-}
-
-/*
- *
- */
-
JNIEXPORT jobject JNICALL Java_org_videolan_Libbluray_getTitleInfoN
(JNIEnv * env, jclass cls, jlong np, jint title)
{
BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
+ const BLURAY_DISC_INFO *disc_info = bd_get_disc_info(bdj->bd);
BD_DEBUG(DBG_JNI, "getTitleInfoN(%d)\n", (int)title);
- if (!_read_index(bdj)) {
- return NULL;
- }
-
- return _get_title_info(env, bdj, title);
+ return _get_title_info(env, disc_info, title);
}
JNIEXPORT jobject JNICALL Java_org_videolan_Libbluray_getPlaylistInfoN
@@ -257,12 +211,9 @@ JNIEXPORT void JNICALL Java_org_videolan_Libbluray_setUOMaskN(JNIEnv * env,
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_getTitlesN(JNIEnv * env,
jclass cls, jlong np) {
BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
+ const BLURAY_DISC_INFO *disc_info = bd_get_disc_info(bdj->bd);
- if (!_read_index(bdj)) {
- return 0;
- }
-
- return bdj->index->num_titles;
+ return disc_info->num_titles;
}
JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekN(JNIEnv * env,
More information about the libbluray-devel
mailing list