/[packages]/cauldron/libdvdread/current/SOURCES/libdvdread-4.1.3-backward-compatibility.patch
ViewVC logotype

Contents of /cauldron/libdvdread/current/SOURCES/libdvdread-4.1.3-backward-compatibility.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31656 - (show annotations) (download)
Sat Jan 22 08:03:38 2011 UTC (13 years, 2 months ago) by dmorgan
File size: 6518 byte(s)
imported package libdvdread
1 diff -Naur --exclude '*~' libdvdread-4.1.3/src/dvd_reader.c libdvdread-4.1.3-backward-compatibility/src/dvd_reader.c
2 --- libdvdread-4.1.3/src/dvd_reader.c 2008-09-06 23:55:51.000000000 +0200
3 +++ libdvdread-4.1.3-backward-compatibility/src/dvd_reader.c 2008-11-22 13:16:51.000000000 +0100
4 @@ -889,6 +889,183 @@
5 }
6 }
7
8 +static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title,
9 + int menu, dvd_stat_t *statbuf)
10 +{
11 + char filename[ MAX_UDF_FILE_NAME_LEN ];
12 + uint32_t size;
13 + off_t tot_size;
14 + off_t parts_size[9];
15 + int nr_parts = 0;
16 + int n;
17 +
18 + if( title == 0 ) {
19 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
20 + } else {
21 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
22 + }
23 + if(!UDFFindFile( dvd, filename, &size )) {
24 + return -1;
25 + }
26 + tot_size = size;
27 + nr_parts = 1;
28 + parts_size[0] = size;
29 +
30 + if( !menu ) {
31 + int cur;
32 +
33 + for( cur = 2; cur < 10; cur++ ) {
34 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
35 + if( !UDFFindFile( dvd, filename, &size ) ) {
36 + break;
37 + }
38 + parts_size[nr_parts] = size;
39 + tot_size += size;
40 + nr_parts++;
41 + }
42 + }
43 +
44 + statbuf->size = tot_size;
45 + statbuf->nr_parts = nr_parts;
46 + for(n = 0; n < nr_parts; n++) {
47 + statbuf->parts_size[n] = parts_size[n];
48 + }
49 + return 0;
50 +}
51 +
52 +
53 +static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title,
54 + int menu, dvd_stat_t *statbuf )
55 +{
56 + char filename[ MAX_UDF_FILE_NAME_LEN ];
57 + char full_path[ PATH_MAX + 1 ];
58 + struct stat fileinfo;
59 + off_t tot_size;
60 + off_t parts_size[9];
61 + int nr_parts = 0;
62 + int n;
63 +
64 +
65 +
66 + if( title == 0 ) {
67 + sprintf( filename, "VIDEO_TS.VOB" );
68 + } else {
69 + sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
70 + }
71 + if( !findDVDFile( dvd, filename, full_path ) ) {
72 + return -1;
73 + }
74 +
75 + if( stat( full_path, &fileinfo ) < 0 ) {
76 + return -1;
77 + }
78 +
79 +
80 + tot_size = fileinfo.st_size;
81 + nr_parts = 1;
82 + parts_size[0] = fileinfo.st_size;
83 +
84 + if( !menu ) {
85 + int cur;
86 +
87 + for( cur = 2; cur < 10; cur++ ) {
88 +
89 + sprintf( filename, "VTS_%02d_%d.VOB", title, cur );
90 + if( !findDVDFile( dvd, filename, full_path ) ) {
91 + break;
92 + }
93 +
94 + if( stat( full_path, &fileinfo ) < 0 ) {
95 + break;
96 + }
97 +
98 + parts_size[nr_parts] = fileinfo.st_size;
99 + tot_size += parts_size[nr_parts];
100 + nr_parts++;
101 + }
102 + }
103 +
104 + statbuf->size = tot_size;
105 + statbuf->nr_parts = nr_parts;
106 + for(n = 0; n < nr_parts; n++) {
107 + statbuf->parts_size[n] = parts_size[n];
108 + }
109 + return 0;
110 +}
111 +
112 +
113 +int DVDFileStat(dvd_reader_t *dvd, int titlenum,
114 + dvd_read_domain_t domain, dvd_stat_t *statbuf)
115 +{
116 + char filename[ MAX_UDF_FILE_NAME_LEN ];
117 + char full_path[ PATH_MAX + 1 ];
118 + struct stat fileinfo;
119 + uint32_t size;
120 +
121 + /* Check arguments. */
122 + if( dvd == NULL || titlenum < 0 ) {
123 + errno = EINVAL;
124 + return -1;
125 + }
126 +
127 + switch( domain ) {
128 + case DVD_READ_INFO_FILE:
129 + if( titlenum == 0 ) {
130 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
131 + } else {
132 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
133 + }
134 + break;
135 + case DVD_READ_INFO_BACKUP_FILE:
136 + if( titlenum == 0 ) {
137 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
138 + } else {
139 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
140 + }
141 + break;
142 + case DVD_READ_MENU_VOBS:
143 + if( dvd->isImageFile ) {
144 + return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf );
145 + } else {
146 + return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf );
147 + }
148 + break;
149 + case DVD_READ_TITLE_VOBS:
150 + if( titlenum == 0 ) {
151 + return -1;
152 + }
153 + if( dvd->isImageFile ) {
154 + return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf );
155 + } else {
156 + return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf );
157 + }
158 + break;
159 + default:
160 + errno = EINVAL;
161 + return -1;
162 + }
163 +
164 + if( dvd->isImageFile ) {
165 + if( UDFFindFile( dvd, filename, &size ) ) {
166 + statbuf->size = size;
167 + statbuf->nr_parts = 1;
168 + statbuf->parts_size[0] = size;
169 + return 0;
170 + }
171 + } else {
172 + if( findDVDFile( dvd, filename, full_path ) ) {
173 + if( stat( full_path, &fileinfo ) < 0 ) {
174 + } else {
175 + statbuf->size = fileinfo.st_size;
176 + statbuf->nr_parts = 1;
177 + statbuf->parts_size[0] = statbuf->size;
178 + return 0;
179 + }
180 + }
181 + }
182 + return -1;
183 +}
184 +
185 /* Internal, but used from dvd_udf.c */
186 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
187 size_t block_count, unsigned char *data,
188 diff -Naur --exclude '*~' libdvdread-4.1.3/src/dvd_reader.h libdvdread-4.1.3-backward-compatibility/src/dvd_reader.h
189 --- libdvdread-4.1.3/src/dvd_reader.h 2008-09-06 23:55:51.000000000 +0200
190 +++ libdvdread-4.1.3-backward-compatibility/src/dvd_reader.h 2008-11-22 13:09:49.000000000 +0100
191 @@ -114,6 +114,39 @@
192 single file. */
193 } dvd_read_domain_t;
194
195 +typedef struct {
196 + off_t size; /**< Total size of file in bytes */
197 + int nr_parts; /**< Number of file parts */
198 + off_t parts_size[9]; /**< Size of each part in bytes */
199 +} dvd_stat_t;
200 +
201 +/**
202 + * Stats a file on the DVD given the title number and domain.
203 + * The information about the file is stored in a dvd_stat_t
204 + * which contains information about the size of the file and
205 + * the number of parts in case of a multipart file and the respective
206 + * sizes of the parts.
207 + * A multipart file is for instance VTS_02_1.VOB, VTS_02_2.VOB, VTS_02_3.VOB
208 + * The size of VTS_02_1.VOB will be stored in stat->parts_size[0],
209 + * VTS_02_2.VOB in stat->parts_size[1], ...
210 + * The total size (sum of all parts) is stored in stat->size and
211 + * stat->nr_parts will hold the number of parts.
212 + * Only DVD_READ_TITLE_VOBS (VTS_??_[1-9].VOB) can be multipart files.
213 + *
214 + * This function is only of use if you want to get the size of each file
215 + * in the filesystem. These sizes are not needed to use any other
216 + * functions in libdvdread.
217 + *
218 + * @param dvd A dvd read handle.
219 + * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
220 + * @param domain Which domain.
221 + * @param stat Pointer to where the result is stored.
222 + * @return If successful 0, otherwise -1.
223 + *
224 + * int DVDFileStat(dvd, titlenum, domain, stat);
225 + */
226 +int DVDFileStat(dvd_reader_t *, int, dvd_read_domain_t, dvd_stat_t *);
227 +
228 /**
229 * Opens a file on the DVD given the title number and domain.
230 *

  ViewVC Help
Powered by ViewVC 1.1.30