7
7
#include < AvTranscoder/Profiles/Wave.hpp>
8
8
9
9
#include < iostream>
10
+ #include < fstream>
10
11
#include < cstdlib>
12
+ #include < stdexcept>
11
13
12
14
namespace avtranscoder
13
15
{
@@ -30,7 +32,7 @@ void Profile::loadProfiles()
30
32
loadDNxHD ( _profiles );
31
33
loadWave ( _profiles );
32
34
33
- if ( const char * envAvProfiles = std::getenv (" AVPROFILES" ) )
35
+ if ( const char * envAvProfiles = std::getenv ( " AVPROFILES" ) )
34
36
{
35
37
std::vector< std::string > paths;
36
38
split ( paths, envAvProfiles, " :" );
@@ -46,11 +48,31 @@ void Profile::loadProfiles()
46
48
if ( ( *fileIt == " ." ) || ( *fileIt == " .." ) )
47
49
continue ;
48
50
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
+ }
54
76
}
55
77
}
56
78
}
@@ -90,6 +112,7 @@ Profile::ProfileDesc& Profile::getProfile( const std::string& searchProfile )
90
112
return (*it);
91
113
}
92
114
}
115
+ throw std::runtime_error ( " unable to find profile: " + searchProfile );
93
116
}
94
117
95
118
}
0 commit comments