FFmpegfs Fuse Multi Media Filesystem 2.16
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
FileIO Class Referenceabstract

Base class for I/O. More...

#include <fileio.h>

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

Public Member Functions

 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...
 

Static Public Member Functions

static std::shared_ptr< FileIOalloc (VIRTUALTYPE type)
 Allocate the correct object for type(). More...
 

Protected Member Functions

void set_virtualfile (LPVIRTUALFILE virtualfile)
 Set the virtual file object. More...
 

Private Attributes

std::string m_path
 Source path (directory without file name) More...
 
LPVIRTUALFILE m_virtualfile
 Virtual file object of current file. More...
 

Detailed Description

Base class for I/O.

Definition at line 259 of file fileio.h.

Constructor & Destructor Documentation

◆ FileIO()

FileIO::FileIO ( )
explicit

Create FileIO object.

Definition at line 57 of file fileio.cc.

Member Function Documentation

◆ alloc()

std::shared_ptr< FileIO > FileIO::alloc ( VIRTUALTYPE  type)
static

Allocate the correct object for type().

Free with delete if no longer required.

Parameters
[in]type- VIRTUALTYPE of new object.
Returns
Upon successful completion, FileIO of the requested type. On error, (out of memory), it returns a nullptr.

Definition at line 63 of file fileio.cc.

References BLURAY, DISK, DVD, type(), and VCD.

Referenced by FFmpeg_Transcoder::open_input_file().

◆ bufsize()

virtual size_t FileIO::bufsize ( ) const
pure virtual

Get the ideal buffer size.

Returns
Return the ideal buffer size.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

◆ closeio()

virtual void FileIO::closeio ( )
pure virtual

Close virtual file.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

◆ duration()

virtual int64_t FileIO::duration ( ) const
pure virtual

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

This is only possible for file formats that are aware of the play time. May be AV_NOPTS_VALUE if the time is not known.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

◆ eof()

virtual bool FileIO::eof ( ) const
pure virtual

Check if at end of file.

Returns
Returns true if at end of file.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by FFmpeg_Transcoder::input_read().

◆ error()

virtual int FileIO::error ( ) const
pure virtual

Get last error.

Returns
errno value of last error.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by FFmpeg_Transcoder::input_read().

◆ filename()

const std::string & FileIO::filename ( ) const

Get source filename.

Returns
Returns source filename.

Definition at line 123 of file fileio.cc.

References VIRTUALFILE::m_destfile, and m_virtualfile.

Referenced by Buffer::init(), Buffer::make_cachefile_name(), Buffer::map_file(), Buffer::reallocate(), Buffer::remove_file(), and Buffer::unmap_file().

◆ openio()

virtual int FileIO::openio ( LPVIRTUALFILE  virtualfile)
pure virtual

Open a virtual file.

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

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

◆ path()

const std::string & FileIO::path ( ) const

Path to source file (without file name)

Returns
Returns path to source file.

Definition at line 118 of file fileio.cc.

References m_path.

Referenced by BlurayIO::openio(), DvdIO::openio(), VcdIO::openio(), BlurayIO::readio(), and DvdIO::readio().

◆ readio()

virtual size_t FileIO::readio ( void *  data,
size_t  size 
)
pure virtual

Read data from a file.

Parameters
[out]data- A buffer to store read bytes in. It must be large enough to hold up to size bytes.
[in]size- The 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 the end of the file, 0 may be returned but errno is not set. error() will return 0 if at EOF.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by FFmpeg_Transcoder::input_read().

◆ seek()

virtual int FileIO::seek ( int64_t  offset,
int  whence 
)
pure virtual

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.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by FFmpeg_Transcoder::seek().

◆ set_virtualfile()

void FileIO::set_virtualfile ( LPVIRTUALFILE  virtualfile)
protected

Set the virtual file object.

Parameters
[in]virtualfile- LPCVIRTUALFILE of file to set.

Definition at line 96 of file fileio.cc.

References VIRTUALFILE::m_origfile, m_path, m_virtualfile, remove_filename(), and virtualfile().

Referenced by BlurayIO::openio(), Buffer::openio(), DiskIO::openio(), DvdIO::openio(), and VcdIO::openio().

◆ size()

virtual size_t FileIO::size ( ) const
pure virtual

Get the file size.

Returns
Returns the file size.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by FFmpeg_Transcoder::seek().

◆ tell()

virtual size_t FileIO::tell ( ) const
pure virtual

Get current read position.

Returns
Gets the current read position.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

◆ type()

virtual VIRTUALTYPE FileIO::type ( ) const
pure virtual

Get type of the virtual file.

Returns
Returns the type of the virtual file.

Implemented in BlurayIO, Buffer, DiskIO, DvdIO, and VcdIO.

Referenced by alloc().

◆ virtualfile()

LPVIRTUALFILE FileIO::virtualfile ( )

Get virtual file object.

Returns
Current virtual file object or nullptr if unset.

Definition at line 113 of file fileio.cc.

References m_virtualfile.

Referenced by FFmpeg_Transcoder::encode_finish(), Buffer::have_frame(), Buffer::init(), BlurayIO::openio(), Buffer::openio(), DiskIO::openio(), DvdIO::openio(), VcdIO::openio(), Buffer::read_frame(), set_virtualfile(), and Buffer::write_frame().

Member Data Documentation

◆ m_path

std::string FileIO::m_path
private

Source path (directory without file name)

Definition at line 373 of file fileio.h.

Referenced by path(), and set_virtualfile().

◆ m_virtualfile

LPVIRTUALFILE FileIO::m_virtualfile
private

Virtual file object of current file.

Definition at line 374 of file fileio.h.

Referenced by filename(), set_virtualfile(), and virtualfile().


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