sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "video/receive_statistics_proxy.h" |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 12 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 13 | #include <algorithm> |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 14 | #include <cmath> |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 15 | #include <sstream> |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 16 | #include <utility> |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "modules/pacing/alr_detector.h" |
| 19 | #include "modules/video_coding/include/video_codec_interface.h" |
| 20 | #include "rtc_base/checks.h" |
| 21 | #include "rtc_base/logging.h" |
| 22 | #include "system_wrappers/include/clock.h" |
| 23 | #include "system_wrappers/include/metrics.h" |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 26 | namespace { |
| 27 | // Periodic time interval for processing samples for |freq_offset_counter_|. |
| 28 | const int64_t kFreqOffsetProcessIntervalMs = 40000; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 29 | |
| 30 | // Configuration for bad call detection. |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 31 | const int kBadCallMinRequiredSamples = 10; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 32 | const int kMinSampleLengthMs = 990; |
| 33 | const int kNumMeasurements = 10; |
| 34 | const int kNumMeasurementsVariance = kNumMeasurements * 1.5; |
| 35 | const float kBadFraction = 0.8f; |
| 36 | // For fps: |
| 37 | // Low means low enough to be bad, high means high enough to be good |
| 38 | const int kLowFpsThreshold = 12; |
| 39 | const int kHighFpsThreshold = 14; |
| 40 | // For qp and fps variance: |
| 41 | // Low means low enough to be good, high means high enough to be bad |
| 42 | const int kLowQpThresholdVp8 = 60; |
| 43 | const int kHighQpThresholdVp8 = 70; |
| 44 | const int kLowVarianceThreshold = 1; |
| 45 | const int kHighVarianceThreshold = 2; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 46 | |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 47 | // Some metrics are reported as a maximum over this period. |
Ilya Nikolaevskiy | b06b358 | 2017-10-16 17:59:12 +0200 | [diff] [blame] | 48 | // This should be synchronized with a typical getStats polling interval in |
| 49 | // the clients. |
| 50 | const int kMovingMaxWindowMs = 1000; |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 51 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 52 | // How large window we use to calculate the framerate/bitrate. |
| 53 | const int kRateStatisticsWindowSizeMs = 1000; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 54 | |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 55 | // Some sane ballpark estimate for maximum common value of inter-frame delay. |
| 56 | // Values below that will be stored explicitly in the array, |
| 57 | // values above - in the map. |
| 58 | const int kMaxCommonInterframeDelayMs = 500; |
| 59 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 60 | std::string UmaPrefixForContentType(VideoContentType content_type) { |
| 61 | std::stringstream ss; |
| 62 | ss << "WebRTC.Video"; |
| 63 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 64 | ss << ".Screenshare"; |
| 65 | } |
| 66 | return ss.str(); |
| 67 | } |
| 68 | |
| 69 | std::string UmaSuffixForContentType(VideoContentType content_type) { |
| 70 | std::stringstream ss; |
| 71 | int simulcast_id = videocontenttypehelpers::GetSimulcastId(content_type); |
| 72 | if (simulcast_id > 0) { |
| 73 | ss << ".S" << simulcast_id - 1; |
| 74 | } |
| 75 | int experiment_id = videocontenttypehelpers::GetExperimentId(content_type); |
| 76 | if (experiment_id > 0) { |
| 77 | ss << ".ExperimentGroup" << experiment_id - 1; |
| 78 | } |
| 79 | return ss.str(); |
| 80 | } |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 81 | } // namespace |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 82 | |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 83 | ReceiveStatisticsProxy::ReceiveStatisticsProxy( |
Tommi | 733b547 | 2016-06-10 17:58:01 +0200 | [diff] [blame] | 84 | const VideoReceiveStream::Config* config, |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 85 | Clock* clock) |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 86 | : clock_(clock), |
Tommi | 733b547 | 2016-06-10 17:58:01 +0200 | [diff] [blame] | 87 | config_(*config), |
asapersson | 4374a09 | 2016-07-27 00:39:09 -0700 | [diff] [blame] | 88 | start_ms_(clock->TimeInMilliseconds()), |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 89 | last_sample_time_(clock->TimeInMilliseconds()), |
| 90 | fps_threshold_(kLowFpsThreshold, |
| 91 | kHighFpsThreshold, |
| 92 | kBadFraction, |
| 93 | kNumMeasurements), |
| 94 | qp_threshold_(kLowQpThresholdVp8, |
| 95 | kHighQpThresholdVp8, |
| 96 | kBadFraction, |
| 97 | kNumMeasurements), |
| 98 | variance_threshold_(kLowVarianceThreshold, |
| 99 | kHighVarianceThreshold, |
| 100 | kBadFraction, |
| 101 | kNumMeasurementsVariance), |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 102 | num_bad_states_(0), |
| 103 | num_certain_states_(0), |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 104 | // 1000ms window, scale 1000 for ms to s. |
| 105 | decode_fps_estimator_(1000, 1000), |
Tim Psiaki | 6304626 | 2015-09-14 10:38:08 -0700 | [diff] [blame] | 106 | renders_fps_estimator_(1000, 1000), |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 107 | render_fps_tracker_(100, 10u), |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 108 | render_pixel_tracker_(100, 10u), |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 109 | total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 110 | interframe_delay_max_moving_(kMovingMaxWindowMs), |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 111 | freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 112 | first_report_block_time_ms_(-1), |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 113 | avg_rtt_ms_(0), |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 114 | last_content_type_(VideoContentType::UNSPECIFIED), |
| 115 | timing_frame_info_counter_(kMovingMaxWindowMs) { |
Tommi | 733b547 | 2016-06-10 17:58:01 +0200 | [diff] [blame] | 116 | stats_.ssrc = config_.rtp.remote_ssrc; |
brandtr | 1474212 | 2017-01-27 04:53:07 -0800 | [diff] [blame] | 117 | // TODO(brandtr): Replace |rtx_stats_| with a single instance of |
| 118 | // StreamDataCounters. |
| 119 | if (config_.rtp.rtx_ssrc) { |
| 120 | rtx_stats_[config_.rtp.rtx_ssrc] = StreamDataCounters(); |
| 121 | } |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Åsa Persson | 3c391cb | 2015-04-27 10:09:49 +0200 | [diff] [blame] | 124 | ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
| 125 | UpdateHistograms(); |
| 126 | } |
| 127 | |
asapersson | d89920b | 2015-07-22 06:52:00 -0700 | [diff] [blame] | 128 | void ReceiveStatisticsProxy::UpdateHistograms() { |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 129 | int stream_duration_sec = (clock_->TimeInMilliseconds() - start_ms_) / 1000; |
| 130 | if (stats_.frame_counts.key_frames > 0 || |
| 131 | stats_.frame_counts.delta_frames > 0) { |
| 132 | RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.ReceiveStreamLifetimeInSeconds", |
| 133 | stream_duration_sec); |
| 134 | LOG(LS_INFO) << "WebRTC.Video.ReceiveStreamLifetimeInSeconds " |
| 135 | << stream_duration_sec; |
| 136 | } |
asapersson | 4374a09 | 2016-07-27 00:39:09 -0700 | [diff] [blame] | 137 | |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 138 | if (first_report_block_time_ms_ != -1 && |
| 139 | ((clock_->TimeInMilliseconds() - first_report_block_time_ms_) / 1000) >= |
| 140 | metrics::kMinRunTimeInSeconds) { |
| 141 | int fraction_lost = report_block_stats_.FractionLostInPercent(); |
| 142 | if (fraction_lost != -1) { |
| 143 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.ReceivedPacketsLostInPercent", |
| 144 | fraction_lost); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 145 | LOG(LS_INFO) << "WebRTC.Video.ReceivedPacketsLostInPercent " |
| 146 | << fraction_lost; |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 147 | } |
Åsa Persson | 3c391cb | 2015-04-27 10:09:49 +0200 | [diff] [blame] | 148 | } |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 149 | |
asapersson | 6718e97 | 2015-07-24 00:20:58 -0700 | [diff] [blame] | 150 | const int kMinRequiredSamples = 200; |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 151 | int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount()); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 152 | if (samples >= kMinRequiredSamples) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 153 | RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond", |
| 154 | round(render_fps_tracker_.ComputeTotalRate())); |
| 155 | RTC_HISTOGRAM_COUNTS_100000( |
asapersson | 28ba927 | 2016-01-25 05:58:23 -0800 | [diff] [blame] | 156 | "WebRTC.Video.RenderSqrtPixelsPerSecond", |
Tim Psiaki | ad13d2f | 2015-11-10 16:34:50 -0800 | [diff] [blame] | 157 | round(render_pixel_tracker_.ComputeTotalRate())); |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 158 | } |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 159 | |
asapersson | f8cdd18 | 2016-03-15 01:00:47 -0700 | [diff] [blame] | 160 | int sync_offset_ms = sync_offset_counter_.Avg(kMinRequiredSamples); |
pbos | 35fdb2a | 2016-05-03 03:32:10 -0700 | [diff] [blame] | 161 | if (sync_offset_ms != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 162 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.AVSyncOffsetInMs", sync_offset_ms); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 163 | LOG(LS_INFO) << "WebRTC.Video.AVSyncOffsetInMs " << sync_offset_ms; |
pbos | 35fdb2a | 2016-05-03 03:32:10 -0700 | [diff] [blame] | 164 | } |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 165 | AggregatedStats freq_offset_stats = freq_offset_counter_.GetStats(); |
| 166 | if (freq_offset_stats.num_samples > 0) { |
| 167 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtpToNtpFreqOffsetInKhz", |
| 168 | freq_offset_stats.average); |
asapersson | 43cb716 | 2016-11-15 08:20:48 -0800 | [diff] [blame] | 169 | LOG(LS_INFO) << "WebRTC.Video.RtpToNtpFreqOffsetInKhz, " |
| 170 | << freq_offset_stats.ToString(); |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 171 | } |
asapersson | f8cdd18 | 2016-03-15 01:00:47 -0700 | [diff] [blame] | 172 | |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 173 | int num_total_frames = |
| 174 | stats_.frame_counts.key_frames + stats_.frame_counts.delta_frames; |
| 175 | if (num_total_frames >= kMinRequiredSamples) { |
| 176 | int num_key_frames = stats_.frame_counts.key_frames; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 177 | int key_frames_permille = |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 178 | (num_key_frames * 1000 + num_total_frames / 2) / num_total_frames; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 179 | RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", |
| 180 | key_frames_permille); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 181 | LOG(LS_INFO) << "WebRTC.Video.KeyFramesReceivedInPermille " |
| 182 | << key_frames_permille; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 183 | } |
| 184 | |
asapersson | 86b0160 | 2015-10-20 23:55:26 -0700 | [diff] [blame] | 185 | int qp = qp_counters_.vp8.Avg(kMinRequiredSamples); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 186 | if (qp != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 187 | RTC_HISTOGRAM_COUNTS_200("WebRTC.Video.Decoded.Vp8.Qp", qp); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 188 | LOG(LS_INFO) << "WebRTC.Video.Decoded.Vp8.Qp " << qp; |
| 189 | } |
asapersson | a563c21 | 2017-03-02 08:25:46 -0800 | [diff] [blame] | 190 | int decode_ms = decode_time_counter_.Avg(kMinRequiredSamples); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 191 | if (decode_ms != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 192 | RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.DecodeTimeInMs", decode_ms); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 193 | LOG(LS_INFO) << "WebRTC.Video.DecodeTimeInMs " << decode_ms; |
| 194 | } |
asapersson | a563c21 | 2017-03-02 08:25:46 -0800 | [diff] [blame] | 195 | int jb_delay_ms = jitter_buffer_delay_counter_.Avg(kMinRequiredSamples); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 196 | if (jb_delay_ms != -1) { |
| 197 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", |
| 198 | jb_delay_ms); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 199 | LOG(LS_INFO) << "WebRTC.Video.JitterBufferDelayInMs " << jb_delay_ms; |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 200 | } |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 201 | |
asapersson | a563c21 | 2017-03-02 08:25:46 -0800 | [diff] [blame] | 202 | int target_delay_ms = target_delay_counter_.Avg(kMinRequiredSamples); |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 203 | if (target_delay_ms != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 204 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", target_delay_ms); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 205 | LOG(LS_INFO) << "WebRTC.Video.TargetDelayInMs " << target_delay_ms; |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 206 | } |
asapersson | a563c21 | 2017-03-02 08:25:46 -0800 | [diff] [blame] | 207 | int current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples); |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 208 | if (current_delay_ms != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 209 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", |
| 210 | current_delay_ms); |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 211 | LOG(LS_INFO) << "WebRTC.Video.CurrentDelayInMs " << current_delay_ms; |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 212 | } |
asapersson | a563c21 | 2017-03-02 08:25:46 -0800 | [diff] [blame] | 213 | int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
asapersson | 13c433c | 2015-10-06 04:08:15 -0700 | [diff] [blame] | 214 | if (delay_ms != -1) |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 215 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 216 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 217 | // Aggregate content_specific_stats_ by removing experiment or simulcast |
| 218 | // information; |
| 219 | std::map<VideoContentType, ContentSpecificStats> aggregated_stats; |
| 220 | for (auto it : content_specific_stats_) { |
| 221 | // Calculate simulcast specific metrics (".S0" ... ".S2" suffixes). |
| 222 | VideoContentType content_type = it.first; |
| 223 | if (videocontenttypehelpers::GetSimulcastId(content_type) > 0) { |
| 224 | // Aggregate on experiment id. |
| 225 | videocontenttypehelpers::SetExperimentId(&content_type, 0); |
| 226 | aggregated_stats[content_type].Add(it.second); |
| 227 | } |
| 228 | // Calculate experiment specific metrics (".ExperimentGroup[0-7]" suffixes). |
| 229 | content_type = it.first; |
| 230 | if (videocontenttypehelpers::GetExperimentId(content_type) > 0) { |
| 231 | // Aggregate on simulcast id. |
| 232 | videocontenttypehelpers::SetSimulcastId(&content_type, 0); |
| 233 | aggregated_stats[content_type].Add(it.second); |
| 234 | } |
| 235 | // Calculate aggregated metrics (no suffixes. Aggregated on everything). |
| 236 | content_type = it.first; |
| 237 | videocontenttypehelpers::SetSimulcastId(&content_type, 0); |
| 238 | videocontenttypehelpers::SetExperimentId(&content_type, 0); |
| 239 | aggregated_stats[content_type].Add(it.second); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 240 | } |
| 241 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 242 | for (auto it : aggregated_stats) { |
| 243 | // For the metric Foo we report the following slices: |
| 244 | // WebRTC.Video.Foo, |
| 245 | // WebRTC.Video.Screenshare.Foo, |
| 246 | // WebRTC.Video.Foo.S[0-3], |
| 247 | // WebRTC.Video.Foo.ExperimentGroup[0-7], |
| 248 | // WebRTC.Video.Screenshare.Foo.S[0-3], |
| 249 | // WebRTC.Video.Screenshare.Foo.ExperimentGroup[0-7]. |
| 250 | auto content_type = it.first; |
| 251 | auto stats = it.second; |
| 252 | std::string uma_prefix = UmaPrefixForContentType(content_type); |
| 253 | std::string uma_suffix = UmaSuffixForContentType(content_type); |
| 254 | // Metrics can be sliced on either simulcast id or experiment id but not |
| 255 | // both. |
| 256 | RTC_DCHECK(videocontenttypehelpers::GetExperimentId(content_type) == 0 || |
| 257 | videocontenttypehelpers::GetSimulcastId(content_type) == 0); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 258 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 259 | int e2e_delay_ms = stats.e2e_delay_counter.Avg(kMinRequiredSamples); |
| 260 | if (e2e_delay_ms != -1) { |
| 261 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 262 | uma_prefix + ".EndToEndDelayInMs" + uma_suffix, e2e_delay_ms); |
| 263 | LOG(LS_INFO) << uma_prefix << ".EndToEndDelayInMs" << uma_suffix << " " |
| 264 | << e2e_delay_ms; |
| 265 | } |
| 266 | int e2e_delay_max_ms = stats.e2e_delay_counter.Max(); |
| 267 | if (e2e_delay_max_ms != -1 && e2e_delay_ms != -1) { |
| 268 | RTC_HISTOGRAM_COUNTS_SPARSE_100000( |
| 269 | uma_prefix + ".EndToEndDelayMaxInMs" + uma_suffix, e2e_delay_max_ms); |
| 270 | LOG(LS_INFO) << uma_prefix << ".EndToEndDelayMaxInMs" << uma_suffix << " " |
| 271 | << e2e_delay_max_ms; |
| 272 | } |
| 273 | int interframe_delay_ms = |
| 274 | stats.interframe_delay_counter.Avg(kMinRequiredSamples); |
| 275 | if (interframe_delay_ms != -1) { |
| 276 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 277 | uma_prefix + ".InterframeDelayInMs" + uma_suffix, |
| 278 | interframe_delay_ms); |
| 279 | LOG(LS_INFO) << uma_prefix << ".InterframeDelayInMs" << uma_suffix << " " |
| 280 | << interframe_delay_ms; |
| 281 | } |
| 282 | int interframe_delay_max_ms = stats.interframe_delay_counter.Max(); |
| 283 | if (interframe_delay_max_ms != -1 && interframe_delay_ms != -1) { |
| 284 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 285 | uma_prefix + ".InterframeDelayMaxInMs" + uma_suffix, |
| 286 | interframe_delay_max_ms); |
| 287 | LOG(LS_INFO) << uma_prefix << ".InterframeDelayMaxInMs" << uma_suffix |
| 288 | << " " << interframe_delay_max_ms; |
| 289 | } |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 290 | |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 291 | rtc::Optional<uint32_t> interframe_delay_95p_ms = |
| 292 | stats.interframe_delay_percentiles.GetPercentile(0.95f); |
| 293 | if (interframe_delay_95p_ms && interframe_delay_ms != -1) { |
| 294 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 295 | uma_prefix + ".InterframeDelay95PercentileInMs" + uma_suffix, |
| 296 | *interframe_delay_95p_ms); |
| 297 | LOG(LS_INFO) << uma_prefix << ".InterframeDelay95PercentileInMs" |
| 298 | << uma_suffix << " " << *interframe_delay_95p_ms; |
| 299 | } |
| 300 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 301 | int width = stats.received_width.Avg(kMinRequiredSamples); |
| 302 | if (width != -1) { |
| 303 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 304 | uma_prefix + ".ReceivedWidthInPixels" + uma_suffix, width); |
| 305 | LOG(LS_INFO) << uma_prefix << ".ReceivedWidthInPixels" << uma_suffix |
| 306 | << " " << width; |
| 307 | } |
asapersson | 1490f7a | 2016-09-23 02:09:46 -0700 | [diff] [blame] | 308 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 309 | int height = stats.received_height.Avg(kMinRequiredSamples); |
| 310 | if (height != -1) { |
| 311 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 312 | uma_prefix + ".ReceivedHeightInPixels" + uma_suffix, height); |
| 313 | LOG(LS_INFO) << uma_prefix << ".ReceivedHeightInPixels" << uma_suffix |
| 314 | << " " << height; |
| 315 | } |
ilnik | 4257ab2 | 2017-07-03 01:15:58 -0700 | [diff] [blame] | 316 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 317 | if (content_type != VideoContentType::UNSPECIFIED) { |
| 318 | // Don't report these 3 metrics unsliced, as more precise variants |
| 319 | // are reported separately in this method. |
| 320 | float flow_duration_sec = stats.flow_duration_ms / 1000.0; |
| 321 | if (flow_duration_sec >= metrics::kMinRunTimeInSeconds) { |
| 322 | int media_bitrate_kbps = static_cast<int>(stats.total_media_bytes * 8 / |
| 323 | flow_duration_sec / 1000); |
| 324 | RTC_HISTOGRAM_COUNTS_SPARSE_10000( |
| 325 | uma_prefix + ".MediaBitrateReceivedInKbps" + uma_suffix, |
| 326 | media_bitrate_kbps); |
| 327 | LOG(LS_INFO) << uma_prefix << ".MediaBitrateReceivedInKbps" |
| 328 | << uma_suffix << " " << media_bitrate_kbps; |
| 329 | } |
| 330 | |
| 331 | int num_total_frames = |
| 332 | stats.frame_counts.key_frames + stats.frame_counts.delta_frames; |
| 333 | if (num_total_frames >= kMinRequiredSamples) { |
| 334 | int num_key_frames = stats.frame_counts.key_frames; |
| 335 | int key_frames_permille = |
| 336 | (num_key_frames * 1000 + num_total_frames / 2) / num_total_frames; |
| 337 | RTC_HISTOGRAM_COUNTS_SPARSE_1000( |
| 338 | uma_prefix + ".KeyFramesReceivedInPermille" + uma_suffix, |
| 339 | key_frames_permille); |
| 340 | LOG(LS_INFO) << uma_prefix << ".KeyFramesReceivedInPermille" |
| 341 | << uma_suffix << " " << key_frames_permille; |
| 342 | } |
| 343 | |
| 344 | int qp = stats.qp_counter.Avg(kMinRequiredSamples); |
| 345 | if (qp != -1) { |
| 346 | RTC_HISTOGRAM_COUNTS_SPARSE_200( |
| 347 | uma_prefix + ".Decoded.Vp8.Qp" + uma_suffix, qp); |
| 348 | LOG(LS_INFO) << uma_prefix << ".Decoded.Vp8.Qp" << uma_suffix << " " |
| 349 | << qp; |
| 350 | } |
| 351 | } |
ilnik | 4257ab2 | 2017-07-03 01:15:58 -0700 | [diff] [blame] | 352 | } |
| 353 | |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 354 | StreamDataCounters rtp = stats_.rtp_stats; |
| 355 | StreamDataCounters rtx; |
| 356 | for (auto it : rtx_stats_) |
| 357 | rtx.Add(it.second); |
| 358 | StreamDataCounters rtp_rtx = rtp; |
| 359 | rtp_rtx.Add(rtx); |
| 360 | int64_t elapsed_sec = |
| 361 | rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 362 | if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 363 | RTC_HISTOGRAM_COUNTS_10000( |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 364 | "WebRTC.Video.BitrateReceivedInKbps", |
| 365 | static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
| 366 | 1000)); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 367 | int media_bitrate_kbs = |
| 368 | static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000); |
| 369 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.MediaBitrateReceivedInKbps", |
| 370 | media_bitrate_kbs); |
| 371 | LOG(LS_INFO) << "WebRTC.Video.MediaBitrateReceivedInKbps " |
| 372 | << media_bitrate_kbs; |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 373 | RTC_HISTOGRAM_COUNTS_10000( |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 374 | "WebRTC.Video.PaddingBitrateReceivedInKbps", |
| 375 | static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / |
| 376 | 1000)); |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 377 | RTC_HISTOGRAM_COUNTS_10000( |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 378 | "WebRTC.Video.RetransmittedBitrateReceivedInKbps", |
| 379 | static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / elapsed_sec / |
| 380 | 1000)); |
| 381 | if (!rtx_stats_.empty()) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 382 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateReceivedInKbps", |
| 383 | static_cast<int>(rtx.transmitted.TotalBytes() * |
| 384 | 8 / elapsed_sec / 1000)); |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 385 | } |
nisse | 3b3622f | 2017-09-26 02:49:21 -0700 | [diff] [blame] | 386 | if (config_.rtp.ulpfec_payload_type != -1) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 387 | RTC_HISTOGRAM_COUNTS_10000( |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 388 | "WebRTC.Video.FecBitrateReceivedInKbps", |
| 389 | static_cast<int>(rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000)); |
| 390 | } |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 391 | const RtcpPacketTypeCounter& counters = stats_.rtcp_packet_type_counts; |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 392 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsSentPerMinute", |
| 393 | counters.nack_packets * 60 / elapsed_sec); |
| 394 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsSentPerMinute", |
| 395 | counters.fir_packets * 60 / elapsed_sec); |
| 396 | RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsSentPerMinute", |
| 397 | counters.pli_packets * 60 / elapsed_sec); |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 398 | if (counters.nack_requests > 0) { |
asapersson | 1d02d3e | 2016-09-09 22:40:25 -0700 | [diff] [blame] | 399 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.UniqueNackRequestsSentInPercent", |
| 400 | counters.UniqueNackRequestsInPercent()); |
sprang | 07fb9be | 2016-02-24 07:55:00 -0800 | [diff] [blame] | 401 | } |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 402 | } |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 403 | |
| 404 | if (num_certain_states_ >= kBadCallMinRequiredSamples) { |
| 405 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.Any", |
| 406 | 100 * num_bad_states_ / num_certain_states_); |
| 407 | } |
| 408 | rtc::Optional<double> fps_fraction = |
| 409 | fps_threshold_.FractionHigh(kBadCallMinRequiredSamples); |
| 410 | if (fps_fraction) { |
| 411 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.FrameRate", |
| 412 | static_cast<int>(100 * (1 - *fps_fraction))); |
| 413 | } |
| 414 | rtc::Optional<double> variance_fraction = |
| 415 | variance_threshold_.FractionHigh(kBadCallMinRequiredSamples); |
| 416 | if (variance_fraction) { |
| 417 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.FrameRateVariance", |
| 418 | static_cast<int>(100 * *variance_fraction)); |
| 419 | } |
| 420 | rtc::Optional<double> qp_fraction = |
| 421 | qp_threshold_.FractionHigh(kBadCallMinRequiredSamples); |
| 422 | if (qp_fraction) { |
| 423 | RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.BadCall.Qp", |
| 424 | static_cast<int>(100 * *qp_fraction)); |
| 425 | } |
Åsa Persson | 3c391cb | 2015-04-27 10:09:49 +0200 | [diff] [blame] | 426 | } |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 427 | |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 428 | void ReceiveStatisticsProxy::QualitySample() { |
| 429 | int64_t now = clock_->TimeInMilliseconds(); |
| 430 | if (last_sample_time_ + kMinSampleLengthMs > now) |
| 431 | return; |
| 432 | |
| 433 | double fps = |
| 434 | render_fps_tracker_.ComputeRateForInterval(now - last_sample_time_); |
| 435 | int qp = qp_sample_.Avg(1); |
| 436 | |
| 437 | bool prev_fps_bad = !fps_threshold_.IsHigh().value_or(true); |
| 438 | bool prev_qp_bad = qp_threshold_.IsHigh().value_or(false); |
| 439 | bool prev_variance_bad = variance_threshold_.IsHigh().value_or(false); |
| 440 | bool prev_any_bad = prev_fps_bad || prev_qp_bad || prev_variance_bad; |
| 441 | |
| 442 | fps_threshold_.AddMeasurement(static_cast<int>(fps)); |
| 443 | if (qp != -1) |
| 444 | qp_threshold_.AddMeasurement(qp); |
| 445 | rtc::Optional<double> fps_variance_opt = fps_threshold_.CalculateVariance(); |
| 446 | double fps_variance = fps_variance_opt.value_or(0); |
| 447 | if (fps_variance_opt) { |
| 448 | variance_threshold_.AddMeasurement(static_cast<int>(fps_variance)); |
| 449 | } |
| 450 | |
| 451 | bool fps_bad = !fps_threshold_.IsHigh().value_or(true); |
| 452 | bool qp_bad = qp_threshold_.IsHigh().value_or(false); |
| 453 | bool variance_bad = variance_threshold_.IsHigh().value_or(false); |
| 454 | bool any_bad = fps_bad || qp_bad || variance_bad; |
| 455 | |
| 456 | if (!prev_any_bad && any_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 457 | LOG(LS_INFO) << "Bad call (any) start: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 458 | } else if (prev_any_bad && !any_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 459 | LOG(LS_INFO) << "Bad call (any) end: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | if (!prev_fps_bad && fps_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 463 | LOG(LS_INFO) << "Bad call (fps) start: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 464 | } else if (prev_fps_bad && !fps_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 465 | LOG(LS_INFO) << "Bad call (fps) end: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | if (!prev_qp_bad && qp_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 469 | LOG(LS_INFO) << "Bad call (qp) start: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 470 | } else if (prev_qp_bad && !qp_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 471 | LOG(LS_INFO) << "Bad call (qp) end: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | if (!prev_variance_bad && variance_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 475 | LOG(LS_INFO) << "Bad call (variance) start: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 476 | } else if (prev_variance_bad && !variance_bad) { |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 477 | LOG(LS_INFO) << "Bad call (variance) end: " << now; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 478 | } |
| 479 | |
palmkvist | c7e7e07 | 2017-01-09 07:23:33 -0800 | [diff] [blame] | 480 | LOG(LS_VERBOSE) << "SAMPLE: sample_length: " << (now - last_sample_time_) |
| 481 | << " fps: " << fps << " fps_bad: " << fps_bad << " qp: " << qp |
| 482 | << " qp_bad: " << qp_bad << " variance_bad: " << variance_bad |
| 483 | << " fps_variance: " << fps_variance; |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 484 | |
| 485 | last_sample_time_ = now; |
| 486 | qp_sample_.Reset(); |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 487 | |
| 488 | if (fps_threshold_.IsHigh() || variance_threshold_.IsHigh() || |
| 489 | qp_threshold_.IsHigh()) { |
| 490 | if (any_bad) |
| 491 | ++num_bad_states_; |
| 492 | ++num_certain_states_; |
| 493 | } |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 494 | } |
| 495 | |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 496 | void ReceiveStatisticsProxy::UpdateFramerate(int64_t now_ms) const { |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 497 | int64_t old_frames_ms = now_ms - kRateStatisticsWindowSizeMs; |
| 498 | while (!frame_window_.empty() && |
| 499 | frame_window_.begin()->first < old_frames_ms) { |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 500 | frame_window_.erase(frame_window_.begin()); |
| 501 | } |
| 502 | |
| 503 | size_t framerate = |
| 504 | (frame_window_.size() * 1000 + 500) / kRateStatisticsWindowSizeMs; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 505 | stats_.network_frame_rate = static_cast<int>(framerate); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 506 | } |
| 507 | |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 508 | VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 509 | rtc::CritScope lock(&crit_); |
sprang | 948b275 | 2017-05-04 02:47:13 -0700 | [diff] [blame] | 510 | // Get current frame rates here, as only updating them on new frames prevents |
| 511 | // us from ever correctly displaying frame rate of 0. |
| 512 | int64_t now_ms = clock_->TimeInMilliseconds(); |
| 513 | UpdateFramerate(now_ms); |
| 514 | stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0); |
| 515 | stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0); |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 516 | stats_.total_bitrate_bps = |
| 517 | static_cast<int>(total_byte_tracker_.ComputeRate() * 8); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 518 | stats_.interframe_delay_max_ms = |
| 519 | interframe_delay_max_moving_.Max(now_ms).value_or(-1); |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 520 | stats_.timing_frame_info = timing_frame_info_counter_.Max(now_ms); |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 521 | stats_.content_type = last_content_type_; |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 522 | return stats_; |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 523 | } |
| 524 | |
pbos | f42376c | 2015-08-28 07:35:32 -0700 | [diff] [blame] | 525 | void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) { |
| 526 | rtc::CritScope lock(&crit_); |
| 527 | stats_.current_payload_type = payload_type; |
| 528 | } |
| 529 | |
Peter Boström | b7d9a97 | 2015-12-18 16:01:11 +0100 | [diff] [blame] | 530 | void ReceiveStatisticsProxy::OnDecoderImplementationName( |
| 531 | const char* implementation_name) { |
| 532 | rtc::CritScope lock(&crit_); |
| 533 | stats_.decoder_implementation_name = implementation_name; |
| 534 | } |
pbos | f42376c | 2015-08-28 07:35:32 -0700 | [diff] [blame] | 535 | void ReceiveStatisticsProxy::OnIncomingRate(unsigned int framerate, |
| 536 | unsigned int bitrate_bps) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 537 | rtc::CritScope lock(&crit_); |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 538 | if (stats_.rtp_stats.first_packet_time_ms != -1) |
| 539 | QualitySample(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 540 | } |
| 541 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 542 | void ReceiveStatisticsProxy::OnFrameBufferTimingsUpdated( |
| 543 | int decode_ms, |
| 544 | int max_decode_ms, |
| 545 | int current_delay_ms, |
| 546 | int target_delay_ms, |
| 547 | int jitter_buffer_ms, |
| 548 | int min_playout_delay_ms, |
| 549 | int render_delay_ms) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 550 | rtc::CritScope lock(&crit_); |
pbos@webrtc.org | 09c77b9 | 2015-02-25 10:42:16 +0000 | [diff] [blame] | 551 | stats_.decode_ms = decode_ms; |
| 552 | stats_.max_decode_ms = max_decode_ms; |
| 553 | stats_.current_delay_ms = current_delay_ms; |
| 554 | stats_.target_delay_ms = target_delay_ms; |
| 555 | stats_.jitter_buffer_ms = jitter_buffer_ms; |
| 556 | stats_.min_playout_delay_ms = min_playout_delay_ms; |
| 557 | stats_.render_delay_ms = render_delay_ms; |
asapersson | 6718e97 | 2015-07-24 00:20:58 -0700 | [diff] [blame] | 558 | decode_time_counter_.Add(decode_ms); |
asapersson | 8688a4e | 2016-04-27 23:42:35 -0700 | [diff] [blame] | 559 | jitter_buffer_delay_counter_.Add(jitter_buffer_ms); |
| 560 | target_delay_counter_.Add(target_delay_ms); |
| 561 | current_delay_counter_.Add(current_delay_ms); |
asapersson | a186288 | 2016-04-18 00:41:05 -0700 | [diff] [blame] | 562 | // Network delay (rtt/2) + target_delay_ms (jitter delay + decode time + |
| 563 | // render delay). |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 564 | delay_counter_.Add(target_delay_ms + avg_rtt_ms_ / 2); |
pbos@webrtc.org | 98c04b3 | 2014-12-18 13:12:52 +0000 | [diff] [blame] | 565 | } |
| 566 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 567 | void ReceiveStatisticsProxy::OnTimingFrameInfoUpdated( |
| 568 | const TimingFrameInfo& info) { |
| 569 | rtc::CritScope lock(&crit_); |
Ilya Nikolaevskiy | 3f670e0 | 2017-10-10 11:18:49 +0200 | [diff] [blame] | 570 | int64_t now_ms = clock_->TimeInMilliseconds(); |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 571 | timing_frame_info_counter_.Add(info, now_ms); |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 572 | } |
| 573 | |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 574 | void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated( |
| 575 | uint32_t ssrc, |
| 576 | const RtcpPacketTypeCounter& packet_counter) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 577 | rtc::CritScope lock(&crit_); |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 578 | if (stats_.ssrc != ssrc) |
| 579 | return; |
| 580 | stats_.rtcp_packet_type_counts = packet_counter; |
| 581 | } |
| 582 | |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 583 | void ReceiveStatisticsProxy::StatisticsUpdated( |
| 584 | const webrtc::RtcpStatistics& statistics, |
| 585 | uint32_t ssrc) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 586 | rtc::CritScope lock(&crit_); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 587 | // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 588 | // receive stats from one of them. |
| 589 | if (stats_.ssrc != ssrc) |
| 590 | return; |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 591 | stats_.rtcp_stats = statistics; |
Åsa Persson | 3c391cb | 2015-04-27 10:09:49 +0200 | [diff] [blame] | 592 | report_block_stats_.Store(statistics, ssrc, 0); |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 593 | |
| 594 | if (first_report_block_time_ms_ == -1) |
| 595 | first_report_block_time_ms_ = clock_->TimeInMilliseconds(); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 596 | } |
| 597 | |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 598 | void ReceiveStatisticsProxy::CNameChanged(const char* cname, uint32_t ssrc) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 599 | rtc::CritScope lock(&crit_); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 600 | // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 601 | // receive stats from one of them. |
| 602 | if (stats_.ssrc != ssrc) |
| 603 | return; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 604 | stats_.c_name = cname; |
| 605 | } |
| 606 | |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 607 | void ReceiveStatisticsProxy::DataCountersUpdated( |
| 608 | const webrtc::StreamDataCounters& counters, |
| 609 | uint32_t ssrc) { |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 610 | size_t last_total_bytes = 0; |
| 611 | size_t total_bytes = 0; |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 612 | rtc::CritScope lock(&crit_); |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 613 | if (ssrc == stats_.ssrc) { |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 614 | last_total_bytes = stats_.rtp_stats.transmitted.TotalBytes(); |
| 615 | total_bytes = counters.transmitted.TotalBytes(); |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 616 | stats_.rtp_stats = counters; |
| 617 | } else { |
| 618 | auto it = rtx_stats_.find(ssrc); |
| 619 | if (it != rtx_stats_.end()) { |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 620 | last_total_bytes = it->second.transmitted.TotalBytes(); |
| 621 | total_bytes = counters.transmitted.TotalBytes(); |
sprang | 0ab8e81 | 2016-02-24 01:35:40 -0800 | [diff] [blame] | 622 | it->second = counters; |
| 623 | } else { |
| 624 | RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc; |
| 625 | } |
| 626 | } |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 627 | if (total_bytes > last_total_bytes) |
| 628 | total_byte_tracker_.AddSamples(total_bytes - last_total_bytes); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 629 | } |
| 630 | |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 631 | void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional<uint8_t> qp, |
| 632 | VideoContentType content_type) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 633 | rtc::CritScope lock(&crit_); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 634 | |
Ilya Nikolaevskiy | 3f670e0 | 2017-10-10 11:18:49 +0200 | [diff] [blame] | 635 | uint64_t now = clock_->TimeInMilliseconds(); |
| 636 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 637 | ContentSpecificStats* content_specific_stats = |
| 638 | &content_specific_stats_[content_type]; |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 639 | ++stats_.frames_decoded; |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 640 | if (qp) { |
| 641 | if (!stats_.qp_sum) { |
| 642 | if (stats_.frames_decoded != 1) { |
| 643 | LOG(LS_WARNING) |
| 644 | << "Frames decoded was not 1 when first qp value was received."; |
| 645 | stats_.frames_decoded = 1; |
| 646 | } |
| 647 | stats_.qp_sum = rtc::Optional<uint64_t>(0); |
| 648 | } |
| 649 | *stats_.qp_sum += *qp; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 650 | content_specific_stats->qp_counter.Add(*qp); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 651 | } else if (stats_.qp_sum) { |
| 652 | LOG(LS_WARNING) |
| 653 | << "QP sum was already set and no QP was given for a frame."; |
| 654 | stats_.qp_sum = rtc::Optional<uint64_t>(); |
| 655 | } |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 656 | last_content_type_ = content_type; |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 657 | decode_fps_estimator_.Update(1, now); |
ilnik | 4257ab2 | 2017-07-03 01:15:58 -0700 | [diff] [blame] | 658 | if (last_decoded_frame_time_ms_) { |
| 659 | int64_t interframe_delay_ms = now - *last_decoded_frame_time_ms_; |
| 660 | RTC_DCHECK_GE(interframe_delay_ms, 0); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 661 | interframe_delay_max_moving_.Add(interframe_delay_ms, now); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 662 | content_specific_stats->interframe_delay_counter.Add(interframe_delay_ms); |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 663 | content_specific_stats->interframe_delay_percentiles.Add( |
| 664 | interframe_delay_ms); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 665 | content_specific_stats->flow_duration_ms += interframe_delay_ms; |
ilnik | 4257ab2 | 2017-07-03 01:15:58 -0700 | [diff] [blame] | 666 | } |
| 667 | last_decoded_frame_time_ms_.emplace(now); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 668 | } |
| 669 | |
asapersson | 1490f7a | 2016-09-23 02:09:46 -0700 | [diff] [blame] | 670 | void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { |
| 671 | int width = frame.width(); |
| 672 | int height = frame.height(); |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 673 | RTC_DCHECK_GT(width, 0); |
| 674 | RTC_DCHECK_GT(height, 0); |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 675 | uint64_t now = clock_->TimeInMilliseconds(); |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 676 | rtc::CritScope lock(&crit_); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 677 | ContentSpecificStats* content_specific_stats = |
| 678 | &content_specific_stats_[last_content_type_]; |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 679 | renders_fps_estimator_.Update(1, now); |
hbos | 50cfe1f | 2017-01-23 07:21:55 -0800 | [diff] [blame] | 680 | ++stats_.frames_rendered; |
asapersson | 2e5cfcd | 2016-08-11 08:41:18 -0700 | [diff] [blame] | 681 | stats_.width = width; |
| 682 | stats_.height = height; |
Tim Psiaki | 6304626 | 2015-09-14 10:38:08 -0700 | [diff] [blame] | 683 | render_fps_tracker_.AddSamples(1); |
asapersson | f839dcc | 2015-10-08 00:41:59 -0700 | [diff] [blame] | 684 | render_pixel_tracker_.AddSamples(sqrt(width * height)); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 685 | content_specific_stats->received_width.Add(width); |
| 686 | content_specific_stats->received_height.Add(height); |
asapersson | 1490f7a | 2016-09-23 02:09:46 -0700 | [diff] [blame] | 687 | |
| 688 | if (frame.ntp_time_ms() > 0) { |
| 689 | int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 690 | if (delay_ms >= 0) { |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 691 | content_specific_stats->e2e_delay_counter.Add(delay_ms); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 692 | } |
asapersson | 1490f7a | 2016-09-23 02:09:46 -0700 | [diff] [blame] | 693 | } |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 694 | } |
| 695 | |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 696 | void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, |
| 697 | double estimated_freq_khz) { |
asapersson | f8cdd18 | 2016-03-15 01:00:47 -0700 | [diff] [blame] | 698 | rtc::CritScope lock(&crit_); |
| 699 | sync_offset_counter_.Add(std::abs(sync_offset_ms)); |
| 700 | stats_.sync_offset_ms = sync_offset_ms; |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 701 | |
| 702 | const double kMaxFreqKhz = 10000.0; |
| 703 | int offset_khz = kMaxFreqKhz; |
| 704 | // Should not be zero or negative. If so, report max. |
| 705 | if (estimated_freq_khz < kMaxFreqKhz && estimated_freq_khz > 0.0) |
| 706 | offset_khz = static_cast<int>(std::fabs(estimated_freq_khz - 90.0) + 0.5); |
| 707 | |
| 708 | freq_offset_counter_.Add(offset_khz); |
asapersson | f8cdd18 | 2016-03-15 01:00:47 -0700 | [diff] [blame] | 709 | } |
| 710 | |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 711 | void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
| 712 | uint32_t frameRate) { |
| 713 | } |
| 714 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 715 | void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe, |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 716 | size_t size_bytes, |
| 717 | VideoContentType content_type) { |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 718 | rtc::CritScope lock(&crit_); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 719 | if (is_keyframe) { |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 720 | ++stats_.frame_counts.key_frames; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 721 | } else { |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 722 | ++stats_.frame_counts.delta_frames; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | ContentSpecificStats* content_specific_stats = |
| 726 | &content_specific_stats_[content_type]; |
| 727 | |
| 728 | content_specific_stats->total_media_bytes += size_bytes; |
| 729 | if (is_keyframe) { |
| 730 | ++content_specific_stats->frame_counts.key_frames; |
| 731 | } else { |
| 732 | ++content_specific_stats->frame_counts.delta_frames; |
| 733 | } |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 734 | |
| 735 | int64_t now_ms = clock_->TimeInMilliseconds(); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 736 | frame_window_.insert(std::make_pair(now_ms, size_bytes)); |
asapersson | 0255acb | 2017-03-28 02:44:58 -0700 | [diff] [blame] | 737 | UpdateFramerate(now_ms); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 738 | } |
| 739 | |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 740 | void ReceiveStatisticsProxy::OnFrameCountsUpdated( |
| 741 | const FrameCounts& frame_counts) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 742 | rtc::CritScope lock(&crit_); |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 743 | stats_.frame_counts = frame_counts; |
| 744 | } |
| 745 | |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 746 | void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) { |
Peter Boström | f2f8283 | 2015-05-01 13:00:41 +0200 | [diff] [blame] | 747 | rtc::CritScope lock(&crit_); |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 748 | stats_.discarded_packets = discarded_packets; |
| 749 | } |
| 750 | |
asapersson | 86b0160 | 2015-10-20 23:55:26 -0700 | [diff] [blame] | 751 | void ReceiveStatisticsProxy::OnPreDecode( |
| 752 | const EncodedImage& encoded_image, |
| 753 | const CodecSpecificInfo* codec_specific_info) { |
Peter Boström | 74f6e9e | 2016-04-04 17:56:10 +0200 | [diff] [blame] | 754 | if (!codec_specific_info || encoded_image.qp_ == -1) { |
asapersson | 86b0160 | 2015-10-20 23:55:26 -0700 | [diff] [blame] | 755 | return; |
| 756 | } |
| 757 | if (codec_specific_info->codecType == kVideoCodecVP8) { |
| 758 | qp_counters_.vp8.Add(encoded_image.qp_); |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 759 | rtc::CritScope lock(&crit_); |
| 760 | qp_sample_.Add(encoded_image.qp_); |
asapersson | 86b0160 | 2015-10-20 23:55:26 -0700 | [diff] [blame] | 761 | } |
| 762 | } |
| 763 | |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 764 | void ReceiveStatisticsProxy::OnStreamInactive() { |
| 765 | // TODO(sprang): Figure out any other state that should be reset. |
| 766 | |
| 767 | rtc::CritScope lock(&crit_); |
| 768 | // Don't report inter-frame delay if stream was paused. |
| 769 | last_decoded_frame_time_ms_.reset(); |
| 770 | } |
| 771 | |
asapersson | d89920b | 2015-07-22 06:52:00 -0700 | [diff] [blame] | 772 | void ReceiveStatisticsProxy::SampleCounter::Add(int sample) { |
| 773 | sum += sample; |
| 774 | ++num_samples; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 775 | if (!max || sample > *max) { |
| 776 | max.emplace(sample); |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | void ReceiveStatisticsProxy::SampleCounter::Add(const SampleCounter& other) { |
| 781 | sum += other.sum; |
| 782 | num_samples += other.num_samples; |
| 783 | if (other.max && (!max || *max < *other.max)) |
| 784 | max = other.max; |
asapersson | d89920b | 2015-07-22 06:52:00 -0700 | [diff] [blame] | 785 | } |
| 786 | |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 787 | int ReceiveStatisticsProxy::SampleCounter::Avg( |
| 788 | int64_t min_required_samples) const { |
asapersson | d89920b | 2015-07-22 06:52:00 -0700 | [diff] [blame] | 789 | if (num_samples < min_required_samples || num_samples == 0) |
| 790 | return -1; |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 791 | return static_cast<int>(sum / num_samples); |
asapersson | d89920b | 2015-07-22 06:52:00 -0700 | [diff] [blame] | 792 | } |
| 793 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 794 | int ReceiveStatisticsProxy::SampleCounter::Max() const { |
| 795 | return max.value_or(-1); |
| 796 | } |
| 797 | |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 798 | void ReceiveStatisticsProxy::SampleCounter::Reset() { |
| 799 | num_samples = 0; |
| 800 | sum = 0; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 801 | max.reset(); |
palmkvist | 349092b | 2016-12-13 02:45:57 -0800 | [diff] [blame] | 802 | } |
| 803 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 804 | void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, |
| 805 | int64_t max_rtt_ms) { |
| 806 | rtc::CritScope lock(&crit_); |
| 807 | avg_rtt_ms_ = avg_rtt_ms; |
| 808 | } |
| 809 | |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 810 | ReceiveStatisticsProxy::ContentSpecificStats::ContentSpecificStats() |
| 811 | : interframe_delay_percentiles(kMaxCommonInterframeDelayMs) {} |
| 812 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 813 | void ReceiveStatisticsProxy::ContentSpecificStats::Add( |
| 814 | const ContentSpecificStats& other) { |
| 815 | e2e_delay_counter.Add(other.e2e_delay_counter); |
| 816 | interframe_delay_counter.Add(other.interframe_delay_counter); |
| 817 | flow_duration_ms += other.flow_duration_ms; |
| 818 | total_media_bytes += other.total_media_bytes; |
| 819 | received_height.Add(other.received_height); |
| 820 | received_width.Add(other.received_width); |
| 821 | qp_counter.Add(other.qp_counter); |
| 822 | frame_counts.key_frames += other.frame_counts.key_frames; |
| 823 | frame_counts.delta_frames += other.frame_counts.delta_frames; |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 824 | interframe_delay_percentiles.Add(other.interframe_delay_percentiles); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 825 | } |
sprang@webrtc.org | 0931570 | 2014-02-07 12:06:29 +0000 | [diff] [blame] | 826 | } // namespace webrtc |