From 60f8200f42e88eb604088106c4a364ed6c0a6fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 4 Nov 2022 13:41:44 +0100 Subject: [PATCH] libwebrtc fixes and updates (#944) - Fix calculation of feedback min_pending_time in goog_cc - Fixes #849 - Commit in libwebrtc: https://webrtc.googlesource.com/src/+/d65dc979b17cdc7cd359aada59e5bce8a6f1b8ce%5E%21/ - Fix signed-to-unsigned overflow in send_side_bandwidth_estimation.cc - Fixes #872 - Issue in libwebrtc: https://bugs.chromium.org/p/webrtc/issues/detail?id=14272 - Commit in libwebrtc: https://webrtc.googlesource.com/src/+/9804aa5f6ad26a45338d685da66497c3bbd88ca6%5E%21/ NOTE: Some changes are already present in ongoing PR https://github.com/versatica/mediasoup/pull/922 but it's not yet merged. --- CHANGELOG.md | 3 ++- .../send_side_bandwidth_estimation.cc | 17 ++++++++++------- .../goog_cc/goog_cc_network_control.cc | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014f12cd87..0556668b37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * `DataConsumer`: Fix `bufferedAmount` type to be a number again (PR #936). * `ActiveSpeakerObserver`: Fix 'dominantspeaker' event by having a single `Producer` as argument rather than an array with a single `Producer` into it (PR #941). * `ActiveSpeakerObserver`: Fix memory leak (PR #942). +* Fix some libwebrtc issues (PR #944). * Update NPM deps. @@ -19,7 +20,7 @@ ### 3.10.11 -* RTCP: Fix trailing space needed by srtp_protect_rtcp() (PR #929). +* RTCP: Fix trailing space needed by `srtp_protect_rtcp()` (PR #929). ### 3.10.10 diff --git a/worker/deps/libwebrtc/libwebrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/worker/deps/libwebrtc/libwebrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc index b6461789aa..2b12cf0fe2 100644 --- a/worker/deps/libwebrtc/libwebrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc +++ b/worker/deps/libwebrtc/libwebrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc @@ -382,26 +382,29 @@ void SendSideBandwidthEstimation::UpdatePacketsLost(int packets_lost, // Check sequence number diff and weight loss report if (number_of_packets > 0) { - // Accumulate reports. - lost_packets_since_last_loss_update_ += packets_lost; - expected_packets_since_last_loss_update_ += number_of_packets; + int64_t expected = + expected_packets_since_last_loss_update_ + number_of_packets; // Don't generate a loss rate until it can be based on enough packets. - if (expected_packets_since_last_loss_update_ < kLimitNumPackets) + if (expected < kLimitNumPackets) { + // Accumulate reports. + expected_packets_since_last_loss_update_ = expected; + lost_packets_since_last_loss_update_ += packets_lost; return; + } has_decreased_since_last_fraction_loss_ = false; - int64_t lost_q8 = lost_packets_since_last_loss_update_ << 8; - int64_t expected = expected_packets_since_last_loss_update_; + int64_t lost_q8 = + std::max(lost_packets_since_last_loss_update_ + packets_lost, 0) << 8; last_fraction_loss_ = std::min(lost_q8 / expected, 255); // Reset accumulators. - lost_packets_since_last_loss_update_ = 0; expected_packets_since_last_loss_update_ = 0; last_loss_packet_report_ = at_time; UpdateEstimate(at_time); } + UpdateUmaStatsPacketsLost(at_time, packets_lost); } diff --git a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index abc4320ee2..aced2db317 100644 --- a/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -431,7 +431,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( for (const auto& feedback : feedbacks) { TimeDelta feedback_rtt = report.feedback_time - feedback.sent_packet.send_time; - TimeDelta min_pending_time = feedback.receive_time - max_recv_time; + TimeDelta min_pending_time = max_recv_time - feedback.receive_time; TimeDelta propagation_rtt = feedback_rtt - min_pending_time; max_feedback_rtt = std::max(max_feedback_rtt, feedback_rtt); min_propagation_rtt = std::min(min_propagation_rtt, propagation_rtt);