AvTranscoder
0.9.4
C++APIforLibav/FFmpeg
|
#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... | |
IDecoder * | getCurrentDecoder () const |
Returns a pointer to the current decoder (from input file or from generator) More... | |
IEncoder * | getEncoder () const |
Returns a pointer to the encoder. More... | |
ITransform * | getTransform () const |
Returns a pointer to the object which transforms the decoded data. More... | |
FilterGraph * | getFilterGraph () const |
Returns a pointer to the object which manage filtering. More... | |
IInputStream * | getInputStream () const |
Returns a pointer to the stream which unwraps data. More... | |
IOutputStream & | getOutputStream () 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) | |
StreamTranscoder & | operator= (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 |
Definition at line 21 of file StreamTranscoder.hpp.
Enumerator | |
---|---|
eProcessCaseTranscode | |
eProcessCaseRewrap | |
eProcessCaseGenerator |
Definition at line 110 of file StreamTranscoder.hpp.
|
private |
avtranscoder::StreamTranscoder::StreamTranscoder | ( | IInputStream & | inputStream, |
IOutputFile & | outputFile, | ||
const float | offset = 0 |
||
) |
rewrap stream
Definition at line 23 of file StreamTranscoder.cpp.
References _filterGraph, _frameBuffer, _generator, _inputStream, _outputEncoder, _outputStream, _sourceBuffer, _transform, avtranscoder::IOutputFile::addAudioStream(), avtranscoder::IOutputFile::addDataStream(), avtranscoder::IOutputFile::addVideoStream(), avtranscoder::IInputStream::getAudioCodec(), avtranscoder::AudioCodec::getAudioFrameDesc(), avtranscoder::ICodec::getCodecName(), avtranscoder::IInputStream::getDataCodec(), avtranscoder::IInputStream::getProperties(), avtranscoder::IInputStream::getStreamIndex(), avtranscoder::StreamProperties::getStreamType(), avtranscoder::IInputStream::getVideoCodec(), avtranscoder::VideoCodec::getVideoFrameDesc(), LOG_WARN, setOffset(), avtranscoder::AudioEncoder::setupAudioEncoder(), and avtranscoder::VideoEncoder::setupVideoEncoder().
avtranscoder::StreamTranscoder::StreamTranscoder | ( | IInputStream & | inputStream, |
IOutputFile & | outputFile, | ||
const ProfileLoader::Profile & | profile, | ||
const int | subStreamIndex = -1 , |
||
const float | offset = 0 |
||
) |
transcode stream
Definition at line 124 of file StreamTranscoder.cpp.
References _currentDecoder, _filterGraph, _frameBuffer, _generator, _inputDecoder, _inputStream, avtranscoder::AudioFrameDesc::_nbChannels, _outputEncoder, _outputStream, _sourceBuffer, _transform, avtranscoder::IOutputFile::addAudioStream(), avtranscoder::IOutputFile::addVideoStream(), avtranscoder::constants::avProfileCodec, avtranscoder::AudioEncoder::getAudioCodec(), avtranscoder::IInputStream::getAudioCodec(), avtranscoder::AudioCodec::getAudioFrameDesc(), avtranscoder::IInputStream::getProperties(), avtranscoder::StreamProperties::getStreamType(), avtranscoder::VideoEncoder::getVideoCodec(), avtranscoder::IInputStream::getVideoCodec(), avtranscoder::VideoCodec::getVideoFrameDesc(), setOffset(), avtranscoder::AudioFrameDesc::setParameters(), avtranscoder::VideoFrameDesc::setParameters(), avtranscoder::AudioEncoder::setupAudioEncoder(), and avtranscoder::VideoEncoder::setupVideoEncoder().
avtranscoder::StreamTranscoder::StreamTranscoder | ( | const ICodec & | inputCodec, |
IOutputFile & | outputFile, | ||
const ProfileLoader::Profile & | profile | ||
) |
encode from a generated stream
Definition at line 229 of file StreamTranscoder.cpp.
References _currentDecoder, _filterGraph, _frameBuffer, _generator, _outputEncoder, _outputStream, _sourceBuffer, _transform, avtranscoder::IOutputFile::addAudioStream(), avtranscoder::IOutputFile::addVideoStream(), avtranscoder::constants::avProfileCodec, avtranscoder::constants::avProfileType, avtranscoder::constants::avProfileTypeAudio, avtranscoder::constants::avProfileTypeVideo, avtranscoder::AudioEncoder::getAudioCodec(), avtranscoder::AudioCodec::getAudioFrameDesc(), avtranscoder::VideoEncoder::getVideoCodec(), avtranscoder::VideoCodec::getVideoFrameDesc(), avtranscoder::AudioFrameDesc::setParameters(), avtranscoder::VideoFrameDesc::setParameters(), avtranscoder::AudioEncoder::setupAudioEncoder(), and avtranscoder::VideoEncoder::setupVideoEncoder().
avtranscoder::StreamTranscoder::~StreamTranscoder | ( | ) |
Definition at line 306 of file StreamTranscoder.cpp.
References _filterGraph, _frameBuffer, _generator, _inputDecoder, _outputEncoder, _sourceBuffer, and _transform.
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().
|
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.
Definition at line 535 of file StreamTranscoder.cpp.
References _inputStream, _offset, avtranscoder::StreamProperties::getDuration(), avtranscoder::IInputStream::getProperties(), and LOG_WARN.
Referenced by needToSwitchToGenerator().
|
inline |
Returns a pointer to the encoder.
Definition at line 77 of file StreamTranscoder.hpp.
|
inline |
Returns a pointer to the object which manage filtering.
Definition at line 83 of file StreamTranscoder.hpp.
|
inline |
Returns a pointer to the stream which unwraps data.
Definition at line 86 of file StreamTranscoder.hpp.
|
inline |
Returns a reference to the stream which wraps data.
Definition at line 88 of file StreamTranscoder.hpp.
StreamTranscoder::EProcessCase avtranscoder::StreamTranscoder::getProcessCase | ( | ) | const |
Definition at line 581 of file StreamTranscoder.cpp.
References _currentDecoder, _inputDecoder, _inputStream, eProcessCaseGenerator, eProcessCaseRewrap, and eProcessCaseTranscode.
Referenced by preProcessCodecLatency(), and processFrame().
|
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.
Definition at line 561 of file StreamTranscoder.cpp.
References _inputStream, _needToSwitchToGenerator, canSwitchToGenerator(), getDuration(), avtranscoder::IInputStream::getStreamIndex(), and LOG_WARN.
Referenced by setOffset().
|
private |
void avtranscoder::StreamTranscoder::preProcessCodecLatency | ( | ) |
Pre-process codec latency.
Definition at line 317 of file StreamTranscoder.cpp.
References _currentDecoder, _inputStream, _outputEncoder, eProcessCaseGenerator, eProcessCaseRewrap, avtranscoder::IEncoder::getCodec(), avtranscoder::ICodec::getLatency(), getProcessCase(), avtranscoder::IInputStream::getStreamIndex(), LOG_DEBUG, LOG_WARN, processFrame(), and switchToGeneratorDecoder().
bool avtranscoder::StreamTranscoder::processFrame | ( | ) |
process a single frame for the current stream
Definition at line 356 of file StreamTranscoder.cpp.
References _currentDecoder, _generator, _inputStream, _offset, _outputStream, _subStreamIndex, eProcessCaseGenerator, eProcessCaseRewrap, eProcessCaseTranscode, avtranscoder::StreamProperties::getDuration(), getProcessCase(), avtranscoder::IInputStream::getProperties(), avtranscoder::IOutputStream::getStreamDuration(), LOG_DEBUG, LOG_INFO, processRewrap(), processTranscode(), switchToGeneratorDecoder(), and switchToInputDecoder().
Referenced by preProcessCodecLatency(), processRewrap(), and processTranscode().
|
private |
Definition at line 419 of file StreamTranscoder.cpp.
References _currentDecoder, _generator, _inputDecoder, _inputStream, _needToSwitchToGenerator, _outputStream, avtranscoder::IOutputStream::eWrappingError, avtranscoder::IOutputStream::eWrappingSuccess, avtranscoder::IOutputStream::eWrappingWaitingForData, LOG_DEBUG, processFrame(), processTranscode(), avtranscoder::IInputStream::readNextPacket(), switchToGeneratorDecoder(), and avtranscoder::IOutputStream::wrap().
Referenced by processFrame().
|
private |
By default transcode all channels.
Definition at line 459 of file StreamTranscoder.cpp.
References _currentDecoder, _filterGraph, _frameBuffer, _needToSwitchToGenerator, _outputEncoder, _outputStream, _sourceBuffer, _transform, avtranscoder::ITransform::convert(), avtranscoder::IDecoder::decodeNextFrame(), avtranscoder::IEncoder::encodeFrame(), avtranscoder::IOutputStream::eWrappingError, avtranscoder::IOutputStream::eWrappingSuccess, avtranscoder::IOutputStream::eWrappingWaitingForData, avtranscoder::CodedData::getSize(), LOG_DEBUG, avtranscoder::FilterGraph::process(), processFrame(), switchToGeneratorDecoder(), and avtranscoder::IOutputStream::wrap().
Referenced by processFrame(), and processRewrap().
void avtranscoder::StreamTranscoder::setOffset | ( | const float | offset | ) |
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().
|
private |
Link to _inputDecoder or _generator.
Definition at line 132 of file StreamTranscoder.hpp.
Referenced by getProcessCase(), preProcessCodecLatency(), processFrame(), processRewrap(), processTranscode(), StreamTranscoder(), switchToGeneratorDecoder(), and switchToInputDecoder().
|
private |
Filter graph (has ownership)
Definition at line 137 of file StreamTranscoder.hpp.
Referenced by processTranscode(), StreamTranscoder(), and ~StreamTranscoder().
|
private |
Has ownership.
Definition at line 128 of file StreamTranscoder.hpp.
Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().
|
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().
|
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().
|
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().
|
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().
|
private |
Offset, in seconds, at the beginning of the StreamTranscoder.
Definition at line 141 of file StreamTranscoder.hpp.
Referenced by getDuration(), processFrame(), and setOffset().
|
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().
|
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().
|
private |
Has ownership.
Definition at line 127 of file StreamTranscoder.hpp.
Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().
|
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().
|
private |
Video or audio transform (has ownership)
Definition at line 135 of file StreamTranscoder.hpp.
Referenced by canSwitchToGenerator(), processTranscode(), StreamTranscoder(), and ~StreamTranscoder().