Skip to content

Commit cfb3669

Browse files
author
Clement Champetier
committed
Transcoder: add private method getTotalDurationFromProcessMethod
In order to simplify process method.
1 parent 51cf36e commit cfb3669

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,7 @@ void Transcoder::process( IProgress& progress )
289289

290290
_outputFile.beginWrap();
291291

292-
double totalDuration = std::numeric_limits<double>::max();
293-
switch( _eProcessMethod )
294-
{
295-
case eProcessMethodShortest :
296-
totalDuration = getMinTotalDuration();
297-
break;
298-
case eProcessMethodLongest :
299-
totalDuration = getMaxTotalDuration();
300-
break;
301-
case eProcessMethodBasedOnStream :
302-
totalDuration = getStreamDuration( _mainStreamIndex );
303-
break;
304-
case eProcessMethodInfinity :
305-
totalDuration = std::numeric_limits<double>::max();
306-
break;
307-
}
292+
double totalDuration = getTotalDurationFromProcessMethod();
308293

309294
if( _verbose )
310295
av_log_set_level( AV_LOG_DEBUG );
@@ -529,4 +514,19 @@ double Transcoder::getMaxTotalDuration() const
529514
return maxTotalDuration;
530515
}
531516

517+
double Transcoder::getTotalDurationFromProcessMethod() const
518+
{
519+
switch( _eProcessMethod )
520+
{
521+
case eProcessMethodShortest :
522+
return getMinTotalDuration();
523+
case eProcessMethodLongest :
524+
return getMaxTotalDuration();
525+
case eProcessMethodBasedOnStream :
526+
return getStreamDuration( _mainStreamIndex );
527+
case eProcessMethodInfinity :
528+
return std::numeric_limits<double>::max();
529+
}
530+
}
531+
532532
}

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ class AvExport Transcoder
166166
*/
167167
double getMaxTotalDuration() const;
168168

169+
/**
170+
* @brief Get the duration of the output program
171+
* @note Depends on the streams, the process method, and the main stream index.
172+
*/
173+
double getTotalDurationFromProcessMethod() const;
174+
169175
private:
170176
OutputFile& _outputFile; ///< The output media file after process.
171177
std::vector< InputFile* > _inputFiles; ///< The list of input files which contain added streams.

0 commit comments

Comments
 (0)