@@ -31,18 +31,35 @@ void ProfileLoader::loadProfile( const std::string& avProfileFile )
31
31
if ( keyValue.size () == 2 )
32
32
customProfile[ keyValue.at ( 0 ) ] = keyValue.at ( 1 );
33
33
}
34
- // check if profile contains required values
35
- if (
36
- customProfile.count ( constants::avProfileIdentificator ) &&
37
- customProfile.count ( constants::avProfileIdentificatorHuman ) &&
38
- customProfile.count ( constants::avProfileType ) &&
39
- ( customProfile.find ( constants::avProfileType )->second == constants::avProfileTypeFormat ||
40
- customProfile.find ( constants::avProfileType )->second == constants::avProfileTypeVideo ||
41
- customProfile.find ( constants::avProfileType )->second == constants::avProfileTypeAudio )
42
- )
34
+
35
+ // check profile long name
36
+ if ( ! customProfile.count ( constants::avProfileIdentificator ) )
43
37
{
44
- _profiles.push_back ( customProfile );
38
+ std::cout << " Warning: A profile has no name. It will not be loaded." << std::endl;
39
+ return ;
40
+ }
41
+
42
+ // check profile type
43
+ if ( customProfile.count ( constants::avProfileType ) == 0 )
44
+ {
45
+ std::cout << " Warning: The profile " << customProfile.find ( constants::avProfileIdentificator )->second << " has not type. It will not be loaded." << std::endl;
46
+ return ;
45
47
}
48
+
49
+ // check complete profile
50
+ bool isValid = false ;
51
+ std::string type ( customProfile.find ( constants::avProfileType )->second );
52
+ if ( type == constants::avProfileTypeFormat )
53
+ isValid = checkFormatProfile ( customProfile );
54
+ else if ( type == constants::avProfileTypeVideo )
55
+ isValid = checkVideoProfile ( customProfile );
56
+ else if ( type == constants::avProfileTypeAudio )
57
+ isValid = checkAudioProfile ( customProfile );
58
+
59
+ if ( isValid )
60
+ _profiles.push_back ( customProfile );
61
+ else
62
+ std::cout << " Warning: The profile " << customProfile.find ( constants::avProfileIdentificator )->second << " is invalid. It will not be loaded." << std::endl;
46
63
}
47
64
48
65
void ProfileLoader::loadProfiles ( const std::string& avProfilesPath )
@@ -147,4 +164,52 @@ ProfileLoader::Profile& ProfileLoader::getProfile( const std::string& avProfileI
147
164
throw std::runtime_error ( " unable to find profile: " + avProfileIdentificator );
148
165
}
149
166
167
+
168
+ bool ProfileLoader::checkFormatProfile ( const Profile& profileToCheck )
169
+ {
170
+ bool isValid = true ;
171
+
172
+ if ( ! profileToCheck.count ( constants::avProfileIdentificator ) ||
173
+ ! profileToCheck.count ( constants::avProfileIdentificatorHuman ) ||
174
+ ! profileToCheck.count ( constants::avProfileType ) ||
175
+ ! profileToCheck.count ( constants::avProfileFormat ) )
176
+ {
177
+ isValid = false ;
178
+ }
179
+
180
+ return isValid;
181
+ }
182
+
183
+ bool ProfileLoader::checkVideoProfile ( const Profile& profileToCheck )
184
+ {
185
+ bool isValid = true ;
186
+
187
+ if ( ! profileToCheck.count ( constants::avProfileIdentificator ) ||
188
+ ! profileToCheck.count ( constants::avProfileIdentificatorHuman ) ||
189
+ ! profileToCheck.count ( constants::avProfileType ) ||
190
+ ! profileToCheck.count ( constants::avProfileCodec ) ||
191
+ ! profileToCheck.count ( constants::avProfileFrameRate ) )
192
+ {
193
+ isValid = false ;
194
+ }
195
+
196
+ return isValid;
197
+ }
198
+
199
+ bool ProfileLoader::checkAudioProfile ( const Profile& profileToCheck )
200
+ {
201
+ bool isValid = true ;
202
+
203
+ if ( ! profileToCheck.count ( constants::avProfileIdentificator ) ||
204
+ ! profileToCheck.count ( constants::avProfileIdentificatorHuman ) ||
205
+ ! profileToCheck.count ( constants::avProfileType ) ||
206
+ ! profileToCheck.count ( constants::avProfileCodec ) )
207
+ {
208
+ isValid = false ;
209
+ }
210
+
211
+ return isValid;
212
+ }
213
+
214
+
150
215
}
0 commit comments