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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 kBadFraction, | 67 kBadFraction, |
68 kNumMeasurementsVariance), | 68 kNumMeasurementsVariance), |
69 num_bad_states_(0), | 69 num_bad_states_(0), |
70 num_certain_states_(0), | 70 num_certain_states_(0), |
71 // 1000ms window, scale 1000 for ms to s. | 71 // 1000ms window, scale 1000 for ms to s. |
72 decode_fps_estimator_(1000, 1000), | 72 decode_fps_estimator_(1000, 1000), |
73 renders_fps_estimator_(1000, 1000), | 73 renders_fps_estimator_(1000, 1000), |
74 render_fps_tracker_(100, 10u), | 74 render_fps_tracker_(100, 10u), |
75 render_pixel_tracker_(100, 10u), | 75 render_pixel_tracker_(100, 10u), |
76 total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count | 76 total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count |
| 77 e2e_delay_max_ms_video_(-1), |
| 78 e2e_delay_max_ms_screenshare_(-1), |
77 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), | 79 freq_offset_counter_(clock, nullptr, kFreqOffsetProcessIntervalMs), |
78 first_report_block_time_ms_(-1), | 80 first_report_block_time_ms_(-1), |
79 avg_rtt_ms_(0) { | 81 avg_rtt_ms_(0), |
| 82 last_content_type_(VideoContentType::kDefault) { |
80 stats_.ssrc = config_.rtp.remote_ssrc; | 83 stats_.ssrc = config_.rtp.remote_ssrc; |
81 // TODO(brandtr): Replace |rtx_stats_| with a single instance of | 84 // TODO(brandtr): Replace |rtx_stats_| with a single instance of |
82 // StreamDataCounters. | 85 // StreamDataCounters. |
83 if (config_.rtp.rtx_ssrc) { | 86 if (config_.rtp.rtx_ssrc) { |
84 rtx_stats_[config_.rtp.rtx_ssrc] = StreamDataCounters(); | 87 rtx_stats_[config_.rtp.rtx_ssrc] = StreamDataCounters(); |
85 } | 88 } |
86 } | 89 } |
87 | 90 |
88 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { | 91 ReceiveStatisticsProxy::~ReceiveStatisticsProxy() { |
89 UpdateHistograms(); | 92 UpdateHistograms(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 165 } |
163 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples); | 166 int current_delay_ms = current_delay_counter_.Avg(kMinRequiredSamples); |
164 if (current_delay_ms != -1) { | 167 if (current_delay_ms != -1) { |
165 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", | 168 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.CurrentDelayInMs", |
166 current_delay_ms); | 169 current_delay_ms); |
167 } | 170 } |
168 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); | 171 int delay_ms = delay_counter_.Avg(kMinRequiredSamples); |
169 if (delay_ms != -1) | 172 if (delay_ms != -1) |
170 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); | 173 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms); |
171 | 174 |
172 int e2e_delay_ms = e2e_delay_counter_.Avg(kMinRequiredSamples); | 175 int e2e_delay_ms_video = e2e_delay_counter_video_.Avg(kMinRequiredSamples); |
173 if (e2e_delay_ms != -1) | 176 if (e2e_delay_ms_video != -1) { |
174 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.EndToEndDelayInMs", e2e_delay_ms); | 177 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.EndToEndDelayInMs", |
| 178 e2e_delay_ms_video); |
| 179 } |
| 180 |
| 181 int e2e_delay_ms_screenshare = |
| 182 e2e_delay_counter_screenshare_.Avg(kMinRequiredSamples); |
| 183 if (e2e_delay_ms_screenshare != -1) { |
| 184 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.EndToEndDelayInMs", |
| 185 e2e_delay_ms_screenshare); |
| 186 } |
| 187 |
| 188 int e2e_delay_max_ms_video = e2e_delay_max_ms_video_; |
| 189 if (e2e_delay_max_ms_video != -1) { |
| 190 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.EndToEndDelayMaxInMs", |
| 191 e2e_delay_max_ms_video); |
| 192 } |
| 193 |
| 194 int e2e_delay_max_ms_screenshare = e2e_delay_max_ms_screenshare_; |
| 195 if (e2e_delay_max_ms_screenshare != -1) { |
| 196 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.Screenshare.EndToEndDelayMaxInMs", |
| 197 e2e_delay_max_ms_screenshare); |
| 198 } |
175 | 199 |
176 StreamDataCounters rtp = stats_.rtp_stats; | 200 StreamDataCounters rtp = stats_.rtp_stats; |
177 StreamDataCounters rtx; | 201 StreamDataCounters rtx; |
178 for (auto it : rtx_stats_) | 202 for (auto it : rtx_stats_) |
179 rtx.Add(it.second); | 203 rtx.Add(it.second); |
180 StreamDataCounters rtp_rtx = rtp; | 204 StreamDataCounters rtp_rtx = rtp; |
181 rtp_rtx.Add(rtx); | 205 rtp_rtx.Add(rtx); |
182 int64_t elapsed_sec = | 206 int64_t elapsed_sec = |
183 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; | 207 rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000; |
184 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 208 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 total_bytes = counters.transmitted.TotalBytes(); | 448 total_bytes = counters.transmitted.TotalBytes(); |
425 it->second = counters; | 449 it->second = counters; |
426 } else { | 450 } else { |
427 RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc; | 451 RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc; |
428 } | 452 } |
429 } | 453 } |
430 if (total_bytes > last_total_bytes) | 454 if (total_bytes > last_total_bytes) |
431 total_byte_tracker_.AddSamples(total_bytes - last_total_bytes); | 455 total_byte_tracker_.AddSamples(total_bytes - last_total_bytes); |
432 } | 456 } |
433 | 457 |
434 void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional<uint8_t> qp) { | 458 void ReceiveStatisticsProxy::OnDecodedFrame(rtc::Optional<uint8_t> qp, |
| 459 VideoContentType content_type) { |
435 uint64_t now = clock_->TimeInMilliseconds(); | 460 uint64_t now = clock_->TimeInMilliseconds(); |
436 | 461 |
437 rtc::CritScope lock(&crit_); | 462 rtc::CritScope lock(&crit_); |
438 ++stats_.frames_decoded; | 463 ++stats_.frames_decoded; |
439 if (qp) { | 464 if (qp) { |
440 if (!stats_.qp_sum) { | 465 if (!stats_.qp_sum) { |
441 if (stats_.frames_decoded != 1) { | 466 if (stats_.frames_decoded != 1) { |
442 LOG(LS_WARNING) | 467 LOG(LS_WARNING) |
443 << "Frames decoded was not 1 when first qp value was received."; | 468 << "Frames decoded was not 1 when first qp value was received."; |
444 stats_.frames_decoded = 1; | 469 stats_.frames_decoded = 1; |
445 } | 470 } |
446 stats_.qp_sum = rtc::Optional<uint64_t>(0); | 471 stats_.qp_sum = rtc::Optional<uint64_t>(0); |
447 } | 472 } |
448 *stats_.qp_sum += *qp; | 473 *stats_.qp_sum += *qp; |
449 } else if (stats_.qp_sum) { | 474 } else if (stats_.qp_sum) { |
450 LOG(LS_WARNING) | 475 LOG(LS_WARNING) |
451 << "QP sum was already set and no QP was given for a frame."; | 476 << "QP sum was already set and no QP was given for a frame."; |
452 stats_.qp_sum = rtc::Optional<uint64_t>(); | 477 stats_.qp_sum = rtc::Optional<uint64_t>(); |
453 } | 478 } |
| 479 last_content_type_ = content_type; |
454 decode_fps_estimator_.Update(1, now); | 480 decode_fps_estimator_.Update(1, now); |
455 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0); | 481 stats_.decode_frame_rate = decode_fps_estimator_.Rate(now).value_or(0); |
456 } | 482 } |
457 | 483 |
458 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { | 484 void ReceiveStatisticsProxy::OnRenderedFrame(const VideoFrame& frame) { |
459 int width = frame.width(); | 485 int width = frame.width(); |
460 int height = frame.height(); | 486 int height = frame.height(); |
461 RTC_DCHECK_GT(width, 0); | 487 RTC_DCHECK_GT(width, 0); |
462 RTC_DCHECK_GT(height, 0); | 488 RTC_DCHECK_GT(height, 0); |
463 uint64_t now = clock_->TimeInMilliseconds(); | 489 uint64_t now = clock_->TimeInMilliseconds(); |
464 | 490 |
465 rtc::CritScope lock(&crit_); | 491 rtc::CritScope lock(&crit_); |
466 renders_fps_estimator_.Update(1, now); | 492 renders_fps_estimator_.Update(1, now); |
467 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0); | 493 stats_.render_frame_rate = renders_fps_estimator_.Rate(now).value_or(0); |
468 ++stats_.frames_rendered; | 494 ++stats_.frames_rendered; |
469 stats_.width = width; | 495 stats_.width = width; |
470 stats_.height = height; | 496 stats_.height = height; |
471 render_width_counter_.Add(width); | 497 render_width_counter_.Add(width); |
472 render_height_counter_.Add(height); | 498 render_height_counter_.Add(height); |
473 render_fps_tracker_.AddSamples(1); | 499 render_fps_tracker_.AddSamples(1); |
474 render_pixel_tracker_.AddSamples(sqrt(width * height)); | 500 render_pixel_tracker_.AddSamples(sqrt(width * height)); |
475 | 501 |
476 if (frame.ntp_time_ms() > 0) { | 502 if (frame.ntp_time_ms() > 0) { |
477 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); | 503 int64_t delay_ms = clock_->CurrentNtpInMilliseconds() - frame.ntp_time_ms(); |
478 if (delay_ms >= 0) | 504 if (delay_ms >= 0) { |
479 e2e_delay_counter_.Add(delay_ms); | 505 if (last_content_type_ == VideoContentType::kScreenshare) { |
| 506 e2e_delay_max_ms_screenshare_ = |
| 507 std::max(delay_ms, e2e_delay_max_ms_screenshare_); |
| 508 e2e_delay_counter_screenshare_.Add(delay_ms); |
| 509 } else { |
| 510 e2e_delay_max_ms_video_ = std::max(delay_ms, e2e_delay_max_ms_video_); |
| 511 e2e_delay_counter_video_.Add(delay_ms); |
| 512 } |
| 513 } |
480 } | 514 } |
481 } | 515 } |
482 | 516 |
483 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, | 517 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t sync_offset_ms, |
484 double estimated_freq_khz) { | 518 double estimated_freq_khz) { |
485 rtc::CritScope lock(&crit_); | 519 rtc::CritScope lock(&crit_); |
486 sync_offset_counter_.Add(std::abs(sync_offset_ms)); | 520 sync_offset_counter_.Add(std::abs(sync_offset_ms)); |
487 stats_.sync_offset_ms = sync_offset_ms; | 521 stats_.sync_offset_ms = sync_offset_ms; |
488 | 522 |
489 const double kMaxFreqKhz = 10000.0; | 523 const double kMaxFreqKhz = 10000.0; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 sum = 0; | 587 sum = 0; |
554 } | 588 } |
555 | 589 |
556 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, | 590 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms, |
557 int64_t max_rtt_ms) { | 591 int64_t max_rtt_ms) { |
558 rtc::CritScope lock(&crit_); | 592 rtc::CritScope lock(&crit_); |
559 avg_rtt_ms_ = avg_rtt_ms; | 593 avg_rtt_ms_ = avg_rtt_ms; |
560 } | 594 } |
561 | 595 |
562 } // namespace webrtc | 596 } // namespace webrtc |
OLD | NEW |