Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
index ea8a300395121671af007f2dbdd74b41187114aa..2f5d4a6c1683446faf86197361187a022f5b9442 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc |
@@ -1472,7 +1472,6 @@ TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
AddSendStream(); |
cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(false); |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
cricket::VideoFormat capture_format_hd = |
capturer.GetSupportedFormats()->front(); |
@@ -1500,9 +1499,15 @@ TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); |
// Removing a capturer triggers a black frame to be sent. |
EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
- capturer.SetScreencast(true); |
- EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
- EXPECT_TRUE(capturer.CaptureFrame()); |
+ |
+ FakeVideoCapturer screencast_capturer(true); |
+ EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &screencast_capturer)); |
+ EXPECT_EQ(cricket::CS_RUNNING, screencast_capturer.Start(capture_format_hd)); |
+ parameters.options.is_screencast = rtc::Optional<bool>(true); |
+ EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
+ EXPECT_TRUE(screencast_capturer.CaptureFrame()); |
+ // Send stream not recreated after option change. |
+ ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); |
EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
// Verify screencast settings. |
@@ -1519,17 +1524,56 @@ TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
} |
+TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { |
+ EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
nisse-webrtc
2016/03/01 13:24:40
Maybe this test is somewhat redundant, behavior is
nisse-webrtc
2016/03/02 08:09:51
Something is broken, and the tests too...
First,
|
+ ASSERT_TRUE( |
+ channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
+ EXPECT_TRUE(channel_->SetSend(true)); |
+ |
+ cricket::FakeVideoCapturer capturer; |
+ EXPECT_TRUE(channel_->SetCapturer(kSsrc, &capturer)); |
+ EXPECT_EQ(cricket::CS_RUNNING, |
+ capturer.Start(capturer.GetSupportedFormats()->front())); |
+ EXPECT_TRUE(capturer.CaptureFrame()); |
+ |
+ ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); |
+ FakeVideoSendStream* stream1 = fake_call_->GetVideoSendStreams().front(); |
+ webrtc::VideoEncoderConfig encoder_config = stream1->GetEncoderConfig(); |
+ EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, |
+ encoder_config.content_type); |
+ |
+ EXPECT_EQ(1, stream1->GetNumberOfSwappedFrames()); |
+ |
+ /* Switch to screencast source. We expect a reconfigure of the |
+ * encoder, but no change of the send stream. */ |
+ struct VideoOptions video_options; |
+ video_options.is_screencast = rtc::Optional<bool>(true); |
+ channel_->SetVideoSend(kSsrc, true, &video_options); |
+ |
+ EXPECT_TRUE(capturer.CaptureFrame()); |
+ ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); |
+ FakeVideoSendStream* stream2 = fake_call_->GetVideoSendStreams().front(); |
+ EXPECT_EQ(stream1, stream2); |
+ EXPECT_EQ(2, stream2->GetNumberOfSwappedFrames()); |
+ |
+ encoder_config = stream2->GetEncoderConfig(); |
+ EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, |
+ encoder_config.content_type); |
+ |
+ EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
+} |
pbos-webrtc
2016/03/01 16:11:36
Should we check switching from screencast? I think
|
+ |
TEST_F(WebRtcVideoChannel2Test, |
ConferenceModeScreencastConfiguresTemporalLayer) { |
static const int kConferenceScreencastTemporalBitrateBps = |
ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; |
send_parameters_.conference_mode = true; |
+ send_parameters_.options.is_screencast = rtc::Optional<bool>(true); |
channel_->SetSendParameters(send_parameters_); |
AddSendStream(); |
- cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(true); |
+ cricket::FakeVideoCapturer capturer(true); |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
cricket::VideoFormat capture_format_hd = |
capturer.GetSupportedFormats()->front(); |
@@ -1599,8 +1643,7 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { |
// both RTX and regular SSRCs). |
FakeVideoSendStream* stream = SetUpSimulcast(false, true); |
- cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(false); |
+ cricket::FakeVideoCapturer capturer(false); |
EXPECT_EQ(cricket::CS_RUNNING, |
capturer.Start(capturer.GetSupportedFormats()->front())); |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
@@ -1640,11 +1683,14 @@ TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { |
EXPECT_TRUE(vp8_settings.frameDroppingOn); |
// In screen-share mode, denoising is forced off and simulcast disabled. |
- EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
- capturer.SetScreencast(true); |
- EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
- EXPECT_TRUE(capturer.CaptureFrame()); |
- stream = SetDenoisingOption(parameters, &capturer, false); |
+ FakeVideoCapturer screencast_capturer(true); |
+ EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &screencast_capturer)); |
+ EXPECT_EQ(cricket::CS_RUNNING, screencast_capturer.Start( |
+ screencast_capturer.GetSupportedFormats()->front())); |
+ parameters.options.is_screencast = rtc::Optional<bool>(true); |
+ EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
+ |
+ stream = SetDenoisingOption(parameters, &screencast_capturer, false); |
EXPECT_EQ(1, stream->GetVideoStreams().size()); |
ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
@@ -1693,8 +1739,7 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { |
FakeVideoSendStream* stream = SetUpSimulcast(false, false); |
- cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(false); |
+ cricket::FakeVideoCapturer capturer(false); |
EXPECT_EQ(cricket::CS_RUNNING, |
capturer.Start(capturer.GetSupportedFormats()->front())); |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
@@ -1721,12 +1766,14 @@ TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) { |
EXPECT_TRUE(vp9_settings.frameDroppingOn); |
// In screen-share mode, denoising is forced off. |
- EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); |
- capturer.SetScreencast(true); |
- EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
+ FakeVideoCapturer screencast_capturer(true); |
+ EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &screencast_capturer)); |
+ EXPECT_EQ(cricket::CS_RUNNING, screencast_capturer.Start( |
+ screencast_capturer.GetSupportedFormats()->front())); |
+ parameters.options.is_screencast = rtc::Optional<bool>(true); |
+ EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
- EXPECT_TRUE(capturer.CaptureFrame()); |
- stream = SetDenoisingOption(parameters, &capturer, false); |
+ stream = SetDenoisingOption(parameters, &screencast_capturer, false); |
ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
EXPECT_FALSE(vp9_settings.denoisingOn); |
@@ -1767,7 +1814,6 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { |
AddSendStream(); |
cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(false); |
ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
ASSERT_EQ(cricket::CS_RUNNING, |
capturer.Start(capturer.GetSupportedFormats()->front())); |
@@ -1838,8 +1884,7 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
AddSendStream(); |
- cricket::FakeVideoCapturer capturer; |
- capturer.SetScreencast(is_screenshare); |
+ cricket::FakeVideoCapturer capturer(is_screenshare); |
EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
EXPECT_EQ(cricket::CS_RUNNING, |
capturer.Start(capturer.GetSupportedFormats()->front())); |