225
|
1 #ifndef DVD_READER_H_INCLUDED
|
|
2 #define DVD_READER_H_INCLUDED
|
|
3
|
|
4 /*
|
|
5 * Copyright (C) 2001, 2002 Billy Biggs <vektor@dumbterm.net>,
|
|
6 * Håkan Hjort <d95hjort@dtek.chalmers.se>,
|
|
7 * Björn Englund <d4bjorn@dtek.chalmers.se>
|
|
8 *
|
|
9 * This program is free software; you can redistribute it and/or modify
|
|
10 * it under the terms of the GNU General Public License as published by
|
|
11 * the Free Software Foundation; either version 2 of the License, or (at
|
|
12 * your option) any later version.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful, but
|
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 * General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
22 */
|
|
23
|
|
24 #ifdef _MSC_VER
|
|
25 #include <config.h>
|
|
26
|
|
27 #include <stdio.h>
|
|
28 #include <stdlib.h>
|
|
29 #endif
|
|
30
|
|
31 #include <sys/types.h>
|
|
32
|
|
33 /**
|
|
34 * The DVD access interface.
|
|
35 *
|
|
36 * This file contains the functions that form the interface to to
|
|
37 * reading files located on a DVD.
|
|
38 */
|
|
39
|
|
40 /**
|
|
41 * The current version.
|
|
42 */
|
|
43 #define DVDREAD_VERSION 904
|
|
44
|
|
45 /**
|
|
46 * The length of one Logical Block of a DVD.
|
|
47 */
|
|
48 #define DVD_VIDEO_LB_LEN 2048
|
|
49
|
|
50 /**
|
|
51 * Maximum length of filenames allowed in UDF.
|
|
52 */
|
|
53 #define MAX_UDF_FILE_NAME_LEN 2048
|
|
54
|
|
55 #ifdef __cplusplus
|
|
56 extern "C" {
|
|
57 #endif
|
|
58
|
|
59 /**
|
|
60 * Opaque type that is used as a handle for one instance of an opened DVD.
|
|
61 */
|
|
62 typedef struct dvd_reader_s dvd_reader_t;
|
|
63
|
|
64 /**
|
|
65 * Opaque type for a file read handle, much like a normal fd or FILE *.
|
|
66 */
|
|
67 typedef struct dvd_file_s dvd_file_t;
|
|
68
|
|
69 /**
|
|
70 * Opens a block device of a DVD-ROM file, or an image file, or a directory
|
|
71 * name for a mounted DVD or HD copy of a DVD.
|
|
72 *
|
|
73 * If the given file is a block device, or is the mountpoint for a block
|
|
74 * device, then that device is used for CSS authentication using libdvdcss.
|
|
75 * If no device is available, then no CSS authentication is performed,
|
|
76 * and we hope that the image is decrypted.
|
|
77 *
|
|
78 * If the path given is a directory, then the files in that directory may be
|
|
79 * in any one of these formats:
|
|
80 *
|
|
81 * path/VIDEO_TS/VTS_01_1.VOB
|
|
82 * path/video_ts/vts_01_1.vob
|
|
83 * path/VTS_01_1.VOB
|
|
84 * path/vts_01_1.vob
|
|
85 *
|
|
86 * @param path Specifies the the device, file or directory to be used.
|
|
87 * @return If successful a a read handle is returned. Otherwise 0 is returned.
|
|
88 *
|
|
89 * dvd = DVDOpen(path);
|
|
90 */
|
|
91 dvd_reader_t *DVDOpen( const char * );
|
|
92
|
|
93 /**
|
|
94 * Closes and cleans up the DVD reader object.
|
|
95 *
|
|
96 * You must close all open files before calling this function.
|
|
97 *
|
|
98 * @param dvd A read handle that should be closed.
|
|
99 *
|
|
100 * DVDClose(dvd);
|
|
101 */
|
|
102 void DVDClose( dvd_reader_t * );
|
|
103
|
|
104 /**
|
|
105 *
|
|
106 */
|
|
107 typedef enum {
|
|
108 DVD_READ_INFO_FILE, /**< VIDEO_TS.IFO or VTS_XX_0.IFO (title) */
|
|
109 DVD_READ_INFO_BACKUP_FILE, /**< VIDEO_TS.BUP or VTS_XX_0.BUP (title) */
|
|
110 DVD_READ_MENU_VOBS, /**< VIDEO_TS.VOB or VTS_XX_0.VOB (title) */
|
|
111 DVD_READ_TITLE_VOBS /**< VTS_XX_[1-9].VOB (title). All files in
|
|
112 the title set are opened and read as a
|
|
113 single file. */
|
|
114 } dvd_read_domain_t;
|
|
115
|
|
116 /**
|
|
117 * Opens a file on the DVD given the title number and domain.
|
|
118 *
|
|
119 * If the title number is 0, the video manager information is opened
|
|
120 * (VIDEO_TS.[IFO,BUP,VOB]). Returns a file structure which may be
|
|
121 * used for reads, or 0 if the file was not found.
|
|
122 *
|
|
123 * @param dvd A dvd read handle.
|
|
124 * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
|
|
125 * @param domain Which domain.
|
|
126 * @return If successful a a file read handle is returned, otherwise 0.
|
|
127 *
|
|
128 * dvd_file = DVDOpenFile(dvd, titlenum, domain); */
|
|
129 dvd_file_t *DVDOpenFile( dvd_reader_t *, int, dvd_read_domain_t );
|
|
130
|
|
131 /**
|
|
132 * Closes a file and frees the associated structure.
|
|
133 *
|
|
134 * @param dvd_file The file read handle to be closed.
|
|
135 *
|
|
136 * DVDCloseFile(dvd_file);
|
|
137 */
|
|
138 void DVDCloseFile( dvd_file_t * );
|
|
139
|
|
140 /**
|
|
141 * Reads block_count number of blocks from the file at the given block offset.
|
|
142 * Returns number of blocks read on success, -1 on error. This call is only
|
|
143 * for reading VOB data, and should not be used when reading the IFO files.
|
|
144 * When reading from an encrypted drive, blocks are decrypted using libdvdcss
|
|
145 * where required.
|
|
146 *
|
|
147 * @param dvd_file A file read handle.
|
|
148 * @param offset Block offset from the start of the file to start reading at.
|
|
149 * @param block_count Number of block to read.
|
|
150 * @param data Pointer to a buffer to write the data into.
|
|
151 * @return Returns number of blocks read on success, -1 on error.
|
|
152 *
|
|
153 * blocks_read = DVDReadBlocks(dvd_file, offset, block_count, data);
|
|
154 */
|
|
155 ssize_t DVDReadBlocks( dvd_file_t *, int, size_t, unsigned char * );
|
|
156
|
|
157 /**
|
|
158 * Seek to the given position in the file. Returns the resulting position in
|
|
159 * bytes from the beginning of the file. The seek position is only used for
|
|
160 * byte reads from the file, the block read call always reads from the given
|
|
161 * offset.
|
|
162 *
|
|
163 * @param dvd_file A file read handle.
|
|
164 * @param seek_offset Byte offset from the start of the file to seek to.
|
|
165 * @return The resulting position in bytes from the beginning of the file.
|
|
166 *
|
|
167 * offset_set = DVDFileSeek(dvd_file, seek_offset);
|
|
168 */
|
|
169 int32_t DVDFileSeek( dvd_file_t *, int32_t );
|
|
170
|
|
171 /**
|
|
172 * Reads the given number of bytes from the file. This call can only be used
|
|
173 * on the information files, and may not be used for reading from a VOB. This
|
|
174 * reads from and increments the currrent seek position for the file.
|
|
175 *
|
|
176 * @param dvd_file A file read handle.
|
|
177 * @param data Pointer to a buffer to write the data into.
|
|
178 * @param bytes Number of bytes to read.
|
|
179 * @return Returns number of bytes read on success, -1 on error.
|
|
180 *
|
|
181 * bytes_read = DVDReadBytes(dvd_file, data, bytes);
|
|
182 */
|
|
183 ssize_t DVDReadBytes( dvd_file_t *, void *, size_t );
|
|
184
|
|
185 /**
|
|
186 * Returns the file size in blocks.
|
|
187 *
|
|
188 * @param dvd_file A file read handle.
|
|
189 * @return The size of the file in blocks, -1 on error.
|
|
190 *
|
|
191 * blocks = DVDFileSize(dvd_file);
|
|
192 */
|
|
193 ssize_t DVDFileSize( dvd_file_t * );
|
|
194
|
|
195 /**
|
|
196 * Get a unique 128 bit disc ID.
|
|
197 * This is the MD5 sum of VIDEO_TS.IFO and the VTS_0?_0.IFO files
|
|
198 * in title order (those that exist).
|
|
199 * If you need a 'text' representation of the id, print it as a
|
|
200 * hexadecimal number, using lowercase letters, discid[0] first.
|
|
201 * I.e. the same format as the command-line 'md5sum' program uses.
|
|
202 *
|
|
203 * @param dvd A read handle to get the disc ID from
|
|
204 * @param discid The buffer to put the disc ID into. The buffer must
|
|
205 * have room for 128 bits (16 chars).
|
|
206 * @return 0 on success, -1 on error.
|
|
207 */
|
|
208 int DVDDiscID( dvd_reader_t *, unsigned char * );
|
|
209
|
|
210 /**
|
|
211 * Get the UDF VolumeIdentifier and VolumeSetIdentifier
|
|
212 * from the PrimaryVolumeDescriptor.
|
|
213 *
|
|
214 * @param dvd A read handle to get the disc ID from
|
|
215 * @param volid The buffer to put the VolumeIdentifier into.
|
|
216 * The VolumeIdentifier is latin-1 encoded (8bit unicode)
|
|
217 * null terminated and max 32 bytes (including '\0')
|
|
218 * @param volid_size No more than volid_size bytes will be copied to volid.
|
|
219 * If the VolumeIdentifier is truncated because of this
|
|
220 * it will still be null terminated.
|
|
221 * @param volsetid The buffer to put the VolumeSetIdentifier into.
|
|
222 * The VolumeIdentifier is 128 bytes as
|
|
223 * stored in the UDF PrimaryVolumeDescriptor.
|
|
224 * Note that this is not a null terminated string.
|
|
225 * @param volsetid_size At most volsetid_size bytes will be copied to volsetid.
|
|
226 * @return 0 on success, -1 on error.
|
|
227 */
|
|
228 int DVDUDFVolumeInfo( dvd_reader_t *, char *, unsigned int,
|
|
229 unsigned char *, unsigned int );
|
|
230
|
|
231 /**
|
|
232 * Get the ISO9660 VolumeIdentifier and VolumeSetIdentifier
|
|
233 *
|
|
234 * * Only use this function as fallback if DVDUDFVolumeInfo returns 0 *
|
|
235 * * this will happen on a disc mastered only with a iso9660 filesystem *
|
|
236 * * All video DVD discs have UDF filesystem *
|
|
237 *
|
|
238 * @param dvd A read handle to get the disc ID from
|
|
239 * @param volid The buffer to put the VolumeIdentifier into.
|
|
240 * The VolumeIdentifier is coded with '0-9','A-Z','_'
|
|
241 * null terminated and max 33 bytes (including '\0')
|
|
242 * @param volid_size No more than volid_size bytes will be copied to volid.
|
|
243 * If the VolumeIdentifier is truncated because of this
|
|
244 * it will still be null terminated.
|
|
245 * @param volsetid The buffer to put the VolumeSetIdentifier into.
|
|
246 * The VolumeIdentifier is 128 bytes as
|
|
247 * stored in the ISO9660 PrimaryVolumeDescriptor.
|
|
248 * Note that this is not a null terminated string.
|
|
249 * @param volsetid_size At most volsetid_size bytes will be copied to volsetid.
|
|
250 * @return 0 on success, -1 on error.
|
|
251 */
|
|
252 int DVDISOVolumeInfo( dvd_reader_t *, char *, unsigned int,
|
|
253 unsigned char *, unsigned int );
|
|
254
|
|
255 /**
|
|
256 * Sets the level of caching that is done when reading from a device
|
|
257 *
|
|
258 * @param dvd A read handle to get the disc ID from
|
|
259 * @param level The level of caching wanted.
|
|
260 * -1 - returns the current setting.
|
|
261 * 0 - UDF Cache turned off.
|
|
262 * 1 - (default level) Pointers to IFO files and some data from
|
|
263 * PrimaryVolumeDescriptor are cached.
|
|
264 *
|
|
265 * @return The level of caching.
|
|
266 */
|
|
267 int DVDUDFCacheLevel( dvd_reader_t *, int );
|
|
268
|
|
269 #ifdef __cplusplus
|
|
270 };
|
|
271 #endif
|
|
272 #endif /* DVD_READER_H_INCLUDED */
|