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

Outputfile is the default implentation of wrapper which uses LibAV/FFMpeg. More...

#include <OutputFile.hpp>

Public Member Functions

 OutputFile (const std::string &filename, const std::string &formatName="", const std::string &mimeType="")
 Create an output media file. More...
 
 ~OutputFile ()
 
IOutputStreamaddVideoStream (const VideoCodec &videoDesc)
 Add a video output stream. More...
 
IOutputStreamaddAudioStream (const AudioCodec &audioDesc)
 Add an audio output stream. More...
 
IOutputStreamaddDataStream (const DataCodec &dataDesc)
 Add a data output stream. More...
 
bool beginWrap ()
 Open ressource, write header, and setup specific wrapping options given when call setupWrapping. More...
 
IOutputStream::EWrappingStatus wrap (const CodedData &data, const size_t streamIndex)
 Wrap a packet of data in the output ressource. More...
 
bool endWrap ()
 Close ressource and write trailer. More...
 
void addMetadata (const PropertyVector &data)
 Add metadata to the output file. More...
 
void addMetadata (const std::string &key, const std::string &value)
 
IOutputStreamgetStream (const size_t streamIndex)
 Get the output stream. More...
 
std::string getFilename () const
 
std::string getFormatName () const
 A comma separated list of short names for the format, or empty if unknown. More...
 
std::string getFormatLongName () const
 Descriptive name for the format, meant to be more human-readable than name, or empty if unknown. More...
 
std::string getFormatMimeType () const
 Comma-separated list of mime types, or empty if unknown. More...
 
FormatContextgetFormatContext ()
 
void setupWrapping (const ProfileLoader::Profile &profile)
 Set the format and the generic options of the output file. More...
 
- Public Member Functions inherited from avtranscoder::IOutputFile
virtual ~IOutputFile ()
 

Private Member Functions

 OutputFile (const OutputFile &outputFile)
 
OutputFileoperator= (const OutputFile &outputFile)
 
void setupWrappingOptions (const ProfileLoader::Profile &profile)
 
void setupRemainingWrappingOptions ()
 

Private Attributes

FormatContext _formatContext
 
std::vector< OutputStream * > _outputStreams
 Has ownership. More...
 
std::vector< size_t > _frameCount
 Number of wrapped frames. More...
 
double _previousProcessedStreamDuration
 To manage process streams order. More...
 
ProfileLoader::Profile _profile
 To setup specific wrapping options. More...
 

Detailed Description

Outputfile is the default implentation of wrapper which uses LibAV/FFMpeg.

Definition at line 17 of file OutputFile.hpp.

Constructor & Destructor Documentation

avtranscoder::OutputFile::OutputFile ( const OutputFile outputFile)
private
avtranscoder::OutputFile::OutputFile ( const std::string &  filename,
const std::string &  formatName = "",
const std::string &  mimeType = "" 
)

Create an output media file.

Parameters
filenameresource to access
formatNameshould matches with the names of the registered formats
mimeTypeshould matches with the MIME type of the registered formats
Note
The caller should indicate formatName and/or mimeType if the filename has no extension.
The ressource is allocated when beginWrap.
See also
beginWrap

Definition at line 14 of file OutputFile.cpp.

References _formatContext, avtranscoder::FormatContext::setFilename(), and avtranscoder::FormatContext::setOutputFormat().

avtranscoder::OutputFile::~OutputFile ( )

Definition at line 25 of file OutputFile.cpp.

References _outputStreams.

Member Function Documentation

IOutputStream & avtranscoder::OutputFile::addAudioStream ( const AudioCodec audioCodec)
virtual

Add an audio output stream.

Parameters
audioCodecdescription of output stream

Reimplemented from avtranscoder::IOutputFile.

Definition at line 68 of file OutputFile.cpp.

References _formatContext, _outputStreams, avtranscoder::FormatContext::addAVStream(), avtranscoder::ICodec::getAVCodec(), avtranscoder::ICodec::getAVCodecContext(), and avtranscoder::FormatContext::getNbStreams().

IOutputStream & avtranscoder::OutputFile::addDataStream ( const DataCodec dataCodec)
virtual

Add a data output stream.

Parameters
dataCodecdescription of output stream

Reimplemented from avtranscoder::IOutputFile.

Definition at line 88 of file OutputFile.cpp.

References _formatContext, _outputStreams, avtranscoder::FormatContext::addAVStream(), avtranscoder::ICodec::getAVCodec(), and avtranscoder::FormatContext::getNbStreams().

void avtranscoder::OutputFile::addMetadata ( const PropertyVector data)

Add metadata to the output file.

Note
Depending on the format, you are not sure to find your metadata after the transcode.

Definition at line 239 of file OutputFile.cpp.

void avtranscoder::OutputFile::addMetadata ( const std::string &  key,
const std::string &  value 
)

Definition at line 247 of file OutputFile.cpp.

References _formatContext, and avtranscoder::FormatContext::addMetaData().

IOutputStream & avtranscoder::OutputFile::addVideoStream ( const VideoCodec videoCodec)
virtual
bool avtranscoder::OutputFile::beginWrap ( )
virtual

Open ressource, write header, and setup specific wrapping options given when call setupWrapping.

Note
Need to add the streams to mux before calling this method.
After this call, a new list of AVOption, relative to the format choosen, will be available for the OutputFile.

Implements avtranscoder::IOutputFile.

Definition at line 150 of file OutputFile.cpp.

References _formatContext, _frameCount, _outputStreams, getFilename(), LOG_DEBUG, avtranscoder::FormatContext::openRessource(), setupRemainingWrappingOptions(), and avtranscoder::FormatContext::writeHeader().

bool avtranscoder::OutputFile::endWrap ( )
virtual

Close ressource and write trailer.

Implements avtranscoder::IOutputFile.

Definition at line 230 of file OutputFile.cpp.

References _formatContext, avtranscoder::FormatContext::closeRessource(), LOG_DEBUG, and avtranscoder::FormatContext::writeTrailer().

std::string avtranscoder::OutputFile::getFilename ( ) const
FormatContext& avtranscoder::OutputFile::getFormatContext ( )
inline

Definition at line 81 of file OutputFile.hpp.

std::string avtranscoder::OutputFile::getFormatLongName ( ) const

Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.

Definition at line 130 of file OutputFile.cpp.

References _formatContext, avtranscoder::FormatContext::getAVOutputFormat(), getFilename(), and LOG_WARN.

std::string avtranscoder::OutputFile::getFormatMimeType ( ) const

Comma-separated list of mime types, or empty if unknown.

Definition at line 140 of file OutputFile.cpp.

References _formatContext, avtranscoder::FormatContext::getAVOutputFormat(), getFilename(), and LOG_WARN.

std::string avtranscoder::OutputFile::getFormatName ( ) const

A comma separated list of short names for the format, or empty if unknown.

Definition at line 120 of file OutputFile.cpp.

References _formatContext, avtranscoder::FormatContext::getAVOutputFormat(), getFilename(), and LOG_WARN.

IOutputStream & avtranscoder::OutputFile::getStream ( const size_t  streamIndex)
virtual

Get the output stream.

Parameters
streamIndexselect the output stream
Returns
the output stream reference

Implements avtranscoder::IOutputFile.

Definition at line 98 of file OutputFile.cpp.

References _outputStreams, and getFilename().

OutputFile& avtranscoder::OutputFile::operator= ( const OutputFile outputFile)
private
void avtranscoder::OutputFile::setupWrapping ( const ProfileLoader::Profile profile)

Set the format and the generic options of the output file.

Parameters
profilethe profile of the output format
Note
options specific to the output format will be set in beginWrap.
See also
beginWrap

Definition at line 252 of file OutputFile.cpp.

References _formatContext, avtranscoder::constants::avProfileFormat, avtranscoder::ProfileLoader::checkFormatProfile(), getFilename(), LOG_ERROR, LOG_INFO, avtranscoder::FormatContext::setOutputFormat(), and setupWrappingOptions().

IOutputStream::EWrappingStatus avtranscoder::OutputFile::wrap ( const CodedData data,
const size_t  streamIndex 
)
virtual

Wrap a packet of data in the output ressource.

Parameters
datacoded packet information for the current stream
streamIndexrefers to the stream in output ressource
Returns
the wrapping status after wrapping
See also
EWrappingStatus

Implements avtranscoder::IOutputFile.

Definition at line 166 of file OutputFile.cpp.

References _formatContext, _frameCount, _outputStreams, _previousProcessedStreamDuration, avtranscoder::IOutputStream::eWrappingSuccess, avtranscoder::IOutputStream::eWrappingWaitingForData, avtranscoder::CodedData::getAVPacket(), avtranscoder::CodedData::getAVStream(), avtranscoder::FormatContext::getAVStream(), avtranscoder::CodedData::getData(), avtranscoder::CodedData::getSize(), LOG_DEBUG, and avtranscoder::FormatContext::writeFrame().

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

Field Documentation

std::vector<size_t> avtranscoder::OutputFile::_frameCount
private

Number of wrapped frames.

Definition at line 104 of file OutputFile.hpp.

Referenced by beginWrap(), and wrap().

std::vector<OutputStream*> avtranscoder::OutputFile::_outputStreams
private

Has ownership.

Definition at line 103 of file OutputFile.hpp.

Referenced by addAudioStream(), addDataStream(), addVideoStream(), beginWrap(), getStream(), wrap(), and ~OutputFile().

double avtranscoder::OutputFile::_previousProcessedStreamDuration
private

To manage process streams order.

Definition at line 106 of file OutputFile.hpp.

Referenced by wrap().

ProfileLoader::Profile avtranscoder::OutputFile::_profile
private

To setup specific wrapping options.

See also
setupWrapping
beginWrap

Definition at line 113 of file OutputFile.hpp.

Referenced by setupRemainingWrappingOptions(), and setupWrappingOptions().


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