[Stats] If remote-inbound-rtp has no RTT, leave it undefined.

Bug: webrtc:14692
Change-Id: I49878449cd91b590f1aedef7676c3715d563ac61
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284660
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Auto-Submit: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38706}
This commit is contained in:
Henrik Boström 2022-11-22 09:56:49 +01:00 committed by WebRTC LUCI CQ
parent dd35e244ce
commit a3a3b6d798
2 changed files with 31 additions and 3 deletions

View File

@ -815,9 +815,11 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData(
remote_inbound->packets_lost = report_block.packets_lost;
remote_inbound->fraction_lost =
static_cast<double>(report_block.fraction_lost) / (1 << 8);
remote_inbound->round_trip_time =
static_cast<double>(report_block_data.last_rtt_ms()) /
rtc::kNumMillisecsPerSec;
if (report_block_data.num_rtts() > 0) {
remote_inbound->round_trip_time =
static_cast<double>(report_block_data.last_rtt_ms()) /
rtc::kNumMillisecsPerSec;
}
remote_inbound->total_round_trip_time =
static_cast<double>(report_block_data.sum_rtt_ms()) /
rtc::kNumMillisecsPerSec;

View File

@ -3557,6 +3557,32 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
}
}
TEST_P(RTCStatsCollectorTestWithParamKind,
RTCRemoteInboundRtpStreamStatsRttMissingBeforeMeasurement) {
constexpr int64_t kReportBlockTimestampUtcUs = 123456789;
RTCPReportBlock report_block;
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
// `source_ssrc`, "SSRC of the RTP packet sender".
report_block.source_ssrc = 12;
ReportBlockData report_block_data; // AddRoundTripTimeSample() not called.
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
AddSenderInfoAndMediaChannel("TransportName", {report_block_data},
absl::nullopt);
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
std::string remote_inbound_rtp_id = "RI" + MediaTypeCharStr() + "12";
ASSERT_TRUE(report->Get(remote_inbound_rtp_id));
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
->cast_to<RTCRemoteInboundRtpStreamStats>();
EXPECT_TRUE(remote_inbound_rtp.round_trip_time_measurements.is_defined());
EXPECT_EQ(0, *remote_inbound_rtp.round_trip_time_measurements);
EXPECT_FALSE(remote_inbound_rtp.round_trip_time.is_defined());
}
TEST_P(RTCStatsCollectorTestWithParamKind,
RTCRemoteInboundRtpStreamStatsWithTimestampFromReportBlock) {
const int64_t kReportBlockTimestampUtcUs = 123456789;