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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); | 287 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); |
288 if (qp_h264 != -1) { | 288 if (qp_h264 != -1) { |
289 int spatial_idx = it.first; | 289 int spatial_idx = it.first; |
290 RTC_DCHECK_EQ(-1, spatial_idx); | 290 RTC_DCHECK_EQ(-1, spatial_idx); |
291 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", | 291 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", |
292 qp_h264); | 292 qp_h264); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
| 296 quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 297 int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; |
| 298 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 299 int quality_changes = current_stats.number_of_quality_adapt_changes - |
| 300 start_stats_.number_of_quality_adapt_changes; |
| 301 RTC_HISTOGRAMS_COUNTS_100(kIndex, |
| 302 uma_prefix_ + "AdaptChangesPerMinute.Quality", |
| 303 quality_changes * 60 / elapsed_sec); |
| 304 } |
| 305 cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 306 elapsed_sec = cpu_scaling_timer_.total_ms / 1000; |
| 307 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 308 int cpu_changes = current_stats.number_of_cpu_adapt_changes - |
| 309 start_stats_.number_of_cpu_adapt_changes; |
| 310 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "AdaptChangesPerMinute.Cpu", |
| 311 cpu_changes * 60 / elapsed_sec); |
| 312 } |
| 313 |
296 if (first_rtcp_stats_time_ms_ != -1) { | 314 if (first_rtcp_stats_time_ms_ != -1) { |
297 int64_t elapsed_sec = | 315 int64_t elapsed_sec = |
298 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; | 316 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
299 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 317 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
300 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 318 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
301 if (fraction_lost != -1) { | 319 if (fraction_lost != -1) { |
302 RTC_HISTOGRAMS_PERCENTAGE( | 320 RTC_HISTOGRAMS_PERCENTAGE( |
303 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); | 321 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
304 } | 322 } |
305 | 323 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 uma_container_->input_fps_counter_.Add(1); | 695 uma_container_->input_fps_counter_.Add(1); |
678 uma_container_->input_width_counter_.Add(width); | 696 uma_container_->input_width_counter_.Add(width); |
679 uma_container_->input_height_counter_.Add(height); | 697 uma_container_->input_height_counter_.Add(height); |
680 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); | 698 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); |
681 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", | 699 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", |
682 "frame_rate", round( | 700 "frame_rate", round( |
683 uma_container_->input_frame_rate_tracker_.ComputeRate()), | 701 uma_container_->input_frame_rate_tracker_.ComputeRate()), |
684 "ssrc", rtp_config_.ssrcs[0]); | 702 "ssrc", rtp_config_.ssrcs[0]); |
685 } | 703 } |
686 | 704 |
687 void SendStatisticsProxy::SetCpuScalingStats(bool cpu_restricted_resolution) { | 705 void SendStatisticsProxy::SetCpuScalingStats(int num_cpu_downscales) { |
688 rtc::CritScope lock(&crit_); | 706 rtc::CritScope lock(&crit_); |
689 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 707 stats_.cpu_limited_resolution = num_cpu_downscales > 0; |
| 708 |
| 709 if (num_cpu_downscales >= 0) { |
| 710 // Scaling enabled. |
| 711 uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); |
| 712 } else { |
| 713 uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 714 } |
690 } | 715 } |
691 | 716 |
692 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { | 717 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { |
693 rtc::CritScope lock(&crit_); | 718 rtc::CritScope lock(&crit_); |
694 quality_downscales_ = num_quality_downscales; | 719 quality_downscales_ = num_quality_downscales; |
695 stats_.bw_limited_resolution = quality_downscales_ > 0; | 720 stats_.bw_limited_resolution = quality_downscales_ > 0; |
| 721 |
| 722 if (num_quality_downscales >= 0) { |
| 723 // Scaling enabled. |
| 724 uma_container_->quality_scaling_timer_.Start(clock_->TimeInMilliseconds()); |
| 725 } else { |
| 726 uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
| 727 } |
696 } | 728 } |
697 | 729 |
698 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | 730 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
699 bool cpu_restricted_resolution) { | 731 bool cpu_restricted_resolution) { |
700 rtc::CritScope lock(&crit_); | 732 rtc::CritScope lock(&crit_); |
701 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 733 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
702 ++stats_.number_of_cpu_adapt_changes; | 734 ++stats_.number_of_cpu_adapt_changes; |
703 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.AdaptationChanges"); | 735 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges"); |
704 } | 736 } |
705 | 737 |
706 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( | 738 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( |
707 int num_quality_downscales) { | 739 int num_quality_downscales) { |
708 rtc::CritScope lock(&crit_); | 740 rtc::CritScope lock(&crit_); |
709 ++stats_.number_of_quality_adapt_changes; | 741 ++stats_.number_of_quality_adapt_changes; |
710 quality_downscales_ = num_quality_downscales; | 742 quality_downscales_ = num_quality_downscales; |
711 stats_.bw_limited_resolution = quality_downscales_ > 0; | 743 stats_.bw_limited_resolution = quality_downscales_ > 0; |
712 } | 744 } |
713 | 745 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 786 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
755 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc; | 787 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc; |
756 | 788 |
757 if (stats->is_flexfec) { | 789 if (stats->is_flexfec) { |
758 // The same counters are reported for both the media ssrc and flexfec ssrc. | 790 // The same counters are reported for both the media ssrc and flexfec ssrc. |
759 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. | 791 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. |
760 return; | 792 return; |
761 } | 793 } |
762 | 794 |
763 stats->rtp_stats = counters; | 795 stats->rtp_stats = counters; |
764 if (uma_container_->first_rtp_stats_time_ms_ == -1) | 796 if (uma_container_->first_rtp_stats_time_ms_ == -1) { |
765 uma_container_->first_rtp_stats_time_ms_ = clock_->TimeInMilliseconds(); | 797 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 798 uma_container_->first_rtp_stats_time_ms_ = now_ms; |
| 799 uma_container_->cpu_scaling_timer_.Restart(now_ms); |
| 800 uma_container_->quality_scaling_timer_.Restart(now_ms); |
| 801 } |
766 | 802 |
767 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), | 803 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), |
768 ssrc); | 804 ssrc); |
769 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, | 805 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, |
770 ssrc); | 806 ssrc); |
771 uma_container_->retransmit_byte_counter_.Set( | 807 uma_container_->retransmit_byte_counter_.Set( |
772 counters.retransmitted.TotalBytes(), ssrc); | 808 counters.retransmitted.TotalBytes(), ssrc); |
773 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); | 809 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); |
774 if (stats->is_rtx) { | 810 if (stats->is_rtx) { |
775 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(), | 811 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 847 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
812 if (!stats) | 848 if (!stats) |
813 return; | 849 return; |
814 stats->avg_delay_ms = avg_delay_ms; | 850 stats->avg_delay_ms = avg_delay_ms; |
815 stats->max_delay_ms = max_delay_ms; | 851 stats->max_delay_ms = max_delay_ms; |
816 | 852 |
817 uma_container_->delay_counter_.Add(avg_delay_ms); | 853 uma_container_->delay_counter_.Add(avg_delay_ms); |
818 uma_container_->max_delay_counter_.Add(max_delay_ms); | 854 uma_container_->max_delay_counter_.Add(max_delay_ms); |
819 } | 855 } |
820 | 856 |
| 857 void SendStatisticsProxy::StatsTimer::Start(int64_t now_ms) { |
| 858 if (start_ms == -1) |
| 859 start_ms = now_ms; |
| 860 } |
| 861 |
| 862 void SendStatisticsProxy::StatsTimer::Stop(int64_t now_ms) { |
| 863 if (start_ms != -1) { |
| 864 total_ms += now_ms - start_ms; |
| 865 start_ms = -1; |
| 866 } |
| 867 } |
| 868 |
| 869 void SendStatisticsProxy::StatsTimer::Restart(int64_t now_ms) { |
| 870 total_ms = 0; |
| 871 if (start_ms != -1) |
| 872 start_ms = now_ms; |
| 873 } |
| 874 |
821 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 875 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
822 sum += sample; | 876 sum += sample; |
823 ++num_samples; | 877 ++num_samples; |
824 } | 878 } |
825 | 879 |
826 int SendStatisticsProxy::SampleCounter::Avg( | 880 int SendStatisticsProxy::SampleCounter::Avg( |
827 int64_t min_required_samples) const { | 881 int64_t min_required_samples) const { |
828 if (num_samples < min_required_samples || num_samples == 0) | 882 if (num_samples < min_required_samples || num_samples == 0) |
829 return -1; | 883 return -1; |
830 return static_cast<int>((sum + (num_samples / 2)) / num_samples); | 884 return static_cast<int>((sum + (num_samples / 2)) / num_samples); |
(...skipping 21 matching lines...) Expand all Loading... |
852 } | 906 } |
853 | 907 |
854 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 908 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
855 int64_t min_required_samples, | 909 int64_t min_required_samples, |
856 float multiplier) const { | 910 float multiplier) const { |
857 if (num_samples < min_required_samples || num_samples == 0) | 911 if (num_samples < min_required_samples || num_samples == 0) |
858 return -1; | 912 return -1; |
859 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 913 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
860 } | 914 } |
861 } // namespace webrtc | 915 } // namespace webrtc |
OLD | NEW |