Skip to content

Commit 7aa151f

Browse files
clean callback for java usage
1 parent 53140cd commit 7aa151f

File tree

4 files changed

+23
-37
lines changed

4 files changed

+23
-37
lines changed

app/genericProcessor/genericProcessor.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
3232
configFile.close();
3333
}
3434

35-
avtranscoder::EJobStatus callBackProgress( const double processedDuration, const double programDuration )
36-
{
37-
std::string progress( 80, '-' );
38-
std::string done( 80.0 * processedDuration / programDuration, '#' );
39-
progress.replace( 0, done.size(), done );
40-
41-
std::cout << std::setprecision(2) << std::fixed << "\r[" << progress << "] " << processedDuration << "/" << programDuration << std::flush;
42-
43-
// if( processedFrames >= 100 )
44-
// return avtranscoder::eJobStatusCancel;
45-
46-
return avtranscoder::eJobStatusContinue;
47-
}
48-
4935
int main( int argc, char** argv )
5036
{
5137
if( argc != 3 )
@@ -61,7 +47,7 @@ int main( int argc, char** argv )
6147
std::cout << "start ..." << std::endl;
6248

6349
std::string inputConfigFile( argv[1] );
64-
std::string outputFile( argv[2] );
50+
avtranscoder::OutputFile outputFile( argv[2] );
6551

6652
avtranscoder::Transcoder::StreamsDefinition streams;
6753

src/AvTranscoder/ProgressListener.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#ifndef _AV_TRANSCODER_PROGRESS_LISTENER_HPP_
22
#define _AV_TRANSCODER_PROGRESS_LISTENER_HPP_
33

4+
#include <iostream>
5+
#include <iomanip>
6+
47
namespace avtranscoder
58
{
69

@@ -21,7 +24,15 @@ class ProgressListener
2124

2225
virtual EJobStatus progress( const double processedDuration, const double programDuration )
2326
{
24-
std::cout << "c++ progress " << processedDuration << "/" << programDuration << std::endl;
27+
std::string progress( 80, '-' );
28+
std::string done( 80.0 * processedDuration / programDuration, '#' );
29+
progress.replace( 0, done.size(), done );
30+
31+
std::cout << std::setprecision(2) << std::fixed << "\r[" << progress << "] " << processedDuration << "/" << programDuration << std::flush;
32+
33+
// if( processedFrames >= 100 )
34+
// return avtranscoder::eJobStatusCancel;
35+
2536
return eJobStatusContinue;
2637
}
2738
};

src/AvTranscoder/Transcoder.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class Transcoder
1717
public:
1818
typedef std::vector< std::pair< std::string, size_t > > StreamsDefinition;
1919

20-
Transcoder( const std::string& filename );
21-
Transcoder( OutputFile* outputFile );
20+
Transcoder( OutputFile& outputFile );
2221

2322
~Transcoder();
2423

@@ -29,7 +28,7 @@ class Transcoder
2928
void process( ProgressListener& progress );
3029

3130
private:
32-
OutputFile* _outputFile;
31+
OutputFile& _outputFile;
3332
std::vector< InputStream > _inputStreams;
3433
};
3534

src/AvTranscoder/Transcoder.tcc

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,14 @@
33
namespace avtranscoder
44
{
55

6-
Transcoder::Transcoder( const std::string& filename )
7-
: _outputFile( NULL )
6+
Transcoder::Transcoder( OutputFile& outputFile )
7+
: _outputFile( outputFile )
88
{
9-
_outputFile = new OutputFile( filename );
10-
_outputFile->setup();
11-
}
12-
13-
Transcoder::Transcoder( OutputFile* outputFile )
14-
: _outputFile( NULL )
15-
{
16-
_outputFile = outputFile;
17-
_outputFile->setup();
9+
_outputFile.setup();
1810
}
1911

2012
Transcoder::~Transcoder()
2113
{
22-
delete _outputFile;
23-
_outputFile = NULL;
2414
}
2515

2616
void Transcoder::add( const std::string& filename, const size_t streamIndex )
@@ -32,13 +22,13 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex )
3222
case AVMEDIA_TYPE_VIDEO:
3323
{
3424
_inputStreams.push_back( avtranscoder::InputStream( filename, streamIndex ) );
35-
_outputFile->addVideoStream( _inputStreams.back().getVideoDesc() );
25+
_outputFile.addVideoStream( _inputStreams.back().getVideoDesc() );
3626
break;
3727
}
3828
case AVMEDIA_TYPE_AUDIO:
3929
{
4030
_inputStreams.push_back( avtranscoder::InputStream( filename, streamIndex ) );
41-
_outputFile->addAudioStream( _inputStreams.back().getAudioDesc() );
31+
_outputFile.addAudioStream( _inputStreams.back().getAudioDesc() );
4232
break;
4333
}
4434
case AVMEDIA_TYPE_DATA:
@@ -75,7 +65,7 @@ void Transcoder::process( ProgressListener& progress )
7565
dataStreams.push_back( dataStream );
7666
}
7767

78-
_outputFile->beginWrap();
68+
_outputFile.beginWrap();
7969

8070
bool continueProcess( true );
8171

@@ -111,13 +101,13 @@ void Transcoder::process( ProgressListener& progress )
111101

112102
for( size_t streamIndex = 0; streamIndex < _inputStreams.size(); ++streamIndex )
113103
{
114-
_outputFile->wrap( dataStreams.at( streamIndex ), streamIndex );
104+
_outputFile.wrap( dataStreams.at( streamIndex ), streamIndex );
115105
}
116106

117107
++frame;
118108
}
119109

120-
_outputFile->endWrap();
110+
_outputFile.endWrap();
121111

122112
}
123113

0 commit comments

Comments
 (0)