diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index dd8de11ba9..3eaa287a94 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -1416,8 +1416,12 @@ void WebRtcVideoChannel2::OnLoadUpdate(Load load) { rtc::CritScope stream_lock(&capturer_crit_); if (!signal_cpu_adaptation_) return; + // Do not adapt resolution for screen content as this will likely result in + // blurry and unreadable text. for (auto& kv : capturers_) { - if (kv.second != nullptr && kv.second->video_adapter() != nullptr) { + if (kv.second != nullptr + && !kv.second->IsScreencast() + && kv.second->video_adapter() != nullptr) { kv.second->video_adapter()->OnCpuResolutionRequest( load == kOveruse ? CoordinatedVideoAdapter::DOWNGRADE : CoordinatedVideoAdapter::UPGRADE); diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index 54e52c2260..7bcab55744 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -973,7 +973,7 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test, EXPECT_EQ(webrtc_ext, recv_stream->GetConfig().rtp.extensions[0].name); } - void TestCpuAdaptation(bool enable_overuse); + void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); FakeVideoSendStream* SetDenoisingOption(bool enabled) { VideoOptions options; @@ -1644,14 +1644,19 @@ TEST_F(WebRtcVideoChannel2Test, DISABLED_SendReceiveBitratesStats) { } TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { - TestCpuAdaptation(true); + TestCpuAdaptation(true, false); } TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { - TestCpuAdaptation(false); + TestCpuAdaptation(false, false); } -void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) { +TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { + TestCpuAdaptation(true, true); +} + +void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, + bool is_screenshare) { cricket::VideoCodec codec = kVp8Codec720p; std::vector codecs; codecs.push_back(codec); @@ -1666,6 +1671,7 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) { AddSendStream(); cricket::FakeVideoCapturer capturer; + capturer.SetScreencast(is_screenshare); EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capturer.GetSupportedFormats()->front())); @@ -1684,7 +1690,7 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse) { EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); - if (enable_overuse) { + if (enable_overuse && !is_screenshare) { EXPECT_LT(send_stream->GetLastWidth(), codec.width); EXPECT_LT(send_stream->GetLastHeight(), codec.height); } else {