openbsd-ports/multimedia/lsdvd/patches/patch-lsdvd_c

148 lines
4.0 KiB
Plaintext

$OpenBSD: patch-lsdvd_c,v 1.6 2012/05/03 08:14:59 ajacoutot Exp $
--- lsdvd.c.orig Thu Mar 2 08:48:11 2006
+++ lsdvd.c Thu May 3 03:29:12 2012
@@ -14,6 +14,7 @@
* output info structures in form of a Perl module, by Henk Vergonet.
*/
#include <dvdread/ifo_read.h>
+#include <dvdread/ifo_print.h>
#include <string.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -119,6 +120,7 @@ void converttime(playback_time_t *pt, dvd_time_t *dt)
/*
* The following method is based on code from vobcopy, by Robos, with thanks.
+ * It fails opening a directory (like /home/movies/casablanca/VIDEO_TS/)
*/
int get_title_name(const char* dvd_device, char* title)
{
@@ -130,20 +132,28 @@ int get_title_name(const char* dvd_device, char* title
strcpy(title, "unknown");
return -1;
}
+ fprintf(stderr, "opening %s for title\n", dvd_device);
- if ( fseek(filehandle, 32808, SEEK_SET )) {
+ if ( fseek(filehandle, 32768, SEEK_SET )) {
fclose(filehandle);
fprintf(stderr, "Couldn't seek in %s for title\n", dvd_device);
strcpy(title, "unknown");
return -1;
}
- if ( 32 != (i = fread(title, 1, 32, filehandle)) ) {
+ {
+ #define DVD_SEC_SIZ 2048
+ char tempBuf[ DVD_SEC_SIZ ];
+
+ if ( DVD_SEC_SIZ != fread(tempBuf, 1, DVD_SEC_SIZ, filehandle) ) {
fclose(filehandle);
fprintf(stderr, "Couldn't read enough bytes for title.\n");
strcpy(title, "unknown");
return -1;
}
+ snprintf( title, 32, "%s", tempBuf + 40 );
+ i=32;
+ }
fclose (filehandle);
@@ -196,7 +206,7 @@ void usage()
fprintf(stderr, "\n");
}
-int opt_a=0, opt_c=0, opt_n=0, opt_p=0, opt_q=0, opt_s=0, opt_t=0, opt_v=0, opt_x=0, opt_d=0, opt_P=0;
+int opt_a=0, opt_c=0, opt_m=0, opt_n=0, opt_p=0, opt_q=0, opt_s=0, opt_t=0, opt_v=0, opt_x=0, opt_d=0, opt_P=0;
char opt_O='h';
char output_option(char *arg)
@@ -235,7 +245,7 @@ int main(int argc, char *argv[])
pgc_t *pgc;
int i, j, c, titles, cell, vts_ttn, title_set_nr;
char lang_code[3];
- char *dvd_device = "/dev/dvd";
+ char *dvd_device = "/dev/rcd0c";
int has_title = 0, ret = 0;
int max_length = 0, max_track = 0;
struct stat dvd_stat;
@@ -252,18 +262,20 @@ int main(int argc, char *argv[])
case 's': opt_s = 1; break;
case 'q': opt_q = 1; break;
case 'c': opt_c = 1; break;
+ case 'm': opt_m = 1; break;
case 'n': opt_n = 1; break;
case 'p': opt_p = 1; break;
case 'P': opt_P = 1; break;
case 't': opt_t = atoi(optarg); break;
case 'O': opt_O = output_option(optarg); break;
- case 'v': opt_v = 1; break;
+ case 'v': opt_v++; break;
case 'x': opt_x = 1;
opt_a = 1;
opt_c = 1;
opt_s = 1;
opt_P = 1;
opt_d = 1;
+ opt_m = 1;
opt_n = 1;
opt_v = 1; break;
}
@@ -277,6 +289,9 @@ int main(int argc, char *argv[])
return 1;
}
+ /* On at least NetBSD this fails if called after DVDOpen */
+ has_title = get_title_name(dvd_device, title);
+
dvd = DVDOpen(dvd_device);
if( !dvd ) {
fprintf( stderr, "Can't open disc %s!\n", dvd_device);
@@ -287,6 +302,12 @@ int main(int argc, char *argv[])
fprintf( stderr, "Can't open main ifo!\n");
return 3;
}
+ if (opt_v > 2) {
+ printf("Title 0 IFO dump\n");
+ printf("================\n");
+ ifo_print(dvd, 0);
+ printf("\n");
+ }
ifo = (ifo_handle_t **)malloc((ifo_zero->vts_atrt->nr_of_vtss + 1) * sizeof(ifo_handle_t *));
@@ -296,6 +317,12 @@ int main(int argc, char *argv[])
fprintf( stderr, "Can't open ifo %d!\n", i);
return 4;
}
+ if (opt_v > 2) {
+ printf("Title %2d IFO dump\n", i);
+ printf("=================\n");
+ ifo_print(dvd, i);
+ printf("\n");
+ }
}
titles = ifo_zero->tt_srpt->nr_of_srpts;
@@ -305,8 +332,6 @@ int main(int argc, char *argv[])
return 5;
}
- has_title = get_title_name(dvd_device, title);
-
vmgi_mat = ifo_zero->vmgi_mat;
struct dvd_info dvd_info;
@@ -377,6 +402,11 @@ int main(int argc, char *argv[])
dvd_info.titles[j].angle_count = ifo_zero->tt_srpt->title[j].nr_of_angles;
} else {
dvd_info.titles[j].angle_count = 0;
+ }
+
+ // MENU STRUCTURE
+ if (opt_m) {
+ // void ifo_print(dvd_reader_t *, int);
}
// AUDIO