|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2009-2010 Obliter0n
|
|
Packit |
5e46da |
* Copyright (C) 2013 VideoLAN
|
|
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 "bluray.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
int main(int argc, char *argv[])
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
BLURAY *bd;
|
|
Packit |
5e46da |
int ii, num_titles;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
if (argc < 3) {
|
|
Packit |
5e46da |
fprintf(stderr, "Usage:\n %s <media_path> [<title_number>]\n\n", argv[0]);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (argc < 2) {
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* open disc */
|
|
Packit |
5e46da |
bd = bd_open(argv[1], NULL);
|
|
Packit |
5e46da |
if (!bd) {
|
|
Packit |
5e46da |
fprintf(stderr, "Error opening %s\n", argv[1]);
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* get titles */
|
|
Packit |
5e46da |
num_titles = bd_get_titles(bd, TITLES_RELEVANT, 0);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* list titles */
|
|
Packit |
5e46da |
if (argc < 3) {
|
|
Packit |
5e46da |
printf("Listing titles:\n");
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
for (ii = 0; ii < num_titles; ii++) {
|
|
Packit |
5e46da |
BLURAY_TITLE_INFO* ti;
|
|
Packit |
5e46da |
ti = bd_get_title_info(bd, ii, 0);
|
|
Packit |
5e46da |
printf("index: %d duration: %02"PRIu64":%02"PRIu64":%02"PRIu64" chapters: %d\n",
|
|
Packit |
5e46da |
ii,
|
|
Packit |
5e46da |
(ti->duration / 90000) / (3600),
|
|
Packit |
5e46da |
((ti->duration / 90000) % 3600) / 60,
|
|
Packit |
5e46da |
((ti->duration / 90000) % 60),
|
|
Packit |
5e46da |
ti->chapter_count);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* select title */
|
|
Packit |
5e46da |
if (bd_select_title(bd, atoi(argv[2])) <= 0) {
|
|
Packit |
5e46da |
fprintf(stderr, "Error opening title #%s\n", argv[2]);
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
return -1;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/* dump */
|
|
Packit |
5e46da |
FILE *fd = fopen("streamdump.m2ts", "wb");
|
|
Packit |
5e46da |
if (fd) {
|
|
Packit |
5e46da |
printf("Writing to streamdump.m2ts\n");
|
|
Packit |
5e46da |
ii = 0;
|
|
Packit |
5e46da |
while (1) {
|
|
Packit |
5e46da |
unsigned char buf[6144];
|
|
Packit |
5e46da |
int len = bd_read(bd, buf, 6144);
|
|
Packit |
5e46da |
if (len <= 0) break;
|
|
Packit |
5e46da |
if (fwrite(buf, len, 1, fd) < 1) {
|
|
Packit |
5e46da |
fprintf(stderr, "Write error\n");
|
|
Packit |
5e46da |
break;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
if (!(ii % 100)) {
|
|
Packit |
5e46da |
printf("Block %d\r", ii);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
ii++;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
fclose(fd);
|
|
Packit |
5e46da |
} else {
|
|
Packit |
5e46da |
printf("Error opening streamdump.m2ts\n");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
bd_close(bd);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return 0;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|