[libbluray-devel] Implement DeviceAttribute
hpi1
git at videolan.org
Fri Apr 26 12:01:54 CEST 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Apr 26 12:39:36 2013 +0300| [2fa7218a67f70eccddadcdb91223b3935db527f3] | committer: hpi1
Implement DeviceAttribute
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=2fa7218a67f70eccddadcdb91223b3935db527f3
---
.../com/aacsla/bluray/online/DeviceAttribute.java | 11 +++++-----
src/libbluray/bdj/java/org/videolan/Libbluray.java | 5 +++++
src/libbluray/bdj/native/org_videolan_Libbluray.c | 21 ++++++++++++++++++++
src/libbluray/bdj/native/org_videolan_Libbluray.h | 8 ++++++++
src/libbluray/bluray.c | 17 ++++++++++++++++
src/libbluray/bluray_internal.h | 1 +
6 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/src/libbluray/bdj/java/com/aacsla/bluray/online/DeviceAttribute.java b/src/libbluray/bdj/java/com/aacsla/bluray/online/DeviceAttribute.java
index 9f9c696..c9d2ef5 100644
--- a/src/libbluray/bdj/java/com/aacsla/bluray/online/DeviceAttribute.java
+++ b/src/libbluray/bdj/java/com/aacsla/bluray/online/DeviceAttribute.java
@@ -19,6 +19,7 @@
package com.aacsla.bluray.online;
+import org.videolan.Libbluray;
import org.videolan.Logger;
public class DeviceAttribute {
@@ -26,10 +27,10 @@ public class DeviceAttribute {
}
public byte[] getDeviceBindingID() {
- // TODO
- logger.unimplemented("getDeviceBindingID");
- return null;
+ byte bid[] = Libbluray.getDeviceBindingID();
+ if (bid == null) {
+ Logger.getLogger(DeviceAttribute.class.getName()).warning("getDeviceBindingID() failed");
+ }
+ return bid;
}
-
- private static final Logger logger = Logger.getLogger(DeviceAttribute.class.getName());
}
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 8ab3cb2..0afab9b 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -142,6 +142,10 @@ public class Libbluray {
return getPMSNN(nativePointer);
}
+ public static byte[] getDeviceBindingID() {
+ return getDeviceBindingIDN(nativePointer);
+ }
+
public static int getTitles() {
return getTitlesN(nativePointer);
}
@@ -410,6 +414,7 @@ public class Libbluray {
private static native byte[] getVolumeIDN(long np);
private static native byte[] getPMSNN(long np);
+ private static native byte[] getDeviceBindingIDN(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 5ff9477..7913834 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -217,6 +217,22 @@ JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getPMSNN
return array;
}
+JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getDeviceBindingIDN
+ (JNIEnv * env, jclass cls, jlong np)
+{
+ BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
+ const uint8_t *bid = bd_get_device_binding_id(bdj->bd);
+
+ static const uint8_t empty[16] = {0};
+ if (!bid || !memcmp(bid, empty, sizeof(empty))) {
+ return NULL;
+ }
+ jbyteArray array = (*env)->NewByteArray(env, 16);
+ (*env)->SetByteArrayRegion(env, array, 0, 16, (const jbyte *)bid);
+ return array;
+}
+
+
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_getTitlesN(JNIEnv * env,
jclass cls, jlong np) {
BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
@@ -466,6 +482,11 @@ Java_org_videolan_Libbluray_methods[] =
VC(Java_org_videolan_Libbluray_getPMSNN),
},
{
+ CC("getDeviceBindingIDN"),
+ CC("(J)[B"),
+ VC(Java_org_videolan_Libbluray_getDeviceBindingIDN),
+ },
+ {
CC("getTitleInfoN"),
CC("(JI)Lorg/videolan/TitleInfo;"),
VC(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 ab87c7a..dcf2496 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.h
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.h
@@ -110,6 +110,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getPMSNN
/*
* Class: org_videolan_Libbluray
+ * Method: getDeviceBindingIDN
+ * Signature: (J)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_videolan_Libbluray_getDeviceBindingIDN
+ (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 7ed969b..7351c75 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -926,6 +926,23 @@ const uint8_t *bd_get_pmsn(BLURAY *bd)
return NULL;
}
+const uint8_t *bd_get_device_binding_id(BLURAY *bd)
+{
+ /* internal function. Used by BD-J. */
+ if (bd->aacs) {
+ fptr_p_void fptr;
+ *(void **)(&fptr) = dl_dlsym(bd->h_libaacs, "aacs_get_device_binding_id");
+ if (fptr) {
+ return (const uint8_t*)fptr(bd->aacs);
+ }
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "aacs_get_device_binding_id() dlsym failed!");
+ return NULL;
+ }
+
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "bd_get_device_binding_id(): libaacs not initialized!");
+ return NULL;
+}
+
static void _libbdplus_close(BLURAY *bd)
{
if (bd->bdplus) {
diff --git a/src/libbluray/bluray_internal.h b/src/libbluray/bluray_internal.h
index 82c24d2..bfb2c12 100644
--- a/src/libbluray/bluray_internal.h
+++ b/src/libbluray/bluray_internal.h
@@ -28,5 +28,6 @@
BD_PRIVATE const uint8_t *bd_get_vid(BLURAY *bd);
BD_PRIVATE const uint8_t *bd_get_pmsn(BLURAY *bd);
+BD_PRIVATE const uint8_t *bd_get_device_binding_id(BLURAY *bd);
#endif /* _BLURAY_INTERNAL_H_ */
More information about the libbluray-devel
mailing list