In RtpTransportController reduce information stored about rtcp report blocks

Store just the fields that are used by RtpTransportController
Avoid redundand map lookup when updating that information

Bug: webrtc:13757
Change-Id: I1e5a000557bde1735979c1cf8fa762936a64ffd0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305023
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Emil Lundmark <lndmrk@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40063}
This commit is contained in:
Danil Chapovalov 2023-05-15 09:28:02 +02:00 committed by WebRTC LUCI CQ
parent eb97ac5f29
commit 121f1e7a01
2 changed files with 16 additions and 9 deletions

View File

@ -670,15 +670,18 @@ void RtpTransportControllerSend::OnReceivedRtcpReceiverReportBlocks(
// Compute the packet loss from all report blocks.
for (const RTCPReportBlock& report_block : report_blocks) {
auto it = last_report_blocks_.find(report_block.source_ssrc);
if (it != last_report_blocks_.end()) {
auto number_of_packets = report_block.extended_highest_sequence_number -
it->second.extended_highest_sequence_number;
total_packets_delta += number_of_packets;
auto lost_delta = report_block.packets_lost - it->second.packets_lost;
total_packets_lost_delta += lost_delta;
auto [it, inserted] =
last_report_blocks_.try_emplace(report_block.source_ssrc);
LossReport& last_loss_report = it->second;
if (!inserted) {
total_packets_delta += report_block.extended_highest_sequence_number -
last_loss_report.extended_highest_sequence_number;
total_packets_lost_delta +=
report_block.packets_lost - last_loss_report.cumulative_lost;
}
last_report_blocks_[report_block.source_ssrc] = report_block;
last_loss_report.extended_highest_sequence_number =
report_block.extended_highest_sequence_number;
last_loss_report.cumulative_lost = report_block.packets_lost;
}
// Can only compute delta if there has been previous blocks to compare to. If
// not, total_packets_delta will be unchanged and there's nothing more to do.

View File

@ -179,7 +179,11 @@ class RtpTransportControllerSend final
TimeDelta process_interval_ RTC_GUARDED_BY(sequence_checker_);
std::map<uint32_t, RTCPReportBlock> last_report_blocks_
struct LossReport {
uint32_t extended_highest_sequence_number = 0;
int cumulative_lost = 0;
};
std::map<uint32_t, LossReport> last_report_blocks_
RTC_GUARDED_BY(sequence_checker_);
Timestamp last_report_block_time_ RTC_GUARDED_BY(sequence_checker_);