Commit e0ef90be authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

[remoting host] Fix div-by-zero in LeakyBucket

When receiving a bandwidth estimate of 0 from WebRTC, the host should
pause the video stream without crashing. This CL is a simple fix which
sets the bucket-emptying time to 1 minute if the rate is set to 0. This
is similar to what we already do in
FrameProcessingTimeEstimator::EstimatedTransitTime().

Bug: 806918
Change-Id: I43bf24cf54250cc3856adeb4c49809733320d46b
Reviewed-on: https://chromium-review.googlesource.com/891671Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532567}
parent 694134e2
......@@ -27,9 +27,17 @@ bool LeakyBucket::RefillOrSpill(int drops, base::TimeTicks now) {
}
base::TimeTicks LeakyBucket::GetEmptyTime() {
return level_updated_time_ +
base::TimeDelta::FromMicroseconds(
base::TimeTicks::kMicrosecondsPerSecond * current_level_ / rate_);
// To avoid unnecessary complexity in WebrtcFrameSchedulerSimple, we return
// a fairly large value (1 minute) here if the b/w estimate is 0 (which means
// that the video stream should be paused). This means that
// WebrtcFrameSchedulerSimple does not need to handle any overflow isssues
// caused by returning TimeDelta::Max().
base::TimeDelta time_to_empty =
(rate_ != 0) ? base::TimeDelta::FromMicroseconds(
base::TimeTicks::kMicrosecondsPerSecond *
current_level_ / rate_)
: base::TimeDelta::FromMinutes(1);
return level_updated_time_ + time_to_empty;
}
void LeakyBucket::UpdateRate(int new_rate, base::TimeTicks now) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment