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

Side by Side Diff: webrtc/modules/pacing/paced_sender.cc

Issue 2995183002: Fix for alr detection bug on pause. (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/pacing/interval_budget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds()); 399 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds());
400 if (ret > 0 || (ret == 0 && !probing_send_failure_)) 400 if (ret > 0 || (ret == 0 && !probing_send_failure_))
401 return ret; 401 return ret;
402 } 402 }
403 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); 403 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0);
404 } 404 }
405 405
406 void PacedSender::Process() { 406 void PacedSender::Process() {
407 int64_t now_us = clock_->TimeInMicroseconds(); 407 int64_t now_us = clock_->TimeInMicroseconds();
408 rtc::CritScope cs(&critsect_); 408 rtc::CritScope cs(&critsect_);
409 int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000; 409 int64_t elapsed_time_ms = std::min(
410 kMaxIntervalTimeMs, (now_us - time_last_update_us_ + 500) / 1000);
410 int target_bitrate_kbps = pacing_bitrate_kbps_; 411 int target_bitrate_kbps = pacing_bitrate_kbps_;
411 412
412 if (paused_) { 413 if (paused_) {
413 PacedPacketInfo pacing_info; 414 PacedPacketInfo pacing_info;
414 time_last_update_us_ = now_us; 415 time_last_update_us_ = now_us;
415 // We can not send padding unless a normal packet has first been sent. If we 416 // We can not send padding unless a normal packet has first been sent. If we
416 // do, timestamps get messed up. 417 // do, timestamps get messed up.
417 if (packet_counter_ == 0) 418 if (packet_counter_ == 0)
418 return; 419 return;
419 size_t bytes_sent = SendPadding(1, pacing_info); 420 size_t bytes_sent = SendPadding(1, pacing_info);
420 alr_detector_->OnBytesSent(bytes_sent, now_us / 1000); 421 alr_detector_->OnBytesSent(bytes_sent, elapsed_time_ms);
421 return; 422 return;
422 } 423 }
423 424
424 if (elapsed_time_ms > 0) { 425 if (elapsed_time_ms > 0) {
425 size_t queue_size_bytes = packets_->SizeInBytes(); 426 size_t queue_size_bytes = packets_->SizeInBytes();
426 if (queue_size_bytes > 0) { 427 if (queue_size_bytes > 0) {
427 // Assuming equal size packets and input/output rate, the average packet 428 // Assuming equal size packets and input/output rate, the average packet
428 // has avg_time_left_ms left to get queue_size_bytes out of the queue, if 429 // has avg_time_left_ms left to get queue_size_bytes out of the queue, if
429 // time constraint shall be met. Determine bitrate needed for that. 430 // time constraint shall be met. Determine bitrate needed for that.
430 packets_->UpdateQueueTime(clock_->TimeInMilliseconds()); 431 packets_->UpdateQueueTime(clock_->TimeInMilliseconds());
431 int64_t avg_time_left_ms = std::max<int64_t>( 432 int64_t avg_time_left_ms = std::max<int64_t>(
432 1, queue_time_limit - packets_->AverageQueueTimeMs()); 433 1, queue_time_limit - packets_->AverageQueueTimeMs());
433 int min_bitrate_needed_kbps = 434 int min_bitrate_needed_kbps =
434 static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms); 435 static_cast<int>(queue_size_bytes * 8 / avg_time_left_ms);
435 if (min_bitrate_needed_kbps > target_bitrate_kbps) 436 if (min_bitrate_needed_kbps > target_bitrate_kbps)
436 target_bitrate_kbps = min_bitrate_needed_kbps; 437 target_bitrate_kbps = min_bitrate_needed_kbps;
437 } 438 }
438 439
439 media_budget_->set_target_rate_kbps(target_bitrate_kbps); 440 media_budget_->set_target_rate_kbps(target_bitrate_kbps);
440
441 elapsed_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms);
442 UpdateBudgetWithElapsedTime(elapsed_time_ms); 441 UpdateBudgetWithElapsedTime(elapsed_time_ms);
443 } 442 }
444 443
445 time_last_update_us_ = now_us; 444 time_last_update_us_ = now_us;
446 445
447 bool is_probing = prober_->IsProbing(); 446 bool is_probing = prober_->IsProbing();
448 PacedPacketInfo pacing_info; 447 PacedPacketInfo pacing_info;
449 size_t bytes_sent = 0; 448 size_t bytes_sent = 0;
450 size_t recommended_probe_size = 0; 449 size_t recommended_probe_size = 0;
451 if (is_probing) { 450 if (is_probing) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 rtc::CritScope cs(&critsect_); 554 rtc::CritScope cs(&critsect_);
556 pacing_factor_ = pacing_factor; 555 pacing_factor_ = pacing_factor;
557 } 556 }
558 557
559 void PacedSender::SetQueueTimeLimit(int limit_ms) { 558 void PacedSender::SetQueueTimeLimit(int limit_ms) {
560 rtc::CritScope cs(&critsect_); 559 rtc::CritScope cs(&critsect_);
561 queue_time_limit = limit_ms; 560 queue_time_limit = limit_ms;
562 } 561 }
563 562
564 } // namespace webrtc 563 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/interval_budget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698