Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "modules/pacing/pacing_controller.h" |
| 12 | |
| 13 | #include <algorithm> |
| 14 | #include <utility> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "absl/memory/memory.h" |
| 18 | #include "modules/pacing/bitrate_prober.h" |
| 19 | #include "modules/pacing/interval_budget.h" |
| 20 | #include "modules/utility/include/process_thread.h" |
| 21 | #include "rtc_base/checks.h" |
| 22 | #include "rtc_base/logging.h" |
| 23 | #include "rtc_base/time_utils.h" |
| 24 | #include "system_wrappers/include/clock.h" |
| 25 | |
| 26 | namespace webrtc { |
| 27 | namespace { |
| 28 | // Time limit in milliseconds between packet bursts. |
| 29 | constexpr TimeDelta kDefaultMinPacketLimit = TimeDelta::Millis<5>(); |
| 30 | constexpr TimeDelta kCongestedPacketInterval = TimeDelta::Millis<500>(); |
| 31 | constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds<2>(); |
| 32 | |
| 33 | // Upper cap on process interval, in case process has not been called in a long |
| 34 | // time. |
| 35 | constexpr TimeDelta kMaxProcessingInterval = TimeDelta::Millis<30>(); |
| 36 | |
| 37 | bool IsDisabled(const WebRtcKeyValueConfig& field_trials, |
| 38 | absl::string_view key) { |
| 39 | return field_trials.Lookup(key).find("Disabled") == 0; |
| 40 | } |
| 41 | |
| 42 | bool IsEnabled(const WebRtcKeyValueConfig& field_trials, |
| 43 | absl::string_view key) { |
| 44 | return field_trials.Lookup(key).find("Enabled") == 0; |
| 45 | } |
| 46 | |
| 47 | int GetPriorityForType(RtpPacketToSend::Type type) { |
| 48 | switch (type) { |
| 49 | case RtpPacketToSend::Type::kAudio: |
| 50 | // Audio is always prioritized over other packet types. |
| 51 | return 0; |
| 52 | case RtpPacketToSend::Type::kRetransmission: |
| 53 | // Send retransmissions before new media. |
| 54 | return 1; |
| 55 | case RtpPacketToSend::Type::kVideo: |
| 56 | // Video has "normal" priority, in the old speak. |
| 57 | return 2; |
| 58 | case RtpPacketToSend::Type::kForwardErrorCorrection: |
| 59 | // Send redundancy concurrently to video. If it is delayed it might have a |
| 60 | // lower chance of being useful. |
| 61 | return 2; |
| 62 | case RtpPacketToSend::Type::kPadding: |
| 63 | // Packets that are in themselves likely useless, only sent to keep the |
| 64 | // BWE high. |
| 65 | return 3; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | } // namespace |
| 70 | |
| 71 | const TimeDelta PacingController::kMaxExpectedQueueLength = |
| 72 | TimeDelta::Millis<2000>(); |
| 73 | const float PacingController::kDefaultPaceMultiplier = 2.5f; |
| 74 | const TimeDelta PacingController::kPausedProcessInterval = |
| 75 | kCongestedPacketInterval; |
| 76 | |
| 77 | PacingController::PacingController(Clock* clock, |
| 78 | PacketSender* packet_sender, |
| 79 | RtcEventLog* event_log, |
| 80 | const WebRtcKeyValueConfig* field_trials) |
| 81 | : clock_(clock), |
| 82 | packet_sender_(packet_sender), |
| 83 | fallback_field_trials_( |
| 84 | !field_trials ? absl::make_unique<FieldTrialBasedConfig>() : nullptr), |
| 85 | field_trials_(field_trials ? field_trials : fallback_field_trials_.get()), |
| 86 | drain_large_queues_( |
| 87 | !IsDisabled(*field_trials_, "WebRTC-Pacer-DrainQueue")), |
| 88 | send_padding_if_silent_( |
| 89 | IsEnabled(*field_trials_, "WebRTC-Pacer-PadInSilence")), |
| 90 | pace_audio_(!IsDisabled(*field_trials_, "WebRTC-Pacer-BlockAudio")), |
| 91 | min_packet_limit_(kDefaultMinPacketLimit), |
| 92 | last_timestamp_(clock_->CurrentTime()), |
| 93 | paused_(false), |
| 94 | media_budget_(0), |
| 95 | padding_budget_(0), |
| 96 | prober_(*field_trials_), |
| 97 | probing_send_failure_(false), |
| 98 | padding_failure_state_(false), |
| 99 | pacing_bitrate_(DataRate::Zero()), |
| 100 | time_last_process_(clock->CurrentTime()), |
| 101 | last_send_time_(time_last_process_), |
| 102 | packet_queue_(time_last_process_, field_trials), |
| 103 | packet_counter_(0), |
| 104 | congestion_window_size_(DataSize::PlusInfinity()), |
| 105 | outstanding_data_(DataSize::Zero()), |
| 106 | queue_time_limit(kMaxExpectedQueueLength), |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 107 | account_for_audio_(false) { |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 108 | if (!drain_large_queues_) { |
| 109 | RTC_LOG(LS_WARNING) << "Pacer queues will not be drained," |
| 110 | "pushback experiment must be enabled."; |
| 111 | } |
| 112 | FieldTrialParameter<int> min_packet_limit_ms("", min_packet_limit_.ms()); |
| 113 | ParseFieldTrial({&min_packet_limit_ms}, |
| 114 | field_trials_->Lookup("WebRTC-Pacer-MinPacketLimitMs")); |
| 115 | min_packet_limit_ = TimeDelta::ms(min_packet_limit_ms.Get()); |
| 116 | UpdateBudgetWithElapsedTime(min_packet_limit_); |
| 117 | } |
| 118 | |
| 119 | PacingController::~PacingController() = default; |
| 120 | |
| 121 | void PacingController::CreateProbeCluster(DataRate bitrate, int cluster_id) { |
| 122 | prober_.CreateProbeCluster(bitrate.bps(), CurrentTime().ms(), cluster_id); |
| 123 | } |
| 124 | |
| 125 | void PacingController::Pause() { |
| 126 | if (!paused_) |
| 127 | RTC_LOG(LS_INFO) << "PacedSender paused."; |
| 128 | paused_ = true; |
| 129 | packet_queue_.SetPauseState(true, CurrentTime()); |
| 130 | } |
| 131 | |
| 132 | void PacingController::Resume() { |
| 133 | if (paused_) |
| 134 | RTC_LOG(LS_INFO) << "PacedSender resumed."; |
| 135 | paused_ = false; |
| 136 | packet_queue_.SetPauseState(false, CurrentTime()); |
| 137 | } |
| 138 | |
| 139 | bool PacingController::IsPaused() const { |
| 140 | return paused_; |
| 141 | } |
| 142 | |
| 143 | void PacingController::SetCongestionWindow(DataSize congestion_window_size) { |
| 144 | congestion_window_size_ = congestion_window_size; |
| 145 | } |
| 146 | |
| 147 | void PacingController::UpdateOutstandingData(DataSize outstanding_data) { |
| 148 | outstanding_data_ = outstanding_data; |
| 149 | } |
| 150 | |
| 151 | bool PacingController::Congested() const { |
| 152 | if (congestion_window_size_.IsFinite()) { |
| 153 | return outstanding_data_ >= congestion_window_size_; |
| 154 | } |
| 155 | return false; |
| 156 | } |
| 157 | |
| 158 | Timestamp PacingController::CurrentTime() const { |
| 159 | Timestamp time = clock_->CurrentTime(); |
| 160 | if (time < last_timestamp_) { |
| 161 | RTC_LOG(LS_WARNING) |
| 162 | << "Non-monotonic clock behavior observed. Previous timestamp: " |
| 163 | << last_timestamp_.ms() << ", new timestamp: " << time.ms(); |
| 164 | RTC_DCHECK_GE(time, last_timestamp_); |
| 165 | time = last_timestamp_; |
| 166 | } |
| 167 | last_timestamp_ = time; |
| 168 | return time; |
| 169 | } |
| 170 | |
| 171 | void PacingController::SetProbingEnabled(bool enabled) { |
| 172 | RTC_CHECK_EQ(0, packet_counter_); |
| 173 | prober_.SetEnabled(enabled); |
| 174 | } |
| 175 | |
| 176 | void PacingController::SetPacingRates(DataRate pacing_rate, |
| 177 | DataRate padding_rate) { |
| 178 | RTC_DCHECK_GT(pacing_rate, DataRate::Zero()); |
| 179 | pacing_bitrate_ = pacing_rate; |
| 180 | padding_budget_.set_target_rate_kbps(padding_rate.kbps()); |
| 181 | |
| 182 | RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps=" |
| 183 | << pacing_bitrate_.kbps() |
| 184 | << " padding_budget_kbps=" << padding_rate.kbps(); |
| 185 | } |
| 186 | |
| 187 | void PacingController::InsertPacket(RtpPacketSender::Priority priority, |
| 188 | uint32_t ssrc, |
| 189 | uint16_t sequence_number, |
| 190 | int64_t capture_time_ms, |
| 191 | size_t bytes, |
| 192 | bool retransmission) { |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 193 | RTC_NOTREACHED(); |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | void PacingController::EnqueuePacket(std::unique_ptr<RtpPacketToSend> packet) { |
| 197 | RTC_DCHECK(pacing_bitrate_ > DataRate::Zero()) |
| 198 | << "SetPacingRate must be called before InsertPacket."; |
| 199 | |
| 200 | Timestamp now = CurrentTime(); |
| 201 | prober_.OnIncomingPacket(packet->payload_size()); |
| 202 | |
| 203 | if (packet->capture_time_ms() < 0) { |
| 204 | packet->set_capture_time_ms(now.ms()); |
| 205 | } |
| 206 | |
| 207 | RTC_CHECK(packet->packet_type()); |
| 208 | int priority = GetPriorityForType(*packet->packet_type()); |
| 209 | packet_queue_.Push(priority, now, packet_counter_++, std::move(packet)); |
| 210 | } |
| 211 | |
| 212 | void PacingController::SetAccountForAudioPackets(bool account_for_audio) { |
| 213 | account_for_audio_ = account_for_audio; |
| 214 | } |
| 215 | |
| 216 | TimeDelta PacingController::ExpectedQueueTime() const { |
| 217 | RTC_DCHECK_GT(pacing_bitrate_, DataRate::Zero()); |
| 218 | return TimeDelta::ms( |
| 219 | (QueueSizeData().bytes() * 8 * rtc::kNumMillisecsPerSec) / |
| 220 | pacing_bitrate_.bps()); |
| 221 | } |
| 222 | |
| 223 | size_t PacingController::QueueSizePackets() const { |
| 224 | return packet_queue_.SizeInPackets(); |
| 225 | } |
| 226 | |
| 227 | DataSize PacingController::QueueSizeData() const { |
| 228 | return packet_queue_.Size(); |
| 229 | } |
| 230 | |
| 231 | absl::optional<Timestamp> PacingController::FirstSentPacketTime() const { |
| 232 | return first_sent_packet_time_; |
| 233 | } |
| 234 | |
| 235 | TimeDelta PacingController::OldestPacketWaitTime() const { |
| 236 | Timestamp oldest_packet = packet_queue_.OldestEnqueueTime(); |
| 237 | if (oldest_packet.IsInfinite()) { |
| 238 | return TimeDelta::Zero(); |
| 239 | } |
| 240 | |
| 241 | return CurrentTime() - oldest_packet; |
| 242 | } |
| 243 | |
| 244 | TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { |
| 245 | TimeDelta elapsed_time = now - time_last_process_; |
| 246 | time_last_process_ = now; |
| 247 | if (elapsed_time > kMaxElapsedTime) { |
| 248 | RTC_LOG(LS_WARNING) << "Elapsed time (" << elapsed_time.ms() |
| 249 | << " ms) longer than expected, limiting to " |
| 250 | << kMaxElapsedTime.ms(); |
| 251 | elapsed_time = kMaxElapsedTime; |
| 252 | } |
| 253 | return elapsed_time; |
| 254 | } |
| 255 | |
| 256 | bool PacingController::ShouldSendKeepalive(Timestamp now) const { |
| 257 | if (send_padding_if_silent_ || paused_ || Congested()) { |
| 258 | // We send a padding packet every 500 ms to ensure we won't get stuck in |
| 259 | // congested state due to no feedback being received. |
| 260 | TimeDelta elapsed_since_last_send = now - last_send_time_; |
| 261 | if (elapsed_since_last_send >= kCongestedPacketInterval) { |
| 262 | // We can not send padding unless a normal packet has first been sent. If |
| 263 | // we do, timestamps get messed up. |
| 264 | if (packet_counter_ > 0) { |
| 265 | return true; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | absl::optional<TimeDelta> PacingController::TimeUntilNextProbe() { |
| 273 | if (!prober_.IsProbing()) { |
| 274 | return absl::nullopt; |
| 275 | } |
| 276 | |
| 277 | TimeDelta time_delta = |
| 278 | TimeDelta::ms(prober_.TimeUntilNextProbe(CurrentTime().ms())); |
| 279 | if (time_delta > TimeDelta::Zero() || |
| 280 | (time_delta == TimeDelta::Zero() && !probing_send_failure_)) { |
| 281 | return time_delta; |
| 282 | } |
| 283 | |
| 284 | return absl::nullopt; |
| 285 | } |
| 286 | |
| 287 | TimeDelta PacingController::TimeElapsedSinceLastProcess() const { |
| 288 | return CurrentTime() - time_last_process_; |
| 289 | } |
| 290 | |
| 291 | void PacingController::ProcessPackets() { |
| 292 | Timestamp now = CurrentTime(); |
| 293 | TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); |
| 294 | if (ShouldSendKeepalive(now)) { |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 295 | DataSize keepalive_data_sent = DataSize::Zero(); |
| 296 | std::vector<std::unique_ptr<RtpPacketToSend>> keepalive_packets = |
| 297 | packet_sender_->GeneratePadding(DataSize::bytes(1)); |
| 298 | for (auto& packet : keepalive_packets) { |
| 299 | keepalive_data_sent += |
| 300 | DataSize::bytes(packet->payload_size() + packet->padding_size()); |
| 301 | packet_sender_->SendRtpPacket(std::move(packet), PacedPacketInfo()); |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 302 | } |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 303 | OnPaddingSent(keepalive_data_sent); |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | if (paused_) |
| 307 | return; |
| 308 | |
| 309 | if (elapsed_time > TimeDelta::Zero()) { |
| 310 | DataRate target_rate = pacing_bitrate_; |
| 311 | DataSize queue_size_data = packet_queue_.Size(); |
| 312 | if (queue_size_data > DataSize::Zero()) { |
| 313 | // Assuming equal size packets and input/output rate, the average packet |
| 314 | // has avg_time_left_ms left to get queue_size_bytes out of the queue, if |
| 315 | // time constraint shall be met. Determine bitrate needed for that. |
| 316 | packet_queue_.UpdateQueueTime(CurrentTime()); |
| 317 | if (drain_large_queues_) { |
| 318 | TimeDelta avg_time_left = |
| 319 | std::max(TimeDelta::ms(1), |
| 320 | queue_time_limit - packet_queue_.AverageQueueTime()); |
| 321 | DataRate min_rate_needed = queue_size_data / avg_time_left; |
| 322 | if (min_rate_needed > target_rate) { |
| 323 | target_rate = min_rate_needed; |
| 324 | RTC_LOG(LS_VERBOSE) << "bwe:large_pacing_queue pacing_rate_kbps=" |
| 325 | << target_rate.kbps(); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | media_budget_.set_target_rate_kbps(target_rate.kbps()); |
| 331 | UpdateBudgetWithElapsedTime(elapsed_time); |
| 332 | } |
| 333 | |
| 334 | bool is_probing = prober_.IsProbing(); |
| 335 | PacedPacketInfo pacing_info; |
| 336 | absl::optional<DataSize> recommended_probe_size; |
| 337 | if (is_probing) { |
| 338 | pacing_info = prober_.CurrentCluster(); |
| 339 | recommended_probe_size = DataSize::bytes(prober_.RecommendedMinProbeSize()); |
| 340 | } |
| 341 | |
| 342 | DataSize data_sent = DataSize::Zero(); |
| 343 | // The paused state is checked in the loop since it leaves the critical |
| 344 | // section allowing the paused state to be changed from other code. |
| 345 | while (!paused_) { |
| 346 | auto* packet = GetPendingPacket(pacing_info); |
| 347 | if (packet == nullptr) { |
| 348 | // No packet available to send, check if we should send padding. |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 349 | DataSize padding_to_add = PaddingToAdd(recommended_probe_size, data_sent); |
| 350 | if (padding_to_add > DataSize::Zero()) { |
| 351 | std::vector<std::unique_ptr<RtpPacketToSend>> padding_packets = |
| 352 | packet_sender_->GeneratePadding(padding_to_add); |
| 353 | if (padding_packets.empty()) { |
| 354 | // No padding packets were generated, quite send loop. |
| 355 | break; |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 356 | } |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 357 | for (auto& packet : padding_packets) { |
| 358 | EnqueuePacket(std::move(packet)); |
| 359 | } |
| 360 | // Continue loop to send the padding that was just added. |
| 361 | continue; |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | // Can't fetch new packet and no padding to send, exit send loop. |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | std::unique_ptr<RtpPacketToSend> rtp_packet = packet->ReleasePacket(); |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 369 | RTC_DCHECK(rtp_packet); |
| 370 | packet_sender_->SendRtpPacket(std::move(rtp_packet), pacing_info); |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 371 | |
Erik Språng | f5815fa | 2019-08-21 14:27:31 +0200 | [diff] [blame^] | 372 | data_sent += packet->size(); |
| 373 | // Send succeeded, remove it from the queue. |
| 374 | OnPacketSent(packet); |
| 375 | if (recommended_probe_size && data_sent > *recommended_probe_size) |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 376 | break; |
Erik Språng | d05edec | 2019-08-14 10:43:47 +0200 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | if (is_probing) { |
| 380 | probing_send_failure_ = data_sent == DataSize::Zero(); |
| 381 | if (!probing_send_failure_) { |
| 382 | prober_.ProbeSent(CurrentTime().ms(), data_sent.bytes()); |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | DataSize PacingController::PaddingToAdd( |
| 388 | absl::optional<DataSize> recommended_probe_size, |
| 389 | DataSize data_sent) { |
| 390 | if (!packet_queue_.Empty()) { |
| 391 | // Actual payload available, no need to add padding. |
| 392 | return DataSize::Zero(); |
| 393 | } |
| 394 | |
| 395 | if (Congested()) { |
| 396 | // Don't add padding if congested, even if requested for probing. |
| 397 | return DataSize::Zero(); |
| 398 | } |
| 399 | |
| 400 | if (packet_counter_ == 0) { |
| 401 | // We can not send padding unless a normal packet has first been sent. If we |
| 402 | // do, timestamps get messed up. |
| 403 | return DataSize::Zero(); |
| 404 | } |
| 405 | |
| 406 | if (recommended_probe_size) { |
| 407 | if (*recommended_probe_size > data_sent) { |
| 408 | return *recommended_probe_size - data_sent; |
| 409 | } |
| 410 | return DataSize::Zero(); |
| 411 | } |
| 412 | |
| 413 | return DataSize::bytes(padding_budget_.bytes_remaining()); |
| 414 | } |
| 415 | |
| 416 | RoundRobinPacketQueue::QueuedPacket* PacingController::GetPendingPacket( |
| 417 | const PacedPacketInfo& pacing_info) { |
| 418 | if (packet_queue_.Empty()) { |
| 419 | return nullptr; |
| 420 | } |
| 421 | |
| 422 | // Since we need to release the lock in order to send, we first pop the |
| 423 | // element from the priority queue but keep it in storage, so that we can |
| 424 | // reinsert it if send fails. |
| 425 | RoundRobinPacketQueue::QueuedPacket* packet = packet_queue_.BeginPop(); |
| 426 | bool audio_packet = packet->type() == RtpPacketToSend::Type::kAudio; |
| 427 | bool apply_pacing = !audio_packet || pace_audio_; |
| 428 | if (apply_pacing && (Congested() || (media_budget_.bytes_remaining() == 0 && |
| 429 | pacing_info.probe_cluster_id == |
| 430 | PacedPacketInfo::kNotAProbe))) { |
| 431 | packet_queue_.CancelPop(); |
| 432 | return nullptr; |
| 433 | } |
| 434 | return packet; |
| 435 | } |
| 436 | |
| 437 | void PacingController::OnPacketSent( |
| 438 | RoundRobinPacketQueue::QueuedPacket* packet) { |
| 439 | Timestamp now = CurrentTime(); |
| 440 | if (!first_sent_packet_time_) { |
| 441 | first_sent_packet_time_ = now; |
| 442 | } |
| 443 | bool audio_packet = packet->type() == RtpPacketToSend::Type::kAudio; |
| 444 | if (!audio_packet || account_for_audio_) { |
| 445 | // Update media bytes sent. |
| 446 | UpdateBudgetWithSentData(packet->size()); |
| 447 | last_send_time_ = now; |
| 448 | } |
| 449 | // Send succeeded, remove it from the queue. |
| 450 | packet_queue_.FinalizePop(); |
| 451 | padding_failure_state_ = false; |
| 452 | } |
| 453 | |
| 454 | void PacingController::OnPaddingSent(DataSize data_sent) { |
| 455 | if (data_sent > DataSize::Zero()) { |
| 456 | UpdateBudgetWithSentData(data_sent); |
| 457 | } else { |
| 458 | padding_failure_state_ = true; |
| 459 | } |
| 460 | last_send_time_ = CurrentTime(); |
| 461 | } |
| 462 | |
| 463 | void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { |
| 464 | delta = std::min(kMaxProcessingInterval, delta); |
| 465 | media_budget_.IncreaseBudget(delta.ms()); |
| 466 | padding_budget_.IncreaseBudget(delta.ms()); |
| 467 | } |
| 468 | |
| 469 | void PacingController::UpdateBudgetWithSentData(DataSize size) { |
| 470 | outstanding_data_ += size; |
| 471 | media_budget_.UseBudget(size.bytes()); |
| 472 | padding_budget_.UseBudget(size.bytes()); |
| 473 | } |
| 474 | |
| 475 | void PacingController::SetQueueTimeLimit(TimeDelta limit) { |
| 476 | queue_time_limit = limit; |
| 477 | } |
| 478 | |
| 479 | } // namespace webrtc |