Skip to content

Commit 5072848

Browse files
loading local profiles using AVPROFILES for detection
1 parent a7aa7a5 commit 5072848

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/AvTranscoder/Profile.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <AvTranscoder/Profiles/Wave.hpp>
88

99
#include <iostream>
10+
#include <fstream>
1011
#include <cstdlib>
12+
#include <stdexcept>
1113

1214
namespace avtranscoder
1315
{
@@ -30,7 +32,7 @@ void Profile::loadProfiles()
3032
loadDNxHD( _profiles );
3133
loadWave( _profiles );
3234

33-
if( const char* envAvProfiles = std::getenv("AVPROFILES") )
35+
if( const char* envAvProfiles = std::getenv( "AVPROFILES" ) )
3436
{
3537
std::vector< std::string > paths;
3638
split( paths, envAvProfiles, ":" );
@@ -46,11 +48,31 @@ void Profile::loadProfiles()
4648
if( ( *fileIt == "." ) || ( *fileIt == ".." ) )
4749
continue;
4850

49-
std::ifstream ifs;
50-
51-
ifs.open( ( *dirIt ) + ( *fileIt ), std::ifstream::in );
52-
53-
std::cout << "file " << *dirIt << *fileIt << std::endl;
51+
std::ifstream infile;
52+
infile.open( ( ( *dirIt ) + "/" + ( *fileIt ) ).c_str(), std::ifstream::in );
53+
54+
// std::cout << "file " << *dirIt << *fileIt << std::endl;
55+
Profile::ProfileDesc customProfile;
56+
57+
std::string line;
58+
while( std::getline( infile, line ) )
59+
{
60+
std::vector< std::string > keyValue;
61+
split( keyValue, line, "=" );
62+
if( keyValue.size() == 2 )
63+
customProfile[ keyValue.at( 0 ) ] = keyValue.at( 1 );
64+
}
65+
// check if profile contains required values
66+
if(
67+
customProfile.count( avProfileIdentificator ) &&
68+
customProfile.count( avProfileIdentificatorHuman ) &&
69+
customProfile.count( avProfileType ) &&
70+
( customProfile.find( avProfileType )->second == avProfileTypeVideo ||
71+
customProfile.find( avProfileType )->second == avProfileTypeAudio )
72+
)
73+
{
74+
_profiles.push_back( customProfile );
75+
}
5476
}
5577
}
5678
}
@@ -90,6 +112,7 @@ Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
90112
return (*it);
91113
}
92114
}
115+
throw std::runtime_error( "unable to find profile: " + searchProfile );
93116
}
94117

95118
}

src/AvTranscoder/Profile.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class Profile
3535
ProfileDesc& getProfile( const std::string& searchProfile );
3636

3737
private:
38-
3938
ProfilesDesc _profiles;
4039
};
4140

0 commit comments

Comments
 (0)