Mercurial > mplayer.hg
annotate dvdread/dvd_reader.c @ 24055:98ba5d5bfe2d
Sync libdvdread with version 0.9.6.
author | diego |
---|---|
date | Thu, 16 Aug 2007 06:57:43 +0000 |
parents | 1542693b2a30 |
children | eb9f3e3723d1 |
rev | line source |
---|---|
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1 /* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */ |
7029 | 2 /* |
15874 | 3 * Copyright (C) 2001, 2002, 2003 Billy Biggs <vektor@dumbterm.net>, |
4 * Håkan Hjort <d95hjort@dtek.chalmers.se>, | |
5 * Björn Englund <d4bjorn@dtek.chalmers.se> | |
7029 | 6 * |
14938
25df9508f9a8
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12431
diff
changeset
|
7 * Modified for use with MPlayer, changes contained in libdvdread_changes.diff. |
18783 | 8 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
14938
25df9508f9a8
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12431
diff
changeset
|
9 * $Id$ |
25df9508f9a8
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12431
diff
changeset
|
10 * |
7029 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or (at | |
14 * your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, but | |
17 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 * General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. | |
24 */ | |
25 | |
7033 | 26 #include "config.h" |
27 | |
7029 | 28 #include <sys/types.h> |
29 #include <sys/stat.h> | |
30 #include <sys/time.h> /* For the timing of dvdcss_title crack. */ | |
31 #include <fcntl.h> | |
32 #include <stdlib.h> | |
33 #include <stdio.h> | |
34 #include <errno.h> | |
35 #include <string.h> | |
36 #include <unistd.h> | |
37 #include <limits.h> | |
38 #include <dirent.h> | |
39 | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
40 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DARWIN__) || defined(__DragonFly__) |
7029 | 41 #define SYS_BSD 1 |
42 #endif | |
43 | |
44 #if defined(__sun) | |
45 #include <sys/mnttab.h> | |
7423
ad967766679a
hpux DVD support fixes by Martin Gansser <mgansser@ngi.de>
arpi
parents:
7358
diff
changeset
|
46 #elif defined(hpux) |
ad967766679a
hpux DVD support fixes by Martin Gansser <mgansser@ngi.de>
arpi
parents:
7358
diff
changeset
|
47 #include </usr/conf/h/mnttab.h> |
7029 | 48 #elif defined(SYS_BSD) |
49 #include <fstab.h> | |
15534 | 50 #elif defined(__linux__) || defined(__CYGWIN__) |
7029 | 51 #include <mntent.h> |
52 #endif | |
53 | |
18910 | 54 #if defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION <= 3) && (__MINGW32_MINOR_VERSION < 10) |
10825 | 55 #include <sys/timeb.h> |
56 static void gettimeofday(struct timeval* t,void* timezone){ | |
57 struct timeb timebuffer; | |
58 ftime( &timebuffer ); | |
59 t->tv_sec=timebuffer.time; | |
60 t->tv_usec=1000*timebuffer.millitm; | |
61 } | |
62 #endif | |
63 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
64 #include "dvd_reader.h" |
7029 | 65 #include "dvd_input.h" |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
66 #include "dvd_udf.h" |
15874 | 67 #include "md5.h" |
68 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
69 #include "dvdread_internal.h" |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
70 |
15874 | 71 #define DEFAULT_UDF_CACHE_LEVEL 0 |
7029 | 72 |
73 struct dvd_reader_s { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
74 /* Basic information. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
75 int isImageFile; |
7029 | 76 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
77 /* Hack for keeping track of the css status. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
78 * 0: no css, 1: perhaps (need init of keys), 2: have done init */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
79 int css_state; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
80 int css_title; /* Last title that we have called dvdinpute_title for. */ |
7029 | 81 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
82 /* Information required for an image file. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
83 dvd_input_t dev; |
7029 | 84 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
85 /* Information required for a directory path drive. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
86 char *path_root; |
15874 | 87 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
88 /* Filesystem cache */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
89 int udfcache_level; /* 0 - turned off, 1 - on */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
90 void *udfcache; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
91 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
92 /* block aligned malloc */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
93 void *align; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
94 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
95 /* error message verbosity level */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
96 int verbose; |
7029 | 97 }; |
98 | |
99 struct dvd_file_s { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
100 /* Basic information. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
101 dvd_reader_t *dvd; |
7029 | 102 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
103 /* Hack for selecting the right css title. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
104 int css_title; |
7029 | 105 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
106 /* Information required for an image file. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
107 uint32_t lb_start; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
108 uint32_t seek_pos; |
7029 | 109 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
110 /* Information required for a directory path drive. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
111 size_t title_sizes[ 9 ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
112 dvd_input_t title_devs[ 9 ]; |
7029 | 113 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
114 /* Calculated at open-time, size in blocks. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
115 ssize_t filesize; |
7029 | 116 }; |
117 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
118 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
119 #define DVDREAD_VERBOSE_DEFAULT 0 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
120 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
121 int get_verbose(void) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
122 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
123 char *dvdread_verbose; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
124 int verbose; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
125 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
126 dvdread_verbose = getenv("DVDREAD_VERBOSE"); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
127 if(dvdread_verbose) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
128 verbose = (int)strtol(dvdread_verbose, NULL, 0); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
129 } else { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
130 verbose = DVDREAD_VERBOSE_DEFAULT; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
131 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
132 return verbose; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
133 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
134 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
135 int dvdread_verbose(dvd_reader_t *dvd) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
136 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
137 return dvd->verbose; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
138 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
139 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
140 dvd_reader_t *device_of_file(dvd_file_t *file) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
141 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
142 return file->dvd; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
143 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
144 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
145 /** |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
146 * Returns the compiled version. (DVDREAD_VERSION as an int) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
147 */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
148 int DVDVersion(void) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
149 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
150 return DVDREAD_VERSION; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
151 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
152 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
153 |
15874 | 154 /** |
155 * Set the level of caching on udf | |
156 * level = 0 (no caching) | |
157 * level = 1 (caching filesystem info) | |
158 */ | |
159 int DVDUDFCacheLevel(dvd_reader_t *device, int level) | |
160 { | |
161 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
162 | |
163 if(level > 0) { | |
164 level = 1; | |
165 } else if(level < 0) { | |
166 return dev->udfcache_level; | |
167 } | |
168 | |
169 dev->udfcache_level = level; | |
170 | |
171 return level; | |
172 } | |
173 | |
174 void *GetUDFCacheHandle(dvd_reader_t *device) | |
175 { | |
176 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
177 | |
178 return dev->udfcache; | |
179 } | |
180 | |
181 void SetUDFCacheHandle(dvd_reader_t *device, void *cache) | |
182 { | |
183 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; | |
184 | |
185 dev->udfcache = cache; | |
186 } | |
187 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
188 void *GetAlignHandle(dvd_reader_t *device) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
189 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
190 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
191 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
192 return dev->align; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
193 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
194 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
195 void SetAlignHandle(dvd_reader_t *device, void *align) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
196 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
197 struct dvd_reader_s *dev = (struct dvd_reader_s *)device; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
198 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
199 dev->align = align; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
200 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
201 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
202 #ifdef WIN32 /* replacement gettimeofday implementation */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
203 #include <sys/timeb.h> |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
204 static int gettimeofday( struct timeval *tv, void *tz ) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
205 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
206 struct timeb t; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
207 ftime( &t ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
208 tv->tv_sec = t.time; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
209 tv->tv_usec = t.millitm * 1000; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
210 return 0; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
211 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
212 #endif |
15874 | 213 |
214 | |
7029 | 215 /* Loop over all titles and call dvdcss_title to crack the keys. */ |
216 static int initAllCSSKeys( dvd_reader_t *dvd ) | |
217 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
218 struct timeval all_s, all_e; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
219 struct timeval t_s, t_e; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
220 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
221 uint32_t start, len; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
222 int title; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
223 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
224 char *nokeys_str = getenv("DVDREAD_NOKEYS"); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
225 if(nokeys_str != NULL) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
226 return 0; |
15874 | 227 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
228 if(dvd->verbose >= 1) { |
7029 | 229 fprintf( stderr, "\n" ); |
230 fprintf( stderr, "libdvdread: Attempting to retrieve all CSS keys\n" ); | |
231 fprintf( stderr, "libdvdread: This can take a _long_ time, " | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
232 "please be patient\n\n" ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
233 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
234 gettimeofday(&all_s, NULL); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
235 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
236 for( title = 0; title < 100; title++ ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
237 gettimeofday( &t_s, NULL ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
238 if( title == 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
239 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
240 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
241 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
242 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
243 start = UDFFindFile( dvd, filename, &len ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
244 if( start != 0 && len != 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
245 /* Perform CSS key cracking for this title. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
246 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
247 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
248 filename, start ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
249 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
250 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
251 if(dvd->verbose >= 0) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
252 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)\n", filename, start); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
253 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
254 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
255 gettimeofday( &t_e, NULL ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
256 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
257 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
258 (long int) t_e.tv_sec - t_s.tv_sec ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
259 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
260 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
261 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
262 if( title == 0 ) continue; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
263 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
264 gettimeofday( &t_s, NULL ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
265 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
266 start = UDFFindFile( dvd, filename, &len ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
267 if( start == 0 || len == 0 ) break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
268 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
269 /* Perform CSS key cracking for this title. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
270 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
271 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n", |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
272 filename, start ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
273 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
274 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
275 if(dvd->verbose >= 0) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
276 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)!!\n", filename, start); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
277 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
278 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
279 gettimeofday( &t_e, NULL ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
280 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
281 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
282 (long int) t_e.tv_sec - t_s.tv_sec ); |
7029 | 283 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
284 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
285 title--; |
7029 | 286 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
287 if(dvd->verbose >= 1) { |
7029 | 288 fprintf( stderr, "libdvdread: Found %d VTS's\n", title ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
289 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
290 gettimeofday(&all_e, NULL); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
291 if(dvd->verbose >= 1) { |
7029 | 292 fprintf( stderr, "libdvdread: Elapsed time %ld\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
293 (long int) all_e.tv_sec - all_s.tv_sec ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
294 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
295 return 0; |
7029 | 296 } |
297 | |
298 | |
299 | |
300 /** | |
301 * Open a DVD image or block device file. | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
302 * Checks if the root directory in the udf image file can be found. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
303 * If not it assumes this isn't a valid udf image and returns NULL |
7029 | 304 */ |
305 static dvd_reader_t *DVDOpenImageFile( const char *location, int have_css ) | |
306 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
307 dvd_reader_t *dvd; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
308 dvd_input_t dev; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
309 int verbose; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
310 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
311 verbose = get_verbose(); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
312 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
313 dev = dvdinput_open( location ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
314 if( !dev ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
315 if(verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
316 fprintf( stderr, "libdvdread: Can't open '%s' for reading: %s\n", |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
317 location, strerror(errno)); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
318 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
319 return NULL; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
320 } |
7029 | 321 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
322 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
323 if( !dvd ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
324 int tmp_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
325 dvdinput_close(dev); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
326 errno = tmp_errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
327 return NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
328 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
329 dvd->verbose = verbose; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
330 dvd->isImageFile = 1; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
331 dvd->dev = dev; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
332 dvd->path_root = NULL; |
7029 | 333 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
334 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
335 dvd->udfcache = NULL; |
15874 | 336 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
337 dvd->align = NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
338 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
339 if( have_css ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
340 /* Only if DVDCSS_METHOD = title, a bit if it's disc or if |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
341 * DVDCSS_METHOD = key but region missmatch. Unfortunaly we |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
342 * don't have that information. */ |
7029 | 343 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
344 dvd->css_state = 1; /* Need key init. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
345 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
346 dvd->css_title = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
347 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
348 /* sanity check, is it a valid UDF image, can we find the root dir */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
349 if(!UDFFindFile(dvd, "/", NULL)) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
350 dvdinput_close(dvd->dev); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
351 if(dvd->udfcache) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
352 FreeUDFCache(dvd, dvd->udfcache); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
353 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
354 if(dvd->align) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
355 if(dvd->verbose >= 0) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
356 fprintf(stderr, "libdvdread: DVDOpenImageFile(): Memory leak in align functions 1\n"); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
357 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
358 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
359 free(dvd); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
360 return NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
361 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
362 return dvd; |
7029 | 363 } |
364 | |
365 static dvd_reader_t *DVDOpenPath( const char *path_root ) | |
366 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
367 dvd_reader_t *dvd; |
7029 | 368 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
369 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
370 if( !dvd ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
371 return NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
372 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
373 dvd->verbose = get_verbose(); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
374 dvd->isImageFile = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
375 dvd->dev = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
376 dvd->path_root = strdup( path_root ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
377 if(!dvd->path_root) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
378 free(dvd); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
379 return 0; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
380 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
381 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
382 dvd->udfcache = NULL; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
383 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
384 dvd->align = NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
385 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
386 dvd->css_state = 0; /* Only used in the UDF path */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
387 dvd->css_title = 0; /* Only matters in the UDF path */ |
15874 | 388 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
389 return dvd; |
7029 | 390 } |
391 | |
392 #if defined(__sun) | |
393 /* /dev/rdsk/c0t6d0s0 (link to /devices/...) | |
394 /vol/dev/rdsk/c0t6d0/?? | |
395 /vol/rdsk/<name> */ | |
396 static char *sun_block2char( const char *path ) | |
397 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
398 char *new_path; |
7029 | 399 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
400 /* Must contain "/dsk/" */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
401 if( !strstr( path, "/dsk/" ) ) return (char *) strdup( path ); |
7029 | 402 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
403 /* Replace "/dsk/" with "/rdsk/" */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
404 new_path = malloc( strlen(path) + 2 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
405 strcpy( new_path, path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
406 strcpy( strstr( new_path, "/dsk/" ), "" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
407 strcat( new_path, "/rdsk/" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
408 strcat( new_path, strstr( path, "/dsk/" ) + strlen( "/dsk/" ) ); |
7029 | 409 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
410 return new_path; |
7029 | 411 } |
412 #endif | |
413 | |
414 #if defined(SYS_BSD) | |
415 /* FreeBSD /dev/(r)(a)cd0c (a is for atapi), recomended to _not_ use r | |
24055 | 416 update: FreeBSD and DragonFly no longer uses the prefix so don't add it. |
417 | |
7029 | 418 OpenBSD /dev/rcd0c, it needs to be the raw device |
419 NetBSD /dev/rcd0[d|c|..] d for x86, c (for non x86), perhaps others | |
420 Darwin /dev/rdisk0, it needs to be the raw device | |
24055 | 421 BSD/OS /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) |
422 | |
423 returns a string allocated with strdup which should be free()'d when | |
424 no longer used. | |
425 */ | |
7029 | 426 static char *bsd_block2char( const char *path ) |
16510 | 427 { |
24055 | 428 #if defined(__FreeBSD__) || defined(__DragonFly__) |
429 return (char *) strdup( path ); | |
16510 | 430 #else |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
431 char *new_path; |
7029 | 432 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
433 /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
434 if( strncmp( path, "/dev/", 5 ) || !strncmp( path, "/dev/r", 6 ) ) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
435 return (char *) strdup( path ); |
7029 | 436 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
437 /* Replace "/dev/" with "/dev/r" */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
438 new_path = malloc( strlen(path) + 2 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
439 strcpy( new_path, "/dev/r" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
440 strcat( new_path, path + strlen( "/dev/" ) ); |
7029 | 441 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
442 return new_path; |
24055 | 443 #endif /* __FreeBSD__ || __DragonFly__ */ |
7029 | 444 } |
445 #endif | |
446 | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
447 |
7029 | 448 dvd_reader_t *DVDOpen( const char *path ) |
449 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
450 struct stat fileinfo; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
451 int ret, have_css; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
452 char *dev_name = NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
453 int internal_errno = 0; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
454 int verbose; |
7029 | 455 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
456 if( path == NULL ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
457 errno = EINVAL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
458 return NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
459 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
460 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
461 verbose = get_verbose(); |
7029 | 462 |
12431
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
463 #ifdef WIN32 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
464 /* Stat doesn't work on devices under mingwin/cygwin. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
465 if( path[0] && path[1] == ':' && path[2] == '\0' ) |
12431
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
466 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
467 /* Don't try to stat the file */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
468 fileinfo.st_mode = S_IFBLK; |
12431
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
469 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
470 else |
12431
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
471 #endif |
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
472 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
473 ret = stat( path, &fileinfo ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
474 if( ret < 0 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
475 int tmp_errno = errno; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
476 /* If we can't stat the file, give up */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
477 if(verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
478 fprintf( stderr, "libdvdread: Can't stat '%s': %s\n", |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
479 path, strerror(errno)); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
480 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
481 errno = tmp_errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
482 return NULL; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
483 } |
12431
663fdd72e594
Encrypted dvd playback now accepts -dvd-drive e: on mingw. fix from libdvdread, left out the various cosmetics changes for now
faust3
parents:
10825
diff
changeset
|
484 } |
7029 | 485 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
486 /* Try to open libdvdcss or fall back to standard functions */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
487 have_css = dvdinput_setup(); |
7029 | 488 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
489 /* First check if this is a block/char device or a file*/ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
490 if( S_ISBLK( fileinfo.st_mode ) || |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
491 S_ISCHR( fileinfo.st_mode ) || |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
492 S_ISREG( fileinfo.st_mode ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
493 /** |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
494 * Block devices and regular files are assumed to be DVD-Video images. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
495 */ |
24055 | 496 dvd_reader_t *dvd = NULL; |
7029 | 497 #if defined(__sun) |
24055 | 498 dev_name = sun_block2char( path ); |
7029 | 499 #elif defined(SYS_BSD) |
24055 | 500 dev_name = bsd_block2char( path ); |
7029 | 501 #else |
24055 | 502 dev_name = strdup( path ); |
7029 | 503 #endif |
24055 | 504 dvd = DVDOpenImageFile( dev_name, have_css ); |
505 free( dev_name ); | |
506 | |
507 return dvd; | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
508 } else if( S_ISDIR( fileinfo.st_mode ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
509 dvd_reader_t *auth_drive = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
510 char *path_copy; |
7029 | 511 #if defined(SYS_BSD) |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
512 struct fstab* fe; |
15534 | 513 #elif defined(__sun) || defined(__linux__) || defined(__CYGWIN__) |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
514 FILE *mntfile; |
7029 | 515 #endif |
516 | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
517 /* XXX: We should scream real loud here. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
518 if( !(path_copy = strdup( path ) ) ) return 0; |
7029 | 519 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
520 #ifndef WIN32 /* don't have fchdir, and getcwd( NULL, ... ) is strange */ |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
521 /* Resolve any symlinks and get the absolut dir name. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
522 { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
523 char *new_path; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
524 char *current_path; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
525 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
526 current_path = malloc(PATH_MAX); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
527 if(current_path) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
528 if(!getcwd(current_path, PATH_MAX)) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
529 free(current_path); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
530 current_path = NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
531 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
532 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
533 if(current_path) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
534 chdir( path_copy ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
535 new_path = malloc(PATH_MAX); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
536 if(new_path) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
537 if(!getcwd(new_path, PATH_MAX )) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
538 free(new_path); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
539 new_path = NULL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
540 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
541 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
542 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
543 chdir(current_path); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
544 free(current_path); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
545 if( new_path ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
546 free( path_copy ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
547 path_copy = new_path; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
548 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
549 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
550 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
551 #endif |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
552 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
553 /** |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
554 * If we're being asked to open a directory, check if that directory |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
555 * is the mountpoint for a DVD-ROM which we can use instead. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
556 */ |
7029 | 557 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
558 if( strlen( path_copy ) > 1 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
559 if( path_copy[ strlen( path_copy ) - 1 ] == '/' ) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
560 path_copy[ strlen( path_copy ) - 1 ] = '\0'; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
561 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
562 } |
7029 | 563 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
564 if( strlen( path_copy ) >= 9 ) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
565 if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]), |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
566 "/video_ts" ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
567 path_copy[ strlen( path_copy ) - 9 ] = '\0'; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
568 if(path_copy[0] == '\0') { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
569 path_copy[0] = '/'; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
570 path_copy[1] = '\0'; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
571 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
572 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
573 } |
7029 | 574 |
575 #if defined(SYS_BSD) | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
576 if( ( fe = getfsfile( path_copy ) ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
577 dev_name = bsd_block2char( fe->fs_spec ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
578 if(verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
579 fprintf( stderr, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
580 "libdvdread: Attempting to use device %s" |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
581 " mounted on %s%s\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
582 dev_name, |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
583 fe->fs_file, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
584 have_css ? " for CSS authentication" : ""); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
585 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
586 auth_drive = DVDOpenImageFile( dev_name, have_css ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
587 if(!auth_drive) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
588 internal_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
589 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
590 } |
7029 | 591 #elif defined(__sun) |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
592 mntfile = fopen( MNTTAB, "r" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
593 if( mntfile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
594 struct mnttab mp; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
595 int res; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
596 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
597 while( ( res = getmntent( mntfile, &mp ) ) != -1 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
598 if( res == 0 && !strcmp( mp.mnt_mountp, path_copy ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
599 dev_name = sun_block2char( mp.mnt_special ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
600 if(verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
601 fprintf( stderr, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
602 "libdvdread: Attempting to use device %s" |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
603 " mounted on %s%s\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
604 dev_name, |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
605 mp.mnt_mountp, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
606 have_css ? " for CSS authentication" : ""); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
607 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
608 auth_drive = DVDOpenImageFile( dev_name, have_css ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
609 if(!auth_drive) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
610 internal_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
611 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
612 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
613 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
614 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
615 fclose( mntfile ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
616 } |
15534 | 617 #elif defined(__linux__) || defined(__CYGWIN__) |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
618 mntfile = fopen( MOUNTED, "r" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
619 if( mntfile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
620 struct mntent *me; |
7029 | 621 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
622 while( ( me = getmntent( mntfile ) ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
623 if( !strcmp( me->mnt_dir, path_copy ) ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
624 if(verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
625 fprintf( stderr, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
626 "libdvdread: Attempting to use device %s" |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
627 " mounted on %s%s\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
628 me->mnt_fsname, |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
629 me->mnt_dir, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
630 have_css ? " for CSS authentication" : ""); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
631 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
632 auth_drive = DVDOpenImageFile( me->mnt_fsname, have_css ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
633 if(!auth_drive) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
634 internal_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
635 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
636 dev_name = strdup(me->mnt_fsname); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
637 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
638 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
639 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
640 fclose( mntfile ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
641 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
642 #elif defined(__MINGW32__) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
643 dev_name = strdup(path); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
644 auth_drive = DVDOpenImageFile( path, have_css ); |
7029 | 645 #endif |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
646 if( !dev_name ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
647 if(verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
648 fprintf( stderr, "libdvdread: Couldn't find device name.\n" ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
649 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
650 } else if( !auth_drive ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
651 if(verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
652 fprintf( stderr, "libdvdread: Device %s inaccessible%s: %s\n", |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
653 dev_name, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
654 have_css ? ", CSS authentication not available" : "", |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
655 strerror(internal_errno)); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
656 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
657 } |
7029 | 658 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
659 free( dev_name ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
660 free( path_copy ); |
7029 | 661 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
662 /** |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
663 * If we've opened a drive, just use that. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
664 */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
665 if( auth_drive ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
666 return auth_drive; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
667 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
668 /** |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
669 * Otherwise, we now try to open the directory tree instead. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
670 */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
671 return DVDOpenPath( path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
672 } |
7029 | 673 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
674 /* If it's none of the above, screw it. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
675 if(verbose >= 1) { |
7029 | 676 fprintf( stderr, "libdvdread: Could not open %s\n", path ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
677 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
678 return 0; |
7029 | 679 } |
680 | |
681 void DVDClose( dvd_reader_t *dvd ) | |
682 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
683 if( dvd ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
684 if( dvd->dev ) dvdinput_close( dvd->dev ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
685 if( dvd->path_root ) free( dvd->path_root ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
686 if( dvd->udfcache ) FreeUDFCache( dvd, dvd->udfcache ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
687 if(dvd->align) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
688 if(dvd->verbose >= 0) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
689 fprintf(stderr, "libdvdread: DVDClose(): Memory leak in align functions\n"); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
690 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
691 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
692 dvdinput_free(); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
693 free( dvd ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
694 } |
7029 | 695 } |
696 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
697 void DVDInit(void) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
698 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
699 dvdinput_setup(); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
700 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
701 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
702 void DVDFinish(void) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
703 { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
704 dvdinput_free(); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
705 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
706 |
7029 | 707 /** |
708 * Open an unencrypted file on a DVD image file. | |
709 */ | |
710 static dvd_file_t *DVDOpenFileUDF( dvd_reader_t *dvd, char *filename ) | |
711 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
712 uint32_t start, len; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
713 dvd_file_t *dvd_file; |
7029 | 714 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
715 start = UDFFindFile( dvd, filename, &len ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
716 if( !start ) return 0; |
7029 | 717 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
718 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
719 if( !dvd_file ) return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
720 dvd_file->dvd = dvd; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
721 dvd_file->lb_start = start; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
722 dvd_file->seek_pos = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
723 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
724 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
725 dvd_file->filesize = len / DVD_VIDEO_LB_LEN; |
7029 | 726 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
727 return dvd_file; |
7029 | 728 } |
729 | |
730 /** | |
731 * Searches for <file> in directory <path>, ignoring case. | |
732 * Returns 0 and full filename in <filename>. | |
733 * or -1 on file not found. | |
734 * or -2 on path not found. | |
735 */ | |
736 static int findDirFile( const char *path, const char *file, char *filename ) | |
737 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
738 DIR *dir; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
739 struct dirent *ent; |
7029 | 740 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
741 dir = opendir( path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
742 if( !dir ) return -2; |
7029 | 743 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
744 while( ( ent = readdir( dir ) ) != NULL ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
745 if( !strcasecmp( ent->d_name, file ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
746 sprintf( filename, "%s%s%s", path, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
747 ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ), |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
748 ent->d_name ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
749 closedir(dir); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
750 return 0; |
7029 | 751 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
752 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
753 closedir(dir); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
754 return -1; |
7029 | 755 } |
756 | |
757 static int findDVDFile( dvd_reader_t *dvd, const char *file, char *filename ) | |
758 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
759 char video_path[ PATH_MAX + 1 ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
760 const char *nodirfile; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
761 int ret; |
7029 | 762 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
763 /* Strip off the directory for our search */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
764 if( !strncasecmp( "/VIDEO_TS/", file, 10 ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
765 nodirfile = &(file[ 10 ]); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
766 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
767 nodirfile = file; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
768 } |
7029 | 769 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
770 ret = findDirFile( dvd->path_root, nodirfile, filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
771 if( ret < 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
772 /* Try also with adding the path, just in case. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
773 sprintf( video_path, "%s/VIDEO_TS/", dvd->path_root ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
774 ret = findDirFile( video_path, nodirfile, filename ); |
7029 | 775 if( ret < 0 ) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
776 /* Try with the path, but in lower case. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
777 sprintf( video_path, "%s/video_ts/", dvd->path_root ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
778 ret = findDirFile( video_path, nodirfile, filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
779 if( ret < 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
780 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
781 } |
7029 | 782 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
783 } |
7029 | 784 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
785 return 1; |
7029 | 786 } |
787 | |
788 /** | |
789 * Open an unencrypted file from a DVD directory tree. | |
790 */ | |
791 static dvd_file_t *DVDOpenFilePath( dvd_reader_t *dvd, char *filename ) | |
792 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
793 char full_path[ PATH_MAX + 1 ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
794 dvd_file_t *dvd_file; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
795 struct stat fileinfo; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
796 dvd_input_t dev; |
7029 | 797 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
798 /* Get the full path of the file. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
799 if( !findDVDFile( dvd, filename, full_path ) ) return 0; |
7029 | 800 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
801 dev = dvdinput_open( full_path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
802 if( !dev ) return 0; |
7029 | 803 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
804 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
805 if( !dvd_file ) return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
806 dvd_file->dvd = dvd; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
807 dvd_file->lb_start = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
808 dvd_file->seek_pos = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
809 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
810 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
811 dvd_file->filesize = 0; |
7029 | 812 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
813 if( stat( full_path, &fileinfo ) < 0 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
814 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
815 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
7029 | 816 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
817 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
818 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
819 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
820 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
821 dvd_file->title_devs[ 0 ] = dev; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
822 dvd_file->filesize = dvd_file->title_sizes[ 0 ]; |
7029 | 823 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
824 return dvd_file; |
7029 | 825 } |
826 | |
827 static dvd_file_t *DVDOpenVOBUDF( dvd_reader_t *dvd, int title, int menu ) | |
828 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
829 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
830 uint32_t start, len; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
831 dvd_file_t *dvd_file; |
7029 | 832 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
833 if( title == 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
834 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
835 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
836 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
837 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
838 start = UDFFindFile( dvd, filename, &len ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
839 if( start == 0 ) return 0; |
7029 | 840 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
841 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
842 if( !dvd_file ) return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
843 dvd_file->dvd = dvd; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
844 /*Hack*/ dvd_file->css_title = title << 1 | menu; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
845 dvd_file->lb_start = start; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
846 dvd_file->seek_pos = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
847 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
848 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
849 dvd_file->filesize = len / DVD_VIDEO_LB_LEN; |
7029 | 850 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
851 /* Calculate the complete file size for every file in the VOBS */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
852 if( !menu ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
853 int cur; |
7029 | 854 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
855 for( cur = 2; cur < 10; cur++ ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
856 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
857 if( !UDFFindFile( dvd, filename, &len ) ) break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
858 dvd_file->filesize += len / DVD_VIDEO_LB_LEN; |
7029 | 859 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
860 } |
7029 | 861 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
862 if( dvd->css_state == 1 /* Need key init */ ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
863 // initAllCSSKeys( dvd ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
864 // dvd->css_state = 2; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
865 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
866 /* |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
867 if( dvdinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) { |
7029 | 868 fprintf( stderr, "libdvdread: Error cracking CSS key for %s\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
869 filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
870 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
871 */ |
7029 | 872 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
873 return dvd_file; |
7029 | 874 } |
875 | |
876 static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu ) | |
877 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
878 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
879 char full_path[ PATH_MAX + 1 ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
880 struct stat fileinfo; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
881 dvd_file_t *dvd_file; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
882 int i; |
7029 | 883 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
884 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
885 if( !dvd_file ) return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
886 dvd_file->dvd = dvd; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
887 /*Hack*/ dvd_file->css_title = title << 1 | menu; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
888 dvd_file->lb_start = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
889 dvd_file->seek_pos = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
890 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
891 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
892 dvd_file->filesize = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
893 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
894 if( menu ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
895 dvd_input_t dev; |
7029 | 896 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
897 if( title == 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
898 sprintf( filename, "VIDEO_TS.VOB" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
899 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
900 sprintf( filename, "VTS_%02i_0.VOB", title ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
901 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
902 if( !findDVDFile( dvd, filename, full_path ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
903 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
904 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
905 } |
7029 | 906 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
907 dev = dvdinput_open( full_path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
908 if( dev == NULL ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
909 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
910 return 0; |
7029 | 911 } |
912 | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
913 if( stat( full_path, &fileinfo ) < 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
914 if(dvd->verbose >= 1) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
915 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
916 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
917 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
918 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
919 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
920 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
921 dvd_file->title_devs[ 0 ] = dev; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
922 dvdinput_title( dvd_file->title_devs[0], 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
923 dvd_file->filesize = dvd_file->title_sizes[ 0 ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
924 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
925 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
926 for( i = 0; i < 9; ++i ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
927 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
928 sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
929 if( !findDVDFile( dvd, filename, full_path ) ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
930 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
931 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
932 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
933 if( stat( full_path, &fileinfo ) < 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
934 if(dvd->verbose >= 1) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
935 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
936 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
937 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
938 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
939 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
940 dvd_file->title_sizes[ i ] = fileinfo.st_size / DVD_VIDEO_LB_LEN; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
941 dvd_file->title_devs[ i ] = dvdinput_open( full_path ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
942 dvdinput_title( dvd_file->title_devs[ i ], 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
943 dvd_file->filesize += dvd_file->title_sizes[ i ]; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
944 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
945 if( !dvd_file->title_devs[ 0 ] ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
946 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
947 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
948 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
949 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
950 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
951 return dvd_file; |
7029 | 952 } |
953 | |
954 dvd_file_t *DVDOpenFile( dvd_reader_t *dvd, int titlenum, | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
955 dvd_read_domain_t domain ) |
7029 | 956 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
957 char filename[ MAX_UDF_FILE_NAME_LEN ]; |
15874 | 958 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
959 /* Check arguments. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
960 if( dvd == NULL || titlenum < 0 ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
961 errno = EINVAL; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
962 return NULL; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
963 } |
7029 | 964 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
965 switch( domain ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
966 case DVD_READ_INFO_FILE: |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
967 if( titlenum == 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
968 sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
969 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
970 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
971 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
972 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
973 case DVD_READ_INFO_BACKUP_FILE: |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
974 if( titlenum == 0 ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
975 sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
976 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
977 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
978 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
979 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
980 case DVD_READ_MENU_VOBS: |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
981 if( dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
982 return DVDOpenVOBUDF( dvd, titlenum, 1 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
983 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
984 return DVDOpenVOBPath( dvd, titlenum, 1 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
985 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
986 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
987 case DVD_READ_TITLE_VOBS: |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
988 if( titlenum == 0 ) return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
989 if( dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
990 return DVDOpenVOBUDF( dvd, titlenum, 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
991 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
992 return DVDOpenVOBPath( dvd, titlenum, 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
993 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
994 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
995 default: |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
996 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
997 fprintf( stderr, "libdvdread: Invalid domain for file open.\n" ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
998 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
999 errno = EINVAL; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1000 return NULL; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1001 } |
7029 | 1002 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1003 if( dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1004 return DVDOpenFileUDF( dvd, filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1005 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1006 return DVDOpenFilePath( dvd, filename ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1007 } |
7029 | 1008 } |
1009 | |
1010 void DVDCloseFile( dvd_file_t *dvd_file ) | |
1011 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1012 int i; |
7029 | 1013 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1014 if( dvd_file ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1015 if( dvd_file->dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1016 ; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1017 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1018 for( i = 0; i < 9; ++i ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1019 if( dvd_file->title_devs[ i ] ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1020 dvdinput_close( dvd_file->title_devs[i] ); |
7029 | 1021 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1022 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1023 } |
7029 | 1024 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1025 free( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1026 dvd_file = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1027 } |
7029 | 1028 } |
1029 | |
24055 | 1030 static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title, |
1031 int menu, dvd_stat_t *statbuf) | |
1032 { | |
1033 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
1034 uint32_t size; | |
1035 off_t tot_size; | |
1036 off_t parts_size[9]; | |
1037 int nr_parts = 0; | |
1038 int n; | |
1039 | |
1040 if( title == 0 ) { | |
1041 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" ); | |
1042 } else { | |
1043 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); | |
1044 } | |
1045 if(!UDFFindFile( dvd, filename, &size )) { | |
1046 return -1; | |
1047 } | |
1048 tot_size = size; | |
1049 nr_parts = 1; | |
1050 parts_size[0] = size; | |
1051 | |
1052 if( !menu ) { | |
1053 int cur; | |
1054 | |
1055 for( cur = 2; cur < 10; cur++ ) { | |
1056 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur ); | |
1057 if( !UDFFindFile( dvd, filename, &size ) ) { | |
1058 break; | |
1059 } | |
1060 parts_size[nr_parts] = size; | |
1061 tot_size += size; | |
1062 nr_parts++; | |
1063 } | |
1064 } | |
1065 | |
1066 statbuf->size = tot_size; | |
1067 statbuf->nr_parts = nr_parts; | |
1068 for(n = 0; n < nr_parts; n++) { | |
1069 statbuf->parts_size[n] = parts_size[n]; | |
1070 } | |
1071 return 0; | |
1072 } | |
1073 | |
1074 | |
1075 static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title, | |
1076 int menu, dvd_stat_t *statbuf ) | |
1077 { | |
1078 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
1079 char full_path[ PATH_MAX + 1 ]; | |
1080 struct stat fileinfo; | |
1081 off_t tot_size; | |
1082 off_t parts_size[9]; | |
1083 int nr_parts = 0; | |
1084 int n; | |
1085 | |
1086 | |
1087 | |
1088 if( title == 0 ) { | |
1089 sprintf( filename, "VIDEO_TS.VOB" ); | |
1090 } else { | |
1091 sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 ); | |
1092 } | |
1093 if( !findDVDFile( dvd, filename, full_path ) ) { | |
1094 return -1; | |
1095 } | |
1096 | |
1097 if( stat( full_path, &fileinfo ) < 0 ) { | |
1098 if(dvd->verbose >= 1) { | |
1099 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
1100 } | |
1101 return -1; | |
1102 } | |
1103 | |
1104 | |
1105 tot_size = fileinfo.st_size; | |
1106 nr_parts = 1; | |
1107 parts_size[0] = fileinfo.st_size; | |
1108 | |
1109 if( !menu ) { | |
1110 int cur; | |
1111 | |
1112 for( cur = 2; cur < 10; cur++ ) { | |
1113 | |
1114 sprintf( filename, "VTS_%02d_%d.VOB", title, cur ); | |
1115 if( !findDVDFile( dvd, filename, full_path ) ) { | |
1116 break; | |
1117 } | |
1118 | |
1119 if( stat( full_path, &fileinfo ) < 0 ) { | |
1120 if(dvd->verbose >= 1) { | |
1121 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
1122 } | |
1123 break; | |
1124 } | |
1125 | |
1126 parts_size[nr_parts] = fileinfo.st_size; | |
1127 tot_size += parts_size[nr_parts]; | |
1128 nr_parts++; | |
1129 } | |
1130 } | |
1131 | |
1132 statbuf->size = tot_size; | |
1133 statbuf->nr_parts = nr_parts; | |
1134 for(n = 0; n < nr_parts; n++) { | |
1135 statbuf->parts_size[n] = parts_size[n]; | |
1136 } | |
1137 return 0; | |
1138 } | |
1139 | |
1140 | |
1141 int DVDFileStat(dvd_reader_t *dvd, int titlenum, | |
1142 dvd_read_domain_t domain, dvd_stat_t *statbuf) | |
1143 { | |
1144 char filename[ MAX_UDF_FILE_NAME_LEN ]; | |
1145 char full_path[ PATH_MAX + 1 ]; | |
1146 struct stat fileinfo; | |
1147 uint32_t size; | |
1148 | |
1149 /* Check arguments. */ | |
1150 if( dvd == NULL || titlenum < 0 ) { | |
1151 errno = EINVAL; | |
1152 return -1; | |
1153 } | |
1154 | |
1155 switch( domain ) { | |
1156 case DVD_READ_INFO_FILE: | |
1157 if( titlenum == 0 ) { | |
1158 sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" ); | |
1159 } else { | |
1160 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum ); | |
1161 } | |
1162 break; | |
1163 case DVD_READ_INFO_BACKUP_FILE: | |
1164 if( titlenum == 0 ) { | |
1165 sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" ); | |
1166 } else { | |
1167 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum ); | |
1168 } | |
1169 break; | |
1170 case DVD_READ_MENU_VOBS: | |
1171 if( dvd->isImageFile ) { | |
1172 return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf ); | |
1173 } else { | |
1174 return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf ); | |
1175 } | |
1176 break; | |
1177 case DVD_READ_TITLE_VOBS: | |
1178 if( titlenum == 0 ) { | |
1179 return -1; | |
1180 } | |
1181 if( dvd->isImageFile ) { | |
1182 return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf ); | |
1183 } else { | |
1184 return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf ); | |
1185 } | |
1186 break; | |
1187 default: | |
1188 if(dvd->verbose >= 1) { | |
1189 fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" ); | |
1190 } | |
1191 errno = EINVAL; | |
1192 return -1; | |
1193 } | |
1194 | |
1195 if( dvd->isImageFile ) { | |
1196 if( UDFFindFile( dvd, filename, &size ) ) { | |
1197 statbuf->size = size; | |
1198 statbuf->nr_parts = 1; | |
1199 statbuf->parts_size[0] = size; | |
1200 return 0; | |
1201 } | |
1202 } else { | |
1203 if( findDVDFile( dvd, filename, full_path ) ) { | |
1204 if( stat( full_path, &fileinfo ) < 0 ) { | |
1205 if(dvd->verbose >= 1) { | |
1206 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename ); | |
1207 } | |
1208 } else { | |
1209 statbuf->size = fileinfo.st_size; | |
1210 statbuf->nr_parts = 1; | |
1211 statbuf->parts_size[0] = statbuf->size; | |
1212 return 0; | |
1213 } | |
1214 } | |
1215 } | |
1216 return -1; | |
1217 } | |
1218 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1219 /** |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1220 * Internal, but used from dvd_udf.c |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1221 * |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1222 * @param device A read handle. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1223 * @param lb_number Logical block number to start read from. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1224 * @param block_count Number of logical blocks to read. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1225 * @param data Pointer to buffer where read data should be stored. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1226 * This buffer must be large enough to hold lb_number*2048 bytes. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1227 * The pointer must be aligned to the logical block size when |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1228 * reading from a raw/O_DIRECT device. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1229 * @param encrypted 0 if no decryption shall be performed, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1230 * 1 if decryption shall be performed |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1231 * @param return Returns number of blocks read on success, negative on error |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1232 */ |
15874 | 1233 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number, |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1234 size_t block_count, unsigned char *data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1235 int encrypted ) |
7029 | 1236 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1237 int ret; |
7029 | 1238 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1239 if( !device->dev ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1240 if(device->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1241 fprintf( stderr, "libdvdread: Fatal error in block read.\n" ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1242 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1243 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1244 } |
7029 | 1245 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1246 ret = dvdinput_seek( device->dev, (int) lb_number ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1247 if( ret != (int) lb_number ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1248 if(device->verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1249 fprintf( stderr, |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1250 "libdvdread: UDFReadBlocksRaw: Can't seek to block %u\n", |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1251 lb_number ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1252 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1253 return 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1254 } |
7029 | 1255 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1256 return dvdinput_read( device->dev, (char *) data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1257 (int) block_count, encrypted ); |
7029 | 1258 } |
1259 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1260 /** |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1261 * This is using a single input and starting from 'dvd_file->lb_start' offset. |
7029 | 1262 * |
1263 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset' | |
1264 * into the buffer located at 'data' and if 'encrypted' is set | |
1265 * descramble the data if it's encrypted. Returning either an | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1266 * negative error or the number of blocks read. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1267 * |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1268 * @param data Pointer to buffer where read data should be placed. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1269 * This buffer must be large enough to hold block_count*2048 bytes. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1270 * The pointer must be aligned to 2048 bytes when reading from |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1271 * a raw/O_DIRECT device. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1272 * @return Returns the number of blocks read on success or a negative error. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1273 */ |
7029 | 1274 static int DVDReadBlocksUDF( dvd_file_t *dvd_file, uint32_t offset, |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1275 size_t block_count, unsigned char *data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1276 int encrypted ) |
7029 | 1277 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1278 return UDFReadBlocksRaw( dvd_file->dvd, dvd_file->lb_start + offset, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1279 block_count, data, encrypted ); |
7029 | 1280 } |
1281 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1282 /** |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1283 * This is using possibly several inputs and starting from an offset of '0'. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1284 * data must be aligned to logical block size (2048 bytes) of the device |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1285 * for raw/O_DIRECT devices to work |
7029 | 1286 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset' |
1287 * into the buffer located at 'data' and if 'encrypted' is set | |
1288 * descramble the data if it's encrypted. Returning either an | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1289 * negative error or the number of blocks read. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1290 * |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1291 * @param dvd_file A file read handle. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1292 * @param offset Block offset from start of file. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1293 * @return Returns number of blocks read on success, negative on error. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1294 */ |
7029 | 1295 static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset, |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1296 size_t block_count, unsigned char *data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1297 int encrypted ) |
7029 | 1298 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1299 int i; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1300 int ret, ret2, off; |
7029 | 1301 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1302 ret = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1303 ret2 = 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1304 for( i = 0; i < 9; ++i ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1305 if( !dvd_file->title_sizes[ i ] ) return 0; /* Past end of file */ |
7029 | 1306 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1307 if( offset < dvd_file->title_sizes[ i ] ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1308 if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1309 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1310 if( off < 0 || off != (int)offset ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1311 if(dvd_file->dvd->verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1312 fprintf( stderr, "libdvdread: DVDReadBlocksPath1: Can't seek to block %d\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1313 offset ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1314 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1315 return off < 0 ? off : 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1316 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1317 ret = dvdinput_read( dvd_file->title_devs[ i ], data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1318 (int)block_count, encrypted ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1319 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1320 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1321 size_t part1_size = dvd_file->title_sizes[ i ] - offset; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1322 /* FIXME: Really needs to be a while loop. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1323 * (This is only true if you try and read >1GB at a time) */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1324 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1325 /* Read part 1 */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1326 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1327 if( off < 0 || off != (int)offset ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1328 if(dvd_file->dvd->verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1329 fprintf( stderr, "libdvdread: DVDReadBlocksPath2: Can't seek to block %d\n", |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1330 offset ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1331 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1332 return off < 0 ? off : 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1333 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1334 ret = dvdinput_read( dvd_file->title_devs[ i ], data, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1335 (int)part1_size, encrypted ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1336 if( ret < 0 ) return ret; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1337 /* FIXME: This is wrong if i is the last file in the set. |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1338 * also error from this read will not show in ret. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1339 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1340 /* Does the next part exist? If not then return now. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1341 if( !dvd_file->title_devs[ i + 1 ] ) return ret; |
7358
bb40478265df
I experienced several segfaults when trying to play (unencrypted) DVDs
arpi
parents:
7033
diff
changeset
|
1342 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1343 /* Read part 2 */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1344 off = dvdinput_seek( dvd_file->title_devs[ i + 1 ], 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1345 if( off < 0 || off != 0 ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1346 if(dvd_file->dvd->verbose >= 1) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1347 fprintf( stderr, "libdvdread: DVDReadBlocksPath3: Can't seek to block %d\n", 0 ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1348 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1349 return off < 0 ? off : 0; |
7029 | 1350 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1351 ret2 = dvdinput_read( dvd_file->title_devs[ i + 1 ], |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1352 data + ( part1_size |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1353 * (int64_t)DVD_VIDEO_LB_LEN ), |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1354 (int)(block_count - part1_size), |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1355 encrypted ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1356 if( ret2 < 0 ) return ret2; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1357 break; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1358 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1359 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1360 offset -= dvd_file->title_sizes[ i ]; |
7029 | 1361 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1362 } |
7029 | 1363 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1364 return ret + ret2; |
7029 | 1365 } |
1366 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1367 /** |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1368 * This is broken reading more than 2Gb at a time if ssize_t is 32-bit. |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1369 */ |
7029 | 1370 ssize_t DVDReadBlocks( dvd_file_t *dvd_file, int offset, |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1371 size_t block_count, unsigned char *data ) |
7029 | 1372 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1373 int ret; |
7029 | 1374 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1375 /* Check arguments. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1376 if( dvd_file == NULL || offset < 0 || data == NULL ) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1377 return -1; |
15874 | 1378 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1379 /* Hack, and it will still fail for multiple opens in a threaded app ! */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1380 if( dvd_file->dvd->css_title != dvd_file->css_title ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1381 dvd_file->dvd->css_title = dvd_file->css_title; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1382 if( dvd_file->dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1383 dvdinput_title( dvd_file->dvd->dev, (int)dvd_file->lb_start ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1384 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1385 /* Here each vobu has it's own dvdcss handle, so no need to update |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1386 else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1387 dvdinput_title( dvd_file->title_devs[ 0 ], (int)dvd_file->lb_start ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1388 }*/ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1389 } |
7029 | 1390 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1391 if( dvd_file->dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1392 ret = DVDReadBlocksUDF( dvd_file, (uint32_t)offset, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1393 block_count, data, DVDINPUT_READ_DECRYPT ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1394 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1395 ret = DVDReadBlocksPath( dvd_file, (unsigned int)offset, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1396 block_count, data, DVDINPUT_READ_DECRYPT ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1397 } |
7029 | 1398 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1399 return (ssize_t)ret; |
7029 | 1400 } |
1401 | |
10017
535a53c058f8
There are conflicting definitions for DVDFileSeek in the .c and .h file.
diego
parents:
9333
diff
changeset
|
1402 int DVDFileSeek( dvd_file_t *dvd_file, int offset ) |
7029 | 1403 { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1404 /* Check arguments. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1405 if( dvd_file == NULL || offset < 0 ) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1406 return -1; |
15874 | 1407 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1408 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1409 return -1; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1410 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1411 dvd_file->seek_pos = (uint32_t) offset; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1412 return offset; |
7029 | 1413 } |
1414 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1415 #ifndef HAVE_UINTPTR_T |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1416 #warning "Assuming that (unsigned long) can hold (void *)" |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1417 typedef unsigned long uintptr_t; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1418 #endif |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1419 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1420 #define DVD_ALIGN(ptr) (void *)((((uintptr_t)(ptr)) + (DVD_VIDEO_LB_LEN-1)) \ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1421 / DVD_VIDEO_LB_LEN * DVD_VIDEO_LB_LEN) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1422 |
7029 | 1423 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size ) |
1424 { | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1425 unsigned char *secbuf_start; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1426 unsigned char *secbuf; //must be aligned to 2048-bytes for raw/O_DIRECT |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1427 unsigned int numsec, seek_sector, seek_byte; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1428 int ret; |
7029 | 1429 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1430 /* Check arguments. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1431 if( dvd_file == NULL || data == NULL ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1432 errno = EINVAL; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1433 return -1; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1434 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1435 seek_sector = dvd_file->seek_pos / DVD_VIDEO_LB_LEN; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1436 seek_byte = dvd_file->seek_pos % DVD_VIDEO_LB_LEN; |
7029 | 1437 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1438 numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) + |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1439 ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1440 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1441 /* must align to 2048 bytes if we are reading from raw/O_DIRECT */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1442 secbuf_start = (unsigned char *) malloc( (numsec+1) * DVD_VIDEO_LB_LEN ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1443 if( !secbuf_start ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1444 /* errno will be set to ENOMEM by malloc */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1445 return -1; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1446 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1447 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1448 secbuf = DVD_ALIGN(secbuf_start); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1449 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1450 if( dvd_file->dvd->isImageFile ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1451 ret = DVDReadBlocksUDF( dvd_file, (uint32_t) seek_sector, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1452 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1453 } else { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1454 ret = DVDReadBlocksPath( dvd_file, seek_sector, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1455 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1456 } |
7029 | 1457 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1458 if( ret != (int) numsec ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1459 free( secbuf_start ); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1460 return ret < 0 ? ret : 0; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1461 } |
7029 | 1462 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1463 memcpy( data, &(secbuf[ seek_byte ]), byte_size ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1464 free( secbuf_start ); |
7029 | 1465 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1466 dvd_file->seek_pos += byte_size; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1467 return byte_size; |
7029 | 1468 } |
1469 | |
1470 ssize_t DVDFileSize( dvd_file_t *dvd_file ) | |
1471 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1472 /* Check arguments. */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1473 if( dvd_file == NULL ) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1474 return -1; |
15874 | 1475 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1476 return dvd_file->filesize; |
7029 | 1477 } |
15874 | 1478 |
1479 int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid ) | |
1480 { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1481 struct md5_ctx ctx; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1482 int title; |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1483 int nr_of_files = 0; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1484 int tmp_errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1485 int nofiles_errno = ENOENT; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1486 /* Check arguments. */ |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1487 if( dvd == NULL || discid == NULL ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1488 errno = EINVAL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1489 return -1; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1490 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1491 /* Go through the first 10 IFO:s, in order, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1492 * and md5sum them, i.e VIDEO_TS.IFO and VTS_0?_0.IFO */ |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1493 md5_init_ctx( &ctx ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1494 for( title = 0; title < 10; title++ ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1495 dvd_file_t *dvd_file = DVDOpenFile( dvd, title, DVD_READ_INFO_FILE ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1496 if( dvd_file != NULL ) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1497 ssize_t bytes_read; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1498 size_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1499 char *buffer = malloc( file_size ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1500 |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1501 nr_of_files++; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1502 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1503 if( buffer == NULL ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1504 /* errno will be set to ENOMEM by malloc */ |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1505 return -1; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1506 } |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1507 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1508 bytes_read = DVDReadBytes( dvd_file, buffer, file_size ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1509 if( bytes_read != file_size ) { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1510 tmp_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1511 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1512 fprintf( stderr, "libdvdread: DVDDiscId read returned %d bytes" |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1513 ", wanted %d\n", (int)bytes_read, (int)file_size ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1514 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1515 free(buffer); |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1516 DVDCloseFile( dvd_file ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1517 errno = tmp_errno; |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1518 return -1; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1519 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1520 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1521 md5_process_bytes( buffer, file_size, &ctx ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1522 |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1523 DVDCloseFile( dvd_file ); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1524 free( buffer ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1525 } else { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1526 if(errno != ENOENT) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1527 nofiles_errno = errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1528 } |
15874 | 1529 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1530 } |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1531 md5_finish_ctx( &ctx, discid ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1532 if(nr_of_files == 0) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1533 errno = nofiles_errno; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1534 return -1; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1535 } |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1536 return 0; |
15874 | 1537 } |
1538 | |
1539 | |
1540 int DVDISOVolumeInfo( dvd_reader_t *dvd, | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1541 char *volid, unsigned int volid_size, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1542 unsigned char *volsetid, unsigned int volsetid_size ) |
15874 | 1543 { |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1544 unsigned char *buffer; /* must be aligned to 2048 for raw/O_DIRECT */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1545 unsigned char *buffer_start; |
15874 | 1546 int ret; |
1547 | |
1548 /* Check arguments. */ | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1549 if( dvd == NULL ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1550 errno = EINVAL; |
15874 | 1551 return -1; |
1552 } | |
1553 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1554 if( dvd->dev == NULL ) { |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1555 /* No block access, so no ISO... */ |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1556 errno = EINVAL; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1557 return -1; |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1558 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1559 |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1560 buffer_start = malloc( 2 * DVD_VIDEO_LB_LEN ); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1561 if( buffer_start == NULL ) { |
15874 | 1562 return -1; |
1563 } | |
1564 | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1565 buffer = DVD_ALIGN(buffer_start); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1566 |
15874 | 1567 ret = UDFReadBlocksRaw( dvd, 16, 1, buffer, 0 ); |
1568 if( ret != 1 ) { | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1569 if(dvd->verbose >= 1) { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1570 fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to " |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1571 "read ISO9660 Primary Volume Descriptor!\n" ); |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1572 } |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1573 free(buffer_start); |
15874 | 1574 return -1; |
1575 } | |
1576 | |
1577 if( (volid != NULL) && (volid_size > 0) ) { | |
1578 unsigned int n; | |
1579 for(n = 0; n < 32; n++) { | |
1580 if(buffer[40+n] == 0x20) { | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1581 break; |
15874 | 1582 } |
1583 } | |
1584 | |
1585 if(volid_size > n+1) { | |
1586 volid_size = n+1; | |
1587 } | |
1588 | |
1589 memcpy(volid, &buffer[40], volid_size-1); | |
1590 volid[volid_size-1] = '\0'; | |
1591 } | |
1592 | |
1593 if( (volsetid != NULL) && (volsetid_size > 0) ) { | |
1594 if(volsetid_size > 128) { | |
1595 volsetid_size = 128; | |
1596 } | |
1597 memcpy(volsetid, &buffer[190], volsetid_size); | |
1598 } | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1599 free(buffer_start); |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
1600 |
15874 | 1601 return 0; |
1602 } | |
1603 | |
1604 | |
1605 int DVDUDFVolumeInfo( dvd_reader_t *dvd, | |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1606 char *volid, unsigned int volid_size, |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1607 unsigned char *volsetid, unsigned int volsetid_size ) |
15874 | 1608 { |
1609 int ret; | |
1610 /* Check arguments. */ | |
1611 if( dvd == NULL ) | |
1612 return -1; | |
1613 | |
1614 if( dvd->dev == NULL ) { | |
1615 /* No block access, so no UDF VolumeSet Identifier */ | |
1616 return -1; | |
1617 } | |
1618 | |
1619 if( (volid != NULL) && (volid_size > 0) ) { | |
1620 ret = UDFGetVolumeIdentifier(dvd, volid, volid_size); | |
1621 if(!ret) { | |
1622 return -1; | |
1623 } | |
1624 } | |
1625 if( (volsetid != NULL) && (volsetid_size > 0) ) { | |
1626 ret = UDFGetVolumeSetIdentifier(dvd, volsetid, volsetid_size); | |
1627 if(!ret) { | |
1628 return -1; | |
1629 } | |
1630 } | |
1631 | |
1632 return 0; | |
1633 } |