| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); | 289 int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples); |
| 290 if (qp_h264 != -1) { | 290 if (qp_h264 != -1) { |
| 291 int spatial_idx = it.first; | 291 int spatial_idx = it.first; |
| 292 RTC_DCHECK_EQ(-1, spatial_idx); | 292 RTC_DCHECK_EQ(-1, spatial_idx); |
| 293 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", | 293 RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264", |
| 294 qp_h264); | 294 qp_h264); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (first_rtp_stats_time_ms_ != -1) { | 298 if (first_rtp_stats_time_ms_ != -1) { |
| 299 quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 299 quality_adapt_timer_.Stop(clock_->TimeInMilliseconds()); |
| 300 int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; | 300 int64_t elapsed_sec = quality_adapt_timer_.total_ms / 1000; |
| 301 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 301 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 302 int quality_changes = current_stats.number_of_quality_adapt_changes - | 302 int quality_changes = current_stats.number_of_quality_adapt_changes - |
| 303 start_stats_.number_of_quality_adapt_changes; | 303 start_stats_.number_of_quality_adapt_changes; |
| 304 RTC_HISTOGRAMS_COUNTS_100(kIndex, | 304 RTC_HISTOGRAMS_COUNTS_100(kIndex, |
| 305 uma_prefix_ + "AdaptChangesPerMinute.Quality", | 305 uma_prefix_ + "AdaptChangesPerMinute.Quality", |
| 306 quality_changes * 60 / elapsed_sec); | 306 quality_changes * 60 / elapsed_sec); |
| 307 } | 307 } |
| 308 cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | 308 cpu_adapt_timer_.Stop(clock_->TimeInMilliseconds()); |
| 309 elapsed_sec = cpu_scaling_timer_.total_ms / 1000; | 309 elapsed_sec = cpu_adapt_timer_.total_ms / 1000; |
| 310 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { | 310 if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
| 311 int cpu_changes = current_stats.number_of_cpu_adapt_changes - | 311 int cpu_changes = current_stats.number_of_cpu_adapt_changes - |
| 312 start_stats_.number_of_cpu_adapt_changes; | 312 start_stats_.number_of_cpu_adapt_changes; |
| 313 RTC_HISTOGRAMS_COUNTS_100(kIndex, | 313 RTC_HISTOGRAMS_COUNTS_100(kIndex, |
| 314 uma_prefix_ + "AdaptChangesPerMinute.Cpu", | 314 uma_prefix_ + "AdaptChangesPerMinute.Cpu", |
| 315 cpu_changes * 60 / elapsed_sec); | 315 cpu_changes * 60 / elapsed_sec); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (first_rtcp_stats_time_ms_ != -1) { | 319 if (first_rtcp_stats_time_ms_ != -1) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 uma_container_->input_fps_counter_.ProcessAndPauseForDuration(kMinMs); | 488 uma_container_->input_fps_counter_.ProcessAndPauseForDuration(kMinMs); |
| 489 uma_container_->sent_fps_counter_.ProcessAndPauseForDuration(kMinMs); | 489 uma_container_->sent_fps_counter_.ProcessAndPauseForDuration(kMinMs); |
| 490 // Pause bitrate stats. | 490 // Pause bitrate stats. |
| 491 uma_container_->total_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 491 uma_container_->total_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 492 uma_container_->media_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 492 uma_container_->media_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 493 uma_container_->rtx_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 493 uma_container_->rtx_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 494 uma_container_->padding_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 494 uma_container_->padding_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 495 uma_container_->retransmit_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 495 uma_container_->retransmit_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 496 uma_container_->fec_byte_counter_.ProcessAndPauseForDuration(kMinMs); | 496 uma_container_->fec_byte_counter_.ProcessAndPauseForDuration(kMinMs); |
| 497 // Stop adaptation stats. | 497 // Stop adaptation stats. |
| 498 uma_container_->cpu_scaling_timer_.Stop(now_ms); | 498 uma_container_->cpu_adapt_timer_.Stop(now_ms); |
| 499 uma_container_->quality_scaling_timer_.Stop(now_ms); | 499 uma_container_->quality_adapt_timer_.Stop(now_ms); |
| 500 } else { | 500 } else { |
| 501 // Start adaptation stats if scaling is enabled. | 501 // Start adaptation stats if scaling is enabled. |
| 502 if (cpu_downscales_ >= 0) | 502 if (cpu_downscales_ >= 0) |
| 503 uma_container_->cpu_scaling_timer_.Start(now_ms); | 503 uma_container_->cpu_adapt_timer_.Start(now_ms); |
| 504 if (quality_downscales_ >= 0) | 504 if (quality_downscales_ >= 0) |
| 505 uma_container_->quality_scaling_timer_.Start(now_ms); | 505 uma_container_->quality_adapt_timer_.Start(now_ms); |
| 506 // Stop pause explicitly for stats that may be zero/not updated for some | 506 // Stop pause explicitly for stats that may be zero/not updated for some |
| 507 // time. | 507 // time. |
| 508 uma_container_->rtx_byte_counter_.ProcessAndStopPause(); | 508 uma_container_->rtx_byte_counter_.ProcessAndStopPause(); |
| 509 uma_container_->padding_byte_counter_.ProcessAndStopPause(); | 509 uma_container_->padding_byte_counter_.ProcessAndStopPause(); |
| 510 uma_container_->retransmit_byte_counter_.ProcessAndStopPause(); | 510 uma_container_->retransmit_byte_counter_.ProcessAndStopPause(); |
| 511 uma_container_->fec_byte_counter_.ProcessAndStopPause(); | 511 uma_container_->fec_byte_counter_.ProcessAndStopPause(); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| 515 VideoSendStream::Stats SendStatisticsProxy::GetStats() { | 515 VideoSendStream::Stats SendStatisticsProxy::GetStats() { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 if (cpu_downscales_ >= 0) { | 712 if (cpu_downscales_ >= 0) { |
| 713 uma_container_->cpu_limited_frame_counter_.Add( | 713 uma_container_->cpu_limited_frame_counter_.Add( |
| 714 stats_.cpu_limited_resolution); | 714 stats_.cpu_limited_resolution); |
| 715 } | 715 } |
| 716 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", | 716 TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate", |
| 717 "frame_rate", round( | 717 "frame_rate", round( |
| 718 uma_container_->input_frame_rate_tracker_.ComputeRate()), | 718 uma_container_->input_frame_rate_tracker_.ComputeRate()), |
| 719 "ssrc", rtp_config_.ssrcs[0]); | 719 "ssrc", rtp_config_.ssrcs[0]); |
| 720 } | 720 } |
| 721 | 721 |
| 722 void SendStatisticsProxy::SetCpuScalingStats(int num_cpu_downscales) { | 722 void SendStatisticsProxy::SetAdaptationStats( |
| 723 const ViEEncoder::AdaptCounts& cpu_counts, |
| 724 const ViEEncoder::AdaptCounts& quality_counts) { |
| 723 rtc::CritScope lock(&crit_); | 725 rtc::CritScope lock(&crit_); |
| 724 cpu_downscales_ = num_cpu_downscales; | 726 SetAdaptTimer(cpu_counts, &uma_container_->cpu_adapt_timer_); |
| 725 stats_.cpu_limited_resolution = num_cpu_downscales > 0; | 727 SetAdaptTimer(quality_counts, &uma_container_->quality_adapt_timer_); |
| 726 | 728 UpdateAdaptationStats(cpu_counts, quality_counts); |
| 727 if (num_cpu_downscales >= 0) { | |
| 728 // Scaling enabled. | |
| 729 if (!stats_.suspended) | |
| 730 uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); | |
| 731 return; | |
| 732 } | |
| 733 uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
| 734 } | 729 } |
| 735 | 730 |
| 736 void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { | 731 void SendStatisticsProxy::OnCpuAdaptationChanged( |
| 732 const ViEEncoder::AdaptCounts& cpu_counts, |
| 733 const ViEEncoder::AdaptCounts& quality_counts) { |
| 737 rtc::CritScope lock(&crit_); | 734 rtc::CritScope lock(&crit_); |
| 738 quality_downscales_ = num_quality_downscales; | |
| 739 stats_.bw_limited_resolution = quality_downscales_ > 0; | |
| 740 | |
| 741 if (num_quality_downscales >= 0) { | |
| 742 // Scaling enabled. | |
| 743 if (!stats_.suspended) { | |
| 744 uma_container_->quality_scaling_timer_.Start( | |
| 745 clock_->TimeInMilliseconds()); | |
| 746 } | |
| 747 return; | |
| 748 } | |
| 749 uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); | |
| 750 } | |
| 751 | |
| 752 void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( | |
| 753 bool cpu_restricted_resolution) { | |
| 754 rtc::CritScope lock(&crit_); | |
| 755 stats_.cpu_limited_resolution = cpu_restricted_resolution; | |
| 756 ++stats_.number_of_cpu_adapt_changes; | 735 ++stats_.number_of_cpu_adapt_changes; |
| 736 UpdateAdaptationStats(cpu_counts, quality_counts); |
| 757 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges"); | 737 TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges"); |
| 758 } | 738 } |
| 759 | 739 |
| 760 void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( | 740 void SendStatisticsProxy::OnQualityAdaptationChanged( |
| 761 int num_quality_downscales) { | 741 const ViEEncoder::AdaptCounts& cpu_counts, |
| 742 const ViEEncoder::AdaptCounts& quality_counts) { |
| 762 rtc::CritScope lock(&crit_); | 743 rtc::CritScope lock(&crit_); |
| 763 ++stats_.number_of_quality_adapt_changes; | 744 ++stats_.number_of_quality_adapt_changes; |
| 764 quality_downscales_ = num_quality_downscales; | 745 UpdateAdaptationStats(cpu_counts, quality_counts); |
| 765 stats_.bw_limited_resolution = quality_downscales_ > 0; | 746 } |
| 747 |
| 748 void SendStatisticsProxy::UpdateAdaptationStats( |
| 749 const ViEEncoder::AdaptCounts& cpu_counts, |
| 750 const ViEEncoder::AdaptCounts& quality_counts) { |
| 751 cpu_downscales_ = cpu_counts.resolution; |
| 752 quality_downscales_ = quality_counts.resolution; |
| 753 |
| 754 stats_.cpu_limited_resolution = cpu_counts.resolution > 0; |
| 755 stats_.cpu_limited_framerate = cpu_counts.fps > 0; |
| 756 stats_.bw_limited_resolution = quality_counts.resolution > 0; |
| 757 stats_.bw_limited_framerate = quality_counts.fps > 0; |
| 758 } |
| 759 |
| 760 void SendStatisticsProxy::SetAdaptTimer(const ViEEncoder::AdaptCounts& counts, |
| 761 StatsTimer* timer) { |
| 762 if (counts.resolution >= 0 || counts.fps >= 0) { |
| 763 // Adaptation enabled. |
| 764 if (!stats_.suspended) |
| 765 timer->Start(clock_->TimeInMilliseconds()); |
| 766 return; |
| 767 } |
| 768 timer->Stop(clock_->TimeInMilliseconds()); |
| 766 } | 769 } |
| 767 | 770 |
| 768 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( | 771 void SendStatisticsProxy::RtcpPacketTypesCounterUpdated( |
| 769 uint32_t ssrc, | 772 uint32_t ssrc, |
| 770 const RtcpPacketTypeCounter& packet_counter) { | 773 const RtcpPacketTypeCounter& packet_counter) { |
| 771 rtc::CritScope lock(&crit_); | 774 rtc::CritScope lock(&crit_); |
| 772 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); | 775 VideoSendStream::StreamStats* stats = GetStatsEntry(ssrc); |
| 773 if (!stats) | 776 if (!stats) |
| 774 return; | 777 return; |
| 775 | 778 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 if (stats->is_flexfec) { | 814 if (stats->is_flexfec) { |
| 812 // The same counters are reported for both the media ssrc and flexfec ssrc. | 815 // The same counters are reported for both the media ssrc and flexfec ssrc. |
| 813 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. | 816 // Bitrate stats are summed for all SSRCs. Use fec stats from media update. |
| 814 return; | 817 return; |
| 815 } | 818 } |
| 816 | 819 |
| 817 stats->rtp_stats = counters; | 820 stats->rtp_stats = counters; |
| 818 if (uma_container_->first_rtp_stats_time_ms_ == -1) { | 821 if (uma_container_->first_rtp_stats_time_ms_ == -1) { |
| 819 int64_t now_ms = clock_->TimeInMilliseconds(); | 822 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 820 uma_container_->first_rtp_stats_time_ms_ = now_ms; | 823 uma_container_->first_rtp_stats_time_ms_ = now_ms; |
| 821 uma_container_->cpu_scaling_timer_.Restart(now_ms); | 824 uma_container_->cpu_adapt_timer_.Restart(now_ms); |
| 822 uma_container_->quality_scaling_timer_.Restart(now_ms); | 825 uma_container_->quality_adapt_timer_.Restart(now_ms); |
| 823 } | 826 } |
| 824 | 827 |
| 825 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), | 828 uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), |
| 826 ssrc); | 829 ssrc); |
| 827 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, | 830 uma_container_->padding_byte_counter_.Set(counters.transmitted.padding_bytes, |
| 828 ssrc); | 831 ssrc); |
| 829 uma_container_->retransmit_byte_counter_.Set( | 832 uma_container_->retransmit_byte_counter_.Set( |
| 830 counters.retransmitted.TotalBytes(), ssrc); | 833 counters.retransmitted.TotalBytes(), ssrc); |
| 831 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); | 834 uma_container_->fec_byte_counter_.Set(counters.fec.TotalBytes(), ssrc); |
| 832 if (stats->is_rtx) { | 835 if (stats->is_rtx) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } | 931 } |
| 929 | 932 |
| 930 int SendStatisticsProxy::BoolSampleCounter::Fraction( | 933 int SendStatisticsProxy::BoolSampleCounter::Fraction( |
| 931 int64_t min_required_samples, | 934 int64_t min_required_samples, |
| 932 float multiplier) const { | 935 float multiplier) const { |
| 933 if (num_samples < min_required_samples || num_samples == 0) | 936 if (num_samples < min_required_samples || num_samples == 0) |
| 934 return -1; | 937 return -1; |
| 935 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); | 938 return static_cast<int>((sum * multiplier / num_samples) + 0.5f); |
| 936 } | 939 } |
| 937 } // namespace webrtc | 940 } // namespace webrtc |
| OLD | NEW |