Skip to content

Commit

Permalink
[Merge-108] [Stats] Add googTimingFrameInfo to the modern API.
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit c5f8f80)

Bug: webrtc:14587, chromium:1376604
Change-Id: Ic3d45b0558d7caf4be2856a4cd95b88db312f85e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279860
Reviewed-by: Harald Alvestrand <[email protected]>
Commit-Queue: Henrik Boström <[email protected]>
Cr-Original-Commit-Position: refs/heads/main@{#38444}
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279900
Cr-Commit-Position: refs/branch-heads/5359@{webrtc-sdk#1}
Cr-Branched-From: fb3bd4a-refs/heads/main@{#38387}
  • Loading branch information
henbos authored and WebRTC LUCI CQ committed Oct 20, 2022
1 parent fb3bd4a commit bfb453a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
7 changes: 7 additions & 0 deletions api/stats/rtcstats_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@ class RTC_EXPORT RTCInboundRTPStreamStats final
RTCStatsMember<uint32_t> pli_count;
RTCStatsMember<uint32_t> nack_count;
RTCStatsMember<uint64_t> 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<std::string> goog_timing_frame_info;
// Non-standard audio metrics.
RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Expand Down
7 changes: 6 additions & 1 deletion pc/rtc_stats_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>();
inbound_video->total_processing_delay =
Expand Down
37 changes: 37 additions & 0 deletions pc/rtc_stats_collector_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -2703,6 +2704,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<const RTCStatsReport> report = stats_->GetStatsReport();
auto inbound_rtps = report->GetStatsOfType<RTCInboundRTPStreamStats>();
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;

Expand Down
2 changes: 2 additions & 0 deletions pc/rtc_stats_integrationtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ class RTCStatsReportVerifier {
inbound_stream.total_interruption_duration);
verifier.TestMemberIsNonNegative<double>(
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);
Expand Down Expand Up @@ -964,6 +965,7 @@ class RTCStatsReportVerifier {
verifier.TestMemberIsNonNegative<double>(
inbound_stream.total_interruption_duration);
verifier.TestMemberIsUndefined(inbound_stream.min_playout_delay);
verifier.TestMemberIsUndefined(inbound_stream.goog_timing_frame_info);
}
return verifier.ExpectAllMembersSuccessfullyTested();
}
Expand Down
2 changes: 2 additions & 0 deletions stats/rtcstats_objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,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,
Expand Down Expand Up @@ -642,6 +643,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}),
Expand Down

0 comments on commit bfb453a

Please sign in to comment.