Index: webrtc/modules/pacing/paced_sender.cc |
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc |
index b0b86ee40e73cce3af346a12876613484059cce4..1f9557080afd9c9e52f02a16dbb40bc215f729ac 100644 |
--- a/webrtc/modules/pacing/paced_sender.cc |
+++ b/webrtc/modules/pacing/paced_sender.cc |
@@ -20,6 +20,7 @@ |
#include "webrtc/base/logging.h" |
#include "webrtc/modules/include/module_common_types.h" |
#include "webrtc/modules/pacing/bitrate_prober.h" |
+#include "webrtc/modules/pacing/alr_detector.h" |
#include "webrtc/system_wrappers/include/clock.h" |
#include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
#include "webrtc/system_wrappers/include/field_trial.h" |
@@ -245,9 +246,12 @@ 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, |
+ AlrDetector* alr_detector) |
: clock_(clock), |
packet_sender_(packet_sender), |
+ alr_detector_(alr_detector), |
critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
paused_(false), |
media_budget_(new paced_sender::IntervalBudget(0)), |
@@ -260,7 +264,7 @@ PacedSender::PacedSender(Clock* clock, PacketSender* packet_sender) |
time_last_update_us_(clock->TimeInMicroseconds()), |
packets_(new paced_sender::PacketQueue(clock)), |
packet_counter_(0) { |
- UpdateBytesPerInterval(kMinPacketLimitMs); |
+ UpdateBudgetWithElapsedTime(kMinPacketLimitMs); |
} |
PacedSender::~PacedSender() {} |
@@ -298,6 +302,8 @@ void PacedSender::SetEstimatedBitrate(uint32_t bitrate_bps) { |
pacing_bitrate_kbps_ = |
std::max(min_send_bitrate_kbps_, estimated_bitrate_bps_ / 1000) * |
kDefaultPaceMultiplier; |
+ if (alr_detector_) |
+ alr_detector_->SetEstimatedBitrate(bitrate_bps); |
} |
void PacedSender::SetSendBitrateLimits(int min_send_bitrate_bps, |
@@ -398,7 +404,7 @@ void PacedSender::Process() { |
media_budget_->set_target_rate_kbps(target_bitrate_kbps); |
int64_t delta_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms); |
- UpdateBytesPerInterval(delta_time_ms); |
+ UpdateBudgetWithElapsedTime(delta_time_ms); |
} |
bool is_probing = prober_->IsProbing(); |
@@ -463,8 +469,7 @@ bool PacedSender::SendPacket(const paced_sender::Packet& packet, |
// are allocating bandwidth for audio. |
if (packet.priority != kHighPriority) { |
// Update media bytes sent. |
- media_budget_->UseBudget(packet.bytes); |
- padding_budget_->UseBudget(packet.bytes); |
+ UpdateBudgetWithBytesSent(packet.bytes); |
} |
} |
@@ -479,13 +484,21 @@ void PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) { |
if (bytes_sent > 0) { |
prober_->PacketSent(clock_->TimeInMilliseconds(), bytes_sent); |
- media_budget_->UseBudget(bytes_sent); |
- padding_budget_->UseBudget(bytes_sent); |
+ UpdateBudgetWithBytesSent(bytes_sent); |
} |
} |
-void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { |
+void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { |
media_budget_->IncreaseBudget(delta_time_ms); |
padding_budget_->IncreaseBudget(delta_time_ms); |
+ if (alr_detector_) |
+ alr_detector_->ReportElapsedTime(delta_time_ms); |
+} |
+ |
+void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
+ media_budget_->UseBudget(bytes_sent); |
+ padding_budget_->UseBudget(bytes_sent); |
+ if (alr_detector_) |
+ alr_detector_->ReportBytesSent(bytes_sent); |
} |
} // namespace webrtc |