[libbluray-devel] Add player setting for disabling persistent storage

hpi1 git at videolan.org
Mon Jul 25 20:21:56 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Sep 22 11:33:29 2015 +0300| [cbb86e18b4575e06ab1237aa91c413757f8c441f] | committer: hpi1

Add player setting for disabling persistent storage

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

 src/libbluray/bdj/bdj.c                            |  8 ++++++++
 src/libbluray/bdj/bdj.h                            |  4 ++++
 src/libbluray/bdj/java/org/videolan/Libbluray.java | 16 ++++++++++++++++
 src/libbluray/bluray.c                             | 16 ++++++++++++++++
 src/libbluray/bluray.h                             |  4 +++-
 src/libbluray/player_settings.h                    | 18 ++++++++++++++++++
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index 9ee1aa8..67d9170 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -346,6 +346,10 @@ static const char *_bdj_persistent_root(BDJ_STORAGE *storage)
     const char *root;
     char       *data_home;
 
+    if (storage->no_persistent_storage) {
+        return NULL;
+    }
+
     if (!storage->persistent_root) {
 
         root = getenv("LIBBLURAY_PERSISTENT_ROOT");
@@ -368,6 +372,10 @@ static const char *_bdj_buda_root(BDJ_STORAGE *storage)
     const char *root;
     char       *cache_home;
 
+    if (storage->no_persistent_storage) {
+        return NULL;
+    }
+
     if (!storage->cache_root) {
 
         root = getenv("LIBBLURAY_CACHE_ROOT");
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index ee6355e..789e7fe 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -22,6 +22,8 @@
 
 #include "util/attributes.h"
 
+#include <stdint.h>
+
 typedef enum {
     /* Note: these must be in sync with Libbluray.java ! */
 
@@ -65,6 +67,8 @@ typedef struct {
     char *cache_root;        /* BD-J binding unit data area */
 
     char *classpath;         /* BD-J implementation class path (location of libbluray.jar) */
+
+    uint8_t no_persistent_storage; /* disable persistent storage (remove files at close) */
 } BDJ_STORAGE;
 
 typedef struct bdjava_s BDJAVA;
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index f2d26dd..071c1de 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -110,6 +110,20 @@ public class Libbluray {
         initOnce();
 
         /* set up directories */
+
+        try {
+            if (persistentRoot == null) {
+                /* no persistent storage */
+                persistentRoot = CacheDir.create("dvb.persistent.root").getPath() + File.separator;
+            }
+            if (budaRoot == null) {
+                /* no persistent storage for BUDA */
+                budaRoot = CacheDir.create("bluray.bindingunit.root").getPath() + File.separator;
+            }
+        } catch (java.io.IOException e) {
+            System.err.println("Cache creation failed: " + e);
+            /* not fatal with most discs */
+        }
         persistentRoot = canonicalize(persistentRoot, true);
         budaRoot       = canonicalize(budaRoot, true);
 
@@ -123,6 +137,8 @@ public class Libbluray {
             System.getProperties().remove("bluray.vfs.root");
         }
 
+        /* */
+
         Libbluray.nativePointer = nativePointer;
         DiscManager.getDiscManager().setCurrentDisc(discID);
 
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index f14073f..36e9fac 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1388,6 +1388,8 @@ static void _storage_free(BLURAY *bd)
 
 BLURAY *bd_init(void)
 {
+    char *env;
+
     BD_DEBUG(DBG_BLURAY, "libbluray version "BLURAY_VERSION_STRING"\n");
 
     BLURAY *bd = calloc(1, sizeof(BLURAY));
@@ -1409,6 +1411,12 @@ BLURAY *bd_init(void)
     bd_mutex_init(&bd->argb_buffer_mutex);
 #endif
 
+    env = getenv("LIBBLURAY_PERSISTENT_STORAGE");
+    if (env) {
+        int v = (!strcmp(env, "yes")) ? 1 : (!strcmp(env, "no")) ? 0 : atoi(env);
+        bd->bdjstorage.no_persistent_storage = !v;
+    }
+
     BD_DEBUG(DBG_BLURAY, "BLURAY initialized!\n");
 
     return bd;
@@ -2767,6 +2775,14 @@ int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value)
         bd_mutex_unlock(&bd->mutex);
         return result;
     }
+    if (idx == BLURAY_PLAYER_SETTING_PERSISTENT_STORAGE) {
+        if (bd->title_type != title_undef) {
+            BD_DEBUG(DBG_BLURAY | DBG_CRIT, "Can't disable persistent storage during playback\n");
+            return 0;
+        }
+        bd->bdjstorage.no_persistent_storage = !value;
+        return 1;
+    }
 
     for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
         if (idx == map[i].idx) {
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index 73e142c..997f59d 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -665,7 +665,9 @@ typedef enum {
     BLURAY_PLAYER_SETTING_TEXT_CAP       = 30,    /* Text Subtitle capability.    Bit mask. */
     BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31,    /* Player profile and version. */
 
-    BLURAY_PLAYER_SETTING_DECODE_PG      = 0x100, /* Enable/disable PG (subtitle) decoder. Integer. */
+    BLURAY_PLAYER_SETTING_DECODE_PG          = 0x100, /* Enable/disable PG (subtitle) decoder. Integer. Default: disabled. */
+    BLURAY_PLAYER_SETTING_PERSISTENT_STORAGE = 0x101, /* Enable/disable BD-J persistent storage. Integer. Default: enabled. */
+
     BLURAY_PLAYER_PERSISTENT_ROOT        = 400,   /* Root path to the BD_J persistent storage location. String. */
     BLURAY_PLAYER_CACHE_ROOT             = 401,   /* Root path to the BD_J cache storage location. String. */
 } bd_player_setting;
diff --git a/src/libbluray/player_settings.h b/src/libbluray/player_settings.h
index 6709303..3a5f207 100644
--- a/src/libbluray/player_settings.h
+++ b/src/libbluray/player_settings.h
@@ -158,4 +158,22 @@ enum {
     BLURAY_PG_TEXTST_DECODER_ENABLE   = 1,  /* enable both decoders */
 };
 
+
+/*
+ * BLURAY_PLAYER_SETTING_PERSISTENT_STORAGE
+ *
+ * Enable / disable BD-J persistent storage.
+ *
+ * If persistent storage is disabled, BD-J Xlets can't access any data
+ * stored during earlier playback sessions. Persistent data stored during
+ * current playback session will be removed and can't be accessed later.
+ *
+ * This setting can't be changed after bd_play() has been called.
+ */
+
+enum {
+    BLURAY_PERSISTENT_STORAGE_DISABLE = 0,  /* disable persistent storage between playback sessions */
+    BLURAY_PERSISTENT_STORAGE_ENABLE  = 1,  /* enable persistent storage */
+};
+
 #endif /* BD_PLAYER_SETTINGS_H_ */



More information about the libbluray-devel mailing list