From 416cb498cc109d76777f76dedf652d42ac43bce9 Mon Sep 17 00:00:00 2001 From: Emil Vardar Date: Fri, 8 Nov 2024 09:56:44 +0000 Subject: [PATCH] Rename corruption related metrics according to WebRTC's Statistics API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats-totalcorruptionprobability for more details. Bug: webrtc:358039777 Change-Id: I34236b9423864008486a9f9949f46397ff8b9f92 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/367960 Commit-Queue: Emil Vardar (xWF) Reviewed-by: Erik Språng Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/main@{#43379} --- api/stats/rtcstats_objects.h | 7 +++---- pc/peer_connection_integrationtest.cc | 24 ++++++++++++------------ pc/rtc_stats_collector.cc | 6 +++--- pc/rtc_stats_collector_unittest.cc | 6 +++--- pc/rtc_stats_integrationtest.cc | 7 ++++--- pc/test/integration_test_helpers.h | 2 +- stats/rtcstats_objects.cc | 7 ++++--- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 67341aab5f..625d122ac6 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -297,10 +297,9 @@ class RTC_EXPORT RTCInboundRtpStreamStats final std::optional pli_count; std::optional nack_count; std::optional qp_sum; - // https://webrtc.googlesource.com/src/+/refs/heads/main/docs/native-code/rtp-hdrext/corruption-detection - std::optional corruption_score_sum; - std::optional corruption_score_squared_sum; - std::optional corruption_score_count; + std::optional total_corruption_probability; + std::optional total_squared_corruption_probability; + std::optional corruption_measurements; // This is a remnant of the legacy getStats() API. When the "video-timing" // header extension is used, // https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/, diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 694e13538e..4cd31e7c17 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -4142,20 +4142,20 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, for (const auto& stat : inbound_stream_stats) { if (*stat->kind == "video") { if (pair == caller()) { - EXPECT_TRUE(stat->corruption_score_sum.has_value()); - EXPECT_TRUE(stat->corruption_score_squared_sum.has_value()); + EXPECT_TRUE(stat->total_corruption_probability.has_value()); + EXPECT_TRUE(stat->total_squared_corruption_probability.has_value()); double average_corruption_score = - (*stat->corruption_score_sum) / - static_cast(*stat->corruption_score_count); + (*stat->total_corruption_probability) / + static_cast(*stat->corruption_measurements); EXPECT_GE(average_corruption_score, 0.0); EXPECT_LE(average_corruption_score, 1.0); } if (pair == callee()) { // Since only `caller` requests corruption score calculation the // callee should not aggregate it. - EXPECT_FALSE(stat->corruption_score_sum.has_value()); - EXPECT_FALSE(stat->corruption_score_squared_sum.has_value()); + EXPECT_FALSE(stat->total_corruption_probability.has_value()); + EXPECT_FALSE(stat->total_squared_corruption_probability.has_value()); } } } @@ -4196,12 +4196,12 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, report->GetStatsOfType(); for (const auto& stat : inbound_stream_stats) { if (*stat->kind == "video") { - EXPECT_TRUE(stat->corruption_score_sum.has_value()); - EXPECT_TRUE(stat->corruption_score_squared_sum.has_value()); + EXPECT_TRUE(stat->total_corruption_probability.has_value()); + EXPECT_TRUE(stat->total_squared_corruption_probability.has_value()); double average_corruption_score = - (*stat->corruption_score_sum) / - static_cast(*stat->corruption_score_count); + (*stat->total_corruption_probability) / + static_cast(*stat->corruption_measurements); EXPECT_GE(average_corruption_score, 0.0); EXPECT_LE(average_corruption_score, 1.0); } @@ -4245,8 +4245,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, report->GetStatsOfType(); for (const auto& stat : inbound_stream_stats) { if (*stat->kind == "video") { - EXPECT_FALSE(stat->corruption_score_sum.has_value()); - EXPECT_FALSE(stat->corruption_score_squared_sum.has_value()); + EXPECT_FALSE(stat->total_corruption_probability.has_value()); + EXPECT_FALSE(stat->total_squared_corruption_probability.has_value()); } } } diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 47a1a86b7b..451590fced 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -627,11 +627,11 @@ CreateInboundRTPStreamStatsFromVideoReceiverInfo( if (video_receiver_info.corruption_score_sum.has_value()) { RTC_CHECK(video_receiver_info.corruption_score_squared_sum.has_value()); RTC_CHECK_GT(video_receiver_info.corruption_score_count, 0); - inbound_video->corruption_score_sum = + inbound_video->total_corruption_probability = *video_receiver_info.corruption_score_sum; - inbound_video->corruption_score_squared_sum = + inbound_video->total_squared_corruption_probability = *video_receiver_info.corruption_score_squared_sum; - inbound_video->corruption_score_count = + inbound_video->corruption_measurements = video_receiver_info.corruption_score_count; } if (video_receiver_info.timing_frame_info.has_value()) { diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 1cc3ce5617..696e071154 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -2459,9 +2459,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) { video_media_info.receivers[0].corruption_score_sum = 0.5; video_media_info.receivers[0].corruption_score_squared_sum = 0.25; video_media_info.receivers[0].corruption_score_count = 5; - expected_video.corruption_score_sum = 0.5; - expected_video.corruption_score_squared_sum = 0.25; - expected_video.corruption_score_count = 5; + expected_video.total_corruption_probability = 0.5; + expected_video.total_squared_corruption_probability = 0.25; + expected_video.corruption_measurements = 5; video_media_info.receivers[0].last_packet_received = Timestamp::Seconds(1); expected_video.last_packet_received_timestamp = 1000.0; video_media_info.receivers[0].content_type = VideoContentType::SCREENSHARE; diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 11f7e5ce49..c21ab0ef5c 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -563,10 +563,11 @@ class RTCStatsReportVerifier { // As long as the corruption detection RTP header extension is not activated // it should not aggregate any corruption score. The tests where this header // extension is enabled are located in pc/peer_connection_integrationtest.cc - verifier.TestAttributeIsUndefined(inbound_stream.corruption_score_sum); verifier.TestAttributeIsUndefined( - inbound_stream.corruption_score_squared_sum); - verifier.TestAttributeIsUndefined(inbound_stream.corruption_score_count); + inbound_stream.total_corruption_probability); + verifier.TestAttributeIsUndefined( + inbound_stream.total_squared_corruption_probability); + verifier.TestAttributeIsUndefined(inbound_stream.corruption_measurements); verifier.TestAttributeIsNonNegative( inbound_stream.packets_received); if (inbound_stream.kind.has_value() && *inbound_stream.kind == "audio") { diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 9a218d9893..6dbbd0b1ee 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -750,7 +750,7 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, report->GetStatsOfType(); for (const auto& stat : inbound_stream_stats) { if (*stat->kind == "video") { - return stat->corruption_score_count.value_or(0); + return stat->corruption_measurements.value_or(0); } } return 0; diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 4ee9bdcc24..4a08133c0a 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -267,9 +267,10 @@ WEBRTC_RTCSTATS_IMPL( AttributeInit("pliCount", &pli_count), AttributeInit("nackCount", &nack_count), AttributeInit("qpSum", &qp_sum), - AttributeInit("corruptionScoreSum", &corruption_score_sum), - AttributeInit("corruptionScoreSumSquared", &corruption_score_squared_sum), - AttributeInit("corruptionScoreCount", &corruption_score_count), + AttributeInit("totalCorruptionProbability", &total_corruption_probability), + AttributeInit("totalSquaredCorruptionProbability", + &total_squared_corruption_probability), + AttributeInit("corruptionMeasurements", &corruption_measurements), AttributeInit("googTimingFrameInfo", &goog_timing_frame_info), AttributeInit("powerEfficientDecoder", &power_efficient_decoder), AttributeInit("jitterBufferFlushes", &jitter_buffer_flushes),