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}
This commit is contained in:
parent
1bd66642c3
commit
731a2c2dc6
@ -175,6 +175,15 @@ int GetMaxDefaultBitrateBps(size_t width, size_t height) {
|
||||
}
|
||||
}
|
||||
|
||||
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, SupportsVideoRotationHeaderExtension) {
|
||||
}
|
||||
|
||||
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 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeCapturer) {
|
||||
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 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeAddSendStream) {
|
||||
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 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
|
||||
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 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
|
||||
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user