Commit 0141be51 authored by ace20022's avatar ace20022 Committed by hpi1

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

parent 35340052
- Fix animations in some BD-J menus. - Fix animations in some BD-J menus.
- Add player setting for persistent/cache root path.
2014-09-03: Version 0.6.2 2014-09-03: Version 0.6.2
- Fix possible subtitle corruption after seek. - Fix possible subtitle corruption after seek.
......
...@@ -254,10 +254,14 @@ static const char *_find_libbluray_jar(void) ...@@ -254,10 +254,14 @@ static const char *_find_libbluray_jar(void)
return classpath; return classpath;
} }
static const char *_bdj_persistent_root(void) static const char *_bdj_persistent_root(BDJ_STORAGE *storage)
{ {
static const char *root = NULL; static const char *root = NULL;
if (storage && storage->persistent_root) {
return storage->persistent_root;
}
if (root) { if (root) {
return root; return root;
} }
...@@ -278,10 +282,14 @@ static const char *_bdj_persistent_root(void) ...@@ -278,10 +282,14 @@ static const char *_bdj_persistent_root(void)
return root; return root;
} }
static const char *_bdj_buda_root(void) static const char *_bdj_buda_root(BDJ_STORAGE *storage)
{ {
static const char *root = NULL; static const char *root = NULL;
if (storage && storage->cache_root) {
return storage->cache_root;
}
if (root) { if (root) {
return root; return root;
} }
...@@ -383,7 +391,7 @@ static int _find_jvm(void *jvm_lib, JNIEnv **env, JavaVM **jvm) ...@@ -383,7 +391,7 @@ static int _find_jvm(void *jvm_lib, JNIEnv **env, JavaVM **jvm)
return 0; 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 */ (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 ...@@ -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); JavaVMOption* option = calloc(1, sizeof(JavaVMOption) * 20);
int n = 0; int n = 0;
JavaVMInitArgs args; JavaVMInitArgs args;
option[n++].optionString = str_printf("-Ddvb.persistent.root=%s", _bdj_persistent_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()); 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 ("-Dawt.toolkit=java.awt.BDToolkit");
option[n++].optionString = str_dup ("-Djava.awt.graphicsenv=java.awt.BDGraphicsEnvironment"); 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 ...@@ -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, 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"); BD_DEBUG(DBG_BDJ, "bdj_open()\n");
...@@ -467,7 +475,7 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd, ...@@ -467,7 +475,7 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,
JNIEnv* env = NULL; JNIEnv* env = NULL;
JavaVM *jvm = 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); dl_dlclose(jvm_lib);
return NULL; return NULL;
} }
......
...@@ -42,6 +42,11 @@ typedef enum { ...@@ -42,6 +42,11 @@ typedef enum {
BDJ_EVENT_RATE, BDJ_EVENT_RATE,
} BDJ_EVENT; } BDJ_EVENT;
typedef struct {
char *persistent_root;
char *cache_root;
} BDJ_STORAGE;
/* bdj_get_uo_mask() */ /* bdj_get_uo_mask() */
#define BDJ_MENU_CALL_MASK 0x01 #define BDJ_MENU_CALL_MASK 0x01
#define BDJ_TITLE_SEARCH_MASK 0x02 #define BDJ_TITLE_SEARCH_MASK 0x02
...@@ -55,7 +60,8 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int, ...@@ -55,7 +60,8 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int,
int, int, int, int); int, int, int, int);
BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd, 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 void bdj_close(BDJAVA *bdjava);
BD_PRIVATE int bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param); 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_get_uo_mask(BDJAVA *bdjava);
......
...@@ -159,6 +159,7 @@ struct bluray { ...@@ -159,6 +159,7 @@ struct bluray {
uint8_t hdmv_suspended; uint8_t hdmv_suspended;
#ifdef USING_BDJAVA #ifdef USING_BDJAVA
BDJAVA *bdjava; BDJAVA *bdjava;
BDJ_STORAGE *bdjstorage;
#endif #endif
/* delayed sending of BDJ_EVENT_END_OF_PLAYLIST: /* delayed sending of BDJ_EVENT_END_OF_PLAYLIST:
* 1 - message pending. 3 - message sent. */ * 1 - message pending. 3 - message sent. */
...@@ -1236,7 +1237,7 @@ static int _start_bdj(BLURAY *bd, unsigned title) ...@@ -1236,7 +1237,7 @@ static int _start_bdj(BLURAY *bd, unsigned title)
{ {
#ifdef USING_BDJAVA #ifdef USING_BDJAVA
if (bd->bdjava == NULL) { 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) { if (!bd->bdjava) {
return 0; return 0;
} }
...@@ -1283,6 +1284,19 @@ static void _close_bdj(BLURAY *bd) ...@@ -1283,6 +1284,19 @@ static void _close_bdj(BLURAY *bd)
#define _close_bdj(bd) do{}while(0) #define _close_bdj(bd) do{}while(0)
#endif #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 #ifdef HAVE_MNTENT_H
/* /*
* Replace device node (/dev/sr0) by mount point * Replace device node (/dev/sr0) by mount point
...@@ -1423,6 +1437,7 @@ void bd_close(BLURAY *bd) ...@@ -1423,6 +1437,7 @@ void bd_close(BLURAY *bd)
_free_event_queue(bd); _free_event_queue(bd);
X_FREE(bd->device_path); X_FREE(bd->device_path);
array_free((void**)&bd->titles); array_free((void**)&bd->titles);
_storage_free(bd);
bd_mutex_destroy(&bd->mutex); bd_mutex_destroy(&bd->mutex);
...@@ -2588,6 +2603,34 @@ int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s) ...@@ -2588,6 +2603,34 @@ int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s)
case BLURAY_PLAYER_SETTING_COUNTRY_CODE: case BLURAY_PLAYER_SETTING_COUNTRY_CODE:
return bd_set_player_setting(bd, idx, str_to_uint32(s, 2)); 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: default:
return 0; return 0;
} }
......
...@@ -561,6 +561,8 @@ typedef enum { ...@@ -561,6 +561,8 @@ typedef enum {
BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31, /* Profile1: 0, Profile1+: 1, Profile2: 3, Profile3: 8 */ 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_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; } bd_player_setting;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment