[libbluray-devel] [PATCH] API: add function to check whether BD-J is functional.

Andreas Zelend ace at kodi.tv
Sun Apr 9 13:13:13 CEST 2017


From: ace20022 <ace20022 at ymail.com>

---
 src/libbluray/bdj/bdj.c | 14 ++++++++++++++
 src/libbluray/bdj/bdj.h |  1 +
 src/libbluray/bluray.c  | 10 ++++++++++
 src/libbluray/bluray.h  | 13 +++++++++++++
 4 files changed, 38 insertions(+)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index eeb3040f..8c6708f0 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -631,6 +631,20 @@ static int _bdj_init(JNIEnv *env, struct bluray *bd, const char *disc_root, cons
     return 1;
 }
 
+int bdj_functional()
+{
+  BDJ_STORAGE* bds = calloc(1, sizeof(BDJ_STORAGE));
+  if (!bds) {
+    BD_DEBUG(DBG_CRIT, "out of memory\n");
+    return 0;
+  }
+
+  int ret = bdj_jvm_available(bds);
+  X_FREE(bds);
+
+  return ret;
+}
+
 int bdj_jvm_available(BDJ_STORAGE *storage)
 {
     const char *java_home;
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index 789e7fee..748c9917 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -81,5 +81,6 @@ BD_PRIVATE void bdj_close(BDJAVA *bdjava);
 BD_PRIVATE int  bdj_process_event(BDJAVA *bdjava, unsigned ev, unsigned param);
 
 BD_PRIVATE int  bdj_jvm_available(BDJ_STORAGE *storage); /* 0: no. 1: only jvm. 2: jvm + libbluray.jar. */
+BD_PRIVATE int  bdj_functional(); /* wrapper for bdj_jvm_available without a specific disc*/
 
 #endif
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 4eddac0f..9dd2577c 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -3862,3 +3862,13 @@ void bd_free_bdjo(struct bdjo_data *obj)
     (void)obj;
 #endif
 }
+
+int bd_bdj_functional()
+{
+#ifdef USING_BDJAVA
+  return bdj_functional();
+#else
+  return -1;
+#endif
+
+}
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index e53a9779..53ea1abe 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -1086,6 +1086,19 @@ void bd_stop_bdj(BLURAY *bd); // shutdown BD-J and clean up resources
  */
 int bd_read_file(BLURAY *, const char *path, void **data, int64_t *size);
 
+/**
+*
+*  Check if BD-J is functional
+*
+*  Checks whether BD-J support was compiled in and if so
+*  whether jvm and/or libbluray.jar is usable or not.
+*
+* @return -1 if BD-J support was not compiled in,
+*         0: JVM library could not be loaded
+*         1: only the JVM library could be loaded
+*         2: the JVM library and the libbluray.jar could be loaded
+*/
+int bd_bdj_functional();
 
 #ifdef __cplusplus
 }
-- 
2.12.0.windows.1



More information about the libbluray-devel mailing list