avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::CustomIO Struct Reference

Interface class to customize IO operations with FormatContext. More...

#include <formatcontext.h>

Public Member Functions

virtual int write (const uint8_t *data, size_t size)
 Write part of data to the destination.
virtual int read (uint8_t *data, size_t size)
 Read part of data from the data source.
virtual int64_t seek (int64_t offset, int whence)
 Seek in stream.
virtual int seekable () const
 Defines supported types of buffer seeking.
virtual const char * name () const
 Name of the I/O.

Detailed Description

It can be used for:

  • From memory I/O
  • mmapped files I/O
  • Specific containers reading (tar, zip files, for example)
  • Device I/O
  • Network I/O
  • Pattern generation
  • Image output to the display (for the appropriate formats, like rawvideo)

CustomIO object is not owned by the av::FormatContext and must be alived across av::FormatContext life.

Member Function Documentation

◆ name()

virtual const char * av::CustomIO::name ( ) const
inlinevirtual

Didn't used for now.

Returns
null-terminated name of the Custom I/O implementation

◆ read()

virtual int av::CustomIO::read ( uint8_t * data,
size_t size )
inlinevirtual

Note, if requested more data that exists to read, you should fill buffer as much as possible and return actual count of the readed data. 0 readed bytes is a valid case, but return it only if there is temporary issues with upstream that can be solved quickly. Otherwise return AVERROR_EOF of AVERROR(EBUSY)/AVERROR(EAGAIN).

See also
avio_read()
Parameters
databuffer to store data
sizesize of the buffer
Returns
count of the actually readed data. AVERROR(xxx) for the system errors (errno wrap) or AVERROR_xxx for the FFmpeg errors. AVERROR_EOF should be returns when end of file reached.

◆ seek()

virtual int64_t av::CustomIO::seek ( int64_t offset,
int whence )
inlinevirtual

whence may support special FFmpeg-ralated values:

  • AVSEEK_SIZE - return size without actual seeking. If unsupported, seek() may return <0
  • AVSEEK_FORCE - read official FFmpeg documentation. Just ignore it.
See also
avio_seek()
Parameters
offsetoffset, may be less zero, equal zero or greater zero.
whenceis a one of SEEK_* from stdio.h
Returns
new position or AVERROR

◆ seekable()

virtual int av::CustomIO::seekable ( ) const
inlinevirtual

Used to fill AVIOContext::seekable. In any case, seek() work on the byte level.

Returns
combination of AVIO_SEEKABLE_* flags or zero

◆ write()

virtual int av::CustomIO::write ( const uint8_t * data,
size_t size )
inlinevirtual

Note, FFmpeg does not consider return value ​​>0 as the number of bytes actually written and assumes that all data has been written. Be careful. If data can't be fit into destination better return appropriate AVERROR code.

See also
avio_write()
Parameters
datablock of data to write
sizesize of the data block
Returns
>=0 on success. AVERROR(xxx) for the system errors (errno wrap) or AVERROR_xxx codes.

The documentation for this struct was generated from the following file: