Skip to content

Commit 7cee053

Browse files
author
Clement Champetier
committed
IOutputFile: remove setup function
Call the instructions in constructor of OutputFile. SetProfile only one time in setProfile method.
1 parent ce1a378 commit 7cee053

File tree

4 files changed

+10
-46
lines changed

4 files changed

+10
-46
lines changed

src/AvTranscoder/file/IOutputFile.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ class AvExport IOutputFile
2525
public:
2626
virtual ~IOutputFile() {};
2727

28-
/**
29-
* @brief Initialize the wrapper
30-
**/
31-
virtual bool setup() = 0;
32-
3328
/**
3429
* @brief Add a video output stream
3530
* @note call setup() before adding any stream

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ OutputFile::OutputFile( const std::string& filename )
1515
, _filename( filename )
1616
, _previousProcessedStreamDuration( 0.0 )
1717
, _verbose( false )
18-
{}
18+
{
19+
_formatContext.setOutputFormat( _filename );
20+
_formatContext.openRessource( _filename, AVIO_FLAG_WRITE );
21+
}
1922

2023
OutputFile::~OutputFile()
2124
{
@@ -25,13 +28,6 @@ OutputFile::~OutputFile()
2528
}
2629
}
2730

28-
bool OutputFile::setup()
29-
{
30-
_formatContext.setOutputFormat( _filename );
31-
_formatContext.openRessource( _filename, AVIO_FLAG_WRITE );
32-
return true;
33-
}
34-
3531
IOutputStream& OutputFile::addVideoStream( const VideoCodec& videoDesc )
3632
{
3733
AVStream& stream = _formatContext.addAVStream( videoDesc.getAVCodec() );
@@ -157,32 +153,16 @@ void OutputFile::addMetadata( const std::string& key, const std::string& value )
157153

158154
void OutputFile::setProfile( const ProfileLoader::Profile& profile )
159155
{
156+
// check if output format indicated is valid with the filename extension
160157
if( ! matchFormat( profile.find( constants::avProfileFormat )->second, _filename ) )
161158
{
162159
throw std::runtime_error( "Invalid format according to the file extension." );
163160
}
164-
161+
162+
// set output format
165163
_formatContext.setOutputFormat( _filename, profile.find( constants::avProfileFormat )->second );
166-
167-
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
168-
{
169-
if( (*it).first == constants::avProfileIdentificator ||
170-
(*it).first == constants::avProfileIdentificatorHuman ||
171-
(*it).first == constants::avProfileType ||
172-
(*it).first == constants::avProfileFormat )
173-
continue;
174-
175-
try
176-
{
177-
Option& formatOption = _formatContext.getOption( (*it).first );
178-
formatOption.setString( (*it).second );
179-
}
180-
catch( std::exception& e )
181-
{}
182-
}
183-
184-
setup();
185-
164+
165+
// set format options
186166
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
187167
{
188168
if( (*it).first == constants::avProfileIdentificator ||
@@ -198,8 +178,7 @@ void OutputFile::setProfile( const ProfileLoader::Profile& profile )
198178
}
199179
catch( std::exception& e )
200180
{
201-
if( _verbose )
202-
std::cout << "[OutputFile] warning - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() << std::endl;
181+
std::cout << "[OutputFile] warning - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() << std::endl;
203182
}
204183
}
205184
}

src/AvTranscoder/file/OutputFile.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ class AvExport OutputFile : public IOutputFile
2525

2626
~OutputFile();
2727

28-
/**
29-
* @brief Initialize the OutputFile, create format context to wrap essences into output file.
30-
* @note call this before adding streams using addVideoStream() or addAudioStream()
31-
* @exception ios_base::failure launched if unable to guess format or open output
32-
**/
33-
bool setup();
34-
3528
IOutputStream& addVideoStream( const VideoCodec& videoDesc );
3629
IOutputStream& addAudioStream( const AudioCodec& audioDesc );
3730
IOutputStream& addDataStream( const DataCodec& dataDesc );

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Transcoder::Transcoder( IOutputFile& outputFile )
2222
, _outputDuration( 0 )
2323
, _verbose( false )
2424
{
25-
// Initialize the OutputFile
26-
_outputFile.setup();
27-
2825
// Print no output from ffmpeg
2926
av_log_set_level( AV_LOG_QUIET );
3027
}

0 commit comments

Comments
 (0)