Skip to content

Commit 0b4ef30

Browse files
author
Clement Champetier
committed
StreamTranscoder: refactor how to get the current process case
* Add EProcessCase enum. * Add getProcessCase method. * Remove 3 methods isTranscodeCase, isRewrapCase, isGeneratorCase. * Fix #180
1 parent 9f75cb9 commit 0b4ef30

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void StreamTranscoder::preProcessCodecLatency()
315315
return;
316316

317317
// set a decoder to preload generated frames
318-
if( isRewrapCase() )
318+
if( getProcessCase() == eProcessCaseRewrap )
319319
switchToGeneratorDecoder();
320320

321321
while( ( latency-- ) > 0 )
@@ -334,7 +334,7 @@ bool StreamTranscoder::processFrame()
334334
{
335335
LOG_INFO( "End of positive offset" )
336336

337-
if( isTranscodeCase() )
337+
if( getProcessCase() == eProcessCaseTranscode )
338338
switchToInputDecoder();
339339
else
340340
_currentDecoder = NULL;
@@ -362,7 +362,7 @@ bool StreamTranscoder::processFrame()
362362
}
363363
}
364364

365-
if( isRewrapCase() )
365+
if( getProcessCase() == eProcessCaseRewrap )
366366
return processRewrap();
367367

368368
return processTranscode( _subStreamIndex );
@@ -501,19 +501,14 @@ double StreamTranscoder::getDuration() const
501501
return std::numeric_limits<double>::max();
502502
}
503503

504-
bool StreamTranscoder::isTranscodeCase() const
504+
StreamTranscoder::EProcessCase StreamTranscoder::getProcessCase() const
505505
{
506-
return _inputStream && _inputDecoder;
507-
}
508-
509-
bool StreamTranscoder::isRewrapCase() const
510-
{
511-
return _inputStream && ! _inputDecoder;
512-
}
513-
514-
bool StreamTranscoder::isGeneratorCase() const
515-
{
516-
return ! _inputStream;
506+
if( _inputStream && _inputDecoder )
507+
return eProcessCaseTranscode;
508+
else if( _inputStream && ! _inputDecoder )
509+
return eProcessCaseRewrap;
510+
else
511+
return eProcessCaseGenerator;
517512
}
518513

519514
}

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ class AvExport StreamTranscoder
9595
bool processRewrap();
9696
bool processTranscode( const int subStreamIndex = -1 ); ///< By default transcode all channels
9797

98-
bool isTranscodeCase() const;
99-
bool isRewrapCase() const;
100-
bool isGeneratorCase() const;
98+
//@{
99+
// Get the current process case.
100+
enum EProcessCase {
101+
eProcessCaseTranscode,
102+
eProcessCaseRewrap,
103+
eProcessCaseGenerator
104+
};
105+
EProcessCase getProcessCase() const;
106+
//@}
101107

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

0 commit comments

Comments
 (0)