[libbluray-devel] [PATCH] API: add function to check whether BD-J is functional.
Petri Hintukainen
phintuka at users.sourceforge.net
Mon Apr 10 12:16:15 CEST 2017
Hello,
We can add this to API if it would be useful. Maybe it would be more
generic if it would return ex. bit mask of available features (BD-J,
JVM, JAR, UDF, metadata, ...). Would there be any real use for the
other flags ?
Do you need to know BD-J status before opening the disc ? vlc/xine do
similar check between bd_open() and bd_play() , and pop up a message or
play the disc without menus if BD-J or some other required feature is
missing.
We could also make existing API to work without opening the disc. This
information is in BLURAY_DISC_INFO. Something like:
BLURAY *bd = bd_init();
const BLURAY_DISC_INFO *info = bd_get_disc_info(bd);
if (!info->bdj_handled) {
...
}
Currently these fields are not initialized if bd_open*() was not
called, but that's easy to fix.
Before adding new API for this I'd like to discuss about simplifying
the build configuration. I think we could unconditionally build BD-J
and UDF support into the library. That does not add any new
dependencies, and code size increase is not that big. Any opinions ?
su, 2017-04-09 kello 13:13 +0200, Andreas Zelend kirjoitti:
> 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
> }
More information about the libbluray-devel
mailing list