From a97c292a05aa32fd7334ed0470704f95b911529f Mon Sep 17 00:00:00 2001 From: Per K Date: Thu, 30 May 2024 10:40:52 +0000 Subject: [PATCH] Ensure packets are sorted on arrival time in CongestionControlFeedbackGenerator Without this, packets may be sorted in the wrong order. Bug: webrtc:42225697 Change-Id: Ib9a72cdc7cb8f7ef6ca1571d095a6474215a83f2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352821 Reviewed-by: Danil Chapovalov Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#42411} --- .../congestion_control_feedback_generator.cc | 6 ++---- .../congestion_control_feedback_generator_unittest.cc | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc index 6b8c7c21e9..aba35861cc 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_generator.cc @@ -95,10 +95,8 @@ void CongestionControlFeedbackGenerator::SetTransportOverhead( void CongestionControlFeedbackGenerator::SendFeedback(Timestamp now) { absl::c_sort(packets_, [](const PacketInfo& a, const PacketInfo& b) { - if (a.ssrc == b.ssrc) { - return a.unwrapped_sequence_number < b.unwrapped_sequence_number; - } - return a.ssrc < b.ssrc; + return std::tie(a.ssrc, a.unwrapped_sequence_number, a.arrival_time) < + std::tie(b.ssrc, b.unwrapped_sequence_number, b.arrival_time); }); uint32_t compact_ntp = CompactNtp(env_.clock().ConvertTimestampToNtpTime(now)); diff --git a/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc b/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc index b8cb828cd4..ecc6e9a95e 100644 --- a/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc +++ b/modules/remote_bitrate_estimator/congestion_control_feedback_generator_unittest.cc @@ -301,8 +301,7 @@ TEST(CongestionControlFeedbackGeneratorTest, generator.Process(clock.CurrentTime()); } -// TODO: bugs.webrtc.org/42225697 - Figure out why this test is flaky. -TEST(DISABLED_CongestionControlFeedbackGeneratorTest, +TEST(CongestionControlFeedbackGeneratorTest, ReportsFirstReceivedPacketArrivalTimeButEcnFromCePacketIfDuplicate) { MockFunction>)> rtcp_sender;