|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2009-2010 hpi1
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include <stdio.h>
|
|
Packit |
5e46da |
#include <stdlib.h>
|
|
Packit |
5e46da |
#include <inttypes.h>
|
|
Packit |
5e46da |
#include <unistd.h>
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "bdnav/meta_data.h"
|
|
Packit |
5e46da |
#include "bluray.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_yes_no(int i)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
return i > 0 ? "yes" : i < 0 ? "unknown" : "no";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_str_chk_null(const char *s)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
return s ? s : "<undefined>";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_num2str(int i)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
if (i > 0 && i < 0xff) {
|
|
Packit |
5e46da |
static char str[32];
|
|
Packit |
5e46da |
sprintf(str, "%d", i);
|
|
Packit |
5e46da |
return str;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return "<undefined>";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_hex2str(const uint8_t *data, size_t len)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
static char *str = NULL;
|
|
Packit |
5e46da |
size_t i;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
str = (char*)realloc(str, 2*len + 1);
|
|
Packit |
5e46da |
*str = 0;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
for (i = 0; i < len; i++) {
|
|
Packit |
5e46da |
sprintf(str+2*i, "%02X", data[i]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return str;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_aacs_error2str(int error_code)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
switch (error_code) {
|
|
Packit |
5e46da |
case BD_AACS_CORRUPTED_DISC: return "corrupted BluRay disc";
|
|
Packit |
5e46da |
case BD_AACS_NO_CONFIG: return "AACS configuration file missing";
|
|
Packit |
5e46da |
case BD_AACS_NO_PK: return "no matching processing key";
|
|
Packit |
5e46da |
case BD_AACS_NO_CERT: return "no valid AACS certificate";
|
|
Packit |
5e46da |
case BD_AACS_CERT_REVOKED: return "AACS certificate revoked";
|
|
Packit |
5e46da |
case BD_AACS_MMC_FAILED: return "MMC authentication failed";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
return "unknown error";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char *_res2str(int x, int y)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
if (x > 0 && y > 0 && x < 0xffff && y < 0xffff) {
|
|
Packit |
5e46da |
static char str[64];
|
|
Packit |
5e46da |
sprintf(str, "%dx%d", x, y);
|
|
Packit |
5e46da |
return str;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return "";
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _print_meta(const META_DL *meta)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
if (!meta) {
|
|
Packit |
5e46da |
printf("\nNo disc library metadata\n");
|
|
Packit |
5e46da |
return;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
unsigned ii;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\nDisc library metadata:\n");
|
|
Packit |
5e46da |
printf("Metadata file : %s\n", _str_chk_null(meta->filename));
|
|
Packit |
5e46da |
printf("Language : %s\n", _str_chk_null(meta->language_code));
|
|
Packit |
5e46da |
printf("Disc name : %s\n", _str_chk_null(meta->di_name));
|
|
Packit |
5e46da |
printf("Alternative : %s\n", _str_chk_null(meta->di_alternative));
|
|
Packit |
5e46da |
printf("Disc # : %s/%s\n", _num2str(meta->di_set_number), _num2str(meta->di_num_sets));
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("TOC count : %d\n", meta->toc_count);
|
|
Packit |
5e46da |
for (ii = 0; ii < meta->toc_count; ii++) {
|
|
Packit |
5e46da |
printf("\tTitle %d: %s\n",
|
|
Packit |
5e46da |
meta->toc_entries[ii].title_number,
|
|
Packit |
5e46da |
_str_chk_null(meta->toc_entries[ii].title_name));
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("Thumbnail count : %d\n", meta->thumb_count);
|
|
Packit |
5e46da |
for (ii = 0; ii < meta->thumb_count; ii++) {
|
|
Packit |
5e46da |
printf("\t%s \t%s\n",
|
|
Packit |
5e46da |
_str_chk_null(meta->thumbnails[ii].path),
|
|
Packit |
5e46da |
_res2str(meta->thumbnails[ii].xres, meta->thumbnails[ii].yres));
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _print_app_info(const BLURAY_DISC_INFO *info)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
static const char video_format_str[16][8] = {
|
|
Packit |
5e46da |
"ignored", "480i", "576i", "480p", "1080i", "720p", "1080p", "576p"
|
|
Packit |
5e46da |
};
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static const char frame_rate_str[16][16] = {
|
|
Packit |
5e46da |
"ignored",
|
|
Packit |
5e46da |
"23.976 Hz",
|
|
Packit |
5e46da |
"24 Hz",
|
|
Packit |
5e46da |
"25 Hz",
|
|
Packit |
5e46da |
"29.97 Hz",
|
|
Packit |
5e46da |
"reserved",
|
|
Packit |
5e46da |
"50 Hz",
|
|
Packit |
5e46da |
"59.94 Hz"
|
|
Packit |
5e46da |
};
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\nApplication info:\n");
|
|
Packit |
5e46da |
printf(" initial mode preference : %s\n", info->initial_output_mode_preference ? "3D" : "2D");
|
|
Packit |
5e46da |
printf(" 3D content exists : %s\n", info->content_exist_3D ? "Yes" : "No");
|
|
Packit |
5e46da |
printf(" video format : %s (0x%x)\n", video_format_str[info->video_format & 0xf], info->video_format);
|
|
Packit |
5e46da |
printf(" frame rate : %s (0x%x)\n", frame_rate_str[info->frame_rate & 0xf], info->frame_rate);
|
|
Packit |
5e46da |
printf(" provider data : \'%32s\'\n", info->provider_data);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
int main(int argc, char *argv[])
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
int major, minor, micro;
|
|
Packit |
5e46da |
const char *disc_root = (argc > 1) ? argv[1] : NULL;
|
|
Packit |
5e46da |
const char *keyfile = (argc > 2) ? argv[2] : NULL;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_get_version(&major, &minor, µ);
|
|
Packit |
5e46da |
printf("Using libbluray version %d.%d.%d\n", major, minor, micro);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (!disc_root) {
|
|
Packit |
5e46da |
fprintf(stderr,
|
|
Packit |
5e46da |
"%s <BD base dir> [keyfile]\n"
|
|
Packit |
5e46da |
" Show BD disc info\n",
|
|
Packit |
5e46da |
argv[0]);
|
|
Packit |
5e46da |
exit(EXIT_FAILURE);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BLURAY *bd = bd_open(disc_root, keyfile);
|
|
Packit |
5e46da |
if (!bd) {
|
|
Packit |
5e46da |
fprintf(stderr, "bd_open('%s', '%s') failed.\n", disc_root, keyfile);
|
|
Packit |
5e46da |
exit(EXIT_FAILURE);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
const BLURAY_DISC_INFO *info = bd_get_disc_info(bd);
|
|
Packit |
5e46da |
if (!info) {
|
|
Packit |
5e46da |
fprintf(stderr, "bd_get_disc_info() failed.\n");
|
|
Packit |
5e46da |
exit(EXIT_FAILURE);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (info->udf_volume_id) {
|
|
Packit |
5e46da |
printf("Volume Identifier : %s\n", info->udf_volume_id);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
printf("BluRay detected : %s\n", _yes_no(info->bluray_detected));
|
|
Packit |
5e46da |
if (info->bluray_detected) {
|
|
Packit |
5e46da |
printf("First Play supported: %s\n", _yes_no(info->first_play_supported));
|
|
Packit |
5e46da |
printf("Top menu supported : %s\n", _yes_no(info->top_menu_supported));
|
|
Packit |
5e46da |
printf("HDMV titles : %d\n", info->num_hdmv_titles);
|
|
Packit |
5e46da |
printf("BD-J titles : %d\n", info->num_bdj_titles);
|
|
Packit |
5e46da |
printf("UNSUPPORTED titles : %d\n", info->num_unsupported_titles);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\nBD-J detected : %s\n", _yes_no(info->bdj_detected));
|
|
Packit |
5e46da |
if (info->bdj_detected) {
|
|
Packit |
5e46da |
printf("Java VM found : %s\n", _yes_no(info->libjvm_detected));
|
|
Packit |
5e46da |
printf("BD-J handled : %s\n", _yes_no(info->bdj_handled));
|
|
Packit |
5e46da |
printf("BD-J organization ID: %s\n", info->bdj_org_id);
|
|
Packit |
5e46da |
printf("BD-J disc ID : %s\n", info->bdj_disc_id);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\nAACS detected : %s\n", _yes_no(info->aacs_detected));
|
|
Packit |
5e46da |
if (info->aacs_detected) {
|
|
Packit |
5e46da |
printf("libaacs detected : %s\n", _yes_no(info->libaacs_detected));
|
|
Packit |
5e46da |
if (info->libaacs_detected) {
|
|
Packit |
5e46da |
printf("Disc ID : %s\n", _hex2str(info->disc_id, sizeof(info->disc_id)));
|
|
Packit |
5e46da |
printf("AACS MKB version : %d\n", info->aacs_mkbv);
|
|
Packit |
5e46da |
printf("AACS handled : %s\n", _yes_no(info->aacs_handled));
|
|
Packit |
5e46da |
if (!info->aacs_handled) {
|
|
Packit |
5e46da |
printf(" (%s)\n", _aacs_error2str(info->aacs_error_code));
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\nBD+ detected : %s\n", _yes_no(info->bdplus_detected));
|
|
Packit |
5e46da |
if (info->bdplus_detected) {
|
|
Packit |
5e46da |
printf("libbdplus detected : %s\n", _yes_no(info->libbdplus_detected));
|
|
Packit |
5e46da |
if (info->libbdplus_detected) {
|
|
Packit |
5e46da |
if (info->bdplus_gen) {
|
|
Packit |
5e46da |
printf("BD+ generation : %d\n", info->bdplus_gen);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (info->bdplus_date) {
|
|
Packit |
5e46da |
printf("BD+ release date : %d-%02d-%02d\n",
|
|
Packit |
5e46da |
info->bdplus_date >> 16, (info->bdplus_date >> 8) & 0xff, info->bdplus_date & 0xff );
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
printf("BD+ handled : %s\n", _yes_no(info->bdplus_handled));
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_print_app_info(info);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_print_meta(bd_get_meta(bd));
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|