Fix for alr detection bug on pause.

BUG=webrtc:7926

Review-Url: https://codereview.webrtc.org/2995183002
Cr-Commit-Position: refs/heads/master@{#19407}
This commit is contained in:
tschumim 2017-08-18 03:38:49 -07:00 committed by Commit Bot
parent 84778c74a0
commit 5afa3f2690
2 changed files with 5 additions and 4 deletions

View File

@ -15,6 +15,7 @@
namespace webrtc {
namespace {
constexpr int kWindowMs = 500;
constexpr int kDeltaTimeMs = 2000;
}
IntervalBudget::IntervalBudget(int initial_target_rate_kbps)
@ -34,6 +35,7 @@ void IntervalBudget::set_target_rate_kbps(int target_rate_kbps) {
}
void IntervalBudget::IncreaseBudget(int64_t delta_time_ms) {
RTC_DCHECK_LT(delta_time_ms, kDeltaTimeMs);
int bytes = target_rate_kbps_ * delta_time_ms / 8;
if (bytes_remaining_ < 0 || can_build_up_underuse_) {
// We overused last interval, compensate this interval.

View File

@ -406,7 +406,8 @@ int64_t PacedSender::TimeUntilNextProcess() {
void PacedSender::Process() {
int64_t now_us = clock_->TimeInMicroseconds();
rtc::CritScope cs(&critsect_);
int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000;
int64_t elapsed_time_ms = std::min(
kMaxIntervalTimeMs, (now_us - time_last_update_us_ + 500) / 1000);
int target_bitrate_kbps = pacing_bitrate_kbps_;
if (paused_) {
@ -417,7 +418,7 @@ void PacedSender::Process() {
if (packet_counter_ == 0)
return;
size_t bytes_sent = SendPadding(1, pacing_info);
alr_detector_->OnBytesSent(bytes_sent, now_us / 1000);
alr_detector_->OnBytesSent(bytes_sent, elapsed_time_ms);
return;
}
@ -437,8 +438,6 @@ void PacedSender::Process() {
}
media_budget_->set_target_rate_kbps(target_bitrate_kbps);
elapsed_time_ms = std::min(kMaxIntervalTimeMs, elapsed_time_ms);
UpdateBudgetWithElapsedTime(elapsed_time_ms);
}