Skip to content

StreamTranscoder: refactor how to get the current process case #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions src/AvTranscoder/transcoder/StreamTranscoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void StreamTranscoder::preProcessCodecLatency()
return;

// set a decoder to preload generated frames
if( isRewrapCase() )
if( getProcessCase() == eProcessCaseRewrap )
switchToGeneratorDecoder();

while( ( latency-- ) > 0 )
Expand All @@ -334,7 +334,7 @@ bool StreamTranscoder::processFrame()
{
LOG_INFO( "End of positive offset" )

if( isTranscodeCase() )
if( getProcessCase() == eProcessCaseTranscode )
switchToInputDecoder();
else
_currentDecoder = NULL;
Expand Down Expand Up @@ -362,7 +362,7 @@ bool StreamTranscoder::processFrame()
}
}

if( isRewrapCase() )
if( getProcessCase() == eProcessCaseRewrap )
return processRewrap();

return processTranscode( _subStreamIndex );
Expand Down Expand Up @@ -501,19 +501,14 @@ double StreamTranscoder::getDuration() const
return std::numeric_limits<double>::max();
}

bool StreamTranscoder::isTranscodeCase() const
StreamTranscoder::EProcessCase StreamTranscoder::getProcessCase() const
{
return _inputStream && _inputDecoder;
}

bool StreamTranscoder::isRewrapCase() const
{
return _inputStream && ! _inputDecoder;
}

bool StreamTranscoder::isGeneratorCase() const
{
return ! _inputStream;
if( _inputStream && _inputDecoder )
return eProcessCaseTranscode;
else if( _inputStream && ! _inputDecoder )
return eProcessCaseRewrap;
else
return eProcessCaseGenerator;
}

}
12 changes: 9 additions & 3 deletions src/AvTranscoder/transcoder/StreamTranscoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@ class AvExport StreamTranscoder
bool processRewrap();
bool processTranscode( const int subStreamIndex = -1 ); ///< By default transcode all channels

bool isTranscodeCase() const;
bool isRewrapCase() const;
bool isGeneratorCase() const;
//@{
// Get the current process case.
enum EProcessCase {
eProcessCaseTranscode,
eProcessCaseRewrap,
eProcessCaseGenerator
};
EProcessCase getProcessCase() const;
//@}

private:
IInputStream* _inputStream; ///< Input stream to read next packet (has link, no ownership)
Expand Down