- fully decoupled from linking with sevana libraris

This commit is contained in:
Dmytro Bogovych 2018-08-20 18:27:01 +03:00
parent 434fa71937
commit b690694e58
2 changed files with 0 additions and 232 deletions

View File

@ -29,11 +29,6 @@ extern std::string IntervalCacheDir;
#define LOG_SUBSYSTEM "Sevana"
#ifdef WIN32
# define popen _popen
# define pclose _pclose
#endif
#define PVQA_ECHO_DETECTOR_NAME "ECHO"
//#define PVQA_ECHO_DETECTOR_NAME "EchoM-00"
@ -67,192 +62,6 @@ static std::string execCommand(const std::string& cmd)
return result;
}
// ------------ PvqaUtility ------------
PvqaUtility::PvqaUtility()
{
}
PvqaUtility::~PvqaUtility()
{
}
void PvqaUtility::setPath(const std::string& path)
{
mPvqaPath = path;
}
std::string PvqaUtility::getPath() const
{
return mPvqaPath;
}
void PvqaUtility::setLicensePath(const std::string& path)
{
mLicensePath = path;
}
std::string PvqaUtility::getLicensePath() const
{
return mLicensePath;
}
void PvqaUtility::setConfigPath(const std::string& path)
{
mConfigPath = path;
}
std::string PvqaUtility::getConfigPath() const
{
return mConfigPath;
}
float PvqaUtility::process(const std::string& filepath, std::string& outputReport)
{
float result = 0.0f;
// Generate temporary filename to receive .csv file
char report_filename[L_tmpnam];
tmpnam(report_filename);
// Build command line
char cmdbuffer[1024];
sprintf(cmdbuffer, "\"%s\" \"%s\" analysis \"%s\" \"%s\" \"%s\" 0.799", mPvqaPath.c_str(), mLicensePath.c_str(),
report_filename, mConfigPath.c_str(), filepath.c_str());
try
{
std::string output = execCommand(cmdbuffer);
std::string line;
std::istringstream is(output);
std::string estimation;
while (std::getline(is, line))
{
std::string::size_type mosPosition = line.find("MOS = ");
if ( mosPosition != std::string::npos)
{
estimation = line.substr(mosPosition + 6);
estimation = StringHelper::trim(estimation);
}
}
if (!estimation.size())
throw std::runtime_error("Bad response from pvqa: " + output);
result = std::stof(estimation);
// Read intervals report file
std::ifstream t(report_filename);
std::string str((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
outputReport = str;
::remove(report_filename);
::remove(report_filename);
}
catch (std::exception& e)
{
std::cerr << e.what() << "\n";
}
return result;
}
// ---------------- AquaUtility -----------------
AquaUtility::AquaUtility()
{}
AquaUtility::~AquaUtility()
{}
void AquaUtility::setPath(const std::string& path)
{
mAquaPath = path;
}
std::string AquaUtility::getPath() const
{
return mAquaPath;
}
void AquaUtility::setLicensePath(const std::string& path)
{
mLicensePath = path;
}
std::string AquaUtility::getLicensePath() const
{
return mLicensePath;
}
void AquaUtility::setConfigLine(const std::string& line)
{
mConfigLine = line;
}
std::string AquaUtility::getConfigLine() const
{
return mConfigLine;
}
float AquaUtility::compare(const std::string& src_path, const std::string& dst_path, std::string& output_report)
{
float result = 0.0f;
// Generate temporary filename to receive .csv file
char spectrum_filename[L_tmpnam], report_filename[L_tmpnam];
tmpnam(spectrum_filename);
tmpnam(report_filename);
std::string config_line = mConfigLine;
StringHelper::replace(config_line, ":src_file", "\"" + src_path + "\"");
StringHelper::replace(config_line, ":tst_file", "\"" + dst_path + "\"");
StringHelper::replace(config_line, ":spectrum_file", spectrum_filename);
StringHelper::replace(config_line, ":report_file", report_filename);
StringHelper::replace(config_line, ":license_file", "\"" + mLicensePath + "\"");
// Build command line
char cmdbuffer[2048];
sprintf(cmdbuffer, "\"%s\" %s", mAquaPath.c_str(), config_line.c_str());
try
{
std::string output = execCommand(cmdbuffer);
std::string line;
std::istringstream is(output);
std::string estimation;
while (std::getline(is, line))
{
std::string::size_type mosPosition = line.find("MOS value ");
if ( mosPosition != std::string::npos)
{
estimation = line.substr(mosPosition + 6);
estimation = StringHelper::trim(estimation);
}
}
if (!estimation.size())
throw std::runtime_error("Bad response from pvqa: " + output);
result = std::stof(estimation);
// Read intervals report file
std::ifstream t(report_filename);
std::string str((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
output_report = str;
::remove(report_filename);
::remove(report_filename);
}
catch (std::exception& e)
{
std::cerr << e.what() << "\n";
}
return result;
}
// -------------- SevanaMosUtility --------------
void SevanaMosUtility::run(const std::string& pcmPath, const std::string& intervalPath,

View File

@ -30,47 +30,6 @@ enum class ReportType
Html
};
class PvqaUtility
{
public:
PvqaUtility();
~PvqaUtility();
void setPath(const std::string& path);
std::string getPath() const;
void setLicensePath(const std::string& path);
std::string getLicensePath() const;
void setConfigPath(const std::string& path);
std::string getConfigPath() const;
float process(const std::string& path, std::string& report);
private:
std::string mPvqaPath, mLicensePath, mConfigPath;
};
class AquaUtility
{
public:
AquaUtility();
~AquaUtility();
void setPath(const std::string& path);
std::string getPath() const;
void setLicensePath(const std::string& path);
std::string getLicensePath() const;
void setConfigLine(const std::string& line);
std::string getConfigLine() const;
float compare(const std::string& src, const std::string& dst, std::string& outputReport);
protected:
std::string mAquaPath, mLicensePath, mConfigLine;
};
#if defined(USE_PVQA_LIBRARY)
class SevanaMosUtility
{