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

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

Issue 2029593002: Update RateStatistics to handle too-little-data case. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comment Created 4 years, 6 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/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc; 240 RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc;
241 } 241 }
242 } 242 }
243 } 243 }
244 244
245 void ReceiveStatisticsProxy::OnDecodedFrame() { 245 void ReceiveStatisticsProxy::OnDecodedFrame() {
246 uint64_t now = clock_->TimeInMilliseconds(); 246 uint64_t now = clock_->TimeInMilliseconds();
247 247
248 rtc::CritScope lock(&crit_); 248 rtc::CritScope lock(&crit_);
249 decode_fps_estimator_.Update(1, now); 249 decode_fps_estimator_.Update(1, now);
250 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now); 250 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0);
251 } 251 }
252 252
253 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { 253 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) {
254 RTC_DCHECK_GT(width, 0); 254 RTC_DCHECK_GT(width, 0);
255 RTC_DCHECK_GT(height, 0); 255 RTC_DCHECK_GT(height, 0);
256 uint64_t now = clock_->TimeInMilliseconds(); 256 uint64_t now = clock_->TimeInMilliseconds();
257 257
258 rtc::CritScope lock(&crit_); 258 rtc::CritScope lock(&crit_);
259 renders_fps_estimator_.Update(1, now); 259 renders_fps_estimator_.Update(1, now);
260 stats_.render_frame_rate = renders_fps_estimator_.Rate(now); 260 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0);
261 render_width_counter_.Add(width); 261 render_width_counter_.Add(width);
262 render_height_counter_.Add(height); 262 render_height_counter_.Add(height);
263 render_fps_tracker_.AddSamples(1); 263 render_fps_tracker_.AddSamples(1);
264 render_pixel_tracker_.AddSamples(sqrt(width * height)); 264 render_pixel_tracker_.AddSamples(sqrt(width * height));
265 } 265 }
266 266
267 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) { 267 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) {
268 rtc::CritScope lock(&crit_); 268 rtc::CritScope lock(&crit_);
269 sync_offset_counter_.Add(std::abs(sync_offset_ms)); 269 sync_offset_counter_.Add(std::abs(sync_offset_ms));
270 stats_.sync_offset_ms = sync_offset_ms; 270 stats_.sync_offset_ms = sync_offset_ms;
(...skipping 30 matching lines...) Expand all
301 ++num_samples; 301 ++num_samples;
302 } 302 }
303 303
304 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { 304 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const {
305 if (num_samples < min_required_samples || num_samples == 0) 305 if (num_samples < min_required_samples || num_samples == 0)
306 return -1; 306 return -1;
307 return sum / num_samples; 307 return sum / num_samples;
308 } 308 }
309 309
310 } // namespace webrtc 310 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698