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); |
| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 716 |
688 uma_container_->delay_counter_.Add(avg_delay_ms); | 717 uma_container_->delay_counter_.Add(avg_delay_ms); |
689 uma_container_->max_delay_counter_.Add(max_delay_ms); | 718 uma_container_->max_delay_counter_.Add(max_delay_ms); |
690 } | 719 } |
691 | 720 |
692 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 721 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
693 sum += sample; | 722 sum += sample; |
694 ++num_samples; | 723 ++num_samples; |
695 } | 724 } |
696 | 725 |
697 int SendStatisticsProxy::SampleCounter::Avg(int min_required_samples) const { | 726 int SendStatisticsProxy::SampleCounter::Avg( |
| 727 int64_t min_required_samples) const { |
698 if (num_samples < min_required_samples || num_samples == 0) | 728 if (num_samples < min_required_samples || num_samples == 0) |
699 return -1; | 729 return -1; |
700 return (sum + (num_samples / 2)) / num_samples; | 730 return static_cast<int>((sum + (num_samples / 2)) / num_samples); |
701 } | 731 } |
702 | 732 |
703 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { | 733 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample) { |
704 if (sample) | 734 if (sample) |
705 ++sum; | 735 ++sum; |
706 ++num_samples; | 736 ++num_samples; |
707 } | 737 } |
708 | 738 |
| 739 void SendStatisticsProxy::BoolSampleCounter::Add(bool sample, int64_t count) { |
| 740 if (sample) |
| 741 sum += count; |
| 742 num_samples += count; |
| 743 } |
709 int SendStatisticsProxy::BoolSampleCounter::Percent( | 744 int SendStatisticsProxy::BoolSampleCounter::Percent( |
710 int min_required_samples) const { | 745 int64_t min_required_samples) const { |
711 return Fraction(min_required_samples, 100.0f); | 746 return Fraction(min_required_samples, 100.0f); |
712 } | 747 } |
713 | 748 |
714 int SendStatisticsProxy::BoolSampleCounter::Permille( | 749 int SendStatisticsProxy::BoolSampleCounter::Permille( |
715 int min_required_samples) const { | 750 int64_t min_required_samples) const { |
716 return Fraction(min_required_samples, 1000.0f); | 751 return Fraction(min_required_samples, 1000.0f); |
717 } | 752 } |
718 | 753 |
719 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 754 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
720 int min_required_samples, float multiplier) const { | 755 int64_t min_required_samples, |
| 756 float multiplier) const { |
721 if (num_samples < min_required_samples || num_samples == 0) | 757 if (num_samples < min_required_samples || num_samples == 0) |
722 return -1; | 758 return -1; |
723 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 759 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
724 } | 760 } |
725 } // namespace webrtc | 761 } // namespace webrtc |
OLD | NEW |