From 49fbe2345f718d8dc6aae5b52e24e74c87c0a127 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Sat, 27 Jun 2020 21:50:03 +0300 Subject: [PATCH] - work on further AQuA integration - now spectrum information is here --- src/engine/agent/Agent_Impl.cpp | 156 ++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 67 deletions(-) diff --git a/src/engine/agent/Agent_Impl.cpp b/src/engine/agent/Agent_Impl.cpp index e3234a62..dddbefae 100644 --- a/src/engine/agent/Agent_Impl.cpp +++ b/src/engine/agent/Agent_Impl.cpp @@ -67,69 +67,69 @@ std::string AgentImpl::command(const std::string& command) if (cmd == "config") processConfig(d, answer); else - if (cmd == "start") - processStart(d, answer); - else - if (cmd == "stop") - processStop(d, answer); - else - if (cmd == "account_create") - processCreateAccount(d, answer); - else - if (cmd == "account_start") - processStartAccount(d, answer); - else - if (cmd == "account_setuserinfo") - processSetUserInfoToAccount(d, answer); - else - if (cmd == "session_create") - processCreateSession(d, answer); - else - if (cmd == "session_start") - processStartSession(d, answer); - else - if (cmd == "session_stop") - processStopSession(d, answer); - else - if (cmd == "session_accept") - processAcceptSession(d, answer); - else - if (cmd == "session_destroy") - processDestroySession(d, answer); - else - if (cmd == "session_use_stream") - processUseStreamForSession(d, answer); - else - if (cmd == "wait_for_event") - processWaitForEvent(d, answer); - else - if (cmd == "session_get_media_stats") - processGetMediaStats(d, answer); - else - if (cmd == "agent_network_changed") - processNetworkChanged(d, answer); - else - if (cmd == "agent_add_root_cert") - processAddRootCert(d, answer); - else - if (cmd == "detach_log") - { - GLogger.closeFile(); - answer["status"] = Status_Ok; - } - else - if (cmd == "attach_log") - { - GLogger.openFile(); - answer["status"] = Status_Ok; - } - else - if (cmd == "log_message") - processLogMessage(d, answer); - else - { - answer["status"] = Status_NoCommand; - } + if (cmd == "start") + processStart(d, answer); + else + if (cmd == "stop") + processStop(d, answer); + else + if (cmd == "account_create") + processCreateAccount(d, answer); + else + if (cmd == "account_start") + processStartAccount(d, answer); + else + if (cmd == "account_setuserinfo") + processSetUserInfoToAccount(d, answer); + else + if (cmd == "session_create") + processCreateSession(d, answer); + else + if (cmd == "session_start") + processStartSession(d, answer); + else + if (cmd == "session_stop") + processStopSession(d, answer); + else + if (cmd == "session_accept") + processAcceptSession(d, answer); + else + if (cmd == "session_destroy") + processDestroySession(d, answer); + else + if (cmd == "session_use_stream") + processUseStreamForSession(d, answer); + else + if (cmd == "wait_for_event") + processWaitForEvent(d, answer); + else + if (cmd == "session_get_media_stats") + processGetMediaStats(d, answer); + else + if (cmd == "agent_network_changed") + processNetworkChanged(d, answer); + else + if (cmd == "agent_add_root_cert") + processAddRootCert(d, answer); + else + if (cmd == "detach_log") + { + GLogger.closeFile(); + answer["status"] = Status_Ok; + } + else + if (cmd == "attach_log") + { + GLogger.openFile(); + answer["status"] = Status_Ok; + } + else + if (cmd == "log_message") + processLogMessage(d, answer); + else + { + answer["status"] = Status_NoCommand; + } } catch(std::exception& e) { @@ -332,14 +332,35 @@ void AgentImpl::processStartSession(Json::Value& request, Json::Value& answer) audioProvider->setState(audioProvider->state() | static_cast(StreamState::Grabbing) | static_cast(StreamState::Playing)); #if defined(USE_AQUA_LIBRARY) - std::string temp_path = request["aqua_temp_path"].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"; + std::string path_faults = request["path_faults"].asString(); + + 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()) config += " -fau " + temp_path; */ auto qc = std::make_shared(); - //qc->setTempPath(temp_path); - qc->configure_with(sevana::aqua::parse(config)); + if (!qc->is_open()) + { + std::cerr << "Problem when initializing AQuA library" << std::endl; + } + qc->configure_with(config); mAquaMap[sessionIter->first] = qc; dynamic_cast(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; auto r = sa->compare(reference, test); + std::cout << r.mFaultsText << std::endl; answer["aqua_mos"] = r.mMos; answer["aqua_report"] = r.mFaultsText; }