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

Side by Side Diff: webrtc/video/stats_counter.cc

Issue 2236923002: Make variable for selecting if intervals without samples should be included in stats configurable (… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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/video/stats_counter.h ('k') | webrtc/video/stats_counter_unittest.cc » ('j') | 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 StatsCounter::Add(sample ? 1 : 0); 188 StatsCounter::Add(sample ? 1 : 0);
189 } 189 }
190 190
191 bool PermilleCounter::GetMetric(int* metric) const { 191 bool PermilleCounter::GetMetric(int* metric) const {
192 if (num_samples_ == 0) 192 if (num_samples_ == 0)
193 return false; 193 return false;
194 *metric = (sum_ * 1000 + num_samples_ / 2) / num_samples_; 194 *metric = (sum_ * 1000 + num_samples_ / 2) / num_samples_;
195 return true; 195 return true;
196 } 196 }
197 197
198 RateCounter::RateCounter(Clock* clock, StatsCounterObserver* observer) 198 RateCounter::RateCounter(Clock* clock,
199 : StatsCounter(clock, 199 StatsCounterObserver* observer,
200 true, // |include_empty_intervals| 200 bool include_empty_intervals)
201 observer) {} 201 : StatsCounter(clock, include_empty_intervals, observer) {}
202 202
203 void RateCounter::Add(int sample) { 203 void RateCounter::Add(int sample) {
204 StatsCounter::Add(sample); 204 StatsCounter::Add(sample);
205 } 205 }
206 206
207 bool RateCounter::GetMetric(int* metric) const { 207 bool RateCounter::GetMetric(int* metric) const {
208 if (num_samples_ == 0) 208 if (num_samples_ == 0)
209 return false; 209 return false;
210 *metric = (sum_ * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs; 210 *metric = (sum_ * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs;
211 return true; 211 return true;
212 } 212 }
213 213
214 RateAccCounter::RateAccCounter(Clock* clock, StatsCounterObserver* observer) 214 RateAccCounter::RateAccCounter(Clock* clock,
215 : StatsCounter(clock, 215 StatsCounterObserver* observer,
216 true, // |include_empty_intervals| 216 bool include_empty_intervals)
217 observer) {} 217 : StatsCounter(clock, include_empty_intervals, observer) {}
218 218
219 void RateAccCounter::Set(int sample) { 219 void RateAccCounter::Set(int sample) {
220 StatsCounter::Set(sample); 220 StatsCounter::Set(sample);
221 } 221 }
222 222
223 bool RateAccCounter::GetMetric(int* metric) const { 223 bool RateAccCounter::GetMetric(int* metric) const {
224 if (num_samples_ == 0 || last_sum_ > sum_) 224 if (num_samples_ == 0 || last_sum_ > sum_)
225 return false; 225 return false;
226 *metric = 226 *metric =
227 ((sum_ - last_sum_) * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs; 227 ((sum_ - last_sum_) * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs;
228 return true; 228 return true;
229 } 229 }
230 230
231 } // namespace webrtc 231 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/stats_counter.h ('k') | webrtc/video/stats_counter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698