annotate dvdread/dvd_reader.c @ 26896:4559d4a7c3cb

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