diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index b370381751..059fb0d68f 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -549,8 +549,6 @@ class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats { RTCStatsMember frames_per_second; RTCStatsMember frames_sent; RTCStatsMember huge_frames_sent; - // TODO(https://crbug.com/webrtc/10635): This is only implemented for video; - // implement it for audio as well. RTCStatsMember total_packet_send_delay; // Enum type RTCQualityLimitationReason RTCStatsMember quality_limitation_reason; diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index e4e9b5748e..097ffcb835 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -441,6 +441,7 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( call_stats.header_and_padding_bytes_sent; stats.retransmitted_bytes_sent = call_stats.retransmitted_bytes_sent; stats.packets_sent = call_stats.packetsSent; + stats.total_packet_send_delay = call_stats.total_packet_send_delay; stats.retransmitted_packets_sent = call_stats.retransmitted_packets_sent; // RTT isn't known until a RTCP report is received. Until then, VoiceEngine // returns 0 to indicate an error value. diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 73b3851fdb..d2604061b8 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -779,6 +779,7 @@ CallSendStatistics ChannelSend::GetRTCPStatistics() const { stats.retransmitted_bytes_sent = rtp_stats.retransmitted.payload_bytes; stats.packetsSent = rtp_stats.transmitted.packets + rtx_stats.transmitted.packets; + stats.total_packet_send_delay = rtp_stats.transmitted.total_packet_delay; stats.retransmitted_packets_sent = rtp_stats.retransmitted.packets; stats.report_block_datas = rtp_rtcp_->GetLatestReportBlockData(); diff --git a/audio/channel_send.h b/audio/channel_send.h index a555b89171..cf9a273f70 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -39,6 +39,8 @@ struct CallSendStatistics { // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent uint64_t retransmitted_bytes_sent; int packetsSent; + // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay + TimeDelta total_packet_send_delay = TimeDelta::Zero(); // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent uint64_t retransmitted_packets_sent; // A snapshot of Report Blocks with additional data of interest to statistics. diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 25d086beaa..15b439c593 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -46,6 +46,8 @@ class AudioSendStream : public AudioSender { // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedbytessent uint64_t retransmitted_bytes_sent = 0; int32_t packets_sent = 0; + // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay + TimeDelta total_packet_send_delay = TimeDelta::Zero(); // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-retransmittedpacketssent uint64_t retransmitted_packets_sent = 0; int32_t packets_lost = -1; diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 5e7f1521da..721bbd3948 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -405,6 +405,8 @@ struct MediaSenderInfo { // the SSRC of the corresponding outbound RTP stream, is unique. std::vector report_block_datas; absl::optional active; + // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay + webrtc::TimeDelta total_packet_send_delay = webrtc::TimeDelta::Zero(); }; struct MediaReceiverInfo { @@ -595,8 +597,6 @@ struct VideoSenderInfo : public MediaSenderInfo { uint64_t total_encode_time_ms = 0; // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalencodedbytestarget uint64_t total_encoded_bytes_target = 0; - // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-totalpacketsenddelay - webrtc::TimeDelta total_packet_send_delay = webrtc::TimeDelta::Zero(); bool has_entered_low_resolution = false; absl::optional qp_sum; webrtc::VideoContentType content_type = webrtc::VideoContentType::UNSPECIFIED; diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index e090fcf62f..ef729f4f87 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -2288,6 +2288,7 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info, sinfo.header_and_padding_bytes_sent = stats.header_and_padding_bytes_sent; sinfo.retransmitted_bytes_sent = stats.retransmitted_bytes_sent; sinfo.packets_sent = stats.packets_sent; + sinfo.total_packet_send_delay = stats.total_packet_send_delay; sinfo.retransmitted_packets_sent = stats.retransmitted_packets_sent; sinfo.packets_lost = stats.packets_lost; sinfo.fraction_lost = stats.fraction_lost; diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 909f5a8892..4a55467c15 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -665,6 +665,8 @@ void SetOutboundRTPStreamStatsFromMediaSenderInfo( outbound_stats->ssrc = media_sender_info.ssrc(); outbound_stats->packets_sent = static_cast(media_sender_info.packets_sent); + outbound_stats->total_packet_send_delay = + media_sender_info.total_packet_send_delay.seconds(); outbound_stats->retransmitted_packets_sent = media_sender_info.retransmitted_packets_sent; outbound_stats->bytes_sent = @@ -674,7 +676,6 @@ void SetOutboundRTPStreamStatsFromMediaSenderInfo( outbound_stats->retransmitted_bytes_sent = media_sender_info.retransmitted_bytes_sent; outbound_stats->nack_count = media_sender_info.nacks_rcvd; - if (media_sender_info.active.has_value()) { outbound_stats->active = *media_sender_info.active; } @@ -764,8 +765,6 @@ void SetOutboundRTPStreamStatsFromVideoSenderInfo( } outbound_video->frames_sent = video_sender_info.frames_sent; outbound_video->huge_frames_sent = video_sender_info.huge_frames_sent; - outbound_video->total_packet_send_delay = - video_sender_info.total_packet_send_delay.seconds(); outbound_video->quality_limitation_reason = QualityLimitationReasonToRTCQualityLimitationReason( video_sender_info.quality_limitation_reason); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index d21d68728f..4422938990 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -2758,6 +2758,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); voice_media_info.senders[0].local_stats[0].ssrc = 1; voice_media_info.senders[0].packets_sent = 2; + voice_media_info.senders[0].total_packet_send_delay = TimeDelta::Seconds(1); voice_media_info.senders[0].retransmitted_packets_sent = 20; voice_media_info.senders[0].payload_bytes_sent = 3; voice_media_info.senders[0].header_and_padding_bytes_sent = 12; @@ -2795,6 +2796,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { expected_audio.transport_id = "TTransportName1"; expected_audio.codec_id = "COTTransportName1_42"; expected_audio.packets_sent = 2; + expected_audio.total_packet_send_delay = 1; expected_audio.retransmitted_packets_sent = 20; expected_audio.bytes_sent = 3; expected_audio.header_bytes_sent = 12; @@ -3192,6 +3194,7 @@ TEST_F(RTCStatsCollectorTest, CollectNoStreamRTCOutboundRTPStreamStats_Audio) { voice_media_info.senders[0].local_stats.push_back(cricket::SsrcSenderInfo()); voice_media_info.senders[0].local_stats[0].ssrc = 1; voice_media_info.senders[0].packets_sent = 2; + voice_media_info.senders[0].total_packet_send_delay = TimeDelta::Seconds(0.5); voice_media_info.senders[0].retransmitted_packets_sent = 20; voice_media_info.senders[0].payload_bytes_sent = 3; voice_media_info.senders[0].header_and_padding_bytes_sent = 4; @@ -3228,6 +3231,7 @@ TEST_F(RTCStatsCollectorTest, CollectNoStreamRTCOutboundRTPStreamStats_Audio) { expected_audio.transport_id = "TTransportName1"; expected_audio.codec_id = "COTTransportName1_42"; expected_audio.packets_sent = 2; + expected_audio.total_packet_send_delay = 0.5; expected_audio.retransmitted_packets_sent = 20; expected_audio.bytes_sent = 3; expected_audio.header_bytes_sent = 4; diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 8310bee102..d170871c64 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -998,6 +998,8 @@ class RTCStatsReportVerifier { verifier.TestMemberIsOptionalIDReference( outbound_stream.remote_id, RTCRemoteInboundRtpStreamStats::kType); verifier.TestMemberIsNonNegative(outbound_stream.packets_sent); + verifier.TestMemberIsNonNegative( + outbound_stream.total_packet_send_delay); verifier.TestMemberIsNonNegative( outbound_stream.retransmitted_packets_sent); verifier.TestMemberIsNonNegative(outbound_stream.bytes_sent); @@ -1013,8 +1015,6 @@ class RTCStatsReportVerifier { outbound_stream.total_encode_time); verifier.TestMemberIsNonNegative( outbound_stream.total_encoded_bytes_target); - verifier.TestMemberIsNonNegative( - outbound_stream.total_packet_send_delay); verifier.TestMemberIsDefined(outbound_stream.quality_limitation_reason); verifier.TestMemberIsDefined( outbound_stream.quality_limitation_durations); @@ -1047,8 +1047,6 @@ class RTCStatsReportVerifier { verifier.TestMemberIsUndefined(outbound_stream.total_encode_time); verifier.TestMemberIsUndefined( outbound_stream.total_encoded_bytes_target); - // TODO(https://crbug.com/webrtc/10635): Implement for audio as well. - verifier.TestMemberIsUndefined(outbound_stream.total_packet_send_delay); verifier.TestMemberIsUndefined(outbound_stream.quality_limitation_reason); verifier.TestMemberIsUndefined( outbound_stream.quality_limitation_durations);