/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvd_reader.h

http://github.com/xbmc/xbmc · C Header · 313 lines · 47 code · 28 blank · 238 comment · 0 complexity · 236e0a1d7a5a7e42cdcf86bbfef17786 MD5 · raw file

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