[libbluray-devel] Add the possibility to set the persistent/ cache root path via bd_set_player_setting_str()

ace20022 git at videolan.org
Tue Sep 30 10:18:02 CEST 2014


libbluray | branch: master | ace20022 <ace20022 at ymail.com> | Fri Sep 19 16:00:06 2014 +0200| [0141be514756a8c5243983c5c0bd01c327ddda0f] | committer: hpi1

Add the possibility to set the persistent/cache root path via bd_set_player_setting_str()

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

 ChangeLog               |    1 +
 src/libbluray/bdj/bdj.c |   22 +++++++++++++++-------
 src/libbluray/bdj/bdj.h |    8 +++++++-
 src/libbluray/bluray.c  |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 src/libbluray/bluray.h  |    2 ++
 5 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d773b69..f0cca99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 - Fix animations in some BD-J menus.
+- Add player setting for persistent/cache root path.
 
 2014-09-03: Version 0.6.2
 - Fix possible subtitle corruption after seek.
diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index c54e7ee..d57776c 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -254,10 +254,14 @@ static const char *_find_libbluray_jar(void)
     return classpath;
 }
 
-static const char *_bdj_persistent_root(void)
+static const char *_bdj_persistent_root(BDJ_STORAGE *storage)
 {
     static const char *root = NULL;
 
+    if (storage && storage->persistent_root) {
+        return storage->persistent_root;
+    }
+
     if (root) {
         return root;
     }
@@ -278,10 +282,14 @@ static const char *_bdj_persistent_root(void)
     return root;
 }
 
-static const char *_bdj_buda_root(void)
+static const char *_bdj_buda_root(BDJ_STORAGE *storage)
 {
     static const char *root = NULL;
 
+    if (storage && storage->cache_root) {
+        return storage->cache_root;
+    }
+
     if (root) {
         return root;
     }
@@ -383,7 +391,7 @@ static int _find_jvm(void *jvm_lib, JNIEnv **env, JavaVM **jvm)
     return 0;
 }
 
-static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaVM **jvm)
+static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaVM **jvm, BDJ_STORAGE *storage)
 {
     (void)java_home;  /* used only with J2ME */
 
@@ -396,8 +404,8 @@ static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaV
     JavaVMOption* option = calloc(1, sizeof(JavaVMOption) * 20);
     int n = 0;
     JavaVMInitArgs args;
-    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s", _bdj_persistent_root());
-    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=%s", _bdj_buda_root());
+    option[n++].optionString = str_printf("-Ddvb.persistent.root=%s", _bdj_persistent_root(storage));
+    option[n++].optionString = str_printf("-Dbluray.bindingunit.root=%s", _bdj_buda_root(storage));
 
     option[n++].optionString = str_dup   ("-Dawt.toolkit=java.awt.BDToolkit");
     option[n++].optionString = str_dup   ("-Djava.awt.graphicsenv=java.awt.BDGraphicsEnvironment");
@@ -452,7 +460,7 @@ static int _create_jvm(void *jvm_lib, const char *java_home, JNIEnv **env, JavaV
 }
 
 BDJAVA* bdj_open(const char *path, struct bluray *bd,
-                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf)
+                 bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf, BDJ_STORAGE *storage)
 {
     BD_DEBUG(DBG_BDJ, "bdj_open()\n");
 
@@ -467,7 +475,7 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,
 
     JNIEnv* env = NULL;
     JavaVM *jvm = NULL;
-    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib, java_home, &env, &jvm)) {
+    if (!_find_jvm(jvm_lib, &env, &jvm) && !_create_jvm(jvm_lib, java_home, &env, &jvm, storage)) {
         dl_dlclose(jvm_lib);
         return NULL;
     }
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index a177510..721c02f 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -42,6 +42,11 @@ typedef enum {
     BDJ_EVENT_RATE,
 } BDJ_EVENT;
 
+typedef struct {
+    char *persistent_root;
+    char *cache_root;
+} BDJ_STORAGE;
+
 /* bdj_get_uo_mask() */
 #define BDJ_MENU_CALL_MASK     0x01
 #define BDJ_TITLE_SEARCH_MASK  0x02
@@ -55,7 +60,8 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int,
                                int, int, int, int);
 
 BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,
-                            bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf);
+                            bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf,
+                            BDJ_STORAGE *storage);
 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);
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 320f009..c750b18 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -159,6 +159,7 @@ struct bluray {
     uint8_t        hdmv_suspended;
 #ifdef USING_BDJAVA
     BDJAVA         *bdjava;
+    BDJ_STORAGE    *bdjstorage;
 #endif
     /* delayed sending of BDJ_EVENT_END_OF_PLAYLIST:
      * 1 - message pending. 3 - message sent. */
@@ -1236,7 +1237,7 @@ static int _start_bdj(BLURAY *bd, unsigned title)
 {
 #ifdef USING_BDJAVA
     if (bd->bdjava == NULL) {
-        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb, bd->argb_buffer);
+        bd->bdjava = bdj_open(bd->device_path, bd, _bdj_osd_cb, bd->argb_buffer, bd->bdjstorage);
         if (!bd->bdjava) {
             return 0;
         }
@@ -1283,6 +1284,19 @@ static void _close_bdj(BLURAY *bd)
 #define _close_bdj(bd) do{}while(0)
 #endif
 
+#ifdef USING_BDJAVA
+static void _storage_free(BLURAY *bd)
+{
+  if (bd->bdjstorage){
+    X_FREE(bd->bdjstorage->cache_root);
+    X_FREE(bd->bdjstorage->persistent_root);
+    X_FREE(bd->bdjstorage);
+  }
+}
+#else
+#define _storage_free(bd) do{}while(0)
+#endif
+
 #ifdef HAVE_MNTENT_H
 /*
  * Replace device node (/dev/sr0) by mount point
@@ -1423,6 +1437,7 @@ void bd_close(BLURAY *bd)
     _free_event_queue(bd);
     X_FREE(bd->device_path);
     array_free((void**)&bd->titles);
+    _storage_free(bd);
 
     bd_mutex_destroy(&bd->mutex);
 
@@ -2588,6 +2603,34 @@ int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s)
         case BLURAY_PLAYER_SETTING_COUNTRY_CODE:
             return bd_set_player_setting(bd, idx, str_to_uint32(s, 2));
 
+#ifdef USING_BDJAVA
+        case BLURAY_PLAYER_CACHE_ROOT:
+        case BLURAY_PLAYER_PERSISTENT_ROOT:
+            if (!bd->bdjstorage) {
+                bd->bdjstorage = calloc(1, sizeof(BDJ_STORAGE));
+            }
+            switch (idx) {
+                case BLURAY_PLAYER_CACHE_ROOT:
+                    if (bd->bdjstorage) {
+                        X_FREE(bd->bdjstorage->cache_root);
+                        bd->bdjstorage->cache_root = str_dup(s);
+                        BD_DEBUG(DBG_BDJ, "Cache root dir set to %s\n", bd->bdjstorage->cache_root);
+                        return 1;
+                    }
+                    else
+                        return 0;
+
+                case BLURAY_PLAYER_PERSISTENT_ROOT:
+                    if (bd->bdjstorage) {
+                        X_FREE(bd->bdjstorage->persistent_root);
+                        bd->bdjstorage->persistent_root = str_dup(s);
+                        BD_DEBUG(DBG_BDJ, "Persistent root dir set to %s\n", bd->bdjstorage->persistent_root);
+                        return 1;
+                    }
+                    else
+                        return 0;
+            }
+#endif /* USING_BDJAVA */
         default:
             return 0;
     }
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index 54f4df7..e89ab39 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -561,6 +561,8 @@ typedef enum {
     BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31,  /* Profile1: 0, Profile1+: 1, Profile2: 3, Profile3: 8 */
 
     BLURAY_PLAYER_SETTING_DECODE_PG      = 0x100, /* enable/disable PG (subtitle) decoder */
+    BLURAY_PLAYER_PERSISTENT_ROOT        = 400,   /* Root path (string) to the BD_J persistent storage location */
+    BLURAY_PLAYER_CACHE_ROOT             = 401,   /* Root path (string) to the BD_J cache storage location */
 } bd_player_setting;
 
 /**



More information about the libbluray-devel mailing list