24 : _inputStream(&inputStream)
30 , _currentDecoder(NULL)
31 , _outputEncoder(NULL)
36 , _needToSwitchToGenerator(false)
41 case AVMEDIA_TYPE_VIDEO:
68 catch(std::runtime_error& e)
76 case AVMEDIA_TYPE_AUDIO:
104 catch(std::runtime_error& e)
112 case AVMEDIA_TYPE_DATA:
125 const int subStreamIndex,
const float offset)
143 case AVMEDIA_TYPE_VIDEO:
150 inputVideo->setupDecoder();
177 case AVMEDIA_TYPE_AUDIO:
184 inputAudio->setupDecoder();
194 if(subStreamIndex > -1)
197 outputFrameDesc._nbChannels = 1;
206 if(subStreamIndex > -1)
222 throw std::runtime_error(
"unupported stream type");
231 , _outputStream(NULL)
232 , _sourceBuffer(NULL)
234 , _inputDecoder(NULL)
236 , _currentDecoder(NULL)
237 , _outputEncoder(NULL)
240 , _subStreamIndex(-1)
242 , _needToSwitchToGenerator(false)
302 throw std::runtime_error(
"unupported stream type");
321 std::stringstream msg;
322 msg <<
"No encoder found for input stream ";
327 msg <<
": will not preProcessCodecLatency.";
334 LOG_DEBUG(
"Latency of stream: " << latency)
336 if(!latency || latency < _outputEncoder->getCodec().getAVCodecContext().frame_number)
340 bool wasARewrapCase =
false;
344 wasARewrapCase =
true;
347 while((latency--) > 0)
359 std::string msg =
"Current process case of the stream is a ";
402 const bool endOfStream =
425 LOG_DEBUG(
"StreamTranscoder::processRewrap")
445 switch(wrappingStatus)
468 LOG_DEBUG(
"StreamTranscoder::processTranscode")
471 bool decodingStatus =
false;
472 if(subStreamIndex < 0)
505 switch(wrappingStatus)
521 LOG_INFO(
"Switch to generator decoder")
541 if(totalDuration < 0)
544 <<
"s. Set its duration to 0s.")
547 return totalDuration;
551 return std::numeric_limits<float>::max();
565 std::stringstream os;
567 <<
"s. It needs to switch to a generator during the process, but it cannot. "
568 <<
"No generator will be used for this stream.")
bool canSwitchToGenerator()
Returns if the stream has the ability to switch to a generator.
bool _needToSwitchToGenerator
Description to create a video frame.
AVMediaType getStreamType() const
AudioCodec & getAudioCodec()
This class describes decoded video data.
EProcessCase getProcessCase() const
IOutputfile is the interface to wrap and write medias. It can be overloaded to integrate custom wrapp...
IDecoder * _inputDecoder
Decoder of packets read from _inputStream (has ownership)
virtual EWrappingStatus wrap(const CodedData &data)=0
Wrap a packet of data.
void setupAudioEncoder(const AudioFrameDesc &frameDesc, const ProfileLoader::Profile &profile=ProfileLoader::Profile())
float getDuration() const
Get the total duration (in seconds), ie. duration of the stream and the offset applies.
void switchToGeneratorDecoder()
Frame * _sourceBuffer
Has ownership.
void setupVideoEncoder(const VideoFrameDesc &frameDesc, const ProfileLoader::Profile &profile=ProfileLoader::Profile())
EWrappingStatus
define wrapping result status
virtual IOutputStream & addVideoStream(const VideoCodec &videoCodec)
Add a video output stream.
void setOffset(const float offset)
IDecoder * _generator
Generator of audio or video packets (has ownership)
std::map< std::string, std::string > Profile
const std::string avProfileTypeAudio
const std::string avProfileTypeVideo
float getDuration() const
in seconds
virtual bool encodeFrame(const Frame &sourceFrame, CodedData &codedFrame)=0
Encode a new frame, and get coded frame.
bool processTranscode(const int subStreamIndex=-1)
By default transcode all channels.
VideoCodec & getVideoCodec()
IEncoder * _outputEncoder
Encoder of packets which will be wrapped by _outputStream (has ownership)
int _subStreamIndex
Index of channel that is processed from the input stream (<0 if no demultiplexing).
AudioFrameDesc getAudioFrameDesc() const
IDecoder * _currentDecoder
Link to _inputDecoder or _generator.
virtual float getStreamDuration() const =0
Description to create an audio frame. This corresponds to the number of samples, which corresponds to...
virtual IOutputStream & addDataStream(const DataCodec &dataCodec)
Add a data output stream.
bool processFrame()
process a single frame for the current stream
void switchToInputDecoder()
std::string getCodecName() const
void preProcessCodecLatency()
Pre-process codec latency.
Frame * _frameBuffer
Has ownership.
virtual IOutputStream & addAudioStream(const AudioCodec &audioCodec)
Add an audio output stream.
IOutputStream * _outputStream
Output stream to wrap next packet (has link, no ownership)
void setParameters(const ProfileLoader::Profile &profile)
Set the attributes from the given profile.
FilterGraph * _filterGraph
Filter graph (has ownership)
void needToSwitchToGenerator(const bool needToSwitch=true)
Set if the stream needs to switch to a generator when ended.
This class describes decoded audio data.
virtual ICodec & getCodec()=0
Get codec used for encoding.
void process(Frame &frame)
Pull filtered data from the filter graph, and put result to the given frame.
Virtual based class of properties for all types of stream.
IInputStream * _inputStream
Input stream to read next packet (has link, no ownership)
This class describes coded data.
const std::string avProfileCodec
float _offset
Offset, in seconds, at the beginning of the StreamTranscoder.
void setParameters(const ProfileLoader::Profile &profile)
Set the attributes from the given profile.
virtual bool decodeNextFrame(Frame &frameBuffer)=0
Decode next frame.
VideoFrameDesc getVideoFrameDesc() const
const std::string avProfileType
ITransform * _transform
Video or audio transform (has ownership)
StreamTranscoder(const StreamTranscoder &streamTranscoder)