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

#include <StreamTranscoder.hpp>

Public Member Functions

 StreamTranscoder (IInputStream &inputStream, IOutputFile &outputFile, const float offset=0)
 rewrap stream More...
 
 StreamTranscoder (IInputStream &inputStream, IOutputFile &outputFile, const ProfileLoader::Profile &profile, const int subStreamIndex=-1, const float offset=0)
 transcode stream More...
 
 StreamTranscoder (const ICodec &inputCodec, IOutputFile &outputFile, const ProfileLoader::Profile &profile)
 encode from a generated stream More...
 
 ~StreamTranscoder ()
 
void preProcessCodecLatency ()
 Pre-process codec latency. More...
 
bool processFrame ()
 process a single frame for the current stream More...
 
float getDuration () const
 Get the total duration (in seconds), ie. duration of the stream and the offset applies. More...
 
IDecodergetCurrentDecoder () const
 Returns a pointer to the current decoder (from input file or from generator) More...
 
IEncodergetEncoder () const
 Returns a pointer to the encoder. More...
 
ITransformgetTransform () const
 Returns a pointer to the object which transforms the decoded data. More...
 
FilterGraphgetFilterGraph () const
 Returns a pointer to the object which manage filtering. More...
 
IInputStreamgetInputStream () const
 Returns a pointer to the stream which unwraps data. More...
 
IOutputStreamgetOutputStream () const
 Returns a reference to the stream which wraps data. More...
 
bool canSwitchToGenerator ()
 Returns if the stream has the ability to switch to a generator. More...
 
void needToSwitchToGenerator (const bool needToSwitch=true)
 Set if the stream needs to switch to a generator when ended. More...
 
void setOffset (const float offset)
 
void switchToGeneratorDecoder ()
 
void switchToInputDecoder ()
 

Private Member Functions

 StreamTranscoder (const StreamTranscoder &streamTranscoder)
 
StreamTranscoderoperator= (const StreamTranscoder &streamTranscoder)
 
bool processRewrap ()
 
bool processTranscode (const int subStreamIndex=-1)
 By default transcode all channels. More...
 

Private Attributes

IInputStream_inputStream
 Input stream to read next packet (has link, no ownership) More...
 
IOutputStream_outputStream
 Output stream to wrap next packet (has link, no ownership) More...
 
Frame_sourceBuffer
 Has ownership. More...
 
Frame_frameBuffer
 Has ownership. More...
 
IDecoder_inputDecoder
 Decoder of packets read from _inputStream (has ownership) More...
 
IDecoder_generator
 Generator of audio or video packets (has ownership) More...
 
IDecoder_currentDecoder
 Link to _inputDecoder or _generator. More...
 
IEncoder_outputEncoder
 Encoder of packets which will be wrapped by _outputStream (has ownership) More...
 
ITransform_transform
 Video or audio transform (has ownership) More...
 
FilterGraph_filterGraph
 Filter graph (has ownership) More...
 
int _subStreamIndex
 Index of channel that is processed from the input stream (<0 if no demultiplexing). More...
 
float _offset
 Offset, in seconds, at the beginning of the StreamTranscoder. More...
 
bool _needToSwitchToGenerator
 
enum  EProcessCase { eProcessCaseTranscode, eProcessCaseRewrap, eProcessCaseGenerator }
 
EProcessCase getProcessCase () const
 

Detailed Description

Definition at line 21 of file StreamTranscoder.hpp.

Member Enumeration Documentation

Enumerator
eProcessCaseTranscode 
eProcessCaseRewrap 
eProcessCaseGenerator 

Definition at line 110 of file StreamTranscoder.hpp.

Constructor & Destructor Documentation

avtranscoder::StreamTranscoder::StreamTranscoder ( const StreamTranscoder streamTranscoder)
private
avtranscoder::StreamTranscoder::~StreamTranscoder ( )

Member Function Documentation

bool avtranscoder::StreamTranscoder::canSwitchToGenerator ( )

Returns if the stream has the ability to switch to a generator.

Definition at line 554 of file StreamTranscoder.cpp.

References _frameBuffer, _generator, _outputEncoder, _sourceBuffer, and _transform.

Referenced by needToSwitchToGenerator().

IDecoder* avtranscoder::StreamTranscoder::getCurrentDecoder ( ) const
inline

Returns a pointer to the current decoder (from input file or from generator)

Definition at line 75 of file StreamTranscoder.hpp.

float avtranscoder::StreamTranscoder::getDuration ( ) const

Get the total duration (in seconds), ie. duration of the stream and the offset applies.

Note
if it's a generated stream, return limit of double.
if offset > duration of the stream, return 0

Definition at line 535 of file StreamTranscoder.cpp.

References _inputStream, _offset, avtranscoder::StreamProperties::getDuration(), avtranscoder::IInputStream::getProperties(), and LOG_WARN.

Referenced by needToSwitchToGenerator().

IEncoder* avtranscoder::StreamTranscoder::getEncoder ( ) const
inline

Returns a pointer to the encoder.

Definition at line 77 of file StreamTranscoder.hpp.

FilterGraph* avtranscoder::StreamTranscoder::getFilterGraph ( ) const
inline

Returns a pointer to the object which manage filtering.

Definition at line 83 of file StreamTranscoder.hpp.

IInputStream* avtranscoder::StreamTranscoder::getInputStream ( ) const
inline

Returns a pointer to the stream which unwraps data.

Definition at line 86 of file StreamTranscoder.hpp.

IOutputStream& avtranscoder::StreamTranscoder::getOutputStream ( ) const
inline

Returns a reference to the stream which wraps data.

Definition at line 88 of file StreamTranscoder.hpp.

StreamTranscoder::EProcessCase avtranscoder::StreamTranscoder::getProcessCase ( ) const
ITransform* avtranscoder::StreamTranscoder::getTransform ( ) const
inline

Returns a pointer to the object which transforms the decoded data.

Definition at line 80 of file StreamTranscoder.hpp.

void avtranscoder::StreamTranscoder::needToSwitchToGenerator ( const bool  needToSwitch = true)

Set if the stream needs to switch to a generator when ended.

Note
Throws a runtime_error exception if the stream cannot switch to a generator
See also
canSwitchToGenerator

Definition at line 561 of file StreamTranscoder.cpp.

References _inputStream, _needToSwitchToGenerator, canSwitchToGenerator(), getDuration(), avtranscoder::IInputStream::getStreamIndex(), and LOG_WARN.

Referenced by setOffset().

StreamTranscoder& avtranscoder::StreamTranscoder::operator= ( const StreamTranscoder streamTranscoder)
private
void avtranscoder::StreamTranscoder::preProcessCodecLatency ( )
void avtranscoder::StreamTranscoder::setOffset ( const float  offset)
Note
Throws a runtime_error exception if it's a positive offset and the stream cannot switch to a generator
See also
needToSwitchToGenerator

Definition at line 574 of file StreamTranscoder.cpp.

References _offset, and needToSwitchToGenerator().

Referenced by StreamTranscoder().

void avtranscoder::StreamTranscoder::switchToGeneratorDecoder ( )

Switch decoder

Definition at line 519 of file StreamTranscoder.cpp.

References _currentDecoder, _generator, and LOG_INFO.

Referenced by preProcessCodecLatency(), processFrame(), processRewrap(), and processTranscode().

void avtranscoder::StreamTranscoder::switchToInputDecoder ( )

Definition at line 527 of file StreamTranscoder.cpp.

References _currentDecoder, _inputDecoder, and LOG_INFO.

Referenced by processFrame().

Field Documentation

IDecoder* avtranscoder::StreamTranscoder::_currentDecoder
private
FilterGraph* avtranscoder::StreamTranscoder::_filterGraph
private

Filter graph (has ownership)

Definition at line 137 of file StreamTranscoder.hpp.

Referenced by processTranscode(), StreamTranscoder(), and ~StreamTranscoder().

Frame* avtranscoder::StreamTranscoder::_frameBuffer
private

Has ownership.

Definition at line 128 of file StreamTranscoder.hpp.

Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().

IDecoder* avtranscoder::StreamTranscoder::_generator
private

Generator of audio or video packets (has ownership)

Definition at line 131 of file StreamTranscoder.hpp.

Referenced by canSwitchToGenerator(), processFrame(), processRewrap(), StreamTranscoder(), switchToGeneratorDecoder(), and ~StreamTranscoder().

IDecoder* avtranscoder::StreamTranscoder::_inputDecoder
private

Decoder of packets read from _inputStream (has ownership)

Definition at line 130 of file StreamTranscoder.hpp.

Referenced by getProcessCase(), processRewrap(), StreamTranscoder(), switchToInputDecoder(), and ~StreamTranscoder().

IInputStream* avtranscoder::StreamTranscoder::_inputStream
private

Input stream to read next packet (has link, no ownership)

Definition at line 124 of file StreamTranscoder.hpp.

Referenced by getDuration(), getProcessCase(), needToSwitchToGenerator(), preProcessCodecLatency(), processFrame(), processRewrap(), and StreamTranscoder().

bool avtranscoder::StreamTranscoder::_needToSwitchToGenerator
private

Set if need to switch to a generator during the process (because, of other streams

Definition at line 143 of file StreamTranscoder.hpp.

Referenced by needToSwitchToGenerator(), processRewrap(), and processTranscode().

float avtranscoder::StreamTranscoder::_offset
private

Offset, in seconds, at the beginning of the StreamTranscoder.

Definition at line 141 of file StreamTranscoder.hpp.

Referenced by getDuration(), processFrame(), and setOffset().

IEncoder* avtranscoder::StreamTranscoder::_outputEncoder
private

Encoder of packets which will be wrapped by _outputStream (has ownership)

Definition at line 133 of file StreamTranscoder.hpp.

Referenced by canSwitchToGenerator(), preProcessCodecLatency(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().

IOutputStream* avtranscoder::StreamTranscoder::_outputStream
private

Output stream to wrap next packet (has link, no ownership)

Definition at line 125 of file StreamTranscoder.hpp.

Referenced by processFrame(), processRewrap(), processTranscode(), and StreamTranscoder().

Frame* avtranscoder::StreamTranscoder::_sourceBuffer
private

Has ownership.

Definition at line 127 of file StreamTranscoder.hpp.

Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().

int avtranscoder::StreamTranscoder::_subStreamIndex
private

Index of channel that is processed from the input stream (<0 if no demultiplexing).

Definition at line 139 of file StreamTranscoder.hpp.

Referenced by processFrame().

ITransform* avtranscoder::StreamTranscoder::_transform
private

Video or audio transform (has ownership)

Definition at line 135 of file StreamTranscoder.hpp.

Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().


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