From edc5d89a546f17a4f2ac23e88ff47db9eb7a91bd Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Wed, 19 Feb 2025 15:21:08 +0000 Subject: [PATCH] Move json.h to webrtc namespace Bug: webrtc:42232595 Change-Id: Ibc4842b123dad332840e3ee2e13eeb3af8b6a0b5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/377820 Commit-Queue: Evan Shrubsole Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43934} --- .../test/echo_canceller3_config_json.cc | 73 +++++++++---------- rtc_base/strings/json.cc | 4 +- rtc_base/strings/json.h | 37 +++++++++- rtc_base/strings/json_unittest.cc | 4 +- rtc_tools/rtp_generator/rtp_generator.cc | 20 ++--- stats/rtc_stats_unittest.cc | 49 ++++++------- 6 files changed, 109 insertions(+), 78 deletions(-) diff --git a/modules/audio_processing/test/echo_canceller3_config_json.cc b/modules/audio_processing/test/echo_canceller3_config_json.cc index d3e3bc5250..4b89be6ee7 100644 --- a/modules/audio_processing/test/echo_canceller3_config_json.cc +++ b/modules/audio_processing/test/echo_canceller3_config_json.cc @@ -25,7 +25,7 @@ namespace { void ReadParam(const Json::Value& root, std::string param_name, bool* param) { RTC_DCHECK(param); bool v; - if (rtc::GetBoolFromJsonObject(root, param_name, &v)) { + if (GetBoolFromJsonObject(root, param_name, &v)) { *param = v; } } @@ -33,7 +33,7 @@ void ReadParam(const Json::Value& root, std::string param_name, bool* param) { void ReadParam(const Json::Value& root, std::string param_name, size_t* param) { RTC_DCHECK(param); int v; - if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) { + if (GetIntFromJsonObject(root, param_name, &v) && v >= 0) { *param = v; } } @@ -41,7 +41,7 @@ void ReadParam(const Json::Value& root, std::string param_name, size_t* param) { void ReadParam(const Json::Value& root, std::string param_name, int* param) { RTC_DCHECK(param); int v; - if (rtc::GetIntFromJsonObject(root, param_name, &v)) { + if (GetIntFromJsonObject(root, param_name, &v)) { *param = v; } } @@ -49,7 +49,7 @@ void ReadParam(const Json::Value& root, std::string param_name, int* param) { void ReadParam(const Json::Value& root, std::string param_name, float* param) { RTC_DCHECK(param); double v; - if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) { + if (GetDoubleFromJsonObject(root, param_name, &v)) { *param = static_cast(v); } } @@ -59,9 +59,9 @@ void ReadParam(const Json::Value& root, EchoCanceller3Config::Filter::RefinedConfiguration* param) { RTC_DCHECK(param); Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + if (GetValueFromJsonObject(root, param_name, &json_array)) { std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); + JsonArrayToDoubleVector(json_array, &v); if (v.size() != 6) { RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; return; @@ -80,9 +80,9 @@ void ReadParam(const Json::Value& root, EchoCanceller3Config::Filter::CoarseConfiguration* param) { RTC_DCHECK(param); Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + if (GetValueFromJsonObject(root, param_name, &json_array)) { std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); + JsonArrayToDoubleVector(json_array, &v); if (v.size() != 3) { RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; return; @@ -99,7 +99,7 @@ void ReadParam(const Json::Value& root, RTC_DCHECK(param); Json::Value subsection; - if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) { + if (GetValueFromJsonObject(root, param_name, &subsection)) { ReadParam(subsection, "downmix", ¶m->downmix); ReadParam(subsection, "adaptive_selection", ¶m->adaptive_selection); ReadParam(subsection, "activity_power_threshold", @@ -116,9 +116,9 @@ void ReadParam( param) { RTC_DCHECK(param); Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + if (GetValueFromJsonObject(root, param_name, &json_array)) { std::vector v; - rtc::JsonArrayToIntVector(json_array, &v); + JsonArrayToIntVector(json_array, &v); if (v.size() != 2) { RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; return; @@ -133,9 +133,9 @@ void ReadParam(const Json::Value& root, EchoCanceller3Config::Suppressor::MaskingThresholds* param) { RTC_DCHECK(param); Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + if (GetValueFromJsonObject(root, param_name, &json_array)) { std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); + JsonArrayToDoubleVector(json_array, &v); if (v.size() != 3) { RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; return; @@ -170,7 +170,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, } Json::Value aec3_root; - success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root); + success = GetValueFromJsonObject(root, "aec3", &aec3_root); if (!success) { RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string; *parsing_successful = false; @@ -178,14 +178,14 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, } Json::Value section; - if (rtc::GetValueFromJsonObject(aec3_root, "buffering", §ion)) { + if (GetValueFromJsonObject(aec3_root, "buffering", §ion)) { ReadParam(section, "excess_render_detection_interval_blocks", &cfg.buffering.excess_render_detection_interval_blocks); ReadParam(section, "max_allowed_excess_render_blocks", &cfg.buffering.max_allowed_excess_render_blocks); } - if (rtc::GetValueFromJsonObject(aec3_root, "delay", §ion)) { + if (GetValueFromJsonObject(aec3_root, "delay", §ion)) { ReadParam(section, "default_delay", &cfg.delay.default_delay); ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor); ReadParam(section, "num_filters", &cfg.delay.num_filters); @@ -203,8 +203,8 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.delay.delay_candidate_detection_threshold); Json::Value subsection; - if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds", - &subsection)) { + if (GetValueFromJsonObject(section, "delay_selection_thresholds", + &subsection)) { ReadParam(subsection, "initial", &cfg.delay.delay_selection_thresholds.initial); ReadParam(subsection, "converged", @@ -223,7 +223,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, ReadParam(section, "detect_pre_echo", &cfg.delay.detect_pre_echo); } - if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) { + if (GetValueFromJsonObject(aec3_root, "filter", §ion)) { ReadParam(section, "refined", &cfg.filter.refined); ReadParam(section, "coarse", &cfg.filter.coarse); ReadParam(section, "refined_initial", &cfg.filter.refined_initial); @@ -245,7 +245,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.filter.export_linear_aec_output); } - if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) { + if (GetValueFromJsonObject(aec3_root, "erle", §ion)) { ReadParam(section, "min", &cfg.erle.min); ReadParam(section, "max_l", &cfg.erle.max_l); ReadParam(section, "max_h", &cfg.erle.max_h); @@ -257,7 +257,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.erle.clamp_quality_estimate_to_one); } - if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) { + if (GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) { ReadParam(section, "default_gain", &cfg.ep_strength.default_gain); ReadParam(section, "default_len", &cfg.ep_strength.default_len); ReadParam(section, "nearend_len", &cfg.ep_strength.nearend_len); @@ -269,7 +269,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.ep_strength.use_conservative_tail_frequency_response); } - if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", §ion)) { + if (GetValueFromJsonObject(aec3_root, "echo_audibility", §ion)) { ReadParam(section, "low_render_limit", &cfg.echo_audibility.low_render_limit); ReadParam(section, "normal_render_limit", @@ -288,7 +288,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.echo_audibility.use_stationarity_properties_at_init); } - if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", §ion)) { + if (GetValueFromJsonObject(aec3_root, "render_levels", §ion)) { ReadParam(section, "active_render_limit", &cfg.render_levels.active_render_limit); ReadParam(section, "poor_excitation_render_limit", @@ -299,15 +299,14 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.render_levels.render_power_gain_db); } - if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control", - §ion)) { + if (GetValueFromJsonObject(aec3_root, "echo_removal_control", §ion)) { ReadParam(section, "has_clock_drift", &cfg.echo_removal_control.has_clock_drift); ReadParam(section, "linear_and_stable_echo_path", &cfg.echo_removal_control.linear_and_stable_echo_path); } - if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", §ion)) { + if (GetValueFromJsonObject(aec3_root, "echo_model", §ion)) { Json::Value subsection; ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold); ReadParam(section, "min_noise_floor_power", @@ -324,16 +323,16 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.echo_model.model_reverb_in_nonlinear_mode); } - if (rtc::GetValueFromJsonObject(aec3_root, "comfort_noise", §ion)) { + if (GetValueFromJsonObject(aec3_root, "comfort_noise", §ion)) { ReadParam(section, "noise_floor_dbfs", &cfg.comfort_noise.noise_floor_dbfs); } Json::Value subsection; - if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", §ion)) { + if (GetValueFromJsonObject(aec3_root, "suppressor", §ion)) { ReadParam(section, "nearend_average_blocks", &cfg.suppressor.nearend_average_blocks); - if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) { + if (GetValueFromJsonObject(section, "normal_tuning", &subsection)) { ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf); ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf); ReadParam(subsection, "max_inc_factor", @@ -342,7 +341,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.suppressor.normal_tuning.max_dec_factor_lf); } - if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) { + if (GetValueFromJsonObject(section, "nearend_tuning", &subsection)) { ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf); ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf); ReadParam(subsection, "max_inc_factor", @@ -360,8 +359,8 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, ReadParam(section, "last_lf_band", &cfg.suppressor.last_lf_band); ReadParam(section, "first_hf_band", &cfg.suppressor.first_hf_band); - if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection", - &subsection)) { + if (GetValueFromJsonObject(section, "dominant_nearend_detection", + &subsection)) { ReadParam(subsection, "enr_threshold", &cfg.suppressor.dominant_nearend_detection.enr_threshold); ReadParam(subsection, "enr_exit_threshold", @@ -380,8 +379,8 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, .use_unbounded_echo_spectrum); } - if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection", - &subsection)) { + if (GetValueFromJsonObject(section, "subband_nearend_detection", + &subsection)) { ReadParam( subsection, "nearend_average_blocks", &cfg.suppressor.subband_nearend_detection.nearend_average_blocks); @@ -398,8 +397,8 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, ReadParam(section, "use_subband_nearend_detection", &cfg.suppressor.use_subband_nearend_detection); - if (rtc::GetValueFromJsonObject(section, "high_bands_suppression", - &subsection)) { + if (GetValueFromJsonObject(section, "high_bands_suppression", + &subsection)) { ReadParam(subsection, "enr_threshold", &cfg.suppressor.high_bands_suppression.enr_threshold); ReadParam(subsection, "max_gain_during_echo", @@ -417,7 +416,7 @@ void Aec3ConfigFromJsonString(absl::string_view json_string, &cfg.suppressor.conservative_hf_suppression); } - if (rtc::GetValueFromJsonObject(aec3_root, "multi_channel", §ion)) { + if (GetValueFromJsonObject(aec3_root, "multi_channel", §ion)) { ReadParam(section, "detect_stereo_content", &cfg.multi_channel.detect_stereo_content); ReadParam(section, "stereo_detection_threshold", diff --git a/rtc_base/strings/json.cc b/rtc_base/strings/json.cc index 5cf153c926..bb8d039601 100644 --- a/rtc_base/strings/json.cc +++ b/rtc_base/strings/json.cc @@ -17,7 +17,7 @@ #include "absl/strings/string_view.h" #include "rtc_base/string_encode.h" -namespace rtc { +namespace webrtc { bool GetStringFromJson(const Json::Value& in, std::string* out) { if (!in.isString()) { @@ -293,4 +293,4 @@ std::string JsonValueToString(const Json::Value& json) { return output.substr(0, output.size() - 1); // trim trailing newline } -} // namespace rtc +} // namespace webrtc diff --git a/rtc_base/strings/json.h b/rtc_base/strings/json.h index 1cc83a275b..45bb24a5af 100644 --- a/rtc_base/strings/json.h +++ b/rtc_base/strings/json.h @@ -17,7 +17,7 @@ #include "absl/strings/string_view.h" #include "json/json.h" // IWYU pragma: export -namespace rtc { +namespace webrtc { /////////////////////////////////////////////////////////////////////////////// // JSON Helpers @@ -78,6 +78,41 @@ bool GetDoubleFromJsonObject(const Json::Value& in, // Writes out a Json value as a string. std::string JsonValueToString(const Json::Value& json); +} // namespace webrtc + +// Re-export symbols from the webrtc namespace for backwards compatibility. +// TODO(bugs.webrtc.org/4222596): Remove once all references are updated. +namespace rtc { +using ::webrtc::BoolVectorToJsonArray; +using ::webrtc::DoubleVectorToJsonArray; +using ::webrtc::GetBoolFromJson; +using ::webrtc::GetBoolFromJsonArray; +using ::webrtc::GetBoolFromJsonObject; +using ::webrtc::GetDoubleFromJson; +using ::webrtc::GetDoubleFromJsonArray; +using ::webrtc::GetDoubleFromJsonObject; +using ::webrtc::GetIntFromJson; +using ::webrtc::GetIntFromJsonArray; +using ::webrtc::GetIntFromJsonObject; +using ::webrtc::GetStringFromJson; +using ::webrtc::GetStringFromJsonArray; +using ::webrtc::GetStringFromJsonObject; +using ::webrtc::GetUIntFromJson; +using ::webrtc::GetUIntFromJsonArray; +using ::webrtc::GetUIntFromJsonObject; +using ::webrtc::GetValueFromJsonArray; +using ::webrtc::GetValueFromJsonObject; +using ::webrtc::IntVectorToJsonArray; +using ::webrtc::JsonArrayToBoolVector; +using ::webrtc::JsonArrayToDoubleVector; +using ::webrtc::JsonArrayToIntVector; +using ::webrtc::JsonArrayToStringVector; +using ::webrtc::JsonArrayToUIntVector; +using ::webrtc::JsonArrayToValueVector; +using ::webrtc::JsonValueToString; +using ::webrtc::StringVectorToJsonArray; +using ::webrtc::UIntVectorToJsonArray; +using ::webrtc::ValueVectorToJsonArray; } // namespace rtc #endif // RTC_BASE_STRINGS_JSON_H_ diff --git a/rtc_base/strings/json_unittest.cc b/rtc_base/strings/json_unittest.cc index 82d26f179e..b0865492d8 100644 --- a/rtc_base/strings/json_unittest.cc +++ b/rtc_base/strings/json_unittest.cc @@ -14,7 +14,7 @@ #include "test/gtest.h" -namespace rtc { +namespace webrtc { static Json::Value in_s("foo"); static Json::Value in_sn("99"); @@ -280,4 +280,4 @@ TEST(JsonTest, DoubleVectorToFromArray) { } } -} // namespace rtc +} // namespace webrtc diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc index 66ab032a12..5ab322dd81 100644 --- a/rtc_tools/rtp_generator/rtp_generator.cc +++ b/rtc_tools/rtp_generator/rtp_generator.cc @@ -74,23 +74,23 @@ ParseVideoSendStreamConfig(const Json::Value& json) { RtpGeneratorOptions::VideoSendStreamConfig config; // Parse video source settings. - if (!rtc::GetIntFromJsonObject(json, "duration_ms", &config.duration_ms)) { + if (!GetIntFromJsonObject(json, "duration_ms", &config.duration_ms)) { RTC_LOG(LS_WARNING) << "duration_ms not specified using default: " << config.duration_ms; } - if (!rtc::GetIntFromJsonObject(json, "video_width", &config.video_width)) { + if (!GetIntFromJsonObject(json, "video_width", &config.video_width)) { RTC_LOG(LS_WARNING) << "video_width not specified using default: " << config.video_width; } - if (!rtc::GetIntFromJsonObject(json, "video_height", &config.video_height)) { + if (!GetIntFromJsonObject(json, "video_height", &config.video_height)) { RTC_LOG(LS_WARNING) << "video_height not specified using default: " << config.video_height; } - if (!rtc::GetIntFromJsonObject(json, "video_fps", &config.video_fps)) { + if (!GetIntFromJsonObject(json, "video_fps", &config.video_fps)) { RTC_LOG(LS_WARNING) << "video_fps not specified using default: " << config.video_fps; } - if (!rtc::GetIntFromJsonObject(json, "num_squares", &config.num_squares)) { + if (!GetIntFromJsonObject(json, "num_squares", &config.num_squares)) { RTC_LOG(LS_WARNING) << "num_squares not specified using default: " << config.num_squares; } @@ -98,12 +98,12 @@ ParseVideoSendStreamConfig(const Json::Value& json) { // Parse RTP settings for this configuration. config.rtp.ssrcs.push_back(kDefaultSsrc); Json::Value rtp_json; - if (!rtc::GetValueFromJsonObject(json, "rtp", &rtp_json)) { + if (!GetValueFromJsonObject(json, "rtp", &rtp_json)) { RTC_LOG(LS_ERROR) << "video_streams must have an rtp section"; return std::nullopt; } - if (!rtc::GetStringFromJsonObject(rtp_json, "payload_name", - &config.rtp.payload_name)) { + if (!GetStringFromJsonObject(rtp_json, "payload_name", + &config.rtp.payload_name)) { RTC_LOG(LS_ERROR) << "rtp.payload_name must be specified"; return std::nullopt; } @@ -114,8 +114,8 @@ ParseVideoSendStreamConfig(const Json::Value& json) { config.rtp.payload_type = GetDefaultTypeForPayloadName(config.rtp.payload_name); - if (!rtc::GetIntFromJsonObject(rtp_json, "payload_type", - &config.rtp.payload_type)) { + if (!GetIntFromJsonObject(rtp_json, "payload_type", + &config.rtp.payload_type)) { RTC_LOG(LS_WARNING) << "rtp.payload_type not specified using default for codec type" << config.rtp.payload_type; diff --git a/stats/rtc_stats_unittest.cc b/stats/rtc_stats_unittest.cc index 0757fb7940..8a75b78295 100644 --- a/stats/rtc_stats_unittest.cc +++ b/stats/rtc_stats_unittest.cc @@ -288,38 +288,37 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { json_stats.c_str() + json_stats.size(), &json_output, nullptr)); - EXPECT_TRUE(rtc::GetStringFromJsonObject(json_output, "id", &id)); - EXPECT_TRUE(rtc::GetIntFromJsonObject(json_output, "timestamp", ×tamp)); - EXPECT_TRUE(rtc::GetBoolFromJsonObject(json_output, "mBool", &m_bool)); - EXPECT_TRUE(rtc::GetIntFromJsonObject(json_output, "mInt32", &m_int32)); - EXPECT_TRUE(rtc::GetDoubleFromJsonObject(json_output, "mDouble", &m_double)); - EXPECT_TRUE(rtc::GetStringFromJsonObject(json_output, "mString", &m_string)); + EXPECT_TRUE(GetStringFromJsonObject(json_output, "id", &id)); + EXPECT_TRUE(GetIntFromJsonObject(json_output, "timestamp", ×tamp)); + EXPECT_TRUE(GetBoolFromJsonObject(json_output, "mBool", &m_bool)); + EXPECT_TRUE(GetIntFromJsonObject(json_output, "mInt32", &m_int32)); + EXPECT_TRUE(GetDoubleFromJsonObject(json_output, "mDouble", &m_double)); + EXPECT_TRUE(GetStringFromJsonObject(json_output, "mString", &m_string)); Json::Value json_array; EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mSequenceBool", &json_array)); - EXPECT_TRUE(rtc::JsonArrayToBoolVector(json_array, &sequence_bool)); + GetValueFromJsonObject(json_output, "mSequenceBool", &json_array)); + EXPECT_TRUE(JsonArrayToBoolVector(json_array, &sequence_bool)); EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mSequenceInt32", &json_array)); - EXPECT_TRUE(rtc::JsonArrayToIntVector(json_array, &sequence_int32)); + GetValueFromJsonObject(json_output, "mSequenceInt32", &json_array)); + EXPECT_TRUE(JsonArrayToIntVector(json_array, &sequence_int32)); EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mSequenceDouble", &json_array)); - EXPECT_TRUE(rtc::JsonArrayToDoubleVector(json_array, &sequence_double)); + GetValueFromJsonObject(json_output, "mSequenceDouble", &json_array)); + EXPECT_TRUE(JsonArrayToDoubleVector(json_array, &sequence_double)); EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mSequenceString", &json_array)); - EXPECT_TRUE(rtc::JsonArrayToStringVector(json_array, &sequence_string)); + GetValueFromJsonObject(json_output, "mSequenceString", &json_array)); + EXPECT_TRUE(JsonArrayToStringVector(json_array, &sequence_string)); Json::Value json_map; EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mMapStringDouble", &json_map)); + GetValueFromJsonObject(json_output, "mMapStringDouble", &json_map)); for (const auto& entry : map_string_double) { double double_output = 0.0; - EXPECT_TRUE( - rtc::GetDoubleFromJsonObject(json_map, entry.first, &double_output)); + EXPECT_TRUE(GetDoubleFromJsonObject(json_map, entry.first, &double_output)); EXPECT_NEAR(double_output, entry.second, GetExpectedError(entry.second)); } @@ -354,12 +353,11 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { std::vector sequence_int64_as_double; EXPECT_TRUE( - rtc::GetDoubleFromJsonObject(json_output, "mInt64", &m_int64_as_double)); + GetDoubleFromJsonObject(json_output, "mInt64", &m_int64_as_double)); EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mSequenceInt64", &json_array)); - EXPECT_TRUE( - rtc::JsonArrayToDoubleVector(json_array, &sequence_int64_as_double)); + GetValueFromJsonObject(json_output, "mSequenceInt64", &json_array)); + EXPECT_TRUE(JsonArrayToDoubleVector(json_array, &sequence_int64_as_double)); double stats_m_int64_as_double = static_cast(*stats.m_int64); EXPECT_NEAR(m_int64_as_double, stats_m_int64_as_double, @@ -375,13 +373,12 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { // Similarly, read Uint64 as double EXPECT_TRUE( - rtc::GetValueFromJsonObject(json_output, "mMapStringUint64", &json_map)); + GetValueFromJsonObject(json_output, "mMapStringUint64", &json_map)); for (const auto& entry : map_string_uint64) { const double stats_value_as_double = static_cast((*stats.m_map_string_uint64)[entry.first]); double double_output = 0.0; - EXPECT_TRUE( - rtc::GetDoubleFromJsonObject(json_map, entry.first, &double_output)); + EXPECT_TRUE(GetDoubleFromJsonObject(json_map, entry.first, &double_output)); EXPECT_NEAR(double_output, stats_value_as_double, GetExpectedError(stats_value_as_double)); } @@ -392,8 +389,8 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { int m_uint64; EXPECT_FALSE(stats.m_uint32.has_value()); EXPECT_FALSE(stats.m_uint64.has_value()); - EXPECT_FALSE(rtc::GetIntFromJsonObject(json_output, "mUint32", &m_uint32)); - EXPECT_FALSE(rtc::GetIntFromJsonObject(json_output, "mUint64", &m_uint64)); + EXPECT_FALSE(GetIntFromJsonObject(json_output, "mUint32", &m_uint32)); + EXPECT_FALSE(GetIntFromJsonObject(json_output, "mUint64", &m_uint64)); std::cout << stats.ToJson() << std::endl; }