FFmpegfs Fuse Multi Media Filesystem 2.16
Public Member Functions | Protected Attributes | Private Types | Private Member Functions | List of all members
DvdIO Class Reference

DVD I/O class. More...

#include <dvdio.h>

Inheritance diagram for DvdIO:
Inheritance graph
[legend]
Collaboration diagram for DvdIO:
Collaboration graph
[legend]

Public Member Functions

 DvdIO ()
 Create DvdIO object. More...
 
virtual ~DvdIO ()
 Free DvdIO object. More...
 
virtual VIRTUALTYPE type () const override
 Get type of the virtual file. More...
 
virtual size_t bufsize () const override
 Get the ideal buffer size. More...
 
virtual int openio (LPVIRTUALFILE virtualfile) override
 Open a virtual file. More...
 
virtual size_t readio (void *data, size_t size) override
 Read data from file. More...
 
virtual int error () const override
 Get last error. More...
 
virtual int64_t duration () const override
 Get the duration of the file, in AV_TIME_BASE fractional seconds. More...
 
virtual size_t size () const override
 Get the file size. More...
 
virtual size_t tell () const override
 Get current read position. More...
 
virtual int seek (int64_t offset, int whence) override
 Seek to position in file. More...
 
virtual bool eof () const override
 Check if at end of file. More...
 
virtual void closeio () override
 Close virtual file. More...
 
- Public Member Functions inherited from FileIO
 FileIO ()
 Create FileIO object. More...
 
virtual ~FileIO ()=default
 Free FileIO object.
 
virtual VIRTUALTYPE type () const =0
 Get type of the virtual file. More...
 
virtual size_t bufsize () const =0
 Get the ideal buffer size. More...
 
virtual int openio (LPVIRTUALFILE virtualfile)=0
 Open a virtual file. More...
 
virtual size_t readio (void *data, size_t size)=0
 Read data from a file. More...
 
virtual int error () const =0
 Get last error. More...
 
virtual int64_t duration () const =0
 Get the duration of the file, in AV_TIME_BASE fractional seconds. More...
 
virtual size_t size () const =0
 Get the file size. More...
 
virtual size_t tell () const =0
 Get current read position. More...
 
virtual int seek (int64_t offset, int whence)=0
 Seek to position in file. More...
 
virtual bool eof () const =0
 Check if at end of file. More...
 
virtual void closeio ()=0
 Close virtual file. More...
 
LPVIRTUALFILE virtualfile ()
 Get virtual file object. More...
 
const std::string & filename () const
 Get source filename. More...
 
const std::string & path () const
 Path to source file (without file name) More...
 

Protected Attributes

dvd_reader_t * m_dvd
 DVD reader handle. More...
 
dvd_file_t * m_dvd_title
 DVD title handle. More...
 
ifo_handle_t * m_vmg_file
 DVD video manager handle. More...
 
ifo_handle_t * m_vts_file
 DVD video title stream handle. More...
 
pgc_t * m_cur_pgc
 Current program chain. More...
 
int m_start_cell
 Start cell. More...
 
int m_end_cell
 End cell (of title) More...
 
int m_cur_cell
 Current cell. More...
 
int m_next_cell
 Next cell to be processed. More...
 
bool m_goto_next_cell
 If logc needs to go to next cell before next read. More...
 
unsigned int m_cur_block
 Current processing block. More...
 
bool m_is_eof
 true if at "end of file", i.e, end of chapter or title More...
 
int m_errno
 errno of last operation More...
 
size_t m_rest_size
 Rest bytes in buffer. More...
 
size_t m_rest_pos
 Position in buffer. More...
 
size_t m_cur_pos
 Current position in virtual file. More...
 
bool m_full_title
 If true, ignore m_chapter_no and provide full track. More...
 
int m_title_idx
 Track index (track number - 1) More...
 
int m_chapter_idx
 Chapter index (chapter number - 1) More...
 
int m_angle_idx
 Selected angle index (angle number -1) More...
 
std::array< unsigned char, 1024 *DVD_VIDEO_LB_LEN > m_data
 Buffer for readio() data. More...
 
std::array< unsigned char, 1024 *DVD_VIDEO_LB_LEN > m_buffer
 Buffer for data extracted from VOB file. More...
 
int64_t m_duration
 Track/chapter duration, in AV_TIME_BASE fractional seconds. More...
 
size_t m_size
 Size of virtual file. More...
 

Private Types

enum class  DSITYPE { CONTINUE , EOF_CHAPTER , EOF_TITLE }
 Type of a DSI block. More...
 

Private Member Functions

void pvt_close ()
 Close virtual file. Non-virtual version to be safely called from constructor/destructor. More...
 
bool is_nav_pack (const unsigned char *buffer) const
 Do a rough check if this is really a navigation packet. More...
 
bool get_packet_size (const uint8_t *p, size_t peek, size_t *size) const
 return the size of the next packet More...
 
int get_pes_id (const uint8_t *buffer, size_t size) const
 return the id of a Packetized Elementary Stream (PES) (should be valid) More...
 
size_t demux_pes (uint8_t *out, const uint8_t *in, size_t len) const
 Extract only the interesting portion of the VOB input stream. More...
 
DSITYPE handle_DSI (void *_dsi_pack, size_t *cur_output_size, unsigned int *next_block, uint8_t *data)
 Handle DSI (Data Search Information) packet. More...
 
void next_cell ()
 Goto next DVD cell. More...
 
void rewind ()
 Rewind to start of stream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FileIO
static std::shared_ptr< FileIOalloc (VIRTUALTYPE type)
 Allocate the correct object for type(). More...
 
- Protected Member Functions inherited from FileIO
void set_virtualfile (LPVIRTUALFILE virtualfile)
 Set the virtual file object. More...
 

Detailed Description

DVD I/O class.

Definition at line 49 of file dvdio.h.

Member Enumeration Documentation

◆ DSITYPE

enum class DvdIO::DSITYPE
strongprivate

Type of a DSI block.

This is used to identify a DSI block on a DVD: Until end of a chapter we simply continue. At the end of chapters we may stop continue to the end of a title

Enumerator
CONTINUE 

Chapter continues.

EOF_CHAPTER 

End of chapter.

EOF_TITLE 

End of title.

Definition at line 58 of file dvdio.h.

Constructor & Destructor Documentation

◆ DvdIO()

DvdIO::DvdIO ( )
explicit

Create DvdIO object.

Definition at line 42 of file dvdio.cc.

References m_buffer, and m_data.

◆ ~DvdIO()

DvdIO::~DvdIO ( )
virtual

Free DvdIO object.

Definition at line 70 of file dvdio.cc.

References pvt_close().

Member Function Documentation

◆ bufsize()

size_t DvdIO::bufsize ( ) const
overridevirtual

Get the ideal buffer size.

Returns
Return the ideal buffer size.

Implements FileIO.

Definition at line 80 of file dvdio.cc.

References m_data.

◆ closeio()

void DvdIO::closeio ( )
overridevirtual

Close virtual file.

Implements FileIO.

Definition at line 797 of file dvdio.cc.

References pvt_close().

◆ demux_pes()

size_t DvdIO::demux_pes ( uint8_t *  out,
const uint8_t *  in,
size_t  len 
) const
private

Extract only the interesting portion of the VOB input stream.

Parameters
[out]out- Stream stripped from unnessessary data
[in]in- Input raw stream
[in]len- Length of input raw stream
Returns
Size of restulting data block.

Definition at line 388 of file dvdio.cc.

References get_packet_size(), get_pes_id(), PS_STREAM_ID, PS_STREAM_ID_AUDIO, PS_STREAM_ID_END_STREAM, PS_STREAM_ID_MAP, PS_STREAM_ID_PACK_HEADER, and PS_STREAM_ID_SYSTEM_HEADER.

Referenced by readio().

◆ duration()

int64_t DvdIO::duration ( ) const
overridevirtual

Get the duration of the file, in AV_TIME_BASE fractional seconds.

Returns
Returns the duration of the file, in AV_TIME_BASE fractional seconds.

Implements FileIO.

Definition at line 706 of file dvdio.cc.

References m_duration.

◆ eof()

bool DvdIO::eof ( ) const
overridevirtual

Check if at end of file.

Returns
Returns true if at end of file.

Implements FileIO.

Definition at line 792 of file dvdio.cc.

References m_is_eof.

Referenced by openio(), and seek().

◆ error()

int DvdIO::error ( ) const
overridevirtual

Get last error.

Returns
errno value of last error.

Implements FileIO.

Definition at line 701 of file dvdio.cc.

References m_errno.

◆ get_packet_size()

bool DvdIO::get_packet_size ( const uint8_t *  p,
size_t  peek,
size_t *  size 
) const
private

return the size of the next packet

Parameters
[in]p- Buffer with PES data.
[in]peek- How many bytes to peek.
[in]size- Size of the next packet
Returns
Size ofr ID invalid.

Definition at line 236 of file dvdio.cc.

References PS_STREAM_ID, PS_STREAM_ID_DIRECTORY, PS_STREAM_ID_END_STREAM, PS_STREAM_ID_MAP, PS_STREAM_ID_PACK_HEADER, PS_STREAM_ID_SYSTEM_HEADER, and size().

Referenced by demux_pes().

◆ get_pes_id()

int DvdIO::get_pes_id ( const uint8_t *  buffer,
size_t  size 
) const
private

return the id of a Packetized Elementary Stream (PES) (should be valid)

Parameters
[in]buffer- Buffer with PES data.
[in]size- Size of buffer.
Returns
The id of a PES (should be valid)

Definition at line 284 of file dvdio.cc.

References PS_STREAM_ID, PS_STREAM_ID_EXTENDED, PS_STREAM_ID_PRIVATE_STREAM1, and size().

Referenced by demux_pes().

◆ handle_DSI()

DvdIO::DSITYPE DvdIO::handle_DSI ( void *  _dsi_pack,
size_t *  cur_output_size,
unsigned int *  next_block,
uint8_t *  data 
)
private

Handle DSI (Data Search Information) packet.

Parameters
[out]_dsi_pack- buffer with DSI packet.
[out]cur_output_size- Net size of packet.
[out]next_block- Address of next VOBU (Video Object Unit).
[out]data- Data extracted from DSI packet.
Returns

Definition at line 439 of file dvdio.cc.

References CONTINUE, EOF_CHAPTER, EOF_TITLE, m_angle_idx, m_cur_block, m_cur_cell, m_cur_pgc, m_end_cell, m_next_cell, and next_cell().

Referenced by readio().

◆ is_nav_pack()

bool DvdIO::is_nav_pack ( const unsigned char *  buffer) const
private

Do a rough check if this is really a navigation packet.

Parameters
[in]buffer- Buffer with data.
Returns
true if the pack is a NAV pack.

Definition at line 831 of file dvdio.cc.

Referenced by readio().

◆ next_cell()

void DvdIO::next_cell ( )
private

Goto next DVD cell.

Definition at line 530 of file dvdio.cc.

References m_angle_idx, m_cur_cell, m_cur_pgc, and m_next_cell.

Referenced by handle_DSI(), and readio().

◆ openio()

int DvdIO::openio ( LPVIRTUALFILE  virtualfile)
overridevirtual

Open a virtual file.

Parameters
[in]virtualfile- LPCVIRTUALFILE of file to open
Returns
Upon successful completion, openio() returns 0.
On error, an nonzero value is returned and errno is set to indicate the error.

Implements FileIO.

Definition at line 85 of file dvdio.cc.

References Logging::debug(), eof(), Logging::error(), m_angle_idx, VIRTUALFILE::DVD_CHAPTER::m_angle_no, m_chapter_idx, VIRTUALFILE::DVD_CHAPTER::m_chapter_no, m_cur_pgc, m_duration, VIRTUALFILE::m_duration, m_dvd, VIRTUALFILE::m_dvd, m_dvd_title, m_end_cell, m_full_title, VIRTUALFILE::m_full_title, m_size, m_start_cell, m_title_idx, VIRTUALFILE::DVD_CHAPTER::m_title_no, m_vmg_file, m_vts_file, FileIO::path(), readio(), rewind(), FileIO::set_virtualfile(), Logging::trace(), and FileIO::virtualfile().

◆ pvt_close()

void DvdIO::pvt_close ( )
private

Close virtual file. Non-virtual version to be safely called from constructor/destructor.

Definition at line 802 of file dvdio.cc.

References m_dvd, m_dvd_title, m_vmg_file, and m_vts_file.

Referenced by closeio(), and ~DvdIO().

◆ readio()

size_t DvdIO::readio ( void *  data,
size_t  size 
)
overridevirtual

Read data from file.

Parameters
[out]data- buffer to store read bytes in. Must be large enough to hold up to size bytes. Special case: If set to nullptr as many bytes as possible are "read" (and discarded). Can be used to determine the net file size of the virtual stream.
[in]size- number of bytes to read
Returns
Upon successful completion, readio() returns the number of bytes read.
This may be less than size.
On error, the value 0 is returned and errno is set to indicate the error.
If at end of file, 0 may be returned by errno not set. error() will return 0 if at EOF.

Implements FileIO.

Definition at line 552 of file dvdio.cc.

References CONTINUE, demux_pes(), EOF_TITLE, Logging::error(), handle_DSI(), is_nav_pack(), m_buffer, m_cur_block, m_cur_cell, m_cur_pgc, m_cur_pos, m_data, m_dvd_title, m_errno, m_full_title, m_goto_next_cell, m_is_eof, m_next_cell, m_rest_pos, m_rest_size, next_cell(), FileIO::path(), size(), and Logging::warning().

Referenced by openio(), and seek().

◆ rewind()

void DvdIO::rewind ( )
private

Rewind to start of stream.

Definition at line 721 of file dvdio.cc.

References m_cur_cell, m_cur_pos, m_errno, m_goto_next_cell, m_is_eof, m_next_cell, m_rest_pos, m_rest_size, and m_start_cell.

Referenced by openio(), and seek().

◆ seek()

int DvdIO::seek ( int64_t  offset,
int  whence 
)
overridevirtual

Seek to position in file.

Repositions the offset of the open file to the argument offset according to the directive whence.

Parameters
[in]offset- offset in bytes
[in]whence- how to seek:
SEEK_SET: The offset is set to offset bytes.
SEEK_CUR: The offset is set to its current location plus offset bytes.
SEEK_END: The offset is set to the size of the file plus offset bytes.
Returns
Upon successful completion, seek() returns the resulting offset location as measured in bytes from the beginning of the file.
On error, the value -1 is returned and errno is set to indicate the error.

Implements FileIO.

Definition at line 734 of file dvdio.cc.

References eof(), readio(), rewind(), size(), and tell().

◆ size()

size_t DvdIO::size ( ) const
overridevirtual

Get the file size.

Returns
Returns the file size.

Implements FileIO.

Definition at line 711 of file dvdio.cc.

References m_size.

Referenced by get_packet_size(), get_pes_id(), readio(), and seek().

◆ tell()

size_t DvdIO::tell ( ) const
overridevirtual

Get current read position.

Returns
Gets the current read position.

Implements FileIO.

Definition at line 716 of file dvdio.cc.

References m_cur_pos.

Referenced by seek().

◆ type()

VIRTUALTYPE DvdIO::type ( ) const
overridevirtual

Get type of the virtual file.

Returns
Returns the type of the virtual file.

Implements FileIO.

Definition at line 75 of file dvdio.cc.

References DVD.

Member Data Documentation

◆ m_angle_idx

int DvdIO::m_angle_idx
protected

Selected angle index (angle number -1)

Definition at line 225 of file dvdio.h.

Referenced by handle_DSI(), next_cell(), and openio().

◆ m_buffer

std::array<unsigned char, 1024 * DVD_VIDEO_LB_LEN> DvdIO::m_buffer
protected

Buffer for data extracted from VOB file.

Definition at line 228 of file dvdio.h.

Referenced by DvdIO(), and readio().

◆ m_chapter_idx

int DvdIO::m_chapter_idx
protected

Chapter index (chapter number - 1)

Definition at line 224 of file dvdio.h.

Referenced by openio().

◆ m_cur_block

unsigned int DvdIO::m_cur_block
protected

Current processing block.

Definition at line 215 of file dvdio.h.

Referenced by handle_DSI(), and readio().

◆ m_cur_cell

int DvdIO::m_cur_cell
protected

Current cell.

Definition at line 212 of file dvdio.h.

Referenced by handle_DSI(), next_cell(), readio(), and rewind().

◆ m_cur_pgc

pgc_t* DvdIO::m_cur_pgc
protected

Current program chain.

Definition at line 209 of file dvdio.h.

Referenced by handle_DSI(), next_cell(), openio(), and readio().

◆ m_cur_pos

size_t DvdIO::m_cur_pos
protected

Current position in virtual file.

Definition at line 220 of file dvdio.h.

Referenced by readio(), rewind(), and tell().

◆ m_data

std::array<unsigned char, 1024 * DVD_VIDEO_LB_LEN> DvdIO::m_data
protected

Buffer for readio() data.

Definition at line 227 of file dvdio.h.

Referenced by bufsize(), DvdIO(), and readio().

◆ m_duration

int64_t DvdIO::m_duration
protected

Track/chapter duration, in AV_TIME_BASE fractional seconds.

Definition at line 230 of file dvdio.h.

Referenced by duration(), and openio().

◆ m_dvd

dvd_reader_t* DvdIO::m_dvd
protected

DVD reader handle.

Definition at line 205 of file dvdio.h.

Referenced by openio(), and pvt_close().

◆ m_dvd_title

dvd_file_t* DvdIO::m_dvd_title
protected

DVD title handle.

Definition at line 206 of file dvdio.h.

Referenced by openio(), pvt_close(), and readio().

◆ m_end_cell

int DvdIO::m_end_cell
protected

End cell (of title)

Definition at line 211 of file dvdio.h.

Referenced by handle_DSI(), and openio().

◆ m_errno

int DvdIO::m_errno
protected

errno of last operation

Definition at line 217 of file dvdio.h.

Referenced by error(), readio(), and rewind().

◆ m_full_title

bool DvdIO::m_full_title
protected

If true, ignore m_chapter_no and provide full track.

Definition at line 222 of file dvdio.h.

Referenced by openio(), and readio().

◆ m_goto_next_cell

bool DvdIO::m_goto_next_cell
protected

If logc needs to go to next cell before next read.

Definition at line 214 of file dvdio.h.

Referenced by readio(), and rewind().

◆ m_is_eof

bool DvdIO::m_is_eof
protected

true if at "end of file", i.e, end of chapter or title

Definition at line 216 of file dvdio.h.

Referenced by eof(), readio(), and rewind().

◆ m_next_cell

int DvdIO::m_next_cell
protected

Next cell to be processed.

Definition at line 213 of file dvdio.h.

Referenced by handle_DSI(), next_cell(), readio(), and rewind().

◆ m_rest_pos

size_t DvdIO::m_rest_pos
protected

Position in buffer.

Definition at line 219 of file dvdio.h.

Referenced by readio(), and rewind().

◆ m_rest_size

size_t DvdIO::m_rest_size
protected

Rest bytes in buffer.

Definition at line 218 of file dvdio.h.

Referenced by readio(), and rewind().

◆ m_size

size_t DvdIO::m_size
protected

Size of virtual file.

Definition at line 231 of file dvdio.h.

Referenced by openio(), and size().

◆ m_start_cell

int DvdIO::m_start_cell
protected

Start cell.

Definition at line 210 of file dvdio.h.

Referenced by openio(), and rewind().

◆ m_title_idx

int DvdIO::m_title_idx
protected

Track index (track number - 1)

Definition at line 223 of file dvdio.h.

Referenced by openio().

◆ m_vmg_file

ifo_handle_t* DvdIO::m_vmg_file
protected

DVD video manager handle.

Definition at line 207 of file dvdio.h.

Referenced by openio(), and pvt_close().

◆ m_vts_file

ifo_handle_t* DvdIO::m_vts_file
protected

DVD video title stream handle.

Definition at line 208 of file dvdio.h.

Referenced by openio(), and pvt_close().


The documentation for this class was generated from the following files: