|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2009-2010 John Stebbins
|
|
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 "bluray.h"
|
|
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 |
#define OPTS "ahs:l"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _usage(char *cmd)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
fprintf(stderr,
|
|
Packit |
5e46da |
"%s <BD base dir> [-s <seconds>]\n"
|
|
Packit |
5e46da |
" List the titles and title info of a BD\n"
|
|
Packit |
5e46da |
" -s # - Filter out titles shorter than # seconds\n"
|
|
Packit |
5e46da |
" -a - List all titles\n"
|
|
Packit |
5e46da |
" -l - Show language codes\n"
|
|
Packit |
5e46da |
" -h - This message\n",
|
|
Packit |
5e46da |
cmd
|
|
Packit |
5e46da |
);
|
|
Packit |
5e46da |
exit(EXIT_FAILURE);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _print_langs(const char *tag, const BLURAY_STREAM_INFO *si, int count)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
int ii;
|
|
Packit |
5e46da |
printf("\t%s: ", tag);
|
|
Packit |
5e46da |
for (ii = 0; ii < count; ii++) {
|
|
Packit |
5e46da |
printf("%3.3s ", si[ii].lang);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
printf("\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static void _dump_langs(const BLURAY_CLIP_INFO *ci)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
if (ci->audio_streams) {
|
|
Packit |
5e46da |
_print_langs("AUD", ci->audio_streams, ci->audio_stream_count);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (ci->pg_streams) {
|
|
Packit |
5e46da |
_print_langs("PG ", ci->pg_streams, ci->pg_stream_count);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
int main(int argc, char *argv[])
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BLURAY *bd;
|
|
Packit |
5e46da |
int count, ii, opt, main_title;
|
|
Packit |
5e46da |
unsigned int seconds = 0, langs = 0;
|
|
Packit |
5e46da |
unsigned int flags = TITLES_RELEVANT;
|
|
Packit |
5e46da |
char *bd_dir = NULL;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
do
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
opt = getopt(argc, argv, OPTS);
|
|
Packit |
5e46da |
switch (opt)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
case -1:
|
|
Packit |
5e46da |
if (optind < argc && bd_dir == NULL)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
bd_dir = argv[optind];
|
|
Packit |
5e46da |
optind++;
|
|
Packit |
5e46da |
opt = 1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
case 'a':
|
|
Packit |
5e46da |
flags = TITLES_ALL;
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
case 's':
|
|
Packit |
5e46da |
seconds = strtol(optarg, NULL, 0);
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
case 'l':
|
|
Packit |
5e46da |
langs = 1;
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
case 'h':
|
|
Packit |
5e46da |
default:
|
|
Packit |
5e46da |
_usage(argv[0]);
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
} while (opt != -1);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (bd_dir == NULL)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
_usage(argv[0]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
bd = bd_open(bd_dir, NULL);
|
|
Packit |
5e46da |
if (!bd) {
|
|
Packit |
5e46da |
fprintf(stderr, "bd_open(%s) failed\n", bd_dir);
|
|
Packit |
5e46da |
exit(EXIT_FAILURE);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
count = bd_get_titles(bd, flags, seconds);
|
|
Packit |
5e46da |
main_title = bd_get_main_title(bd);
|
|
Packit |
5e46da |
if (main_title >= 0) {
|
|
Packit |
5e46da |
printf("Main title: %d\n", main_title + 1);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
for (ii = 0; ii < count; ii++)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BLURAY_TITLE_INFO* ti;
|
|
Packit |
5e46da |
ti = bd_get_title_info(bd, ii, 0);
|
|
Packit |
5e46da |
printf(
|
|
Packit |
5e46da |
"index: %3d duration: %02"PRIu64":%02"PRIu64":%02"PRIu64" chapters: %3d angles: %2u clips: %3u (playlist: %05d.mpls) "
|
|
Packit |
5e46da |
"V:%d A:%-2d PG:%-2d IG:%-2d SV:%d SA:%d\n",
|
|
Packit |
5e46da |
ii + 1,
|
|
Packit |
5e46da |
(ti->duration / 90000) / (3600),
|
|
Packit |
5e46da |
((ti->duration / 90000) % 3600) / 60,
|
|
Packit |
5e46da |
((ti->duration / 90000) % 60),
|
|
Packit |
5e46da |
ti->chapter_count, ti->angle_count, ti->clip_count, ti->playlist,
|
|
Packit |
5e46da |
ti->clips[0].video_stream_count,
|
|
Packit |
5e46da |
ti->clips[0].audio_stream_count,
|
|
Packit |
5e46da |
ti->clips[0].pg_stream_count,
|
|
Packit |
5e46da |
ti->clips[0].ig_stream_count,
|
|
Packit |
5e46da |
ti->clips[0].sec_video_stream_count,
|
|
Packit |
5e46da |
ti->clips[0].sec_audio_stream_count
|
|
Packit |
5e46da |
);
|
|
Packit |
5e46da |
if (langs) {
|
|
Packit |
5e46da |
_dump_langs(&ti->clips[0]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
bd_free_title_info(ti);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|