[libbluray-devel] Provide VID for BD-J

hpi1 git at videolan.org
Thu Dec 20 22:40:35 CET 2012


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Dec 20 11:37:00 2012 +0200| [b7fb8a4eae78104b8fad114bb2c9b29deb919113] | committer: hpi1

Provide VID for BD-J

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

 src/Makefile.am                                    |    1 +
 .../com/aacsla/bluray/online/MediaAttribute.java   |    5 ++--
 src/libbluray/bdj/java/org/videolan/Libbluray.java |    5 ++++
 src/libbluray/bdj/native/org_videolan_Libbluray.c  |   24 +++++++++++++++
 src/libbluray/bdj/native/org_videolan_Libbluray.h  |    9 ++++++
 src/libbluray/bluray.c                             |    6 ++--
 src/libbluray/bluray_internal.h                    |   31 ++++++++++++++++++++
 7 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 0bb7ee4..9677e4d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ lib_LTLIBRARIES=libbluray.la
 libbluray_ladir= $(includedir)/libbluray
 libbluray_la_SOURCES=libbluray/bluray.h \
 	libbluray/bluray.c \
+	libbluray/bluray_internal.h \
 	libbluray/register.h \
 	libbluray/register.c \
 	libbluray/keys.h \
diff --git a/src/libbluray/bdj/java/com/aacsla/bluray/online/MediaAttribute.java b/src/libbluray/bdj/java/com/aacsla/bluray/online/MediaAttribute.java
index 7aab022..9b45760 100644
--- a/src/libbluray/bdj/java/com/aacsla/bluray/online/MediaAttribute.java
+++ b/src/libbluray/bdj/java/com/aacsla/bluray/online/MediaAttribute.java
@@ -19,6 +19,7 @@
 
 package com.aacsla.bluray.online;
 
+import org.videolan.Libbluray;
 import org.videolan.Logger;
 
 public class MediaAttribute {
@@ -32,9 +33,7 @@ public class MediaAttribute {
     }
 
     public byte[] getVolumeID() {
-        // TODO
-        logger.unimplemented("getVolumeID");
-        return null;
+        return Libbluray.getVolumeID();
     }
 
     private static final Logger logger = Logger.getLogger(MediaAttribute.class.getName());
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index a60ead5..16387a1 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -130,6 +130,10 @@ public class Libbluray {
         nativePointer = 0;
     }
 
+    public static byte[] getVolumeID() {
+        return getVolumeIDN(nativePointer);
+    }
+
     public static int getTitles() {
         return getTitlesN(nativePointer);
     }
@@ -383,6 +387,7 @@ public class Libbluray {
     public static final int PSR_BACKUP_PSR11     = 43;
     public static final int PSR_BACKUP_PSR12     = 44;
 
+    private static native byte[] getVolumeIDN(long np);
     private static native TitleInfo getTitleInfoN(long np, int title);
     private static native PlaylistInfo getPlaylistInfoN(long np, int playlist);
     private static native int getTitlesN(long np);
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index 8cb9b91..4c30478 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -26,12 +26,15 @@
 #include "libbluray/bdj/bdjo_parser.h"
 #include "libbluray/register.h"
 #include "libbluray/bluray.h"
+#include "libbluray/bluray_internal.h"
 
 #include "util/strutl.h"
 #include "util/macro.h"
 
 #include "org_videolan_Libbluray.h"
 
+#include <string.h>
+
 /* Disable some warnings */
 #if defined __GNUC__
 #pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -173,6 +176,22 @@ JNIEXPORT jobject JNICALL Java_org_videolan_Libbluray_getPlaylistInfoN
 }
 
 static
+JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getVolumeIDN
+  (JNIEnv * env, jclass cls, jlong np)
+{
+    BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
+    const uint8_t *vid = bd_get_vid(bdj->bd);
+
+    static const uint8_t empty[16] = {0};
+    if (!vid || !memcmp(vid, empty, sizeof(empty))) {
+        return NULL;
+    }
+    jbyteArray array = (*env)->NewByteArray(env, 16);
+    (*env)->SetByteArrayRegion(env, array, 0, 16, (const jbyte *)vid);
+    return array;
+}
+
+static
 JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_getTitlesN(JNIEnv * env,
                                                               jclass cls, jlong np) {
     BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
@@ -350,6 +369,11 @@ BD_PRIVATE const JNINativeMethod
 Java_org_videolan_Libbluray_methods[] =
 { /* AUTOMATICALLY GENERATED */
     {
+        CC("getVolumeIDN"),
+        CC("(J)[B"),
+        Java_org_videolan_Libbluray_getVolumeIDN,
+    },
+    {
         CC("getTitleInfoN"),
         CC("(JI)Lorg/videolan/TitleInfo;"),
         Java_org_videolan_Libbluray_getTitleInfoN,
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.h b/src/libbluray/bdj/native/org_videolan_Libbluray.h
index ec6c985..a650c9a 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.h
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.h
@@ -89,6 +89,15 @@ extern "C" {
 #define org_videolan_Libbluray_PSR_BACKUP_PSR12 44L
 /*
  * Class:     org_videolan_Libbluray
+ * Method:    getVolumeIDN
+ * Signature: (J)[B
+ */
+static
+JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getVolumeIDN
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_videolan_Libbluray
  * Method:    getTitleInfoN
  * Signature: (JI)Lorg/videolan/TitleInfo;
  */
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 9d3ddfa..5dca951 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -25,6 +25,7 @@
 
 #include "bluray-version.h"
 #include "bluray.h"
+#include "bluray_internal.h"
 #include "register.h"
 #include "util/macro.h"
 #include "util/logging.h"
@@ -790,8 +791,9 @@ static int _libaacs_open(BLURAY *bd, const char *keyfile_path)
     return 0;
 }
 
-static const uint8_t *_libaacs_get_vid(BLURAY *bd)
+const uint8_t *bd_get_vid(BLURAY *bd)
 {
+    /* internal function. Used by BD-J and libbdplus loader. */
     if (bd->aacs) {
         fptr_p_void fptr;
         *(void **)(&fptr) = dl_dlsym(bd->h_libaacs, "aacs_get_vid");
@@ -904,7 +906,7 @@ static int _libbdplus_open(BLURAY *bd, const char *keyfile_path)
         return 0;
     }
 
-    const uint8_t *aacs_vid = _libaacs_get_vid(bd);
+    const uint8_t *aacs_vid = bd_get_vid(bd);
     bd->bdplus = bd->bdplus_init(bd->device_path, keyfile_path, aacs_vid ? aacs_vid : vid);
 
     if (bd->bdplus) {
diff --git a/src/libbluray/bluray_internal.h b/src/libbluray/bluray_internal.h
new file mode 100644
index 0000000..e300ec4
--- /dev/null
+++ b/src/libbluray/bluray_internal.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of libbluray
+ * Copyright (C) 2012  libbluray
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(_BLURAY_INTERNAL_H_)
+#define _BLURAY_INTERNAL_H_
+
+#include <util/attributes.h>
+
+#include "bluray.h"
+
+#include <stdint.h>
+
+BD_PRIVATE const uint8_t *bd_get_vid(BLURAY *bd);
+
+#endif  /* _BLURAY_INTERNAL_H_ */



More information about the libbluray-devel mailing list