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

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

Issue 2861663002: Update decode/render fps stats when calling VideoReceiveStream::GetStats (Closed)
Patch Set: Added unit test Created 3 years, 7 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 | « no previous file | webrtc/video/receive_statistics_proxy_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) 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 frame_window_.erase(frame_window_.begin()); 342 frame_window_.erase(frame_window_.begin());
343 } 343 }
344 344
345 size_t framerate = 345 size_t framerate =
346 (frame_window_.size() * 1000 + 500) / kRateStatisticsWindowSizeMs; 346 (frame_window_.size() * 1000 + 500) / kRateStatisticsWindowSizeMs;
347 stats_.network_frame_rate = static_cast<int>(framerate); 347 stats_.network_frame_rate = static_cast<int>(framerate);
348 } 348 }
349 349
350 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { 350 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
351 rtc::CritScope lock(&crit_); 351 rtc::CritScope lock(&crit_);
352 UpdateFramerate(clock_->TimeInMilliseconds()); 352 // Get current frame rates here, as only updating them on new frames prevents
353 // us from ever correctly displaying frame rate of 0.
354 int64_t now_ms = clock_->TimeInMilliseconds();
355 UpdateFramerate(now_ms);
356 stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0);
357 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0);
353 stats_.total_bitrate_bps = 358 stats_.total_bitrate_bps =
354 static_cast<int>(total_byte_tracker_.ComputeRate() * 8); 359 static_cast<int>(total_byte_tracker_.ComputeRate() * 8);
355 return stats_; 360 return stats_;
356 } 361 }
357 362
358 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) { 363 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) {
359 rtc::CritScope lock(&crit_); 364 rtc::CritScope lock(&crit_);
360 stats_.current_payload_type = payload_type; 365 stats_.current_payload_type = payload_type;
361 } 366 }
362 367
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 stats_.qp_sum = rtc::Optional<uint64_t>(0); 475 stats_.qp_sum = rtc::Optional<uint64_t>(0);
471 } 476 }
472 *stats_.qp_sum += *qp; 477 *stats_.qp_sum += *qp;
473 } else if (stats_.qp_sum) { 478 } else if (stats_.qp_sum) {
474 LOG(LS_WARNING) 479 LOG(LS_WARNING)
475 << "QP sum was already set and no QP was given for a frame."; 480 << "QP sum was already set and no QP was given for a frame.";
476 stats_.qp_sum = rtc::Optional<uint64_t>(); 481 stats_.qp_sum = rtc::Optional<uint64_t>();
477 } 482 }
478 last_content_type_ = content_type; 483 last_content_type_ = content_type;
479 decode_fps_estimator_.Update(1, now); 484 decode_fps_estimator_.Update(1, now);
480 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0);
481 } 485 }
482 486
483 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { 487 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) {
484 int width = frame.width(); 488 int width = frame.width();
485 int height = frame.height(); 489 int height = frame.height();
486 RTC_DCHECK_GT(width, 0); 490 RTC_DCHECK_GT(width, 0);
487 RTC_DCHECK_GT(height, 0); 491 RTC_DCHECK_GT(height, 0);
488 uint64_t now = clock_->TimeInMilliseconds(); 492 uint64_t now = clock_->TimeInMilliseconds();
489 493
490 rtc::CritScope lock(&crit_); 494 rtc::CritScope lock(&crit_);
491 renders_fps_estimator_.Update(1, now); 495 renders_fps_estimator_.Update(1, now);
492 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0);
493 ++stats_.frames_rendered; 496 ++stats_.frames_rendered;
494 stats_.width = width; 497 stats_.width = width;
495 stats_.height = height; 498 stats_.height = height;
496 render_width_counter_.Add(width); 499 render_width_counter_.Add(width);
497 render_height_counter_.Add(height); 500 render_height_counter_.Add(height);
498 render_fps_tracker_.AddSamples(1); 501 render_fps_tracker_.AddSamples(1);
499 render_pixel_tracker_.AddSamples(sqrt(width * height)); 502 render_pixel_tracker_.AddSamples(sqrt(width * height));
500 503
501 if (frame.ntp_time_ms() > 0) { 504 if (frame.ntp_time_ms() > 0) {
502 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); 505 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 sum = 0; 589 sum = 0;
587 } 590 }
588 591
589 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, 592 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms,
590 int64_t max_rtt_ms) { 593 int64_t max_rtt_ms) {
591 rtc::CritScope lock(&crit_); 594 rtc::CritScope lock(&crit_);
592 avg_rtt_ms_ = avg_rtt_ms; 595 avg_rtt_ms_ = avg_rtt_ms;
593 } 596 }
594 597
595 } // namespace webrtc 598 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/receive_statistics_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698