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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 279 } |
280 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); | 280 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); |
281 if (qp_h264 != -1) { | 281 if (qp_h264 != -1) { |
282 int spatial_idx = it.first; | 282 int spatial_idx = it.first; |
283 RTC_DCHECK_EQ(-1, spatial_idx); | 283 RTC_DCHECK_EQ(-1, spatial_idx); |
284 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", | 284 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", |
285 qp_h264); | 285 qp_h264); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
290 int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; | |
291 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | |
292 int quality_changes = current_stats.number_of_quality_adapt_changes - | |
293 start_stats_.number_of_quality_adapt_changes; | |
294 RTC_HISTOGRAMS_COUNTS_100(kIndex, | |
295 uma_prefix_ + "AdaptChangesPerMinute.Quality", | |
296 quality_changes * 60 / elapsed_sec); | |
297 } | |
298 cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
299 elapsed_sec = cpu_scaling_timer_.total_ms / 1000; | |
300 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | |
301 int cpu_changes = current_stats.number_of_cpu_adapt_changes - | |
302 start_stats_.number_of_cpu_adapt_changes; | |
303 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "AdaptChangesPerMinute.Cpu", | |
304 cpu_changes * 60 / elapsed_sec); | |
305 } | |
306 | |
289 if (first_rtcp_stats_time_ms_ != -1) { | 307 if (first_rtcp_stats_time_ms_ != -1) { |
290 int64_t elapsed_sec = | 308 int64_t elapsed_sec = |
291 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; | 309 (clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
292 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 310 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
293 int fraction_lost = report_block_stats_.FractionLostInPercent(); | 311 int fraction_lost = report_block_stats_.FractionLostInPercent(); |
294 if (fraction_lost != -1) { | 312 if (fraction_lost != -1) { |
295 RTC_HISTOGRAMS_PERCENTAGE( | 313 RTC_HISTOGRAMS_PERCENTAGE( |
296 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); | 314 kIndex, uma_prefix_ + "SentPacketsLostInPercent", fraction_lost); |
297 } | 315 } |
298 | 316 |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 uma_container_->input_fps_counter_.Add(1); | 688 uma_container_->input_fps_counter_.Add(1); |
671 uma_container_->input_width_counter_.Add(width); | 689 uma_container_->input_width_counter_.Add(width); |
672 uma_container_->input_height_counter_.Add(height); | 690 uma_container_->input_height_counter_.Add(height); |
673 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); | 691 uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution); |
674 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", | 692 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", |
675 "frame_rate", round( | 693 "frame_rate", round( |
676 uma_container_->input_frame_rate_tracker_.ComputeRate()), | 694 uma_container_->input_frame_rate_tracker_.ComputeRate()), |
677 "ssrc", rtp_config_.ssrcs[0]); | 695 "ssrc", rtp_config_.ssrcs[0]); |
678 } | 696 } |
679 | 697 |
680 void SendStatisticsProxy::SetCpuScalingStats(bool cpu_restricted_resolution) { | 698 void SendStatisticsProxy::SetCpuScalingStats(int cpu_restricted_resolutions) { |
brandtr
2017/04/04 11:24:21
To be consistent with the method below, maybe name
åsapersson
2017/04/04 14:30:51
Done.
| |
681 rtc::CritScope lock(&crit_); | 699 rtc::CritScope lock(&crit_); |
682 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 700 stats_.cpu_limited_resolution = cpu_restricted_resolutions > 0; |
701 | |
702 if (cpu_restricted_resolutions >= 0) { | |
703 // Scaling enabled. | |
704 uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); | |
705 } else { | |
706 uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
707 } | |
683 } | 708 } |
684 | 709 |
685 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { | 710 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { |
686 rtc::CritScope lock(&crit_); | 711 rtc::CritScope lock(&crit_); |
687 quality_downscales_ = num_quality_downscales; | 712 quality_downscales_ = num_quality_downscales; |
688 stats_.bw_limited_resolution = quality_downscales_ > 0; | 713 stats_.bw_limited_resolution = quality_downscales_ > 0; |
714 | |
715 if (num_quality_downscales >= 0) { | |
716 // Scaling enabled. | |
717 uma_container_->quality_scaling_timer_.Start(clock_->TimeInMilliseconds()); | |
718 } else { | |
719 uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
720 } | |
689 } | 721 } |
690 | 722 |
691 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | 723 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
692 bool cpu_restricted_resolution) { | 724 bool cpu_restricted_resolution) { |
693 rtc::CritScope lock(&crit_); | 725 rtc::CritScope lock(&crit_); |
694 stats_.cpu_limited_resolution = cpu_restricted_resolution; | 726 stats_.cpu_limited_resolution = cpu_restricted_resolution; |
695 ++stats_.number_of_cpu_adapt_changes; | 727 ++stats_.number_of_cpu_adapt_changes; |
696 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.AdaptationChanges"); | 728 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.AdaptationChanges"); |
brandtr
2017/04/04 11:24:21
Should this trace name be updated?
åsapersson
2017/04/04 14:30:51
Done.
| |
697 } | 729 } |
698 | 730 |
699 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( | 731 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( |
700 int num_quality_downscales) { | 732 int num_quality_downscales) { |
701 rtc::CritScope lock(&crit_); | 733 rtc::CritScope lock(&crit_); |
734 ++stats_.number_of_quality_adapt_changes; | |
702 quality_downscales_ = num_quality_downscales; | 735 quality_downscales_ = num_quality_downscales; |
703 stats_.bw_limited_resolution = quality_downscales_ > 0; | 736 stats_.bw_limited_resolution = quality_downscales_ > 0; |
704 } | 737 } |
705 | 738 |
706 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 739 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
707 uint32_t ssrc, | 740 uint32_t ssrc, |
708 const RtcpPacketTypeCounter& packet_counter) { | 741 const RtcpPacketTypeCounter& packet_counter) { |
709 rtc::CritScope lock(&crit_); | 742 rtc::CritScope lock(&crit_); |
710 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 743 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
711 if (!stats) | 744 if (!stats) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 779 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
747 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc; | 780 RTC_DCHECK(stats) << "DataCountersUpdated reported for unknown ssrc " << ssrc; |
748 | 781 |
749 if (stats->is_flexfec) { | 782 if (stats->is_flexfec) { |
750 // The same counters are reported for both the media ssrc and flexfec ssrc. | 783 // The same counters are reported for both the media ssrc and flexfec ssrc. |
751 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. | 784 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. |
752 return; | 785 return; |
753 } | 786 } |
754 | 787 |
755 stats->rtp_stats = counters; | 788 stats->rtp_stats = counters; |
756 if (uma_container_->first_rtp_stats_time_ms_ == -1) | 789 if (uma_container_->first_rtp_stats_time_ms_ == -1) { |
757 uma_container_->first_rtp_stats_time_ms_ = clock_->TimeInMilliseconds(); | 790 int64_t now_ms = clock_->TimeInMilliseconds(); |
791 uma_container_->first_rtp_stats_time_ms_ = now_ms; | |
792 uma_container_->cpu_scaling_timer_.Restart(now_ms); | |
793 uma_container_->quality_scaling_timer_.Restart(now_ms); | |
794 } | |
758 | 795 |
759 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), | 796 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), |
760 ssrc); | 797 ssrc); |
761 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, | 798 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, |
762 ssrc); | 799 ssrc); |
763 uma_container_->retransmit_byte_counter_.Set( | 800 uma_container_->retransmit_byte_counter_.Set( |
764 counters.retransmitted.TotalBytes(), ssrc); | 801 counters.retransmitted.TotalBytes(), ssrc); |
765 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); | 802 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); |
766 if (stats->is_rtx) { | 803 if (stats->is_rtx) { |
767 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(), | 804 uma_container_->rtx_byte_counter_.Set(counters.transmitted.TotalBytes(), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 840 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
804 if (!stats) | 841 if (!stats) |
805 return; | 842 return; |
806 stats->avg_delay_ms = avg_delay_ms; | 843 stats->avg_delay_ms = avg_delay_ms; |
807 stats->max_delay_ms = max_delay_ms; | 844 stats->max_delay_ms = max_delay_ms; |
808 | 845 |
809 uma_container_->delay_counter_.Add(avg_delay_ms); | 846 uma_container_->delay_counter_.Add(avg_delay_ms); |
810 uma_container_->max_delay_counter_.Add(max_delay_ms); | 847 uma_container_->max_delay_counter_.Add(max_delay_ms); |
811 } | 848 } |
812 | 849 |
850 void SendStatisticsProxy::StatsTimer::Start(int64_t now_ms) { | |
851 if (start_ms == -1) | |
852 start_ms = now_ms; | |
853 } | |
854 | |
855 void SendStatisticsProxy::StatsTimer::Stop(int64_t now_ms) { | |
856 if (start_ms != -1) { | |
857 total_ms += now_ms - start_ms; | |
858 start_ms = -1; | |
859 } | |
860 } | |
861 | |
862 void SendStatisticsProxy::StatsTimer::Restart(int64_t now_ms) { | |
863 total_ms = 0; | |
864 if (start_ms != -1) | |
865 start_ms = now_ms; | |
866 } | |
867 | |
813 void SendStatisticsProxy::SampleCounter::Add(int sample) { | 868 void SendStatisticsProxy::SampleCounter::Add(int sample) { |
814 sum += sample; | 869 sum += sample; |
815 ++num_samples; | 870 ++num_samples; |
816 } | 871 } |
817 | 872 |
818 int SendStatisticsProxy::SampleCounter::Avg( | 873 int SendStatisticsProxy::SampleCounter::Avg( |
819 int64_t min_required_samples) const { | 874 int64_t min_required_samples) const { |
820 if (num_samples < min_required_samples || num_samples == 0) | 875 if (num_samples < min_required_samples || num_samples == 0) |
821 return -1; | 876 return -1; |
822 return static_cast<int>((sum + (num_samples / 2)) / num_samples); | 877 return static_cast<int>((sum + (num_samples / 2)) / num_samples); |
(...skipping 21 matching lines...) Expand all Loading... | |
844 } | 899 } |
845 | 900 |
846 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 901 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
847 int64_t min_required_samples, | 902 int64_t min_required_samples, |
848 float multiplier) const { | 903 float multiplier) const { |
849 if (num_samples < min_required_samples || num_samples == 0) | 904 if (num_samples < min_required_samples || num_samples == 0) |
850 return -1; | 905 return -1; |
851 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 906 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
852 } | 907 } |
853 } // namespace webrtc | 908 } // namespace webrtc |
OLD | NEW |