diff options
Diffstat (limited to 'stats')
-rw-r--r-- | stats/BUILD.gn | 13 | ||||
-rw-r--r-- | stats/g3doc/stats.md | 18 | ||||
-rw-r--r-- | stats/rtc_stats.cc | 167 | ||||
-rw-r--r-- | stats/rtc_stats_report.cc | 31 | ||||
-rw-r--r-- | stats/rtc_stats_report_unittest.cc | 19 | ||||
-rw-r--r-- | stats/rtc_stats_unittest.cc | 182 | ||||
-rw-r--r-- | stats/rtcstats_objects.cc | 677 | ||||
-rw-r--r-- | stats/test/rtc_test_stats.cc | 12 | ||||
-rw-r--r-- | stats/test/rtc_test_stats.h | 3 |
9 files changed, 676 insertions, 446 deletions
diff --git a/stats/BUILD.gn b/stats/BUILD.gn index 37224cd618..b2a0c20473 100644 --- a/stats/BUILD.gn +++ b/stats/BUILD.gn @@ -24,7 +24,8 @@ rtc_library("rtc_stats") { deps = [ "../api:rtc_stats_api", "../rtc_base:checks", - "../rtc_base:rtc_base_approved", + "../rtc_base:macromagic", + "../rtc_base:stringutils", ] } @@ -44,7 +45,7 @@ rtc_library("rtc_stats_test_utils") { ] } -if (rtc_include_tests) { +if (rtc_include_tests && !build_with_chromium) { rtc_test("rtc_stats_unittests") { testonly = true sources = [ @@ -58,14 +59,18 @@ if (rtc_include_tests) { "../api:rtc_stats_api", "../rtc_base:checks", "../rtc_base:gunit_helpers", - "../rtc_base:rtc_base_approved", "../rtc_base:rtc_json", "../test:test_main", "../test:test_support", ] if (is_android) { - deps += [ "//testing/android/native_test:native_test_native_code" ] + use_default_launcher = false + deps += [ + "//build/android/gtest_apk:native_test_instrumentation_test_runner_java", + "//testing/android/native_test:native_test_java", + "//testing/android/native_test:native_test_support", + ] } } } diff --git a/stats/g3doc/stats.md b/stats/g3doc/stats.md new file mode 100644 index 0000000000..790e101727 --- /dev/null +++ b/stats/g3doc/stats.md @@ -0,0 +1,18 @@ +<?% config.freshness.reviewed = '2022-10-01' %?>
+<?% config.freshness.owner = 'hta' %?>
+
+# getStats in WebRTC
+
+The WebRTC getStats API is specified in
+ https://w3c.github.io/webrtc-stats/
+and allows querying information about the current state of a RTCPeerConnection
+API and some of its member objects.
+
+## Adding new statistics to Chrome
+
+When adding a new standardized `RTCStatsMember` it is necessary to add
+it to the Chrome allowlist
+ chrome/test/data/webrtc/peerconnection_getstats.js
+before landing the WebRTC change. This mechanism prevents the accidential
+addition and exposure of non-standard attributes and is not required for
+`RTCNonStandardStatsMember` which is not exposed to the web API.
\ No newline at end of file diff --git a/stats/rtc_stats.cc b/stats/rtc_stats.cc index b8e9633f46..ae352fa170 100644 --- a/stats/rtc_stats.cc +++ b/stats/rtc_stats.cc @@ -20,7 +20,7 @@ namespace webrtc { namespace { -// Produces "[a,b,c]". Works for non-vector |RTCStatsMemberInterface::Type| +// Produces "[a,b,c]". Works for non-vector `RTCStatsMemberInterface::Type` // types. template <typename T> std::string VectorToString(const std::vector<T>& vector) { @@ -35,6 +35,20 @@ std::string VectorToString(const std::vector<T>& vector) { return sb.Release(); } +// This overload is required because std::vector<bool> range loops don't +// return references but objects, causing -Wrange-loop-analysis diagnostics. +std::string VectorToString(const std::vector<bool>& vector) { + rtc::StringBuilder sb; + sb << "["; + const char* separator = ""; + for (bool element : vector) { + sb << separator << rtc::ToString(element); + separator = ","; + } + sb << "]"; + return sb.Release(); +} + // Produces "[\"a\",\"b\",\"c\"]". Works for vectors of both const char* and // std::string element types. template <typename T> @@ -51,6 +65,20 @@ std::string VectorOfStringsToString(const std::vector<T>& strings) { } template <typename T> +std::string MapToString(const std::map<std::string, T>& map) { + rtc::StringBuilder sb; + sb << "{"; + const char* separator = ""; + for (const auto& element : map) { + sb << separator << rtc::ToString(element.first) << ":" + << rtc::ToString(element.second); + separator = ","; + } + sb << "}"; + return sb.Release(); +} + +template <typename T> std::string ToStringAsDouble(const T value) { // JSON represents numbers as floating point numbers with about 15 decimal // digits of precision. @@ -74,6 +102,20 @@ std::string VectorToStringAsDouble(const std::vector<T>& vector) { return sb.Release(); } +template <typename T> +std::string MapToStringAsDouble(const std::map<std::string, T>& map) { + rtc::StringBuilder sb; + sb << "{"; + const char* separator = ""; + for (const auto& element : map) { + sb << separator << "\"" << rtc::ToString(element.first) + << "\":" << ToStringAsDouble(element.second); + separator = ","; + } + sb << "}"; + return sb.Release(); +} + } // namespace bool RTCStats::operator==(const RTCStats& other) const { @@ -145,12 +187,12 @@ RTCStats::MembersOfThisObjectAndAncestors(size_t additional_capacity) const { } \ template <> \ std::string RTCStatsMember<T>::ValueToString() const { \ - RTC_DCHECK(is_defined_); \ + RTC_DCHECK(value_.has_value()); \ return to_str; \ } \ template <> \ std::string RTCStatsMember<T>::ValueToJson() const { \ - RTC_DCHECK(is_defined_); \ + RTC_DCHECK(value_.has_value()); \ return to_json; \ } \ template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) RTCStatsMember<T> @@ -159,81 +201,146 @@ WEBRTC_DEFINE_RTCSTATSMEMBER(bool, kBool, false, false, - rtc::ToString(value_), - rtc::ToString(value_)); + rtc::ToString(*value_), + rtc::ToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(int32_t, kInt32, false, false, - rtc::ToString(value_), - rtc::ToString(value_)); + rtc::ToString(*value_), + rtc::ToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(uint32_t, kUint32, false, false, - rtc::ToString(value_), - rtc::ToString(value_)); + rtc::ToString(*value_), + rtc::ToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(int64_t, kInt64, false, false, - rtc::ToString(value_), - ToStringAsDouble(value_)); + rtc::ToString(*value_), + ToStringAsDouble(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(uint64_t, kUint64, false, false, - rtc::ToString(value_), - ToStringAsDouble(value_)); + rtc::ToString(*value_), + ToStringAsDouble(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(double, kDouble, false, false, - rtc::ToString(value_), - ToStringAsDouble(value_)); -WEBRTC_DEFINE_RTCSTATSMEMBER(std::string, kString, false, true, value_, value_); + rtc::ToString(*value_), + ToStringAsDouble(*value_)); +WEBRTC_DEFINE_RTCSTATSMEMBER(std::string, + kString, + false, + true, + *value_, + *value_); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<bool>, kSequenceBool, true, false, - VectorToString(value_), - VectorToString(value_)); + VectorToString(*value_), + VectorToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<int32_t>, kSequenceInt32, true, false, - VectorToString(value_), - VectorToString(value_)); + VectorToString(*value_), + VectorToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<uint32_t>, kSequenceUint32, true, false, - VectorToString(value_), - VectorToString(value_)); + VectorToString(*value_), + VectorToString(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<int64_t>, kSequenceInt64, true, false, - VectorToString(value_), - VectorToStringAsDouble(value_)); + VectorToString(*value_), + VectorToStringAsDouble(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<uint64_t>, kSequenceUint64, true, false, - VectorToString(value_), - VectorToStringAsDouble(value_)); + VectorToString(*value_), + VectorToStringAsDouble(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<double>, kSequenceDouble, true, false, - VectorToString(value_), - VectorToStringAsDouble(value_)); + VectorToString(*value_), + VectorToStringAsDouble(*value_)); WEBRTC_DEFINE_RTCSTATSMEMBER(std::vector<std::string>, kSequenceString, true, false, - VectorOfStringsToString(value_), - VectorOfStringsToString(value_)); + VectorOfStringsToString(*value_), + VectorOfStringsToString(*value_)); +WEBRTC_DEFINE_RTCSTATSMEMBER(rtc_stats_internal::MapStringUint64, + kMapStringUint64, + false, + false, + MapToString(*value_), + MapToStringAsDouble(*value_)); +WEBRTC_DEFINE_RTCSTATSMEMBER(rtc_stats_internal::MapStringDouble, + kMapStringDouble, + false, + false, + MapToString(*value_), + MapToStringAsDouble(*value_)); + +// Restricted members that expose hardware capabilites. +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<int32_t, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<uint32_t, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<int64_t, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<uint64_t, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<double, StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::string, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<bool>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<int32_t>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<uint32_t>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<int64_t>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<uint64_t>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<double>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::vector<std::string>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::map<std::string, uint64_t>, + StatExposureCriteria::kHardwareCapability>; +template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) + RTCRestrictedStatsMember<std::map<std::string, double>, + StatExposureCriteria::kHardwareCapability>; template class RTC_EXPORT_TEMPLATE_DEFINE(RTC_EXPORT) RTCNonStandardStatsMember<bool>; diff --git a/stats/rtc_stats_report.cc b/stats/rtc_stats_report.cc index a56d30d3c3..f6fbd8c44d 100644 --- a/stats/rtc_stats_report.cc +++ b/stats/rtc_stats_report.cc @@ -56,17 +56,20 @@ bool RTCStatsReport::ConstIterator::operator!=( rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create( int64_t timestamp_us) { - return rtc::scoped_refptr<RTCStatsReport>( - new rtc::RefCountedObject<RTCStatsReport>(timestamp_us)); + return rtc::scoped_refptr<RTCStatsReport>(new RTCStatsReport(timestamp_us)); +} + +rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create(Timestamp timestamp) { + return rtc::scoped_refptr<RTCStatsReport>(new RTCStatsReport(timestamp)); } RTCStatsReport::RTCStatsReport(int64_t timestamp_us) - : timestamp_us_(timestamp_us) {} + : RTCStatsReport(Timestamp::Micros(timestamp_us)) {} -RTCStatsReport::~RTCStatsReport() {} +RTCStatsReport::RTCStatsReport(Timestamp timestamp) : timestamp_(timestamp) {} rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Copy() const { - rtc::scoped_refptr<RTCStatsReport> copy = Create(timestamp_us_); + rtc::scoped_refptr<RTCStatsReport> copy = Create(timestamp_); for (auto it = stats_.begin(); it != stats_.end(); ++it) { copy->AddStats(it->second->copy()); } @@ -74,12 +77,15 @@ rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Copy() const { } void RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) { +#if RTC_DCHECK_IS_ON auto result = +#endif stats_.insert(std::make_pair(std::string(stats->id()), std::move(stats))); +#if RTC_DCHECK_IS_ON RTC_DCHECK(result.second) - << "A stats object with ID " << result.first->second->id() - << " is already " - "present in this stats report."; + << "A stats object with ID \"" << result.first->second->id() << "\" is " + << "already present in this stats report."; +#endif } const RTCStats* RTCStatsReport::Get(const std::string& id) const { @@ -98,13 +104,12 @@ std::unique_ptr<const RTCStats> RTCStatsReport::Take(const std::string& id) { return stats; } -void RTCStatsReport::TakeMembersFrom( - rtc::scoped_refptr<RTCStatsReport> victim) { - for (StatsMap::iterator it = victim->stats_.begin(); - it != victim->stats_.end(); ++it) { +void RTCStatsReport::TakeMembersFrom(rtc::scoped_refptr<RTCStatsReport> other) { + for (StatsMap::iterator it = other->stats_.begin(); it != other->stats_.end(); + ++it) { AddStats(std::unique_ptr<const RTCStats>(it->second.release())); } - victim->stats_.clear(); + other->stats_.clear(); } RTCStatsReport::ConstIterator RTCStatsReport::begin() const { diff --git a/stats/rtc_stats_report_unittest.cc b/stats/rtc_stats_report_unittest.cc index 2081364f66..8af6dbe620 100644 --- a/stats/rtc_stats_report_unittest.cc +++ b/stats/rtc_stats_report_unittest.cc @@ -53,8 +53,10 @@ class RTCTestStats3 : public RTCStats { WEBRTC_RTCSTATS_IMPL(RTCTestStats3, RTCStats, "test-stats-3", &string) TEST(RTCStatsReport, AddAndGetStats) { - rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create(1337); + rtc::scoped_refptr<RTCStatsReport> report = + RTCStatsReport::Create(Timestamp::Micros(1337)); EXPECT_EQ(report->timestamp_us(), 1337u); + EXPECT_EQ(report->timestamp().us_or(-1), 1337u); EXPECT_EQ(report->size(), static_cast<size_t>(0)); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("a0", 1))); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("a1", 2))); @@ -87,8 +89,10 @@ TEST(RTCStatsReport, AddAndGetStats) { } TEST(RTCStatsReport, StatsOrder) { - rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create(1337); + rtc::scoped_refptr<RTCStatsReport> report = + RTCStatsReport::Create(Timestamp::Micros(1337)); EXPECT_EQ(report->timestamp_us(), 1337u); + EXPECT_EQ(report->timestamp().us_or(-1), 1337u); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("C", 2))); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("D", 3))); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats2("B", 1))); @@ -105,7 +109,8 @@ TEST(RTCStatsReport, StatsOrder) { } TEST(RTCStatsReport, Take) { - rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create(0); + rtc::scoped_refptr<RTCStatsReport> report = + RTCStatsReport::Create(Timestamp::Zero()); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("A", 1))); report->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("B", 2))); EXPECT_TRUE(report->Get("A")); @@ -118,13 +123,17 @@ TEST(RTCStatsReport, Take) { } TEST(RTCStatsReport, TakeMembersFrom) { - rtc::scoped_refptr<RTCStatsReport> a = RTCStatsReport::Create(1337); + rtc::scoped_refptr<RTCStatsReport> a = + RTCStatsReport::Create(Timestamp::Micros(1337)); EXPECT_EQ(a->timestamp_us(), 1337u); + EXPECT_EQ(a->timestamp().us_or(-1), 1337u); a->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("B", 1))); a->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("C", 2))); a->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("E", 4))); - rtc::scoped_refptr<RTCStatsReport> b = RTCStatsReport::Create(1338); + rtc::scoped_refptr<RTCStatsReport> b = + RTCStatsReport::Create(Timestamp::Micros(1338)); EXPECT_EQ(b->timestamp_us(), 1338u); + EXPECT_EQ(b->timestamp().us_or(-1), 1338u); b->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("A", 0))); b->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("D", 3))); b->AddStats(std::unique_ptr<RTCStats>(new RTCTestStats1("F", 5))); diff --git a/stats/rtc_stats_unittest.cc b/stats/rtc_stats_unittest.cc index b159977858..5d3857f327 100644 --- a/stats/rtc_stats_unittest.cc +++ b/stats/rtc_stats_unittest.cc @@ -71,7 +71,7 @@ TEST(RTCStatsTest, RTCStatsAndMembers) { EXPECT_EQ(stats.id(), "testId"); EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42)); std::vector<const RTCStatsMemberInterface*> members = stats.Members(); - EXPECT_EQ(members.size(), static_cast<size_t>(14)); + EXPECT_EQ(members.size(), static_cast<size_t>(16)); for (const RTCStatsMemberInterface* member : members) { EXPECT_FALSE(member->is_defined()); } @@ -98,6 +98,9 @@ TEST(RTCStatsTest, RTCStatsAndMembers) { std::vector<std::string> sequence_string; sequence_string.push_back(std::string("six")); + std::map<std::string, uint64_t> map_string_uint64{{"seven", 8}}; + std::map<std::string, double> map_string_double{{"nine", 10.0}}; + stats.m_sequence_bool = sequence_bool; stats.m_sequence_int32 = sequence_int32; stats.m_sequence_uint32 = sequence_uint32; @@ -106,6 +109,8 @@ TEST(RTCStatsTest, RTCStatsAndMembers) { stats.m_sequence_uint64 = sequence_uint64; stats.m_sequence_double = sequence_double; stats.m_sequence_string = sequence_string; + stats.m_map_string_uint64 = map_string_uint64; + stats.m_map_string_double = map_string_double; for (const RTCStatsMemberInterface* member : members) { EXPECT_TRUE(member->is_defined()); } @@ -123,6 +128,8 @@ TEST(RTCStatsTest, RTCStatsAndMembers) { EXPECT_EQ(*stats.m_sequence_uint64, sequence_uint64); EXPECT_EQ(*stats.m_sequence_double, sequence_double); EXPECT_EQ(*stats.m_sequence_string, sequence_string); + EXPECT_EQ(*stats.m_map_string_uint64, map_string_uint64); + EXPECT_EQ(*stats.m_map_string_double, map_string_double); int32_t numbers[] = {4, 8, 15, 16, 23, 42}; std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[6]); @@ -152,6 +159,8 @@ TEST(RTCStatsTest, EqualityOperator) { stats_with_all_values.m_sequence_uint64 = std::vector<uint64_t>(); stats_with_all_values.m_sequence_double = std::vector<double>(); stats_with_all_values.m_sequence_string = std::vector<std::string>(); + stats_with_all_values.m_map_string_uint64 = std::map<std::string, uint64_t>(); + stats_with_all_values.m_map_string_double = std::map<std::string, double>(); EXPECT_NE(stats_with_all_values, empty_stats); EXPECT_EQ(stats_with_all_values, stats_with_all_values); EXPECT_NE(stats_with_all_values.m_int32, stats_with_all_values.m_uint32); @@ -180,6 +189,8 @@ TEST(RTCStatsTest, EqualityOperator) { one_member_different[11].m_sequence_uint64->push_back(321); one_member_different[12].m_sequence_double->push_back(321.0); one_member_different[13].m_sequence_string->push_back("321"); + (*one_member_different[13].m_map_string_uint64)["321"] = 321; + (*one_member_different[13].m_map_string_double)["321"] = 321.0; for (size_t i = 0; i < 14; ++i) { EXPECT_NE(stats_with_all_values, one_member_different[i]); } @@ -238,6 +249,11 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { std::vector<std::string> sequence_string; sequence_string.push_back(std::string("four")); + std::map<std::string, uint64_t> map_string_uint64{ + {"long", static_cast<uint64_t>(1234567890123456499L)}}; + std::map<std::string, double> map_string_double{ + {"three", 123.4567890123456499}, {"thirteen", 123.4567890123456499}}; + RTCTestStats stats(id, timestamp); stats.m_bool = m_bool; stats.m_int32 = m_int32; @@ -249,9 +265,16 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { stats.m_sequence_int64 = sequence_int64; stats.m_sequence_double = sequence_double; stats.m_sequence_string = sequence_string; + stats.m_map_string_uint64 = map_string_uint64; + stats.m_map_string_double = map_string_double; + std::string json_stats = stats.ToJson(); + Json::CharReaderBuilder builder; Json::Value json_output; - EXPECT_TRUE(Json::Reader().parse(stats.ToJson(), json_output)); + std::unique_ptr<Json::CharReader> json_reader(builder.newCharReader()); + EXPECT_TRUE(json_reader->parse(json_stats.c_str(), + 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)); @@ -278,6 +301,16 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { rtc::GetValueFromJsonObject(json_output, "mSequenceString", &json_array)); EXPECT_TRUE(rtc::JsonArrayToStringVector(json_array, &sequence_string)); + Json::Value json_map; + EXPECT_TRUE( + rtc::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_NEAR(double_output, entry.second, GetExpectedError(entry.second)); + } + EXPECT_EQ(id, stats.id()); EXPECT_EQ(timestamp, stats.timestamp_us()); EXPECT_EQ(m_bool, *stats.m_bool); @@ -286,6 +319,7 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { EXPECT_EQ(sequence_bool, *stats.m_sequence_bool); EXPECT_EQ(sequence_int32, *stats.m_sequence_int32); EXPECT_EQ(sequence_string, *stats.m_sequence_string); + EXPECT_EQ(map_string_double, *stats.m_map_string_double); EXPECT_NEAR(m_double, *stats.m_double, GetExpectedError(*stats.m_double)); @@ -295,6 +329,13 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { GetExpectedError(stats.m_sequence_double->at(i))); } + EXPECT_EQ(map_string_double.size(), stats.m_map_string_double->size()); + for (const auto& entry : map_string_double) { + auto it = stats.m_map_string_double->find(entry.first); + EXPECT_NE(it, stats.m_map_string_double->end()); + EXPECT_NEAR(entry.second, it->second, GetExpectedError(it->second)); + } + // We read mInt64 as double since JSON stores all numbers as doubles, so there // is not enough precision to represent large numbers. double m_int64_as_double; @@ -320,6 +361,19 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) { GetExpectedError(stats_value_as_double)); } + // Similarly, read Uint64 as double + EXPECT_TRUE( + rtc::GetValueFromJsonObject(json_output, "mMapStringUint64", &json_map)); + for (const auto& entry : map_string_uint64) { + const double stats_value_as_double = + static_cast<double>((*stats.m_map_string_uint64)[entry.first]); + double double_output = 0.0; + EXPECT_TRUE( + rtc::GetDoubleFromJsonObject(json_map, entry.first, &double_output)); + EXPECT_NEAR(double_output, stats_value_as_double, + GetExpectedError(stats_value_as_double)); + } + // Neither stats.m_uint32 nor stats.m_uint64 are defined, so "mUint64" and // "mUint32" should not be part of the generated JSON object. int m_uint32; @@ -339,6 +393,130 @@ TEST(RTCStatsTest, IsStandardized) { EXPECT_FALSE(unstandardized.is_standardized()); } +TEST(RTCStatsTest, IsSequence) { + RTCTestStats stats("statsId", 42); + EXPECT_FALSE(stats.m_bool.is_sequence()); + EXPECT_FALSE(stats.m_int32.is_sequence()); + EXPECT_FALSE(stats.m_uint32.is_sequence()); + EXPECT_FALSE(stats.m_int64.is_sequence()); + EXPECT_FALSE(stats.m_uint64.is_sequence()); + EXPECT_FALSE(stats.m_double.is_sequence()); + EXPECT_FALSE(stats.m_string.is_sequence()); + EXPECT_TRUE(stats.m_sequence_bool.is_sequence()); + EXPECT_TRUE(stats.m_sequence_int32.is_sequence()); + EXPECT_TRUE(stats.m_sequence_uint32.is_sequence()); + EXPECT_TRUE(stats.m_sequence_int64.is_sequence()); + EXPECT_TRUE(stats.m_sequence_uint64.is_sequence()); + EXPECT_TRUE(stats.m_sequence_double.is_sequence()); + EXPECT_TRUE(stats.m_sequence_string.is_sequence()); + EXPECT_FALSE(stats.m_map_string_uint64.is_sequence()); + EXPECT_FALSE(stats.m_map_string_double.is_sequence()); +} + +TEST(RTCStatsTest, Type) { + RTCTestStats stats("statsId", 42); + EXPECT_EQ(RTCStatsMemberInterface::kBool, stats.m_bool.type()); + EXPECT_EQ(RTCStatsMemberInterface::kInt32, stats.m_int32.type()); + EXPECT_EQ(RTCStatsMemberInterface::kUint32, stats.m_uint32.type()); + EXPECT_EQ(RTCStatsMemberInterface::kInt64, stats.m_int64.type()); + EXPECT_EQ(RTCStatsMemberInterface::kUint64, stats.m_uint64.type()); + EXPECT_EQ(RTCStatsMemberInterface::kDouble, stats.m_double.type()); + EXPECT_EQ(RTCStatsMemberInterface::kString, stats.m_string.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceBool, + stats.m_sequence_bool.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceInt32, + stats.m_sequence_int32.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceUint32, + stats.m_sequence_uint32.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceInt64, + stats.m_sequence_int64.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceUint64, + stats.m_sequence_uint64.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceDouble, + stats.m_sequence_double.type()); + EXPECT_EQ(RTCStatsMemberInterface::kSequenceString, + stats.m_sequence_string.type()); + EXPECT_EQ(RTCStatsMemberInterface::kMapStringUint64, + stats.m_map_string_uint64.type()); + EXPECT_EQ(RTCStatsMemberInterface::kMapStringDouble, + stats.m_map_string_double.type()); +} + +TEST(RTCStatsTest, IsString) { + RTCTestStats stats("statsId", 42); + EXPECT_TRUE(stats.m_string.is_string()); + EXPECT_FALSE(stats.m_bool.is_string()); + EXPECT_FALSE(stats.m_int32.is_string()); + EXPECT_FALSE(stats.m_uint32.is_string()); + EXPECT_FALSE(stats.m_int64.is_string()); + EXPECT_FALSE(stats.m_uint64.is_string()); + EXPECT_FALSE(stats.m_double.is_string()); + EXPECT_FALSE(stats.m_sequence_bool.is_string()); + EXPECT_FALSE(stats.m_sequence_int32.is_string()); + EXPECT_FALSE(stats.m_sequence_uint32.is_string()); + EXPECT_FALSE(stats.m_sequence_int64.is_string()); + EXPECT_FALSE(stats.m_sequence_uint64.is_string()); + EXPECT_FALSE(stats.m_sequence_double.is_string()); + EXPECT_FALSE(stats.m_sequence_string.is_string()); + EXPECT_FALSE(stats.m_map_string_uint64.is_string()); + EXPECT_FALSE(stats.m_map_string_double.is_string()); +} + +TEST(RTCStatsTest, ValueToString) { + RTCTestStats stats("statsId", 42); + stats.m_bool = true; + EXPECT_EQ("true", stats.m_bool.ValueToString()); + + stats.m_string = "foo"; + EXPECT_EQ("foo", stats.m_string.ValueToString()); + stats.m_int32 = -32; + EXPECT_EQ("-32", stats.m_int32.ValueToString()); + stats.m_uint32 = 32; + EXPECT_EQ("32", stats.m_uint32.ValueToString()); + stats.m_int64 = -64; + EXPECT_EQ("-64", stats.m_int64.ValueToString()); + stats.m_uint64 = 64; + EXPECT_EQ("64", stats.m_uint64.ValueToString()); + stats.m_double = 0.5; + EXPECT_EQ("0.5", stats.m_double.ValueToString()); + stats.m_sequence_bool = {true, false}; + EXPECT_EQ("[true,false]", stats.m_sequence_bool.ValueToString()); + stats.m_sequence_int32 = {-32, 32}; + EXPECT_EQ("[-32,32]", stats.m_sequence_int32.ValueToString()); + stats.m_sequence_uint32 = {64, 32}; + EXPECT_EQ("[64,32]", stats.m_sequence_uint32.ValueToString()); + stats.m_sequence_int64 = {-64, 32}; + EXPECT_EQ("[-64,32]", stats.m_sequence_int64.ValueToString()); + stats.m_sequence_uint64 = {16, 32}; + EXPECT_EQ("[16,32]", stats.m_sequence_uint64.ValueToString()); + stats.m_sequence_double = {0.5, 0.25}; + EXPECT_EQ("[0.5,0.25]", stats.m_sequence_double.ValueToString()); + stats.m_sequence_string = {"foo", "bar"}; + EXPECT_EQ("[\"foo\",\"bar\"]", stats.m_sequence_string.ValueToString()); + stats.m_map_string_uint64 = std::map<std::string, uint64_t>(); + stats.m_map_string_uint64->emplace("foo", 32); + stats.m_map_string_uint64->emplace("bar", 64); + EXPECT_EQ("{bar:64,foo:32}", stats.m_map_string_uint64.ValueToString()); + stats.m_map_string_double = std::map<std::string, double>(); + stats.m_map_string_double->emplace("foo", 0.5); + stats.m_map_string_double->emplace("bar", 0.25); + EXPECT_EQ("{bar:0.25,foo:0.5}", stats.m_map_string_double.ValueToString()); +} + +TEST(RTCStatsTest, RestrictedStatsTest) { + RTCStatsMember<bool> unrestricted("unrestricted"); + EXPECT_EQ(unrestricted.exposure_criteria(), StatExposureCriteria::kAlways); + RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability> + restricted("restricted"); + EXPECT_EQ(restricted.exposure_criteria(), + StatExposureCriteria::kHardwareCapability); + + unrestricted = true; + restricted = true; + EXPECT_NE(unrestricted, restricted) + << "These can not be equal as they have different exposure criteria."; +} + TEST(RTCStatsTest, NonStandardGroupId) { auto group_id = NonStandardGroupId::kGroupIdForTesting; RTCNonStandardStatsMember<int32_t> with_group_id("stat", {group_id}); diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 2fe85468c8..7c20b87562 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -62,6 +62,25 @@ const char* const RTCQualityLimitationReason::kOther = "other"; const char* const RTCContentType::kUnspecified = "unspecified"; const char* const RTCContentType::kScreenshare = "screenshare"; +// https://w3c.github.io/webrtc-stats/#dom-rtcdtlsrole +const char* const RTCDtlsRole::kUnknown = "unknown"; +const char* const RTCDtlsRole::kClient = "client"; +const char* const RTCDtlsRole::kServer = "server"; + +// https://www.w3.org/TR/webrtc/#rtcicerole +const char* const RTCIceRole::kUnknown = "unknown"; +const char* const RTCIceRole::kControlled = "controlled"; +const char* const RTCIceRole::kControlling = "controlling"; + +// https://www.w3.org/TR/webrtc/#dom-rtcicetransportstate +const char* const RTCIceTransportState::kNew = "new"; +const char* const RTCIceTransportState::kChecking = "checking"; +const char* const RTCIceTransportState::kConnected = "connected"; +const char* const RTCIceTransportState::kCompleted = "completed"; +const char* const RTCIceTransportState::kDisconnected = "disconnected"; +const char* const RTCIceTransportState::kFailed = "failed"; +const char* const RTCIceTransportState::kClosed = "closed"; + // clang-format off WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate", &fingerprint, @@ -81,17 +100,13 @@ RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us) base64_certificate("base64Certificate"), issuer_certificate_id("issuerCertificateId") {} -RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) - : RTCStats(other.id(), other.timestamp_us()), - fingerprint(other.fingerprint), - fingerprint_algorithm(other.fingerprint_algorithm), - base64_certificate(other.base64_certificate), - issuer_certificate_id(other.issuer_certificate_id) {} - +RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) = + default; RTCCertificateStats::~RTCCertificateStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec", + &transport_id, &payload_type, &mime_type, &clock_rate, @@ -104,19 +119,14 @@ RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us) RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), + transport_id("transportId"), payload_type("payloadType"), mime_type("mimeType"), clock_rate("clockRate"), channels("channels"), sdp_fmtp_line("sdpFmtpLine") {} -RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) - : RTCStats(other.id(), other.timestamp_us()), - payload_type(other.payload_type), - mime_type(other.mime_type), - clock_rate(other.clock_rate), - channels(other.channels), - sdp_fmtp_line(other.sdp_fmtp_line) {} +RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) = default; RTCCodecStats::~RTCCodecStats() {} @@ -147,16 +157,8 @@ RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us) messages_received("messagesReceived"), bytes_received("bytesReceived") {} -RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) - : RTCStats(other.id(), other.timestamp_us()), - label(other.label), - protocol(other.protocol), - data_channel_identifier(other.data_channel_identifier), - state(other.state), - messages_sent(other.messages_sent), - bytes_sent(other.bytes_sent), - messages_received(other.messages_received), - bytes_received(other.bytes_received) {} +RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) = + default; RTCDataChannelStats::~RTCDataChannelStats() {} @@ -169,7 +171,8 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair", &priority, &nominated, &writable, - &readable, + &packets_sent, + &packets_received, &bytes_sent, &bytes_received, &total_round_trip_time, @@ -180,12 +183,11 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair", &requests_sent, &responses_received, &responses_sent, - &retransmissions_received, - &retransmissions_sent, - &consent_requests_received, &consent_requests_sent, - &consent_responses_received, - &consent_responses_sent) + &packets_discarded_on_send, + &bytes_discarded_on_send, + &last_packet_received_timestamp, + &last_packet_sent_timestamp) // clang-format on RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id, @@ -202,7 +204,8 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id, priority("priority"), nominated("nominated"), writable("writable"), - readable("readable"), + packets_sent("packetsSent"), + packets_received("packetsReceived"), bytes_sent("bytesSent"), bytes_received("bytesReceived"), total_round_trip_time("totalRoundTripTime"), @@ -213,40 +216,14 @@ RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id, requests_sent("requestsSent"), responses_received("responsesReceived"), responses_sent("responsesSent"), - retransmissions_received("retransmissionsReceived"), - retransmissions_sent("retransmissionsSent"), - consent_requests_received("consentRequestsReceived"), consent_requests_sent("consentRequestsSent"), - consent_responses_received("consentResponsesReceived"), - consent_responses_sent("consentResponsesSent") {} + packets_discarded_on_send("packetsDiscardedOnSend"), + bytes_discarded_on_send("bytesDiscardedOnSend"), + last_packet_received_timestamp("lastPacketReceivedTimestamp"), + last_packet_sent_timestamp("lastPacketSentTimestamp") {} RTCIceCandidatePairStats::RTCIceCandidatePairStats( - const RTCIceCandidatePairStats& other) - : RTCStats(other.id(), other.timestamp_us()), - transport_id(other.transport_id), - local_candidate_id(other.local_candidate_id), - remote_candidate_id(other.remote_candidate_id), - state(other.state), - priority(other.priority), - nominated(other.nominated), - writable(other.writable), - readable(other.readable), - bytes_sent(other.bytes_sent), - bytes_received(other.bytes_received), - total_round_trip_time(other.total_round_trip_time), - current_round_trip_time(other.current_round_trip_time), - available_outgoing_bitrate(other.available_outgoing_bitrate), - available_incoming_bitrate(other.available_incoming_bitrate), - requests_received(other.requests_received), - requests_sent(other.requests_sent), - responses_received(other.responses_received), - responses_sent(other.responses_sent), - retransmissions_received(other.retransmissions_received), - retransmissions_sent(other.retransmissions_sent), - consent_requests_received(other.consent_requests_received), - consent_requests_sent(other.consent_requests_sent), - consent_responses_received(other.consent_responses_received), - consent_responses_sent(other.consent_responses_sent) {} + const RTCIceCandidatePairStats& other) = default; RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {} @@ -256,13 +233,20 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", &is_remote, &network_type, &ip, + &address, &port, &protocol, &relay_protocol, &candidate_type, &priority, &url, - &deleted) + &foundation, + &related_address, + &related_port, + &username_fragment, + &tcp_type, + &vpn, + &network_adapter_type) // clang-format on RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id, @@ -278,27 +262,23 @@ RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id, is_remote("isRemote", is_remote), network_type("networkType"), ip("ip"), + address("address"), port("port"), protocol("protocol"), relay_protocol("relayProtocol"), candidate_type("candidateType"), priority("priority"), url("url"), - deleted("deleted", false) {} - -RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) - : RTCStats(other.id(), other.timestamp_us()), - transport_id(other.transport_id), - is_remote(other.is_remote), - network_type(other.network_type), - ip(other.ip), - port(other.port), - protocol(other.protocol), - relay_protocol(other.relay_protocol), - candidate_type(other.candidate_type), - priority(other.priority), - url(other.url), - deleted(other.deleted) {} + foundation("foundation"), + related_address("relatedAddress"), + related_port("relatedPort"), + username_fragment("usernameFragment"), + tcp_type("tcpType"), + vpn("vpn"), + network_adapter_type("networkAdapterType") {} + +RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) = + default; RTCIceCandidateStats::~RTCIceCandidateStats() {} @@ -313,7 +293,7 @@ RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id, : RTCIceCandidateStats(std::move(id), timestamp_us, false) {} std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const { - return std::unique_ptr<RTCStats>(new RTCLocalIceCandidateStats(*this)); + return std::make_unique<RTCLocalIceCandidateStats>(*this); } const char* RTCLocalIceCandidateStats::type() const { @@ -331,7 +311,7 @@ RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id, : RTCIceCandidateStats(std::move(id), timestamp_us, true) {} std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const { - return std::unique_ptr<RTCStats>(new RTCRemoteIceCandidateStats(*this)); + return std::make_unique<RTCRemoteIceCandidateStats>(*this); } const char* RTCRemoteIceCandidateStats::type() const { @@ -339,29 +319,30 @@ const char* RTCRemoteIceCandidateStats::type() const { } // clang-format off -WEBRTC_RTCSTATS_IMPL(RTCMediaStreamStats, RTCStats, "stream", +WEBRTC_RTCSTATS_IMPL(DEPRECATED_RTCMediaStreamStats, RTCStats, "stream", &stream_identifier, &track_ids) // clang-format on -RTCMediaStreamStats::RTCMediaStreamStats(const std::string& id, - int64_t timestamp_us) - : RTCMediaStreamStats(std::string(id), timestamp_us) {} +DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats( + const std::string& id, + int64_t timestamp_us) + : DEPRECATED_RTCMediaStreamStats(std::string(id), timestamp_us) {} -RTCMediaStreamStats::RTCMediaStreamStats(std::string&& id, int64_t timestamp_us) +DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats( + std::string&& id, + int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), stream_identifier("streamIdentifier"), track_ids("trackIds") {} -RTCMediaStreamStats::RTCMediaStreamStats(const RTCMediaStreamStats& other) - : RTCStats(other.id(), other.timestamp_us()), - stream_identifier(other.stream_identifier), - track_ids(other.track_ids) {} +DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats( + const DEPRECATED_RTCMediaStreamStats& other) = default; -RTCMediaStreamStats::~RTCMediaStreamStats() {} +DEPRECATED_RTCMediaStreamStats::~DEPRECATED_RTCMediaStreamStats() {} // clang-format off -WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track", +WEBRTC_RTCSTATS_IMPL(DEPRECATED_RTCMediaStreamTrackStats, RTCStats, "track", &track_identifier, &media_source_id, &remote_source, @@ -372,15 +353,11 @@ WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track", &jitter_buffer_emitted_count, &frame_width, &frame_height, - &frames_per_second, &frames_sent, &huge_frames_sent, &frames_received, &frames_decoded, &frames_dropped, - &frames_corrupted, - &partial_frames_lost, - &full_frames_lost, &audio_level, &total_audio_energy, &echo_return_loss, @@ -391,29 +368,20 @@ WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track", &silent_concealed_samples, &concealment_events, &inserted_samples_for_deceleration, - &removed_samples_for_acceleration, - &jitter_buffer_flushes, - &delayed_packet_outage_samples, - &relative_packet_arrival_delay, - &jitter_buffer_target_delay, - &interruption_count, - &total_interruption_duration, - &freeze_count, - &pause_count, - &total_freezes_duration, - &total_pauses_duration, - &total_frames_duration, - &sum_squared_frame_durations) + &removed_samples_for_acceleration) // clang-format on -RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(const std::string& id, - int64_t timestamp_us, - const char* kind) - : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {} +DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats( + const std::string& id, + int64_t timestamp_us, + const char* kind) + : DEPRECATED_RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) { +} -RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id, - int64_t timestamp_us, - const char* kind) +DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats( + std::string&& id, + int64_t timestamp_us, + const char* kind) : RTCStats(std::move(id), timestamp_us), track_identifier("trackIdentifier"), media_source_id("mediaSourceId"), @@ -425,15 +393,11 @@ RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id, jitter_buffer_emitted_count("jitterBufferEmittedCount"), frame_width("frameWidth"), frame_height("frameHeight"), - frames_per_second("framesPerSecond"), frames_sent("framesSent"), huge_frames_sent("hugeFramesSent"), frames_received("framesReceived"), frames_decoded("framesDecoded"), frames_dropped("framesDropped"), - frames_corrupted("framesCorrupted"), - partial_frames_lost("partialFramesLost"), - full_frames_lost("fullFramesLost"), audio_level("audioLevel"), total_audio_energy("totalAudioEnergy"), echo_return_loss("echoReturnLoss"), @@ -444,78 +408,15 @@ RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id, silent_concealed_samples("silentConcealedSamples"), concealment_events("concealmentEvents"), inserted_samples_for_deceleration("insertedSamplesForDeceleration"), - removed_samples_for_acceleration("removedSamplesForAcceleration"), - jitter_buffer_flushes( - "jitterBufferFlushes", - {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}), - delayed_packet_outage_samples( - "delayedPacketOutageSamples", - {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets, - NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}), - relative_packet_arrival_delay( - "relativePacketArrivalDelay", - {NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}), - jitter_buffer_target_delay("jitterBufferTargetDelay"), - interruption_count("interruptionCount"), - total_interruption_duration("totalInterruptionDuration"), - freeze_count("freezeCount"), - pause_count("pauseCount"), - total_freezes_duration("totalFreezesDuration"), - total_pauses_duration("totalPausesDuration"), - total_frames_duration("totalFramesDuration"), - sum_squared_frame_durations("sumOfSquaredFramesDuration") { + removed_samples_for_acceleration("removedSamplesForAcceleration") { RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio || kind == RTCMediaStreamTrackKind::kVideo); } -RTCMediaStreamTrackStats::RTCMediaStreamTrackStats( - const RTCMediaStreamTrackStats& other) - : RTCStats(other.id(), other.timestamp_us()), - track_identifier(other.track_identifier), - media_source_id(other.media_source_id), - remote_source(other.remote_source), - ended(other.ended), - detached(other.detached), - kind(other.kind), - jitter_buffer_delay(other.jitter_buffer_delay), - jitter_buffer_emitted_count(other.jitter_buffer_emitted_count), - frame_width(other.frame_width), - frame_height(other.frame_height), - frames_per_second(other.frames_per_second), - frames_sent(other.frames_sent), - huge_frames_sent(other.huge_frames_sent), - frames_received(other.frames_received), - frames_decoded(other.frames_decoded), - frames_dropped(other.frames_dropped), - frames_corrupted(other.frames_corrupted), - partial_frames_lost(other.partial_frames_lost), - full_frames_lost(other.full_frames_lost), - audio_level(other.audio_level), - total_audio_energy(other.total_audio_energy), - echo_return_loss(other.echo_return_loss), - echo_return_loss_enhancement(other.echo_return_loss_enhancement), - total_samples_received(other.total_samples_received), - total_samples_duration(other.total_samples_duration), - concealed_samples(other.concealed_samples), - silent_concealed_samples(other.silent_concealed_samples), - concealment_events(other.concealment_events), - inserted_samples_for_deceleration( - other.inserted_samples_for_deceleration), - removed_samples_for_acceleration(other.removed_samples_for_acceleration), - jitter_buffer_flushes(other.jitter_buffer_flushes), - delayed_packet_outage_samples(other.delayed_packet_outage_samples), - relative_packet_arrival_delay(other.relative_packet_arrival_delay), - jitter_buffer_target_delay(other.jitter_buffer_target_delay), - interruption_count(other.interruption_count), - total_interruption_duration(other.total_interruption_duration), - freeze_count(other.freeze_count), - pause_count(other.pause_count), - total_freezes_duration(other.total_freezes_duration), - total_pauses_duration(other.total_pauses_duration), - total_frames_duration(other.total_frames_duration), - sum_squared_frame_durations(other.sum_squared_frame_durations) {} - -RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() {} +DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats( + const DEPRECATED_RTCMediaStreamTrackStats& other) = default; + +DEPRECATED_RTCMediaStreamTrackStats::~DEPRECATED_RTCMediaStreamTrackStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection", @@ -534,27 +435,18 @@ RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id, data_channels_closed("dataChannelsClosed") {} RTCPeerConnectionStats::RTCPeerConnectionStats( - const RTCPeerConnectionStats& other) - : RTCStats(other.id(), other.timestamp_us()), - data_channels_opened(other.data_channels_opened), - data_channels_closed(other.data_channels_closed) {} + const RTCPeerConnectionStats& other) = default; RTCPeerConnectionStats::~RTCPeerConnectionStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp", &ssrc, - &is_remote, - &media_type, &kind, &track_id, &transport_id, &codec_id, - &fir_count, - &pli_count, - &nack_count, - &sli_count, - &qp_sum) + &media_type) // clang-format on RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id, @@ -564,47 +456,76 @@ RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id, RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us) : RTCStats(std::move(id), timestamp_us), ssrc("ssrc"), - is_remote("isRemote", false), - media_type("mediaType"), kind("kind"), track_id("trackId"), transport_id("transportId"), codec_id("codecId"), - fir_count("firCount"), - pli_count("pliCount"), - nack_count("nackCount"), - sli_count("sliCount"), - qp_sum("qpSum") {} - -RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other) - : RTCStats(other.id(), other.timestamp_us()), - ssrc(other.ssrc), - is_remote(other.is_remote), - media_type(other.media_type), - kind(other.kind), - track_id(other.track_id), - transport_id(other.transport_id), - codec_id(other.codec_id), - fir_count(other.fir_count), - pli_count(other.pli_count), - nack_count(other.nack_count), - sli_count(other.sli_count), - qp_sum(other.qp_sum) {} + media_type("mediaType") {} + +RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other) = default; RTCRTPStreamStats::~RTCRTPStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL( - RTCInboundRTPStreamStats, RTCRTPStreamStats, "inbound-rtp", + RTCReceivedRtpStreamStats, RTCRTPStreamStats, "received-rtp", + &jitter, + &packets_lost) +// clang-format on + +RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(const std::string&& id, + int64_t timestamp_us) + : RTCReceivedRtpStreamStats(std::string(id), timestamp_us) {} + +RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string&& id, + int64_t timestamp_us) + : RTCRTPStreamStats(std::move(id), timestamp_us), + jitter("jitter"), + packets_lost("packetsLost") {} + +RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats( + const RTCReceivedRtpStreamStats& other) = default; + +RTCReceivedRtpStreamStats::~RTCReceivedRtpStreamStats() {} + +// clang-format off +WEBRTC_RTCSTATS_IMPL( + RTCSentRtpStreamStats, RTCRTPStreamStats, "sent-rtp", + &packets_sent, + &bytes_sent) +// clang-format on + +RTCSentRtpStreamStats::RTCSentRtpStreamStats(const std::string&& id, + int64_t timestamp_us) + : RTCSentRtpStreamStats(std::string(id), timestamp_us) {} + +RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string&& id, + int64_t timestamp_us) + : RTCRTPStreamStats(std::move(id), timestamp_us), + packets_sent("packetsSent"), + bytes_sent("bytesSent") {} + +RTCSentRtpStreamStats::RTCSentRtpStreamStats( + const RTCSentRtpStreamStats& other) = default; + +RTCSentRtpStreamStats::~RTCSentRtpStreamStats() {} + +// clang-format off +WEBRTC_RTCSTATS_IMPL( + RTCInboundRTPStreamStats, RTCReceivedRtpStreamStats, "inbound-rtp", + &track_identifier, + &mid, + &remote_id, &packets_received, + &packets_discarded, &fec_packets_received, &fec_packets_discarded, &bytes_received, &header_bytes_received, - &packets_lost, &last_packet_received_timestamp, - &jitter, &jitter_buffer_delay, + &jitter_buffer_target_delay, + &jitter_buffer_minimum_delay, &jitter_buffer_emitted_count, &total_samples_received, &concealed_samples, @@ -616,30 +537,37 @@ WEBRTC_RTCSTATS_IMPL( &total_audio_energy, &total_samples_duration, &frames_received, - &round_trip_time, - &packets_discarded, - &packets_repaired, - &burst_packets_lost, - &burst_packets_discarded, - &burst_loss_count, - &burst_discard_count, - &burst_loss_rate, - &burst_discard_rate, - &gap_loss_rate, - &gap_discard_rate, &frame_width, &frame_height, - &frame_bit_depth, &frames_per_second, &frames_decoded, &key_frames_decoded, &frames_dropped, &total_decode_time, + &total_processing_delay, + &total_assembly_time, + &frames_assembled_from_multiple_packets, &total_inter_frame_delay, &total_squared_inter_frame_delay, + &pause_count, + &total_pauses_duration, + &freeze_count, + &total_freezes_duration, &content_type, &estimated_playout_timestamp, - &decoder_implementation) + &decoder_implementation, + &fir_count, + &pli_count, + &nack_count, + &qp_sum, + &goog_timing_frame_info, + &power_efficient_decoder, + &jitter_buffer_flushes, + &delayed_packet_outage_samples, + &relative_packet_arrival_delay, + &interruption_count, + &total_interruption_duration, + &min_playout_delay) // clang-format on RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id, @@ -648,16 +576,20 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id, RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us) - : RTCRTPStreamStats(std::move(id), timestamp_us), + : RTCReceivedRtpStreamStats(std::move(id), timestamp_us), + track_identifier("trackIdentifier"), + mid("mid"), + remote_id("remoteId"), packets_received("packetsReceived"), + packets_discarded("packetsDiscarded"), fec_packets_received("fecPacketsReceived"), fec_packets_discarded("fecPacketsDiscarded"), bytes_received("bytesReceived"), header_bytes_received("headerBytesReceived"), - packets_lost("packetsLost"), last_packet_received_timestamp("lastPacketReceivedTimestamp"), - jitter("jitter"), jitter_buffer_delay("jitterBufferDelay"), + jitter_buffer_target_delay("jitterBufferTargetDelay"), + jitter_buffer_minimum_delay("jitterBufferMinimumDelay"), jitter_buffer_emitted_count("jitterBufferEmittedCount"), total_samples_received("totalSamplesReceived"), concealed_samples("concealedSamples"), @@ -669,80 +601,48 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, total_audio_energy("totalAudioEnergy"), total_samples_duration("totalSamplesDuration"), frames_received("framesReceived"), - round_trip_time("roundTripTime"), - packets_discarded("packetsDiscarded"), - packets_repaired("packetsRepaired"), - burst_packets_lost("burstPacketsLost"), - burst_packets_discarded("burstPacketsDiscarded"), - burst_loss_count("burstLossCount"), - burst_discard_count("burstDiscardCount"), - burst_loss_rate("burstLossRate"), - burst_discard_rate("burstDiscardRate"), - gap_loss_rate("gapLossRate"), - gap_discard_rate("gapDiscardRate"), frame_width("frameWidth"), frame_height("frameHeight"), - frame_bit_depth("frameBitDepth"), frames_per_second("framesPerSecond"), frames_decoded("framesDecoded"), key_frames_decoded("keyFramesDecoded"), frames_dropped("framesDropped"), total_decode_time("totalDecodeTime"), + total_processing_delay("totalProcessingDelay"), + total_assembly_time("totalAssemblyTime"), + frames_assembled_from_multiple_packets( + "framesAssembledFromMultiplePackets"), total_inter_frame_delay("totalInterFrameDelay"), total_squared_inter_frame_delay("totalSquaredInterFrameDelay"), + pause_count("pauseCount"), + total_pauses_duration("totalPausesDuration"), + freeze_count("freezeCount"), + total_freezes_duration("totalFreezesDuration"), content_type("contentType"), estimated_playout_timestamp("estimatedPlayoutTimestamp"), - decoder_implementation("decoderImplementation") {} + decoder_implementation("decoderImplementation"), + fir_count("firCount"), + pli_count("pliCount"), + nack_count("nackCount"), + qp_sum("qpSum"), + goog_timing_frame_info("googTimingFrameInfo"), + power_efficient_decoder("powerEfficientDecoder"), + jitter_buffer_flushes( + "jitterBufferFlushes", + {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}), + delayed_packet_outage_samples( + "delayedPacketOutageSamples", + {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets, + NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}), + relative_packet_arrival_delay( + "relativePacketArrivalDelay", + {NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}), + interruption_count("interruptionCount"), + total_interruption_duration("totalInterruptionDuration"), + min_playout_delay("minPlayoutDelay") {} RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( - const RTCInboundRTPStreamStats& other) - : RTCRTPStreamStats(other), - packets_received(other.packets_received), - fec_packets_received(other.fec_packets_received), - fec_packets_discarded(other.fec_packets_discarded), - bytes_received(other.bytes_received), - header_bytes_received(other.header_bytes_received), - packets_lost(other.packets_lost), - last_packet_received_timestamp(other.last_packet_received_timestamp), - jitter(other.jitter), - jitter_buffer_delay(other.jitter_buffer_delay), - jitter_buffer_emitted_count(other.jitter_buffer_emitted_count), - total_samples_received(other.total_samples_received), - concealed_samples(other.concealed_samples), - silent_concealed_samples(other.silent_concealed_samples), - concealment_events(other.concealment_events), - inserted_samples_for_deceleration( - other.inserted_samples_for_deceleration), - removed_samples_for_acceleration(other.removed_samples_for_acceleration), - audio_level(other.audio_level), - total_audio_energy(other.total_audio_energy), - total_samples_duration(other.total_samples_duration), - frames_received(other.frames_received), - round_trip_time(other.round_trip_time), - packets_discarded(other.packets_discarded), - packets_repaired(other.packets_repaired), - burst_packets_lost(other.burst_packets_lost), - burst_packets_discarded(other.burst_packets_discarded), - burst_loss_count(other.burst_loss_count), - burst_discard_count(other.burst_discard_count), - burst_loss_rate(other.burst_loss_rate), - burst_discard_rate(other.burst_discard_rate), - gap_loss_rate(other.gap_loss_rate), - gap_discard_rate(other.gap_discard_rate), - frame_width(other.frame_width), - frame_height(other.frame_height), - frame_bit_depth(other.frame_bit_depth), - frames_per_second(other.frames_per_second), - frames_decoded(other.frames_decoded), - key_frames_decoded(other.key_frames_decoded), - frames_dropped(other.frames_dropped), - total_decode_time(other.total_decode_time), - total_inter_frame_delay(other.total_inter_frame_delay), - total_squared_inter_frame_delay(other.total_squared_inter_frame_delay), - content_type(other.content_type), - estimated_playout_timestamp(other.estimated_playout_timestamp), - decoder_implementation(other.decoder_implementation) {} - + const RTCInboundRTPStreamStats& other) = default; RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {} // clang-format off @@ -750,6 +650,7 @@ WEBRTC_RTCSTATS_IMPL( RTCOutboundRTPStreamStats, RTCRTPStreamStats, "outbound-rtp", &media_source_id, &remote_id, + &mid, &rid, &packets_sent, &retransmitted_packets_sent, @@ -768,9 +669,16 @@ WEBRTC_RTCSTATS_IMPL( &huge_frames_sent, &total_packet_send_delay, &quality_limitation_reason, + &quality_limitation_durations, &quality_limitation_resolution_changes, &content_type, - &encoder_implementation) + &encoder_implementation, + &fir_count, + &pli_count, + &nack_count, + &qp_sum, + &active, + &power_efficient_encoder) // clang-format on RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id, @@ -782,6 +690,7 @@ RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id, : RTCRTPStreamStats(std::move(id), timestamp_us), media_source_id("mediaSourceId"), remote_id("remoteId"), + mid("mid"), rid("rid"), packets_sent("packetsSent"), retransmitted_packets_sent("retransmittedPacketsSent"), @@ -800,52 +709,32 @@ RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id, huge_frames_sent("hugeFramesSent"), total_packet_send_delay("totalPacketSendDelay"), quality_limitation_reason("qualityLimitationReason"), + quality_limitation_durations("qualityLimitationDurations"), quality_limitation_resolution_changes( "qualityLimitationResolutionChanges"), content_type("contentType"), - encoder_implementation("encoderImplementation") {} + encoder_implementation("encoderImplementation"), + fir_count("firCount"), + pli_count("pliCount"), + nack_count("nackCount"), + qp_sum("qpSum"), + active("active"), + power_efficient_encoder("powerEfficientEncoder") {} RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats( - const RTCOutboundRTPStreamStats& other) - : RTCRTPStreamStats(other), - media_source_id(other.media_source_id), - remote_id(other.remote_id), - rid(other.rid), - packets_sent(other.packets_sent), - retransmitted_packets_sent(other.retransmitted_packets_sent), - bytes_sent(other.bytes_sent), - header_bytes_sent(other.header_bytes_sent), - retransmitted_bytes_sent(other.retransmitted_bytes_sent), - target_bitrate(other.target_bitrate), - frames_encoded(other.frames_encoded), - key_frames_encoded(other.key_frames_encoded), - total_encode_time(other.total_encode_time), - total_encoded_bytes_target(other.total_encoded_bytes_target), - frame_width(other.frame_width), - frame_height(other.frame_height), - frames_per_second(other.frames_per_second), - frames_sent(other.frames_sent), - huge_frames_sent(other.huge_frames_sent), - total_packet_send_delay(other.total_packet_send_delay), - quality_limitation_reason(other.quality_limitation_reason), - quality_limitation_resolution_changes( - other.quality_limitation_resolution_changes), - content_type(other.content_type), - encoder_implementation(other.encoder_implementation) {} + const RTCOutboundRTPStreamStats& other) = default; RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {} // clang-format off WEBRTC_RTCSTATS_IMPL( - RTCRemoteInboundRtpStreamStats, RTCStats, "remote-inbound-rtp", - &ssrc, - &kind, - &transport_id, - &codec_id, - &packets_lost, - &jitter, + RTCRemoteInboundRtpStreamStats, RTCReceivedRtpStreamStats, + "remote-inbound-rtp", &local_id, - &round_trip_time) + &round_trip_time, + &fraction_lost, + &total_round_trip_time, + &round_trip_time_measurements) // clang-format on RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( @@ -856,31 +745,52 @@ RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( std::string&& id, int64_t timestamp_us) - : RTCStats(std::move(id), timestamp_us), - ssrc("ssrc"), - kind("kind"), - transport_id("transportId"), - codec_id("codecId"), - packets_lost("packetsLost"), - jitter("jitter"), + : RTCReceivedRtpStreamStats(std::move(id), timestamp_us), local_id("localId"), - round_trip_time("roundTripTime") {} + round_trip_time("roundTripTime"), + fraction_lost("fractionLost"), + total_round_trip_time("totalRoundTripTime"), + round_trip_time_measurements("roundTripTimeMeasurements") {} RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( - const RTCRemoteInboundRtpStreamStats& other) - : RTCStats(other), - ssrc(other.ssrc), - kind(other.kind), - transport_id(other.transport_id), - codec_id(other.codec_id), - packets_lost(other.packets_lost), - jitter(other.jitter), - local_id(other.local_id), - round_trip_time(other.round_trip_time) {} + const RTCRemoteInboundRtpStreamStats& other) = default; RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {} // clang-format off +WEBRTC_RTCSTATS_IMPL( + RTCRemoteOutboundRtpStreamStats, RTCSentRtpStreamStats, + "remote-outbound-rtp", + &local_id, + &remote_timestamp, + &reports_sent, + &round_trip_time, + &round_trip_time_measurements, + &total_round_trip_time) +// clang-format on + +RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats( + const std::string& id, + int64_t timestamp_us) + : RTCRemoteOutboundRtpStreamStats(std::string(id), timestamp_us) {} + +RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats( + std::string&& id, + int64_t timestamp_us) + : RTCSentRtpStreamStats(std::move(id), timestamp_us), + local_id("localId"), + remote_timestamp("remoteTimestamp"), + reports_sent("reportsSent"), + round_trip_time("roundTripTime"), + round_trip_time_measurements("roundTripTimeMeasurements"), + total_round_trip_time("totalRoundTripTime") {} + +RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats( + const RTCRemoteOutboundRtpStreamStats& other) = default; + +RTCRemoteOutboundRtpStreamStats::~RTCRemoteOutboundRtpStreamStats() {} + +// clang-format off WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source", &track_identifier, &kind) @@ -895,10 +805,8 @@ RTCMediaSourceStats::RTCMediaSourceStats(std::string&& id, int64_t timestamp_us) track_identifier("trackIdentifier"), kind("kind") {} -RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other) - : RTCStats(other.id(), other.timestamp_us()), - track_identifier(other.track_identifier), - kind(other.kind) {} +RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other) = + default; RTCMediaSourceStats::~RTCMediaSourceStats() {} @@ -906,7 +814,9 @@ RTCMediaSourceStats::~RTCMediaSourceStats() {} WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source", &audio_level, &total_audio_energy, - &total_samples_duration) + &total_samples_duration, + &echo_return_loss, + &echo_return_loss_enhancement) // clang-format on RTCAudioSourceStats::RTCAudioSourceStats(const std::string& id, @@ -917,13 +827,12 @@ RTCAudioSourceStats::RTCAudioSourceStats(std::string&& id, int64_t timestamp_us) : RTCMediaSourceStats(std::move(id), timestamp_us), audio_level("audioLevel"), total_audio_energy("totalAudioEnergy"), - total_samples_duration("totalSamplesDuration") {} + total_samples_duration("totalSamplesDuration"), + echo_return_loss("echoReturnLoss"), + echo_return_loss_enhancement("echoReturnLossEnhancement") {} -RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other) - : RTCMediaSourceStats(other), - audio_level(other.audio_level), - total_audio_energy(other.total_audio_energy), - total_samples_duration(other.total_samples_duration) {} +RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other) = + default; RTCAudioSourceStats::~RTCAudioSourceStats() {} @@ -946,12 +855,8 @@ RTCVideoSourceStats::RTCVideoSourceStats(std::string&& id, int64_t timestamp_us) frames("frames"), frames_per_second("framesPerSecond") {} -RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other) - : RTCMediaSourceStats(other), - width(other.width), - height(other.height), - frames(other.frames), - frames_per_second(other.frames_per_second) {} +RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other) = + default; RTCVideoSourceStats::~RTCVideoSourceStats() {} @@ -968,8 +873,12 @@ WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport", &remote_certificate_id, &tls_version, &dtls_cipher, + &dtls_role, &srtp_cipher, - &selected_candidate_pair_changes) + &selected_candidate_pair_changes, + &ice_role, + &ice_local_username_fragment, + &ice_state) // clang-format on RTCTransportStats::RTCTransportStats(const std::string& id, @@ -989,24 +898,14 @@ RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us) remote_certificate_id("remoteCertificateId"), tls_version("tlsVersion"), dtls_cipher("dtlsCipher"), + dtls_role("dtlsRole"), srtp_cipher("srtpCipher"), - selected_candidate_pair_changes("selectedCandidatePairChanges") {} - -RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) - : RTCStats(other.id(), other.timestamp_us()), - bytes_sent(other.bytes_sent), - packets_sent(other.packets_sent), - bytes_received(other.bytes_received), - packets_received(other.packets_received), - rtcp_transport_stats_id(other.rtcp_transport_stats_id), - dtls_state(other.dtls_state), - selected_candidate_pair_id(other.selected_candidate_pair_id), - local_certificate_id(other.local_certificate_id), - remote_certificate_id(other.remote_certificate_id), - tls_version(other.tls_version), - dtls_cipher(other.dtls_cipher), - srtp_cipher(other.srtp_cipher), - selected_candidate_pair_changes(other.selected_candidate_pair_changes) {} + selected_candidate_pair_changes("selectedCandidatePairChanges"), + ice_role("iceRole"), + ice_local_username_fragment("iceLocalUsernameFragment"), + ice_state("iceState") {} + +RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) = default; RTCTransportStats::~RTCTransportStats() {} diff --git a/stats/test/rtc_test_stats.cc b/stats/test/rtc_test_stats.cc index d8bcbb19eb..e73da76fa9 100644 --- a/stats/test/rtc_test_stats.cc +++ b/stats/test/rtc_test_stats.cc @@ -30,7 +30,9 @@ WEBRTC_RTCSTATS_IMPL(RTCTestStats, &m_sequence_int64, &m_sequence_uint64, &m_sequence_double, - &m_sequence_string) + &m_sequence_string, + &m_map_string_uint64, + &m_map_string_double) RTCTestStats::RTCTestStats(const std::string& id, int64_t timestamp_us) : RTCStats(id, timestamp_us), @@ -47,7 +49,9 @@ RTCTestStats::RTCTestStats(const std::string& id, int64_t timestamp_us) m_sequence_int64("mSequenceInt64"), m_sequence_uint64("mSequenceUint64"), m_sequence_double("mSequenceDouble"), - m_sequence_string("mSequenceString") {} + m_sequence_string("mSequenceString"), + m_map_string_uint64("mMapStringUint64"), + m_map_string_double("mMapStringDouble") {} RTCTestStats::RTCTestStats(const RTCTestStats& other) : RTCStats(other.id(), other.timestamp_us()), @@ -64,7 +68,9 @@ RTCTestStats::RTCTestStats(const RTCTestStats& other) m_sequence_int64(other.m_sequence_int64), m_sequence_uint64(other.m_sequence_uint64), m_sequence_double(other.m_sequence_double), - m_sequence_string(other.m_sequence_string) {} + m_sequence_string(other.m_sequence_string), + m_map_string_uint64(other.m_map_string_uint64), + m_map_string_double(other.m_map_string_double) {} RTCTestStats::~RTCTestStats() {} diff --git a/stats/test/rtc_test_stats.h b/stats/test/rtc_test_stats.h index 1db32c25c1..0feb07e78e 100644 --- a/stats/test/rtc_test_stats.h +++ b/stats/test/rtc_test_stats.h @@ -12,6 +12,7 @@ #define STATS_TEST_RTC_TEST_STATS_H_ #include <cstdint> +#include <map> #include <string> #include <vector> @@ -42,6 +43,8 @@ class RTC_EXPORT RTCTestStats : public RTCStats { RTCStatsMember<std::vector<uint64_t>> m_sequence_uint64; RTCStatsMember<std::vector<double>> m_sequence_double; RTCStatsMember<std::vector<std::string>> m_sequence_string; + RTCStatsMember<std::map<std::string, uint64_t>> m_map_string_uint64; + RTCStatsMember<std::map<std::string, double>> m_map_string_double; }; } // namespace webrtc |