annotate libmpdvdkit2/libdvdread_changes.diff @ 15151:1edaf17d5205

messed ordering of switch branches, 10l for Ivan
author henry
date Wed, 13 Apr 2005 19:38:44 +0000
parents d18e40806248
children 5b5ca5c4f381
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14937
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
1 --- dvdread/bswap.h 2002-04-07 19:52:00.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
2 +++ bswap.h 2005-03-01 07:07:45.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
3 @@ -20,8 +20,6 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
4 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
5 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
6
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
7 -#include <config.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
8 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
9 #if defined(WORDS_BIGENDIAN)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
10 /* All bigendian systems are fine, just ignore the swaps. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
11 #define B2N_16(x) (void)(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
12 @@ -48,13 +46,51 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
13 #define B2N_32(x) x = swap32(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
14 #define B2N_64(x) x = swap64(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
15
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
16 +#elif defined(ARCH_X86)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
17 +inline static unsigned short bswap_16(unsigned short x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
18 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
19 + __asm("xchgb %b0,%h0" :
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
20 + "=q" (x) :
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
21 + "0" (x));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
22 + return x;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
23 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
24 +#define B2N_16(x) x = bswap_16(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
25 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
26 +inline static unsigned int bswap_32(unsigned int x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
27 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
28 + __asm(
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
29 +#if __CPU__ > 386
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
30 + "bswap %0":
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
31 + "=r" (x) :
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
32 +#else
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
33 + "xchgb %b0,%h0\n"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
34 + " rorl $16,%0\n"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
35 + " xchgb %b0,%h0":
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
36 + "=q" (x) :
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
37 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
38 + "0" (x));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
39 + return x;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
40 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
41 +#define B2N_32(x) x = bswap_32(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
42 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
43 +inline static unsigned long long int bswap_64(unsigned long long int x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
44 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
45 + register union { __extension__ uint64_t __ll;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
46 + uint32_t __l[2]; } __x;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
47 + asm("xchgl %0,%1":
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
48 + "=r"(__x.__l[0]),"=r"(__x.__l[1]):
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
49 + "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
50 + return __x.__ll;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
51 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
52 +#define B2N_64(x) x = bswap_64(x)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
53 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
54 /* This is a slow but portable implementation, it has multiple evaluation
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
55 * problems so beware.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
56 * FreeBSD and Solaris don't have <byteswap.h> or any other such
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
57 * functionality!
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
58 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
59
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
60 -#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
61 +#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(__CYGWIN__)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
62 #define B2N_16(x) \
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
63 x = ((((x) & 0xff00) >> 8) | \
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
64 (((x) & 0x00ff) << 8))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
65 --- dvdread/dvd_input.c 2002-05-09 23:32:46.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
66 +++ dvd_input.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
67 @@ -21,13 +21,11 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
68 #include <stdlib.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
69 #include <fcntl.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
70 #include <unistd.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
71 -#include <dlfcn.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
72
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
73 #include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
74 #include "dvd_input.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
75
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
76 -/* For libdvdcss */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
77 -typedef struct dvdcss_s *dvdcss_handle;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
78 +#include "dvdcss.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
79
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
80 dvdcss_handle (*DVDcss_open) (const char *);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
81 int (*DVDcss_close) (dvdcss_handle);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
82 @@ -36,6 +34,12 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
83 int (*DVDcss_read) (dvdcss_handle, void *, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
84 char * (*DVDcss_error) (dvdcss_handle);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
85
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
86 +dvd_input_t (*DVDinput_open) (const char *);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
87 +int (*DVDinput_close) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
88 +int (*DVDinput_seek) (dvd_input_t, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
89 +int (*DVDinput_title) (dvd_input_t, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
90 +int (*DVDinput_read) (dvd_input_t, void *, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
91 +char * (*DVDinput_error) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
92
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
93 /* The DVDinput handle, add stuff here for new input methods. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
94 struct dvd_input_s {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
95 @@ -55,7 +59,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
96 dvd_input_t dev;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
97
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
98 /* Allocate the handle structure */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
99 - dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
100 + dev = (dvd_input_t) malloc(sizeof(struct dvd_input_s));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
101 if(dev == NULL) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
102 fprintf(stderr, "libdvdread: Could not allocate memory.\n");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
103 return NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
104 @@ -123,176 +127,26 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
105
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
106
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
107
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
108 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
109 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
110 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
111 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
112 - * initialize and open a DVD device or file.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
113 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
114 -static dvd_input_t file_open(const char *target)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
115 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
116 - dvd_input_t dev;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
117 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
118 - /* Allocate the library structure */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
119 - dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
120 - if(dev == NULL) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
121 - fprintf(stderr, "libdvdread: Could not allocate memory.\n");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
122 - return NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
123 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
124 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
125 - /* Open the device */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
126 - dev->fd = open(target, O_RDONLY);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
127 - if(dev->fd < 0) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
128 - perror("libdvdread: Could not open input");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
129 - free(dev);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
130 - return NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
131 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
132 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
133 - return dev;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
134 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
135 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
136 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
137 - * return the last error message
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
138 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
139 -static char *file_error(dvd_input_t dev)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
140 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
141 - /* use strerror(errno)? */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
142 - return "unknown error";
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
143 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
144 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
145 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
146 - * seek into the device.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
147 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
148 -static int file_seek(dvd_input_t dev, int blocks, int flags)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
149 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
150 - off_t pos;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
151 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
152 - pos = lseek(dev->fd, (off_t)blocks * (off_t)DVD_VIDEO_LB_LEN, SEEK_SET);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
153 - if(pos < 0) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
154 - return pos;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
155 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
156 - /* assert pos % DVD_VIDEO_LB_LEN == 0 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
157 - return (int) (pos / DVD_VIDEO_LB_LEN);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
158 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
159 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
160 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
161 - * set the block for the begining of a new title (key).
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
162 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
163 -static int file_title(dvd_input_t dev, int block)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
164 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
165 - return -1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
166 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
167 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
168 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
169 - * read data from the device.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
170 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
171 -static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
172 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
173 - size_t len;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
174 - ssize_t ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
175 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
176 - len = (size_t)blocks * DVD_VIDEO_LB_LEN;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
177 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
178 - while(len > 0) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
179 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
180 - ret = read(dev->fd, buffer, len);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
181 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
182 - if(ret < 0) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
183 - /* One of the reads failed, too bad. We won't even bother
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
184 - * returning the reads that went ok, and as in the posix spec
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
185 - * the file postition is left unspecified after a failure. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
186 - return ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
187 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
188 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
189 - if(ret == 0) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
190 - /* Nothing more to read. Return the whole blocks, if any, that we got.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
191 - and adjust the file possition back to the previous block boundary. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
192 - size_t bytes = (size_t)blocks * DVD_VIDEO_LB_LEN - len;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
193 - off_t over_read = -(bytes % DVD_VIDEO_LB_LEN);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
194 - /*off_t pos =*/ lseek(dev->fd, over_read, SEEK_CUR);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
195 - /* should have pos % 2048 == 0 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
196 - return (int) (bytes / DVD_VIDEO_LB_LEN);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
197 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
198 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
199 - len -= ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
200 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
201 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
202 - return blocks;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
203 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
204 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
205 -/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
206 - * close the DVD device and clean up.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
207 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
208 -static int file_close(dvd_input_t dev)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
209 -{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
210 - int ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
211 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
212 - ret = close(dev->fd);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
213 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
214 - if(ret < 0)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
215 - return ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
216 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
217 - free(dev);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
218 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
219 - return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
220 -}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
221 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
222 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
223 /**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
224 * Setup read functions with either libdvdcss or minimal DVD access.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
225 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
226 int DVDInputSetup(void)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
227 {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
228 - void *dvdcss_library = NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
229 - char **dvdcss_version = NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
230 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
231 - dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
232 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
233 - if(dvdcss_library != NULL) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
234 -#if defined(__OpenBSD__) && !defined(__ELF__)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
235 -#define U_S "_"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
236 -#else
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
237 -#define U_S
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
238 -#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
239 - DVDcss_open = (dvdcss_handle (*)(const char*))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
240 - dlsym(dvdcss_library, U_S "dvdcss_open");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
241 - DVDcss_close = (int (*)(dvdcss_handle))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
242 - dlsym(dvdcss_library, U_S "dvdcss_close");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
243 - DVDcss_title = (int (*)(dvdcss_handle, int))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
244 - dlsym(dvdcss_library, U_S "dvdcss_title");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
245 - DVDcss_seek = (int (*)(dvdcss_handle, int, int))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
246 - dlsym(dvdcss_library, U_S "dvdcss_seek");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
247 - DVDcss_read = (int (*)(dvdcss_handle, void*, int, int))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
248 - dlsym(dvdcss_library, U_S "dvdcss_read");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
249 - DVDcss_error = (char* (*)(dvdcss_handle))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
250 - dlsym(dvdcss_library, U_S "dvdcss_error");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
251 + DVDcss_open = dvdcss_open;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
252 + DVDcss_close = dvdcss_close;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
253 + DVDcss_title = dvdcss_title;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
254 + DVDcss_seek = dvdcss_seek;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
255 + DVDcss_read = dvdcss_read;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
256 + DVDcss_error = dvdcss_error;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
257
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
258 - dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
259 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
260 - if(dlsym(dvdcss_library, U_S "dvdcss_crack")) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
261 - fprintf(stderr,
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
262 - "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
263 - "libdvdread: You should get the latest version from "
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
264 - "http://www.videolan.org/\n" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
265 - dlclose(dvdcss_library);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
266 - dvdcss_library = NULL;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
267 - } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
268 - || !DVDcss_read || !DVDcss_error || !dvdcss_version) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
269 - fprintf(stderr, "libdvdread: Missing symbols in libdvdcss.so.2, "
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
270 - "this shouldn't happen !\n");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
271 - dlclose(dvdcss_library);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
272 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
273 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
274 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
275 - if(dvdcss_library != NULL) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
276 /*
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
277 char *psz_method = getenv( "DVDCSS_METHOD" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
278 char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
279 fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
280 fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
281 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
282 - fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
283 - *dvdcss_version);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
284 +// fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
285 +// *dvdcss_version);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
286
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
287 /* libdvdcss wraper functions */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
288 DVDinput_open = css_open;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
289 @@ -303,16 +157,4 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
290 DVDinput_error = css_error;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
291 return 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
292
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
293 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
294 - fprintf(stderr, "libdvdread: Encrypted DVD support unavailable.\n");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
295 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
296 - /* libdvdcss replacement functions */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
297 - DVDinput_open = file_open;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
298 - DVDinput_close = file_close;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
299 - DVDinput_seek = file_seek;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
300 - DVDinput_title = file_title;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
301 - DVDinput_read = file_read;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
302 - DVDinput_error = file_error;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
303 - return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
304 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
305 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
306 --- dvdread/dvd_input.h 2002-05-09 23:21:20.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
307 +++ dvd_input.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
308 @@ -36,12 +36,12 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
309 /**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
310 * Pointers which will be filled either the input meathods functions.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
311 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
312 -dvd_input_t (*DVDinput_open) (const char *);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
313 -int (*DVDinput_close) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
314 -int (*DVDinput_seek) (dvd_input_t, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
315 -int (*DVDinput_title) (dvd_input_t, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
316 -int (*DVDinput_read) (dvd_input_t, void *, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
317 -char * (*DVDinput_error) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
318 +extern dvd_input_t (*DVDinput_open) (const char *);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
319 +extern int (*DVDinput_close) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
320 +extern int (*DVDinput_seek) (dvd_input_t, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
321 +extern int (*DVDinput_title) (dvd_input_t, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
322 +extern int (*DVDinput_read) (dvd_input_t, void *, int, int);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
323 +extern char * (*DVDinput_error) (dvd_input_t);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
324
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
325 /**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
326 * Setup function accessed by dvd_reader.c. Returns 1 if there is CSS support.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
327 --- dvdread/dvd_reader.c 2002-05-19 17:48:41.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
328 +++ dvd_reader.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
329 @@ -17,6 +17,8 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
330 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
331 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
332
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
333 +#include "config.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
334 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
335 #include <sys/types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
336 #include <sys/stat.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
337 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
338 @@ -35,12 +37,24 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
339
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
340 #if defined(__sun)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
341 #include <sys/mnttab.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
342 +#elif defined(hpux)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
343 +#include </usr/conf/h/mnttab.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
344 #elif defined(SYS_BSD)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
345 #include <fstab.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
346 #elif defined(__linux__)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
347 #include <mntent.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
348 #endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
349
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
350 +#ifdef __MINGW32__
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
351 +#include <sys/timeb.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
352 +static void gettimeofday(struct timeval* t,void* timezone){
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
353 + struct timeb timebuffer;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
354 + ftime( &timebuffer );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
355 + t->tv_sec=timebuffer.time;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
356 + t->tv_usec=1000*timebuffer.millitm;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
357 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
358 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
359 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
360 #include "dvd_udf.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
361 #include "dvd_input.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
362 #include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
363 @@ -144,6 +158,13 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
364 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
365
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
366
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
367 +#ifndef HAVE_MPLAYER
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
368 + #include "get_path.c"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
369 +#else
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
370 + extern char * get_path( char * filename );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
371 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
372 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
373 +//extern char * dvdcss_cache_dir;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
374
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
375 /**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
376 * Open a DVD image or block device file.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
377 @@ -152,7 +173,17 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
378 {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
379 dvd_reader_t *dvd;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
380 dvd_input_t dev;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
381 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
382 + /* setup cache dir is no longer needed, it's now implemented in libdvdcss.c
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
383 + if(!dvdcss_cache_dir){
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
384 + dvdcss_cache_dir=get_path( "" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
385 + if ( dvdcss_cache_dir ) { mkdir( dvdcss_cache_dir,493 ); free( dvdcss_cache_dir ); }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
386 + dvdcss_cache_dir=get_path( "DVDKeys" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
387 + if(dvdcss_cache_dir) mkdir( dvdcss_cache_dir,493 );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
388 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
389 + */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
390
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
391 + /* open it */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
392 dev = DVDinput_open( location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
393 if( !dev ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
394 fprintf( stderr, "libdvdread: Can't open %s for reading\n", location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
395 @@ -222,7 +253,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
396 char *new_path;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
397
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
398 /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
399 - if( !strncmp( path, "/dev/", 5 ) || strncmp( path, "/dev/r", 6 ) )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
400 + if( strncmp( path, "/dev/", 5 ) || !strncmp( path, "/dev/r", 6 ) )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
401 return (char *) strdup( path );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
402
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
403 /* Replace "/dev/" with "/dev/r" */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
404 @@ -242,6 +273,16 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
405
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
406 if( !path ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
407
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
408 +#ifdef WIN32
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
409 + /* Stat doesn't work on devices under mingwin/cygwin. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
410 + if( path[0] && path[1] == ':' && path[2] == '\0' )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
411 + {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
412 + /* Don't try to stat the file */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
413 + fileinfo.st_mode = S_IFBLK;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
414 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
415 + else
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
416 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
417 + {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
418 ret = stat( path, &fileinfo );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
419 if( ret < 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
420 /* If we can't stat the file, give up */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
421 @@ -249,6 +290,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
422 perror("");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
423 return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
424 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
425 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
426
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
427 /* Try to open libdvdcss or fall back to standard functions */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
428 have_css = DVDInputSetup();
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
429 @@ -289,7 +331,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
430 if( cdir >= 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
431 chdir( path_copy );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
432 new_path = getcwd( NULL, PATH_MAX );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
433 +#ifndef __MINGW32__
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
434 fchdir( cdir );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
435 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
436 close( cdir );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
437 if( new_path ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
438 free( path_copy );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
439 @@ -364,6 +408,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
440 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
441 fclose( mntfile );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
442 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
443 +#elif defined(WIN32)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
444 + dev_name = strdup(path);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
445 + auth_drive = DVDOpenImageFile( path, have_css );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
446 #endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
447 if( !dev_name ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
448 fprintf( stderr, "libdvdread: Couldn't find device name.\n" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
449 @@ -554,8 +601,8 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
450 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
451
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
452 if( dvd->css_state == 1 /* Need key init */ ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
453 - initAllCSSKeys( dvd );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
454 - dvd->css_state = 2;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
455 +// initAllCSSKeys( dvd );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
456 +// dvd->css_state = 2;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
457 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
458 /*
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
459 if( DVDinput_seek( dvd_file->dvd->dev,
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
460 @@ -631,10 +678,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
461 dvd_file->title_sizes[ i ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
462 dvd_file->title_devs[ i ] = DVDinput_open( full_path );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
463 dvd_file->filesize += dvd_file->title_sizes[ i ];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
464 + DVDinput_seek( dvd_file->title_devs[ i ], 0, DVDINPUT_SEEK_KEY );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
465 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
466 - if( dvd_file->title_devs[ 0 ] ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
467 - DVDinput_seek( dvd_file->title_devs[ 0 ], 0, DVDINPUT_SEEK_KEY );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
468 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
469 + if( !dvd_file->title_devs[ 0 ] ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
470 free( dvd_file );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
471 return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
472 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
473 @@ -794,7 +840,10 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
474 if( ret < 0 ) return ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
475 /* FIXME: This is wrong if i is the last file in the set.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
476 * also error from this read will not show in ret. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
477 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
478 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
479 + /* Does the next part exist? If not then return now. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
480 + if( !dvd_file->title_devs[ i + 1 ] ) return ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
481 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
482 /* Read part 2 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
483 off = DVDinput_seek( dvd_file->title_devs[ i + 1 ],
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
484 0, DVDINPUT_NOFLAGS );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
485 @@ -846,7 +895,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
486 return (ssize_t)ret;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
487 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
488
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
489 -int32_t DVDFileSeek( dvd_file_t *dvd_file, int32_t offset )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
490 +int DVDFileSeek( dvd_file_t *dvd_file, int offset )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
491 {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
492 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
493 return -1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
494 --- dvdread/dvd_udf.c 2002-05-06 22:16:31.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
495 +++ dvd_udf.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
496 @@ -4,6 +4,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
497 *
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
498 * Modifications by:
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
499 * Billy Biggs <vektor@dumbterm.net>.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
500 + * Björn Englund <d4bjorn@dtek.chalmers.se>.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
501 + * Joey Parrish <joey@nicewarrior.org>.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
502 + * - updated from libdvdread 0.9.4 and removed udf caching
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
503 *
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
504 * dvdudf: parse and read the UDF volume information of a DVD Video
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
505 * Copyright (C) 1999 Christian Wolff for convergence integrated media
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
506 @@ -30,8 +33,10 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
507 #include <stdio.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
508 #include <stdlib.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
509 #include <string.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
510 -#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
511 +//#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
512 +#ifndef __MINGW32__
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
513 #include <sys/ioctl.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
514 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
515 #include <sys/types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
516 #include <sys/stat.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
517 #include <unistd.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
518 @@ -93,6 +98,32 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
519 uint16_t Partition;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
520 };
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
521
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
522 +struct extent_ad {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
523 + uint32_t location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
524 + uint32_t length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
525 +};
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
526 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
527 +struct avdp_t {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
528 + struct extent_ad mvds;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
529 + struct extent_ad rvds;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
530 +};
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
531 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
532 +struct pvd_t {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
533 + uint8_t VolumeIdentifier[32];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
534 + uint8_t VolumeSetIdentifier[128];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
535 +};
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
536 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
537 +struct lbudf {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
538 + uint32_t lb;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
539 + uint8_t *data;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
540 +};
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
541 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
542 +struct icbmap {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
543 + uint32_t lbn;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
544 + struct AD file;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
545 + uint8_t filetype;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
546 +};
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
547 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
548 /* For direct data access, LSB first */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
549 #define GETN1(p) ((uint8_t)data[p])
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
550 #define GETN2(p) ((uint16_t)data[p] | ((uint16_t)data[(p) + 1] << 8))
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
551 @@ -334,6 +365,67 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
552 return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
553 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
554
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
555 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
556 +static int UDFGetAVDP( dvd_reader_t *device,
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
557 + struct avdp_t *avdp)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
558 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
559 + uint8_t Anchor[ DVD_VIDEO_LB_LEN ];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
560 + uint32_t lbnum, MVDS_location, MVDS_length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
561 + uint16_t TagID;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
562 + uint32_t lastsector;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
563 + int terminate;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
564 + struct avdp_t;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
565 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
566 + /* Find Anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
567 + lastsector = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
568 + lbnum = 256; /* Try #1, prime anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
569 + terminate = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
570 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
571 + for(;;) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
572 + if( DVDReadLBUDF( device, lbnum, 1, Anchor, 0 ) > 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
573 + UDFDescriptor( Anchor, &TagID );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
574 + } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
575 + TagID = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
576 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
577 + if (TagID != 2) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
578 + /* Not an anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
579 + if( terminate ) return 0; /* Final try failed */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
580 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
581 + if( lastsector ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
582 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
583 + /* We already found the last sector. Try #3, alternative
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
584 + * backup anchor. If that fails, don't try again.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
585 + */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
586 + lbnum = lastsector;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
587 + terminate = 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
588 + } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
589 + /* TODO: Find last sector of the disc (this is optional). */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
590 + if( lastsector ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
591 + /* Try #2, backup anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
592 + lbnum = lastsector - 256;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
593 + } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
594 + /* Unable to find last sector */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
595 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
596 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
597 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
598 + } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
599 + /* It's an anchor! We can leave */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
600 + break;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
601 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
602 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
603 + /* Main volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
604 + UDFExtentAD( &Anchor[ 16 ], &MVDS_length, &MVDS_location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
605 + avdp->mvds.location = MVDS_location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
606 + avdp->mvds.length = MVDS_length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
607 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
608 + /* Backup volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
609 + UDFExtentAD( &Anchor[ 24 ], &MVDS_length, &MVDS_location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
610 + avdp->rvds.location = MVDS_location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
611 + avdp->rvds.length = MVDS_length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
612 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
613 + return 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
614 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
615 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
616 /**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
617 * Looks for partition on the disc. Returns 1 if partition found, 0 on error.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
618 * partnum: Number of the partition, starting at 0.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
619 @@ -342,52 +434,21 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
620 static int UDFFindPartition( dvd_reader_t *device, int partnum,
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
621 struct Partition *part )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
622 {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
623 - uint8_t LogBlock[ DVD_VIDEO_LB_LEN ], Anchor[ DVD_VIDEO_LB_LEN ];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
624 + uint8_t LogBlock[ DVD_VIDEO_LB_LEN ];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
625 uint32_t lbnum, MVDS_location, MVDS_length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
626 uint16_t TagID;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
627 - uint32_t lastsector;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
628 - int i, terminate, volvalid;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
629 + int i, volvalid;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
630 + struct avdp_t avdp;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
631
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
632 - /* Find Anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
633 - lastsector = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
634 - lbnum = 256; /* Try #1, prime anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
635 - terminate = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
636 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
637 - for(;;) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
638 - if( DVDReadLBUDF( device, lbnum, 1, Anchor, 0 ) > 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
639 - UDFDescriptor( Anchor, &TagID );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
640 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
641 - TagID = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
642 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
643 - if (TagID != 2) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
644 - /* Not an anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
645 - if( terminate ) return 0; /* Final try failed */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
646 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
647 - if( lastsector ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
648 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
649 - /* We already found the last sector. Try #3, alternative
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
650 - * backup anchor. If that fails, don't try again.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
651 - */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
652 - lbnum = lastsector;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
653 - terminate = 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
654 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
655 - /* TODO: Find last sector of the disc (this is optional). */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
656 - if( lastsector ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
657 - /* Try #2, backup anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
658 - lbnum = lastsector - 256;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
659 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
660 - /* Unable to find last sector */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
661 - return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
662 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
663 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
664 - } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
665 - /* It's an anchor! We can leave */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
666 - break;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
667 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
668 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
669 + if(!UDFGetAVDP(device, &avdp)) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
670 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
671 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
672 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
673 /* Main volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
674 - UDFExtentAD( &Anchor[ 16 ], &MVDS_length, &MVDS_location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
675 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
676 + MVDS_location = avdp.mvds.location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
677 + MVDS_length = avdp.mvds.length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
678 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
679 part->valid = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
680 volvalid = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
681 part->VolumeDesc[ 0 ] = '\0';
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
682 @@ -422,8 +483,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
683 && ( ( !part->valid ) || ( !volvalid ) ) );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
684
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
685 if( ( !part->valid) || ( !volvalid ) ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
686 - /* Backup volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
687 - UDFExtentAD( &Anchor[ 24 ], &MVDS_length, &MVDS_location );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
688 + /* Backup volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
689 + MVDS_location = avdp.mvds.location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
690 + MVDS_length = avdp.mvds.length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
691 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
692 } while( i-- && ( ( !part->valid ) || ( !volvalid ) ) );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
693
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
694 @@ -442,17 +504,18 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
695 char tokenline[ MAX_UDF_FILE_NAME_LEN ];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
696 char *token;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
697 uint8_t filetype;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
698 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
699 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
700 *filesize = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
701 tokenline[0] = '\0';
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
702 strcat( tokenline, filename );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
703
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
704 - /* Find partition, 0 is the standard location for DVD Video.*/
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
705 - if( !UDFFindPartition( device, 0, &partition ) ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
706 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
707 - /* Find root dir ICB */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
708 - lbnum = partition.Start;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
709 - do {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
710 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
711 + /* Find partition, 0 is the standard location for DVD Video.*/
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
712 + if( !UDFFindPartition( device, 0, &partition ) ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
713 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
714 + /* Find root dir ICB */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
715 + lbnum = partition.Start;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
716 + do {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
717 if( DVDReadLBUDF( device, lbnum++, 1, LogBlock, 0 ) <= 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
718 TagID = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
719 } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
720 @@ -469,19 +532,27 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
721 /* Sanity checks. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
722 if( TagID != 256 ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
723 if( RootICB.Partition != 0 ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
724 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
725 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
726 /* Find root dir */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
727 if( !UDFMapICB( device, RootICB, &filetype, &partition, &File ) ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
728 if( filetype != 4 ) return 0; /* Root dir should be dir */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
729
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
730 - /* Tokenize filepath */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
731 - token = strtok(tokenline, "/");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
732 - while( token != NULL ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
733 - if( !UDFScanDir( device, File, token, &partition, &ICB ) ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
734 - if( !UDFMapICB( device, ICB, &filetype, &partition, &File ) ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
735 + {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
736 + /* Tokenize filepath */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
737 + token = strtok(tokenline, "/");
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
738 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
739 + while( token != NULL ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
740 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
741 + if( !UDFScanDir( device, File, token, &partition, &ICB)) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
742 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
743 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
744 + if( !UDFMapICB( device, ICB, &filetype, &partition, &File ) ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
745 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
746 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
747 token = strtok( NULL, "/" );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
748 - }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
749 -
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
750 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
751 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
752 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
753 /* Sanity check. */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
754 if( File.Partition != 0 ) return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
755
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
756 @@ -492,3 +563,81 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
757 else
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
758 return partition.Start + File.Location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
759 }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
760 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
761 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
762 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
763 +/**
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
764 + * Gets a Descriptor .
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
765 + * Returns 1 if descriptor found, 0 on error.
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
766 + * id, tagid of descriptor
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
767 + * bufsize, size of BlockBuf (must be >= DVD_VIDEO_LB_LEN).
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
768 + */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
769 +static int UDFGetDescriptor( dvd_reader_t *device, int id,
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
770 + uint8_t *descriptor, int bufsize)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
771 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
772 + uint32_t lbnum, MVDS_location, MVDS_length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
773 + struct avdp_t avdp;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
774 + uint16_t TagID;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
775 + uint32_t lastsector;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
776 + int i, terminate;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
777 + int desc_found = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
778 + /* Find Anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
779 + lastsector = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
780 + lbnum = 256; /* Try #1, prime anchor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
781 + terminate = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
782 + if(bufsize < DVD_VIDEO_LB_LEN) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
783 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
784 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
785 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
786 + if(!UDFGetAVDP(device, &avdp)) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
787 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
788 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
789 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
790 + /* Main volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
791 + MVDS_location = avdp.mvds.location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
792 + MVDS_length = avdp.mvds.length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
793 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
794 + i = 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
795 + do {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
796 + /* Find Descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
797 + lbnum = MVDS_location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
798 + do {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
799 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
800 + if( DVDReadLBUDF( device, lbnum++, 1, descriptor, 0 ) <= 0 ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
801 + TagID = 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
802 + } else {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
803 + UDFDescriptor( descriptor, &TagID );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
804 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
805 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
806 + if( (TagID == id) && ( !desc_found ) ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
807 + /* Descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
808 + desc_found = 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
809 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
810 + } while( ( lbnum <= MVDS_location + ( MVDS_length - 1 )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
811 + / DVD_VIDEO_LB_LEN ) && ( TagID != 8 )
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
812 + && ( !desc_found) );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
813 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
814 + if( !desc_found ) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
815 + /* Backup volume descriptor */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
816 + MVDS_location = avdp.rvds.location;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
817 + MVDS_length = avdp.rvds.length;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
818 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
819 + } while( i-- && ( !desc_found ) );
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
820 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
821 + return desc_found;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
822 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
823 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
824 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
825 +static int UDFGetPVD(dvd_reader_t *device, struct pvd_t *pvd)
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
826 +{
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
827 + uint8_t pvd_buf[DVD_VIDEO_LB_LEN];
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
828 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
829 + if(!UDFGetDescriptor( device, 1, pvd_buf, sizeof(pvd_buf))) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
830 + return 0;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
831 + }
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
832 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
833 + memcpy(pvd->VolumeIdentifier, &pvd_buf[24], 32);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
834 + memcpy(pvd->VolumeSetIdentifier, &pvd_buf[72], 128);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
835 +
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
836 + return 1;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
837 +}
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
838 --- dvdread/ifo_print.c 2002-05-15 21:35:54.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
839 +++ ifo_print.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
840 @@ -23,7 +23,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
841 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
842 #include <string.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
843 #include <ctype.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
844 -#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
845 +//#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
846
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
847 #include "config.h" // Needed for WORDS_BIGENDIAN
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
848 #include "ifo_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
849 --- dvdread/ifo_print.h 2002-04-07 19:52:01.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
850 +++ ifo_print.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
851 @@ -20,8 +20,8 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
852 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
853 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
854
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
855 -#include <dvdread/ifo_types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
856 -#include <dvdread/dvd_reader.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
857 +#include "ifo_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
858 +#include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
859
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
860 #ifdef __cplusplus
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
861 extern "C" {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
862 --- dvdread/ifo_read.c 2002-05-25 21:37:18.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
863 +++ ifo_read.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
864 @@ -22,7 +22,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
865 #include <unistd.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
866 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
867 #include <string.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
868 -#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
869 +//#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
870
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
871 #include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
872
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
873 --- dvdread/ifo_read.h 2002-04-07 19:52:01.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
874 +++ ifo_read.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
875 @@ -20,8 +20,8 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
876 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
877 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
878
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
879 -#include <dvdread/ifo_types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
880 -#include <dvdread/dvd_reader.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
881 +#include "ifo_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
882 +#include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
883
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
884 #ifdef __cplusplus
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
885 extern "C" {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
886 --- dvdread/ifo_types.h 2002-04-07 19:52:01.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
887 +++ ifo_types.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
888 @@ -21,7 +21,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
889 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
890
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
891 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
892 -#include <dvdread/dvd_reader.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
893 +#include "dvd_reader.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
894
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
895
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
896 #undef ATTRIBUTE_PACKED
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
897 --- dvdread/nav_print.c 2002-04-07 19:18:06.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
898 +++ nav_print.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
899 @@ -25,7 +25,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
900
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
901 #include <stdio.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
902 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
903 -#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
904 +//#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
905
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
906 #include "config.h" // Needed for WORDS_BIGENDIAN
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
907 #include "nav_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
908 --- dvdread/nav_print.h 2002-04-07 20:17:19.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
909 +++ nav_print.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
910 @@ -20,7 +20,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
911 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
912 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
913
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
914 -#include <dvdread/nav_types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
915 +#include "nav_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
916
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
917 #ifdef __cplusplus
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
918 extern "C" {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
919 --- dvdread/nav_read.c 2002-04-07 19:52:01.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
920 +++ nav_read.c 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
921 @@ -19,7 +19,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
922 #include <stdio.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
923 #include <string.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
924 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
925 -#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
926 +//#include <assert.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
927
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
928 #include "config.h" // Needed for WORDS_BIGENDIAN
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
929 #include "bswap.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
930 @@ -95,7 +95,9 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
931 /* pci hli btnit */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
932 for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
933 for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
934 +#ifdef HAVE_ASSERT_H
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
935 int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j;
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
936 +#endif
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
937 assert(pci->hli.btnit[n].zero1 == 0);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
938 assert(pci->hli.btnit[n].zero2 == 0);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
939 assert(pci->hli.btnit[n].zero3 == 0);
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
940 --- dvdread/nav_read.h 2002-04-07 20:17:19.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
941 +++ nav_read.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
942 @@ -19,7 +19,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
943 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
944 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
945
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
946 -#include <dvdread/nav_types.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
947 +#include "nav_types.h"
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
948
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
949 #ifdef __cplusplus
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
950 extern "C" {
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
951 --- dvdread/nav_types.h 2002-04-07 20:41:59.000000000 +0200
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
952 +++ nav_types.h 2005-03-01 07:07:46.000000000 +0100
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
953 @@ -30,7 +30,7 @@
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
954 */
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
955
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
956 #include <inttypes.h>
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
957 -#include <dvdread/ifo_types.h> // only dvd_time_t, vm_cmd_t and user_ops_t
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
958 +#include "ifo_types.h" // only dvd_time_t, vm_cmd_t and user_ops_t
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
959
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
960
d18e40806248 MPlayer-specific changes to libdvdread
diego
parents:
diff changeset
961 #undef ATTRIBUTE_PACKED