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

Side by Side Diff: webrtc/base/ratetracker.cc

Issue 2381833003: Change TWCC send interval to reduce overhead on low BW situations. (Closed)
Patch Set: Rebased Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 for (size_t i = NextBucketIndex(start_bucket); 86 for (size_t i = NextBucketIndex(start_bucket);
87 i != NextBucketIndex(current_bucket_); 87 i != NextBucketIndex(current_bucket_);
88 i = NextBucketIndex(i)) { 88 i = NextBucketIndex(i)) {
89 total_samples += sample_buckets_[i]; 89 total_samples += sample_buckets_[i];
90 } 90 }
91 // Convert to samples per second. 91 // Convert to samples per second.
92 return static_cast<double>(total_samples * 1000) / 92 return static_cast<double>(total_samples * 1000) /
93 static_cast<double>(available_interval_milliseconds); 93 static_cast<double>(available_interval_milliseconds);
94 } 94 }
95 95
96 double RateTracker::ComputeRate() const {
97 return ComputeRateForInterval(bucket_milliseconds_ *
98 static_cast<int64_t>(bucket_count_));
99 }
100
96 double RateTracker::ComputeTotalRate() const { 101 double RateTracker::ComputeTotalRate() const {
97 if (bucket_start_time_milliseconds_ == kTimeUnset) { 102 if (bucket_start_time_milliseconds_ == kTimeUnset) {
98 return 0.0; 103 return 0.0;
99 } 104 }
100 int64_t current_time = Time(); 105 int64_t current_time = Time();
101 if (current_time <= initialization_time_milliseconds_) { 106 if (current_time <= initialization_time_milliseconds_) {
102 return 0.0; 107 return 0.0;
103 } 108 }
104 return static_cast<double>(total_sample_count_ * 1000) / 109 return static_cast<double>(total_sample_count_ * 1000) /
105 static_cast<double>( 110 static_cast<double>(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // current_bucket_ increments. 150 // current_bucket_ increments.
146 sample_buckets_[current_bucket_] = 0; 151 sample_buckets_[current_bucket_] = 0;
147 } 152 }
148 } 153 }
149 154
150 size_t RateTracker::NextBucketIndex(size_t bucket_index) const { 155 size_t RateTracker::NextBucketIndex(size_t bucket_index) const {
151 return (bucket_index + 1u) % (bucket_count_ + 1u); 156 return (bucket_index + 1u) % (bucket_count_ + 1u);
152 } 157 }
153 158
154 } // namespace rtc 159 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698