From 4e5bc9f081d1b2253a4b63e2e59af81773042006 Mon Sep 17 00:00:00 2001 From: Eldar Rello Date: Mon, 6 Jul 2020 14:18:07 +0300 Subject: [PATCH] Reland "Complete migration from "track" to "inbound-rtp" stats" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a reland of 94fe0d3de5e8162d1a105fd1a3ec4bd2da97f43b with a fix. Original change's description: > Complete migration from "track" to "inbound-rtp" stats > > Bug: webrtc:11683 > Change-Id: I4c4a4fa0a7d6a20976922aca41d57540aa27fd1d > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178611 > Reviewed-by: Henrik Boström > Reviewed-by: Harald Alvestrand > Commit-Queue: Eldar Rello > Cr-Commit-Position: refs/heads/master@{#31683} Bug: webrtc:11683 Change-Id: I173b91625174051c02ff34127aaf6c086d3c5c66 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179060 Commit-Queue: Eldar Rello Reviewed-by: Henrik Boström Cr-Commit-Position: refs/heads/master@{#31696} --- api/stats/rtcstats_objects.h | 17 ++++++++++ pc/rtc_stats_collector.cc | 31 +++++++++++++++++ pc/rtc_stats_collector_unittest.cc | 32 ++++++++++++++++-- pc/rtc_stats_integrationtest.cc | 53 +++++++++++++++++++++++++++++- stats/rtcstats_objects.cc | 52 +++++++++++++++++++++++++++++ 5 files changed, 182 insertions(+), 3 deletions(-) diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index 3458d6fef7..dc91f41195 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -419,6 +419,18 @@ class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats { // TODO(hbos): Collect and populate this value for both "audio" and "video", // currently not collected for "video". https://bugs.webrtc.org/7065 RTCStatsMember jitter; + RTCStatsMember jitter_buffer_delay; + RTCStatsMember jitter_buffer_emitted_count; + RTCStatsMember total_samples_received; + RTCStatsMember concealed_samples; + RTCStatsMember silent_concealed_samples; + RTCStatsMember concealment_events; + RTCStatsMember inserted_samples_for_deceleration; + RTCStatsMember removed_samples_for_acceleration; + RTCStatsMember audio_level; + RTCStatsMember total_audio_energy; + RTCStatsMember total_samples_duration; + RTCStatsMember frames_received; // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065 RTCStatsMember round_trip_time; // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065 @@ -441,8 +453,13 @@ class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats { RTCStatsMember gap_loss_rate; // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065 RTCStatsMember gap_discard_rate; + RTCStatsMember frame_width; + RTCStatsMember frame_height; + RTCStatsMember frame_bit_depth; + RTCStatsMember frames_per_second; RTCStatsMember frames_decoded; RTCStatsMember key_frames_decoded; + RTCStatsMember frames_dropped; RTCStatsMember total_decode_time; RTCStatsMember total_inter_frame_delay; RTCStatsMember total_squared_inter_frame_delay; diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index c6b3caed4c..be0bbd6f73 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -291,6 +291,24 @@ void SetInboundRTPStreamStatsFromVoiceReceiverInfo( } inbound_audio->jitter = static_cast(voice_receiver_info.jitter_ms) / rtc::kNumMillisecsPerSec; + inbound_audio->jitter_buffer_delay = + voice_receiver_info.jitter_buffer_delay_seconds; + inbound_audio->jitter_buffer_emitted_count = + voice_receiver_info.jitter_buffer_emitted_count; + inbound_audio->total_samples_received = + voice_receiver_info.total_samples_received; + inbound_audio->concealed_samples = voice_receiver_info.concealed_samples; + inbound_audio->silent_concealed_samples = + voice_receiver_info.silent_concealed_samples; + inbound_audio->concealment_events = voice_receiver_info.concealment_events; + inbound_audio->inserted_samples_for_deceleration = + voice_receiver_info.inserted_samples_for_deceleration; + inbound_audio->removed_samples_for_acceleration = + voice_receiver_info.removed_samples_for_acceleration; + inbound_audio->audio_level = voice_receiver_info.audio_level; + inbound_audio->total_audio_energy = voice_receiver_info.total_output_energy; + inbound_audio->total_samples_duration = + voice_receiver_info.total_output_duration; // |fir_count|, |pli_count| and |sli_count| are only valid for video and are // purposefully left undefined for audio. if (voice_receiver_info.last_packet_received_timestamp_ms) { @@ -327,8 +345,21 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo( static_cast(video_receiver_info.plis_sent); inbound_video->nack_count = static_cast(video_receiver_info.nacks_sent); + inbound_video->frames_received = video_receiver_info.frames_received; inbound_video->frames_decoded = video_receiver_info.frames_decoded; + inbound_video->frames_dropped = video_receiver_info.frames_dropped; inbound_video->key_frames_decoded = video_receiver_info.key_frames_decoded; + if (video_receiver_info.frame_width > 0) { + inbound_video->frame_width = + static_cast(video_receiver_info.frame_width); + } + if (video_receiver_info.frame_height > 0) { + inbound_video->frame_height = + static_cast(video_receiver_info.frame_height); + } + if (video_receiver_info.framerate_rcvd > 0) { + inbound_video->frames_per_second = video_receiver_info.framerate_rcvd; + } if (video_receiver_info.qp_sum) inbound_video->qp_sum = *video_receiver_info.qp_sum; inbound_video->total_decode_time = diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index b7727f9baa..af9e5456d4 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -1783,6 +1783,18 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { voice_media_info.receivers[0].header_and_padding_bytes_rcvd = 4; voice_media_info.receivers[0].codec_payload_type = 42; voice_media_info.receivers[0].jitter_ms = 4500; + voice_media_info.receivers[0].jitter_buffer_delay_seconds = 1.0; + voice_media_info.receivers[0].jitter_buffer_emitted_count = 2; + voice_media_info.receivers[0].total_samples_received = 3; + voice_media_info.receivers[0].concealed_samples = 4; + voice_media_info.receivers[0].silent_concealed_samples = 5; + voice_media_info.receivers[0].concealment_events = 6; + voice_media_info.receivers[0].inserted_samples_for_deceleration = 7; + voice_media_info.receivers[0].removed_samples_for_acceleration = 8; + voice_media_info.receivers[0].audio_level = 9.0; + voice_media_info.receivers[0].total_output_energy = 10.0; + voice_media_info.receivers[0].total_output_duration = 11.0; + voice_media_info.receivers[0].last_packet_received_timestamp_ms = absl::nullopt; @@ -1821,6 +1833,18 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { expected_audio.packets_lost = -1; // |expected_audio.last_packet_received_timestamp| should be undefined. expected_audio.jitter = 4.5; + expected_audio.jitter_buffer_delay = 1.0; + expected_audio.jitter_buffer_emitted_count = 2; + expected_audio.total_samples_received = 3; + expected_audio.concealed_samples = 4; + expected_audio.silent_concealed_samples = 5; + expected_audio.concealment_events = 6; + expected_audio.inserted_samples_for_deceleration = 7; + expected_audio.removed_samples_for_acceleration = 8; + expected_audio.audio_level = 9.0; + expected_audio.total_audio_energy = 10.0; + expected_audio.total_samples_duration = 11.0; + ASSERT_TRUE(report->Get(expected_audio.id())); EXPECT_EQ( report->Get(expected_audio.id())->cast_to(), @@ -1859,8 +1883,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { video_media_info.receivers[0].firs_sent = 5; video_media_info.receivers[0].plis_sent = 6; video_media_info.receivers[0].nacks_sent = 7; - video_media_info.receivers[0].frames_decoded = 8; + video_media_info.receivers[0].frames_received = 8; + video_media_info.receivers[0].frames_decoded = 9; video_media_info.receivers[0].key_frames_decoded = 3; + video_media_info.receivers[0].frames_dropped = 13; video_media_info.receivers[0].qp_sum = absl::nullopt; video_media_info.receivers[0].total_decode_time_ms = 9000; video_media_info.receivers[0].total_inter_frame_delay = 0.123; @@ -1904,8 +1930,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { expected_video.bytes_received = 3; expected_video.header_bytes_received = 12; expected_video.packets_lost = 42; - expected_video.frames_decoded = 8; + expected_video.frames_received = 8; + expected_video.frames_decoded = 9; expected_video.key_frames_decoded = 3; + expected_video.frames_dropped = 13; // |expected_video.qp_sum| should be undefined. expected_video.total_decode_time = 9.0; expected_video.total_inter_frame_delay = 0.123; diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index a0fd2d0253..751195a702 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -818,13 +818,62 @@ class RTCStatsReportVerifier { // this test. See RFC 3550. verifier.TestMemberIsNonNegative(inbound_stream.packets_lost); verifier.TestMemberIsDefined(inbound_stream.last_packet_received_timestamp); + if (inbound_stream.frames_received.ValueOrDefault(0) > 0) { + verifier.TestMemberIsNonNegative(inbound_stream.frame_width); + verifier.TestMemberIsNonNegative(inbound_stream.frame_height); + } else { + verifier.TestMemberIsUndefined(inbound_stream.frame_width); + verifier.TestMemberIsUndefined(inbound_stream.frame_height); + } + if (inbound_stream.frames_per_second.is_defined()) { + verifier.TestMemberIsNonNegative( + inbound_stream.frames_per_second); + } else { + verifier.TestMemberIsUndefined(inbound_stream.frames_per_second); + } + verifier.TestMemberIsUndefined(inbound_stream.frame_bit_depth); if (inbound_stream.media_type.is_defined() && *inbound_stream.media_type == "video") { verifier.TestMemberIsUndefined(inbound_stream.jitter); + verifier.TestMemberIsUndefined(inbound_stream.jitter_buffer_delay); + verifier.TestMemberIsUndefined( + inbound_stream.jitter_buffer_emitted_count); + verifier.TestMemberIsUndefined(inbound_stream.total_samples_received); + verifier.TestMemberIsUndefined(inbound_stream.concealed_samples); + verifier.TestMemberIsUndefined(inbound_stream.silent_concealed_samples); + verifier.TestMemberIsUndefined(inbound_stream.concealment_events); + verifier.TestMemberIsUndefined( + inbound_stream.inserted_samples_for_deceleration); + verifier.TestMemberIsUndefined( + inbound_stream.removed_samples_for_acceleration); + verifier.TestMemberIsUndefined(inbound_stream.audio_level); + verifier.TestMemberIsUndefined(inbound_stream.total_audio_energy); + verifier.TestMemberIsUndefined(inbound_stream.total_samples_duration); + verifier.TestMemberIsNonNegative(inbound_stream.frames_received); } else { verifier.TestMemberIsNonNegative(inbound_stream.jitter); + verifier.TestMemberIsNonNegative( + inbound_stream.jitter_buffer_delay); + verifier.TestMemberIsNonNegative( + inbound_stream.jitter_buffer_emitted_count); + verifier.TestMemberIsPositive( + inbound_stream.total_samples_received); + verifier.TestMemberIsNonNegative( + inbound_stream.concealed_samples); + verifier.TestMemberIsNonNegative( + inbound_stream.silent_concealed_samples); + verifier.TestMemberIsNonNegative( + inbound_stream.concealment_events); + verifier.TestMemberIsNonNegative( + inbound_stream.inserted_samples_for_deceleration); + verifier.TestMemberIsNonNegative( + inbound_stream.removed_samples_for_acceleration); + verifier.TestMemberIsPositive(inbound_stream.audio_level); + verifier.TestMemberIsPositive(inbound_stream.total_audio_energy); + verifier.TestMemberIsPositive( + inbound_stream.total_samples_duration); + verifier.TestMemberIsUndefined(inbound_stream.frames_received); } - verifier.TestMemberIsUndefined(inbound_stream.round_trip_time); verifier.TestMemberIsUndefined(inbound_stream.packets_discarded); verifier.TestMemberIsUndefined(inbound_stream.packets_repaired); @@ -843,6 +892,7 @@ class RTCStatsReportVerifier { *inbound_stream.media_type == "video") { verifier.TestMemberIsDefined(inbound_stream.frames_decoded); verifier.TestMemberIsDefined(inbound_stream.key_frames_decoded); + verifier.TestMemberIsNonNegative(inbound_stream.frames_dropped); verifier.TestMemberIsNonNegative( inbound_stream.total_decode_time); verifier.TestMemberIsNonNegative( @@ -855,6 +905,7 @@ class RTCStatsReportVerifier { } else { verifier.TestMemberIsUndefined(inbound_stream.frames_decoded); verifier.TestMemberIsUndefined(inbound_stream.key_frames_decoded); + verifier.TestMemberIsUndefined(inbound_stream.frames_dropped); verifier.TestMemberIsUndefined(inbound_stream.total_decode_time); verifier.TestMemberIsUndefined(inbound_stream.total_inter_frame_delay); verifier.TestMemberIsUndefined( diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 6c7b8d2123..ea2ba40bc0 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -604,6 +604,18 @@ WEBRTC_RTCSTATS_IMPL( &packets_lost, &last_packet_received_timestamp, &jitter, + &jitter_buffer_delay, + &jitter_buffer_emitted_count, + &total_samples_received, + &concealed_samples, + &silent_concealed_samples, + &concealment_events, + &inserted_samples_for_deceleration, + &removed_samples_for_acceleration, + &audio_level, + &total_audio_energy, + &total_samples_duration, + &frames_received, &round_trip_time, &packets_discarded, &packets_repaired, @@ -615,8 +627,13 @@ WEBRTC_RTCSTATS_IMPL( &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_inter_frame_delay, &total_squared_inter_frame_delay, @@ -640,6 +657,18 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, packets_lost("packetsLost"), last_packet_received_timestamp("lastPacketReceivedTimestamp"), jitter("jitter"), + jitter_buffer_delay("jitterBufferDelay"), + jitter_buffer_emitted_count("jitterBufferEmittedCount"), + total_samples_received("totalSamplesReceived"), + concealed_samples("concealedSamples"), + silent_concealed_samples("silentConcealedSamples"), + concealment_events("concealmentEvents"), + inserted_samples_for_deceleration("insertedSamplesForDeceleration"), + removed_samples_for_acceleration("removedSamplesForAcceleration"), + audio_level("audioLevel"), + total_audio_energy("totalAudioEnergy"), + total_samples_duration("totalSamplesDuration"), + frames_received("framesReceived"), round_trip_time("roundTripTime"), packets_discarded("packetsDiscarded"), packets_repaired("packetsRepaired"), @@ -651,8 +680,13 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id, 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_inter_frame_delay("totalInterFrameDelay"), total_squared_inter_frame_delay("totalSquaredInterFrameDelay"), @@ -671,6 +705,19 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( 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), @@ -682,8 +729,13 @@ RTCInboundRTPStreamStats::RTCInboundRTPStreamStats( 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),