Skip to content

Commit 1880556

Browse files
author
Clement Champetier
committed
ProfileLoader: can check if already hasProfile
1 parent 4e84007 commit 1880556

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/AvTranscoder/profile/ProfileLoader.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ void ProfileLoader::loadProfile( const Profile& profile )
102102
throw std::runtime_error( "Warning: The profile " + profile.find( constants::avProfileIdentificator )->second + " is invalid. It will not be loaded." );
103103
}
104104

105+
bool ProfileLoader::hasProfile( const Profile& profile ) const
106+
{
107+
// check profile identificator
108+
if( ! profile.count( constants::avProfileIdentificator ) )
109+
{
110+
throw std::runtime_error( "Warning: A profile has no name. It will not be loaded." );
111+
}
112+
113+
for( Profiles::const_iterator it = _profiles.begin(); it != _profiles.end(); ++it )
114+
{
115+
if( (*it).at( constants::avProfileIdentificator ) == profile.at( constants::avProfileIdentificator ) )
116+
return true;
117+
}
118+
return false;
119+
}
120+
105121
const ProfileLoader::Profiles& ProfileLoader::getProfiles() const
106122
{
107123
return _profiles;

src/AvTranscoder/profile/ProfileLoader.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class AvExport ProfileLoader
5757
*/
5858
void loadProfile( const Profile& profile );
5959

60+
bool hasProfile( const Profile& profile ) const;
61+
6062
const Profiles& getProfiles() const;
6163

6264
Profiles getFormatProfiles() const;

0 commit comments

Comments
 (0)