OLD | NEW |
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 int target_delay_ms = target_delay_counter_.Avg(kMinRequiredDecodeSamples); | 88 int target_delay_ms = target_delay_counter_.Avg(kMinRequiredDecodeSamples); |
89 if (target_delay_ms != -1) { | 89 if (target_delay_ms != -1) { |
90 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", target_delay_ms); | 90 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.TargetDelayInMs", target_delay_ms); |
91 } | 91 } |
92 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredDecodeSamples); | 92 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredDecodeSamples); |
93 if (current_delay_ms != -1) { | 93 if (current_delay_ms != -1) { |
94 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", | 94 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", |
95 current_delay_ms); | 95 current_delay_ms); |
96 } | 96 } |
97 | |
98 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); | 97 int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples); |
99 if (delay_ms != -1) | 98 if (delay_ms != -1) |
100 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); | 99 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); |
101 | 100 |
| 101 int e2e_delay_ms = e2e_delay_counter_.Avg(kMinRequiredSamples); |
| 102 if (e2e_delay_ms != -1) |
| 103 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.EndToEndDelayInMs", e2e_delay_ms); |
| 104 |
102 StreamDataCounters rtp = stats_.rtp_stats; | 105 StreamDataCounters rtp = stats_.rtp_stats; |
103 StreamDataCounters rtx; | 106 StreamDataCounters rtx; |
104 for (auto it : rtx_stats_) | 107 for (auto it : rtx_stats_) |
105 rtx.Add(it.second); | 108 rtx.Add(it.second); |
106 StreamDataCounters rtp_rtx = rtp; | 109 StreamDataCounters rtp_rtx = rtp; |
107 rtp_rtx.Add(rtx); | 110 rtp_rtx.Add(rtx); |
108 int64_t elapsed_sec = | 111 int64_t elapsed_sec = |
109 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; | 112 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; |
110 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 113 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
111 RTC_HISTOGRAM_COUNTS_10000( | 114 RTC_HISTOGRAM_COUNTS_10000( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 244 } |
242 | 245 |
243 void ReceiveStatisticsProxy::OnDecodedFrame() { | 246 void ReceiveStatisticsProxy::OnDecodedFrame() { |
244 uint64_t now = clock_->TimeInMilliseconds(); | 247 uint64_t now = clock_->TimeInMilliseconds(); |
245 | 248 |
246 rtc::CritScope lock(&crit_); | 249 rtc::CritScope lock(&crit_); |
247 decode_fps_estimator_.Update(1, now); | 250 decode_fps_estimator_.Update(1, now); |
248 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0); | 251 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0); |
249 } | 252 } |
250 | 253 |
251 void ReceiveStatisticsProxy::OnRenderedFrame(int width, int height) { | 254 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { |
| 255 int width = frame.width(); |
| 256 int height = frame.height(); |
252 RTC_DCHECK_GT(width, 0); | 257 RTC_DCHECK_GT(width, 0); |
253 RTC_DCHECK_GT(height, 0); | 258 RTC_DCHECK_GT(height, 0); |
254 uint64_t now = clock_->TimeInMilliseconds(); | 259 uint64_t now = clock_->TimeInMilliseconds(); |
255 | 260 |
256 rtc::CritScope lock(&crit_); | 261 rtc::CritScope lock(&crit_); |
257 renders_fps_estimator_.Update(1, now); | 262 renders_fps_estimator_.Update(1, now); |
258 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0); | 263 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0); |
259 stats_.width = width; | 264 stats_.width = width; |
260 stats_.height = height; | 265 stats_.height = height; |
261 render_width_counter_.Add(width); | 266 render_width_counter_.Add(width); |
262 render_height_counter_.Add(height); | 267 render_height_counter_.Add(height); |
263 render_fps_tracker_.AddSamples(1); | 268 render_fps_tracker_.AddSamples(1); |
264 render_pixel_tracker_.AddSamples(sqrt(width * height)); | 269 render_pixel_tracker_.AddSamples(sqrt(width * height)); |
| 270 |
| 271 if (frame.ntp_time_ms() > 0) { |
| 272 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); |
| 273 if (delay_ms >= 0) |
| 274 e2e_delay_counter_.Add(delay_ms); |
| 275 } |
265 } | 276 } |
266 | 277 |
267 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) { | 278 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms) { |
268 rtc::CritScope lock(&crit_); | 279 rtc::CritScope lock(&crit_); |
269 sync_offset_counter_.Add(std::abs(sync_offset_ms)); | 280 sync_offset_counter_.Add(std::abs(sync_offset_ms)); |
270 stats_.sync_offset_ms = sync_offset_ms; | 281 stats_.sync_offset_ms = sync_offset_ms; |
271 } | 282 } |
272 | 283 |
273 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, | 284 void ReceiveStatisticsProxy::OnReceiveRatesUpdated(uint32_t bitRate, |
274 uint32_t frameRate) { | 285 uint32_t frameRate) { |
(...skipping 26 matching lines...) Expand all Loading... |
301 ++num_samples; | 312 ++num_samples; |
302 } | 313 } |
303 | 314 |
304 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 315 int ReceiveStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { |
305 if (num_samples < min_required_samples || num_samples == 0) | 316 if (num_samples < min_required_samples || num_samples == 0) |
306 return -1; | 317 return -1; |
307 return sum / num_samples; | 318 return sum / num_samples; |
308 } | 319 } |
309 | 320 |
310 } // namespace webrtc | 321 } // namespace webrtc |
OLD | NEW |