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(