From 6fb8d1a2d7c158caa1ddb63c9fa9b6a5e2548a43 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Mon, 30 May 2022 12:37:04 +0200 Subject: [PATCH] stats: expose minPlayoutDelay as nonstandard stat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This currently only exists as a goog legacy stat and has no spec equivalent according to https://docs.google.com/document/d/1z-D4SngG36WPiMuRvWeTMN7mWQXrf1XKZwVl3Nf1BIE/edit Yet it is useful to debug issues sometimes. Exposing it as a nonstandard stat will make it show up in chrome://webrtc-internals, removing a need to switch to the legacy stats API there. BUG=webrtc:14118 Change-Id: I506357ad54ff33df3ba46fb81558aa32187ac8e9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264420 Commit-Queue: Henrik Boström Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/main@{#37055} --- api/stats/rtcstats_objects.h | 3 +++ pc/rtc_stats_collector.cc | 3 +++ pc/rtc_stats_collector_unittest.cc | 2 ++ pc/rtc_stats_integrationtest.cc | 3 +++ stats/rtcstats_objects.cc | 9 ++++++--- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 7446690f1e..7f93c1c91c 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -553,6 +553,9 @@ class RTC_EXPORT RTCInboundRTPStreamStats final RTCStatsMember pli_count; RTCStatsMember nack_count; RTCStatsMember qp_sum; + + // The former googMinPlayoutDelayMs (in seconds). + RTCNonStandardStatsMember min_playout_delay; }; // https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict* diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 16f97993db..1a611bdb2e 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -569,6 +569,9 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo( video_receiver_info.total_inter_frame_delay; inbound_video->total_squared_inter_frame_delay = video_receiver_info.total_squared_inter_frame_delay; + inbound_video->min_playout_delay = + static_cast(video_receiver_info.min_playout_delay_ms) / + rtc::kNumMillisecsPerSec; if (video_receiver_info.last_packet_received_timestamp_ms) { inbound_video->last_packet_received_timestamp = static_cast( *video_receiver_info.last_packet_received_timestamp_ms); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index c64c523adb..586d07f3ed 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -2156,6 +2156,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { video_media_info.receivers[0].estimated_playout_ntp_timestamp_ms = absl::nullopt; video_media_info.receivers[0].decoder_implementation_name = ""; + video_media_info.receivers[0].min_playout_delay_ms = 50; RtpCodecParameters codec_parameters; codec_parameters.payload_type = 42; @@ -2204,6 +2205,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { // `expected_video.last_packet_received_timestamp` should be undefined. // `expected_video.content_type` should be undefined. // `expected_video.decoder_implementation` should be undefined. + expected_video.min_playout_delay = 0.05; ASSERT_TRUE(report->Get(expected_video.id())); EXPECT_EQ( diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 598395af94..b5d86a9bf5 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -927,6 +927,8 @@ class RTCStatsReportVerifier { // The integration test is not set up to test screen share; don't require // this to be present. verifier.MarkMemberTested(inbound_stream.content_type, true); + verifier.TestMemberIsNonNegative( + inbound_stream.min_playout_delay); } else { verifier.TestMemberIsUndefined(inbound_stream.frames_decoded); verifier.TestMemberIsUndefined(inbound_stream.key_frames_decoded); @@ -940,6 +942,7 @@ class RTCStatsReportVerifier { verifier.TestMemberIsUndefined( inbound_stream.total_squared_inter_frame_delay); verifier.TestMemberIsUndefined(inbound_stream.content_type); + verifier.TestMemberIsUndefined(inbound_stream.min_playout_delay); } return verifier.ExpectAllMembersSuccessfullyTested(); } diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index d2c6a6b7e4..b0003c3952 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -718,7 +718,8 @@ WEBRTC_RTCSTATS_IMPL( &fir_count, &pli_count, &nack_count, - &qp_sum) + &qp_sum, + &min_playout_delay) // clang-format on RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id, @@ -777,7 +778,8 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, fir_count("firCount"), pli_count("pliCount"), nack_count("nackCount"), - qp_sum("qpSum") {} + qp_sum("qpSum"), + min_playout_delay("minPlayoutDelay") {} RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( const RTCInboundRTPStreamStats& other) @@ -832,7 +834,8 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( fir_count(other.fir_count), pli_count(other.pli_count), nack_count(other.nack_count), - qp_sum(other.qp_sum) {} + qp_sum(other.qp_sum), + min_playout_delay(other.min_playout_delay) {} RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {}