From 4d8a16789965cb1a9c178d626f555c5f109b5bbf Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Wed, 20 Jan 2021 20:38:58 +0200 Subject: [PATCH] - fix building issue (move from Json:: to JsonCpp:: namespace) + minor cleanup in cmake file --- src/engine/agent/Agent_Impl.cpp | 56 ++++++++++++++++---------------- src/engine/agent/Agent_Impl.h | 38 +++++++++++----------- src/engine/helper/CMakeLists.txt | 1 + 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/engine/agent/Agent_Impl.cpp b/src/engine/agent/Agent_Impl.cpp index 53f166c3..3bd8091b 100644 --- a/src/engine/agent/Agent_Impl.cpp +++ b/src/engine/agent/Agent_Impl.cpp @@ -55,10 +55,10 @@ std::string AgentImpl::command(const std::string& command) if (command.empty()) return ""; - Json::Value d, answer; + JsonCpp::Value d, answer; try { - Json::Reader r; + JsonCpp::Reader r; if (!r.parse(command, d)) return ""; @@ -151,7 +151,7 @@ std::string AgentImpl::read() return ""; } -void AgentImpl::processConfig(Json::Value &d, Json::Value &answer) +void AgentImpl::processConfig(JsonCpp::Value &d, JsonCpp::Value &answer) { std::unique_lock l(mAgentMutex); @@ -188,7 +188,7 @@ void AgentImpl::processConfig(Json::Value &d, Json::Value &answer) answer["status"] = Status_Ok; } -void AgentImpl::processStart(Json::Value& /*request*/, Json::Value &answer) +void AgentImpl::processStart(JsonCpp::Value& /*request*/, JsonCpp::Value &answer) { std::unique_lock l(mAgentMutex); if (mThread) @@ -230,13 +230,13 @@ void AgentImpl::processStart(Json::Value& /*request*/, Json::Value &answer) answer["status"] = Status_Ok; } -void AgentImpl::processStop(Json::Value& /*request*/, Json::Value& answer) +void AgentImpl::processStop(JsonCpp::Value& /*request*/, JsonCpp::Value& answer) { stopAgentAndThread(); answer["status"] = Status_Ok; } -void AgentImpl::processCreateAccount(Json::Value &d, Json::Value& answer) +void AgentImpl::processCreateAccount(JsonCpp::Value &d, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); PVariantMap c = std::make_shared(); @@ -256,7 +256,7 @@ void AgentImpl::processCreateAccount(Json::Value &d, Json::Value& answer) answer["status"] = Status_Ok; } -void AgentImpl::processStartAccount(Json::Value& request, Json::Value& answer) +void AgentImpl::processStartAccount(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); // Locate account in map @@ -270,7 +270,7 @@ void AgentImpl::processStartAccount(Json::Value& request, Json::Value& answer) answer["status"] = Status_AccountNotFound; } -void AgentImpl::processSetUserInfoToAccount(Json::Value &request, Json::Value &answer) +void AgentImpl::processSetUserInfoToAccount(JsonCpp::Value &request, JsonCpp::Value &answer) { std::unique_lock l(mAgentMutex); // Locate account in map @@ -278,7 +278,7 @@ void AgentImpl::processSetUserInfoToAccount(Json::Value &request, Json::Value &a if (accountIter != mAccountMap.end()) { Account::UserInfo info; - Json::Value& arg = request["userinfo"]; + JsonCpp::Value& arg = request["userinfo"]; std::vector keys = arg.getMemberNames(); for (const std::string& k: keys) info[k] = arg[k].asString(); @@ -290,7 +290,7 @@ void AgentImpl::processSetUserInfoToAccount(Json::Value &request, Json::Value &a answer["status"] = Status_AccountNotFound; } -void AgentImpl::processCreateSession(Json::Value &request, Json::Value &answer) +void AgentImpl::processCreateSession(JsonCpp::Value &request, JsonCpp::Value &answer) { std::unique_lock l(mAgentMutex); auto accountIter = mAccountMap.find(request["account_id"].asInt()); @@ -305,7 +305,7 @@ void AgentImpl::processCreateSession(Json::Value &request, Json::Value &answer) answer["status"] = Status_AccountNotFound; } -void AgentImpl::processStartSession(Json::Value& request, Json::Value& answer) +void AgentImpl::processStartSession(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); @@ -368,7 +368,7 @@ void AgentImpl::processStartSession(Json::Value& request, Json::Value& answer) // Get user headers Session::UserHeaders info; - Json::Value& arg = request["userinfo"]; + JsonCpp::Value& arg = request["userinfo"]; std::vector keys = arg.getMemberNames(); for (const std::string& k: keys) info[k] = arg[k].asString(); @@ -384,7 +384,7 @@ void AgentImpl::processStartSession(Json::Value& request, Json::Value& answer) } } -void AgentImpl::processStopSession(Json::Value& request, Json::Value& answer) +void AgentImpl::processStopSession(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); @@ -399,7 +399,7 @@ void AgentImpl::processStopSession(Json::Value& request, Json::Value& answer) answer["status"] = Status_SessionNotFound; } -void AgentImpl::processAcceptSession(Json::Value& request, Json::Value& answer) +void AgentImpl::processAcceptSession(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); auto sessionIter = mSessionMap.find(request["session_id"].asInt()); @@ -413,7 +413,7 @@ void AgentImpl::processAcceptSession(Json::Value& request, Json::Value& answer) // Get user headers Session::UserHeaders info; - Json::Value& arg = request["userinfo"]; + JsonCpp::Value& arg = request["userinfo"]; std::vector keys = arg.getMemberNames(); for (const std::string& k: keys) info[k] = arg[k].asString(); @@ -429,7 +429,7 @@ void AgentImpl::processAcceptSession(Json::Value& request, Json::Value& answer) } -void AgentImpl::processDestroySession(Json::Value& request, Json::Value& answer) +void AgentImpl::processDestroySession(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); @@ -443,7 +443,7 @@ void AgentImpl::processDestroySession(Json::Value& request, Json::Value& answer) answer["status"] = Status_Ok; } -void AgentImpl::processWaitForEvent(Json::Value &request, Json::Value &answer) +void AgentImpl::processWaitForEvent(JsonCpp::Value &request, JsonCpp::Value &answer) { std::unique_lock l(mAgentMutex); @@ -464,15 +464,15 @@ void AgentImpl::processWaitForEvent(Json::Value &request, Json::Value &answer) } #if defined(USE_PVQA_LIBRARY) -static Json::Value CsvReportToJson(const std::string& report) +static JsonCpp::Value CsvReportToJson(const std::string& report) { - Json::Value detectorValues; + JsonCpp::Value detectorValues; std::istringstream iss(report); CsvReader reader(iss); std::vector cells; if (reader.readLine(cells)) { - Json::Value detectorNames; + JsonCpp::Value detectorNames; for (size_t nameIndex = 0; nameIndex < cells.size(); nameIndex++) detectorNames[static_cast(nameIndex)] = StringHelper::trim(cells[nameIndex]); // Put first line name of columns @@ -482,7 +482,7 @@ static Json::Value CsvReportToJson(const std::string& report) while (reader.readLine(cells)) { // Skip last column for now - Json::Value row; + JsonCpp::Value row; for (size_t valueIndex = 0; valueIndex < cells.size(); valueIndex++) { bool isFloat = true; @@ -499,7 +499,7 @@ static Json::Value CsvReportToJson(const std::string& report) } #endif -void AgentImpl::processGetMediaStats(Json::Value& request, Json::Value& answer) +void AgentImpl::processGetMediaStats(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); int sessionId = request["session_id"].asInt(); @@ -611,7 +611,7 @@ void AgentImpl::processGetMediaStats(Json::Value& request, Json::Value& answer) answer["status"] = Status_SessionNotFound; } -void AgentImpl::processNetworkChanged(Json::Value& /*request*/, Json::Value& /*answer*/) +void AgentImpl::processNetworkChanged(JsonCpp::Value& /*request*/, JsonCpp::Value& /*answer*/) { std::unique_lock l(mAgentMutex); } @@ -619,7 +619,7 @@ void AgentImpl::processNetworkChanged(Json::Value& /*request*/, Json::Value& /*a const std::string BeginCertificate = "-----BEGIN CERTIFICATE-----"; const std::string EndCertificate = "-----END CERTIFICATE-----"; -void AgentImpl::processAddRootCert(Json::Value& request, Json::Value& answer) +void AgentImpl::processAddRootCert(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); std::string pem = request["cert"].asString(); @@ -642,7 +642,7 @@ void AgentImpl::processAddRootCert(Json::Value& request, Json::Value& answer) answer["status"] = Status_Ok; } -void AgentImpl::processLogMessage(Json::Value &request, Json::Value &answer) +void AgentImpl::processLogMessage(JsonCpp::Value &request, JsonCpp::Value &answer) { int level = request["level"].asInt(); std::string message = request["message"].asString(); @@ -692,7 +692,7 @@ void AgentImpl::stopAgentAndThread() SocketHeap::instance().stop(); } -void AgentImpl::processUseStreamForSession(Json::Value& request, Json::Value& answer) +void AgentImpl::processUseStreamForSession(JsonCpp::Value& request, JsonCpp::Value& answer) { std::unique_lock l(mAgentMutex); SessionMap::iterator sessionIter = mSessionMap.find(request["session_id"].asInt()); @@ -790,7 +790,7 @@ void AgentImpl::onMedia(const void* data, int length, MT::Stream::MediaDirection // Called on new incoming session; providers shoukld -#define EVENT_WITH_NAME(X) Json::Value v; v["event_name"] = X; +#define EVENT_WITH_NAME(X) JsonCpp::Value v; v["event_name"] = X; PDataProvider AgentImpl::onProviderNeeded(const std::string& name) { @@ -935,7 +935,7 @@ void AgentImpl::onSipConnectionFailed() addEvent(v); } -void AgentImpl::addEvent(const Json::Value& v) +void AgentImpl::addEvent(const JsonCpp::Value& v) { std::unique_lock lock(mEventListMutex); mEventList.push_back(v); diff --git a/src/engine/agent/Agent_Impl.h b/src/engine/agent/Agent_Impl.h index 3eed655b..6d68b8a1 100644 --- a/src/engine/agent/Agent_Impl.h +++ b/src/engine/agent/Agent_Impl.h @@ -30,7 +30,7 @@ protected: std::recursive_mutex mAgentMutex; std::mutex mEventListMutex; std::condition_variable mEventListChangeCondVar; - std::vector mEventList; + std::vector mEventList; bool mUseNativeAudio = false; typedef std::map AccountMap; @@ -54,24 +54,24 @@ protected: //Audio::PWavFileWriter mIncomingAudioDump, mOutgoingAudioDump; void run(); - void addEvent(const Json::Value& v); - void processConfig(Json::Value& request, Json::Value& answer); - void processStart(Json::Value& request, Json::Value& answer); - void processStop(Json::Value& request, Json::Value& answer); - void processCreateAccount(Json::Value& request, Json::Value& answer); - void processStartAccount(Json::Value& request, Json::Value& answer); - void processSetUserInfoToAccount(Json::Value& request, Json::Value& answer); - void processCreateSession(Json::Value& request, Json::Value& answer); - void processStartSession(Json::Value& request, Json::Value& answer); - void processStopSession(Json::Value& request, Json::Value& answer); - void processAcceptSession(Json::Value& request, Json::Value& answer); - void processDestroySession(Json::Value& request, Json::Value& answer); - void processWaitForEvent(Json::Value& request, Json::Value& answer); - void processGetMediaStats(Json::Value& request, Json::Value& answer); - void processUseStreamForSession(Json::Value& request, Json::Value& answer); - void processNetworkChanged(Json::Value& request, Json::Value& answer); - void processAddRootCert(Json::Value& request, Json::Value& answer); - void processLogMessage(Json::Value& request, Json::Value& answer); + void addEvent(const JsonCpp::Value& v); + void processConfig(JsonCpp::Value& request, JsonCpp::Value& answer); + void processStart(JsonCpp::Value& request, JsonCpp::Value& answer); + void processStop(JsonCpp::Value& request, JsonCpp::Value& answer); + void processCreateAccount(JsonCpp::Value& request, JsonCpp::Value& answer); + void processStartAccount(JsonCpp::Value& request, JsonCpp::Value& answer); + void processSetUserInfoToAccount(JsonCpp::Value& request, JsonCpp::Value& answer); + void processCreateSession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processStartSession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processStopSession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processAcceptSession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processDestroySession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processWaitForEvent(JsonCpp::Value& request, JsonCpp::Value& answer); + void processGetMediaStats(JsonCpp::Value& request, JsonCpp::Value& answer); + void processUseStreamForSession(JsonCpp::Value& request, JsonCpp::Value& answer); + void processNetworkChanged(JsonCpp::Value& request, JsonCpp::Value& answer); + void processAddRootCert(JsonCpp::Value& request, JsonCpp::Value& answer); + void processLogMessage(JsonCpp::Value& request, JsonCpp::Value& answer); void stopAgentAndThread(); public: diff --git a/src/engine/helper/CMakeLists.txt b/src/engine/helper/CMakeLists.txt index 290875ba..da91327d 100644 --- a/src/engine/helper/CMakeLists.txt +++ b/src/engine/helper/CMakeLists.txt @@ -3,6 +3,7 @@ project (helper_lib) # Rely on C++ 11 set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD_REQUIRED ON) + set (USE_NULL_UUID OFF CACHE BOOL "When enabled linking to libuuid is avoided") set (CMAKE_POSITION_INDEPENDENT_CODE ON)