Skip to content

Commit a63de78

Browse files
committed
Windows: move Profile static members to constants namespace
1 parent 4092ed0 commit a63de78

File tree

16 files changed

+144
-186
lines changed

16 files changed

+144
-186
lines changed

src/AvTranscoder/Profile.cpp

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@
1616
namespace avtranscoder
1717
{
1818

19-
const std::string Profile::avProfileIdentificator( "avProfile" );
20-
const std::string Profile::avProfileIdentificatorHuman( "avProfileLong" );
21-
const std::string Profile::avProfileType( "avProfileType" );
22-
const std::string Profile::avProfileTypeFormat( "avProfileTypeFormat" );
23-
const std::string Profile::avProfileTypeVideo( "avProfileTypeVideo" );
24-
const std::string Profile::avProfileTypeAudio( "avProfileTypeAudio" );
25-
const std::string Profile::avProfileFormat( "format" );
26-
const std::string Profile::avProfileCodec( "codec" );
27-
const std::string Profile::avProfilePixelFormat( "pix_fmt" );
28-
const std::string Profile::avProfileSampleFormat( "sample_fmt" );
29-
const std::string Profile::avProfileFrameRate( "r" );
30-
const std::string Profile::avProfileSampleRate( "ar" );
31-
const std::string Profile::avProfileChannel( "ac" );
32-
3319
Profile::Profile( bool autoload )
3420
{
3521
if( autoload )
@@ -53,11 +39,11 @@ void Profile::loadProfile( const std::string& avProfileFile )
5339
}
5440
// check if profile contains required values
5541
if(
56-
customProfile.count( avProfileIdentificator ) &&
57-
customProfile.count( avProfileIdentificatorHuman ) &&
58-
customProfile.count( avProfileType ) &&
59-
( customProfile.find( avProfileType )->second == avProfileTypeVideo ||
60-
customProfile.find( avProfileType )->second == avProfileTypeAudio )
42+
customProfile.count( constants::avProfileIdentificator ) &&
43+
customProfile.count( constants::avProfileIdentificatorHuman ) &&
44+
customProfile.count( constants::avProfileType ) &&
45+
( customProfile.find( constants::avProfileType )->second == constants::avProfileTypeVideo ||
46+
customProfile.find( constants::avProfileType )->second == constants::avProfileTypeAudio )
6147
)
6248
{
6349
_profiles.push_back( customProfile );
@@ -99,11 +85,11 @@ void Profile::loadProfiles( const std::string& avProfilesPath )
9985

10086
void Profile::update( const ProfileDesc& profile )
10187
{
102-
std::string profileId( profile.find( avProfileIdentificator )->second );
88+
std::string profileId( profile.find( constants::avProfileIdentificator )->second );
10389
size_t profileIndex = 0;
10490
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
10591
{
106-
if( (*it).find( avProfileIdentificator )->second == profileId )
92+
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
10793
{
10894
_profiles.at( profileIndex ) = profile;
10995
return;
@@ -125,7 +111,7 @@ Profile::ProfilesDesc Profile::getFormatProfiles()
125111

126112
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
127113
{
128-
if( (*it).find( avProfileType )->second == avProfileTypeFormat )
114+
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeFormat )
129115
profiles.push_back( *it );
130116
}
131117

@@ -138,7 +124,7 @@ Profile::ProfilesDesc Profile::getVideoProfiles()
138124

139125
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
140126
{
141-
if( (*it).find( avProfileType )->second == avProfileTypeVideo )
127+
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeVideo )
142128
profiles.push_back( *it );
143129
}
144130

@@ -151,7 +137,7 @@ Profile::ProfilesDesc Profile::getAudioProfiles()
151137

152138
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
153139
{
154-
if( (*it).find( avProfileType )->second == avProfileTypeAudio )
140+
if( (*it).find( constants::avProfileType )->second == constants::avProfileTypeAudio )
155141
profiles.push_back( *it );
156142
}
157143

@@ -162,26 +148,12 @@ Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
162148
{
163149
for( ProfilesDesc::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
164150
{
165-
if( (*it).find( avProfileIdentificator )->second == searchProfile )
151+
if( (*it).find( constants::avProfileIdentificator )->second == searchProfile )
166152
{
167153
return (*it);
168154
}
169155
}
170156
throw std::runtime_error( "unable to find profile: " + searchProfile );
171157
}
172158

173-
const std::string & Profile::getAvProfileIdentificatorKey() { return avProfileIdentificator; };
174-
const std::string & Profile::getAvProfileIdentificatorHumanKey() { return avProfileIdentificatorHuman; };
175-
const std::string & Profile::getAvProfileTypeKey() { return avProfileType; };
176-
const std::string & Profile::getAvProfileTypeFormatKey() { return avProfileTypeFormat; };
177-
const std::string & Profile::getAvProfileTypeVideoKey() { return avProfileTypeVideo; };
178-
const std::string & Profile::getAvProfileTypeAudioKey() { return avProfileTypeAudio; };
179-
const std::string & Profile::getAvProfileFormatKey() { return avProfileFormat; };
180-
const std::string & Profile::getAvProfileCodecKey() { return avProfileCodec; };
181-
const std::string & Profile::getAvProfilePixelFormatKey() { return avProfilePixelFormat; };
182-
const std::string & Profile::getAvProfileSampleFormatKey() { return avProfileSampleFormat; };
183-
const std::string & Profile::getAvProfileFrameRateKey() { return avProfileFrameRate; };
184-
const std::string & Profile::getAvProfileSampleRateKey() { return avProfileSampleRate; };
185-
const std::string & Profile::getAvProfileChannelKey() { return avProfileChannel; };
186-
187159
}

src/AvTranscoder/Profile.hpp

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111
namespace avtranscoder
1212
{
1313

14+
namespace constants
15+
{
16+
const std::string avProfileIdentificator = "avProfile";
17+
const std::string avProfileIdentificatorHuman = "avProfileLong";
18+
const std::string avProfileType = "avProfileType";
19+
const std::string avProfileTypeFormat = "avProfileTypeFormat";
20+
const std::string avProfileTypeVideo = "avProfileTypeVideo";
21+
const std::string avProfileTypeAudio = "avProfileTypeAudio";
22+
const std::string avProfileFormat = "format";
23+
const std::string avProfileCodec = "codec";
24+
const std::string avProfilePixelFormat = "pix_fmt";
25+
const std::string avProfileSampleFormat = "sample_fmt";
26+
const std::string avProfileFrameRate = "r";
27+
const std::string avProfileSampleRate = "ar";
28+
const std::string avProfileChannel = "ac";
29+
}
30+
1431
class AvExport Profile
1532
{
1633
public:
@@ -37,40 +54,9 @@ class AvExport Profile
3754

3855
ProfileDesc& getProfile( const std::string& searchProfile );
3956

40-
static const std::string & getAvProfileIdentificatorKey();
41-
static const std::string & getAvProfileIdentificatorHumanKey();
42-
static const std::string & getAvProfileTypeKey();
43-
static const std::string & getAvProfileTypeFormatKey();
44-
static const std::string & getAvProfileTypeVideoKey();
45-
static const std::string & getAvProfileTypeAudioKey();
46-
static const std::string & getAvProfileFormatKey();
47-
static const std::string & getAvProfileCodecKey();
48-
static const std::string & getAvProfilePixelFormatKey();
49-
static const std::string & getAvProfileSampleFormatKey();
50-
static const std::string & getAvProfileFrameRateKey();
51-
static const std::string & getAvProfileSampleRateKey();
52-
static const std::string & getAvProfileChannelKey();
53-
5457
private:
5558
ProfilesDesc _profiles;
5659

57-
#ifndef SWIG
58-
public:
59-
static const std::string avProfileIdentificator;
60-
static const std::string avProfileIdentificatorHuman;
61-
static const std::string avProfileType;
62-
static const std::string avProfileTypeFormat;
63-
static const std::string avProfileTypeVideo;
64-
static const std::string avProfileTypeAudio;
65-
static const std::string avProfileFormat;
66-
static const std::string avProfileCodec;
67-
static const std::string avProfilePixelFormat;
68-
static const std::string avProfileSampleFormat;
69-
static const std::string avProfileFrameRate;
70-
static const std::string avProfileSampleRate;
71-
static const std::string avProfileChannel;
72-
#endif
73-
7460
};
7561

7662

src/AvTranscoder/essenceStream/AvInputVideo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ void AvInputVideo::setProfile( const Profile::ProfileDesc& desc )
153153

154154
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
155155
{
156-
if( (*it).first == Profile::avProfileIdentificator ||
157-
(*it).first == Profile::avProfileIdentificatorHuman ||
158-
(*it).first == Profile::avProfileType )
156+
if( (*it).first == constants::avProfileIdentificator ||
157+
(*it).first == constants::avProfileIdentificatorHuman ||
158+
(*it).first == constants::avProfileType )
159159
continue;
160160

161161
try

src/AvTranscoder/essenceStream/AvOutputAudio.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,25 @@ bool AvOutputAudio::encodeFrame( DataStream& codedFrame )
174174

175175
void AvOutputAudio::setProfile( const Profile::ProfileDesc& desc, const AudioFrameDesc& frameDesc )
176176
{
177-
if( ! desc.count( Profile::avProfileCodec ) ||
178-
! desc.count( Profile::avProfileSampleFormat ) )
177+
if( ! desc.count( constants::avProfileCodec ) ||
178+
! desc.count( constants::avProfileSampleFormat ) )
179179
{
180-
throw std::runtime_error( "The profile " + desc.find( Profile::avProfileIdentificatorHuman )->second + " is invalid." );
180+
throw std::runtime_error( "The profile " + desc.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
181181
}
182182

183-
_codedDesc.setCodec( desc.find( Profile::avProfileCodec )->second );
183+
_codedDesc.setCodec( desc.find( constants::avProfileCodec )->second );
184184

185185
static_cast<AudioDesc>( _codedDesc ).setAudioParameters( frameDesc );
186186

187187
ParamSet paramSet( _codedDesc.getCodecContext() );
188188

189189
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
190190
{
191-
if( (*it).first == Profile::avProfileIdentificator ||
192-
(*it).first == Profile::avProfileIdentificatorHuman ||
193-
(*it).first == Profile::avProfileType ||
194-
(*it).first == Profile::avProfileCodec ||
195-
(*it).first == Profile::avProfileSampleFormat )
191+
if( (*it).first == constants::avProfileIdentificator ||
192+
(*it).first == constants::avProfileIdentificatorHuman ||
193+
(*it).first == constants::avProfileType ||
194+
(*it).first == constants::avProfileCodec ||
195+
(*it).first == constants::avProfileSampleFormat )
196196
continue;
197197

198198
try
@@ -209,11 +209,11 @@ void AvOutputAudio::setProfile( const Profile::ProfileDesc& desc, const AudioFra
209209

210210
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
211211
{
212-
if( (*it).first == Profile::avProfileIdentificator ||
213-
(*it).first == Profile::avProfileIdentificatorHuman ||
214-
(*it).first == Profile::avProfileType ||
215-
(*it).first == Profile::avProfileCodec ||
216-
(*it).first == Profile::avProfileSampleFormat )
212+
if( (*it).first == constants::avProfileIdentificator ||
213+
(*it).first == constants::avProfileIdentificatorHuman ||
214+
(*it).first == constants::avProfileType ||
215+
(*it).first == constants::avProfileCodec ||
216+
(*it).first == constants::avProfileSampleFormat )
217217
continue;
218218

219219
try

src/AvTranscoder/essenceStream/AvOutputVideo.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ bool AvOutputVideo::encodeFrame( DataStream& codedFrame )
175175

176176
void AvOutputVideo::setProfile( const Profile::ProfileDesc& desc, const avtranscoder::VideoFrameDesc& frameDesc )
177177
{
178-
if( ! desc.count( Profile::avProfileCodec ) ||
179-
! desc.count( Profile::avProfilePixelFormat ) ||
180-
! desc.count( Profile::avProfileFrameRate ) )
178+
if( ! desc.count( constants::avProfileCodec ) ||
179+
! desc.count( constants::avProfilePixelFormat ) ||
180+
! desc.count( constants::avProfileFrameRate ) )
181181
{
182-
throw std::runtime_error( "The profile " + desc.find( Profile::avProfileIdentificatorHuman )->second + " is invalid." );
182+
throw std::runtime_error( "The profile " + desc.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
183183
}
184184

185-
_codedDesc.setCodec( desc.find( Profile::avProfileCodec )->second );
185+
_codedDesc.setCodec( desc.find( constants::avProfileCodec )->second );
186186

187-
const size_t frameRate = std::strtoul( desc.find( Profile::avProfileFrameRate )->second.c_str(), NULL, 0 );
187+
const size_t frameRate = std::strtoul( desc.find( constants::avProfileFrameRate )->second.c_str(), NULL, 0 );
188188
static_cast<VideoDesc>( _codedDesc ).setTimeBase( 1, frameRate );
189189

190190
static_cast<VideoDesc>( _codedDesc ).setImageParameters( frameDesc );
@@ -193,12 +193,12 @@ void AvOutputVideo::setProfile( const Profile::ProfileDesc& desc, const avtransc
193193

194194
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
195195
{
196-
if( (*it).first == Profile::avProfileIdentificator ||
197-
(*it).first == Profile::avProfileIdentificatorHuman ||
198-
(*it).first == Profile::avProfileType ||
199-
(*it).first == Profile::avProfileCodec ||
200-
(*it).first == Profile::avProfilePixelFormat ||
201-
(*it).first == Profile::avProfileFrameRate )
196+
if( (*it).first == constants::avProfileIdentificator ||
197+
(*it).first == constants::avProfileIdentificatorHuman ||
198+
(*it).first == constants::avProfileType ||
199+
(*it).first == constants::avProfileCodec ||
200+
(*it).first == constants::avProfilePixelFormat ||
201+
(*it).first == constants::avProfileFrameRate )
202202
continue;
203203

204204
try
@@ -215,12 +215,12 @@ void AvOutputVideo::setProfile( const Profile::ProfileDesc& desc, const avtransc
215215

216216
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
217217
{
218-
if( (*it).first == Profile::avProfileIdentificator ||
219-
(*it).first == Profile::avProfileIdentificatorHuman ||
220-
(*it).first == Profile::avProfileType ||
221-
(*it).first == Profile::avProfileCodec ||
222-
(*it).first == Profile::avProfilePixelFormat ||
223-
(*it).first == Profile::avProfileFrameRate )
218+
if( (*it).first == constants::avProfileIdentificator ||
219+
(*it).first == constants::avProfileIdentificatorHuman ||
220+
(*it).first == constants::avProfileType ||
221+
(*it).first == constants::avProfileCodec ||
222+
(*it).first == constants::avProfilePixelFormat ||
223+
(*it).first == constants::avProfileFrameRate )
224224
continue;
225225

226226
try

src/AvTranscoder/essenceStructures/AudioFrame.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class AvExport AudioFrameDesc
3131

3232
void setParameters( const Profile::ProfileDesc& desc )
3333
{
34-
if( desc.find( Profile::getAvProfileSampleFormatKey() ) != desc.end() )
35-
setSampleFormat( desc.find( Profile::getAvProfileSampleFormatKey() )->second );
34+
if( desc.find( constants::avProfileSampleFormat ) != desc.end() )
35+
setSampleFormat( desc.find( constants::avProfileSampleFormat )->second );
3636
}
3737

3838
size_t getSampleRate() const { return _sampleRate; }

src/AvTranscoder/essenceStructures/VideoFrame.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class AvExport VideoFrameDesc
5151

5252
void setParameters( const Profile::ProfileDesc& desc )
5353
{
54-
if( desc.find( Profile::getAvProfilePixelFormatKey() ) != desc.end() )
55-
setPixel( Pixel( desc.find( Profile::getAvProfilePixelFormatKey() )->second.c_str() ) );
54+
if( desc.find( constants::avProfilePixelFormat ) != desc.end() )
55+
setPixel( Pixel( desc.find( constants::avProfilePixelFormat )->second.c_str() ) );
5656
}
5757

5858
size_t getWidth () const { return _width; }

src/AvTranscoder/file/InputFile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ void InputFile::setProfile( const Profile::ProfileDesc& desc )
219219

220220
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
221221
{
222-
if( (*it).first == Profile::avProfileIdentificator ||
223-
(*it).first == Profile::avProfileIdentificatorHuman ||
224-
(*it).first == Profile::avProfileType )
222+
if( (*it).first == constants::avProfileIdentificator ||
223+
(*it).first == constants::avProfileIdentificatorHuman ||
224+
(*it).first == constants::avProfileType )
225225
continue;
226226

227227
try

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,25 +225,25 @@ void OutputFile::addMetadata( const std::string& key, const std::string& value )
225225

226226
void OutputFile::setProfile( const Profile::ProfileDesc& desc )
227227
{
228-
if( ! desc.count( Profile::avProfileFormat ) )
228+
if( ! desc.count( constants::avProfileFormat ) )
229229
{
230-
throw std::runtime_error( "The profile " + desc.find( Profile::avProfileIdentificatorHuman )->second + " is invalid." );
230+
throw std::runtime_error( "The profile " + desc.find( constants::avProfileIdentificatorHuman )->second + " is invalid." );
231231
}
232232

233-
if( ! matchFormat( desc.find( Profile::avProfileFormat )->second, _filename ) )
233+
if( ! matchFormat( desc.find( constants::avProfileFormat )->second, _filename ) )
234234
{
235235
throw std::runtime_error( "Invalid format according to the file extension." );
236236
}
237-
_outputFormat = av_guess_format( desc.find( Profile::avProfileFormat )->second.c_str(), _filename.c_str(), NULL);
237+
_outputFormat = av_guess_format( desc.find( constants::avProfileFormat )->second.c_str(), _filename.c_str(), NULL);
238238

239239
ParamSet paramSet( _formatContext );
240240

241241
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
242242
{
243-
if( (*it).first == Profile::avProfileIdentificator ||
244-
(*it).first == Profile::avProfileIdentificatorHuman ||
245-
(*it).first == Profile::avProfileType ||
246-
(*it).first == Profile::avProfileFormat )
243+
if( (*it).first == constants::avProfileIdentificator ||
244+
(*it).first == constants::avProfileIdentificatorHuman ||
245+
(*it).first == constants::avProfileType ||
246+
(*it).first == constants::avProfileFormat )
247247
continue;
248248

249249
try
@@ -260,10 +260,10 @@ void OutputFile::setProfile( const Profile::ProfileDesc& desc )
260260

261261
for( Profile::ProfileDesc::const_iterator it = desc.begin(); it != desc.end(); ++it )
262262
{
263-
if( (*it).first == Profile::avProfileIdentificator ||
264-
(*it).first == Profile::avProfileIdentificatorHuman ||
265-
(*it).first == Profile::avProfileType ||
266-
(*it).first == Profile::avProfileFormat )
263+
if( (*it).first == constants::avProfileIdentificator ||
264+
(*it).first == constants::avProfileIdentificatorHuman ||
265+
(*it).first == constants::avProfileType ||
266+
(*it).first == constants::avProfileFormat )
267267
continue;
268268

269269
try

src/AvTranscoder/profile/Avi.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace avtranscoder
77
void loadAvi( Profile::ProfilesDesc& profiles )
88
{
99
Profile::ProfileDesc avi;
10-
avi[ Profile::avProfileIdentificator ] = "avi";
11-
avi[ Profile::avProfileIdentificatorHuman ] = "AVI (Audio Video Interleaved)";
12-
avi[ Profile::avProfileType ] = Profile::avProfileTypeFormat;
10+
avi[ constants::avProfileIdentificator ] = "avi";
11+
avi[ constants::avProfileIdentificatorHuman ] = "AVI (Audio Video Interleaved)";
12+
avi[ constants::avProfileType ] = constants::avProfileTypeFormat;
1313

14-
avi[ Profile::avProfileFormat ] = "avi";
14+
avi[ constants::avProfileFormat ] = "avi";
1515

1616
profiles.push_back( avi );
1717
}

0 commit comments

Comments
 (0)