Do not report cpu limited resolution stats when degradation preference is disabled and no scaling is done.
When degradation preference is kDegradationDisabled, do not update WebRTC.Video.CpuLimitedResolutionInPercent.
BUG=webrtc:6634
Review-Url: https://codereview.webrtc.org/2807133002
Cr-Commit-Position: refs/heads/master@{#17757}
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc
index 822ed97..4fcf842 100644
--- a/webrtc/video/send_statistics_proxy.cc
+++ b/webrtc/video/send_statistics_proxy.cc
@@ -709,7 +709,10 @@
uma_container_->input_fps_counter_.Add(1);
uma_container_->input_width_counter_.Add(width);
uma_container_->input_height_counter_.Add(height);
- uma_container_->cpu_limited_frame_counter_.Add(stats_.cpu_limited_resolution);
+ if (cpu_downscales_ >= 0) {
+ uma_container_->cpu_limited_frame_counter_.Add(
+ stats_.cpu_limited_resolution);
+ }
TRACE_EVENT_INSTANT2("webrtc_stats", "WebRTC.Video.InputFrameRate",
"frame_rate", round(
uma_container_->input_frame_rate_tracker_.ComputeRate()),
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index e2cb2fd..edb7564 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -841,7 +841,22 @@
EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SentFramesPerSecond", kFps));
}
-TEST_F(SendStatisticsProxyTest, CpuLimitedResolutionUpdated) {
+TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramNotUpdatedWhenDisabled) {
+ const int kNumDownscales = -1;
+ statistics_proxy_->SetQualityScalingStats(kNumDownscales);
+
+ for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
+ statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
+
+ statistics_proxy_.reset();
+ EXPECT_EQ(0,
+ metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent"));
+}
+
+TEST_F(SendStatisticsProxyTest, CpuLimitedHistogramUpdated) {
+ const int kNumDownscales = 0;
+ statistics_proxy_->SetCpuScalingStats(kNumDownscales);
+
for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc
index 79a08b3..765efbc 100644
--- a/webrtc/video/vie_encoder_unittest.cc
+++ b/webrtc/video/vie_encoder_unittest.cc
@@ -1425,9 +1425,8 @@
vie_encoder_->Stop();
}
-TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) {
+TEST_F(ViEEncoderTest, CpuLimitedHistogramIsReported) {
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
-
const int kWidth = 640;
const int kHeight = 360;
@@ -1454,6 +1453,28 @@
1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50));
}
+TEST_F(ViEEncoderTest, CpuLimitedHistogramIsNotReportedForDisabledDegradation) {
+ vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0);
+ const int kWidth = 640;
+ const int kHeight = 360;
+
+ vie_encoder_->SetSource(
+ &video_source_,
+ VideoSendStream::DegradationPreference::kDegradationDisabled);
+
+ for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
+ video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight));
+ sink_.WaitForEncodedFrame(i);
+ }
+
+ vie_encoder_->Stop();
+ vie_encoder_.reset();
+ stats_proxy_.reset();
+
+ EXPECT_EQ(0,
+ metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent"));
+}
+
TEST_F(ViEEncoderTest, CallsBitrateObserver) {
class MockBitrateObserver : public VideoBitrateAllocationObserver {
public: