|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 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 <string.h>
|
|
Packit |
5e46da |
#include <inttypes.h>
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "decoders/overlay.h"
|
|
Packit |
5e46da |
#include "util/log_control.h"
|
|
Packit |
5e46da |
#include "bluray.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#define PRINT_EV0(e) \
|
|
Packit |
5e46da |
case BD_EVENT_##e: \
|
|
Packit |
5e46da |
printf(#e "\n"); \
|
|
Packit |
5e46da |
break
|
|
Packit |
5e46da |
#define PRINT_EV1(e,f) \
|
|
Packit |
5e46da |
case BD_EVENT_##e: \
|
|
Packit |
5e46da |
printf("%-25s " f "\n", #e ":", ev->param); \
|
|
Packit |
5e46da |
break
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _print_event(BD_EVENT *ev)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
switch ((bd_event_e)ev->event) {
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
case BD_EVENT_NONE:
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* errors */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(ERROR, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(READ_ERROR, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(ENCRYPTED, "%u");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* current playback position */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(ANGLE, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(TITLE, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(PLAYLIST, "%05u.mpls");
|
|
Packit |
5e46da |
PRINT_EV1(PLAYITEM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(PLAYMARK, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(CHAPTER, "%u");
|
|
Packit |
5e46da |
PRINT_EV0(END_OF_TITLE);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(STEREOSCOPIC_STATUS, "%u");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(SEEK, "%u");
|
|
Packit |
5e46da |
PRINT_EV0(DISCONTINUITY);
|
|
Packit |
5e46da |
PRINT_EV0(PLAYLIST_STOP);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* Interactive */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(STILL_TIME, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(STILL, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SOUND_EFFECT, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(IDLE, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(POPUP, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(MENU, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(UO_MASK_CHANGED, "0x%04x");
|
|
Packit |
5e46da |
PRINT_EV1(KEY_INTEREST_TABLE, "0x%04x");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* stream selection */
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(PG_TEXTST, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SECONDARY_AUDIO, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SECONDARY_VIDEO, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(PIP_PG_TEXTST, "%u");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
PRINT_EV1(AUDIO_STREAM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(IG_STREAM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(PG_TEXTST_STREAM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SECONDARY_AUDIO_STREAM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SECONDARY_VIDEO_STREAM, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(SECONDARY_VIDEO_SIZE, "%u");
|
|
Packit |
5e46da |
PRINT_EV1(PIP_PG_TEXTST_STREAM, "%u");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
fflush(stdout);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _read_to_eof(BLURAY *bd)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BD_EVENT ev;
|
|
Packit |
5e46da |
int bytes;
|
|
Packit |
5e46da |
uint64_t total = 0;
|
|
Packit |
5e46da |
uint8_t buf[6144];
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_seek(bd, bd_get_title_size(bd) - 6144);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
do {
|
|
Packit |
5e46da |
bytes = bd_read_ext(bd, buf, 6144, &ev;;
|
|
Packit |
5e46da |
total += bytes < 0 ? 0 : bytes;
|
|
Packit |
5e46da |
_print_event(&ev;;
|
|
Packit |
5e46da |
} while (bytes > 0);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("_read_to_eof(): read %"PRIu64" bytes\n", total);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _print_events(BLURAY *bd)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BD_EVENT ev;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
do {
|
|
Packit |
5e46da |
bd_read_ext(bd, NULL, 0, &ev;;
|
|
Packit |
5e46da |
_print_event(&ev;;
|
|
Packit |
5e46da |
} while (ev.event != BD_EVENT_NONE && ev.event != BD_EVENT_ERROR);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _play_pl(BLURAY *bd)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
printf("Playing playlist\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
fflush(stdout);
|
|
Packit |
5e46da |
_read_to_eof(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("Playing playlist done\n\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_print_events(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _overlay_cb(void *h, const struct bd_overlay_s * const ov)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
(void)h;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (ov) {
|
|
Packit |
5e46da |
printf("OVERLAY @%ld p%d %d: %d,%d %dx%d\n", (long)ov->pts, ov->plane, ov->cmd, ov->x, ov->y, ov->w, ov->h);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
} else {
|
|
Packit |
5e46da |
printf("OVERLAY CLOSE\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _argb_overlay_cb(void *h, const struct bd_argb_overlay_s * const ov)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
(void)h;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (ov) {
|
|
Packit |
5e46da |
printf("ARGB OVERLAY @%ld p%d %d: %d,%d %dx%d\n", (long)ov->pts, ov->plane, ov->cmd, ov->x, ov->y, ov->w, ov->h);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
} else {
|
|
Packit |
5e46da |
printf("ARGB OVERLAY CLOSE\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
int main(int argc, char *argv[])
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
int title = -1;
|
|
Packit |
5e46da |
int verbose = 0;
|
|
Packit |
5e46da |
int args = 0;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* parse arguments
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (argc < 2) {
|
|
Packit |
5e46da |
printf("\nUsage:\n %s [-v] [-t <title>] <media_path> [<keyfile_path>]\n\n", argv[0]);
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (!strcmp(argv[1+args], "-v")) {
|
|
Packit |
5e46da |
verbose = 1;
|
|
Packit |
5e46da |
args++;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (!strcmp(argv[1+args], "-t")) {
|
|
Packit |
5e46da |
args++;
|
|
Packit |
5e46da |
title = atoi(argv[1+args]);
|
|
Packit |
5e46da |
args++;
|
|
Packit |
5e46da |
printf("Requested title %d\n", title);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (verbose) {
|
|
Packit |
5e46da |
printf("Enabling verbose debug\n");
|
|
Packit |
5e46da |
bd_set_debug_mask(bd_get_debug_mask() | DBG_HDMV | DBG_BLURAY);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* open and setup
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BLURAY *bd = bd_open(argv[1+args], argv[2+args]);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (!bd) {
|
|
Packit |
5e46da |
printf("bd_open(\'%s\') failed\n", argv[1+args]);
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_set_player_setting (bd, BLURAY_PLAYER_SETTING_PARENTAL, 99);
|
|
Packit |
5e46da |
bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_AUDIO_LANG, "eng");
|
|
Packit |
5e46da |
bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_PG_LANG, "eng");
|
|
Packit |
5e46da |
bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_MENU_LANG, "eng");
|
|
Packit |
5e46da |
bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_COUNTRY_CODE, NULL);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_register_overlay_proc(bd, bd, _overlay_cb);
|
|
Packit |
5e46da |
bd_register_argb_overlay_proc(bd, bd, _argb_overlay_cb, NULL);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* play
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("Running first play movie object\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
fflush(stdout);
|
|
Packit |
5e46da |
bd_play(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_print_events(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* play title
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (title >= 0) {
|
|
Packit |
5e46da |
printf("Playing title %d\n", title);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
fflush(stdout);
|
|
Packit |
5e46da |
bd_play_title(bd, title);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_print_events(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
printf("\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* play playlist
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_play_pl(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_play_pl(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
_play_pl(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* clean up
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|