Convert webrtcvideoengine CVO tests away from cricket::VideoCapturer.
Bug: webrtc:6353
Change-Id: I1f4f705cda4fdf88465395898e2588b2a19eebf3
Reviewed-on: https://webrtc-review.googlesource.com/83324
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24142}
diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc
index cd8daf6..5361a95 100644
--- a/media/engine/webrtcvideoengine_unittest.cc
+++ b/media/engine/webrtcvideoengine_unittest.cc
@@ -175,6 +175,15 @@
}
}
+class MockVideoSource : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
+ public:
+ MOCK_METHOD2(AddOrUpdateSink,
+ void(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
+ const rtc::VideoSinkWants& wants));
+ MOCK_METHOD1(RemoveSink,
+ void(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink));
+};
+
} // namespace
#define EXPECT_FRAME_WAIT(c, w, h, t) \
@@ -300,9 +309,9 @@
}
TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeCapturer) {
- // Allocate the capturer first to prevent early destruction before channel's
+ // Allocate the source first to prevent early destruction before channel's
// dtor is called.
- FakeVideoCapturerWithTaskQueue capturer;
+ testing::NiceMock<MockVideoSource> video_source;
encoder_factory_->AddSupportedVideoCodecType("VP8");
@@ -318,22 +327,30 @@
RtpExtension(RtpExtension::kVideoRotationUri, id));
EXPECT_TRUE(channel->SetSendParameters(parameters));
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, false)));
// Set capturer.
- EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &capturer));
+ EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &video_source));
// Verify capturer has turned off applying rotation.
- EXPECT_FALSE(capturer.apply_rotation());
+ testing::Mock::VerifyAndClear(&video_source);
// Verify removing header extension turns on applying rotation.
parameters.extensions.clear();
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, true)));
+
EXPECT_TRUE(channel->SetSendParameters(parameters));
- EXPECT_TRUE(capturer.apply_rotation());
}
TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeAddSendStream) {
- // Allocate the capturer first to prevent early destruction before channel's
+ // Allocate the source first to prevent early destruction before channel's
// dtor is called.
- FakeVideoCapturerWithTaskQueue capturer;
+ testing::NiceMock<MockVideoSource> video_source;
encoder_factory_->AddSupportedVideoCodecType("VP8");
@@ -348,15 +365,16 @@
EXPECT_TRUE(channel->SetSendParameters(parameters));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
- // Set capturer.
- EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &capturer));
-
- // Verify capturer has turned off applying rotation.
- EXPECT_FALSE(capturer.apply_rotation());
+ // Set source.
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, false)));
+ EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &video_source));
}
TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
- FakeVideoCapturerWithTaskQueue capturer;
+ testing::NiceMock<MockVideoSource> video_source;
encoder_factory_->AddSupportedVideoCodecType("VP8");
encoder_factory_->AddSupportedVideoCodecType("VP9");
@@ -366,10 +384,14 @@
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
// Set capturer.
- EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &capturer));
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, true)));
+ EXPECT_TRUE(channel->SetVideoSend(kSsrc, nullptr, &video_source));
// Verify capturer has turned on applying rotation.
- EXPECT_TRUE(capturer.apply_rotation());
+ testing::Mock::VerifyAndClear(&video_source);
// Add CVO extension.
const int id = 1;
@@ -380,15 +402,22 @@
RtpExtension(RtpExtension::kVideoRotationUri, id));
// Also remove the first codec to trigger a codec change as well.
parameters.codecs.erase(parameters.codecs.begin());
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, false)));
EXPECT_TRUE(channel->SetSendParameters(parameters));
// Verify capturer has turned off applying rotation.
- EXPECT_FALSE(capturer.apply_rotation());
+ testing::Mock::VerifyAndClear(&video_source);
// Verify removing header extension turns on applying rotation.
parameters.extensions.clear();
+ EXPECT_CALL(
+ video_source,
+ AddOrUpdateSink(testing::_,
+ Field(&rtc::VideoSinkWants::rotation_applied, true)));
EXPECT_TRUE(channel->SetSendParameters(parameters));
- EXPECT_TRUE(capturer.apply_rotation());
}
TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) {