diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index dbf55af6ca..d58a7a7d2a 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -463,7 +463,7 @@ void SimulcastEncoderAdapter::PopulateStreamCodec( stream_codec->qpMax = inst.simulcastStream[stream_index].qpMax; // Settings that are based on stream/resolution. const bool lowest_resolution_stream = (stream_index == 0); - if (lowest_resolution_stream) { + if (lowest_resolution_stream && inst.mode != VideoCodecMode::kScreensharing) { // Settings for lowest spatial resolutions. stream_codec->qpMax = kLowestResMaxQp; } diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc index a352887321..5f1eebe0d0 100644 --- a/media/engine/simulcast_encoder_adapter_unittest.cc +++ b/media/engine/simulcast_encoder_adapter_unittest.cc @@ -872,5 +872,36 @@ TEST_F(TestSimulcastEncoderAdapterFake, TestInitFailureCleansUpEncoders) { EXPECT_TRUE(helper_->factory()->encoders().empty()); } +TEST_F(TestSimulcastEncoderAdapterFake, DoesNotAlterMaxQpForScreenshare) { + const int kHighMaxQp = 56; + const int kLowMaxQp = 46; + + SimulcastTestFixtureImpl::DefaultSettings( + &codec_, static_cast(kTestTemporalLayerProfile), + kVideoCodecVP8); + codec_.numberOfSimulcastStreams = 3; + codec_.simulcastStream[0].qpMax = kHighMaxQp; + codec_.mode = VideoCodecMode::kScreensharing; + + EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); + EXPECT_EQ(3u, helper_->factory()->encoders().size()); + + // Just check the lowest stream, which is the one that where the adapter + // might alter the max qp setting. + VideoCodec ref_codec; + InitRefCodec(0, &ref_codec); + ref_codec.qpMax = kHighMaxQp; + ref_codec.VP8()->complexity = webrtc::VideoCodecComplexity::kComplexityHigher; + ref_codec.VP8()->denoisingOn = false; + ref_codec.startBitrate = 100; // Should equal to the target bitrate. + VerifyCodec(ref_codec, 0); + + // Change the max qp and try again. + codec_.simulcastStream[0].qpMax = kLowMaxQp; + EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200)); + EXPECT_EQ(3u, helper_->factory()->encoders().size()); + ref_codec.qpMax = kLowMaxQp; + VerifyCodec(ref_codec, 0); +} } // namespace test } // namespace webrtc