Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
dvd_reader.h File Reference
#include <sys/types.h>
#include <stdarg.h>
#include <sys/uio.h>

Classes

struct  dvd_reader_stream_cb
 
struct  dvd_logger_cb
 
struct  dvd_stat_t
 

Macros

#define DVD_VIDEO_LB_LEN   2048
 
#define MAX_UDF_FILE_NAME_LEN   2048
 

Typedefs

typedef struct dvd_reader_s dvd_reader_t
 
typedef struct dvd_reader_device_s dvd_reader_device_t
 
typedef struct dvd_file_s dvd_file_t
 
typedef struct dvd_reader_stream_cb dvd_reader_stream_cb
 

Enumerations

enum  dvd_logger_level_t { DVD_LOGGER_LEVEL_INFO , DVD_LOGGER_LEVEL_ERROR , DVD_LOGGER_LEVEL_WARN , DVD_LOGGER_LEVEL_DEBUG }
 
enum  dvd_read_domain_t { DVD_READ_INFO_FILE , DVD_READ_INFO_BACKUP_FILE , DVD_READ_MENU_VOBS , DVD_READ_TITLE_VOBS }
 

Functions

dvd_reader_tDVDOpen (const char *)
 
dvd_reader_tDVDOpenStream (void *, dvd_reader_stream_cb *)
 
dvd_reader_tDVDOpen2 (void *, const dvd_logger_cb *, const char *)
 
dvd_reader_tDVDOpenStream2 (void *, const dvd_logger_cb *, dvd_reader_stream_cb *)
 
void DVDClose (dvd_reader_t *)
 
int DVDFileStat (dvd_reader_t *, int, dvd_read_domain_t, dvd_stat_t *)
 
dvd_file_tDVDOpenFile (dvd_reader_t *, int, dvd_read_domain_t)
 
void DVDCloseFile (dvd_file_t *)
 
ssize_t DVDReadBlocks (dvd_file_t *, int, size_t, unsigned char *)
 
int32_t DVDFileSeek (dvd_file_t *, int32_t)
 
ssize_t DVDReadBytes (dvd_file_t *, void *, size_t)
 
ssize_t DVDFileSize (dvd_file_t *)
 
int DVDDiscID (dvd_reader_t *, unsigned char *)
 
int DVDUDFVolumeInfo (dvd_reader_t *, char *, unsigned int, unsigned char *, unsigned int)
 
int DVDFileSeekForce (dvd_file_t *, int offset, int force_size)
 
int DVDISOVolumeInfo (dvd_reader_t *, char *, unsigned int, unsigned char *, unsigned int)
 
int DVDUDFCacheLevel (dvd_reader_t *, int)
 

Macro Definition Documentation

◆ DVD_VIDEO_LB_LEN

#define DVD_VIDEO_LB_LEN   2048

The DVD access interface.

This file contains the functions that form the interface for reading files located on a DVD. The length of one Logical Block of a DVD.

◆ MAX_UDF_FILE_NAME_LEN

#define MAX_UDF_FILE_NAME_LEN   2048

Maximum length of filenames allowed in UDF.

Typedef Documentation

◆ dvd_file_t

typedef struct dvd_file_s dvd_file_t

Opaque type for a file read handle, much like a normal fd or FILE *.

◆ dvd_reader_device_t

typedef struct dvd_reader_device_s dvd_reader_device_t

◆ dvd_reader_stream_cb

typedef struct dvd_reader_stream_cb dvd_reader_stream_cb

◆ dvd_reader_t

typedef struct dvd_reader_s dvd_reader_t

Opaque type that is used as a handle for one instance of an opened DVD.

Enumeration Type Documentation

◆ dvd_logger_level_t

Custom logger callback for DVDOpen[Stream]2

Parameters
privateHandle as provided in Open functions
levelLog level
fmtFormat string
argsArguments list pf_log(priv, level, fmt, args);
Enumerator
DVD_LOGGER_LEVEL_INFO 
DVD_LOGGER_LEVEL_ERROR 
DVD_LOGGER_LEVEL_WARN 
DVD_LOGGER_LEVEL_DEBUG 

◆ dvd_read_domain_t

Enumerator
DVD_READ_INFO_FILE 

VIDEO_TS.IFO or VTS_XX_0.IFO (title)

DVD_READ_INFO_BACKUP_FILE 

VIDEO_TS.BUP or VTS_XX_0.BUP (title)

DVD_READ_MENU_VOBS 

VIDEO_TS.VOB or VTS_XX_0.VOB (title)

DVD_READ_TITLE_VOBS 

VTS_XX_[1-9].VOB (title). All files in the title set are opened and read as a single file.

Function Documentation

◆ DVDClose()

void DVDClose ( dvd_reader_t * )

Closes and cleans up the DVD reader object.

You must close all open files before calling this function.

Parameters
dvdA read handle that should be closed.

DVDClose(dvd);

◆ DVDCloseFile()

void DVDCloseFile ( dvd_file_t * )

Closes a file and frees the associated structure.

Parameters
dvd_fileThe file read handle to be closed.

DVDCloseFile(dvd_file);

◆ DVDDiscID()

int DVDDiscID ( dvd_reader_t * ,
unsigned char *  )

Get a unique 128 bit disc ID. This is the MD5 sum of VIDEO_TS.IFO and the VTS_0?_0.IFO files in title order (those that exist). If you need a 'text' representation of the id, print it as a hexadecimal number, using lowercase letters, discid[0] first. I.e. the same format as the command-line 'md5sum' program uses.

Parameters
dvdA read handle to get the disc ID from
discidThe buffer to put the disc ID into. The buffer must have room for 128 bits (16 chars).
Returns
0 on success, -1 on error.

◆ DVDFileSeek()

int32_t DVDFileSeek ( dvd_file_t * ,
int32_t  )

Seek to the given position in the file. Returns the resulting position in bytes from the beginning of the file. The seek position is only used for byte reads from the file, the block read call always reads from the given offset.

Parameters
dvd_fileA file read handle.
seek_offsetByte offset from the start of the file to seek to.
Returns
The resulting position in bytes from the beginning of the file.

offset_set = DVDFileSeek(dvd_file, seek_offset);

◆ DVDFileSeekForce()

int DVDFileSeekForce ( dvd_file_t * ,
int offset,
int force_size )

◆ DVDFileSize()

ssize_t DVDFileSize ( dvd_file_t * )

Returns the file size in blocks.

Parameters
dvd_fileA file read handle.
Returns
The size of the file in blocks, -1 on error.

blocks = DVDFileSize(dvd_file);

◆ DVDFileStat()

int DVDFileStat ( dvd_reader_t * ,
int ,
dvd_read_domain_t ,
dvd_stat_t *  )

Stats a file on the DVD given the title number and domain. The information about the file is stored in a dvd_stat_t which contains information about the size of the file and the number of parts in case of a multipart file and the respective sizes of the parts. A multipart file is for instance VTS_02_1.VOB, VTS_02_2.VOB, VTS_02_3.VOB The size of VTS_02_1.VOB will be stored in stat->parts_size[0], VTS_02_2.VOB in stat->parts_size[1], ... The total size (sum of all parts) is stored in stat->size and stat->nr_parts will hold the number of parts. Only DVD_READ_TITLE_VOBS (VTS_??_[1-9].VOB) can be multipart files.

This function is only of use if you want to get the size of each file in the filesystem. These sizes are not needed to use any other functions in libdvdread.

Parameters
dvdA dvd read handle.
titlenumWhich Video Title Set should be used, VIDEO_TS is 0.
domainWhich domain.
statPointer to where the result is stored.
Returns
If successful 0, otherwise -1.

int DVDFileStat(dvd, titlenum, domain, stat);

◆ DVDISOVolumeInfo()

int DVDISOVolumeInfo ( dvd_reader_t * ,
char * ,
unsigned int ,
unsigned char * ,
unsigned int  )

Get the ISO9660 VolumeIdentifier and VolumeSetIdentifier

  • Only use this function as fallback if DVDUDFVolumeInfo returns -1 *
  • this will happen on a disc mastered only with a iso9660 filesystem *
  • All video DVD discs have UDF filesystem *
Parameters
dvdA read handle to get the disc ID from
volidThe buffer to put the VolumeIdentifier into. The VolumeIdentifier is coded with '0-9','A-Z','_' null terminated and max 33 bytes (including '\0')
volid_sizeNo more than volid_size bytes will be copied to volid. If the VolumeIdentifier is truncated because of this it will still be null terminated.
volsetidThe buffer to put the VolumeSetIdentifier into. The VolumeIdentifier is 128 bytes as stored in the ISO9660 PrimaryVolumeDescriptor. Note that this is not a null terminated string.
volsetid_sizeAt most volsetid_size bytes will be copied to volsetid.
Returns
0 on success, -1 on error.

◆ DVDOpen()

dvd_reader_t * DVDOpen ( const char * )

Opens a block device of a DVD-ROM file, or an image file, or a directory name for a mounted DVD or HD copy of a DVD. The second form of Open function (DVDOpenStream) can be used to provide custom stream_cb functions to access the DVD (see libdvdcss).

If the given file is a block device, or is the mountpoint for a block device, then that device is used for CSS authentication using libdvdcss. If no device is available, then no CSS authentication is performed, and we hope that the image is decrypted.

If the path given is a directory, then the files in that directory may be in any one of these formats:

path/VIDEO_TS/VTS_01_1.VOB path/video_ts/vts_01_1.vob path/VTS_01_1.VOB path/vts_01_1.vob

Parameters
pathSpecifies the the device, file or directory to be used.
streamis a private handle used by stream_cb
stream_cbis a struct containing seek and read functions
Returns
If successful a a read handle is returned. Otherwise 0 is returned.

dvd = DVDOpen(path); dvd = DVDOpenStream(stream, &stream_cb);

◆ DVDOpen2()

dvd_reader_t * DVDOpen2 ( void * ,
const dvd_logger_cb * ,
const char *  )

Same as DVDOpen, but with private handle to be passed back on callbacks

Parameters
pathSpecifies the the device, file or directory to be used.
privis a private handle
logcbis a custom logger callback struct, or NULL if none needed
stream_cbis a struct containing seek and read functions
Returns
If successful a a read handle is returned. Otherwise 0 is returned.

dvd = DVDOpen2(priv, logcb, path); dvd = DVDOpenStream2(priv, logcb, &stream_cb);

◆ DVDOpenFile()

dvd_file_t * DVDOpenFile ( dvd_reader_t * ,
int ,
dvd_read_domain_t  )

Opens a file on the DVD given the title number and domain.

If the title number is 0, the video manager information is opened (VIDEO_TS.[IFO,BUP,VOB]). Returns a file structure which may be used for reads, or 0 if the file was not found.

Parameters
dvdA dvd read handle.
titlenumWhich Video Title Set should be used, VIDEO_TS is 0.
domainWhich domain.
Returns
If successful a a file read handle is returned, otherwise 0.

dvd_file = DVDOpenFile(dvd, titlenum, domain);

◆ DVDOpenStream()

dvd_reader_t * DVDOpenStream ( void * ,
dvd_reader_stream_cb *  )

◆ DVDOpenStream2()

dvd_reader_t * DVDOpenStream2 ( void * ,
const dvd_logger_cb * ,
dvd_reader_stream_cb *  )

◆ DVDReadBlocks()

ssize_t DVDReadBlocks ( dvd_file_t * ,
int ,
size_t ,
unsigned char *  )

Reads block_count number of blocks from the file at the given block offset. Returns number of blocks read on success, -1 on error. This call is only for reading VOB data, and should not be used when reading the IFO files. When reading from an encrypted drive, blocks are decrypted using libdvdcss where required.

Parameters
dvd_fileA file read handle.
offsetBlock offset from the start of the file to start reading at.
block_countNumber of block to read.
dataPointer to a buffer to write the data into.
Returns
Returns number of blocks read on success, -1 on error.

blocks_read = DVDReadBlocks(dvd_file, offset, block_count, data);

◆ DVDReadBytes()

ssize_t DVDReadBytes ( dvd_file_t * ,
void * ,
size_t  )

Reads the given number of bytes from the file. This call can only be used on the information files, and may not be used for reading from a VOB. This reads from and increments the current seek position for the file.

Parameters
dvd_fileA file read handle.
dataPointer to a buffer to write the data into.
bytesNumber of bytes to read.
Returns
Returns number of bytes read on success, -1 on error.

bytes_read = DVDReadBytes(dvd_file, data, bytes);

◆ DVDUDFCacheLevel()

int DVDUDFCacheLevel ( dvd_reader_t * ,
int  )

Sets the level of caching that is done when reading from a device

Parameters
dvdA read handle to get the disc ID from
levelThe level of caching wanted. -1 - returns the current setting. 0 - UDF Cache turned off. 1 - (default level) Pointers to IFO files and some data from PrimaryVolumeDescriptor are cached.
Returns
The level of caching.

◆ DVDUDFVolumeInfo()

int DVDUDFVolumeInfo ( dvd_reader_t * ,
char * ,
unsigned int ,
unsigned char * ,
unsigned int  )

Get the UDF VolumeIdentifier and VolumeSetIdentifier from the PrimaryVolumeDescriptor.

Parameters
dvdA read handle to get the disc ID from
volidThe buffer to put the VolumeIdentifier into. The VolumeIdentifier is latin-1 encoded (8bit unicode) null terminated and max 32 bytes (including '\0')
volid_sizeNo more than volid_size bytes will be copied to volid. If the VolumeIdentifier is truncated because of this it will still be null terminated.
volsetidThe buffer to put the VolumeSetIdentifier into. The VolumeIdentifier is 128 bytes as stored in the UDF PrimaryVolumeDescriptor. Note that this is not a null terminated string.
volsetid_sizeAt most volsetid_size bytes will be copied to volsetid.
Returns
0 on success, -1 on error.