[libbluray-devel] Added mkb version and disc id to BD_DISC_INFO
npzacs
git at videolan.org
Tue May 1 21:11:35 CEST 2012
libbluray | branch: master | npzacs <npzacs at gmail.com> | Tue May 1 22:10:27 2012 +0300| [bbb6283b27fcb507a2e2f80b6b77bd150d486f82] | committer: npzacs
Added mkb version and disc id to BD_DISC_INFO
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=bbb6283b27fcb507a2e2f80b6b77bd150d486f82
---
src/examples/bd_info.c | 37 ++++++++++++++++++++++++++++++++++++-
src/libbluray/bluray.c | 19 +++++++++++++++----
src/libbluray/bluray.h | 5 +++++
3 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/src/examples/bd_info.c b/src/examples/bd_info.c
index ad186bb..069e1b0 100644
--- a/src/examples/bd_info.c
+++ b/src/examples/bd_info.c
@@ -50,6 +50,34 @@ static const char *_num2str(int i)
return "<undefined>";
}
+static const char *_hex2str(const uint8_t *data, size_t len)
+{
+ static char *str = NULL;
+ size_t i;
+
+ str = realloc(str, len + 1);
+ *str = 0;
+
+ for (i = 0; i < len; i++) {
+ sprintf(str+2*i, "%02X", data[i]);
+ }
+
+ return str;
+}
+
+static const char *_aacs_error2str(int error_code)
+{
+ switch (error_code) {
+ case BD_AACS_CORRUPTED_DISC: return "corrupted BluRay disc";
+ case BD_AACS_NO_CONFIG: return "AACS configuration file missing";
+ case BD_AACS_NO_PK: return "no matching processing key";
+ case BD_AACS_NO_CERT: return "no valid AACS certificate";
+ case BD_AACS_CERT_REVOKED: return "AACS certificate revoked";
+ case BD_AACS_MMC_FAILED: return "MMC authentication failed";
+ }
+ return "unknown error";
+}
+
static const char *_res2str(int x, int y)
{
if (x > 0 && y > 0 && x < 0xffff && y < 0xffff) {
@@ -130,7 +158,14 @@ int main(int argc, char *argv[])
printf("\nAACS detected : %s\n", _yes_no(info->aacs_detected));
if (info->aacs_detected) {
printf("libaacs detected : %s\n", _yes_no(info->libaacs_detected));
- printf("AACS handled : %s\n", _yes_no(info->aacs_handled));
+ if (info->libaacs_detected) {
+ printf("Disc ID : %s\n", _hex2str(info->disc_id, sizeof(info->disc_id)));
+ printf("AACS MKB version : %d\n", info->aacs_mkbv);
+ printf("AACS handled : %s\n", _yes_no(info->aacs_handled));
+ if (!info->aacs_handled) {
+ printf(" (%s)\n", _aacs_error2str(info->aacs_error_code));
+ }
+ }
}
printf("\nBD+ detected : %s\n", _yes_no(info->bdplus_detected));
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index e1b333c..141a9b9 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -710,10 +710,21 @@ static int _libaacs_open(BLURAY *bd, const char *keyfile_path)
bd->aacs = aacs_open2(bd->device_path, keyfile_path, &error_code);
}
- if (bd->aacs && !error_code) {
- BD_DEBUG(DBG_BLURAY, "Opened libaacs (%p)\n", bd->aacs);
- bd->disc_info.aacs_handled = 1;
- return 1;
+ if (bd->aacs) {
+ fptr_int aacs_get_mkb_version = (fptr_int) dl_dlsym(bd->h_libaacs, "aacs_get_mkb_version");
+ fptr_p_void aacs_get_disc_id = (fptr_p_void) dl_dlsym(bd->h_libaacs, "aacs_get_disc_id");
+ if (aacs_get_mkb_version) {
+ bd->disc_info.aacs_mkbv = aacs_get_mkb_version(bd->aacs);
+ }
+ if (aacs_get_disc_id) {
+ memcpy(bd->disc_info.disc_id, aacs_get_disc_id(bd->aacs), 20);
+ }
+
+ if (!error_code) {
+ BD_DEBUG(DBG_BLURAY, "Opened libaacs (%p)\n", bd->aacs);
+ bd->disc_info.aacs_handled = 1;
+ return 1;
+ }
}
BD_DEBUG(DBG_BLURAY, "aacs_open() failed!\n");
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index 067e061..411443f 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -435,6 +435,11 @@ typedef struct {
/* aacs error code */
int aacs_error_code;
+ /* aacs MKB version */
+ int aacs_mkbv;
+
+ /* Disc ID */
+ uint8_t disc_id[20];
} BLURAY_DISC_INFO;
More information about the libbluray-devel
mailing list