- work on further AQuA integration - now spectrum information is here

This commit is contained in:
Dmytro Bogovych 2020-06-27 21:50:03 +03:00
parent cb037b5ae0
commit 49fbe2345f
1 changed files with 89 additions and 67 deletions

View File

@ -67,69 +67,69 @@ std::string AgentImpl::command(const std::string& command)
if (cmd == "config") if (cmd == "config")
processConfig(d, answer); processConfig(d, answer);
else else
if (cmd == "start") if (cmd == "start")
processStart(d, answer); processStart(d, answer);
else else
if (cmd == "stop") if (cmd == "stop")
processStop(d, answer); processStop(d, answer);
else else
if (cmd == "account_create") if (cmd == "account_create")
processCreateAccount(d, answer); processCreateAccount(d, answer);
else else
if (cmd == "account_start") if (cmd == "account_start")
processStartAccount(d, answer); processStartAccount(d, answer);
else else
if (cmd == "account_setuserinfo") if (cmd == "account_setuserinfo")
processSetUserInfoToAccount(d, answer); processSetUserInfoToAccount(d, answer);
else else
if (cmd == "session_create") if (cmd == "session_create")
processCreateSession(d, answer); processCreateSession(d, answer);
else else
if (cmd == "session_start") if (cmd == "session_start")
processStartSession(d, answer); processStartSession(d, answer);
else else
if (cmd == "session_stop") if (cmd == "session_stop")
processStopSession(d, answer); processStopSession(d, answer);
else else
if (cmd == "session_accept") if (cmd == "session_accept")
processAcceptSession(d, answer); processAcceptSession(d, answer);
else else
if (cmd == "session_destroy") if (cmd == "session_destroy")
processDestroySession(d, answer); processDestroySession(d, answer);
else else
if (cmd == "session_use_stream") if (cmd == "session_use_stream")
processUseStreamForSession(d, answer); processUseStreamForSession(d, answer);
else else
if (cmd == "wait_for_event") if (cmd == "wait_for_event")
processWaitForEvent(d, answer); processWaitForEvent(d, answer);
else else
if (cmd == "session_get_media_stats") if (cmd == "session_get_media_stats")
processGetMediaStats(d, answer); processGetMediaStats(d, answer);
else else
if (cmd == "agent_network_changed") if (cmd == "agent_network_changed")
processNetworkChanged(d, answer); processNetworkChanged(d, answer);
else else
if (cmd == "agent_add_root_cert") if (cmd == "agent_add_root_cert")
processAddRootCert(d, answer); processAddRootCert(d, answer);
else else
if (cmd == "detach_log") if (cmd == "detach_log")
{ {
GLogger.closeFile(); GLogger.closeFile();
answer["status"] = Status_Ok; answer["status"] = Status_Ok;
} }
else else
if (cmd == "attach_log") if (cmd == "attach_log")
{ {
GLogger.openFile(); GLogger.openFile();
answer["status"] = Status_Ok; answer["status"] = Status_Ok;
} }
else else
if (cmd == "log_message") if (cmd == "log_message")
processLogMessage(d, answer); processLogMessage(d, answer);
else else
{ {
answer["status"] = Status_NoCommand; answer["status"] = Status_NoCommand;
} }
} }
catch(std::exception& e) catch(std::exception& e)
{ {
@ -332,14 +332,35 @@ void AgentImpl::processStartSession(Json::Value& request, Json::Value& answer)
audioProvider->setState(audioProvider->state() | static_cast<int>(StreamState::Grabbing) | static_cast<int>(StreamState::Playing)); audioProvider->setState(audioProvider->state() | static_cast<int>(StreamState::Grabbing) | static_cast<int>(StreamState::Playing));
#if defined(USE_AQUA_LIBRARY) #if defined(USE_AQUA_LIBRARY)
std::string temp_path = request["aqua_temp_path"].asString(); std::string path_faults = request["path_faults"].asString();
std::string config = "-avlp on -smtnrm on -decor off -mprio off -npnt auto -voip off -enorm off -g711 on -spfrcor off -grad off -tmc on -miter 1 -trim a 10 -output json";
sevana::aqua::config config = {
{ "avlp", "off" },
{ "decor", "off" },
{ "mprio", "off" },
{ "miter", "1" },
{ "enorm", "off" },
{ "voip", "on" },
{ "g711", "on" },
{ "spfrcor", "on" },
{ "grad", "off" },
{ "ratem", "%%m" },
{ "trim", "a 2" },
{ "output", "json" },
{ "fau", path_faults},
{ "specp", "32"}
};
// std::string config = "-avlp on -smtnrm on -decor off -mprio off -npnt auto -voip off -enorm off -g711 on -spfrcor off -grad off -tmc on -miter 1 -trim a 10 -output json";
/*if (temp_path.size()) /*if (temp_path.size())
config += " -fau " + temp_path; */ config += " -fau " + temp_path; */
auto qc = std::make_shared<sevana::aqua>(); auto qc = std::make_shared<sevana::aqua>();
//qc->setTempPath(temp_path); if (!qc->is_open())
qc->configure_with(sevana::aqua::parse(config)); {
std::cerr << "Problem when initializing AQuA library" << std::endl;
}
qc->configure_with(config);
mAquaMap[sessionIter->first] = qc; mAquaMap[sessionIter->first] = qc;
dynamic_cast<AudioProvider*>(audioProvider.get())->configureMediaObserver(this, (void*)qc.get()); dynamic_cast<AudioProvider*>(audioProvider.get())->configureMediaObserver(this, (void*)qc.get());
@ -559,6 +580,7 @@ void AgentImpl::processGetMediaStats(Json::Value& request, Json::Value& answer)
test.mChannels = AUDIO_CHANNELS; reference.mChannels = AUDIO_CHANNELS; test.mChannels = AUDIO_CHANNELS; reference.mChannels = AUDIO_CHANNELS;
auto r = sa->compare(reference, test); auto r = sa->compare(reference, test);
std::cout << r.mFaultsText << std::endl;
answer["aqua_mos"] = r.mMos; answer["aqua_mos"] = r.mMos;
answer["aqua_report"] = r.mFaultsText; answer["aqua_report"] = r.mFaultsText;
} }