@@ -34,54 +34,56 @@ Profile::Profile( bool autoload )
34
34
loadProfiles ();
35
35
}
36
36
37
- void Profile::loadProfiles ()
37
+ void Profile::loadProfile ( const std::string& avProfileFile )
38
+ {
39
+ std::ifstream infile;
40
+ infile.open ( avProfileFile.c_str (), std::ifstream::in );
41
+
42
+ Profile::ProfileDesc customProfile;
43
+
44
+ std::string line;
45
+ while ( std::getline ( infile, line ) )
46
+ {
47
+ std::vector< std::string > keyValue;
48
+ split ( keyValue, line, " =" );
49
+ if ( keyValue.size () == 2 )
50
+ customProfile[ keyValue.at ( 0 ) ] = keyValue.at ( 1 );
51
+ }
52
+ // check if profile contains required values
53
+ if (
54
+ customProfile.count ( avProfileIdentificator ) &&
55
+ customProfile.count ( avProfileIdentificatorHuman ) &&
56
+ customProfile.count ( avProfileType ) &&
57
+ ( customProfile.find ( avProfileType )->second == avProfileTypeVideo ||
58
+ customProfile.find ( avProfileType )->second == avProfileTypeAudio )
59
+ )
60
+ {
61
+ _profiles.push_back ( customProfile );
62
+ }
63
+ }
64
+
65
+ void Profile::loadProfiles ( const std::string& avProfilesPath )
38
66
{
39
67
loadXdCamHD422 ( _profiles );
40
68
loadDNxHD ( _profiles );
41
69
loadWave ( _profiles );
42
-
43
- if ( const char * envAvProfiles = std::getenv ( " AVPROFILES" ) )
70
+
71
+ std::string realAvProfilesPath = avProfilesPath;
72
+ if ( realAvProfilesPath.empty () )
73
+ realAvProfilesPath = std::getenv ( " AVPROFILES" );
74
+
75
+ std::vector< std::string > paths;
76
+ split ( paths, realAvProfilesPath, " :" );
77
+ for ( std::vector< std::string >::iterator dirIt = paths.begin (); dirIt != paths.end (); ++dirIt )
44
78
{
45
- std::vector< std::string > paths;
46
- split ( paths, envAvProfiles, " :" );
47
- for ( std::vector< std::string >::iterator dirIt = paths.begin (); dirIt != paths.end (); ++dirIt )
79
+ std::vector< std::string > files;
80
+ if ( getFilesInDir ( *dirIt, files ) != 0 )
81
+ continue ;
82
+
83
+ for ( std::vector< std::string >::iterator fileIt = files.begin (); fileIt != files.end (); ++fileIt )
48
84
{
49
- // std::cout << "search profile in path " << *dirIt << std::endl;
50
- std::vector< std::string > files;
51
- if ( getFilesInDir ( *dirIt, files ) != 0 )
52
- continue ;
53
-
54
- for ( std::vector< std::string >::iterator fileIt = files.begin (); fileIt != files.end (); ++fileIt )
55
- {
56
- if ( ( *fileIt == " ." ) || ( *fileIt == " .." ) )
57
- continue ;
58
-
59
- std::ifstream infile;
60
- infile.open ( ( ( *dirIt ) + " /" + ( *fileIt ) ).c_str (), std::ifstream::in );
61
-
62
- // std::cout << "file " << *dirIt << *fileIt << std::endl;
63
- Profile::ProfileDesc customProfile;
64
-
65
- std::string line;
66
- while ( std::getline ( infile, line ) )
67
- {
68
- std::vector< std::string > keyValue;
69
- split ( keyValue, line, " =" );
70
- if ( keyValue.size () == 2 )
71
- customProfile[ keyValue.at ( 0 ) ] = keyValue.at ( 1 );
72
- }
73
- // check if profile contains required values
74
- if (
75
- customProfile.count ( avProfileIdentificator ) &&
76
- customProfile.count ( avProfileIdentificatorHuman ) &&
77
- customProfile.count ( avProfileType ) &&
78
- ( customProfile.find ( avProfileType )->second == avProfileTypeVideo ||
79
- customProfile.find ( avProfileType )->second == avProfileTypeAudio )
80
- )
81
- {
82
- _profiles.push_back ( customProfile );
83
- }
84
- }
85
+ const std::string absPath = ( *dirIt ) + " /" + ( *fileIt );
86
+ loadProfile ( absPath );
85
87
}
86
88
}
87
89
}
0 commit comments