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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 kIndex, uma_prefix_ + "UniqueNackRequestsReceivedInPercent", | 315 kIndex, uma_prefix_ + "UniqueNackRequestsReceivedInPercent", |
316 counters.UniqueNackRequestsInPercent()); | 316 counters.UniqueNackRequestsInPercent()); |
317 } | 317 } |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 if (first_rtp_stats_time_ms_ != -1) { | 321 if (first_rtp_stats_time_ms_ != -1) { |
322 int64_t elapsed_sec = | 322 int64_t elapsed_sec = |
323 (clock_->TimeInMilliseconds() - first_rtp_stats_time_ms_) / 1000; | 323 (clock_->TimeInMilliseconds() - first_rtp_stats_time_ms_) / 1000; |
324 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 324 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
325 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "NumberOfPauseEvents", | |
326 target_rate_updates_.pause_resume_events); | |
327 | |
328 int paused_time_percent = | |
329 paused_time_counter_.Percent(metrics::kMinRunTimeInSeconds * 1000); | |
stefan-webrtc
2016/12/13 12:18:01
Why is this argument passed in? We already know it
åsapersson
2016/12/13 12:51:32
Right, should be about the same if OnSetEncoderTar
stefan-webrtc
2016/12/19 12:37:15
Acknowledged.
| |
330 if (paused_time_percent != -1) { | |
331 RTC_HISTOGRAMS_PERCENTAGE(kIndex, uma_prefix_ + "PausedTimeInPercent", | |
332 paused_time_percent); | |
333 } | |
334 | |
325 StreamDataCounters rtp; | 335 StreamDataCounters rtp; |
326 StreamDataCounters rtx; | 336 StreamDataCounters rtx; |
327 AccumulateRtxStats(current_stats, rtp_config.rtx.ssrcs, &rtp, &rtx); | 337 AccumulateRtxStats(current_stats, rtp_config.rtx.ssrcs, &rtp, &rtx); |
328 StreamDataCounters start_rtp; | 338 StreamDataCounters start_rtp; |
329 StreamDataCounters start_rtx; | 339 StreamDataCounters start_rtx; |
330 AccumulateRtxStats(start_stats_, rtp_config.rtx.ssrcs, &start_rtp, | 340 AccumulateRtxStats(start_stats_, rtp_config.rtx.ssrcs, &start_rtp, |
331 &start_rtx); | 341 &start_rtx); |
332 rtp.Subtract(start_rtp); | 342 rtp.Subtract(start_rtp); |
333 rtx.Subtract(start_rtx); | 343 rtx.Subtract(start_rtx); |
334 StreamDataCounters rtp_rtx = rtp; | 344 StreamDataCounters rtp_rtx = rtp; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 return; | 470 return; |
461 | 471 |
462 stats->total_bitrate_bps = 0; | 472 stats->total_bitrate_bps = 0; |
463 stats->retransmit_bitrate_bps = 0; | 473 stats->retransmit_bitrate_bps = 0; |
464 stats->height = 0; | 474 stats->height = 0; |
465 stats->width = 0; | 475 stats->width = 0; |
466 } | 476 } |
467 | 477 |
468 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { | 478 void SendStatisticsProxy::OnSetEncoderTargetRate(uint32_t bitrate_bps) { |
469 rtc::CritScope lock(&crit_); | 479 rtc::CritScope lock(&crit_); |
480 if (uma_container_->target_rate_updates_.last_ms == -1 && bitrate_bps == 0) | |
481 return; // Start on first non-zero bitrate, may initially be zero. | |
482 | |
483 int64_t now = clock_->TimeInMilliseconds(); | |
484 if (uma_container_->target_rate_updates_.last_ms != -1) { | |
485 bool was_paused = stats_.target_media_bitrate_bps == 0; | |
486 int64_t diff_ms = now - uma_container_->target_rate_updates_.last_ms; | |
487 uma_container_->paused_time_counter_.Add(was_paused, diff_ms); | |
488 | |
489 // Use last to not include update when stream is stopped and video disabled. | |
490 if (uma_container_->target_rate_updates_.last_paused_or_resumed) | |
491 ++uma_container_->target_rate_updates_.pause_resume_events; | |
492 | |
493 // Check if video is paused/resumed. | |
494 uma_container_->target_rate_updates_.last_paused_or_resumed = | |
495 (bitrate_bps == 0) != was_paused; | |
496 } | |
497 uma_container_->target_rate_updates_.last_ms = now; | |
498 | |
470 stats_.target_media_bitrate_bps = bitrate_bps; | 499 stats_.target_media_bitrate_bps = bitrate_bps; |
471 } | 500 } |
472 | 501 |
473 void SendStatisticsProxy::OnSendEncodedImage( | 502 void SendStatisticsProxy::OnSendEncodedImage( |
474 const EncodedImage& encoded_image, | 503 const EncodedImage& encoded_image, |
475 const CodecSpecificInfo* codec_info) { | 504 const CodecSpecificInfo* codec_info) { |
476 size_t simulcast_idx = 0; | 505 size_t simulcast_idx = 0; |
477 | 506 |
478 rtc::CritScope lock(&crit_); | 507 rtc::CritScope lock(&crit_); |
479 ++stats_.frames_encoded; | 508 ++stats_.frames_encoded; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 return -1; | 728 return -1; |
700 return (sum + (num_samples / 2)) / num_samples; | 729 return (sum + (num_samples / 2)) / num_samples; |
701 } | 730 } |
702 | 731 |
703 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { | 732 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { |
704 if (sample) | 733 if (sample) |
705 ++sum; | 734 ++sum; |
706 ++num_samples; | 735 ++num_samples; |
707 } | 736 } |
708 | 737 |
738 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample, int64_t count) { | |
739 if (sample) | |
740 sum += count; | |
741 num_samples += count; | |
742 } | |
709 int SendStatisticsProxy::BoolSampleCounter::Percent( | 743 int SendStatisticsProxy::BoolSampleCounter::Percent( |
710 int min_required_samples) const { | 744 int64_t min_required_samples) const { |
711 return Fraction(min_required_samples, 100.0f); | 745 return Fraction(min_required_samples, 100.0f); |
712 } | 746 } |
713 | 747 |
714 int SendStatisticsProxy::BoolSampleCounter::Permille( | 748 int SendStatisticsProxy::BoolSampleCounter::Permille( |
715 int min_required_samples) const { | 749 int64_t min_required_samples) const { |
716 return Fraction(min_required_samples, 1000.0f); | 750 return Fraction(min_required_samples, 1000.0f); |
717 } | 751 } |
718 | 752 |
719 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 753 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
720 int min_required_samples, float multiplier) const { | 754 int64_t min_required_samples, |
755 float multiplier) const { | |
721 if (num_samples < min_required_samples || num_samples == 0) | 756 if (num_samples < min_required_samples || num_samples == 0) |
722 return -1; | 757 return -1; |
723 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 758 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
724 } | 759 } |
725 } // namespace webrtc | 760 } // namespace webrtc |
OLD | NEW |