[libbluray-devel] Added BD-J flags to disc info

hpi1 git at videolan.org
Sat Dec 14 20:30:37 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Dec 13 20:32:09 2013 +0200| [f325c9dde1bbc1c595e6608d665c6df7ea732144] | committer: npzacs

Added BD-J flags to disc info

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f325c9dde1bbc1c595e6608d665c6df7ea732144
---

 src/examples/bd_info.c  |    9 +++++++++
 src/libbluray/bdj/bdj.c |   22 ++++++++++++++++++++++
 src/libbluray/bdj/bdj.h |    2 ++
 src/libbluray/bluray.c  |   34 ++++++++++++++++++++++++++++++++++
 src/libbluray/bluray.h  |    4 ++++
 5 files changed, 71 insertions(+)

diff --git a/src/examples/bd_info.c b/src/examples/bd_info.c
index 607f270..028960a 100644
--- a/src/examples/bd_info.c
+++ b/src/examples/bd_info.c
@@ -153,6 +153,15 @@ int main(int argc, char *argv[])
         printf("HDMV titles         : %d\n", info->num_hdmv_titles);
         printf("BD-J titles         : %d\n", info->num_bdj_titles);
         printf("UNSUPPORTED titles  : %d\n", info->num_unsupported_titles);
+
+        printf("\nBD-J detected       : %s\n", _yes_no(info->bdj_supported));
+        if (info->bdj_detected) {
+            printf("BD-J supported      : %s\n", _yes_no(info->bdj_supported));
+            if (info->bdj_supported) {
+                printf("Java VM found       : %s\n", _yes_no(info->libjvm_detected));
+                printf("BD-J handled        : %s\n", _yes_no(info->bdj_handled));
+            }
+        }
     }
 
     printf("\nAACS detected       : %s\n", _yes_no(info->aacs_detected));
diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index 896d45e..fdd25c0 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -250,6 +250,28 @@ static int _bdj_init(BDJAVA *bdjava, JNIEnv *env)
     return 1;
 }
 
+int bdj_jvm_available(void)
+{
+    const char *java_home;
+    void* jvm_lib = _load_jvm(&java_home);
+    if (!jvm_lib) {
+        BD_DEBUG(DBG_BDJ | DBG_CRIT, "BD-J check: Failed to load JVM library\n");
+        return 0;
+    }
+    dl_dlclose(jvm_lib);
+
+    FILE *fp = fopen(_find_libbluray_jar(), "rb");
+    if (!fp) {
+        BD_DEBUG(DBG_BDJ | DBG_CRIT, "BD-J check: Failed to load libbluray.jar\n");
+        return 1;
+    }
+    fclose(fp);
+
+    BD_DEBUG(DBG_BDJ, "BD-J check: OK\n");
+
+    return 2;
+}
+
 BDJAVA* bdj_open(const char *path, struct bluray *bd,
                  struct indx_root_s *index,
                  bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf)
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index 203cf53..869ceda 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -60,4 +60,6 @@ BD_PRIVATE void bdj_close(BDJAVA *bdjava);
 BD_PRIVATE int  bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);
 BD_PRIVATE int  bdj_get_uo_mask(BDJAVA *bdjava);
 
+BD_PRIVATE int  bdj_jvm_available(void); /* 0: no. 1: only jvm. 2: jvm + libbluray.jar. */
+
 #endif
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 6010d82..db90a34 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -936,12 +936,19 @@ static void _fill_disc_info(BLURAY *bd)
     bd->disc_info.num_bdj_titles         = 0;
     bd->disc_info.num_unsupported_titles = 0;
 
+    bd->disc_info.bdj_detected    = 0;
+    bd->disc_info.bdj_supported   = 0;
+    bd->disc_info.libjvm_detected = 0;
+    bd->disc_info.bdj_handled     = 0;
+
     if (bd->index) {
         INDX_PLAY_ITEM *pi;
         unsigned        ii;
 
         bd->disc_info.bluray_detected = 1;
 
+        /* count titles */
+
         for (ii = 0; ii < bd->index->num_titles; ii++) {
             if (bd->index->titles[ii].object_type == indx_object_type_hdmv) {
                 bd->disc_info.num_hdmv_titles++;
@@ -949,9 +956,31 @@ static void _fill_disc_info(BLURAY *bd)
             if (bd->index->titles[ii].object_type == indx_object_type_bdj) {
                 bd->disc_info.num_bdj_titles++;
                 bd->disc_info.num_unsupported_titles++;
+                bd->disc_info.bdj_detected = 1;
             }
         }
 
+        if (bd->index->first_play.object_type == indx_object_type_bdj) {
+            bd->disc_info.bdj_detected = 1;
+        }
+        if (bd->index->top_menu.object_type == indx_object_type_bdj) {
+            bd->disc_info.bdj_detected = 1;
+        }
+
+        /* BD-J capability */
+
+#ifdef USING_BDJAVA
+        if (bd->disc_info.bdj_detected) {
+            bd->disc_info.bdj_supported = 1;
+            /* BD-J titles found. Check if jvm + jar can be loaded ? */
+            switch (bdj_jvm_available()) {
+                case 2: bd->disc_info.bdj_handled     = 1;
+                case 1: bd->disc_info.libjvm_detected = 1;
+                default:;
+            }
+        }
+#endif /* USING_BDJAVA */
+
         pi = &bd->index->first_play;
         if (pi->object_type == indx_object_type_hdmv && pi->hdmv.id_ref != 0xffff) {
             bd->disc_info.first_play_supported = 1;
@@ -2655,6 +2684,11 @@ static void _queue_initial_psr_events(BLURAY *bd)
 
 static int _play_bdj(BLURAY *bd, unsigned title)
 {
+    if (!bd->disc_info.bdj_handled) {
+        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "Can't play BD-J title %d\n", title);
+        return 0;
+    }
+
     bd->title_type = title_bdj;
 
     return _start_bdj(bd, title);
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index cca42fe..90ca186 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -496,6 +496,10 @@ typedef struct {
     /* Disc ID */
     uint8_t  disc_id[20];
 
+    uint8_t  bdj_detected;     /* 1 if disc uses BD-J */
+    uint8_t  bdj_supported;    /* 1 if BD-J support was compiled in */
+    uint8_t  libjvm_detected;  /* 1 if usable Java VM was found */
+    uint8_t  bdj_handled;      /* 1 if usable Java VM + libbluray.jar was found */
 } BLURAY_DISC_INFO;
 
 /**



More information about the libbluray-devel mailing list