Index: webrtc/modules/pacing/paced_sender.cc |
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc |
index 4c0df4d271457b8efb48c554b237806b6608fa58..b7f9bba2dc5f37dae662a6039a7893e9fc97c222 100644 |
--- a/webrtc/modules/pacing/paced_sender.cc |
+++ b/webrtc/modules/pacing/paced_sender.cc |
@@ -245,9 +245,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, |
+ PacingObserver* pacing_observer) |
: clock_(clock), |
packet_sender_(packet_sender), |
+ pacing_observer_(pacing_observer), |
critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
paused_(false), |
media_budget_(new paced_sender::IntervalBudget(0)), |
@@ -260,7 +263,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() {} |
@@ -397,8 +400,8 @@ 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); |
+ elapsed_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms); |
+ UpdateBudgetWithElapsedTime(elapsed_time_ms); |
} |
bool is_probing = prober_->IsProbing(); |
@@ -442,6 +445,7 @@ void PacedSender::Process() { |
} |
if (is_probing) |
prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent); |
+ pacing_observer_->OnBytesSent(bytes_sent, elapsed_time_ms); |
} |
bool PacedSender::SendPacket(const paced_sender::Packet& packet, |
@@ -468,8 +472,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); |
} |
} |
@@ -483,14 +486,18 @@ size_t PacedSender::SendPadding(size_t padding_needed, int probe_cluster_id) { |
critsect_->Enter(); |
if (bytes_sent > 0) { |
- media_budget_->UseBudget(bytes_sent); |
- padding_budget_->UseBudget(bytes_sent); |
+ UpdateBudgetWithBytesSent(bytes_sent); |
} |
return 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); |
} |
+ |
+void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
+ media_budget_->UseBudget(bytes_sent); |
+ padding_budget_->UseBudget(bytes_sent); |
+} |
} // namespace webrtc |