annotate libmpdvdkit2/dvd_reader.c @ 16161:58f47c971d53

Sync to 1.055 - last commit contains also update ;-(
author danny
date Mon, 01 Aug 2005 13:17:28 +0000
parents 483e955893b8
children 881e136ebf1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1 /*
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
2 * Copyright (C) 2001, 2002, 2003 Billy Biggs <vektor@dumbterm.net>,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
3 * Håkan Hjort <d95hjort@dtek.chalmers.se>,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
4 * Björn Englund <d4bjorn@dtek.chalmers.se>
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
5 *
14938
25df9508f9a8 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12431
diff changeset
6 * Modified for use with MPlayer, changes contained in libdvdread_changes.diff.
25df9508f9a8 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12431
diff changeset
7 * detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
25df9508f9a8 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12431
diff changeset
8 * $Id$
25df9508f9a8 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12431
diff changeset
9 *
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or (at
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
13 * your option) any later version.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
14 *
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful, but
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
18 * General Public License for more details.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
19 *
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
23 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
24
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
25 #include "config.h"
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
26
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
27 #include <sys/types.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
28 #include <sys/stat.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
29 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
30 #include <fcntl.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
31 #include <stdlib.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
32 #include <stdio.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
33 #include <errno.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
34 #include <string.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
35 #include <unistd.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
36 #include <limits.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
37 #include <dirent.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
38
15566
3758536dcef3 DragonFly BSD support
diego
parents: 15534
diff changeset
39 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)|| defined(__DARWIN__) || defined(__DragonFly__)
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
40 #define SYS_BSD 1
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
41 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
42
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
43 #if defined(__sun)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
44 #include <sys/mnttab.h>
7423
ad967766679a hpux DVD support fixes by Martin Gansser <mgansser@ngi.de>
arpi
parents: 7358
diff changeset
45 #elif defined(hpux)
ad967766679a hpux DVD support fixes by Martin Gansser <mgansser@ngi.de>
arpi
parents: 7358
diff changeset
46 #include </usr/conf/h/mnttab.h>
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
47 #elif defined(SYS_BSD)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
48 #include <fstab.h>
15534
77c0e983c155 Support playing DVDs from harddrive directories.
diego
parents: 14938
diff changeset
49 #elif defined(__linux__) || defined(__CYGWIN__)
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
50 #include <mntent.h>
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
51 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
52
10825
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
53 #ifdef __MINGW32__
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
54 #include <sys/timeb.h>
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
55 static void gettimeofday(struct timeval* t,void* timezone){
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
56 struct timeb timebuffer;
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
57 ftime( &timebuffer );
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
58 t->tv_sec=timebuffer.time;
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
59 t->tv_usec=1000*timebuffer.millitm;
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
60 }
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
61 #endif
b9bbfd4a0acc fix debug compilation on mingw
faust3
parents: 10511
diff changeset
62
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
63 #include "dvd_udf.h"
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
64 #include "dvd_input.h"
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
65 #include "dvd_reader.h"
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
66 #include "md5.h"
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
67
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
68 #define DEFAULT_UDF_CACHE_LEVEL 0
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
69
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
70 struct dvd_reader_s {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
71 /* Basic information. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
72 int isImageFile;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
73
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
74 /* Hack for keeping track of the css status.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
75 * 0: no css, 1: perhaps (need init of keys), 2: have done init */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
76 int css_state;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
77 int css_title; /* Last title that we have called dvdinpute_title for. */
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
78
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
79 /* Information required for an image file. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
80 dvd_input_t dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
81
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
82 /* Information required for a directory path drive. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
83 char *path_root;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
84
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
85 /* Filesystem cache */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
86 int udfcache_level; /* 0 - turned off, 1 - on */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
87 void *udfcache;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
88 };
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
89
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
90 struct dvd_file_s {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
91 /* Basic information. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
92 dvd_reader_t *dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
93
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
94 /* Hack for selecting the right css title. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
95 int css_title;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
96
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
97 /* Information required for an image file. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
98 uint32_t lb_start;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
99 uint32_t seek_pos;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
100
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
101 /* Information required for a directory path drive. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
102 size_t title_sizes[ 9 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
103 dvd_input_t title_devs[ 9 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
104
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
105 /* Calculated at open-time, size in blocks. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
106 ssize_t filesize;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
107 };
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
108
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
109 /**
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
110 * Set the level of caching on udf
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
111 * level = 0 (no caching)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
112 * level = 1 (caching filesystem info)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
113 */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
114 int DVDUDFCacheLevel(dvd_reader_t *device, int level)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
115 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
116 struct dvd_reader_s *dev = (struct dvd_reader_s *)device;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
117
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
118 if(level > 0) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
119 level = 1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
120 } else if(level < 0) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
121 return dev->udfcache_level;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
122 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
123
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
124 dev->udfcache_level = level;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
125
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
126 return level;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
127 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
128
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
129 void *GetUDFCacheHandle(dvd_reader_t *device)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
130 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
131 struct dvd_reader_s *dev = (struct dvd_reader_s *)device;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
132
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
133 return dev->udfcache;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
134 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
135
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
136 void SetUDFCacheHandle(dvd_reader_t *device, void *cache)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
137 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
138 struct dvd_reader_s *dev = (struct dvd_reader_s *)device;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
139
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
140 dev->udfcache = cache;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
141 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
142
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
143
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
144
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
145 /* Loop over all titles and call dvdcss_title to crack the keys. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
146 static int initAllCSSKeys( dvd_reader_t *dvd )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
147 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
148 struct timeval all_s, all_e;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
149 struct timeval t_s, t_e;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
150 char filename[ MAX_UDF_FILE_NAME_LEN ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
151 uint32_t start, len;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
152 int title;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
153
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
154 char *nokeys_str = getenv("DVDREAD_NOKEYS");
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
155 if(nokeys_str != NULL)
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
156 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
157
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
158 fprintf( stderr, "\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
159 fprintf( stderr, "libdvdread: Attempting to retrieve all CSS keys\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
160 fprintf( stderr, "libdvdread: This can take a _long_ time, "
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
161 "please be patient\n\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
162
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
163 gettimeofday(&all_s, NULL);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
164
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
165 for( title = 0; title < 100; title++ ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
166 gettimeofday( &t_s, NULL );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
167 if( title == 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
168 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
169 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
170 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
171 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
172 start = UDFFindFile( dvd, filename, &len );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
173 if( start != 0 && len != 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
174 /* Perform CSS key cracking for this title. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
175 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
176 filename, start );
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
177 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) {
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
178 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)\n", filename, start);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
179 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
180 gettimeofday( &t_e, NULL );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
181 fprintf( stderr, "libdvdread: Elapsed time %ld\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
182 (long int) t_e.tv_sec - t_s.tv_sec );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
183 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
184
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
185 if( title == 0 ) continue;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
186
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
187 gettimeofday( &t_s, NULL );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
188 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, 1 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
189 start = UDFFindFile( dvd, filename, &len );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
190 if( start == 0 || len == 0 ) break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
191
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
192 /* Perform CSS key cracking for this title. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
193 fprintf( stderr, "libdvdread: Get key for %s at 0x%08x\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
194 filename, start );
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
195 if( dvdinput_title( dvd->dev, (int)start ) < 0 ) {
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
196 fprintf( stderr, "libdvdread: Error cracking CSS key for %s (0x%08x)!!\n", filename, start);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
197 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
198 gettimeofday( &t_e, NULL );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
199 fprintf( stderr, "libdvdread: Elapsed time %ld\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
200 (long int) t_e.tv_sec - t_s.tv_sec );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
201 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
202 title--;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
203
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
204 fprintf( stderr, "libdvdread: Found %d VTS's\n", title );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
205 gettimeofday(&all_e, NULL);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
206 fprintf( stderr, "libdvdread: Elapsed time %ld\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
207 (long int) all_e.tv_sec - all_s.tv_sec );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
208
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
209 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
210 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
211
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
212
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
213 #ifndef HAVE_MPLAYER
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
214 #include "get_path.c"
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
215 #else
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
216 extern char * get_path( char * filename );
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
217 #endif
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
218
9333
f0f0f176d298 sync with libdvdcss 1.2.5 (including u8->uint8_t and whitespace cosmetics...)
arpi
parents: 8881
diff changeset
219 //extern char * dvdcss_cache_dir;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
220
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
221 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
222 * Open a DVD image or block device file.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
223 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
224 static dvd_reader_t *DVDOpenImageFile( const char *location, int have_css )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
225 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
226 dvd_reader_t *dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
227 dvd_input_t dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
228
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
229 dev = dvdinput_open( location );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
230 if( !dev ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
231 fprintf( stderr, "libdvdread: Can't open %s for reading\n", location );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
232 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
233 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
234
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
235 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
236 if( !dvd ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
237 dvd->isImageFile = 1;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
238 dvd->dev = dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
239 dvd->path_root = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
240
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
241 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
242 dvd->udfcache = NULL;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
243
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
244 if( have_css ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
245 /* Only if DVDCSS_METHOD = title, a bit if it's disc or if
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
246 * DVDCSS_METHOD = key but region missmatch. Unfortunaly we
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
247 * don't have that information. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
248
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
249 dvd->css_state = 1; /* Need key init. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
250 }
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
251 dvd->css_title = 0;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
252
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
253 return dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
254 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
255
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
256 static dvd_reader_t *DVDOpenPath( const char *path_root )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
257 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
258 dvd_reader_t *dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
259
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
260 dvd = (dvd_reader_t *) malloc( sizeof( dvd_reader_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
261 if( !dvd ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
262 dvd->isImageFile = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
263 dvd->dev = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
264 dvd->path_root = strdup( path_root );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
265
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
266 dvd->udfcache_level = DEFAULT_UDF_CACHE_LEVEL;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
267 dvd->udfcache = NULL;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
268
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
269 dvd->css_state = 0; /* Only used in the UDF path */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
270 dvd->css_title = 0; /* Only matters in the UDF path */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
271
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
272 return dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
273 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
274
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
275 #if defined(__sun)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
276 /* /dev/rdsk/c0t6d0s0 (link to /devices/...)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
277 /vol/dev/rdsk/c0t6d0/??
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
278 /vol/rdsk/<name> */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
279 static char *sun_block2char( const char *path )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
280 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
281 char *new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
282
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
283 /* Must contain "/dsk/" */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
284 if( !strstr( path, "/dsk/" ) ) return (char *) strdup( path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
285
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
286 /* Replace "/dsk/" with "/rdsk/" */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
287 new_path = malloc( strlen(path) + 2 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
288 strcpy( new_path, path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
289 strcpy( strstr( new_path, "/dsk/" ), "" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
290 strcat( new_path, "/rdsk/" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
291 strcat( new_path, strstr( path, "/dsk/" ) + strlen( "/dsk/" ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
292
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
293 return new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
294 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
295 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
296
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
297 #if defined(SYS_BSD)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
298 /* FreeBSD /dev/(r)(a)cd0c (a is for atapi), recomended to _not_ use r
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
299 OpenBSD /dev/rcd0c, it needs to be the raw device
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
300 NetBSD /dev/rcd0[d|c|..] d for x86, c (for non x86), perhaps others
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
301 Darwin /dev/rdisk0, it needs to be the raw device
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
302 BSD/OS /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
303 static char *bsd_block2char( const char *path )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
304 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
305 char *new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
306
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
307 /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */
10511
dc98cee9a50f 10l fix by Bjrn Sandell <biorn@dce.chalmers.se>
alex
parents: 10443
diff changeset
308 if( strncmp( path, "/dev/", 5 ) || !strncmp( path, "/dev/r", 6 ) )
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
309 return (char *) strdup( path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
310
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
311 /* Replace "/dev/" with "/dev/r" */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
312 new_path = malloc( strlen(path) + 2 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
313 strcpy( new_path, "/dev/r" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
314 strcat( new_path, path + strlen( "/dev/" ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
315
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
316 return new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
317 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
318 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
319
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
320 dvd_reader_t *DVDOpen( const char *path )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
321 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
322 struct stat fileinfo;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
323 int ret, have_css;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
324 char *dev_name = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
325
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
326 if( path == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
327 return 0;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
328
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
329 #ifdef WIN32
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
330 /* Stat doesn't work on devices under mingwin/cygwin. */
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
331 if( path[0] && path[1] == ':' && path[2] == '\0' )
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
332 {
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
333 /* Don't try to stat the file */
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
334 fileinfo.st_mode = S_IFBLK;
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
335 }
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
336 else
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
337 #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
338 {
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
339 ret = stat( path, &fileinfo );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
340 if( ret < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
341 /* If we can't stat the file, give up */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
342 fprintf( stderr, "libdvdread: Can't stat %s\n", path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
343 perror("");
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
344 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
345 }
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
346 }
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
347
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
348 /* Try to open libdvdcss or fall back to standard functions */
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
349 have_css = dvdinput_setup();
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
350
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
351 /* First check if this is a block/char device or a file*/
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
352 if( S_ISBLK( fileinfo.st_mode ) ||
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
353 S_ISCHR( fileinfo.st_mode ) ||
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
354 S_ISREG( fileinfo.st_mode ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
355
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
356 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
357 * Block devices and regular files are assumed to be DVD-Video images.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
358 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
359 #if defined(__sun)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
360 return DVDOpenImageFile( sun_block2char( path ), have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
361 #elif defined(SYS_BSD)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
362 return DVDOpenImageFile( bsd_block2char( path ), have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
363 #else
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
364 return DVDOpenImageFile( path, have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
365 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
366
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
367 } else if( S_ISDIR( fileinfo.st_mode ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
368 dvd_reader_t *auth_drive = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
369 char *path_copy;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
370 #if defined(SYS_BSD)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
371 struct fstab* fe;
15534
77c0e983c155 Support playing DVDs from harddrive directories.
diego
parents: 14938
diff changeset
372 #elif defined(__sun) || defined(__linux__) || defined(__CYGWIN__)
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
373 FILE *mntfile;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
374 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
375
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
376 /* XXX: We should scream real loud here. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
377 if( !(path_copy = strdup( path ) ) ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
378
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
379 /* Resolve any symlinks and get the absolut dir name. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
380 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
381 char *new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
382 int cdir = open( ".", O_RDONLY );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
383
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
384 if( cdir >= 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
385 chdir( path_copy );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
386 new_path = getcwd( NULL, PATH_MAX );
10443
8d7ca7c06ca6 MinGW support in mpdvdkit
diego
parents: 10017
diff changeset
387 #ifndef __MINGW32__
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
388 fchdir( cdir );
10443
8d7ca7c06ca6 MinGW support in mpdvdkit
diego
parents: 10017
diff changeset
389 #endif
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
390 close( cdir );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
391 if( new_path ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
392 free( path_copy );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
393 path_copy = new_path;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
394 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
395 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
396 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
397
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
398 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
399 * If we're being asked to open a directory, check if that directory
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
400 * is the mountpoint for a DVD-ROM which we can use instead.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
401 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
402
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
403 if( strlen( path_copy ) > 1 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
404 if( path_copy[ strlen( path_copy ) - 1 ] == '/' )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
405 path_copy[ strlen( path_copy ) - 1 ] = '\0';
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
406 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
407
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
408 if( strlen( path_copy ) > 9 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
409 if( !strcasecmp( &(path_copy[ strlen( path_copy ) - 9 ]),
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
410 "/video_ts" ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
411 path_copy[ strlen( path_copy ) - 9 ] = '\0';
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
412 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
413 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
414
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
415 #if defined(SYS_BSD)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
416 if( ( fe = getfsfile( path_copy ) ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
417 dev_name = bsd_block2char( fe->fs_spec );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
418 fprintf( stderr,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
419 "libdvdread: Attempting to use device %s"
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
420 " mounted on %s for CSS authentication\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
421 dev_name,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
422 fe->fs_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
423 auth_drive = DVDOpenImageFile( dev_name, have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
424 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
425 #elif defined(__sun)
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
426 mntfile = fopen( MNTTAB, "r" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
427 if( mntfile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
428 struct mnttab mp;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
429 int res;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
430
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
431 while( ( res = getmntent( mntfile, &mp ) ) != -1 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
432 if( res == 0 && !strcmp( mp.mnt_mountp, path_copy ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
433 dev_name = sun_block2char( mp.mnt_special );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
434 fprintf( stderr,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
435 "libdvdread: Attempting to use device %s"
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
436 " mounted on %s for CSS authentication\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
437 dev_name,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
438 mp.mnt_mountp );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
439 auth_drive = DVDOpenImageFile( dev_name, have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
440 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
441 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
442 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
443 fclose( mntfile );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
444 }
15534
77c0e983c155 Support playing DVDs from harddrive directories.
diego
parents: 14938
diff changeset
445 #elif defined(__linux__) || defined(__CYGWIN__)
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
446 mntfile = fopen( MOUNTED, "r" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
447 if( mntfile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
448 struct mntent *me;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
449
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
450 while( ( me = getmntent( mntfile ) ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
451 if( !strcmp( me->mnt_dir, path_copy ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
452 fprintf( stderr,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
453 "libdvdread: Attempting to use device %s"
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
454 " mounted on %s for CSS authentication\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
455 me->mnt_fsname,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
456 me->mnt_dir );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
457 auth_drive = DVDOpenImageFile( me->mnt_fsname, have_css );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
458 dev_name = strdup(me->mnt_fsname);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
459 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
460 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
461 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
462 fclose( mntfile );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
463 }
15534
77c0e983c155 Support playing DVDs from harddrive directories.
diego
parents: 14938
diff changeset
464 #elif defined(__MINGW32__)
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
465 dev_name = strdup(path);
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
466 auth_drive = DVDOpenImageFile( path, have_css );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
467 #endif
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
468 if( !dev_name ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
469 fprintf( stderr, "libdvdread: Couldn't find device name.\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
470 } else if( !auth_drive ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
471 fprintf( stderr, "libdvdread: Device %s inaccessible, "
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
472 "CSS authentication not available.\n", dev_name );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
473 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
474
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
475 free( dev_name );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
476 free( path_copy );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
477
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
478 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
479 * If we've opened a drive, just use that.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
480 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
481 if( auth_drive ) return auth_drive;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
482
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
483 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
484 * Otherwise, we now try to open the directory tree instead.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
485 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
486 return DVDOpenPath( path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
487 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
488
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
489 /* If it's none of the above, screw it. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
490 fprintf( stderr, "libdvdread: Could not open %s\n", path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
491 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
492 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
493
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
494 void DVDClose( dvd_reader_t *dvd )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
495 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
496 if( dvd ) {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
497 if( dvd->dev ) dvdinput_close( dvd->dev );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
498 if( dvd->path_root ) free( dvd->path_root );
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
499 if( dvd->udfcache ) FreeUDFCache( dvd->udfcache );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
500 free( dvd );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
501 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
502 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
503
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
504 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
505 * Open an unencrypted file on a DVD image file.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
506 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
507 static dvd_file_t *DVDOpenFileUDF( dvd_reader_t *dvd, char *filename )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
508 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
509 uint32_t start, len;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
510 dvd_file_t *dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
511
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
512 start = UDFFindFile( dvd, filename, &len );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
513 if( !start ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
514
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
515 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
516 if( !dvd_file ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
517 dvd_file->dvd = dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
518 dvd_file->lb_start = start;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
519 dvd_file->seek_pos = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
520 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
521 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
522 dvd_file->filesize = len / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
523
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
524 return dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
525 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
526
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
527 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
528 * Searches for <file> in directory <path>, ignoring case.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
529 * Returns 0 and full filename in <filename>.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
530 * or -1 on file not found.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
531 * or -2 on path not found.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
532 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
533 static int findDirFile( const char *path, const char *file, char *filename )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
534 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
535 DIR *dir;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
536 struct dirent *ent;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
537
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
538 dir = opendir( path );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
539 if( !dir ) return -2;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
540
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
541 while( ( ent = readdir( dir ) ) != NULL ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
542 if( !strcasecmp( ent->d_name, file ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
543 sprintf( filename, "%s%s%s", path,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
544 ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
545 ent->d_name );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
546 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
547 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
548 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
549
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
550 return -1;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
551 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
552
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
553 static int findDVDFile( dvd_reader_t *dvd, const char *file, char *filename )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
554 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
555 char video_path[ PATH_MAX + 1 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
556 const char *nodirfile;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
557 int ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
558
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
559 /* Strip off the directory for our search */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
560 if( !strncasecmp( "/VIDEO_TS/", file, 10 ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
561 nodirfile = &(file[ 10 ]);
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
562 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
563 nodirfile = file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
564 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
565
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
566 ret = findDirFile( dvd->path_root, nodirfile, filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
567 if( ret < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
568 /* Try also with adding the path, just in case. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
569 sprintf( video_path, "%s/VIDEO_TS/", dvd->path_root );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
570 ret = findDirFile( video_path, nodirfile, filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
571 if( ret < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
572 /* Try with the path, but in lower case. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
573 sprintf( video_path, "%s/video_ts/", dvd->path_root );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
574 ret = findDirFile( video_path, nodirfile, filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
575 if( ret < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
576 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
577 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
578 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
579 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
580
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
581 return 1;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
582 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
583
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
584 /**
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
585 * Open an unencrypted file from a DVD directory tree.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
586 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
587 static dvd_file_t *DVDOpenFilePath( dvd_reader_t *dvd, char *filename )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
588 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
589 char full_path[ PATH_MAX + 1 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
590 dvd_file_t *dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
591 struct stat fileinfo;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
592 dvd_input_t dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
593
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
594 /* Get the full path of the file. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
595 if( !findDVDFile( dvd, filename, full_path ) ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
596
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
597 dev = dvdinput_open( full_path );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
598 if( !dev ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
599
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
600 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
601 if( !dvd_file ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
602 dvd_file->dvd = dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
603 dvd_file->lb_start = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
604 dvd_file->seek_pos = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
605 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
606 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
607 dvd_file->filesize = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
608
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
609 if( stat( full_path, &fileinfo ) < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
610 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
611 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
612 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
613 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
614 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
615 dvd_file->title_devs[ 0 ] = dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
616 dvd_file->filesize = dvd_file->title_sizes[ 0 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
617
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
618 return dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
619 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
620
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
621 static dvd_file_t *DVDOpenVOBUDF( dvd_reader_t *dvd, int title, int menu )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
622 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
623 char filename[ MAX_UDF_FILE_NAME_LEN ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
624 uint32_t start, len;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
625 dvd_file_t *dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
626
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
627 if( title == 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
628 sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
629 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
630 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
631 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
632 start = UDFFindFile( dvd, filename, &len );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
633 if( start == 0 ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
634
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
635 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
636 if( !dvd_file ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
637 dvd_file->dvd = dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
638 /*Hack*/ dvd_file->css_title = title << 1 | menu;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
639 dvd_file->lb_start = start;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
640 dvd_file->seek_pos = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
641 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
642 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
643 dvd_file->filesize = len / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
644
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
645 /* Calculate the complete file size for every file in the VOBS */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
646 if( !menu ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
647 int cur;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
648
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
649 for( cur = 2; cur < 10; cur++ ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
650 sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
651 if( !UDFFindFile( dvd, filename, &len ) ) break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
652 dvd_file->filesize += len / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
653 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
654 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
655
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
656 if( dvd->css_state == 1 /* Need key init */ ) {
7033
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
657 // initAllCSSKeys( dvd );
596919e4f601 apply mplayer-specific patches
arpi
parents: 7029
diff changeset
658 // dvd->css_state = 2;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
659 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
660 /*
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
661 if( dvdinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) {
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
662 fprintf( stderr, "libdvdread: Error cracking CSS key for %s\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
663 filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
664 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
665 */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
666
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
667 return dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
668 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
669
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
670 static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
671 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
672 char filename[ MAX_UDF_FILE_NAME_LEN ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
673 char full_path[ PATH_MAX + 1 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
674 struct stat fileinfo;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
675 dvd_file_t *dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
676 int i;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
677
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
678 dvd_file = (dvd_file_t *) malloc( sizeof( dvd_file_t ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
679 if( !dvd_file ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
680 dvd_file->dvd = dvd;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
681 /*Hack*/ dvd_file->css_title = title << 1 | menu;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
682 dvd_file->lb_start = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
683 dvd_file->seek_pos = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
684 memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
685 memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
686 dvd_file->filesize = 0;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
687
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
688 if( menu ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
689 dvd_input_t dev;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
690
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
691 if( title == 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
692 sprintf( filename, "VIDEO_TS.VOB" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
693 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
694 sprintf( filename, "VTS_%02i_0.VOB", title );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
695 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
696 if( !findDVDFile( dvd, filename, full_path ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
697 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
698 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
699 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
700
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
701 dev = dvdinput_open( full_path );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
702 if( dev == NULL ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
703 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
704 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
705 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
706
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
707 if( stat( full_path, &fileinfo ) < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
708 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
709 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
710 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
711 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
712 dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
713 dvd_file->title_devs[ 0 ] = dev;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
714 dvdinput_title( dvd_file->title_devs[0], 0);
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
715 dvd_file->filesize = dvd_file->title_sizes[ 0 ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
716
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
717 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
718 for( i = 0; i < 9; ++i ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
719
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
720 sprintf( filename, "VTS_%02i_%i.VOB", title, i + 1 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
721 if( !findDVDFile( dvd, filename, full_path ) ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
722 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
723 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
724
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
725 if( stat( full_path, &fileinfo ) < 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
726 fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
727 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
728 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
729
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
730 dvd_file->title_sizes[ i ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
731 dvd_file->title_devs[ i ] = dvdinput_open( full_path );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
732 dvdinput_title( dvd_file->title_devs[ i ], 0 );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
733 dvd_file->filesize += dvd_file->title_sizes[ i ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
734 }
8881
1e40d4a2466f Function DVDOpenVOBPath only decrypts first VOB file and since each VOB file has
arpi
parents: 7423
diff changeset
735 if( !dvd_file->title_devs[ 0 ] ) {
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
736 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
737 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
738 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
739 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
740
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
741 return dvd_file;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
742 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
743
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
744 dvd_file_t *DVDOpenFile( dvd_reader_t *dvd, int titlenum,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
745 dvd_read_domain_t domain )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
746 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
747 char filename[ MAX_UDF_FILE_NAME_LEN ];
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
748
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
749 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
750 if( dvd == NULL || titlenum < 0 )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
751 return NULL;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
752
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
753 switch( domain ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
754 case DVD_READ_INFO_FILE:
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
755 if( titlenum == 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
756 sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
757 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
758 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
759 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
760 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
761 case DVD_READ_INFO_BACKUP_FILE:
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
762 if( titlenum == 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
763 sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
764 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
765 sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
766 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
767 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
768 case DVD_READ_MENU_VOBS:
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
769 if( dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
770 return DVDOpenVOBUDF( dvd, titlenum, 1 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
771 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
772 return DVDOpenVOBPath( dvd, titlenum, 1 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
773 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
774 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
775 case DVD_READ_TITLE_VOBS:
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
776 if( titlenum == 0 ) return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
777 if( dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
778 return DVDOpenVOBUDF( dvd, titlenum, 0 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
779 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
780 return DVDOpenVOBPath( dvd, titlenum, 0 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
781 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
782 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
783 default:
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
784 fprintf( stderr, "libdvdread: Invalid domain for file open.\n" );
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
785 return NULL;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
786 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
787
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
788 if( dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
789 return DVDOpenFileUDF( dvd, filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
790 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
791 return DVDOpenFilePath( dvd, filename );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
792 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
793 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
794
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
795 void DVDCloseFile( dvd_file_t *dvd_file )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
796 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
797 int i;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
798
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
799 if( dvd_file ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
800 if( dvd_file->dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
801 ;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
802 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
803 for( i = 0; i < 9; ++i ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
804 if( dvd_file->title_devs[ i ] ) {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
805 dvdinput_close( dvd_file->title_devs[i] );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
806 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
807 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
808 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
809
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
810 free( dvd_file );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
811 dvd_file = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
812 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
813 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
814
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
815 /* Internal, but used from dvd_udf.c */
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
816 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
817 size_t block_count, unsigned char *data,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
818 int encrypted )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
819 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
820 int ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
821
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
822 if( !device->dev ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
823 fprintf( stderr, "libdvdread: Fatal error in block read.\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
824 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
825 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
826
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
827 ret = dvdinput_seek( device->dev, (int) lb_number );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
828 if( ret != (int) lb_number ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
829 fprintf( stderr, "libdvdread: Can't seek to block %u\n", lb_number );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
830 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
831 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
832
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
833 return dvdinput_read( device->dev, (char *) data,
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
834 (int) block_count, encrypted );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
835 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
836
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
837 /* This is using a single input and starting from 'dvd_file->lb_start' offset.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
838 *
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
839 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset'
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
840 * into the buffer located at 'data' and if 'encrypted' is set
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
841 * descramble the data if it's encrypted. Returning either an
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
842 * negative error or the number of blocks read. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
843 static int DVDReadBlocksUDF( dvd_file_t *dvd_file, uint32_t offset,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
844 size_t block_count, unsigned char *data,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
845 int encrypted )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
846 {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
847 return UDFReadBlocksRaw( dvd_file->dvd, dvd_file->lb_start + offset,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
848 block_count, data, encrypted );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
849 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
850
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
851 /* This is using possibly several inputs and starting from an offset of '0'.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
852 *
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
853 * Reads 'block_count' blocks from 'dvd_file' at block offset 'offset'
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
854 * into the buffer located at 'data' and if 'encrypted' is set
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
855 * descramble the data if it's encrypted. Returning either an
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
856 * negative error or the number of blocks read. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
857 static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
858 size_t block_count, unsigned char *data,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
859 int encrypted )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
860 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
861 int i;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
862 int ret, ret2, off;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
863
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
864 ret = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
865 ret2 = 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
866 for( i = 0; i < 9; ++i ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
867 if( !dvd_file->title_sizes[ i ] ) return 0; /* Past end of file */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
868
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
869 if( offset < dvd_file->title_sizes[ i ] ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
870 if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
871 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
872 if( off < 0 || off != (int)offset ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
873 fprintf( stderr, "libdvdread: Can't seek to block %d\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
874 offset );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
875 return off < 0 ? off : 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
876 }
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
877 ret = dvdinput_read( dvd_file->title_devs[ i ], data,
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
878 (int)block_count, encrypted );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
879 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
880 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
881 size_t part1_size = dvd_file->title_sizes[ i ] - offset;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
882 /* FIXME: Really needs to be a while loop.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
883 * (This is only true if you try and read >1GB at a time) */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
884
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
885 /* Read part 1 */
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
886 off = dvdinput_seek( dvd_file->title_devs[ i ], (int)offset );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
887 if( off < 0 || off != (int)offset ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
888 fprintf( stderr, "libdvdread: Can't seek to block %d\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
889 offset );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
890 return off < 0 ? off : 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
891 }
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
892 ret = dvdinput_read( dvd_file->title_devs[ i ], data,
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
893 (int)part1_size, encrypted );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
894 if( ret < 0 ) return ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
895 /* FIXME: This is wrong if i is the last file in the set.
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
896 * also error from this read will not show in ret. */
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
897
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
898 /* Does the next part exist? If not then return now. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
899 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
900
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
901 /* Read part 2 */
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
902 off = dvdinput_seek( dvd_file->title_devs[ i + 1 ], 0 );
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
903 if( off < 0 || off != 0 ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
904 fprintf( stderr, "libdvdread: Can't seek to block %d\n",
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
905 0 );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
906 return off < 0 ? off : 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
907 }
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
908 ret2 = dvdinput_read( dvd_file->title_devs[ i + 1 ],
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
909 data + ( part1_size
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
910 * (int64_t)DVD_VIDEO_LB_LEN ),
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
911 (int)(block_count - part1_size),
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
912 encrypted );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
913 if( ret2 < 0 ) return ret2;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
914 break;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
915 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
916 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
917 offset -= dvd_file->title_sizes[ i ];
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
918 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
919 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
920
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
921 return ret + ret2;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
922 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
923
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
924 /* This is broken reading more than 2Gb at a time is ssize_t is 32-bit. */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
925 ssize_t DVDReadBlocks( dvd_file_t *dvd_file, int offset,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
926 size_t block_count, unsigned char *data )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
927 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
928 int ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
929
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
930 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
931 if( dvd_file == NULL || offset < 0 || data == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
932 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
933
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
934 /* Hack, and it will still fail for multiple opens in a threaded app ! */
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
935 if( dvd_file->dvd->css_title != dvd_file->css_title ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
936 dvd_file->dvd->css_title = dvd_file->css_title;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
937 if( dvd_file->dvd->isImageFile ) {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
938 dvdinput_title( dvd_file->dvd->dev, (int)dvd_file->lb_start );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
939 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
940 /* Here each vobu has it's own dvdcss handle, so no need to update
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
941 else {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
942 dvdinput_title( dvd_file->title_devs[ 0 ], (int)dvd_file->lb_start );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
943 }*/
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
944 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
945
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
946 if( dvd_file->dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
947 ret = DVDReadBlocksUDF( dvd_file, (uint32_t)offset,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
948 block_count, data, DVDINPUT_READ_DECRYPT );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
949 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
950 ret = DVDReadBlocksPath( dvd_file, (unsigned int)offset,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
951 block_count, data, DVDINPUT_READ_DECRYPT );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
952 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
953
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
954 return (ssize_t)ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
955 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
956
10017
535a53c058f8 There are conflicting definitions for DVDFileSeek in the .c and .h file.
diego
parents: 9333
diff changeset
957 int DVDFileSeek( dvd_file_t *dvd_file, int offset )
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
958 {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
959 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
960 if( dvd_file == NULL || offset < 0 )
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
961 return -1;
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
962
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
963 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
964 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
965 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
966 dvd_file->seek_pos = (uint32_t) offset;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
967 return offset;
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
968 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
969
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
970 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
971 {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
972 unsigned char *secbuf;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
973 unsigned int numsec, seek_sector, seek_byte;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
974 int ret;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
975
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
976 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
977 if( dvd_file == NULL || data == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
978 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
979
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
980 seek_sector = dvd_file->seek_pos / DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
981 seek_byte = dvd_file->seek_pos % DVD_VIDEO_LB_LEN;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
982
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
983 numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) +
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
984 ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
985
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
986 secbuf = (unsigned char *) malloc( numsec * DVD_VIDEO_LB_LEN );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
987 if( !secbuf ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
988 fprintf( stderr, "libdvdread: Can't allocate memory "
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
989 "for file read!\n" );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
990 return 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
991 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
992
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
993 if( dvd_file->dvd->isImageFile ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
994 ret = DVDReadBlocksUDF( dvd_file, (uint32_t) seek_sector,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
995 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
996 } else {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
997 ret = DVDReadBlocksPath( dvd_file, seek_sector,
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
998 (size_t) numsec, secbuf, DVDINPUT_NOFLAGS );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
999 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1000
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1001 if( ret != (int) numsec ) {
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1002 free( secbuf );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1003 return ret < 0 ? ret : 0;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1004 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1005
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1006 memcpy( data, &(secbuf[ seek_byte ]), byte_size );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1007 free( secbuf );
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1008
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1009 dvd_file->seek_pos += byte_size;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1010 return byte_size;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1011 }
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1012
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1013 ssize_t DVDFileSize( dvd_file_t *dvd_file )
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1014 {
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1015 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1016 if( dvd_file == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1017 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1018
7029
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1019 return dvd_file->filesize;
9db58ffbd73c importing libdvdread 0.9.3 files
arpi
parents:
diff changeset
1020 }
15874
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1021
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1022 int DVDDiscID( dvd_reader_t *dvd, unsigned char *discid )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1023 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1024 struct md5_ctx ctx;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1025 int title;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1026
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1027 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1028 if( dvd == NULL || discid == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1029 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1030
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1031 /* Go through the first 10 IFO:s, in order,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1032 * and md5sum them, i.e VIDEO_TS.IFO and VTS_0?_0.IFO */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1033 md5_init_ctx( &ctx );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1034 for( title = 0; title < 10; title++ ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1035 dvd_file_t *dvd_file = DVDOpenFile( dvd, title, DVD_READ_INFO_FILE );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1036 if( dvd_file != NULL ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1037 ssize_t bytes_read;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1038 size_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1039 char *buffer = malloc( file_size );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1040
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1041 if( buffer == NULL ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1042 fprintf( stderr, "libdvdread: DVDDiscId, failed to "
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1043 "allocate memory for file read!\n" );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1044 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1045 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1046 bytes_read = DVDReadBytes( dvd_file, buffer, file_size );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1047 if( bytes_read != file_size ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1048 fprintf( stderr, "libdvdread: DVDDiscId read returned %d bytes"
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1049 ", wanted %d\n", bytes_read, file_size );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1050 DVDCloseFile( dvd_file );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1051 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1052 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1053
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1054 md5_process_bytes( buffer, file_size, &ctx );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1055
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1056 DVDCloseFile( dvd_file );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1057 free( buffer );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1058 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1059 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1060 md5_finish_ctx( &ctx, discid );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1061
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1062 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1063 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1064
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1065
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1066 int DVDISOVolumeInfo( dvd_reader_t *dvd,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1067 char *volid, unsigned int volid_size,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1068 unsigned char *volsetid, unsigned int volsetid_size )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1069 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1070 unsigned char *buffer;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1071 int ret;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1072
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1073 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1074 if( dvd == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1075 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1076
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1077 if( dvd->dev == NULL ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1078 /* No block access, so no ISO... */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1079 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1080 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1081
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1082 buffer = malloc( DVD_VIDEO_LB_LEN );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1083 if( buffer == NULL ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1084 fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to "
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1085 "allocate memory for file read!\n" );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1086 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1087 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1088
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1089 ret = UDFReadBlocksRaw( dvd, 16, 1, buffer, 0 );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1090 if( ret != 1 ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1091 fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to "
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1092 "read ISO9660 Primary Volume Descriptor!\n" );
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1093 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1094 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1095
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1096 if( (volid != NULL) && (volid_size > 0) ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1097 unsigned int n;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1098 for(n = 0; n < 32; n++) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1099 if(buffer[40+n] == 0x20) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1100 break;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1101 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1102 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1103
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1104 if(volid_size > n+1) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1105 volid_size = n+1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1106 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1107
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1108 memcpy(volid, &buffer[40], volid_size-1);
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1109 volid[volid_size-1] = '\0';
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1110 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1111
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1112 if( (volsetid != NULL) && (volsetid_size > 0) ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1113 if(volsetid_size > 128) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1114 volsetid_size = 128;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1115 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1116 memcpy(volsetid, &buffer[190], volsetid_size);
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1117 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1118 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1119 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1120
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1121
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1122 int DVDUDFVolumeInfo( dvd_reader_t *dvd,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1123 char *volid, unsigned int volid_size,
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1124 unsigned char *volsetid, unsigned int volsetid_size )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1125 {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1126 int ret;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1127 /* Check arguments. */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1128 if( dvd == NULL )
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1129 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1130
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1131 if( dvd->dev == NULL ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1132 /* No block access, so no UDF VolumeSet Identifier */
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1133 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1134 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1135
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1136 if( (volid != NULL) && (volid_size > 0) ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1137 ret = UDFGetVolumeIdentifier(dvd, volid, volid_size);
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1138 if(!ret) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1139 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1140 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1141 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1142 if( (volsetid != NULL) && (volsetid_size > 0) ) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1143 ret = UDFGetVolumeSetIdentifier(dvd, volsetid, volsetid_size);
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1144 if(!ret) {
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1145 return -1;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1146 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1147 }
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1148
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1149 return 0;
483e955893b8 update libdvdread to v0.9.4
aurel
parents: 15566
diff changeset
1150 }