Skip to content

Commit 4747e4a

Browse files
author
Clement Champetier
committed
ProfileLoader: getProfile returns a const profile
Update Transcoder: 'add' functions declare their profile parameter as const.
1 parent 1880556 commit 4747e4a

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/AvTranscoder/profile/ProfileLoader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
7171

7272
void ProfileLoader::loadProfile( const Profile& profile )
7373
{
74-
// check profile long name
74+
// check profile identificator
7575
if( ! profile.count( constants::avProfileIdentificator ) )
7676
{
7777
throw std::runtime_error( "Warning: A profile has no name. It will not be loaded." );
@@ -162,9 +162,9 @@ ProfileLoader::Profiles ProfileLoader::getAudioProfiles() const
162162
return profiles;
163163
}
164164

165-
ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& avProfileIdentificator )
165+
const ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& avProfileIdentificator ) const
166166
{
167-
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
167+
for( Profiles::const_iterator it = _profiles.begin(); it != _profiles.end(); ++it )
168168
{
169169
if( (*it).find( constants::avProfileIdentificator )->second == avProfileIdentificator )
170170
{

src/AvTranscoder/profile/ProfileLoader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AvExport ProfileLoader
5252
void loadProfile( const std::string& avProfileFileName );
5353

5454
/**
55-
* @brief Load the given profile
55+
* @brief Load the given profile
5656
* @exception throw std::runtime_error if the profile is invalid
5757
*/
5858
void loadProfile( const Profile& profile );
@@ -65,7 +65,7 @@ class AvExport ProfileLoader
6565
Profiles getVideoProfiles() const;
6666
Profiles getAudioProfiles() const;
6767

68-
Profile& getProfile( const std::string& avProfileIdentificator );
68+
const Profile& getProfile( const std::string& avProfileIdentificator ) const;
6969

7070
private:
7171
bool checkFormatProfile( const Profile& profileToCheck ) const;

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
4747
// Transcode
4848
else
4949
{
50-
ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
50+
const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
5151
add( filename, streamIndex, transcodeProfile, offset );
5252
}
5353
}
@@ -66,12 +66,12 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
6666
// Transcode
6767
else
6868
{
69-
ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
69+
const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
7070
add( filename, streamIndex, transcodeProfile, codec, offset );
7171
}
7272
}
7373

74-
void Transcoder::add( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, const double offset )
74+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const double offset )
7575
{
7676
// Check filename
7777
if( ! filename.length() )
@@ -80,7 +80,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, Pro
8080
addTranscodeStream( filename, streamIndex, -1, profile, offset );
8181
}
8282

83-
void Transcoder::add( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, ICodec& codec, const double offset )
83+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset )
8484
{
8585
// Generator
8686
if( ! filename.length() )
@@ -119,7 +119,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
119119
// Transcode
120120
else
121121
{
122-
ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
122+
const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
123123
add( filename, streamIndex, subStreamIndex, transcodeProfile, offset );
124124
}
125125
}
@@ -150,12 +150,12 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
150150
// Transcode
151151
else
152152
{
153-
ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
153+
const ProfileLoader::Profile& transcodeProfile = _profileLoader.getProfile( profileName );
154154
add( filename, streamIndex, subStreamIndex, transcodeProfile, codec, offset );
155155
}
156156
}
157157

158-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, const double offset )
158+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset )
159159
{
160160
// No subStream selected
161161
if( subStreamIndex < 0 )
@@ -171,7 +171,7 @@ void Transcoder::add( const std::string& filename, const size_t streamIndex, con
171171
addTranscodeStream( filename, streamIndex, subStreamIndex, profile, offset );
172172
}
173173

174-
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, ICodec& codec, const double offset )
174+
void Transcoder::add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset )
175175
{
176176
// No subStream selected
177177
if( subStreamIndex < 0 )
@@ -290,14 +290,14 @@ void Transcoder::addTranscodeStream( const std::string& filename, const size_t s
290290
ProfileLoader::Profile profile = getProfileFromFile( *referenceFile, streamIndex );
291291

292292
// override channels parameter to manage demultiplexing
293-
ProfileLoader::Profile::iterator it = profile.find( constants::avProfileChannel );
293+
ProfileLoader::Profile::iterator it = profile.find( constants::avProfileChannel );
294294
if( it != profile.end() )
295295
it->second = "1";
296296

297297
addTranscodeStream( filename, streamIndex, subStreamIndex, profile, offset );
298298
}
299299

300-
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, const double offset )
300+
void Transcoder::addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset )
301301
{
302302
// Add profile
303303
_profileLoader.loadProfile( profile );

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ class AvExport Transcoder
6666
* @brief Add a stream and set a custom profile
6767
* @note Profile will be updated, be sure to pass unique profile name.
6868
*/
69-
void add( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, const double offset = 0 );
69+
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
7070
/*
7171
* @note If filename is empty, add a generated stream.
7272
*/
73-
void add( const std::string& filename, const size_t streamIndex, ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
73+
void add( const std::string& filename, const size_t streamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
7474

7575
/**
7676
* @brief Add a stream and set a profile
@@ -89,11 +89,11 @@ class AvExport Transcoder
8989
* @note Profile will be updated, be sure to pass unique profile name.
9090
* @note If subStreamIndex is negative, no substream is selected it's the stream.
9191
*/
92-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, const double offset = 0 );
92+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
9393
/**
9494
* @note If filename is empty, add a generated stream.
9595
*/
96-
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
96+
void add( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, ICodec& codec, const double offset = 0 );
9797

9898
/**
9999
* @brief Add the stream
@@ -139,7 +139,7 @@ class AvExport Transcoder
139139
void addRewrapStream( const std::string& filename, const size_t streamIndex );
140140

141141
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const double offset );
142-
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, ProfileLoader::Profile& profile, const double offset = 0 );
142+
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const int subStreamIndex, const ProfileLoader::Profile& profile, const double offset = 0 );
143143

144144
void addDummyStream( const ProfileLoader::Profile& profile, const ICodec& codec );
145145

0 commit comments

Comments
 (0)