Commit 42a8e548 authored by Michael Froman's avatar Michael Froman
Browse files

Bug 1828517 - Vendor libwebrtc from 17f783eee8

Upstream commit: https://webrtc.googlesource.com/src/+/17f783eee8b816e659732bc93511f460d692485e
    Skip trimming packet arrival history at the beginning

    PacketArrivalMap explicitly doesn't promise packet at the beginning
    of it is received. Ensuring that property is wasteful

    Bug: chromium:1382563
    Change-Id: Ifc898b7ec2bc7a302af8dcfd233e0c598f62db95
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290501


    Reviewed-by: default avatarPer Kjellander <perkj@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#39083}
parent 26b9379a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20865,3 +20865,6 @@ d22dc86211
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
778742963a
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
17f783eee8
+2 −0
Original line number Diff line number Diff line
@@ -13932,3 +13932,5 @@ libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-l
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:46:42.305967.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:47:37.767078.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /home/mfroman/mozilla/moz-central/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2023-04-21T03:48:37.355759.
+0 −28
Original line number Diff line number Diff line
@@ -69,9 +69,6 @@ void PacketArrivalTimeMap::AddPacket(int64_t sequence_number,
    // Remove oldest entries
    begin_sequence_number_ = new_end_sequence_number - kMaxNumberOfPackets;
    RTC_DCHECK_GT(end_sequence_number_, begin_sequence_number_);
    // Also trim the buffer to remove leading non-received packets, to
    // ensure that the buffer only spans received packets.
    TrimLeadingNotReceivedEntries();
  }

  AdjustToSize(new_end_sequence_number - begin_sequence_number_);
@@ -83,31 +80,6 @@ void PacketArrivalTimeMap::AddPacket(int64_t sequence_number,
  arrival_times_[Index(sequence_number)] = arrival_time;
}

void PacketArrivalTimeMap::TrimLeadingNotReceivedEntries() {
  const int begin_index = Index(begin_sequence_number_);
  const Timestamp* const begin_it = arrival_times_.get() + begin_index;
  const Timestamp* const end_it = arrival_times_.get() + capacity();

  for (const Timestamp* it = begin_it; it != end_it; ++it) {
    if (*it >= Timestamp::Zero()) {
      begin_sequence_number_ += (it - begin_it);
      return;
    }
  }
  // Reached end of the arrival_times_ and all entries represent not received
  // packets. Remove them.
  begin_sequence_number_ += (capacity() - begin_index);
  // Continue removing entries at the beginning of the circular buffer.
  for (const Timestamp* it = arrival_times_.get(); it != begin_it; ++it) {
    if (*it >= Timestamp::Zero()) {
      begin_sequence_number_ += (it - arrival_times_.get());
      return;
    }
  }

  RTC_DCHECK_NOTREACHED() << "There should be at least one non-empty entry";
}

void PacketArrivalTimeMap::SetNotReceived(
    int64_t begin_sequence_number_inclusive,
    int64_t end_sequence_number_exclusive) {
+0 −2
Original line number Diff line number Diff line
@@ -114,8 +114,6 @@ class PacketArrivalTimeMap {
  void SetNotReceived(int64_t begin_sequence_number_inclusive,
                      int64_t end_sequence_number_exclusive);

  void TrimLeadingNotReceivedEntries();

  // Adjust capacity to match new_size, may reduce capacity.
  // On return guarantees capacity >= new_size.
  void AdjustToSize(int new_size);
+0 −19
Original line number Diff line number Diff line
@@ -132,25 +132,6 @@ TEST(PacketArrivalMapTest, GrowsBufferAndRemoveOld) {
  EXPECT_FALSE(map.has_received(kLargeSeq + 1));
}

TEST(PacketArrivalMapTest, GrowsBufferAndRemoveOldTrimsBeginning) {
  PacketArrivalTimeMap map;

  constexpr int64_t kLargeSeq = 42 + PacketArrivalTimeMap::kMaxNumberOfPackets;
  map.AddPacket(42, Timestamp::Millis(10));
  // Missing: 43, 44
  map.AddPacket(45, Timestamp::Millis(13));
  map.AddPacket(kLargeSeq, Timestamp::Millis(12));

  EXPECT_EQ(map.begin_sequence_number(), 45);
  EXPECT_EQ(map.end_sequence_number(), kLargeSeq + 1);

  EXPECT_FALSE(map.has_received(44));
  EXPECT_TRUE(map.has_received(45));
  EXPECT_FALSE(map.has_received(46));
  EXPECT_TRUE(map.has_received(kLargeSeq));
  EXPECT_FALSE(map.has_received(kLargeSeq + 1));
}

TEST(PacketArrivalMapTest, SequenceNumberJumpsDeletesAll) {
  PacketArrivalTimeMap map;

Loading