Commit c32862b7 authored by hpi1's avatar hpi1

Added bd_get_disc_info()

parent 01249ff5
......@@ -11,7 +11,7 @@ CFLAGS=$(shell test -z "$$CFLAGS" || echo "$$CFLAGS")
if USING_EXAMPLES
noinst_PROGRAMS=bdsplice mpls_dump clpi_dump index_dump mobj_dump sound_dump \
libbluray_test list_titles hdmv_test
libbluray_test bd_info list_titles hdmv_test
BLURAY_LIB = $(top_builddir)/src/libbluray.la
BLURAY_LIB_STATIC = $(top_builddir)/src/.libs/libbluray.a
......@@ -65,6 +65,11 @@ list_titles_SOURCES = \
list_titles_LDADD = $(BLURAY_LIB)
bd_info_SOURCES = \
bd_info.c
bd_info_LDADD = $(BLURAY_LIB)
if USING_BDJAVA
noinst_PROGRAMS+= bdj_test
bdj_test_SOURCES = bdj_test.c
......
/*
* This file is part of libbluray
* Copyright (C) 2009-2010 hpi1
*
* 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 HAVE_CONFIG_H
#include "config.h"
#endif
#include "libbluray/bluray.h"
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <unistd.h>
static const char *_yes_no(int i)
{
return i > 0 ? "yes" : i < 0 ? "unknown" : "no";
}
int main(int argc, char *argv[])
{
const char *disc_root = (argc > 1) ? argv[1] : NULL;
const char *keyfile = (argc > 2) ? argv[2] : NULL;
if (!disc_root) {
fprintf(stderr,
"%s <BD base dir> [keyfile]\n"
" Show BD disc info\n",
argv[0]);
exit(EXIT_FAILURE);
}
BLURAY *bd = bd_open(disc_root, keyfile);
if (!bd) {
fprintf(stderr, "bd_open('%s', '%s') failed.\n", disc_root, keyfile);
exit(EXIT_FAILURE);
}
const BLURAY_DISC_INFO *info = bd_get_disc_info(bd);
if (!info) {
fprintf(stderr, "bd_get_disc_info() failed.\n");
exit(EXIT_FAILURE);
}
printf("BluRay detected : %s\n", _yes_no(info->bluray_detected));
if (info->bluray_detected) {
printf("First Play supported: %s\n", _yes_no(info->first_play_supported));
printf("Top menu supported : %s\n", _yes_no(info->top_menu_supported));
printf("HDMV titles : %d\n", info->num_hdmv_titles);
printf("BD-J titles : %d\n", info->num_bdj_titles);
printf("UNSUPPORTED titles : %d\n", info->num_unsupported_titles);
}
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));
}
printf("\nBD+ detected : %s\n", _yes_no(info->bdplus_detected));
if (info->bdplus_detected) {
printf("libbdplus detected : %s\n", _yes_no(info->libbdplus_detected));
printf("BD+ handled : %s\n", _yes_no(info->bdplus_handled));
}
return 0;
}
......@@ -87,9 +87,10 @@ typedef struct {
struct bluray {
/* current disc */
char *device_path;
INDX_ROOT *index;
NAV_TITLE_LIST *title_list;
char *device_path;
BLURAY_DISC_INFO disc_info;
INDX_ROOT *index;
NAV_TITLE_LIST *title_list;
/* current playlist */
NAV_TITLE *title;
......@@ -437,10 +438,12 @@ static int _libaacs_required(BLURAY *bd)
file_close(fd);
DEBUG(DBG_BLURAY, "AACS/Unit_Key_RO.inf found. Disc seems to be AACS protected (%p)\n", bd);
bd->disc_info.aacs_detected = 1;
return 1;
}
DEBUG(DBG_BLURAY, "AACS/Unit_Key_RO.inf not found. No AACS protection (%p)\n", bd);
bd->disc_info.aacs_detected = 0;
return 0;
}
......@@ -451,6 +454,7 @@ static int _libaacs_load(BLURAY *bd)
return 1;
}
bd->disc_info.libaacs_detected = 0;
if ((bd->h_libaacs = dl_dlopen("libaacs", "0"))) {
DEBUG(DBG_BLURAY, "Loading libaacs (%p)\n", bd->h_libaacs);
......@@ -460,6 +464,7 @@ static int _libaacs_load(BLURAY *bd)
if (bd->libaacs_open && bd->libaacs_decrypt_unit) {
DEBUG(DBG_BLURAY, "Loaded libaacs (%p)\n", bd->h_libaacs);
bd->disc_info.libaacs_detected = 1;
return 1;
} else {
......@@ -479,6 +484,7 @@ static int _libaacs_load(BLURAY *bd)
bd->libaacs_open = &aacs_open;
bd->libaacs_decrypt_unit = &aacs_decrypt_unit;
bd->disc_info.libaacs_detected = 1;
return 1;
#endif
......@@ -502,10 +508,12 @@ static int _libaacs_open(BLURAY *bd, const char *keyfile_path)
if (bd->aacs) {
DEBUG(DBG_BLURAY, "Opened libaacs (%p)\n", bd->aacs);
bd->disc_info.aacs_handled = 1;
return 1;
}
DEBUG(DBG_BLURAY, "aacs_open() failed!\n");
bd->disc_info.aacs_handled = 0;
_libaacs_unload(bd);
return 0;
......@@ -548,10 +556,12 @@ static int _libbdplus_required(BLURAY *bd)
file_close(fd);
DEBUG(DBG_BLURAY, "BDSVM/00000.svm found. Disc seems to be BD+ protected (%p)\n", bd);
bd->disc_info.bdplus_detected = 1;
return 1;
}
DEBUG(DBG_BLURAY, "BDSVM/00000.svm not found. No BD+ protection (%p)\n", bd);
bd->disc_info.bdplus_detected = 0;
return 0;
}
......@@ -564,6 +574,7 @@ static int _libbdplus_load(BLURAY *bd)
return 1;
}
bd->disc_info.libbdplus_detected = 0;
if ((bd->h_libbdplus = dl_dlopen("libbdplus", "0"))) {
DEBUG(DBG_BLURAY, "Loading libbdplus (%p)\n", bd->h_libbdplus);
......@@ -574,6 +585,7 @@ static int _libbdplus_load(BLURAY *bd)
if (bd->bdplus_init && bd->bdplus_seek && bd->bdplus_fixup) {
DEBUG(DBG_BLURAY, "Loaded libbdplus (%p)\n", bd->h_libbdplus);
bd->disc_info.libbdplus_detected = 1;
return 1;
}
......@@ -593,6 +605,7 @@ static int _libbdplus_load(BLURAY *bd)
bd->bdplus_init = &bdplus_init;
bd->bdplus_seek = &bdplus_seek;
bd->bdplus_fixup = &bdplus_fixup;
bd->disc_info.libbdplus_detected = 1;
return 1;
#endif
......@@ -622,10 +635,12 @@ static int _libbdplus_open(BLURAY *bd, const char *keyfile_path)
if (bd->bdplus) {
DEBUG(DBG_BLURAY,"libbdplus initialized\n");
bd->disc_info.bdplus_handled = 1;
return 1;
}
DEBUG(DBG_BLURAY,"bdplus_init() failed\n");
bd->disc_info.bdplus_handled = 0;
_libbdplus_unload(bd);
return 0;
......@@ -648,6 +663,56 @@ static int _index_open(BLURAY *bd)
return !!bd->index;
}
/*
* disc info
*/
const BLURAY_DISC_INFO *bd_get_disc_info(BLURAY *bd)
{
return &bd->disc_info;
}
static void _fill_disc_info(BLURAY *bd)
{
bd->disc_info.bluray_detected = 0;
bd->disc_info.top_menu_supported = 0;
bd->disc_info.first_play_supported = 0;
bd->disc_info.num_hdmv_titles = 0;
bd->disc_info.num_bdj_titles = 0;
bd->disc_info.num_unsupported_titles = 0;
if (bd->index) {
INDX_PLAY_ITEM *pi;
unsigned ii;
bd->disc_info.bluray_detected = 1;
pi = &bd->index->first_play;
if (pi->object_type == indx_object_type_hdmv && pi->hdmv.id_ref != 0xffff) {
bd->disc_info.first_play_supported = 1;
}
pi = &bd->index->top_menu;
if (pi->object_type == indx_object_type_hdmv && pi->hdmv.id_ref != 0xffff) {
bd->disc_info.top_menu_supported = 1;
}
for (ii = 0; ii < bd->index->num_titles; ii++) {
if (bd->index->titles[ii].object_type == indx_object_type_hdmv) {
bd->disc_info.num_hdmv_titles++;
}
if (bd->index->titles[ii].object_type == indx_object_type_bdj) {
bd->disc_info.num_bdj_titles++;
bd->disc_info.num_unsupported_titles++;
}
}
}
}
/*
* open / close
*/
BLURAY *bd_open(const char* device_path, const char* keyfile_path)
{
BLURAY *bd = calloc(1, sizeof(BLURAY));
......@@ -665,6 +730,8 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path)
bd->regs = bd_registers_init();
_fill_disc_info(bd);
DEBUG(DBG_BLURAY, "BLURAY initialized! (%p)\n", bd);
} else {
X_FREE(bd);
......
......@@ -365,6 +365,32 @@ uint64_t bd_tell(BLURAY *bd);
*/
uint64_t bd_tell_time(BLURAY *bd);
/*
* Disc info
*/
typedef struct {
uint8_t bluray_detected;
uint8_t first_play_supported;
uint8_t top_menu_supported;
uint32_t num_hdmv_titles;
uint32_t num_bdj_titles;
uint32_t num_unsupported_titles;
uint8_t aacs_detected;
uint8_t libaacs_detected;
uint8_t aacs_handled;
uint8_t bdplus_detected;
uint8_t libbdplus_detected;
uint8_t bdplus_handled;
} BLURAY_DISC_INFO;
const BLURAY_DISC_INFO *bd_get_disc_info(BLURAY*);
/*
* player settings
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment