Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: webrtc/modules/pacing/paced_sender.cc

Issue 1993113003: Refactor how padding is calculated. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/pacing/paced_sender.cc
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc
index efbf969ac1c871d34d709adf665c757f1208bf64..e5e989aac35bfbc4379cd11db43890e95c4c7428 100644
--- a/webrtc/modules/pacing/paced_sender.cc
+++ b/webrtc/modules/pacing/paced_sender.cc
@@ -245,8 +245,7 @@ class IntervalBudget {
const int64_t PacedSender::kMaxQueueLengthMs = 2000;
const float PacedSender::kDefaultPaceMultiplier = 2.5f;
-PacedSender::PacedSender(Clock* clock,
- PacketSender* packet_sender)
+PacedSender::PacedSender(Clock* clock, PacketSender* packet_sender)
: clock_(clock),
packet_sender_(packet_sender),
critsect_(CriticalSectionWrapper::CreateCriticalSection()),
@@ -257,6 +256,7 @@ PacedSender::PacedSender(Clock* clock,
prober_(new BitrateProber()),
estimated_bitrate_bps_(0),
min_send_bitrate_kbps_(0u),
+ max_padding_bitrate_kbps_(0u),
pacing_bitrate_kbps_(0),
time_last_update_us_(clock->TimeInMicroseconds()),
packets_(new paced_sender::PacketQueue(clock)),
@@ -284,6 +284,8 @@ void PacedSender::SetProbingEnabled(bool enabled) {
void PacedSender::SetEstimatedBitrate(uint32_t bitrate_bps) {
CriticalSectionScoped cs(critsect_.get());
estimated_bitrate_bps_ = bitrate_bps;
+ padding_budget_->set_target_rate_kbps(
+ std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
pacing_bitrate_kbps_ =
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
kDefaultPaceMultiplier;
@@ -296,7 +298,9 @@ void PacedSender::SetAllocatedSendBitrate(int allocated_bitrate,
pacing_bitrate_kbps_ =
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) *
kDefaultPaceMultiplier;
- padding_budget_->set_target_rate_kbps(padding_bitrate / 1000);
+ max_padding_bitrate_kbps_ = padding_bitrate / 1000;
+ padding_budget_->set_target_rate_kbps(
+ std::min(estimated_bitrate_bps_ / 1000, max_padding_bitrate_kbps_));
}
void PacedSender::InsertPacket(RtpPacketSender::Priority priority,
@@ -418,15 +422,15 @@ void PacedSender::Process() {
if (paused_ || !packets_->Empty())
return;
- size_t padding_needed;
- if (is_probing) {
- padding_needed = prober_->RecommendedPacketSize();
- } else {
- padding_needed = padding_budget_->bytes_remaining();
- }
+ // We can not send padding unless a normal packet has first been sent. If we
+ // do, timestamps gets messed up.
stefan-webrtc 2016/06/10 13:54:13 This isnt true if we are using rtx. Is this really
perkj_webrtc 2016/06/14 10:58:02 There was a test that failed due to that it checke
+ if (packet_counter_ > 0) {
+ size_t padding_needed = is_probing ? prober_->RecommendedPacketSize()
+ : padding_budget_->bytes_remaining();
- if (padding_needed > 0)
- SendPadding(padding_needed, probe_cluster_id);
+ if (padding_needed > 0)
+ SendPadding(padding_needed, probe_cluster_id);
+ }
}
bool PacedSender::SendPacket(const paced_sender::Packet& packet,

Powered by Google App Engine
This is Rietveld 408576698