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>
|
2014-07-07 10:20:35 +00:00
|
|
|
#include <map>
|
2014-11-04 16:27:16 +00:00
|
|
|
#include <queue>
|
2014-07-07 10:20:35 +00:00
|
|
|
#include <set>
|
2016-02-08 23:18:25 -08:00
|
|
|
#include <vector>
|
2017-10-31 09:54:50 +01:00
|
|
|
#include <utility>
|
2014-07-07 10:20:35 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/include/module_common_types.h"
|
|
|
|
|
#include "modules/pacing/alr_detector.h"
|
|
|
|
|
#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"
|
2017-10-18 13:08:22 +02:00
|
|
|
#include "rtc_base/ptr_util.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "system_wrappers/include/clock.h"
|
|
|
|
|
#include "system_wrappers/include/field_trial.h"
|
2012-11-09 20:56:23 +00:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
// Time limit in milliseconds between packet bursts.
|
2014-12-15 22:09:40 +00:00
|
|
|
const int64_t kMinPacketLimitMs = 5;
|
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
|
|
|
const int64_t kPausedPacketIntervalMs = 500;
|
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
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-04-25 17:35:56 +00:00
|
|
|
|
2015-11-20 09:00:37 -08:00
|
|
|
const int64_t PacedSender::kMaxQueueLengthMs = 2000;
|
2014-07-04 09:20:42 +00:00
|
|
|
const float PacedSender::kDefaultPaceMultiplier = 2.5f;
|
|
|
|
|
|
2017-03-29 01:23:13 -07:00
|
|
|
PacedSender::PacedSender(const Clock* clock,
|
|
|
|
|
PacketSender* packet_sender,
|
2017-10-31 09:54:50 +01:00
|
|
|
RtcEventLog* event_log) :
|
|
|
|
|
PacedSender(clock, packet_sender, event_log,
|
|
|
|
|
webrtc::field_trial::IsEnabled("WebRTC-RoundRobinPacing")
|
|
|
|
|
? rtc::MakeUnique<PacketQueue2>(clock)
|
|
|
|
|
: rtc::MakeUnique<PacketQueue>(clock)) {}
|
|
|
|
|
|
|
|
|
|
PacedSender::PacedSender(const Clock* clock,
|
|
|
|
|
PacketSender* packet_sender,
|
|
|
|
|
RtcEventLog* event_log,
|
|
|
|
|
std::unique_ptr<PacketQueue> packets)
|
2014-07-04 09:20:42 +00:00
|
|
|
: clock_(clock),
|
2016-05-11 06:01:13 -07:00
|
|
|
packet_sender_(packet_sender),
|
2017-10-18 13:08:22 +02:00
|
|
|
alr_detector_(rtc::MakeUnique<AlrDetector>()),
|
2013-03-22 23:39:29 +00:00
|
|
|
paused_(false),
|
2017-10-18 13:08:22 +02:00
|
|
|
media_budget_(rtc::MakeUnique<IntervalBudget>(0)),
|
|
|
|
|
padding_budget_(rtc::MakeUnique<IntervalBudget>(0)),
|
|
|
|
|
prober_(rtc::MakeUnique<BitrateProber>(event_log)),
|
2017-02-28 07:05:23 -08:00
|
|
|
probing_send_failure_(false),
|
2016-05-11 06:01:13 -07:00
|
|
|
estimated_bitrate_bps_(0),
|
|
|
|
|
min_send_bitrate_kbps_(0u),
|
2016-06-15 00:47:53 -07:00
|
|
|
max_padding_bitrate_kbps_(0u),
|
2016-05-11 06:01:13 -07:00
|
|
|
pacing_bitrate_kbps_(0),
|
2014-07-15 16:40:38 +00:00
|
|
|
time_last_update_us_(clock->TimeInMicroseconds()),
|
2017-04-19 23:28:53 -07:00
|
|
|
first_sent_packet_ms_(-1),
|
2017-10-31 09:54:50 +01:00
|
|
|
packets_(std::move(packets)),
|
2017-06-30 13:27:40 -07:00
|
|
|
packet_counter_(0),
|
|
|
|
|
pacing_factor_(kDefaultPaceMultiplier),
|
2017-10-20 10:37:47 +02:00
|
|
|
queue_time_limit(kMaxQueueLengthMs),
|
|
|
|
|
account_for_audio_(false) {
|
2016-10-04 08:43:09 -07:00
|
|
|
UpdateBudgetWithElapsedTime(kMinPacketLimitMs);
|
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
|
|
|
|
2017-01-04 07:05:25 -08:00
|
|
|
void PacedSender::CreateProbeCluster(int bitrate_bps) {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2017-02-08 15:19:05 +01:00
|
|
|
prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds());
|
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;
|
2017-08-16 05:38:49 -07:00
|
|
|
packets_->SetPauseState(true, clock_->TimeInMilliseconds());
|
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;
|
2017-08-16 05:38:49 -07:00
|
|
|
packets_->SetPauseState(false, clock_->TimeInMilliseconds());
|
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
|
|
|
}
|
|
|
|
|
|
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_);
|
2016-08-02 12:57:37 -07:00
|
|
|
prober_->SetEnabled(enabled);
|
2015-02-16 15:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
void PacedSender::SetEstimatedBitrate(uint32_t bitrate_bps) {
|
2016-08-01 09:47:31 -07:00
|
|
|
if (bitrate_bps == 0)
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_ERROR) << "PacedSender is not designed to handle 0 bitrate.";
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2016-05-11 06:01:13 -07:00
|
|
|
estimated_bitrate_bps_ = bitrate_bps;
|
2016-06-15 00:47:53 -07:00
|
|
|
padding_budget_->set_target_rate_kbps(
|
|
|
|
|
std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
|
2016-05-11 06:01:13 -07:00
|
|
|
pacing_bitrate_kbps_ =
|
|
|
|
|
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
|
2017-06-30 13:27:40 -07:00
|
|
|
pacing_factor_;
|
2016-10-04 08:43:09 -07:00
|
|
|
alr_detector_->SetEstimatedBitrate(bitrate_bps);
|
2016-05-11 06:01:13 -07:00
|
|
|
}
|
|
|
|
|
|
2016-06-15 00:47:53 -07:00
|
|
|
void PacedSender::SetSendBitrateLimits(int min_send_bitrate_bps,
|
|
|
|
|
int padding_bitrate) {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2016-06-15 00:47:53 -07:00
|
|
|
min_send_bitrate_kbps_ = min_send_bitrate_bps / 1000;
|
2016-05-11 06:01:13 -07:00
|
|
|
pacing_bitrate_kbps_ =
|
|
|
|
|
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
|
2017-06-30 13:27:40 -07:00
|
|
|
pacing_factor_;
|
2016-06-15 00:47:53 -07:00
|
|
|
max_padding_bitrate_kbps_ = padding_bitrate / 1000;
|
|
|
|
|
padding_budget_->set_target_rate_kbps(
|
|
|
|
|
std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
|
2012-11-09 20:56:23 +00: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_);
|
2016-05-11 06:01:13 -07:00
|
|
|
RTC_DCHECK(estimated_bitrate_bps_ > 0)
|
|
|
|
|
<< "SetEstimatedBitrate must be called before InsertPacket.";
|
2012-11-09 20:56:23 +00:00
|
|
|
|
2015-11-26 16:26:12 +01:00
|
|
|
int64_t now_ms = clock_->TimeInMilliseconds();
|
2016-08-15 11:51:06 -07: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
|
|
|
|
2017-09-26 17:16:06 +02:00
|
|
|
packets_->Push(PacketQueue::Packet(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);
|
2016-05-11 06:01:13 -07:00
|
|
|
return static_cast<int64_t>(packets_->SizeInBytes() * 8 /
|
|
|
|
|
pacing_bitrate_kbps_);
|
2013-11-27 14:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-28 13:11:13 -08:00
|
|
|
rtc::Optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime()
|
|
|
|
|
const {
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2016-11-28 13:11:13 -08:00
|
|
|
return alr_detector_->GetApplicationLimitedRegionStartTime();
|
2016-10-18 17:04:25 -07: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_);
|
2014-11-04 16:27:16 +00:00
|
|
|
return packets_->SizeInPackets();
|
2013-03-27 16:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2015-11-20 09:00:37 -08:00
|
|
|
int64_t oldest_packet = packets_->OldestEnqueueTimeMs();
|
2014-11-04 16:27:16 +00:00
|
|
|
if (oldest_packet == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return clock_->TimeInMilliseconds() - 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_);
|
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_us = clock_->TimeInMicroseconds() - time_last_update_us_;
|
|
|
|
|
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_)
|
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
|
|
|
return std::max<int64_t>(kPausedPacketIntervalMs - elapsed_time_ms, 0);
|
2017-03-15 07:45:36 -07:00
|
|
|
|
2014-10-23 11:57:05 +00:00
|
|
|
if (prober_->IsProbing()) {
|
2015-02-16 15:47:51 +00:00
|
|
|
int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds());
|
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
|
|
|
}
|
2014-12-15 22:09:40 +00:00
|
|
|
return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-25 04:50:01 -08:00
|
|
|
void PacedSender::Process() {
|
2014-07-15 16:40:38 +00:00
|
|
|
int64_t now_us = clock_->TimeInMicroseconds();
|
2017-03-30 01:14:41 -07:00
|
|
|
rtc::CritScope cs(&critsect_);
|
2017-08-18 03:38:49 -07:00
|
|
|
int64_t elapsed_time_ms = std::min(
|
|
|
|
|
kMaxIntervalTimeMs, (now_us - time_last_update_us_ + 500) / 1000);
|
2016-05-11 06:01:13 -07:00
|
|
|
int target_bitrate_kbps = pacing_bitrate_kbps_;
|
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_) {
|
|
|
|
|
PacedPacketInfo pacing_info;
|
|
|
|
|
time_last_update_us_ = now_us;
|
|
|
|
|
// We can not send padding unless a normal packet has first been sent. If we
|
|
|
|
|
// do, timestamps get messed up.
|
|
|
|
|
if (packet_counter_ == 0)
|
|
|
|
|
return;
|
|
|
|
|
size_t bytes_sent = SendPadding(1, pacing_info);
|
2017-08-18 03:38:49 -07:00
|
|
|
alr_detector_->OnBytesSent(bytes_sent, elapsed_time_ms);
|
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
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (elapsed_time_ms > 0) {
|
2015-11-20 09:00:37 -08:00
|
|
|
size_t queue_size_bytes = packets_->SizeInBytes();
|
|
|
|
|
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.
|
2015-11-26 16:26:12 +01:00
|
|
|
packets_->UpdateQueueTime(clock_->TimeInMilliseconds());
|
2015-11-20 09:00:37 -08:00
|
|
|
int64_t avg_time_left_ms = std::max<int64_t>(
|
2017-06-30 13:27:40 -07:00
|
|
|
1, queue_time_limit - packets_->AverageQueueTimeMs());
|
2015-11-20 09:00:37 -08:00
|
|
|
int min_bitrate_needed_kbps =
|
|
|
|
|
static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms);
|
|
|
|
|
if (min_bitrate_needed_kbps > target_bitrate_kbps)
|
|
|
|
|
target_bitrate_kbps = min_bitrate_needed_kbps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
time_last_update_us_ = now_us;
|
|
|
|
|
|
2016-06-03 01:41:45 -07: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) {
|
2017-02-17 03:59:43 -08:00
|
|
|
pacing_info = prober_->CurrentCluster();
|
2016-10-04 08:29:38 -07:00
|
|
|
recommended_probe_size = prober_->RecommendedMinProbeSize();
|
|
|
|
|
}
|
2015-10-08 11:44:14 +02:00
|
|
|
while (!packets_->Empty()) {
|
|
|
|
|
// 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.
|
2017-09-26 17:16:06 +02:00
|
|
|
const PacketQueue::Packet& packet = packets_->BeginPop();
|
2015-12-07 10:26:18 +01:00
|
|
|
|
2017-02-17 03:59:43 -08:00
|
|
|
if (SendPacket(packet, pacing_info)) {
|
2015-10-08 11:44:14 +02:00
|
|
|
// Send succeeded, remove it from the queue.
|
2017-04-19 23:28:53 -07:00
|
|
|
if (first_sent_packet_ms_ == -1)
|
|
|
|
|
first_sent_packet_ms_ = clock_->TimeInMilliseconds();
|
2016-10-04 08:29:38 -07:00
|
|
|
bytes_sent += packet.bytes;
|
2015-10-08 11:44:14 +02:00
|
|
|
packets_->FinalizePop(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.
|
|
|
|
|
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
|
|
|
|
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 (packets_->Empty()) {
|
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)
|
|
|
|
|
: padding_budget_->bytes_remaining());
|
|
|
|
|
if (padding_needed > 0)
|
2017-02-17 03:59:43 -08:00
|
|
|
bytes_sent += SendPadding(padding_needed, pacing_info);
|
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_)
|
|
|
|
|
prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent);
|
|
|
|
|
}
|
2017-07-11 06:56:04 -07:00
|
|
|
alr_detector_->OnBytesSent(bytes_sent, elapsed_time_ms);
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-15 07:45:36 -07:00
|
|
|
void PacedSender::ProcessThreadAttached(ProcessThread* process_thread) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_INFO) << "ProcessThreadAttached 0x" << std::hex << process_thread;
|
2017-03-15 07:45:36 -07:00
|
|
|
process_thread_ = process_thread;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 17:16:06 +02:00
|
|
|
bool PacedSender::SendPacket(const PacketQueue::Packet& packet,
|
2017-02-17 03:59:43 -08:00
|
|
|
const PacedPacketInfo& pacing_info) {
|
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
|
|
|
RTC_DCHECK(!paused_);
|
2017-02-01 03:57:42 -08:00
|
|
|
if (media_budget_->bytes_remaining() == 0 &&
|
2017-02-17 03:59:43 -08:00
|
|
|
pacing_info.probe_cluster_id == PacedPacketInfo::kNotAProbe) {
|
2017-02-01 03:57:42 -08:00
|
|
|
return false;
|
2016-08-01 09:47:31 -07:00
|
|
|
}
|
2017-02-17 03:59:43 -08:00
|
|
|
|
2017-03-30 01:14:41 -07:00
|
|
|
critsect_.Leave();
|
2016-05-11 06:01:13 -07:00
|
|
|
const bool success = packet_sender_->TimeToSendPacket(
|
|
|
|
|
packet.ssrc, packet.sequence_number, packet.capture_time_ms,
|
2017-02-17 03:59:43 -08:00
|
|
|
packet.retransmission, pacing_info);
|
2017-03-30 01:14:41 -07:00
|
|
|
critsect_.Enter();
|
2014-11-04 16:27:16 +00:00
|
|
|
|
2016-03-02 14:22:25 +01:00
|
|
|
if (success) {
|
2017-10-20 10:37:47 +02:00
|
|
|
if (packet.priority != kHighPriority || account_for_audio_) {
|
2016-03-02 14:22:25 +01:00
|
|
|
// Update media bytes sent.
|
2017-08-02 06:29:00 -07:00
|
|
|
// TODO(eladalon): TimeToSendPacket() can also return |true| in some
|
|
|
|
|
// situations where nothing actually ended up being sent to the network,
|
|
|
|
|
// and we probably don't want to update the budget in such cases.
|
|
|
|
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=8052
|
2016-10-04 08:43:09 -07:00
|
|
|
UpdateBudgetWithBytesSent(packet.bytes);
|
2016-03-02 14:22:25 +01:00
|
|
|
}
|
2013-11-27 14:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-04 16:27:16 +00:00
|
|
|
return success;
|
2012-11-09 20:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-17 03:59:43 -08:00
|
|
|
size_t PacedSender::SendPadding(size_t padding_needed,
|
|
|
|
|
const PacedPacketInfo& pacing_info) {
|
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
|
|
|
RTC_DCHECK_GT(packet_counter_, 0);
|
2017-03-30 01:14:41 -07:00
|
|
|
critsect_.Leave();
|
2016-06-01 06:31:17 -07:00
|
|
|
size_t bytes_sent =
|
2017-02-17 03:59:43 -08:00
|
|
|
packet_sender_->TimeToSendPadding(padding_needed, pacing_info);
|
2017-03-30 01:14:41 -07:00
|
|
|
critsect_.Enter();
|
2012-11-09 20:56:23 +00:00
|
|
|
|
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
|
|
|
}
|
2016-10-04 08:29:38 -07:00
|
|
|
return bytes_sent;
|
2013-03-22 23:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-04 08:43:09 -07:00
|
|
|
void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) {
|
2014-11-04 16:27:16 +00: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) {
|
|
|
|
|
media_budget_->UseBudget(bytes_sent);
|
|
|
|
|
padding_budget_->UseBudget(bytes_sent);
|
|
|
|
|
}
|
2017-06-30 13:27:40 -07:00
|
|
|
|
|
|
|
|
void PacedSender::SetPacingFactor(float pacing_factor) {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
pacing_factor_ = pacing_factor;
|
2017-10-04 09:42:53 +02:00
|
|
|
// Make sure new padding factor is applied immediately, otherwise we need to
|
|
|
|
|
// wait for the send bitrate estimate to be updated before this takes effect.
|
|
|
|
|
SetEstimatedBitrate(estimated_bitrate_bps_);
|
2017-06-30 13:27:40 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-24 17:05:18 +02:00
|
|
|
float PacedSender::GetPacingFactor() const {
|
|
|
|
|
rtc::CritScope cs(&critsect_);
|
|
|
|
|
return pacing_factor_;
|
|
|
|
|
}
|
|
|
|
|
|
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
|