webrtc_m130/modules/pacing/pacing_controller.h

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

292 lines
11 KiB
C
Raw Permalink Normal View History

/*
* Copyright (c) 2019 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.
*/
#ifndef MODULES_PACING_PACING_CONTROLLER_H_
#define MODULES_PACING_PACING_CONTROLLER_H_
#include <stddef.h>
#include <stdint.h>
#include <array>
#include <memory>
#include <optional>
#include <vector>
#include "api/array_view.h"
#include "api/field_trials_view.h"
#include "api/rtp_packet_sender.h"
#include "api/transport/network_types.h"
#include "api/units/data_rate.h"
#include "api/units/data_size.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "modules/pacing/bitrate_prober.h"
#include "modules/pacing/prioritized_packet_queue.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
// This class implements a leaky-bucket packet pacing algorithm. It handles the
// logic of determining which packets to send when, but the actual timing of
// the processing is done externally (e.g. RtpPacketPacer). Furthermore, the
// forwarding of packets when they are ready to be sent is also handled
// externally, via the PacingController::PacketSender interface.
class PacingController {
public:
class PacketSender {
public:
virtual ~PacketSender() = default;
Reland "Lets PacingController call PacketRouter directly." This reverts commit 980cadd02c7384397a41c0e334e9f329f3cc5c65. Reason for revert: Problematic code now fix. Original change's description: > Revert "Lets PacingController call PacketRouter directly." > > This reverts commit 848ea9f0d3678118cb8926a2898454e5a4df58ae. > > Reason for revert: Part of changes that may cause deadlock > > Original change's description: > > Lets PacingController call PacketRouter directly. > > > > Since locking model has been cleaned up, PacingController can now call > > PacketRouter directly - without having to go via PacedSender or > > TaskQueuePacedSender. > > > > Bug: webrtc:10809 > > Change-Id: I181f04167d677c35395286f8b246aefb4c3e7ec7 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175909 > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#31342} > > TBR=sprang@webrtc.org,srte@webrtc.org > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: webrtc:10809 > Change-Id: I1d7d5217a03a51555b130ec5c2dd6a992b6e489e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178021 > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > Commit-Queue: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31563} TBR=sprang@webrtc.org,srte@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:10809 Change-Id: I8bea1a5b1b1f618b697e4b09d83c9aac08099593 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178389 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31600}
2020-06-30 11:53:37 +00:00
virtual void SendPacket(std::unique_ptr<RtpPacketToSend> packet,
const PacedPacketInfo& cluster_info) = 0;
Reland "Reland "Allows FEC generation after pacer step."" This is a reland of 19df870d924662e3b6efb86078d31a8e086b38b5 Patchset 1 is the original. Subsequent patchset changes threadchecker that crashed with downstream code. Original change's description: > Reland "Allows FEC generation after pacer step." > > This is a reland of 75fd127640bdf1729af6b4a25875e6d01f1570e0 > > Patchset 2 contains a fix. Old code can in factor call > RtpRtcpImpl::FetchFec(). It should only be a noop since deferred fec > is not supported there - we shouldn't crash. > > Original change's description: > > Allows FEC generation after pacer step. > > > > Split out from https://webrtc-review.googlesource.com/c/src/+/173708 > > This CL enables FEC packets to be generated as media packets are sent, > > rather than generated, i.e. media packets are inserted into the fec > > generator after the pacing stage rather than at packetization time. > > > > This may have some small impact of performance. FEC packets are > > typically only generated when a new packet with a marker bit is added, > > which means FEC packets protecting a frame will now be sent after all > > of the media packets, rather than (potentially) interleaved with them. > > Therefore this feature is currently behind a flag so we can examine the > > impact. Once we are comfortable with the behavior we'll make it default > > and remove the old code. > > > > Note that this change does not include the "protect all header > > extensions" part of the original CL - that will be a follow-up. > > > > Bug: webrtc:11340 > > Change-Id: I3fe139c5d53968579b75b91e2612075451ff0f5d > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177760 > > Commit-Queue: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#31558} > > Bug: webrtc:11340 > Change-Id: I2ea49ee87ee9ff409044e34a777a7dd0ae0a077f > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177984 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31613} Bug: webrtc:11340 Change-Id: Ib741c8c284f523c959f8aca454088d9eee7b17f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178600 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31619}
2020-07-02 17:41:32 +02:00
// Should be called after each call to SendPacket().
virtual std::vector<std::unique_ptr<RtpPacketToSend>> FetchFec() = 0;
virtual std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding(
DataSize size) = 0;
// TODO(bugs.webrtc.org/1439830): Make pure virtual once subclasses adapt.
virtual void OnBatchComplete() {}
// TODO(bugs.webrtc.org/11340): Make pure virtual once downstream projects
// have been updated.
virtual void OnAbortedRetransmissions(
uint32_t /* ssrc */,
rtc::ArrayView<const uint16_t> /* sequence_numbers */) {}
virtual std::optional<uint32_t> GetRtxSsrcForMedia(
uint32_t /* ssrc */) const {
return std::nullopt;
}
};
// If no media or paused, wake up at least every `kPausedProcessIntervalMs` in
// order to send a keep-alive packet so we don't get stuck in a bad state due
// to lack of feedback.
static const TimeDelta kPausedProcessInterval;
// The default minimum time that should elapse calls to `ProcessPackets()`.
static const TimeDelta kMinSleepTime;
// When padding should be generated, add packets to the buffer with a size
// corresponding to this duration times the current padding rate.
static const TimeDelta kTargetPaddingDuration;
// The maximum time that the pacer can use when "replaying" passed time where
// padding should have been generated.
static const TimeDelta kMaxPaddingReplayDuration;
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
// Allow probes to be processed slightly ahead of inteded send time. Currently
// set to 1ms as this is intended to allow times be rounded down to the
// nearest millisecond.
static const TimeDelta kMaxEarlyProbeProcessing;
// Max total size of packets expected to be sent in a burst in order to not
// risk loosing packets due to too small send socket buffers. It upper limits
// the send burst interval.
// Ex: max send burst interval = 63Kb / 10Mbit/s = 50ms.
static constexpr DataSize kMaxBurstSize = DataSize::Bytes(63 * 1000);
// Configuration default values.
static constexpr TimeDelta kDefaultBurstInterval = TimeDelta::Millis(40);
static constexpr TimeDelta kMaxExpectedQueueLength = TimeDelta::Millis(2000);
struct Configuration {
// If the pacer queue grows longer than the configured max queue limit,
// pacer sends at the minimum rate needed to keep the max queue limit and
// ignore the current bandwidth estimate.
bool drain_large_queues = true;
// Expected max pacer delay. If ExpectedQueueTime() is higher than
// this value, the packet producers should wait (eg drop frames rather than
// encoding them). Bitrate sent may temporarily exceed target set by
// SetPacingRates() so that this limit will be upheld if
// `drain_large_queues` is set.
TimeDelta queue_time_limit = kMaxExpectedQueueLength;
// If the first packet of a keyframe is enqueued on a RTP stream, pacer
// skips forward to that packet and drops other enqueued packets on that
// stream, unless a keyframe is already being paced.
bool keyframe_flushing = false;
// Audio retransmission is prioritized before video retransmission packets.
bool prioritize_audio_retransmission = false;
// Configure separate timeouts per priority. After a timeout, a packet of
// that sort will not be paced and instead dropped.
// Note: to set TTL on audio retransmission,
// `prioritize_audio_retransmission` must be true.
PacketQueueTTL packet_queue_ttl;
// The pacer is allowed to send enqueued packets in bursts and can build up
// a packet "debt" that correspond to approximately the send rate during the
// burst interval.
TimeDelta send_burst_interval = kDefaultBurstInterval;
};
static Configuration DefaultConfiguration() { return Configuration{}; }
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
PacingController(Clock* clock,
PacketSender* packet_sender,
const FieldTrialsView& field_trials,
Configuration configuration = DefaultConfiguration());
~PacingController();
// Adds the packet to the queue and calls PacketRouter::SendPacket() when
// it's time to send.
void EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet);
void CreateProbeClusters(
rtc::ArrayView<const ProbeClusterConfig> probe_cluster_configs);
void Pause(); // Temporarily pause all sending.
void Resume(); // Resume sending packets.
bool IsPaused() const;
void SetCongested(bool congested);
// Sets the pacing rates. Must be called once before packets can be sent.
void SetPacingRates(DataRate pacing_rate, DataRate padding_rate);
DataRate pacing_rate() const { return adjusted_media_rate_; }
// Currently audio traffic is not accounted by pacer and passed through.
// With the introduction of audio BWE audio traffic will be accounted for
// the pacer budget calculation. The audio traffic still will be injected
// at high priority.
void SetAccountForAudioPackets(bool account_for_audio);
Reland "Reland "Only include overhead if using send side bandwidth estimation."" This is a reland of 086055d0fd9b9b9efe8bcf85884324a019e9bd33 ANA was accitendly disabled even when transport sequence numbers were negotiated due to a bug in how the audio send stream is configured. To solve this we simply continue to always allow enabling ANA and leave it up to the application to ensure that it's not used together with receive side estimation. Original change's description: > Reland "Only include overhead if using send side bandwidth estimation." > > This is a reland of 8c79c6e1af354c526497082c79ccbe12af03a33e > > Original change's description: > > Only include overhead if using send side bandwidth estimation. > > > > Bug: webrtc:11298 > > Change-Id: Ia2daf690461b55d394c1b964d6a7977a98be8be2 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166820 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > > Reviewed-by: Ali Tofigh <alito@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30382} > > Bug: webrtc:11298 > Change-Id: I33205e869a8ae27c15ffe991f6d985973ed6d15a > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167524 > Reviewed-by: Ali Tofigh <alito@webrtc.org> > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30390} Bug: webrtc:11298 Change-Id: If2ad91e17ebfc85dc51edcd9607996e18c5d1f13 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167883 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30413}
2020-01-29 17:42:52 +01:00
void SetIncludeOverhead();
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
void SetTransportOverhead(DataSize overhead_per_packet);
// The pacer is allowed to send enqued packets in bursts and can build up a
// packet "debt" that correspond to approximately the send rate during
// 'burst_interval'.
void SetSendBurstInterval(TimeDelta burst_interval);
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
// A probe may be sent without first waing for a media packet.
void SetAllowProbeWithoutMediaPacket(bool allow);
// Returns the time when the oldest packet was queued.
Timestamp OldestPacketEnqueueTime() const;
// Number of packets in the pacer queue.
size_t QueueSizePackets() const;
// Number of packets in the pacer queue per media type (RtpPacketMediaType
// values are used as lookup index).
const std::array<int, kNumMediaTypes>& SizeInPacketsPerRtpPacketMediaType()
const;
// Totals size of packets in the pacer queue.
DataSize QueueSizeData() const;
// Current buffer level, i.e. max of media and padding debt.
DataSize CurrentBufferLevel() const;
// Returns the time when the first packet was sent.
std::optional<Timestamp> FirstSentPacketTime() const;
// Returns the number of milliseconds it will take to send the current
// packets in the queue, given the current size and bitrate, ignoring prio.
TimeDelta ExpectedQueueTime() const;
void SetQueueTimeLimit(TimeDelta limit);
// Enable bitrate probing. Enabled by default, mostly here to simplify
// testing. Must be called before any packets are being sent to have an
// effect.
void SetProbingEnabled(bool enabled);
// Returns the next time we expect ProcessPackets() to be called.
Timestamp NextSendTime() const;
// Check queue of pending packets and send them or padding packets, if budget
// is available.
void ProcessPackets();
bool IsProbing() const;
// Note: Intended for debugging purposes only, will be removed.
// Sets the number of iterations of the main loop in `ProcessPackets()` that
// is considered erroneous to exceed.
void SetCircuitBreakerThreshold(int num_iterations);
// Remove any pending packets matching this SSRC from the packet queue.
void RemovePacketsForSsrc(uint32_t ssrc);
private:
TimeDelta UpdateTimeAndGetElapsed(Timestamp now);
bool ShouldSendKeepalive(Timestamp now) const;
// Updates the number of bytes that can be sent for the next time interval.
void UpdateBudgetWithElapsedTime(TimeDelta delta);
void UpdateBudgetWithSentData(DataSize size);
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
void UpdatePaddingBudgetWithSentData(DataSize size);
DataSize PaddingToAdd(DataSize recommended_probe_size,
DataSize data_sent) const;
std::unique_ptr<RtpPacketToSend> GetPendingPacket(
const PacedPacketInfo& pacing_info,
Timestamp target_send_time,
Timestamp now);
void OnPacketSent(RtpPacketMediaType packet_type,
DataSize packet_size,
Timestamp send_time);
void MaybeUpdateMediaRateDueToLongQueue(Timestamp now);
Timestamp CurrentTime() const;
// Helper methods for packet that may not be paced. Returns a finite Timestamp
// if a packet type is configured to not be paced and the packet queue has at
// least one packet of that type. Otherwise returns
// Timestamp::MinusInfinity().
Timestamp NextUnpacedSendTime() const;
Clock* const clock_;
PacketSender* const packet_sender_;
const FieldTrialsView& field_trials_;
const bool drain_large_queues_;
const bool send_padding_if_silent_;
const bool pace_audio_;
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
const bool ignore_transport_overhead_;
const bool fast_retransmissions_;
const bool keyframe_flushing_;
DataRate max_rate = DataRate::BitsPerSec(100'000'000);
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
DataSize transport_overhead_per_packet_;
TimeDelta send_burst_interval_;
Reland "Adds trial to use correct overhead calculation in pacer." This reverts commit 7affd9bcbb7a778408942d8afa4fe3ce29a8fc0b. Reason for revert: The perf issue has been addressed in the reland (https://webrtc-review.googlesource.com/c/src/+/167883). Original change's description: > Revert "Adds trial to use correct overhead calculation in pacer." > > This reverts commit 71a77c4b3b314a5e3b4e6b2f12d4886cff1b60d7. > > Reason for revert: https://webrtc-review.googlesource.com/c/src/+/167524 needs to be reverted and this CL causes a merge conflict. > > Original change's description: > > Adds trial to use correct overhead calculation in pacer. > > > > Bug: webrtc:9883 > > Change-Id: I1f25a235468678bf823ee1399ba31d94acf33be9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166534 > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30399} > > TBR=sprang@webrtc.org,srte@webrtc.org > > Change-Id: I7d3efa29f70aa0363311766980acae6d88bbcaaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9883 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167880 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30409} TBR=mbonadei@webrtc.org,sprang@webrtc.org,srte@webrtc.org Change-Id: Iafdef81d08078000dc368e001f67bee660e2f5bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167861 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30414}
2020-01-29 18:45:00 +00:00
// TODO(webrtc:9716): Remove this when we are certain clocks are monotonic.
// The last millisecond timestamp returned by `clock_`.
mutable Timestamp last_timestamp_;
bool paused_;
// Amount of outstanding data for media and padding.
DataSize media_debt_;
DataSize padding_debt_;
// The target pacing rate, signaled via SetPacingRates().
DataRate pacing_rate_;
// The media send rate, which might adjusted from pacing_rate_, e.g. if the
// pacing queue is growing too long.
DataRate adjusted_media_rate_;
// The padding target rate. We aim to fill up to this rate with padding what
// is not already used by media.
DataRate padding_rate_;
BitrateProber prober_;
bool probing_send_failure_;
Timestamp last_process_time_;
Timestamp last_send_time_;
std::optional<Timestamp> first_sent_packet_time_;
bool seen_first_packet_;
PrioritizedPacketQueue packet_queue_;
bool congested_;
Reland "Pacer: Reduce TQ wake up and improve packet size estimation" Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng <sprang@webrtc.org> >Reviewed-by: Henrik Boström <hbos@webrtc.org> >Commit-Queue: Erik Språng <sprang@webrtc.org> >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Owners-Override: Erik Språng <sprang@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36283}
2022-03-19 15:38:51 +08:00
TimeDelta queue_time_limit_;
bool account_for_audio_;
Reland "Reland "Only include overhead if using send side bandwidth estimation."" This is a reland of 086055d0fd9b9b9efe8bcf85884324a019e9bd33 ANA was accitendly disabled even when transport sequence numbers were negotiated due to a bug in how the audio send stream is configured. To solve this we simply continue to always allow enabling ANA and leave it up to the application to ensure that it's not used together with receive side estimation. Original change's description: > Reland "Only include overhead if using send side bandwidth estimation." > > This is a reland of 8c79c6e1af354c526497082c79ccbe12af03a33e > > Original change's description: > > Only include overhead if using send side bandwidth estimation. > > > > Bug: webrtc:11298 > > Change-Id: Ia2daf690461b55d394c1b964d6a7977a98be8be2 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166820 > > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > > Reviewed-by: Ali Tofigh <alito@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30382} > > Bug: webrtc:11298 > Change-Id: I33205e869a8ae27c15ffe991f6d985973ed6d15a > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167524 > Reviewed-by: Ali Tofigh <alito@webrtc.org> > Reviewed-by: Sam Zackrisson <saza@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30390} Bug: webrtc:11298 Change-Id: If2ad91e17ebfc85dc51edcd9607996e18c5d1f13 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167883 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30413}
2020-01-29 17:42:52 +01:00
bool include_overhead_;
int circuit_breaker_threshold_;
};
} // namespace webrtc
#endif // MODULES_PACING_PACING_CONTROLLER_H_