Skip to content

Commit 04a4f68

Browse files
author
Clement Champetier
committed
ProgressListener: add IProgress class
* Base class of all possible Progress. * ProgressListener inherits this base class. * Add documentation. * Swig: add feature "director" to the base class.
1 parent e325ae9 commit 04a4f68

File tree

7 files changed

+38
-16
lines changed

7 files changed

+38
-16
lines changed

src/AvTranscoder/File/InputFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ InputFile::~InputFile()
6464
}
6565
}
6666

67-
InputFile& InputFile::analyse( ProgressListener& progress, const EAnalyseLevel level )
67+
InputFile& InputFile::analyse( IProgress& progress, const EAnalyseLevel level )
6868
{
6969
assert( _formatContext != NULL );
7070

@@ -134,7 +134,7 @@ InputFile& InputFile::analyse( ProgressListener& progress, const EAnalyseLevel l
134134
return *this;
135135
}
136136

137-
Properties InputFile::analyseFile( const std::string& filename, ProgressListener& progress, const EAnalyseLevel level )
137+
Properties InputFile::analyseFile( const std::string& filename, IProgress& progress, const EAnalyseLevel level )
138138
{
139139
InputFile file( filename );
140140
file.analyse( progress, level );

src/AvTranscoder/File/InputFile.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AvExport InputFile
5050
* call this function before getProperties().
5151
* @param progress callback to get analysis progression
5252
**/
53-
InputFile& analyse( ProgressListener& progress, const EAnalyseLevel level = eAnalyseLevelFull );
53+
InputFile& analyse( IProgress& progress, const EAnalyseLevel level = eAnalyseLevelFull );
5454

5555
/**
5656
* @brief Return media properties on the current InputFile.
@@ -67,7 +67,7 @@ class AvExport InputFile
6767
* @param progress callback to get analysis progression
6868
* @return structure of media metadatas
6969
**/
70-
static Properties analyseFile( const std::string& filename, ProgressListener& progress, const EAnalyseLevel level = eAnalyseLevelFull );
70+
static Properties analyseFile( const std::string& filename, IProgress& progress, const EAnalyseLevel level = eAnalyseLevelFull );
7171

7272
/**
7373
* @brief Get stream type: video, audio, subtitle, etc.

src/AvTranscoder/Metadatas/VideoStreamProperties.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void getGopProperties(
3333
AVCodecContext* codecContext,
3434
AVCodec* codec,
3535
const int videoStreamIndex,
36-
ProgressListener& progress
36+
IProgress& progress
3737
)
3838
{
3939
AVPacket pkt;
@@ -108,7 +108,7 @@ std::string makeTimecodeMpegToString( uint32_t tc25bit )
108108
VideoProperties videoStreamInfo(
109109
AVFormatContext* formatContext,
110110
const size_t videoStreamIndex,
111-
ProgressListener& progress,
111+
IProgress& progress,
112112
const InputFile::EAnalyseLevel level
113113
)
114114
{

src/AvTranscoder/ProgressListener.hpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,44 @@
77
namespace avtranscoder
88
{
99

10+
/**
11+
* @brief Indicate the state of a process.
12+
*/
1013
enum EJobStatus
1114
{
1215
eJobStatusContinue = 0,
1316
eJobStatusCancel
1417
};
1518

16-
class ProgressListener
19+
/**
20+
* @brief Base class of Progress.
21+
* Inherit this class to have your own way to manage a progress bar.
22+
* You can inherit this class in C++, but also in python / Java binding.
23+
*/
24+
class IProgress
1725
{
1826
public:
19-
ProgressListener()
20-
{}
27+
virtual ~IProgress() {};
28+
29+
/**
30+
* @brief Manage the progress.
31+
* @param processedDuration: what is processed
32+
* @param programDuration: what you need to process (the totality)
33+
* @return eJobStatusContinue if we continue the progress or eJobStatusCancel to stop it.
34+
*/
35+
virtual EJobStatus progress( const double processedDuration, const double programDuration ) = 0;
36+
};
2137

22-
virtual ~ProgressListener()
38+
/**
39+
* @brief Implementation of IProgress, to display a progress bar in console.
40+
*/
41+
class ProgressListener: public IProgress
42+
{
43+
public:
44+
~ProgressListener()
2345
{}
2446

25-
virtual EJobStatus progress( const double processedDuration, const double programDuration )
47+
EJobStatus progress( const double processedDuration, const double programDuration )
2648
{
2749
std::string progress( 80, '-' );
2850
std::string done( 80.0 * processedDuration / programDuration, '#' );

src/AvTranscoder/ProgressListener.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <AvTranscoder/ProgressListener.hpp>
66
%}
77

8-
/* turn on director wrapping ProgressListener */
9-
%feature("director") ProgressListener;
8+
/* turn on director wrapping for IProgress */
9+
%feature("director") IProgress;
1010

11-
%include <AvTranscoder/ProgressListener.hpp>
11+
%include <AvTranscoder/ProgressListener.hpp>

src/AvTranscoder/Transcoder/Transcoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ bool Transcoder::processFrame()
238238
return true;
239239
}
240240

241-
void Transcoder::process( ProgressListener& progress )
241+
void Transcoder::process( IProgress& progress )
242242
{
243243
size_t frame = 0;
244244

src/AvTranscoder/Transcoder/Transcoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Transcoder
111111
* @brief Process all the streams, and ended the process depending on the transcode politic.
112112
* @param progress
113113
*/
114-
void process( ProgressListener& progress );
114+
void process( IProgress& progress );
115115

116116
/**
117117
* @brief Set the transcodage politic.

0 commit comments

Comments
 (0)