From c5f8f800a28536d09eb1978afa69208365dc22b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 19 Oct 2022 17:50:09 +0200 Subject: [PATCH] [Stats] Add googTimingFrameInfo to the modern API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is exposing something that is already exposed in the legacy getStats() API and is only available if the "video-timing" header extension is used. Adding this metric here should unblock legacy getStats() API deprecation. The follow-up to unship or standardize this metric is tracked by https://crbug.com/webrtc/14586. Bug: webrtc:14587 Change-Id: Ic3d45b0558d7caf4be2856a4cd95b88db312f85e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279860 Reviewed-by: Harald Alvestrand Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#38444} --- api/stats/rtcstats_objects.h | 7 ++++++ pc/rtc_stats_collector.cc | 7 +++++- pc/rtc_stats_collector_unittest.cc | 37 ++++++++++++++++++++++++++++++ pc/rtc_stats_integrationtest.cc | 2 ++ stats/rtcstats_objects.cc | 2 ++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 2b6c622f27..b370381751 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -502,6 +502,13 @@ class RTC_EXPORT RTCInboundRTPStreamStats final RTCStatsMember pli_count; RTCStatsMember nack_count; RTCStatsMember qp_sum; + // 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/, + // `googTimingFrameInfo` is exposed with the value of + // TimingFrameInfo::ToString(). + // TODO(https://crbug.com/webrtc/14586): Unship or standardize this metric. + RTCStatsMember goog_timing_frame_info; // Non-standard audio metrics. RTCNonStandardStatsMember jitter_buffer_flushes; RTCNonStandardStatsMember delayed_packet_outage_samples; diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 53da849eea..4c980af295 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -607,8 +607,13 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo( if (video_receiver_info.framerate_decoded > 0) { inbound_video->frames_per_second = video_receiver_info.framerate_decoded; } - if (video_receiver_info.qp_sum) + if (video_receiver_info.qp_sum) { inbound_video->qp_sum = *video_receiver_info.qp_sum; + } + if (video_receiver_info.timing_frame_info.has_value()) { + inbound_video->goog_timing_frame_info = + video_receiver_info.timing_frame_info->ToString(); + } inbound_video->total_decode_time = video_receiver_info.total_decode_time.seconds(); inbound_video->total_processing_delay = diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index ec799a2390..60f3f3dc35 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -38,6 +38,7 @@ #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" +#include "api/video/video_timing.h" #include "common_video/include/quality_limitation_reason.h" #include "media/base/media_channel.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -2714,6 +2715,42 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { EXPECT_TRUE(report->Get(*expected_video.codec_id)); } +TEST_F(RTCStatsCollectorTest, CollectGoogTimingFrameInfo) { + cricket::VideoMediaInfo video_media_info; + + video_media_info.receivers.push_back(cricket::VideoReceiverInfo()); + video_media_info.receivers[0].local_stats.push_back( + cricket::SsrcReceiverInfo()); + video_media_info.receivers[0].local_stats[0].ssrc = 1; + TimingFrameInfo timing_frame_info; + timing_frame_info.rtp_timestamp = 1; + timing_frame_info.capture_time_ms = 2; + timing_frame_info.encode_start_ms = 3; + timing_frame_info.encode_finish_ms = 4; + timing_frame_info.packetization_finish_ms = 5; + timing_frame_info.pacer_exit_ms = 6; + timing_frame_info.network_timestamp_ms = 7; + timing_frame_info.network2_timestamp_ms = 8; + timing_frame_info.receive_start_ms = 9; + timing_frame_info.receive_finish_ms = 10; + timing_frame_info.decode_start_ms = 11; + timing_frame_info.decode_finish_ms = 12; + timing_frame_info.render_time_ms = 13; + timing_frame_info.flags = 14; + video_media_info.receivers[0].timing_frame_info = timing_frame_info; + + pc_->AddVideoChannel("Mid0", "Transport0", video_media_info); + stats_->SetupRemoteTrackAndReceiver( + cricket::MEDIA_TYPE_VIDEO, "RemoteVideoTrackID", "RemoteStreamId", 1); + + rtc::scoped_refptr report = stats_->GetStatsReport(); + auto inbound_rtps = report->GetStatsOfType(); + ASSERT_EQ(inbound_rtps.size(), 1u); + ASSERT_TRUE(inbound_rtps[0]->goog_timing_frame_info.is_defined()); + EXPECT_EQ(*inbound_rtps[0]->goog_timing_frame_info, + "1,2,3,4,5,6,7,8,9,10,11,12,13,1,0"); +} + TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { cricket::VoiceMediaInfo voice_media_info; diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 205faa33a1..8310bee102 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -937,6 +937,7 @@ class RTCStatsReportVerifier { inbound_stream.total_interruption_duration); verifier.TestMemberIsNonNegative( inbound_stream.min_playout_delay); + verifier.TestMemberIsDefined(inbound_stream.goog_timing_frame_info); } else { verifier.TestMemberIsUndefined(inbound_stream.frames_decoded); verifier.TestMemberIsUndefined(inbound_stream.key_frames_decoded); @@ -965,6 +966,7 @@ class RTCStatsReportVerifier { verifier.TestMemberIsNonNegative( inbound_stream.total_interruption_duration); verifier.TestMemberIsUndefined(inbound_stream.min_playout_delay); + verifier.TestMemberIsUndefined(inbound_stream.goog_timing_frame_info); } return verifier.ExpectAllMembersSuccessfullyTested(); } diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index db12bf6d35..420613b777 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -585,6 +585,7 @@ WEBRTC_RTCSTATS_IMPL( &pli_count, &nack_count, &qp_sum, + &goog_timing_frame_info, &jitter_buffer_flushes, &delayed_packet_outage_samples, &relative_packet_arrival_delay, @@ -648,6 +649,7 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, pli_count("pliCount"), nack_count("nackCount"), qp_sum("qpSum"), + goog_timing_frame_info("googTimingFrameInfo"), jitter_buffer_flushes( "jitterBufferFlushes", {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}),