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

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

Issue 2995143002: Report max interframe delay over window insdead of interframe delay sum (Closed)
Patch Set: Created 3 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
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 25 matching lines...) Expand all
36 // Low means low enough to be bad, high means high enough to be good 36 // Low means low enough to be bad, high means high enough to be good
37 const int kLowFpsThreshold = 12; 37 const int kLowFpsThreshold = 12;
38 const int kHighFpsThreshold = 14; 38 const int kHighFpsThreshold = 14;
39 // For qp and fps variance: 39 // For qp and fps variance:
40 // Low means low enough to be good, high means high enough to be bad 40 // Low means low enough to be good, high means high enough to be bad
41 const int kLowQpThresholdVp8 = 60; 41 const int kLowQpThresholdVp8 = 60;
42 const int kHighQpThresholdVp8 = 70; 42 const int kHighQpThresholdVp8 = 70;
43 const int kLowVarianceThreshold = 1; 43 const int kLowVarianceThreshold = 1;
44 const int kHighVarianceThreshold = 2; 44 const int kHighVarianceThreshold = 2;
45 45
46 // Some metrics are reported as a maximum over this period.
47 const int kMovingMaxWindowMs = 5000;
sprang_webrtc 2017/08/18 09:06:49 I think this interval needs to be longer. At least
ilnik 2017/08/18 11:43:01 Done.
48
46 // How large window we use to calculate the framerate/bitrate. 49 // How large window we use to calculate the framerate/bitrate.
47 const int kRateStatisticsWindowSizeMs = 1000; 50 const int kRateStatisticsWindowSizeMs = 1000;
48 } // namespace 51 } // namespace
49 52
50 ReceiveStatisticsProxy::ReceiveStatisticsProxy( 53 ReceiveStatisticsProxy::ReceiveStatisticsProxy(
51 const VideoReceiveStream::Config* config, 54 const VideoReceiveStream::Config* config,
52 Clock* clock) 55 Clock* clock)
53 : clock_(clock), 56 : clock_(clock),
54 config_(*config), 57 config_(*config),
55 start_ms_(clock->TimeInMilliseconds()), 58 start_ms_(clock->TimeInMilliseconds()),
(...skipping 15 matching lines...) Expand all
71 // 1000ms window, scale 1000 for ms to s. 74 // 1000ms window, scale 1000 for ms to s.
72 decode_fps_estimator_(1000, 1000), 75 decode_fps_estimator_(1000, 1000),
73 renders_fps_estimator_(1000, 1000), 76 renders_fps_estimator_(1000, 1000),
74 render_fps_tracker_(100, 10u), 77 render_fps_tracker_(100, 10u),
75 render_pixel_tracker_(100, 10u), 78 render_pixel_tracker_(100, 10u),
76 total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count 79 total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count
77 e2e_delay_max_ms_video_(-1), 80 e2e_delay_max_ms_video_(-1),
78 e2e_delay_max_ms_screenshare_(-1), 81 e2e_delay_max_ms_screenshare_(-1),
79 interframe_delay_max_ms_video_(-1), 82 interframe_delay_max_ms_video_(-1),
80 interframe_delay_max_ms_screenshare_(-1), 83 interframe_delay_max_ms_screenshare_(-1),
84 interframe_delay_max_moving_(kMovingMaxWindowMs),
81 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), 85 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs),
82 first_report_block_time_ms_(-1), 86 first_report_block_time_ms_(-1),
83 avg_rtt_ms_(0), 87 avg_rtt_ms_(0),
84 last_content_type_(VideoContentType::UNSPECIFIED) { 88 last_content_type_(VideoContentType::UNSPECIFIED) {
85 stats_.ssrc = config_.rtp.remote_ssrc; 89 stats_.ssrc = config_.rtp.remote_ssrc;
86 // TODO(brandtr): Replace |rtx_stats_| with a single instance of 90 // TODO(brandtr): Replace |rtx_stats_| with a single instance of
87 // StreamDataCounters. 91 // StreamDataCounters.
88 if (config_.rtp.rtx_ssrc) { 92 if (config_.rtp.rtx_ssrc) {
89 rtx_stats_[config_.rtp.rtx_ssrc] = StreamDataCounters(); 93 rtx_stats_[config_.rtp.rtx_ssrc] = StreamDataCounters();
90 } 94 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { 391 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
388 rtc::CritScope lock(&crit_); 392 rtc::CritScope lock(&crit_);
389 // Get current frame rates here, as only updating them on new frames prevents 393 // Get current frame rates here, as only updating them on new frames prevents
390 // us from ever correctly displaying frame rate of 0. 394 // us from ever correctly displaying frame rate of 0.
391 int64_t now_ms = clock_->TimeInMilliseconds(); 395 int64_t now_ms = clock_->TimeInMilliseconds();
392 UpdateFramerate(now_ms); 396 UpdateFramerate(now_ms);
393 stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0); 397 stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0);
394 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0); 398 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0);
395 stats_.total_bitrate_bps = 399 stats_.total_bitrate_bps =
396 static_cast<int>(total_byte_tracker_.ComputeRate() * 8); 400 static_cast<int>(total_byte_tracker_.ComputeRate() * 8);
401 stats_.interframe_delay_max_ms =
402 interframe_delay_max_moving_.MovingMax(now_ms).value_or(0);
397 return stats_; 403 return stats_;
398 } 404 }
399 405
400 rtc::Optional<TimingFrameInfo> 406 rtc::Optional<TimingFrameInfo>
401 ReceiveStatisticsProxy::GetAndResetTimingFrameInfo() { 407 ReceiveStatisticsProxy::GetAndResetTimingFrameInfo() {
402 rtc::CritScope lock(&crit_); 408 rtc::CritScope lock(&crit_);
403 rtc::Optional<TimingFrameInfo> info = timing_frame_info_; 409 rtc::Optional<TimingFrameInfo> info = timing_frame_info_;
404 // Reset reported value to empty, so it will be always 410 // Reset reported value to empty, so it will be always
405 // overwritten in |OnTimingFrameInfoUpdated|, thus allowing to store new 411 // overwritten in |OnTimingFrameInfoUpdated|, thus allowing to store new
406 // value instead of reported one. 412 // value instead of reported one.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } else if (stats_.qp_sum) { 543 } else if (stats_.qp_sum) {
538 LOG(LS_WARNING) 544 LOG(LS_WARNING)
539 << "QP sum was already set and no QP was given for a frame."; 545 << "QP sum was already set and no QP was given for a frame.";
540 stats_.qp_sum = rtc::Optional<uint64_t>(); 546 stats_.qp_sum = rtc::Optional<uint64_t>();
541 } 547 }
542 last_content_type_ = content_type; 548 last_content_type_ = content_type;
543 decode_fps_estimator_.Update(1, now); 549 decode_fps_estimator_.Update(1, now);
544 if (last_decoded_frame_time_ms_) { 550 if (last_decoded_frame_time_ms_) {
545 int64_t interframe_delay_ms = now - *last_decoded_frame_time_ms_; 551 int64_t interframe_delay_ms = now - *last_decoded_frame_time_ms_;
546 RTC_DCHECK_GE(interframe_delay_ms, 0); 552 RTC_DCHECK_GE(interframe_delay_ms, 0);
547 stats_.interframe_delay_sum_ms += interframe_delay_ms; 553 interframe_delay_max_moving_.Add(interframe_delay_ms, now);
548 if (last_content_type_ == VideoContentType::SCREENSHARE) { 554 if (last_content_type_ == VideoContentType::SCREENSHARE) {
549 interframe_delay_counter_screenshare_.Add(interframe_delay_ms); 555 interframe_delay_counter_screenshare_.Add(interframe_delay_ms);
550 if (interframe_delay_max_ms_screenshare_ < interframe_delay_ms) { 556 if (interframe_delay_max_ms_screenshare_ < interframe_delay_ms) {
551 interframe_delay_max_ms_screenshare_ = interframe_delay_ms; 557 interframe_delay_max_ms_screenshare_ = interframe_delay_ms;
552 } 558 }
553 } else { 559 } else {
554 interframe_delay_counter_video_.Add(interframe_delay_ms); 560 interframe_delay_counter_video_.Add(interframe_delay_ms);
555 if (interframe_delay_max_ms_video_ < interframe_delay_ms) { 561 if (interframe_delay_max_ms_video_ < interframe_delay_ms) {
556 interframe_delay_max_ms_video_ = interframe_delay_ms; 562 interframe_delay_max_ms_video_ = interframe_delay_ms;
557 } 563 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 if (num_samples < min_required_samples || num_samples == 0) 664 if (num_samples < min_required_samples || num_samples == 0)
659 return -1; 665 return -1;
660 return static_cast<int>(sum / num_samples); 666 return static_cast<int>(sum / num_samples);
661 } 667 }
662 668
663 void ReceiveStatisticsProxy::SampleCounter::Reset() { 669 void ReceiveStatisticsProxy::SampleCounter::Reset() {
664 num_samples = 0; 670 num_samples = 0;
665 sum = 0; 671 sum = 0;
666 } 672 }
667 673
674 void ReceiveStatisticsProxy::MovingMaxCounter::Add(int sample,
675 int64_t time_ms) {
676 int64_t window_begin_ms = time_ms - window_length_ms_;
677 // Throw out obsolete samples.
678 while (!samples_.empty() && samples_.front().first < window_begin_ms) {
679 samples_.pop_front();
680 }
681 // Remove samples what will never be maximum in any window: newly added sample
682 // will always be in all windows the previous samples are. Thus, smaller
683 // samples could be removed. This will maintain the invariant - deque contains
684 // non-increasing sequence of values.
685 while (!samples_.empty() && samples_.back().second < sample) {
686 samples_.pop_back();
687 }
688 samples_.push_back(std::make_pair(time_ms, sample));
sprang_webrtc 2017/08/18 09:06:49 emplace_back even?
ilnik 2017/08/18 11:43:01 Done.
689 }
690
691 rtc::Optional<int> ReceiveStatisticsProxy::MovingMaxCounter::MovingMax(
692 int64_t time_ms) const {
693 rtc::Optional<int> res;
694 if (samples_.empty()) {
695 return res;
696 }
697 int64_t window_begin_ms = time_ms - window_length_ms_;
698 auto it = samples_.begin();
699 while (it != samples_.end() && it->first < window_begin_ms) {
700 ++it;
701 }
702 if (it != samples_.end()) {
703 res.emplace(it->second);
704 }
705 return res;
706 }
707
708 void ReceiveStatisticsProxy::MovingMaxCounter::Reset() {
709 samples_.clear();
710 }
711
712
668 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, 713 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms,
669 int64_t max_rtt_ms) { 714 int64_t max_rtt_ms) {
670 rtc::CritScope lock(&crit_); 715 rtc::CritScope lock(&crit_);
671 avg_rtt_ms_ = avg_rtt_ms; 716 avg_rtt_ms_ = avg_rtt_ms;
672 } 717 }
673 718
674 } // namespace webrtc 719 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698