diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index f328326745..46bc018372 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -556,6 +556,8 @@ class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats { RTCStatsMember local_id; RTCStatsMember round_trip_time; RTCStatsMember fraction_lost; + RTCStatsMember total_round_trip_time; + RTCStatsMember round_trip_time_measurements; }; // https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index aa3b17bb7f..6cb1dcc7a9 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -546,6 +546,11 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData( remote_inbound->round_trip_time = static_cast(report_block_data.last_rtt_ms()) / rtc::kNumMillisecsPerSec; + remote_inbound->total_round_trip_time = + static_cast(report_block_data.sum_rtt_ms()) / + rtc::kNumMillisecsPerSec; + remote_inbound->round_trip_time_measurements = + report_block_data.num_rtts(); std::string local_id = RTCOutboundRTPStreamStatsIDFromSSRC( media_type == cricket::MEDIA_TYPE_AUDIO, report_block.source_ssrc); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 13c8f980ee..aa8bff0a54 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -2676,9 +2676,11 @@ class RTCStatsCollectorTestWithParamKind TEST_P(RTCStatsCollectorTestWithParamKind, RTCRemoteInboundRtpStreamStatsCollectedFromReportBlock) { const int64_t kReportBlockTimestampUtcUs = 123456789; - const int64_t kRoundTripTimeMs = 13000; - const double kRoundTripTimeSeconds = 13.0; const uint8_t kFractionLost = 12; + const int64_t kRoundTripTimeSample1Ms = 1234; + const double kRoundTripTimeSample1Seconds = 1.234; + const int64_t kRoundTripTimeSample2Ms = 13000; + const double kRoundTripTimeSample2Seconds = 13; // The report block's timestamp cannot be from the future, set the fake clock // to match. @@ -2694,10 +2696,10 @@ TEST_P(RTCStatsCollectorTestWithParamKind, report_block.fraction_lost = kFractionLost; ReportBlockData report_block_data; report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs); - report_block_data.AddRoundTripTimeSample(1234); + report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample1Ms); // Only the last sample should be exposed as the // |RTCRemoteInboundRtpStreamStats::round_trip_time|. - report_block_data.AddRoundTripTimeSample(kRoundTripTimeMs); + report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample2Ms); report_block_datas.push_back(report_block_data); } AddSenderInfoAndMediaChannel("TransportName", report_block_datas, @@ -2719,7 +2721,10 @@ TEST_P(RTCStatsCollectorTestWithParamKind, expected_remote_inbound_rtp.packets_lost = 7; expected_remote_inbound_rtp.local_id = "RTCOutboundRTP" + MediaTypeUpperCase() + stream_id; - expected_remote_inbound_rtp.round_trip_time = kRoundTripTimeSeconds; + expected_remote_inbound_rtp.round_trip_time = kRoundTripTimeSample2Seconds; + expected_remote_inbound_rtp.total_round_trip_time = + kRoundTripTimeSample1Seconds + kRoundTripTimeSample2Seconds; + expected_remote_inbound_rtp.round_trip_time_measurements = 2; // This test does not set up RTCCodecStats, so |codec_id| and |jitter| are // expected to be missing. These are tested separately. diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 82f07cf4c6..63426673d8 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -1022,6 +1022,10 @@ class RTCStatsReportVerifier { RTCOutboundRTPStreamStats::kType); verifier.TestMemberIsNonNegative( remote_inbound_stream.round_trip_time); + verifier.TestMemberIsNonNegative( + remote_inbound_stream.total_round_trip_time); + verifier.TestMemberIsNonNegative( + remote_inbound_stream.round_trip_time_measurements); return verifier.ExpectAllMembersSuccessfullyTested(); } diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 4e743dae2c..e234705767 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -849,7 +849,9 @@ WEBRTC_RTCSTATS_IMPL( &jitter, &local_id, &round_trip_time, - &fraction_lost) + &fraction_lost, + &total_round_trip_time, + &round_trip_time_measurements) // clang-format on RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( @@ -869,7 +871,9 @@ RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( jitter("jitter"), local_id("localId"), round_trip_time("roundTripTime"), - fraction_lost("fractionLost") {} + fraction_lost("fractionLost"), + total_round_trip_time("totalRoundTripTime"), + round_trip_time_measurements("roundTripTimeMeasurements") {} RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( const RTCRemoteInboundRtpStreamStats& other) @@ -882,7 +886,9 @@ RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( jitter(other.jitter), local_id(other.local_id), round_trip_time(other.round_trip_time), - fraction_lost(other.fraction_lost) {} + fraction_lost(other.fraction_lost), + total_round_trip_time(other.total_round_trip_time), + round_trip_time_measurements(other.round_trip_time_measurements) {} RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}