From d5b51674a1885f3f89eee7fecac4e74f20d5cd93 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 4 May 2023 10:56:07 +0200 Subject: [PATCH] Cleanup usasge of ReportBlockData::report_block accessor in pc/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reduces dependency on the struct RTCPReportBlock and would allow to delete it in favor of class ReportBlockData Bug: None Change-Id: I93874c4f54cf62af0c16ae26e2231b8fb49f195d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304161 Reviewed-by: Henrik Boström Auto-Submit: Danil Chapovalov Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#39985} --- pc/rtc_stats_collector.cc | 32 ++++++++++++------------------ pc/rtc_stats_collector_unittest.cc | 6 ++---- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 8a1ded79f8..e09b495f74 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -849,34 +849,31 @@ CreateOutboundRTPStreamStatsFromVideoSenderInfo( std::unique_ptr ProduceRemoteInboundRtpStreamStatsFromReportBlockData( const std::string& transport_id, - const ReportBlockData& report_block_data, + const ReportBlockData& report_block, cricket::MediaType media_type, const std::map& outbound_rtps, const RTCStatsReport& report) { - const auto& report_block = report_block_data.report_block(); // RTCStats' timestamp generally refers to when the metric was sampled, but // for "remote-[outbound/inbound]-rtp" it refers to the local time when the // Report Block was received. auto remote_inbound = std::make_unique( - RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc(media_type, - report_block.source_ssrc), - report_block_data.report_block_timestamp_utc()); - remote_inbound->ssrc = report_block.source_ssrc; + RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc( + media_type, report_block.source_ssrc()), + report_block.report_block_timestamp_utc()); + remote_inbound->ssrc = report_block.source_ssrc(); remote_inbound->kind = media_type == cricket::MEDIA_TYPE_AUDIO ? "audio" : "video"; - remote_inbound->packets_lost = report_block.packets_lost; - remote_inbound->fraction_lost = - static_cast(report_block.fraction_lost) / (1 << 8); - if (report_block_data.num_rtts() > 0) { - remote_inbound->round_trip_time = - report_block_data.last_rtt().seconds(); + remote_inbound->packets_lost = report_block.cumulative_lost(); + remote_inbound->fraction_lost = report_block.fraction_lost(); + if (report_block.num_rtts() > 0) { + remote_inbound->round_trip_time = report_block.last_rtt().seconds(); } remote_inbound->total_round_trip_time = - report_block_data.sum_rtts().seconds(); - remote_inbound->round_trip_time_measurements = report_block_data.num_rtts(); + report_block.sum_rtts().seconds(); + remote_inbound->round_trip_time_measurements = report_block.num_rtts(); std::string local_id = RTCOutboundRtpStreamStatsIDFromSSRC( - transport_id, media_type, report_block.source_ssrc); + transport_id, media_type, report_block.source_ssrc()); // Look up local stat from `outbound_rtps` where the pointers are non-const. auto local_id_it = outbound_rtps.find(local_id); if (local_id_it != outbound_rtps.end()) { @@ -907,11 +904,8 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData( remote_inbound->codec_id = *outbound_rtp.codec_id; const auto& codec = codec_from_id->cast_to(); if (codec.clock_rate.is_defined()) { - // The Report Block jitter is expressed in RTP timestamp units - // (https://tools.ietf.org/html/rfc3550#section-6.4.1). To convert this - // to seconds we divide by the codec's clock rate. remote_inbound->jitter = - static_cast(report_block.jitter) / *codec.clock_rate; + report_block.jitter(*codec.clock_rate).seconds(); } } } diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 9db5b3f6f9..2358e3bae3 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -3556,8 +3556,7 @@ class RTCStatsCollectorTestWithParamKind for (const auto& report_block_data : report_block_datas) { cricket::VoiceSenderInfo sender; sender.local_stats.push_back(cricket::SsrcSenderInfo()); - sender.local_stats[0].ssrc = - report_block_data.report_block().source_ssrc; + sender.local_stats[0].ssrc = report_block_data.source_ssrc(); if (codec.has_value()) { sender.codec_payload_type = codec->payload_type; voice_media_info.send_codecs.insert( @@ -3574,8 +3573,7 @@ class RTCStatsCollectorTestWithParamKind for (const auto& report_block_data : report_block_datas) { cricket::VideoSenderInfo sender; sender.local_stats.push_back(cricket::SsrcSenderInfo()); - sender.local_stats[0].ssrc = - report_block_data.report_block().source_ssrc; + sender.local_stats[0].ssrc = report_block_data.source_ssrc(); if (codec.has_value()) { sender.codec_payload_type = codec->payload_type; video_media_info.send_codecs.insert(