webrtc_m130/modules/rtp_rtcp/source/rtp_packet_history.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

304 lines
9.8 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/rtp_rtcp/source/rtp_packet_history.h"
#include <algorithm>
#include <limits>
#include <utility>
#include "absl/memory/memory.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
namespace {
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
// Min packet size for BestFittingPacket() to honor.
constexpr size_t kMinPacketRequestBytes = 50;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
// Utility function to get the absolute difference in size between the provided
// target size and the size of packet.
size_t SizeDiff(size_t packet_size, size_t size) {
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
if (packet_size > size) {
return packet_size - size;
}
return size - packet_size;
}
} // namespace
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
constexpr size_t RtpPacketHistory::kMaxCapacity;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
constexpr int64_t RtpPacketHistory::kMinPacketDurationMs;
constexpr int RtpPacketHistory::kMinPacketDurationRtt;
constexpr int RtpPacketHistory::kPacketCullingDelayFactor;
RtpPacketHistory::PacketState::PacketState() = default;
RtpPacketHistory::PacketState::PacketState(const PacketState&) = default;
RtpPacketHistory::PacketState::~PacketState() = default;
Revert "Rework rtp packet history" This reverts commit 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887. Reason for revert: Breaks downstream build, due to use of std::pair constructor that some compilers appear to not support yet. See comment. Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: I2fa7efc7d008c56f7a8f77bc9958c19119f69de8 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/60880 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22350}
2018-03-08 23:41:12 +00:00
RtpPacketHistory::StoredPacket::StoredPacket() = default;
RtpPacketHistory::StoredPacket::StoredPacket(StoredPacket&&) = default;
RtpPacketHistory::StoredPacket& RtpPacketHistory::StoredPacket::operator=(
RtpPacketHistory::StoredPacket&&) = default;
RtpPacketHistory::StoredPacket::~StoredPacket() = default;
RtpPacketHistory::RtpPacketHistory(Clock* clock)
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
: clock_(clock),
number_to_store_(0),
mode_(StorageMode::kDisabled),
rtt_ms_(-1) {}
RtpPacketHistory::~RtpPacketHistory() {}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
void RtpPacketHistory::SetStorePacketsStatus(StorageMode mode,
size_t number_to_store) {
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
RTC_DCHECK_LE(number_to_store, kMaxCapacity);
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
rtc::CritScope cs(&lock_);
if (mode != StorageMode::kDisabled && mode_ != StorageMode::kDisabled) {
RTC_LOG(LS_WARNING) << "Purging packet history in order to re-set status.";
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
Reset();
mode_ = mode;
number_to_store_ = std::min(kMaxCapacity, number_to_store);
}
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
RtpPacketHistory::StorageMode RtpPacketHistory::GetStorageMode() const {
rtc::CritScope cs(&lock_);
return mode_;
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
void RtpPacketHistory::SetRtt(int64_t rtt_ms) {
rtc::CritScope cs(&lock_);
RTC_DCHECK_GE(rtt_ms, 0);
rtt_ms_ = rtt_ms;
}
void RtpPacketHistory::PutRtpPacket(std::unique_ptr<RtpPacketToSend> packet,
StorageType type,
absl::optional<int64_t> send_time_ms) {
RTC_DCHECK(packet);
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
rtc::CritScope cs(&lock_);
int64_t now_ms = clock_->TimeInMilliseconds();
if (mode_ == StorageMode::kDisabled) {
return;
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
CullOldPackets(now_ms);
// Store packet.
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
const uint16_t rtp_seq_no = packet->SequenceNumber();
StoredPacket& stored_packet = packet_history_[rtp_seq_no];
RTC_DCHECK(stored_packet.packet == nullptr);
stored_packet.packet = std::move(packet);
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
if (stored_packet.packet->capture_time_ms() <= 0) {
stored_packet.packet->set_capture_time_ms(now_ms);
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
stored_packet.send_time_ms = send_time_ms;
stored_packet.storage_type = type;
stored_packet.times_retransmitted = 0;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
if (!start_seqno_) {
start_seqno_ = rtp_seq_no;
}
// Store the sequence number of the last send packet with this size.
packet_size_[stored_packet.packet->size()] = rtp_seq_no;
}
std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPacketAndSetSendTime(
uint16_t sequence_number,
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
bool verify_rtt) {
rtc::CritScope cs(&lock_);
if (mode_ == StorageMode::kDisabled) {
return nullptr;
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
int64_t now_ms = clock_->TimeInMilliseconds();
StoredPacketIterator rtp_it = packet_history_.find(sequence_number);
if (rtp_it == packet_history_.end()) {
return nullptr;
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
StoredPacket& packet = rtp_it->second;
if (verify_rtt && !VerifyRtt(rtp_it->second, now_ms)) {
return nullptr;
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
if (packet.send_time_ms) {
++packet.times_retransmitted;
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
// Update send-time and return copy of packet instance.
packet.send_time_ms = now_ms;
if (packet.storage_type == StorageType::kDontRetransmit) {
// Non retransmittable packet, so call must come from paced sender.
// Remove from history and return actual packet instance.
return RemovePacket(rtp_it);
}
return absl::make_unique<RtpPacketToSend>(*packet.packet);
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22356}
2018-03-09 09:52:59 +01:00
}
absl::optional<RtpPacketHistory::PacketState> RtpPacketHistory::GetPacketState(
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
uint16_t sequence_number,
bool verify_rtt) const {
rtc::CritScope cs(&lock_);
if (mode_ == StorageMode::kDisabled) {
return absl::nullopt;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
}
auto rtp_it = packet_history_.find(sequence_number);
if (rtp_it == packet_history_.end()) {
return absl::nullopt;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
}
if (verify_rtt && !VerifyRtt(rtp_it->second, clock_->TimeInMilliseconds())) {
return absl::nullopt;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
}
return StoredPacketToPacketState(rtp_it->second);
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
bool RtpPacketHistory::VerifyRtt(const RtpPacketHistory::StoredPacket& packet,
int64_t now_ms) const {
if (packet.send_time_ms) {
// Send-time already set, this check must be for a retransmission.
if (packet.times_retransmitted > 0 &&
now_ms < *packet.send_time_ms + rtt_ms_) {
// This packet has already been retransmitted once, and the time since
// that even is lower than on RTT. Ignore request as this packet is
// likely already in the network pipe.
return false;
}
Revert "Rework rtp packet history" This reverts commit 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887. Reason for revert: Breaks downstream build, due to use of std::pair constructor that some compilers appear to not support yet. See comment. Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: I2fa7efc7d008c56f7a8f77bc9958c19119f69de8 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/60880 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22350}
2018-03-08 23:41:12 +00:00
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
return true;
}
std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetBestFittingPacket(
size_t packet_length) const {
// TODO(sprang): Make this smarter, taking retransmit count etc into account.
rtc::CritScope cs(&lock_);
if (packet_length < kMinPacketRequestBytes || packet_size_.empty()) {
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
return nullptr;
Revert "Reland "Rework rtp packet history"" This reverts commit 7bb37b884b197ea22e2830b043c09018c186bad5. Reason for revert: Breaks downstream projects Original change's description: > Reland "Rework rtp packet history" > > This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 > > Original change's description: > > Rework rtp packet history > > > > This CL rewrites the history from the ground up, but keeps the logic > > (mostly) intact. It does however lay the groundwork for adding a new > > mode where TransportFeedback messages can be used to remove packets > > from the history as we know the remote end has received them. > > > > This should both reduce memory usage and make the payload based padding > > a little more likely to be useful. > > > > My tests show a reduction of ca 500-800kB reduction in memory usage per > > rtp module. So with simulcast and/or fec this will increase. Lossy > > links and long RTT will use more memory. > > > > I've also slightly update the interface to make usage with/without > > pacer less unintuitive, and avoid making a copy of the entire RTP > > packet just to find the ssrc and sequence number to put into the pacer. > > > > The more aggressive culling is not enabled by default. I will > > wire that up in a follow-up CL, as there's some interface refactoring > > required. > > > > Bug: webrtc:8975 > > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > > Reviewed-on: https://webrtc-review.googlesource.com/59441 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#22347} > > Bug: webrtc:8975 > Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b > Reviewed-on: https://webrtc-review.googlesource.com/60900 > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22356} TBR=danilchap@webrtc.org,sprang@webrtc.org Change-Id: Id698f5dbba6f9f871f37501d056e2b8463ebae50 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8975 Reviewed-on: https://webrtc-review.googlesource.com/61020 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Commit-Queue: Oleh Prypin <oprypin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22358}
2018-03-09 12:27:24 +00:00
}
auto size_iter_upper = packet_size_.upper_bound(packet_length);
auto size_iter_lower = size_iter_upper;
if (size_iter_upper == packet_size_.end()) {
--size_iter_upper;
}
if (size_iter_lower != packet_size_.begin()) {
--size_iter_lower;
}
const size_t upper_bound_diff =
SizeDiff(size_iter_upper->first, packet_length);
const size_t lower_bound_diff =
SizeDiff(size_iter_lower->first, packet_length);
const uint16_t seq_no = upper_bound_diff < lower_bound_diff
? size_iter_upper->second
: size_iter_lower->second;
RtpPacketToSend* best_packet =
packet_history_.find(seq_no)->second.packet.get();
return absl::make_unique<RtpPacketToSend>(*best_packet);
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
void RtpPacketHistory::Reset() {
packet_history_.clear();
packet_size_.clear();
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
start_seqno_.reset();
}
void RtpPacketHistory::CullOldPackets(int64_t now_ms) {
int64_t packet_duration_ms =
std::max(kMinPacketDurationRtt * rtt_ms_, kMinPacketDurationMs);
while (!packet_history_.empty()) {
auto stored_packet_it = packet_history_.find(*start_seqno_);
RTC_DCHECK(stored_packet_it != packet_history_.end());
if (packet_history_.size() >= kMaxCapacity) {
// We have reached the absolute max capacity, remove one packet
// unconditionally.
RemovePacket(stored_packet_it);
continue;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
}
const StoredPacket& stored_packet = stored_packet_it->second;
if (!stored_packet.send_time_ms) {
// Don't remove packets that have not been sent.
return;
}
if (*stored_packet.send_time_ms + packet_duration_ms > now_ms) {
// Don't cull packets too early to avoid failed retransmission requests.
return;
}
if (packet_history_.size() >= number_to_store_ ||
(mode_ == StorageMode::kStoreAndCull &&
*stored_packet.send_time_ms +
(packet_duration_ms * kPacketCullingDelayFactor) <=
now_ms)) {
// Too many packets in history, or this packet has timed out. Remove it
// and continue.
RemovePacket(stored_packet_it);
} else {
// No more packets can be removed right now.
return;
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: Ibbdbcc3c13bd58d994ad66f789a95ef9bd9bc19b Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22356}
2018-03-09 09:52:59 +01:00
}
}
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
std::unique_ptr<RtpPacketToSend> RtpPacketHistory::RemovePacket(
StoredPacketIterator packet_it) {
// Move the packet out from the StoredPacket container.
std::unique_ptr<RtpPacketToSend> rtp_packet =
std::move(packet_it->second.packet);
// Erase the packet from the map, and capture iterator to the next one.
StoredPacketIterator next_it = packet_history_.erase(packet_it);
// |next_it| now points to the next element, or to the end. If the end,
// check if we can wrap around.
if (next_it == packet_history_.end()) {
next_it = packet_history_.begin();
}
// Update |start_seq_no| to the new oldest item.
if (next_it != packet_history_.end()) {
start_seqno_ = next_it->first;
} else {
start_seqno_.reset();
}
auto size_iterator = packet_size_.find(rtp_packet->size());
RTC_CHECK(size_iterator != packet_size_.end());
if (size_iterator->second == rtp_packet->SequenceNumber()) {
packet_size_.erase(size_iterator);
}
Reland "Rework rtp packet history" This is a reland of 6328d7cbbc8a72fdc81a766c0bf4039e1e2e7887 Original change's description: > Rework rtp packet history > > This CL rewrites the history from the ground up, but keeps the logic > (mostly) intact. It does however lay the groundwork for adding a new > mode where TransportFeedback messages can be used to remove packets > from the history as we know the remote end has received them. > > This should both reduce memory usage and make the payload based padding > a little more likely to be useful. > > My tests show a reduction of ca 500-800kB reduction in memory usage per > rtp module. So with simulcast and/or fec this will increase. Lossy > links and long RTT will use more memory. > > I've also slightly update the interface to make usage with/without > pacer less unintuitive, and avoid making a copy of the entire RTP > packet just to find the ssrc and sequence number to put into the pacer. > > The more aggressive culling is not enabled by default. I will > wire that up in a follow-up CL, as there's some interface refactoring > required. > > Bug: webrtc:8975 > Change-Id: I0c1bb528f32eeed0fb276b4ae77ae3235656980f > Reviewed-on: https://webrtc-review.googlesource.com/59441 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22347} Bug: webrtc:8975 Change-Id: I162cb9a1eccddf567bdda7285f8296dc2f005503 Reviewed-on: https://webrtc-review.googlesource.com/60900 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Original-Commit-Position: refs/heads/master@{#22356} Reviewed-on: https://webrtc-review.googlesource.com/61661 Cr-Commit-Position: refs/heads/master@{#22438}
2018-03-14 12:39:24 +01:00
return rtp_packet;
}
RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState(
const RtpPacketHistory::StoredPacket& stored_packet) {
RtpPacketHistory::PacketState state;
state.rtp_sequence_number = stored_packet.packet->SequenceNumber();
state.send_time_ms = stored_packet.send_time_ms;
state.capture_time_ms = stored_packet.packet->capture_time_ms();
state.ssrc = stored_packet.packet->Ssrc();
state.payload_size = stored_packet.packet->size();
state.times_retransmitted = stored_packet.times_retransmitted;
return state;
}
} // namespace webrtc