2012-11-09 20:56:23 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/pacing/paced_sender.h"
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2016-02-08 23:18:25 -08:00
|
|
|
#include <algorithm>
|
2018-10-26 13:10:23 +02:00
|
|
|
#include <utility>
|
2014-07-07 10:20:35 +00:00
|
|
|
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/pacing/bitrate_prober.h"
|
|
|
|
|
#include "modules/pacing/interval_budget.h"
|
|
|
|
|
#include "modules/utility/include/process_thread.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
|
|
|
|
#include "system_wrappers/include/clock.h"
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2019-02-22 13:09:32 +01:00
|
|
|
namespace webrtc {
|
2012-11-09 20:56:23 +00:00
|
|
|
namespace {
|
|
|
|
|
// Time limit in milliseconds between packet bursts.
|
2018-12-20 15:46:03 +01:00
|
|
|
const int64_t kDefaultMinPacketLimitMs = 5;
|
2018-03-09 12:48:01 +01:00
|
|
|
const int64_t kCongestedPacketIntervalMs = 500;
|
|
|
|
|
const int64_t kPausedProcessIntervalMs = kCongestedPacketIntervalMs;
|
2018-02-28 08:53:06 +01:00
|
|
|
const int64_t kMaxElapsedTimeMs = 2000;
|
2012-11-09 20:56:23 +00:00
|
|
|
|
|
|
|
|
// Upper cap on process interval, in case process has not been called in a long
|
|
|
|
|
// time.
|
2014-12-15 22:09:40 +00:00
|
|
|
const int64_t kMaxIntervalTimeMs = 30;
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2019-02-22 13:09:32 +01:00
|
|
|
bool IsDisabled(const WebRtcKeyValueConfig& field_trials,
|
|
|
|
|
absl::string_view key) {
|
|
|
|
|
return field_trials.Lookup(key).find("Disabled") == 0;
|
|
|
|
|
}
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2019-02-22 13:09:32 +01:00
|
|
|
bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
|
|
|
|
|
absl::string_view key) {
|
|
|
|
|
return field_trials.Lookup(key).find("Enabled") == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
2015-11-20 09:00:37 -08:00
|
|
|
const int64_t PacedSender::kMaxQueueLengthMs = 2000;
|
Revert "Revert "Revert "Reland "Moved congestion controller to task queue.""""
This reverts commit 65792c5a5c542201f7b9feefded505842692e6ed.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Revert "Revert "Reland "Moved congestion controller to task queue."""
>
> This reverts commit 4e849f6925b2ac44b0957a228d7131fc391fca54.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Revert "Reland "Moved congestion controller to task queue.""
> >
> > This reverts commit 57daeb7ac7f3d80992905b53fea500953fcfd793.
> >
> > Reason for revert: Cause increased congestion and deadlocks in downstream project
> >
> > Original change's description:
> > > Reland "Moved congestion controller to task queue."
> > >
> > > This is a reland of 0cbcba7ea0dced1a7f353c64d6cf91d46ccb29f9.
> > >
> > > Original change's description:
> > > > Moved congestion controller to task queue.
> > > >
> > > > The goal of this work is to make it easier to experiment with the
> > > > bandwidth estimation implementation. For this reason network control
> > > > functionality is moved from SendSideCongestionController(SSCC),
> > > > PacedSender and BitrateController to the newly created
> > > > GoogCcNetworkController which implements the newly created
> > > > NetworkControllerInterface. This allows the implementation to be
> > > > replaced at runtime in the future.
> > > >
> > > > This is the first part of a split of a larger CL, see:
> > > > https://webrtc-review.googlesource.com/c/src/+/39788/8
> > > > For further explanations.
> > > >
> > > > Bug: webrtc:8415
> > > > Change-Id: I770189c04cc31b313bd4e57821acff55fbcb1ad3
> > > > Reviewed-on: https://webrtc-review.googlesource.com/43840
> > > > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > > > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#21868}
> > >
> > > Bug: webrtc:8415
> > > Change-Id: I1d1756a30deed5b421b1c91c1918a13b6bb455da
> > > Reviewed-on: https://webrtc-review.googlesource.com/48000
> > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#21899}
> >
> > TBR=terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:8415
> > Change-Id: Ida8074dcac2cc28b3629228eb22846d8a8e81b83
> > Reviewed-on: https://webrtc-review.googlesource.com/52980
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22017}
>
> TBR=danilchap@webrtc.org,terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org
>
> Change-Id: I3393b74370c4f4d0955f50728005b2b925be169b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8415
> Reviewed-on: https://webrtc-review.googlesource.com/53262
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22023}
TBR=danilchap@webrtc.org,terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org
Change-Id: Id68ad986ee51142b7be3381d0793709b4392fe2c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8415
Reviewed-on: https://webrtc-review.googlesource.com/53360
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22024}
2018-02-14 16:53:38 +00:00
|
|
|
const float PacedSender::kDefaultPaceMultiplier = 2.5f;
|
2014-07-04 09:20:42 +00:00
|
|
|
|
2019-01-30 11:28:59 +01:00
|
|
|
PacedSender::PacedSender(Clock* clock,
|
2017-03-29 01:23:13 -07:00
|
|
|
PacketSender* packet_sender,
|
2019-02-22 13:09:32 +01:00
|
|
|
RtcEventLog* event_log,
|
|
|
|
|
const WebRtcKeyValueConfig* field_trials)
|
2014-07-04 09:20:42 +00:00
|
|
|
: clock_(clock),
|
2016-05-11 06:01:13 -07:00
|
|
|
packet_sender_(packet_sender),
|
2019-04-15 12:36:33 +02:00
|
|
|
fallback_field_trials_(
|
|
|
|
|
!field_trials ? absl::make_unique<FieldTrialBasedConfig>() : nullptr),
|
|
|
|
|
field_trials_(field_trials ? field_trials : fallback_field_trials_.get()),
|
|
|
|
|
drain_large_queues_(
|
|
|
|
|
!IsDisabled(*field_trials_, "WebRTC-Pacer-DrainQueue")),
|
2018-06-15 14:46:11 +02:00
|
|
|
send_padding_if_silent_(
|
2019-04-15 12:36:33 +02:00
|
|
|
IsEnabled(*field_trials_, "WebRTC-Pacer-PadInSilence")),
|
|
|
|
|
pace_audio_(!IsDisabled(*field_trials_, "WebRTC-Pacer-BlockAudio")),
|
2018-12-20 15:46:03 +01:00
|
|
|
min_packet_limit_ms_("", kDefaultMinPacketLimitMs),
|
2018-09-04 18:40:19 +02:00
|
|
|
last_timestamp_ms_(clock_->TimeInMilliseconds()),
|
2013-03-22 23:39:29 +00:00
|
|
|
paused_(false),
|
2018-10-11 20:22:03 +02:00
|
|
|
media_budget_(0),
|
|
|
|
|
padding_budget_(0),
|
2019-04-15 12:36:33 +02:00
|
|
|
prober_(*field_trials_),
|
2017-02-28 07:05:23 -08:00
|
|
|
probing_send_failure_(false),
|
2016-05-11 06:01:13 -07:00
|
|
|
pacing_bitrate_kbps_(0),
|
2018-02-21 13:39:26 +01:00
|
|
|
time_last_process_us_(clock->TimeInMicroseconds()),
|
|
|
|
|
last_send_time_us_(clock->TimeInMicroseconds()),
|
2017-04-19 23:28:53 -07:00
|
|
|
first_sent_packet_ms_(-1),
|
2018-10-11 20:17:22 +02:00
|
|
|
packets_(clock->TimeInMicroseconds()),
|
2017-06-30 13:27:40 -07:00
|
|
|
packet_counter_(0),
|
2017-10-20 10:37:47 +02:00
|
|
|
queue_time_limit(kMaxQueueLengthMs),
|
|
|
|
|
account_for_audio_(false) {
|
2018-12-20 15:46:03 +01:00
|
|
|
if (!drain_large_queues_) {
|
2018-06-25 19:23:05 +02:00
|
|
|
RTC_LOG(LS_WARNING) << "Pacer queues will not be drained,"
|
|
|
|
|
"pushback experiment must be enabled.";
|
2018-12-20 15:46:03 +01:00
|
|
|
}
|
|
|
|
|
ParseFieldTrial({&min_packet_limit_ms_},
|
2019-04-15 12:36:33 +02:00
|
|
|
field_trials_->Lookup("WebRTC-Pacer-MinPacketLimitMs"));
|
2018-12-20 15:46:03 +01:00
|
|
|
UpdateBudgetWithElapsedTime(min_packet_limit_ms_);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-15 16:40:38 +00:00
|
|
|
PacedSender::~PacedSender() {}
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2019-02-15 07:38:04 -08:00
|
|
|
void PacedSender::CreateProbeCluster(int bitrate_bps, int cluster_id) {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2019-02-15 07:38:04 -08:00
|
|
|
prober_.CreateProbeCluster(bitrate_bps, TimeMilliseconds(), cluster_id);
|
2016-08-17 11:11:59 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-22 23:39:29 +00:00
|
|
|
void PacedSender::Pause() {
|
2017-03-15 07:45:36 -07:00
|
|
|
{
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
Reland of Add functionality which limits the number of bytes on the network. (patchset #1 id:1 of https://codereview.webrtc.org/3001653002/ )
Reason for revert:
Reland
Original issue's description:
> Revert of Add functionality which limits the number of bytes on the network. (patchset #26 id:500001 of https://codereview.webrtc.org/2918323002/ )
>
> Reason for revert:
> Speculative revert to see if this caused regressions in android perf tests.
>
> Original issue's description:
> > Add functionality which limits the number of bytes on the network.
> >
> > The limit is based on the bandwidth delay product, but also adds some additional slack to compensate for the sawtooth-like BWE pattern and the slowness of the encoder rate control. The delay is estimated based on the time from sending a packet until an ack is received. Since acks are received in bursts (feedback is only sent periodically), a min filter is used to estimate the rtt.
> >
> > Whenever the in flight bytes reaches the congestion window, the pacer is paused, which in turn will result in send-side queues growing. Eventually the encoders will be paused as the pacer queue grows large (currently 2 seconds).
> >
> > BUG=webrtc:7926
> >
> > Review-Url: https://codereview.webrtc.org/2918323002
> > Cr-Commit-Position: refs/heads/master@{#19289}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/8497fdde43d920ab1f0cc90362534e5493d23abe
>
> TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7926
>
> Review-Url: https://codereview.webrtc.org/3001653002
> Cr-Commit-Position: refs/heads/master@{#19339}
> Committed: https://chromium.googlesource.com/external/webrtc/+/64136af364d1fecada49e35b1bfa39ef2641d5d0
TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7926
Review-Url: https://codereview.webrtc.org/2994343002
Cr-Commit-Position: refs/heads/master@{#19373}
2017-08-16 08:16:25 -07:00
|
|
|
if (!paused_)
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_INFO) << "PacedSender paused.";
|
2017-03-15 07:45:36 -07:00
|
|
|
paused_ = true;
|
2018-09-13 17:11:06 +02:00
|
|
|
packets_.SetPauseState(true, TimeMilliseconds());
|
2017-03-15 07:45:36 -07:00
|
|
|
}
|
2018-02-20 10:46:39 +01:00
|
|
|
rtc::CritScope cs(&process_thread_lock_);
|
2017-03-15 07:45:36 -07:00
|
|
|
// Tell the process thread to call our TimeUntilNextProcess() method to get
|
|
|
|
|
// a new (longer) estimate for when to call Process().
|
|
|
|
|
if (process_thread_)
|
|
|
|
|
process_thread_->WakeUp(this);
|
2013-03-22 23:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PacedSender::Resume() {
|
2017-03-15 07:45:36 -07:00
|
|
|
{
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
Reland of Add functionality which limits the number of bytes on the network. (patchset #1 id:1 of https://codereview.webrtc.org/3001653002/ )
Reason for revert:
Reland
Original issue's description:
> Revert of Add functionality which limits the number of bytes on the network. (patchset #26 id:500001 of https://codereview.webrtc.org/2918323002/ )
>
> Reason for revert:
> Speculative revert to see if this caused regressions in android perf tests.
>
> Original issue's description:
> > Add functionality which limits the number of bytes on the network.
> >
> > The limit is based on the bandwidth delay product, but also adds some additional slack to compensate for the sawtooth-like BWE pattern and the slowness of the encoder rate control. The delay is estimated based on the time from sending a packet until an ack is received. Since acks are received in bursts (feedback is only sent periodically), a min filter is used to estimate the rtt.
> >
> > Whenever the in flight bytes reaches the congestion window, the pacer is paused, which in turn will result in send-side queues growing. Eventually the encoders will be paused as the pacer queue grows large (currently 2 seconds).
> >
> > BUG=webrtc:7926
> >
> > Review-Url: https://codereview.webrtc.org/2918323002
> > Cr-Commit-Position: refs/heads/master@{#19289}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/8497fdde43d920ab1f0cc90362534e5493d23abe
>
> TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7926
>
> Review-Url: https://codereview.webrtc.org/3001653002
> Cr-Commit-Position: refs/heads/master@{#19339}
> Committed: https://chromium.googlesource.com/external/webrtc/+/64136af364d1fecada49e35b1bfa39ef2641d5d0
TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7926
Review-Url: https://codereview.webrtc.org/2994343002
Cr-Commit-Position: refs/heads/master@{#19373}
2017-08-16 08:16:25 -07:00
|
|
|
if (paused_)
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_INFO) << "PacedSender resumed.";
|
2017-03-15 07:45:36 -07:00
|
|
|
paused_ = false;
|
2018-09-13 17:11:06 +02:00
|
|
|
packets_.SetPauseState(false, TimeMilliseconds());
|
2017-03-15 07:45:36 -07:00
|
|
|
}
|
2018-02-20 10:46:39 +01:00
|
|
|
rtc::CritScope cs(&process_thread_lock_);
|
2017-03-15 07:45:36 -07:00
|
|
|
// Tell the process thread to call our TimeUntilNextProcess() method to
|
|
|
|
|
// refresh the estimate for when to call Process().
|
|
|
|
|
if (process_thread_)
|
|
|
|
|
process_thread_->WakeUp(this);
|
2013-03-22 23:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2018-03-09 12:48:01 +01:00
|
|
|
void PacedSender::SetCongestionWindow(int64_t congestion_window_bytes) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
congestion_window_bytes_ = congestion_window_bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PacedSender::UpdateOutstandingData(int64_t outstanding_bytes) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
outstanding_bytes_ = outstanding_bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PacedSender::Congested() const {
|
|
|
|
|
if (congestion_window_bytes_ == kNoCongestionWindow)
|
|
|
|
|
return false;
|
|
|
|
|
return outstanding_bytes_ >= congestion_window_bytes_;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-04 18:40:19 +02:00
|
|
|
int64_t PacedSender::TimeMilliseconds() const {
|
|
|
|
|
int64_t time_ms = clock_->TimeInMilliseconds();
|
|
|
|
|
if (time_ms < last_timestamp_ms_) {
|
|
|
|
|
RTC_LOG(LS_WARNING)
|
|
|
|
|
<< "Non-monotonic clock behavior observed. Previous timestamp: "
|
|
|
|
|
<< last_timestamp_ms_ << ", new timestamp: " << time_ms;
|
|
|
|
|
RTC_DCHECK_GE(time_ms, last_timestamp_ms_);
|
|
|
|
|
time_ms = last_timestamp_ms_;
|
|
|
|
|
}
|
|
|
|
|
last_timestamp_ms_ = time_ms;
|
|
|
|
|
return time_ms;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-16 15:47:51 +00:00
|
|
|
void PacedSender::SetProbingEnabled(bool enabled) {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2017-10-17 14:17:54 +02:00
|
|
|
RTC_CHECK_EQ(0, packet_counter_);
|
2018-10-11 20:22:03 +02:00
|
|
|
prober_.SetEnabled(enabled);
|
2015-02-16 15:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-20 10:46:39 +01:00
|
|
|
void PacedSender::SetPacingRates(uint32_t pacing_rate_bps,
|
|
|
|
|
uint32_t padding_rate_bps) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
RTC_DCHECK(pacing_rate_bps > 0);
|
|
|
|
|
pacing_bitrate_kbps_ = pacing_rate_bps / 1000;
|
2018-10-11 20:22:03 +02:00
|
|
|
padding_budget_.set_target_rate_kbps(padding_rate_bps / 1000);
|
2019-02-26 15:25:52 +01:00
|
|
|
|
|
|
|
|
RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps="
|
|
|
|
|
<< pacing_bitrate_kbps_
|
|
|
|
|
<< " padding_budget_kbps=" << padding_rate_bps / 1000;
|
2018-02-20 10:46:39 +01:00
|
|
|
}
|
|
|
|
|
|
2015-10-08 11:44:14 +02:00
|
|
|
void PacedSender::InsertPacket(RtpPacketSender::Priority priority,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
uint16_t sequence_number,
|
|
|
|
|
int64_t capture_time_ms,
|
|
|
|
|
size_t bytes,
|
|
|
|
|
bool retransmission) {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2018-02-20 10:46:39 +01:00
|
|
|
RTC_DCHECK(pacing_bitrate_kbps_ > 0)
|
|
|
|
|
<< "SetPacingRate must be called before InsertPacket.";
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2018-09-04 18:40:19 +02:00
|
|
|
int64_t now_ms = TimeMilliseconds();
|
2018-10-11 20:22:03 +02:00
|
|
|
prober_.OnIncomingPacket(bytes);
|
2016-02-16 16:23:08 +01:00
|
|
|
|
2015-11-20 09:00:37 -08:00
|
|
|
if (capture_time_ms < 0)
|
2015-11-26 16:26:12 +01:00
|
|
|
capture_time_ms = now_ms;
|
2014-11-04 16:27:16 +00:00
|
|
|
|
2018-09-13 17:11:06 +02:00
|
|
|
packets_.Push(RoundRobinPacketQueue::Packet(
|
2017-09-26 17:16:06 +02:00
|
|
|
priority, ssrc, sequence_number, capture_time_ms, now_ms, bytes,
|
|
|
|
|
retransmission, packet_counter_++));
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 10:37:47 +02:00
|
|
|
void PacedSender::SetAccountForAudioPackets(bool account_for_audio) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
account_for_audio_ = account_for_audio;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 22:21:14 +00:00
|
|
|
int64_t PacedSender::ExpectedQueueTimeMs() const {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GT(pacing_bitrate_kbps_, 0);
|
2018-09-13 17:11:06 +02:00
|
|
|
return static_cast<int64_t>(packets_.SizeInBytes() * 8 /
|
2016-05-11 06:01:13 -07:00
|
|
|
pacing_bitrate_kbps_);
|
2013-11-27 14:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-04 16:27:16 +00:00
|
|
|
size_t PacedSender::QueueSizePackets() const {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2018-09-13 17:11:06 +02:00
|
|
|
return packets_.SizeInPackets();
|
2013-03-27 16:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-08 10:49:19 +01:00
|
|
|
int64_t PacedSender::QueueSizeBytes() const {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
return packets_.SizeInBytes();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-19 23:28:53 -07:00
|
|
|
int64_t PacedSender::FirstSentPacketTimeMs() const {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
return first_sent_packet_ms_;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t PacedSender::QueueInMs() const {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2014-11-04 16:27:16 +00:00
|
|
|
|
2018-09-13 17:11:06 +02:00
|
|
|
int64_t oldest_packet = packets_.OldestEnqueueTimeMs();
|
2014-11-04 16:27:16 +00:00
|
|
|
if (oldest_packet == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2018-09-04 18:40:19 +02:00
|
|
|
return TimeMilliseconds() - oldest_packet;
|
2014-10-23 11:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t PacedSender::TimeUntilNextProcess() {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2018-02-21 13:39:26 +01:00
|
|
|
int64_t elapsed_time_us =
|
|
|
|
|
clock_->TimeInMicroseconds() - time_last_process_us_;
|
Reland of Add functionality which limits the number of bytes on the network. (patchset #1 id:1 of https://codereview.webrtc.org/3001653002/ )
Reason for revert:
Reland
Original issue's description:
> Revert of Add functionality which limits the number of bytes on the network. (patchset #26 id:500001 of https://codereview.webrtc.org/2918323002/ )
>
> Reason for revert:
> Speculative revert to see if this caused regressions in android perf tests.
>
> Original issue's description:
> > Add functionality which limits the number of bytes on the network.
> >
> > The limit is based on the bandwidth delay product, but also adds some additional slack to compensate for the sawtooth-like BWE pattern and the slowness of the encoder rate control. The delay is estimated based on the time from sending a packet until an ack is received. Since acks are received in bursts (feedback is only sent periodically), a min filter is used to estimate the rtt.
> >
> > Whenever the in flight bytes reaches the congestion window, the pacer is paused, which in turn will result in send-side queues growing. Eventually the encoders will be paused as the pacer queue grows large (currently 2 seconds).
> >
> > BUG=webrtc:7926
> >
> > Review-Url: https://codereview.webrtc.org/2918323002
> > Cr-Commit-Position: refs/heads/master@{#19289}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/8497fdde43d920ab1f0cc90362534e5493d23abe
>
> TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7926
>
> Review-Url: https://codereview.webrtc.org/3001653002
> Cr-Commit-Position: refs/heads/master@{#19339}
> Committed: https://chromium.googlesource.com/external/webrtc/+/64136af364d1fecada49e35b1bfa39ef2641d5d0
TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7926
Review-Url: https://codereview.webrtc.org/2994343002
Cr-Commit-Position: refs/heads/master@{#19373}
2017-08-16 08:16:25 -07:00
|
|
|
int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000;
|
|
|
|
|
// When paused we wake up every 500 ms to send a padding packet to ensure
|
|
|
|
|
// we won't get stuck in the paused state due to no feedback being received.
|
2017-03-15 07:45:36 -07:00
|
|
|
if (paused_)
|
2018-03-09 12:48:01 +01:00
|
|
|
return std::max<int64_t>(kPausedProcessIntervalMs - elapsed_time_ms, 0);
|
2017-03-15 07:45:36 -07:00
|
|
|
|
2018-10-11 20:22:03 +02:00
|
|
|
if (prober_.IsProbing()) {
|
|
|
|
|
int64_t ret = prober_.TimeUntilNextProbe(TimeMilliseconds());
|
2017-02-28 07:05:23 -08:00
|
|
|
if (ret > 0 || (ret == 0 && !probing_send_failure_))
|
2015-02-16 15:47:51 +00:00
|
|
|
return ret;
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
2018-12-20 15:46:03 +01:00
|
|
|
return std::max<int64_t>(min_packet_limit_ms_ - elapsed_time_ms, 0);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-26 13:10:23 +02:00
|
|
|
int64_t PacedSender::UpdateTimeAndGetElapsedMs(int64_t now_us) {
|
2018-06-04 19:02:41 +02:00
|
|
|
int64_t elapsed_time_ms = (now_us - time_last_process_us_ + 500) / 1000;
|
2018-02-21 13:39:26 +01:00
|
|
|
time_last_process_us_ = now_us;
|
2018-02-28 08:53:06 +01:00
|
|
|
if (elapsed_time_ms > kMaxElapsedTimeMs) {
|
|
|
|
|
RTC_LOG(LS_WARNING) << "Elapsed time (" << elapsed_time_ms
|
|
|
|
|
<< " ms) longer than expected, limiting to "
|
|
|
|
|
<< kMaxElapsedTimeMs << " ms";
|
|
|
|
|
elapsed_time_ms = kMaxElapsedTimeMs;
|
|
|
|
|
}
|
2018-10-26 13:10:23 +02:00
|
|
|
return elapsed_time_ms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PacedSender::ShouldSendKeepalive(int64_t now_us) const {
|
2018-06-15 14:46:11 +02:00
|
|
|
if (send_padding_if_silent_ || paused_ || Congested()) {
|
|
|
|
|
// We send a padding packet every 500 ms to ensure we won't get stuck in
|
|
|
|
|
// congested state due to no feedback being received.
|
2018-06-04 19:02:41 +02:00
|
|
|
int64_t elapsed_since_last_send_us = now_us - last_send_time_us_;
|
|
|
|
|
if (elapsed_since_last_send_us >= kCongestedPacketIntervalMs * 1000) {
|
2018-04-12 13:08:22 +02:00
|
|
|
// We can not send padding unless a normal packet has first been sent. If
|
|
|
|
|
// we do, timestamps get messed up.
|
|
|
|
|
if (packet_counter_ > 0) {
|
2018-10-26 13:10:23 +02:00
|
|
|
return true;
|
2018-04-12 13:08:22 +02:00
|
|
|
}
|
2018-02-21 13:39:26 +01:00
|
|
|
}
|
Reland of Add functionality which limits the number of bytes on the network. (patchset #1 id:1 of https://codereview.webrtc.org/3001653002/ )
Reason for revert:
Reland
Original issue's description:
> Revert of Add functionality which limits the number of bytes on the network. (patchset #26 id:500001 of https://codereview.webrtc.org/2918323002/ )
>
> Reason for revert:
> Speculative revert to see if this caused regressions in android perf tests.
>
> Original issue's description:
> > Add functionality which limits the number of bytes on the network.
> >
> > The limit is based on the bandwidth delay product, but also adds some additional slack to compensate for the sawtooth-like BWE pattern and the slowness of the encoder rate control. The delay is estimated based on the time from sending a packet until an ack is received. Since acks are received in bursts (feedback is only sent periodically), a min filter is used to estimate the rtt.
> >
> > Whenever the in flight bytes reaches the congestion window, the pacer is paused, which in turn will result in send-side queues growing. Eventually the encoders will be paused as the pacer queue grows large (currently 2 seconds).
> >
> > BUG=webrtc:7926
> >
> > Review-Url: https://codereview.webrtc.org/2918323002
> > Cr-Commit-Position: refs/heads/master@{#19289}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/8497fdde43d920ab1f0cc90362534e5493d23abe
>
> TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7926
>
> Review-Url: https://codereview.webrtc.org/3001653002
> Cr-Commit-Position: refs/heads/master@{#19339}
> Committed: https://chromium.googlesource.com/external/webrtc/+/64136af364d1fecada49e35b1bfa39ef2641d5d0
TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7926
Review-Url: https://codereview.webrtc.org/2994343002
Cr-Commit-Position: refs/heads/master@{#19373}
2017-08-16 08:16:25 -07:00
|
|
|
}
|
2018-10-26 13:10:23 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PacedSender::Process() {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
int64_t now_us = clock_->TimeInMicroseconds();
|
|
|
|
|
int64_t elapsed_time_ms = UpdateTimeAndGetElapsedMs(now_us);
|
|
|
|
|
if (ShouldSendKeepalive(now_us)) {
|
|
|
|
|
critsect_.Leave();
|
|
|
|
|
size_t bytes_sent = packet_sender_->TimeToSendPadding(1, PacedPacketInfo());
|
|
|
|
|
critsect_.Enter();
|
|
|
|
|
OnPaddingSent(bytes_sent);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 14:46:11 +02:00
|
|
|
if (paused_)
|
|
|
|
|
return;
|
Reland of Add functionality which limits the number of bytes on the network. (patchset #1 id:1 of https://codereview.webrtc.org/3001653002/ )
Reason for revert:
Reland
Original issue's description:
> Revert of Add functionality which limits the number of bytes on the network. (patchset #26 id:500001 of https://codereview.webrtc.org/2918323002/ )
>
> Reason for revert:
> Speculative revert to see if this caused regressions in android perf tests.
>
> Original issue's description:
> > Add functionality which limits the number of bytes on the network.
> >
> > The limit is based on the bandwidth delay product, but also adds some additional slack to compensate for the sawtooth-like BWE pattern and the slowness of the encoder rate control. The delay is estimated based on the time from sending a packet until an ack is received. Since acks are received in bursts (feedback is only sent periodically), a min filter is used to estimate the rtt.
> >
> > Whenever the in flight bytes reaches the congestion window, the pacer is paused, which in turn will result in send-side queues growing. Eventually the encoders will be paused as the pacer queue grows large (currently 2 seconds).
> >
> > BUG=webrtc:7926
> >
> > Review-Url: https://codereview.webrtc.org/2918323002
> > Cr-Commit-Position: refs/heads/master@{#19289}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/8497fdde43d920ab1f0cc90362534e5493d23abe
>
> TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7926
>
> Review-Url: https://codereview.webrtc.org/3001653002
> Cr-Commit-Position: refs/heads/master@{#19339}
> Committed: https://chromium.googlesource.com/external/webrtc/+/64136af364d1fecada49e35b1bfa39ef2641d5d0
TBR=terelius@webrtc.org,philipel@webrtc.org,tschumim@webrtc.org,gnish@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7926
Review-Url: https://codereview.webrtc.org/2994343002
Cr-Commit-Position: refs/heads/master@{#19373}
2017-08-16 08:16:25 -07:00
|
|
|
|
|
|
|
|
if (elapsed_time_ms > 0) {
|
2018-06-15 14:46:11 +02:00
|
|
|
int target_bitrate_kbps = pacing_bitrate_kbps_;
|
2018-09-13 17:11:06 +02:00
|
|
|
size_t queue_size_bytes = packets_.SizeInBytes();
|
2015-11-20 09:00:37 -08:00
|
|
|
if (queue_size_bytes > 0) {
|
|
|
|
|
// Assuming equal size packets and input/output rate, the average packet
|
|
|
|
|
// has avg_time_left_ms left to get queue_size_bytes out of the queue, if
|
|
|
|
|
// time constraint shall be met. Determine bitrate needed for that.
|
2018-09-13 17:11:06 +02:00
|
|
|
packets_.UpdateQueueTime(TimeMilliseconds());
|
2018-06-25 19:23:05 +02:00
|
|
|
if (drain_large_queues_) {
|
|
|
|
|
int64_t avg_time_left_ms = std::max<int64_t>(
|
2018-09-13 17:11:06 +02:00
|
|
|
1, queue_time_limit - packets_.AverageQueueTimeMs());
|
2018-06-25 19:23:05 +02:00
|
|
|
int min_bitrate_needed_kbps =
|
|
|
|
|
static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms);
|
2019-02-26 15:25:52 +01:00
|
|
|
if (min_bitrate_needed_kbps > target_bitrate_kbps) {
|
2018-06-25 19:23:05 +02:00
|
|
|
target_bitrate_kbps = min_bitrate_needed_kbps;
|
2019-02-26 15:25:52 +01:00
|
|
|
RTC_LOG(LS_VERBOSE) << "bwe:large_pacing_queue pacing_rate_kbps="
|
|
|
|
|
<< target_bitrate_kbps;
|
|
|
|
|
}
|
2018-06-25 19:23:05 +02:00
|
|
|
}
|
2015-11-20 09:00:37 -08:00
|
|
|
}
|
|
|
|
|
|
2018-10-11 20:22:03 +02:00
|
|
|
media_budget_.set_target_rate_kbps(target_bitrate_kbps);
|
2016-10-04 08:43:09 -07:00
|
|
|
UpdateBudgetWithElapsedTime(elapsed_time_ms);
|
2013-08-09 11:31:23 +00:00
|
|
|
}
|
2016-06-01 06:31:17 -07:00
|
|
|
|
2018-10-11 20:22:03 +02:00
|
|
|
bool is_probing = prober_.IsProbing();
|
2017-02-17 03:59:43 -08:00
|
|
|
PacedPacketInfo pacing_info;
|
2016-10-04 08:29:38 -07:00
|
|
|
size_t bytes_sent = 0;
|
|
|
|
|
size_t recommended_probe_size = 0;
|
|
|
|
|
if (is_probing) {
|
2018-10-11 20:22:03 +02:00
|
|
|
pacing_info = prober_.CurrentCluster();
|
|
|
|
|
recommended_probe_size = prober_.RecommendedMinProbeSize();
|
2016-10-04 08:29:38 -07:00
|
|
|
}
|
2018-10-26 13:10:23 +02:00
|
|
|
// The paused state is checked in the loop since it leaves the critical
|
|
|
|
|
// section allowing the paused state to be changed from other code.
|
2018-09-13 17:11:06 +02:00
|
|
|
while (!packets_.Empty() && !paused_) {
|
2018-10-26 13:10:23 +02:00
|
|
|
const auto* packet = GetPendingPacket(pacing_info);
|
|
|
|
|
if (packet == nullptr)
|
|
|
|
|
break;
|
2015-12-07 10:26:18 +01:00
|
|
|
|
2018-10-26 13:10:23 +02:00
|
|
|
critsect_.Leave();
|
2019-05-10 08:29:01 -07:00
|
|
|
RtpPacketSendResult success = packet_sender_->TimeToSendPacket(
|
2018-10-26 13:10:23 +02:00
|
|
|
packet->ssrc, packet->sequence_number, packet->capture_time_ms,
|
|
|
|
|
packet->retransmission, pacing_info);
|
|
|
|
|
critsect_.Enter();
|
2019-05-10 08:29:01 -07:00
|
|
|
if (success == RtpPacketSendResult::kSuccess ||
|
|
|
|
|
success == RtpPacketSendResult::kPacketNotFound) {
|
|
|
|
|
// Packet sent or invalid packet, remove it from queue.
|
|
|
|
|
// TODO(webrtc:8052): Don't consume media budget on kInvalid.
|
2018-10-26 13:10:23 +02:00
|
|
|
bytes_sent += packet->bytes;
|
2018-02-21 13:39:26 +01:00
|
|
|
// Send succeeded, remove it from the queue.
|
2019-01-31 21:38:12 +01:00
|
|
|
OnPacketSent(packet);
|
2016-10-04 08:29:38 -07:00
|
|
|
if (is_probing && bytes_sent > recommended_probe_size)
|
|
|
|
|
break;
|
2015-10-08 11:44:14 +02:00
|
|
|
} else {
|
|
|
|
|
// Send failed, put it back into the queue.
|
2018-10-26 13:10:23 +02:00
|
|
|
packets_.CancelPop(*packet);
|
2016-10-04 08:29:38 -07:00
|
|
|
break;
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
2015-10-08 11:44:14 +02:00
|
|
|
}
|
2014-11-04 16:27:16 +00:00
|
|
|
|
2018-09-13 17:11:06 +02:00
|
|
|
if (packets_.Empty() && !Congested()) {
|
2016-10-04 08:29:38 -07:00
|
|
|
// We can not send padding unless a normal packet has first been sent. If we
|
|
|
|
|
// do, timestamps get messed up.
|
|
|
|
|
if (packet_counter_ > 0) {
|
|
|
|
|
int padding_needed =
|
|
|
|
|
static_cast<int>(is_probing ? (recommended_probe_size - bytes_sent)
|
2018-10-11 20:22:03 +02:00
|
|
|
: padding_budget_.bytes_remaining());
|
2018-02-20 10:46:39 +01:00
|
|
|
if (padding_needed > 0) {
|
2018-10-26 13:10:23 +02:00
|
|
|
critsect_.Leave();
|
|
|
|
|
size_t padding_sent =
|
|
|
|
|
packet_sender_->TimeToSendPadding(padding_needed, pacing_info);
|
|
|
|
|
critsect_.Enter();
|
|
|
|
|
bytes_sent += padding_sent;
|
|
|
|
|
OnPaddingSent(padding_sent);
|
2018-02-20 10:46:39 +01:00
|
|
|
}
|
2016-10-04 08:29:38 -07:00
|
|
|
}
|
2016-06-15 00:47:53 -07:00
|
|
|
}
|
2017-02-28 07:05:23 -08:00
|
|
|
if (is_probing) {
|
|
|
|
|
probing_send_failure_ = bytes_sent == 0;
|
|
|
|
|
if (!probing_send_failure_)
|
2018-10-11 20:22:03 +02:00
|
|
|
prober_.ProbeSent(TimeMilliseconds(), bytes_sent);
|
2017-02-28 07:05:23 -08:00
|
|
|
}
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-15 07:45:36 -07:00
|
|
|
void PacedSender::ProcessThreadAttached(ProcessThread* process_thread) {
|
2018-05-23 11:13:31 +02:00
|
|
|
RTC_LOG(LS_INFO) << "ProcessThreadAttached 0x" << process_thread;
|
2018-02-20 10:46:39 +01:00
|
|
|
rtc::CritScope cs(&process_thread_lock_);
|
2017-03-15 07:45:36 -07:00
|
|
|
process_thread_ = process_thread;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-26 13:10:23 +02:00
|
|
|
const RoundRobinPacketQueue::Packet* PacedSender::GetPendingPacket(
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
|
|
|
|
// Since we need to release the lock in order to send, we first pop the
|
|
|
|
|
// element from the priority queue but keep it in storage, so that we can
|
|
|
|
|
// reinsert it if send fails.
|
|
|
|
|
const RoundRobinPacketQueue::Packet* packet = &packets_.BeginPop();
|
|
|
|
|
bool audio_packet = packet->priority == kHighPriority;
|
2019-01-23 12:37:49 +01:00
|
|
|
bool apply_pacing = !audio_packet || pace_audio_;
|
2018-10-11 20:22:03 +02:00
|
|
|
if (apply_pacing && (Congested() || (media_budget_.bytes_remaining() == 0 &&
|
2018-06-15 14:47:35 +02:00
|
|
|
pacing_info.probe_cluster_id ==
|
|
|
|
|
PacedPacketInfo::kNotAProbe))) {
|
2018-10-26 13:10:23 +02:00
|
|
|
packets_.CancelPop(*packet);
|
|
|
|
|
return nullptr;
|
2016-08-01 09:47:31 -07:00
|
|
|
}
|
2018-10-26 13:10:23 +02:00
|
|
|
return packet;
|
|
|
|
|
}
|
2017-02-17 03:59:43 -08:00
|
|
|
|
2018-10-26 13:10:23 +02:00
|
|
|
void PacedSender::OnPacketSent(const RoundRobinPacketQueue::Packet* packet) {
|
|
|
|
|
if (first_sent_packet_ms_ == -1)
|
|
|
|
|
first_sent_packet_ms_ = TimeMilliseconds();
|
|
|
|
|
bool audio_packet = packet->priority == kHighPriority;
|
|
|
|
|
if (!audio_packet || account_for_audio_) {
|
|
|
|
|
// Update media bytes sent.
|
|
|
|
|
UpdateBudgetWithBytesSent(packet->bytes);
|
|
|
|
|
last_send_time_us_ = clock_->TimeInMicroseconds();
|
2013-11-27 14:16:20 +00:00
|
|
|
}
|
2018-10-26 13:10:23 +02:00
|
|
|
// Send succeeded, remove it from the queue.
|
|
|
|
|
packets_.FinalizePop(*packet);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-26 13:10:23 +02:00
|
|
|
void PacedSender::OnPaddingSent(size_t bytes_sent) {
|
2015-05-05 10:21:24 +02:00
|
|
|
if (bytes_sent > 0) {
|
2016-10-04 08:43:09 -07:00
|
|
|
UpdateBudgetWithBytesSent(bytes_sent);
|
2015-05-05 10:21:24 +02:00
|
|
|
}
|
2018-06-15 14:46:11 +02:00
|
|
|
last_send_time_us_ = clock_->TimeInMicroseconds();
|
2013-03-22 23:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-04 08:43:09 -07:00
|
|
|
void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) {
|
2018-02-21 13:39:26 +01:00
|
|
|
delta_time_ms = std::min(kMaxIntervalTimeMs, delta_time_ms);
|
2018-10-11 20:22:03 +02:00
|
|
|
media_budget_.IncreaseBudget(delta_time_ms);
|
|
|
|
|
padding_budget_.IncreaseBudget(delta_time_ms);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
2016-10-04 08:43:09 -07:00
|
|
|
|
|
|
|
|
void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) {
|
2018-03-09 12:48:01 +01:00
|
|
|
outstanding_bytes_ += bytes_sent;
|
2018-10-11 20:22:03 +02:00
|
|
|
media_budget_.UseBudget(bytes_sent);
|
|
|
|
|
padding_budget_.UseBudget(bytes_sent);
|
2016-10-04 08:43:09 -07:00
|
|
|
}
|
2017-06-30 13:27:40 -07:00
|
|
|
|
|
|
|
|
void PacedSender::SetQueueTimeLimit(int limit_ms) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
queue_time_limit = limit_ms;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-09 20:56:23 +00:00
|
|
|
} // namespace webrtc
|