Index: webrtc/video/send_statistics_proxy.cc |
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc |
index 7cefa294e60cdf4741f685220ee0136762d3081f..9ff54782c5e9959ff5f1e40a84fbac1e8b0a3120 100644 |
--- a/webrtc/video/send_statistics_proxy.cc |
+++ b/webrtc/video/send_statistics_proxy.cc |
@@ -286,6 +286,24 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms( |
} |
} |
+ quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
+ int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000; |
+ if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
+ int quality_changes = current_stats.number_of_quality_adapt_changes - |
+ start_stats_.number_of_quality_adapt_changes; |
+ RTC_HISTOGRAMS_COUNTS_100(kIndex, |
+ uma_prefix_ + "AdaptChangesPerMinute.Quality", |
+ quality_changes * 60 / elapsed_sec); |
+ } |
+ cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
+ elapsed_sec = cpu_scaling_timer_.total_ms / 1000; |
+ if (elapsed_sec >= metrics::kMinRunTimeInSeconds) { |
+ int cpu_changes = current_stats.number_of_cpu_adapt_changes - |
+ start_stats_.number_of_cpu_adapt_changes; |
+ RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "AdaptChangesPerMinute.Cpu", |
+ cpu_changes * 60 / elapsed_sec); |
+ } |
+ |
if (first_rtcp_stats_time_ms_ != -1) { |
int64_t elapsed_sec = |
(clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000; |
@@ -677,15 +695,29 @@ void SendStatisticsProxy::OnIncomingFrame(int width, int height) { |
"ssrc", rtp_config_.ssrcs[0]); |
} |
-void SendStatisticsProxy::SetCpuScalingStats(bool cpu_restricted_resolution) { |
+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.
|
rtc::CritScope lock(&crit_); |
- stats_.cpu_limited_resolution = cpu_restricted_resolution; |
+ stats_.cpu_limited_resolution = cpu_restricted_resolutions > 0; |
+ |
+ if (cpu_restricted_resolutions >= 0) { |
+ // Scaling enabled. |
+ uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds()); |
+ } else { |
+ uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
+ } |
} |
void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) { |
rtc::CritScope lock(&crit_); |
quality_downscales_ = num_quality_downscales; |
stats_.bw_limited_resolution = quality_downscales_ > 0; |
+ |
+ if (num_quality_downscales >= 0) { |
+ // Scaling enabled. |
+ uma_container_->quality_scaling_timer_.Start(clock_->TimeInMilliseconds()); |
+ } else { |
+ uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds()); |
+ } |
} |
void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
@@ -699,6 +731,7 @@ void SendStatisticsProxy::OnCpuRestrictedResolutionChanged( |
void SendStatisticsProxy::OnQualityRestrictedResolutionChanged( |
int num_quality_downscales) { |
rtc::CritScope lock(&crit_); |
+ ++stats_.number_of_quality_adapt_changes; |
quality_downscales_ = num_quality_downscales; |
stats_.bw_limited_resolution = quality_downscales_ > 0; |
} |
@@ -753,8 +786,12 @@ void SendStatisticsProxy::DataCountersUpdated( |
} |
stats->rtp_stats = counters; |
- if (uma_container_->first_rtp_stats_time_ms_ == -1) |
- uma_container_->first_rtp_stats_time_ms_ = clock_->TimeInMilliseconds(); |
+ if (uma_container_->first_rtp_stats_time_ms_ == -1) { |
+ int64_t now_ms = clock_->TimeInMilliseconds(); |
+ uma_container_->first_rtp_stats_time_ms_ = now_ms; |
+ uma_container_->cpu_scaling_timer_.Restart(now_ms); |
+ uma_container_->quality_scaling_timer_.Restart(now_ms); |
+ } |
uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(), |
ssrc); |
@@ -810,6 +847,24 @@ void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms, |
uma_container_->max_delay_counter_.Add(max_delay_ms); |
} |
+void SendStatisticsProxy::StatsTimer::Start(int64_t now_ms) { |
+ if (start_ms == -1) |
+ start_ms = now_ms; |
+} |
+ |
+void SendStatisticsProxy::StatsTimer::Stop(int64_t now_ms) { |
+ if (start_ms != -1) { |
+ total_ms += now_ms - start_ms; |
+ start_ms = -1; |
+ } |
+} |
+ |
+void SendStatisticsProxy::StatsTimer::Restart(int64_t now_ms) { |
+ total_ms = 0; |
+ if (start_ms != -1) |
+ start_ms = now_ms; |
+} |
+ |
void SendStatisticsProxy::SampleCounter::Add(int sample) { |
sum += sample; |
++num_samples; |