From e0310719b18b4a3a8712f344478463576c08cd44 Mon Sep 17 00:00:00 2001 From: Dong Yu Date: Sat, 18 May 2024 15:25:50 +0800 Subject: [PATCH] isolate json.hpp for arkui-x compile Signed-off-by: Dong Yu --- config.gni | 9 +++++++++ services/utils/include/media_dfx.h | 6 ++++++ services/utils/media_dfx.cpp | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config.gni b/config.gni index 8b7d3ee9d..9d2468ec0 100644 --- a/config.gni +++ b/config.gni @@ -239,6 +239,11 @@ declare_args() { defined(global_parts_info.powermgr_power_manager)) { multimedia_player_framework_support_power_manager = true } + multimedia_player_framework_support_json = false + if (defined(global_parts_info) && + defined(global_parts_info.third_party_json)) { + multimedia_player_framework_support_json = true + } } player_framework_defines = [] @@ -331,6 +336,10 @@ if (multimedia_player_framework_support_mediasource) { player_framework_defines += [ "SUPPORT_MEDIA_SOURCE" ] } +if (multimedia_player_framework_support_json) { + player_framework_defines += [ "SUPPORT_JSON" ] +} + # Config path MEDIA_PLAYER_ROOT_DIR = "//foundation/multimedia/player_framework" MEDIA_PLAYER_AVCODEC = "//foundation/multimedia/av_codec" diff --git a/services/utils/include/media_dfx.h b/services/utils/include/media_dfx.h index e8ef875ce..ba948535e 100644 --- a/services/utils/include/media_dfx.h +++ b/services/utils/include/media_dfx.h @@ -25,13 +25,17 @@ #include "nocopyable.h" #include "hisysevent.h" #include "meta/meta.h" +#ifdef SUPPORT_JSON #include "nlohmann/json.hpp" +#endif #include #include namespace OHOS { namespace Media { +#ifdef SUPPORT_JSON using json = nlohmann::json; +#endif enum CallType { AVPLAYER, AVRECORDER, @@ -69,7 +73,9 @@ public: private: void StatisicsHiSysEventWrite(CallType callType, OHOS::HiviewDFX::HiSysEvent::EventType type, const std::vector& infoArr); +#ifdef SUPPORT_JSON void ParseOneEvent(const std::pair> &listPair, json& metaInfoJson); +#endif std::string msg_; }; diff --git a/services/utils/media_dfx.cpp b/services/utils/media_dfx.cpp index 9c5cce442..2f30f5a0b 100644 --- a/services/utils/media_dfx.cpp +++ b/services/utils/media_dfx.cpp @@ -204,6 +204,7 @@ void MediaEvent::CommonStatisicsEventWrite(CallType callType, OHOS::HiviewDFX::H return; } std::vector infoArr; +#ifdef SUPPORT_JSON for (const auto& kv : infoMap) { json jsonArray; json eventInfoJson; @@ -218,10 +219,12 @@ void MediaEvent::CommonStatisicsEventWrite(CallType callType, OHOS::HiviewDFX::H jsonArray.push_back(eventInfoJson); infoArr.push_back(jsonArray.dump()); } - +#endif StatisicsHiSysEventWrite(callType, type, infoArr); } + +#ifdef SUPPORT_JSON void MediaEvent::ParseOneEvent(const std::pair> &listPair, json& metaInfoJson) { @@ -259,6 +262,7 @@ void MediaEvent::ParseOneEvent(const std::pair& infoArr) -- Gitee