21 infile.open(avProfileFileName.c_str(), std::ifstream::in);
26 while(std::getline(infile, line))
28 std::vector<std::string> keyValue;
29 split(keyValue, line,
"=");
30 if(keyValue.size() == 2)
31 customProfile[keyValue.at(0)] = keyValue.at(1);
38 std::string realAvProfilesPath = avProfilesPath;
39 if(realAvProfilesPath.empty())
42 if(std::getenv(
"AVPROFILES"))
43 realAvProfilesPath = std::getenv(
"AVPROFILES");
46 realAvProfilesPath = AVTRANSCODER_DEFAULT_AVPROFILES;
49 std::vector<std::string> paths;
50 split(paths, realAvProfilesPath,
":");
51 for(std::vector<std::string>::iterator dirIt = paths.begin(); dirIt != paths.end(); ++dirIt)
53 std::vector<std::string> files;
57 for(std::vector<std::string>::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt)
59 const std::string absPath = (*dirIt) +
"/" + (*fileIt);
64 catch(
const std::exception& e)
77 throw std::runtime_error(
"Warning: A profile has no name. It will not be loaded.");
84 " has not type. It will not be loaded.");
104 " is invalid. It will not be loaded.");
112 throw std::runtime_error(
"Warning: A profile has no name. It will not be loaded.");
135 profiles.push_back(*it);
148 profiles.push_back(*it);
161 profiles.push_back(*it);
176 throw std::runtime_error(
"unable to find profile: " + avProfileIdentificator);
224 for(ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it)
225 os <<
"(" << it->first <<
", " << it->second <<
")" << std::endl;
void loadProfile(const std::string &avProfileFileName)
Load the profile defines in the given file.
std::vector< Profile > Profiles
ProfileLoader(const bool autoload=true)
static bool checkFormatProfile(const Profile &profileToCheck)
const std::string avProfileFormat
bool hasProfile(const Profile &profile) const
std::map< std::string, std::string > Profile
const std::string avProfileTypeAudio
const std::string avProfileIdentificator
const std::string avProfileIdentificatorHuman
const Profile & getProfile(const std::string &avProfileIdentificator) const
const std::string avProfileTypeVideo
const std::string avProfileTypeFormat
int getFilesInDir(const std::string &dir, std::vector< std::string > &files)
static bool checkAudioProfile(const Profile &profileToCheck)
const Profiles & getProfiles() const
const std::string avProfileCodec
Profiles getFormatProfiles() const
void loadProfiles(const std::string &avProfilesPath="")
Load profiles from files in avProfilesPath directory.
std::ostream & operator<<(std::ostream &flux, const InputFile &input)
const std::string avProfileType
Profiles getVideoProfiles() const
void split(std::vector< std::string > &splitString, const std::string &inputString, const std::string &splitChars)
Profiles getAudioProfiles() const
static bool checkVideoProfile(const Profile &profileToCheck)