Chromium Code Reviews| Index: webrtc/video/vie_encoder_unittest.cc |
| diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc |
| index 7516a2e8ffe68b80ad9c913d292936a5fde4b3d4..fe9f9d3877f3716f60ec42adc988a0458045413c 100644 |
| --- a/webrtc/video/vie_encoder_unittest.cc |
| +++ b/webrtc/video/vie_encoder_unittest.cc |
| @@ -1042,6 +1042,50 @@ TEST_F(ViEEncoderTest, SwitchingSourceKeepsQualityAdaptation) { |
| vie_encoder_->Stop(); |
| } |
| +TEST_F(ViEEncoderTest, QualityAdaptationStatsAreResetWhenScalerIsDisabled) { |
| + vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| + |
| + const int kWidth = 1280; |
| + const int kHeight = 720; |
| + video_source_.set_adaptation_enabled(true); |
| + video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight)); |
| + sink_.WaitForEncodedFrame(1); |
| + EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution); |
| + EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); |
| + EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes); |
| + |
| + // Trigger adapt down. |
| + vie_encoder_->TriggerQualityLow(); |
| + video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight)); |
| + sink_.WaitForEncodedFrame(2); |
| + EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution); |
| + EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution); |
| + EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes); |
| + |
| + // Trigger overuse. |
| + vie_encoder_->TriggerCpuOveruse(); |
| + video_source_.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight)); |
| + sink_.WaitForEncodedFrame(3); |
| + EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution); |
| + EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution); |
| + EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes); |
| + |
| + // Set new source with adaptation still enabled but quality scaler is off. |
| + fake_encoder_.SetQualityScaling(false); |
| + test::FrameForwarder new_video_source; |
|
kthelgason
2017/03/31 07:57:38
I guess the new source is technically not required
åsapersson
2017/03/31 09:53:38
Done.
|
| + vie_encoder_->SetSource( |
| + &new_video_source, |
| + VideoSendStream::DegradationPreference::kMaintainFramerate); |
| + |
| + new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight)); |
| + sink_.WaitForEncodedFrame(4); |
| + EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution); |
| + EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); |
| + EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes); |
| + |
| + vie_encoder_->Stop(); |
| +} |
| + |
| TEST_F(ViEEncoderTest, StatsTracksAdaptationStatsWhenSwitchingSource) { |
| vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |