AvTranscoder  0.9.4
C++APIforLibav/FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
avtranscoder::FormatContext Class Reference

Wrapper of an AVFormatContext. More...

#include <FormatContext.hpp>

Public Member Functions

 FormatContext (const std::string &filename, int req_flags=0, AVDictionary **options=NULL)
 Allocate an AVFormatContext by opening an input file. More...
 
 FormatContext (int req_flags=0)
 Allocate an AVFormatContext with default values. More...
 
 ~FormatContext ()
 
void findStreamInfo (AVDictionary **options=NULL)
 Read packets of a media file to get stream information. More...
 
void openRessource (const std::string &url, int flags)
 Create and initialize a AVIOContext for accessing the resource indicated by url. More...
 
void closeRessource ()
 Close the resource accessed by the AVIOContext and free it. More...
 
void writeHeader (AVDictionary **options=NULL)
 Write the stream header to an output media file. More...
 
void writeFrame (AVPacket &packet, bool interleaved=true)
 Write a packet to an output media file. More...
 
void writeTrailer ()
 Write the stream trailer to an output media file. More...
 
void addMetaData (const std::string &key, const std::string &value)
 
AVStream & addAVStream (const AVCodec &avCodec)
 
bool seek (const uint64_t position, const int flag)
 Seek at a specific position. More...
 
size_t getNbStreams () const
 
size_t getDuration () const
 Get duration of the program, in seconds. More...
 
size_t getStartTime () const
 
OptionArray getOptions ()
 Get options as array. More...
 
OptionMapgetOptionsMap ()
 Get options as map. More...
 
OptiongetOption (const std::string &optionName)
 
void setOutputFormat (const std::string &filename, const std::string &shortName="", const std::string &mimeType="")
 
void setFilename (const std::string &filename)
 
AVFormatContext & getAVFormatContext () const
 
AVOutputFormat & getAVOutputFormat () const
 
AVInputFormat & getAVInputFormat () const
 
AVIOContext & getAVIOContext () const
 
AVDictionary & getAVMetaData () const
 
AVStream & getAVStream (size_t index) const
 

Private Member Functions

 FormatContext (const FormatContext &formatContext)
 
FormatContextoperator= (const FormatContext &formatContext)
 

Private Attributes

AVFormatContext * _avFormatContext
 Has ownership. More...
 
const int _flags
 Flags with which the options are loaded (see AV_OPT_FLAG_xxx) More...
 
OptionMap _options
 
bool _isOpen
 Is the AVFormatContext open (in constructor with a filename) More...
 

Detailed Description

Wrapper of an AVFormatContext.

Definition at line 17 of file FormatContext.hpp.

Constructor & Destructor Documentation

avtranscoder::FormatContext::FormatContext ( const FormatContext formatContext)
private
avtranscoder::FormatContext::FormatContext ( const std::string &  filename,
int  req_flags = 0,
AVDictionary **  options = NULL 
)

Allocate an AVFormatContext by opening an input file.

Definition at line 9 of file FormatContext.cpp.

References _avFormatContext, _isOpen, _options, avtranscoder::getDescriptionFromErrorCode(), and avtranscoder::loadOptions().

avtranscoder::FormatContext::FormatContext ( int  req_flags = 0)

Allocate an AVFormatContext with default values.

Definition at line 32 of file FormatContext.cpp.

References _avFormatContext, _options, and avtranscoder::loadOptions().

avtranscoder::FormatContext::~FormatContext ( )

Definition at line 42 of file FormatContext.cpp.

References _avFormatContext, and _isOpen.

Member Function Documentation

AVStream & avtranscoder::FormatContext::addAVStream ( const AVCodec &  avCodec)
void avtranscoder::FormatContext::addMetaData ( const std::string &  key,
const std::string &  value 
)
void avtranscoder::FormatContext::closeRessource ( )

Close the resource accessed by the AVIOContext and free it.

Note
Should be called after openRessource

Definition at line 75 of file FormatContext.cpp.

References _avFormatContext, and avtranscoder::getDescriptionFromErrorCode().

Referenced by avtranscoder::OutputFile::endWrap().

void avtranscoder::FormatContext::findStreamInfo ( AVDictionary **  options = NULL)

Read packets of a media file to get stream information.

Definition at line 54 of file FormatContext.cpp.

References _avFormatContext, and avtranscoder::getDescriptionFromErrorCode().

Referenced by avtranscoder::InputFile::InputFile().

AVFormatContext& avtranscoder::FormatContext::getAVFormatContext ( ) const
inline
AVInputFormat& avtranscoder::FormatContext::getAVInputFormat ( ) const
inline

Definition at line 114 of file FormatContext.hpp.

AVIOContext& avtranscoder::FormatContext::getAVIOContext ( ) const
inline

Definition at line 115 of file FormatContext.hpp.

AVDictionary& avtranscoder::FormatContext::getAVMetaData ( ) const
inline

Definition at line 116 of file FormatContext.hpp.

AVOutputFormat& avtranscoder::FormatContext::getAVOutputFormat ( ) const
inline
AVStream & avtranscoder::FormatContext::getAVStream ( size_t  index) const
size_t avtranscoder::FormatContext::getDuration ( ) const
inline

Get duration of the program, in seconds.

Definition at line 88 of file FormatContext.hpp.

Option& avtranscoder::FormatContext::getOption ( const std::string &  optionName)
inline
std::vector< Option > avtranscoder::FormatContext::getOptions ( )

Get options as array.

Definition at line 158 of file FormatContext.cpp.

References _options.

OptionMap& avtranscoder::FormatContext::getOptionsMap ( )
inline

Get options as map.

Definition at line 93 of file FormatContext.hpp.

size_t avtranscoder::FormatContext::getStartTime ( ) const
inline

Definition at line 89 of file FormatContext.hpp.

void avtranscoder::FormatContext::openRessource ( const std::string &  url,
int  flags 
)

Create and initialize a AVIOContext for accessing the resource indicated by url.

Parameters
urlurl of ressource
flagsAVIO_FLAG_READ / AVIO_FLAG_WRITE / AVIO_FLAG_READ_WRITE

Definition at line 63 of file FormatContext.cpp.

References _avFormatContext, and avtranscoder::getDescriptionFromErrorCode().

Referenced by avtranscoder::OutputFile::beginWrap().

FormatContext& avtranscoder::FormatContext::operator= ( const FormatContext formatContext)
private
bool avtranscoder::FormatContext::seek ( const uint64_t  position,
const int  flag 
)

Seek at a specific position.

Parameters
positioncan be in AV_TIME_BASE units, in frames... depending on the flag value
flagseeking mode (AVSEEK_FLAG_xxx)
Returns
seek status seeking on a raw bitstreams (without any container) could produce an error (because of a lack of timing information)
See also
flushDecoder

Definition at line 145 of file FormatContext.cpp.

References _avFormatContext, avtranscoder::getDescriptionFromErrorCode(), LOG_ERROR, and LOG_INFO.

Referenced by avtranscoder::InputFile::seekAtFrame(), and avtranscoder::InputFile::seekAtTime().

void avtranscoder::FormatContext::setFilename ( const std::string &  filename)

Set filename of AVFormatContext.

Definition at line 180 of file FormatContext.cpp.

References _avFormatContext.

Referenced by avtranscoder::OutputFile::OutputFile().

void avtranscoder::FormatContext::setOutputFormat ( const std::string &  filename,
const std::string &  shortName = "",
const std::string &  mimeType = "" 
)

Guess format from arguments. Set the AVOutputFormat of AVFormatContext.

Parameters
filenamechecks if it terminates with the extensions of the registered formats
shortNamechecks if it matches with the names of the registered formats
mimeTypechecks if it matches with the MIME type of the registered formats

Definition at line 185 of file FormatContext.cpp.

References _avFormatContext.

Referenced by avtranscoder::OutputFile::OutputFile(), and avtranscoder::OutputFile::setupWrapping().

void avtranscoder::FormatContext::writeFrame ( AVPacket &  packet,
bool  interleaved = true 
)

Write a packet to an output media file.

Parameters
packetpacket to write (must be allocate and free by the caller
interleavedto ensuring correct interleaving (available by default)

Definition at line 99 of file FormatContext.cpp.

References _avFormatContext, and avtranscoder::getDescriptionFromErrorCode().

Referenced by avtranscoder::OutputFile::wrap().

void avtranscoder::FormatContext::writeHeader ( AVDictionary **  options = NULL)

Write the stream header to an output media file.

Note
Also load options specific to the output format

Definition at line 87 of file FormatContext.cpp.

References _avFormatContext, _flags, _options, avtranscoder::getDescriptionFromErrorCode(), and avtranscoder::loadOptions().

Referenced by avtranscoder::OutputFile::beginWrap().

void avtranscoder::FormatContext::writeTrailer ( )

Write the stream trailer to an output media file.

Note
Should be called after writeHeader

Definition at line 116 of file FormatContext.cpp.

References _avFormatContext, and avtranscoder::getDescriptionFromErrorCode().

Referenced by avtranscoder::OutputFile::endWrap().

Field Documentation

AVFormatContext* avtranscoder::FormatContext::_avFormatContext
private
const int avtranscoder::FormatContext::_flags
private

Flags with which the options are loaded (see AV_OPT_FLAG_xxx)

Definition at line 122 of file FormatContext.hpp.

Referenced by writeHeader().

bool avtranscoder::FormatContext::_isOpen
private

Is the AVFormatContext open (in constructor with a filename)

Definition at line 124 of file FormatContext.hpp.

Referenced by FormatContext(), and ~FormatContext().

OptionMap avtranscoder::FormatContext::_options
private

Definition at line 123 of file FormatContext.hpp.

Referenced by FormatContext(), getOptions(), and writeHeader().


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