diff --git a/media/base/media_channel.h b/media/base/media_channel.h index a4a925e912..e9d48701c4 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -426,6 +426,12 @@ struct MediaReceiverInfo { int64_t header_and_padding_bytes_rcvd = 0; int packets_rcvd = 0; int packets_lost = 0; + // Jitter (network-related) latency (cumulative). + // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-jitterbufferdelay + double jitter_buffer_delay_seconds = 0.0; + // Number of observations for cumulative jitter latency. + // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-jitterbufferemittedcount + uint64_t jitter_buffer_emitted_count = 0; // The timestamp at which the last packet was received, i.e. the time of the // local clock when it was received - not the RTP timestamp of that packet. // https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-lastpacketreceivedtimestamp @@ -469,8 +475,6 @@ struct VoiceReceiverInfo : public MediaReceiverInfo { uint64_t concealed_samples = 0; uint64_t silent_concealed_samples = 0; uint64_t concealment_events = 0; - double jitter_buffer_delay_seconds = 0.0; - uint64_t jitter_buffer_emitted_count = 0; double jitter_buffer_target_delay_seconds = 0.0; uint64_t inserted_samples_for_deceleration = 0; uint64_t removed_samples_for_acceleration = 0; @@ -616,12 +620,6 @@ struct VideoReceiverInfo : public MediaReceiverInfo { int max_decode_ms = 0; // Jitter (network-related) latency. int jitter_buffer_ms = 0; - // Jitter (network-related) latency (cumulative). - // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferdelay - double jitter_buffer_delay_seconds = 0; - // Number of observations for cumulative jitter latency. - // https://w3c.github.io/webrtc-stats/#dom-rtcvideoreceiverstats-jitterbufferemittedcount - uint64_t jitter_buffer_emitted_count = 0; // Requested minimum playout latency. int min_playout_delay_ms = 0; // Requested latency to account for rendering delay. diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 2049d835a2..1fa731b912 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -333,6 +333,10 @@ void SetInboundRTPStreamStatsFromMediaReceiverInfo( static_cast(media_receiver_info.header_and_padding_bytes_rcvd); inbound_stats->packets_lost = static_cast(media_receiver_info.packets_lost); + inbound_stats->jitter_buffer_delay = + media_receiver_info.jitter_buffer_delay_seconds; + inbound_stats->jitter_buffer_emitted_count = + media_receiver_info.jitter_buffer_emitted_count; } std::unique_ptr CreateInboundAudioStreamStats( @@ -353,10 +357,6 @@ std::unique_ptr CreateInboundAudioStreamStats( } 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; diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 62b2c4d71f..845454148e 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -1737,7 +1737,7 @@ TEST_F(RTCStatsCollectorTest, voice_receiver_info.inserted_samples_for_deceleration = 987; voice_receiver_info.removed_samples_for_acceleration = 876; voice_receiver_info.silent_concealed_samples = 765; - voice_receiver_info.jitter_buffer_delay_seconds = 3456; + voice_receiver_info.jitter_buffer_delay_seconds = 3.456; voice_receiver_info.jitter_buffer_emitted_count = 13; voice_receiver_info.jitter_buffer_target_delay_seconds = 7.894; voice_receiver_info.jitter_buffer_flushes = 7; @@ -1782,7 +1782,7 @@ TEST_F(RTCStatsCollectorTest, expected_remote_audio_track.inserted_samples_for_deceleration = 987; expected_remote_audio_track.removed_samples_for_acceleration = 876; expected_remote_audio_track.silent_concealed_samples = 765; - expected_remote_audio_track.jitter_buffer_delay = 3456; + expected_remote_audio_track.jitter_buffer_delay = 3.456; expected_remote_audio_track.jitter_buffer_emitted_count = 13; expected_remote_audio_track.jitter_buffer_target_delay = 7.894; expected_remote_audio_track.jitter_buffer_flushes = 7; @@ -2068,6 +2068,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { video_media_info.receivers[0].total_inter_frame_delay = 0.123; video_media_info.receivers[0].total_squared_inter_frame_delay = 0.00456; video_media_info.receivers[0].jitter_ms = 1199; + video_media_info.receivers[0].jitter_buffer_delay_seconds = 3.456; + video_media_info.receivers[0].jitter_buffer_emitted_count = 13; video_media_info.receivers[0].last_packet_received_timestamp_ms = absl::nullopt; @@ -2115,6 +2117,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { expected_video.total_inter_frame_delay = 0.123; expected_video.total_squared_inter_frame_delay = 0.00456; expected_video.jitter = 1.199; + expected_video.jitter_buffer_delay = 3.456; + expected_video.jitter_buffer_emitted_count = 13; // |expected_video.last_packet_received_timestamp| should be undefined. // |expected_video.content_type| should be undefined. // |expected_video.decoder_implementation| should be undefined. diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 90be60003f..c15ffbf94a 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -840,11 +840,12 @@ class RTCStatsReportVerifier { verifier.TestMemberIsUndefined(inbound_stream.frames_per_second); } verifier.TestMemberIsUndefined(inbound_stream.frame_bit_depth); + verifier.TestMemberIsNonNegative( + inbound_stream.jitter_buffer_delay); + verifier.TestMemberIsNonNegative( + inbound_stream.jitter_buffer_emitted_count); if (inbound_stream.media_type.is_defined() && *inbound_stream.media_type == "video") { - 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); @@ -864,10 +865,6 @@ class RTCStatsReportVerifier { verifier.TestMemberIsUndefined(inbound_stream.fir_count); verifier.TestMemberIsUndefined(inbound_stream.pli_count); verifier.TestMemberIsUndefined(inbound_stream.nack_count); - verifier.TestMemberIsNonNegative( - inbound_stream.jitter_buffer_delay); - verifier.TestMemberIsNonNegative( - inbound_stream.jitter_buffer_emitted_count); verifier.TestMemberIsPositive( inbound_stream.total_samples_received); verifier.TestMemberIsNonNegative(