Skip to content

Commit 9d296c7

Browse files
author
Clement Champetier
committed
Transcoder: change way to add Dummy
* 2 new "add(...)" functions, the only ones which can create dummy streams (from a profileDesc and an EssenceDesc). When the user tries to create a dummy stream with an empty file name and no EssenceDesc indicated, there is no add. * Update comments to fit to this new behavior.
1 parent d2bd6ed commit 9d296c7

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

src/AvTranscoder/Transcoder/Transcoder.cpp

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, Pro
5454
if( ! filename.length() )
5555
{
5656
if( _verbose )
57-
std::cout << "add encoding stream for dummy input" << std::endl;
58-
addDummyStream( profileDesc );
57+
std::cerr << "can't add a stream with no filename indicated" << std::endl;
5958
return;
6059
}
6160

@@ -64,6 +63,22 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, Pro
6463
addTranscodeStream( filename, streamIndex, profileDesc );
6564
}
6665

66+
void Transcoder::add( const std::string& filename, const size_t streamIndex, Profile::ProfileDesc& profileDesc, EssenceDesc& essenceDesc )
67+
{
68+
_profile.update( profileDesc );
69+
if( ! filename.length() )
70+
{
71+
if( _verbose )
72+
std::cout << "add dummy stream" << std::endl;
73+
addDummyStream( profileDesc, essenceDesc );
74+
return;
75+
}
76+
77+
if( _verbose )
78+
std::cout << "add transcoding stream" << std::endl;
79+
addTranscodeStream( filename, streamIndex, profileDesc );
80+
}
81+
6782
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName )
6883
{
6984
if( subStreamIndex < 0 )
@@ -87,18 +102,41 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
87102

88103
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc )
89104
{
105+
_profile.update( profileDesc );
106+
90107
if( subStreamIndex < 0 )
91108
{
92109
add( filename, streamIndex, profileDesc );
93110
return;
94111
}
112+
113+
if( ! filename.length() )
114+
{
115+
if( _verbose )
116+
std::cerr << "can't add a stream with no filename indicated" << std::endl;
117+
return;
118+
}
119+
120+
if( _verbose )
121+
std::cout << "add transcoding stream for substream " << subStreamIndex << std::endl;
122+
addTranscodeStream( filename, streamIndex, subStreamIndex, profileDesc );
123+
}
95124

125+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc, EssenceDesc& essenceDesc )
126+
{
96127
_profile.update( profileDesc );
128+
129+
if( subStreamIndex < 0 )
130+
{
131+
add( filename, streamIndex, profileDesc );
132+
return;
133+
}
134+
97135
if( ! filename.length() )
98136
{
99137
if( _verbose )
100-
std::cout << "add encoding stream for dummy input" << std::endl;
101-
addDummyStream( profileDesc );
138+
std::cout << "add dummy stream" << std::endl;
139+
addDummyStream( profileDesc, essenceDesc );
102140
return;
103141
}
104142

@@ -253,20 +291,24 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
253291
}
254292
}
255293

256-
void Transcoder::addDummyStream( Profile::ProfileDesc& profile )
294+
void Transcoder::addDummyStream( const Profile::ProfileDesc& profile, EssenceDesc& essenceDesc )
257295
{
258296
if( ! profile.count( Profile::avProfileType ) )
259297
throw std::runtime_error( "unable to found stream type (audio, video, etc.)" );
260298

261299
if( profile.find( Profile::avProfileType )->second == Profile::avProfileTypeAudio )
262300
{
263301
_dummyAudio.push_back( new DummyAudio() );
302+
_dummyAudio.back()->setAudioDesc( static_cast<AudioDesc>( essenceDesc ) );
303+
264304
_streamTranscoders.push_back( new StreamTranscoder( *_dummyAudio.back(), _outputFile, profile ) );
265305
}
266306

267307
if( profile.find( Profile::avProfileType )->second == Profile::avProfileTypeVideo )
268308
{
269309
_dummyVideo.push_back( new DummyVideo() );
310+
_dummyVideo.back()->setVideoDesc( static_cast<VideoDesc>( essenceDesc ) );
311+
270312
_streamTranscoders.push_back( new StreamTranscoder( *_dummyVideo.back(), _outputFile, profile ) );
271313
}
272314
}

src/AvTranscoder/Transcoder/Transcoder.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Transcoder
2727

2828
/**
2929
* @brief Add a stream and set a profile
30-
* @note If profile is empty, add a dummy stream.
30+
* @note If profileName is empty, rewrap.
3131
*/
3232
void add( const std::string& filename, const size_t streamIndex, const std::string& profileName = "" );
3333

@@ -36,11 +36,15 @@ class Transcoder
3636
* @note Profile will be updated, be sure to pass unique profile name.
3737
*/
3838
void add( const std::string& filename, const size_t streamIndex, Profile::ProfileDesc& profileDesc );
39-
39+
/*
40+
* @note If filename is empty, add a dummy stream.
41+
*/
42+
void add( const std::string& filename, const size_t streamIndex, Profile::ProfileDesc& profileDesc, EssenceDesc& essenceDesc );
43+
4044
/**
4145
* @brief Add a stream and set a profile
42-
* @note If profile is empty, add a dummy stream.
4346
* @note If subStreamIndex is negative, no substream a selected it's the stream.
47+
* @note If profileName is empty, rewrap.
4448
*/
4549
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const std::string& profileName = "" );
4650

@@ -50,6 +54,10 @@ class Transcoder
5054
* @note If subStreamIndex is negative, no substream a selected it's the stream.
5155
*/
5256
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc );
57+
/**
58+
* @note If filename is empty, add a dummy stream.
59+
*/
60+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, Profile::ProfileDesc& profileDesc, EssenceDesc& essenceDesc );
5361

5462
void add( StreamTranscoder& stream );
5563

@@ -67,7 +75,7 @@ class Transcoder
6775

6876
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const size_t subStreamIndex, Profile::ProfileDesc& profile );
6977

70-
void addDummyStream( Profile::ProfileDesc& profile );
78+
void addDummyStream( const Profile::ProfileDesc& profile, EssenceDesc& essenceDesc );
7179

7280
InputFile* addInputFile( const std::string& filename, const size_t streamIndex );
7381

0 commit comments

Comments
 (0)