dvdnav.patch 14.8 KB
Newer Older
1
2
3
4
diff -ur libdvdnav/Makefile.am libdvdnav.new/Makefile.am
--- libdvdnav/Makefile.am	2004-10-26 18:26:07.000000000 +0100
+++ libdvdnav.new/Makefile.am	2005-11-28 16:19:13.343750000 +0000
@@ -2,7 +2,7 @@
5
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 AUTOMAKE_OPTIONS = 1.3
 
-SUBDIRS = src examples doc misc m4
+SUBDIRS = src misc m4
 
 EXTRA_DIST = autogen.sh \
 	     AUTHORS \
diff -ur libdvdnav/src/dvdnav.c libdvdnav.new/src/dvdnav.c
--- libdvdnav/src/dvdnav.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav.c	2005-11-28 16:19:13.328125000 +0000
@@ -31,7 +31,6 @@
 
 #include "dvdnav_internal.h"
 #include "read_cache.h"
-#include "nav_read.h"
 
 #include <stdlib.h>
 #include <stdio.h>
diff -ur libdvdnav/src/dvdnav.h libdvdnav.new/src/dvdnav.h
--- libdvdnav/src/dvdnav.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav.h	2005-11-28 16:19:13.328125000 +0000
@@ -33,16 +33,19 @@
 extern "C" {
 #endif
 
+#include <inttypes.h>
32
+
33
34
35
36
+#include <dvdread/dvd_reader.h>
+#include <dvdread/nav_types.h>
+#include <dvdread/nav_read.h>
+#include <dvdread/ifo_types.h> /* For vm_cmd_t */
37
+
38
39
40
41
42
 #ifdef DVDNAV_COMPILE
 #  include "dvdnav_events.h"
 #  include "dvd_types.h"
-#  include "dvd_reader.h"
-#  include "ifo_types.h" /* For vm_cmd_t */
Eric Petit's avatar
Eric Petit committed
43
 #else
44
45
46
47
48
 #  include <dvdnav/dvdnav_events.h>
 #  include <dvdnav/dvd_types.h>
-#  include <dvdnav/dvd_reader.h>
-#  include <dvdnav/ifo_types.h> /* For vm_cmd_t */
 #endif
Eric Petit's avatar
Eric Petit committed
49
 
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
diff -ur libdvdnav/src/dvdnav_events.h libdvdnav.new/src/dvdnav_events.h
--- libdvdnav/src/dvdnav_events.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/dvdnav_events.h	2005-11-28 16:19:13.328125000 +0000
@@ -28,10 +28,6 @@
 #ifndef DVDNAV_EVENTS_H_INCLUDED
 #define DVDNAV_EVENTS_H_INCLUDED
 
-#include "ifo_types.h"
-#include "dvd_reader.h"
-#include "nav_types.h"
-
 
 /*
  * DVDNAV_BLOCK_OK
diff -ur libdvdnav/src/dvdread/Makefile.am libdvdnav.new/src/dvdread/Makefile.am
--- libdvdnav/src/dvdread/Makefile.am	2004-05-19 19:31:11.000000000 +0100
+++ libdvdnav.new/src/dvdread/Makefile.am	2005-12-01 22:26:05.078125000 +0000
@@ -1,10 +1,10 @@
 include $(top_srcdir)/misc/Makefile.common
 
-includedir = ${prefix}/include/dvdnav
+includedir = ${prefix}/include/dvdread
 
 AM_CPPFLAGS = -DDVDNAV_COMPILE -I$(top_srcdir)/src/vm
 
-noinst_LTLIBRARIES = libdvdread.la
+lib_LTLIBRARIES = libdvdread.la
 
 libdvdread_la_SOURCES = dvd_reader.c nav_read.c ifo_read.c \
 	dvd_input.c dvd_udf.c md5.c nav_print.c ifo_print.c \
diff -ur libdvdnav/src/dvdread/bswap.h libdvdnav.new/src/dvdread/bswap.h
--- libdvdnav/src/dvdread/bswap.h	2004-01-11 21:43:13.000000000 +0000
+++ libdvdnav.new/src/dvdread/bswap.h	2005-12-01 21:55:20.328125000 +0000
Eric Petit's avatar
Eric Petit committed
84
85
86
87
88
89
90
91
92
@@ -65,7 +65,7 @@
  * functionality! 
  */
 
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__) || defined(__BEOS__)
 #define B2N_16(x) \
  x = ((((x) & 0xff00) >> 8) | \
       (((x) & 0x00ff) << 8))
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@@ -75,14 +75,14 @@
       (((x) & 0x0000ff00) <<  8) | \
       (((x) & 0x000000ff) << 24))
 #define B2N_64(x) \
- x = ((((x) & 0xff00000000000000) >> 56) | \
-      (((x) & 0x00ff000000000000) >> 40) | \
-      (((x) & 0x0000ff0000000000) >> 24) | \
-      (((x) & 0x000000ff00000000) >>  8) | \
-      (((x) & 0x00000000ff000000) <<  8) | \
-      (((x) & 0x0000000000ff0000) << 24) | \
-      (((x) & 0x000000000000ff00) << 40) | \
-      (((x) & 0x00000000000000ff) << 56))
+ x = ((((x) & 0xff00000000000000LL) >> 56) | \
+      (((x) & 0x00ff000000000000LL) >> 40) | \
+      (((x) & 0x0000ff0000000000LL) >> 24) | \
+      (((x) & 0x000000ff00000000LL) >>  8) | \
+      (((x) & 0x00000000ff000000LL) <<  8) | \
+      (((x) & 0x0000000000ff0000LL) << 24) | \
+      (((x) & 0x000000000000ff00LL) << 40) | \
+      (((x) & 0x00000000000000ffLL) << 56))
 
 #else
 
diff -ur libdvdnav/src/dvdread/dvd_input.c libdvdnav.new/src/dvdread/dvd_input.c
--- libdvdnav/src/dvdread/dvd_input.c	2004-04-09 13:15:26.000000000 +0100
+++ libdvdnav.new/src/dvdread/dvd_input.c	2005-11-30 23:07:47.140625000 +0000
@@ -21,12 +21,24 @@
120
 
121
122
 #include <stdio.h>
 #include <stdlib.h>
123
+
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
+#if defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
+
 #include <fcntl.h>
 #include <unistd.h>
 
 #include "dvd_reader.h"
 #include "dvd_input.h"
 
+#ifdef WIN32
+#   define lseek _lseeki64
+#   undef off_t
+#   define off_t int64_t
+#endif
 
 /* The function pointers that is the exported interface of this file. */
 dvd_input_t (*dvdinput_open)  (const char *);
diff -ur libdvdnav/src/dvdread/dvd_reader.c libdvdnav.new/src/dvdread/dvd_reader.c
--- libdvdnav/src/dvdread/dvd_reader.c	2004-09-12 16:18:16.000000000 +0100
+++ libdvdnav.new/src/dvdread/dvd_reader.c	2005-12-01 22:19:07.750000000 +0000
@@ -347,9 +347,7 @@
148
149
150
151
152
153
 	}
 #endif
     
-    ret = stat( path, &fileinfo );
-
-    if( ret < 0 ) {
154
+    if( *path && (ret = stat( path, &fileinfo ) < 0) ) {
155
156
157
 
         /* maybe "host:port" url? try opening it with acCeSS library */
         if( strchr(path,':') ) {
158
@@ -366,7 +364,7 @@
159
160
161
162
163
164
165
166
     }
 
     /* First check if this is a block/char device or a file*/
-    if( S_ISBLK( fileinfo.st_mode ) || 
+    if( !*path || S_ISBLK( fileinfo.st_mode ) || 
 	S_ISCHR( fileinfo.st_mode ) || 
 	S_ISREG( fileinfo.st_mode ) ) {
 
167
@@ -404,14 +402,15 @@
Eric Petit's avatar
Eric Petit committed
168
169
170
 
 	/* Resolve any symlinks and get the absolut dir name. */
 	{
171
+		char *current_path;
172
173
 	    char *new_path;
-	    int cdir = open( ".", O_RDONLY );
174
-	    
175
-	    if( cdir >= 0 ) {
176
177
178
+	   
+		current_path = getcwd( NULL, PATH_MAX );
+		if( current_path ) {
179
180
181
182
183
184
185
186
187
 		chdir( path_copy );
 		new_path = getcwd( NULL, PATH_MAX );
-		fchdir( cdir );
-		close( cdir );
+		chdir( current_path );
+		free( current_path );
 		if( new_path ) {
 		    free( path_copy );
 		    path_copy = new_path;
188
@@ -586,10 +585,12 @@
189
190
191
192
193
194
195
196
197
198
199
200
             sprintf( filename, "%s%s%s", path,
                      ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
                      ent->d_name );
+            closedir( dir );
             return 0;
         }
     }
 
+    closedir( dir );
     return -1;
 }
 
201
202
203
204
205
diff -ur libdvdnav/src/highlight.c libdvdnav.new/src/highlight.c
--- libdvdnav/src/highlight.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/highlight.c	2005-11-28 16:19:13.343750000 +0000
@@ -26,7 +26,6 @@
 #endif
206
 
207
208
209
 #include <assert.h>
-#include "nav_types.h"
 #include "dvdnav_internal.h"
210
 
211
212
213
214
215
216
 /*
diff -ur libdvdnav/src/remap.c libdvdnav.new/src/remap.c
--- libdvdnav/src/remap.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/remap.c	2005-11-28 16:19:13.343750000 +0000
@@ -189,7 +189,11 @@
     remap_t *map;
217
 
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
     /* Build the map filename */
-    home = getenv("HOME"); assert(home);
+    home = getenv("HOME");
+    if (!home) {
+	fprintf(MSG_OUT, "libdvdnav: Unable to find map for title '%s'\n", title);
+	return NULL;
+    }
     strncpy(fname, home, sizeof(fname));
     strncat(fname, "/.dvdnav/", sizeof(fname));
     strncat(fname, title, sizeof(fname));
diff -ur libdvdnav/src/vm/decoder.c libdvdnav.new/src/vm/decoder.c
--- libdvdnav/src/vm/decoder.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/decoder.c	2005-11-28 16:19:13.343750000 +0000
@@ -31,7 +31,6 @@
 #include <stdlib.h>
233
 #include <inttypes.h>
234
235
 #include <string.h>  /* For memset */
-#include "ifo_types.h" /* vm_cmd_t */
236
 
237
238
239
240
241
242
 #include "dvdnav_internal.h"
 
diff -ur libdvdnav/src/vm/decoder.h libdvdnav.new/src/vm/decoder.h
--- libdvdnav/src/vm/decoder.h	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/decoder.h	2005-11-28 16:19:13.343750000 +0000
@@ -28,7 +28,7 @@
243
 #include <inttypes.h>
244
 #include <sys/time.h>
245
 
246
247
248
-#include "ifo_types.h" /*  vm_cmd_t */
+#include <dvdread/ifo_types.h> /*  vm_cmd_t */
 #include "dvdnav_internal.h"
249
 
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
 /* link command types */
diff -ur libdvdnav/src/vm/vm.c libdvdnav.new/src/vm/vm.c
--- libdvdnav/src/vm/vm.c	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/src/vm/vm.c	2005-11-28 16:19:13.343750000 +0000
@@ -38,13 +38,17 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "ifo_types.h"
-#include "ifo_read.h"
+/* from dvdread */
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
 
 #include "dvdnav_internal.h"
 
 #ifdef _MSC_VER
 #include <io.h>   /* read() */
+#elif defined(WIN32)
+#   define lseek _lseeki64
+#   define off_t int64_t
 #endif /* _MSC_VER */
272
 
273
 /*
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
@@ -126,24 +130,25 @@
 }
 #endif
 
+#include <dvdread/dvd_input.h>
+
 static void dvd_read_name(char *name, const char *device) {
     /* Because we are compiling with _FILE_OFFSET_BITS=64
      * all off_t are 64bit.
      */
     off_t off;
-    int fd, i;
+    dvd_input_t fd; int i;
     uint8_t data[DVD_VIDEO_LB_LEN];
 
     /* Read DVD name */
-    fd = open(device, O_RDONLY);
+    fd = dvdinput_open(device);
     if (fd > 0) { 
-      off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
-      if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
-        off = read( fd, data, DVD_VIDEO_LB_LEN ); 
-        close(fd);
-        if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
+      off = dvdinput_seek( fd, 16 );
+      if( off == 16 ) {
+        off = dvdinput_read( fd, data, 1, DVDINPUT_NOFLAGS ); 
+        if (off == 1 ) {
           fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
-          for(i=25; i < 73; i++ ) {
+          for(i=40; i < 73; i++ ) {
             if((data[i] == 0)) break;
             if((data[i] > 32) && (data[i] < 127)) {
               fprintf(MSG_OUT, "%c", data[i]);
@@ -151,10 +156,12 @@
               fprintf(MSG_OUT, " ");
             }
           }
-          strncpy(name, &data[25], 48);
-          name[48] = 0;
+          strncpy(name, &data[40], 32);
+          i=31;
+          while( (i >= 0) && (name[i] <= ' ')) --i;
+          name[i+1] = '\0';
           fprintf(MSG_OUT, "\nlibdvdnav: DVD Serial Number: ");
-          for(i=73; i < 89; i++ ) {
+          for(i=813; i < 829; i++ ) {
             if((data[i] == 0)) break;
             if((data[i] > 32) && (data[i] < 127)) {
               fprintf(MSG_OUT, "%c", data[i]);
@@ -178,7 +185,7 @@
       } else {
         fprintf(MSG_OUT, "libdvdnav: Can't seek to block %u\n", 32 );
       }
-      close(fd);
+      dvdinput_close(fd);
     } else {
     fprintf(MSG_OUT, "NAME OPEN FAILED\n");
   }
333
334
335
336
337
338
339
340
341
--- libdvdnav/misc/dvdnav-config.in	2003-04-27 02:26:17.000000000 +0100
+++ libdvdnav.new/misc/dvdnav-config.in	2005-12-02 09:29:48.265625000 +0000
@@ -76,5 +76,5 @@
 fi
 
 if test "$echo_libs" = "yes"; then
-      echo -L@libdir@ -ldvdnav @THREAD_LIBS@
+      echo -L@libdir@ -ldvdnav -ldvdread @THREAD_LIBS@
 fi      
342
343
--- libdvdnav/configure.ac	2005-02-11 12:33:19.000000000 +0000
+++ libdvdnav.new/configure.ac	2005-12-02 15:23:13.921875000 +0000
344
345
346
347
348
349
350
351
352
353
354
355
@@ -128,7 +128,10 @@
 AC_TYPE_SIZE_T
 dnl AC_CHECK_TYPES([ptrdiff_t])
 AC_C_BIGENDIAN
-
+dnl ---------------------------------------------
+dnl Check for basic *nix fonction that we may emulate on other OS
+dnl ---------------------------------------------
+AC_CHECK_FUNCS(gettimeofday)
 dnl ---------------------------------------------
 dnl threads
 dnl ---------------------------------------------
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
@@ -138,7 +138,7 @@
     THREAD_CFLAGS="-I/usr/local/include -D_THREAD_SAFE"
     CFLAGS="$THREAD_CFLAGS $CFLAGS"
     ;;
-  *mingw32* | *cygwin*)
+  *mingw32* | *cygwin* | *beos*)
     ;;
   *)
     AC_CHECK_LIB(pthread, pthread_create,
@@ -149,26 +149,63 @@
 AC_SUBST(THREAD_LIBS)
 AC_SUBST(THREAD_CFLAGS)
 
+link_dvdcss=no
+dvdcss_path=""
 dnl ---------------------------------------------
-dnl dynamic linker
+dnl dvdcss checking
 dnl ---------------------------------------------
-case $host in
-  *mingw32*)
-    CFLAGS="-idirafter \$(top_srcdir)/msvc/include $CFLAGS"
-    LDFLAGS="-no-undefined $LDFLAGS"
-    ;;
-  *cygwin*)
-    LDFLAGS="-no-undefined $LDFLAGS"
-    ;;
-  *)
-    AC_CHECK_LIB(c, dlopen,
-	         DYNAMIC_LD_LIBS="",
-	         AC_CHECK_LIB(dl, dlopen,
-             	              DYNAMIC_LD_LIBS="-ldl",
-	                      AC_MSG_ERROR(dynamic linker needed)))
-    AC_SUBST(DYNAMIC_LD_LIBS)
-    ;;
-esac
+AC_ARG_WITH( [libdvdcss],
+    [ --with-libdvdcss[=PATH]    force linking against libdvdcss],
+    [if test x"$withval" != xno; then
+       link_dvdcss=yes
+     fi
+     if test x"$withval" != xyes; then
+       dvdcss_path=$withval
+     fi])
+
+if test x"$link_dvdcss" != xyes; then
+dnl dlopen libdvdcss
+  AC_CHECK_FUNC( dlopen,
404
+    [DL_LIBS="" ],
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
+    AC_CHECK_LIB( dl, dlopen,
+      [DL_LIBS=-ld ],
+      AC_MSG_ERROR(You need libdl (dlopen))
+    )
+  )
+else
+dnl link with libdvdcss
+  if test -z "$dvdcss_path"; then
+    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
+      [ CSS_LIBS=-ldvdcss ],
+      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
+    )
+    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
+      [ ],
+      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
+    )
+  else
+    saved_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS -L$dvdcss_path/lib"
+    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
+      [ CSS_LIBS="-L$dvdcss_path/lib -R$dvdcss_path/lib -ldvdcss"
+        CSS_CFLAGS=-I$dvdcss_path/include ],
+      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
+    )
+    CFLAGS=$saved_CFLAGS
+    dnl -w added to shutup GCC3.1's cpp warning about -I/usr/local
+    saved_CPPFLAGS=$CPPFLAGS
+    CPPFLAGS="-w $CPPFLAGS -I$dvdcss_path/include"
+    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
+      [ ],
+      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
+    )
+    CPPFLAGS=$saved_CPPFLAGS
+  fi
+fi
+
+AC_SUBST(DL_LIBS)
+AC_SUBST(CSS_LIBS)
+AC_SUBST(CSS_CFLAGS)
 
 dnl ---------------------------------------------
 dnl cflags
--- libdvdnav/src/dvdnav_internal.h	2005-02-11 12:25:11.000000000 +0000
+++ libdvdnav.new/src/dvdnav_internal.h	2005-12-02 15:29:35.250000000 +0000
@@ -59,6 +59,15 @@
 #include <io.h> /* read() */
 #define lseek64 _lseeki64
 
+#elif defined(__BEOS__)
+
+#include <OS.h>
+typedef sem_id pthread_mutex_t;
+#define pthread_mutex_init(a, b) (*a) = create_sem( 1,"" )
+#define pthread_mutex_lock(a)    acquire_sem( *a )
+#define pthread_mutex_unlock(a)  release_sem( *a )
+#define pthread_mutex_destroy(a) delete_sem( *a )
+
 #else
 
 #include <pthread.h>
--- libdvdnav/examples/Makefile.am	2004-01-11 21:43:12.000000000 +0000
+++ libdvdnav.new/examples/Makefile.am	2005-12-02 15:24:58.671875000 +0000
@@ -7,7 +7,7 @@
 noinst_PROGRAMS = menus
 
 menus_SOURCES = menus.c
-menus_LDFLAGS = -L$(top_srcdir)/src/
+menus_LDFLAGS = -L$(top_srcdir)/src/ $(CSS_LIBS)
 menus_LDADD   = $(DVDNAV_LIB)
 
 $(DVDNAV_LIB):
476
477
478
479
480
481
--- libdvdnav/src/dvdnav_internal.h.orig	2007-02-19 18:41:27.784456800 +0000
+++ libdvdnav/src/dvdnav_internal.h	2007-02-19 18:41:50.706478500 +0000
@@ -45,6 +45,7 @@
 #define pthread_mutex_unlock(a)  LeaveCriticalSection(a)
 #define pthread_mutex_destroy(a)
 
482
+#ifndef HAVE_GETIMEOFDAY 
483
484
485
486
487
488
489
490
491
492
493
494
 /* replacement gettimeofday implementation */
 #include <sys/timeb.h>
 static inline int _private_gettimeofday( struct timeval *tv, void *tz )
@@ -56,6 +57,8 @@
   return 0;
 }
 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
+#endif
+
 #include <io.h> /* read() */
 #define lseek64 _lseeki64