Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: webrtc/media/engine/webrtcvideoengine_unittest.cc

Issue 3008043002: Simplify passing video codec factories in media engine (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine_unittest.cc
diff --git a/webrtc/media/engine/webrtcvideoengine_unittest.cc b/webrtc/media/engine/webrtcvideoengine_unittest.cc
index 1306082abf8715b2733109ce4c3f2ad4c1f884cd..683ccd5747f3c34676596434c61c55be5eabbbf6 100644
--- a/webrtc/media/engine/webrtcvideoengine_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine_unittest.cc
@@ -147,7 +147,7 @@ class WebRtcVideoEngineTest : public ::testing::Test {
explicit WebRtcVideoEngineTest(const char* field_trials)
: override_field_trials_(field_trials),
call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
- engine_() {
+ engine_(&encoder_factory_, &decoder_factory_) {
std::vector<VideoCodec> engine_codecs = engine_.codecs();
RTC_DCHECK(!engine_codecs.empty());
bool codec_set = false;
@@ -172,11 +172,9 @@ class WebRtcVideoEngineTest : public ::testing::Test {
// present.
cricket::VideoCodec GetEngineCodec(const std::string& name);
- VideoMediaChannel* SetUpForExternalEncoderFactory(
- cricket::WebRtcVideoEncoderFactory* encoder_factory);
+ VideoMediaChannel* SetUpForExternalEncoderFactory();
VideoMediaChannel* SetUpForExternalDecoderFactory(
- cricket::WebRtcVideoDecoderFactory* decoder_factory,
const std::vector<VideoCodec>& codecs);
void TestExtendedEncoderOveruse(bool use_external_encoder);
@@ -186,6 +184,8 @@ class WebRtcVideoEngineTest : public ::testing::Test {
// Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly
// initialized when the constructor is called.
std::unique_ptr<webrtc::Call> call_;
+ cricket::FakeWebRtcVideoEncoderFactory encoder_factory_;
+ cricket::FakeWebRtcVideoDecoderFactory decoder_factory_;
WebRtcVideoEngine engine_;
VideoCodec default_codec_;
std::map<int, int> default_apt_rtx_types_;
@@ -273,11 +273,9 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeCapturer) {
// dtor is called.
cricket::FakeVideoCapturer capturer;
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
// Add CVO extension.
@@ -305,11 +303,9 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeAddSendStream) {
// dtor is called.
cricket::FakeVideoCapturer capturer;
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
// Add CVO extension.
const int id = 1;
cricket::VideoSendParameters parameters;
@@ -329,12 +325,10 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionBeforeAddSendStream) {
TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
cricket::FakeVideoCapturer capturer;
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
- encoder_factory.AddSupportedVideoCodecType("VP9");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP9");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
// Set capturer.
@@ -364,7 +358,6 @@ TEST_F(WebRtcVideoEngineTest, CVOSetHeaderExtensionAfterCapturer) {
}
TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) {
- engine_.Init();
std::unique_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
@@ -377,7 +370,6 @@ TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) {
}
TEST_F(WebRtcVideoEngineTest, GetStatsWithoutSendCodecsSetDoesNotCrash) {
- engine_.Init();
std::unique_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(123)));
@@ -386,16 +378,14 @@ TEST_F(WebRtcVideoEngineTest, GetStatsWithoutSendCodecsSetDoesNotCrash) {
}
TEST_F(WebRtcVideoEngineTest, UseExternalFactoryForVp8WhenSupported) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
channel->OnReadyToSend(true);
EXPECT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
- EXPECT_EQ(0, encoder_factory.GetNumCreatedEncoders());
+ EXPECT_EQ(0, encoder_factory_.GetNumCreatedEncoders());
EXPECT_TRUE(channel->SetSend(true));
cricket::FakeVideoCapturer capturer;
EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
@@ -403,11 +393,11 @@ TEST_F(WebRtcVideoEngineTest, UseExternalFactoryForVp8WhenSupported) {
capturer.Start(capturer.GetSupportedFormats()->front()));
EXPECT_TRUE(capturer.CaptureFrame());
// Sending one frame will have allocate the encoder.
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1));
- EXPECT_TRUE_WAIT(encoder_factory.encoders()[0]->GetNumEncodedFrames() > 0,
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(1));
+ EXPECT_TRUE_WAIT(encoder_factory_.encoders()[0]->GetNumEncodedFrames() > 0,
kTimeout);
- int num_created_encoders = encoder_factory.GetNumCreatedEncoders();
+ int num_created_encoders = encoder_factory_.GetNumCreatedEncoders();
EXPECT_EQ(num_created_encoders, 1);
// Setting codecs of the same type should not reallocate any encoders
@@ -415,11 +405,11 @@ TEST_F(WebRtcVideoEngineTest, UseExternalFactoryForVp8WhenSupported) {
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("VP8"));
EXPECT_TRUE(channel->SetSendParameters(parameters));
- EXPECT_EQ(num_created_encoders, encoder_factory.GetNumCreatedEncoders());
+ EXPECT_EQ(num_created_encoders, encoder_factory_.GetNumCreatedEncoders());
// Remove stream previously added to free the external encoder instance.
EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
- EXPECT_EQ(0u, encoder_factory.encoders().size());
+ EXPECT_EQ(0u, encoder_factory_.encoders().size());
}
// Test that when an external encoder factory supports a codec we don't
@@ -443,12 +433,9 @@ TEST_F(WebRtcVideoEngineTest, RtxCodecAddedForExternalCodec) {
h264_high.params[kH264FmtpProfileLevelId] = *ProfileLevelIdToString(
ProfileLevelId(webrtc::H264::kProfileHigh, kLevel1));
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodec(h264_constrained_baseline);
- encoder_factory.AddSupportedVideoCodec(h264_constrained_high);
- encoder_factory.AddSupportedVideoCodec(h264_high);
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodec(h264_constrained_baseline);
+ encoder_factory_.AddSupportedVideoCodec(h264_constrained_high);
+ encoder_factory_.AddSupportedVideoCodec(h264_high);
// First figure out what payload types the test codecs got assigned.
const std::vector<cricket::VideoCodec> codecs = engine_.codecs();
@@ -464,15 +451,13 @@ TEST_F(WebRtcVideoEngineTest, RtxCodecAddedForExternalCodec) {
void WebRtcVideoEngineTest::TestExtendedEncoderOveruse(
bool use_external_encoder) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
std::unique_ptr<VideoMediaChannel> channel;
FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
call_.reset(fake_call);
if (use_external_encoder) {
- channel.reset(SetUpForExternalEncoderFactory(&encoder_factory));
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
+ channel.reset(SetUpForExternalEncoderFactory());
} else {
- engine_.Init();
channel.reset(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
}
@@ -500,11 +485,9 @@ TEST_F(WebRtcVideoEngineTest, DisablesFullEncoderTimeForNonExternalEncoders) {
#if !defined(RTC_DISABLE_VP9)
TEST_F(WebRtcVideoEngineTest, CanConstructDecoderForVp9EncoderFactory) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP9");
+ encoder_factory_.AddSupportedVideoCodecType("VP9");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
EXPECT_TRUE(
channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
@@ -512,12 +495,10 @@ TEST_F(WebRtcVideoEngineTest, CanConstructDecoderForVp9EncoderFactory) {
#endif // !defined(RTC_DISABLE_VP9)
TEST_F(WebRtcVideoEngineTest, PropagatesInputFrameTimestamp) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
call_.reset(fake_call);
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
EXPECT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
@@ -578,16 +559,12 @@ cricket::VideoCodec WebRtcVideoEngineTest::GetEngineCodec(
return cricket::VideoCodec();
}
-VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalEncoderFactory(
- cricket::WebRtcVideoEncoderFactory* encoder_factory) {
- engine_.SetExternalEncoderFactory(encoder_factory);
- engine_.Init();
-
+VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalEncoderFactory() {
VideoMediaChannel* channel =
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions());
cricket::VideoSendParameters parameters;
// We need to look up the codec in the engine to get the correct payload type.
- for (const VideoCodec& codec : encoder_factory->supported_codecs())
+ for (const VideoCodec& codec : encoder_factory_.supported_codecs())
parameters.codecs.push_back(GetEngineCodec(codec.name));
EXPECT_TRUE(channel->SetSendParameters(parameters));
@@ -596,11 +573,7 @@ VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalEncoderFactory(
}
VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalDecoderFactory(
- cricket::WebRtcVideoDecoderFactory* decoder_factory,
const std::vector<VideoCodec>& codecs) {
- engine_.SetExternalDecoderFactory(decoder_factory);
- engine_.Init();
-
VideoMediaChannel* channel =
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions());
cricket::VideoRecvParameters parameters;
@@ -611,11 +584,9 @@ VideoMediaChannel* WebRtcVideoEngineTest::SetUpForExternalDecoderFactory(
}
TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
@@ -629,15 +600,15 @@ TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) {
capturer.Start(capturer.GetSupportedFormats()->front()));
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(2));
// Verify that encoders are configured for simulcast through adapter
// (increasing resolution and only configured to send one stream each).
int prev_width = -1;
- for (size_t i = 0; i < encoder_factory.encoders().size(); ++i) {
- ASSERT_TRUE(encoder_factory.encoders()[i]->WaitForInitEncode());
+ for (size_t i = 0; i < encoder_factory_.encoders().size(); ++i) {
+ ASSERT_TRUE(encoder_factory_.encoders()[i]->WaitForInitEncode());
webrtc::VideoCodec codec_settings =
- encoder_factory.encoders()[i]->GetCodecSettings();
+ encoder_factory_.encoders()[i]->GetCodecSettings();
EXPECT_EQ(0, codec_settings.numberOfSimulcastStreams);
EXPECT_GT(codec_settings.width, prev_width);
prev_width = codec_settings.width;
@@ -646,33 +617,27 @@ TEST_F(WebRtcVideoEngineTest, UsesSimulcastAdapterForVp8Factories) {
EXPECT_TRUE(channel->SetVideoSend(ssrcs.front(), true, nullptr, nullptr));
channel.reset();
- ASSERT_EQ(0u, encoder_factory.encoders().size());
+ ASSERT_EQ(0u, encoder_factory_.encoders().size());
}
TEST_F(WebRtcVideoEngineTest, ChannelWithExternalH264CanChangeToInternalVp8) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("H264");
+ encoder_factory_.AddSupportedVideoCodecType("H264");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
EXPECT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
- ASSERT_EQ(1u, encoder_factory.encoders().size());
+ ASSERT_EQ(1u, encoder_factory_.encoders().size());
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(GetEngineCodec("VP8"));
EXPECT_TRUE(channel->SetSendParameters(parameters));
- ASSERT_EQ(0u, encoder_factory.encoders().size());
+ ASSERT_EQ(0u, encoder_factory_.encoders().size());
}
TEST_F(WebRtcVideoEngineTest,
DontUseExternalEncoderFactoryForUnsupportedCodecs) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("H264");
-
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodecType("H264");
std::unique_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
@@ -683,17 +648,13 @@ TEST_F(WebRtcVideoEngineTest,
EXPECT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
// Make sure DestroyVideoEncoder was called on the factory.
- ASSERT_EQ(0u, encoder_factory.encoders().size());
+ ASSERT_EQ(0u, encoder_factory_.encoders().size());
}
TEST_F(WebRtcVideoEngineTest,
UsesSimulcastAdapterForVp8WithCombinedVP8AndH264Factory) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
- encoder_factory.AddSupportedVideoCodecType("H264");
-
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("H264");
std::unique_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
@@ -716,24 +677,20 @@ TEST_F(WebRtcVideoEngineTest,
capturer.Start(capturer.GetSupportedFormats()->front()));
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
- ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(2));
+ ASSERT_TRUE(encoder_factory_.encoders()[0]->WaitForInitEncode());
EXPECT_EQ(webrtc::kVideoCodecVP8,
- encoder_factory.encoders()[0]->GetCodecSettings().codecType);
+ encoder_factory_.encoders()[0]->GetCodecSettings().codecType);
channel.reset();
// Make sure DestroyVideoEncoder was called on the factory.
- EXPECT_EQ(0u, encoder_factory.encoders().size());
+ EXPECT_EQ(0u, encoder_factory_.encoders().size());
}
TEST_F(WebRtcVideoEngineTest,
DestroysNonSimulcastEncoderFromCombinedVP8AndH264Factory) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
- encoder_factory.AddSupportedVideoCodecType("H264");
-
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("H264");
std::unique_ptr<VideoMediaChannel> channel(
engine_.CreateChannel(call_.get(), GetMediaConfig(), VideoOptions()));
@@ -743,7 +700,7 @@ TEST_F(WebRtcVideoEngineTest,
EXPECT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
- ASSERT_EQ(1u, encoder_factory.encoders().size());
+ ASSERT_EQ(1u, encoder_factory_.encoders().size());
// Send a frame of 720p. This should trigger a "real" encoder initialization.
cricket::VideoFormat format(
@@ -752,21 +709,19 @@ TEST_F(WebRtcVideoEngineTest,
EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer));
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
+ ASSERT_TRUE(encoder_factory_.encoders()[0]->WaitForInitEncode());
EXPECT_EQ(webrtc::kVideoCodecH264,
- encoder_factory.encoders()[0]->GetCodecSettings().codecType);
+ encoder_factory_.encoders()[0]->GetCodecSettings().codecType);
channel.reset();
// Make sure DestroyVideoEncoder was called on the factory.
- ASSERT_EQ(0u, encoder_factory.encoders().size());
+ ASSERT_EQ(0u, encoder_factory_.encoders().size());
}
TEST_F(WebRtcVideoEngineTest, SimulcastDisabledForH264) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("H264");
+ encoder_factory_.AddSupportedVideoCodecType("H264");
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
EXPECT_TRUE(
@@ -780,9 +735,9 @@ TEST_F(WebRtcVideoEngineTest, SimulcastDisabledForH264) {
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(format));
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_EQ(1u, encoder_factory.encoders().size());
- FakeWebRtcVideoEncoder* encoder = encoder_factory.encoders()[0];
- ASSERT_TRUE(encoder_factory.encoders()[0]->WaitForInitEncode());
+ ASSERT_EQ(1u, encoder_factory_.encoders().size());
+ FakeWebRtcVideoEncoder* encoder = encoder_factory_.encoders()[0];
+ ASSERT_TRUE(encoder_factory_.encoders()[0]->WaitForInitEncode());
EXPECT_EQ(webrtc::kVideoCodecH264, encoder->GetCodecSettings().codecType);
EXPECT_EQ(1u, encoder->GetCodecSettings().numberOfSimulcastStreams);
EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr));
@@ -801,7 +756,6 @@ TEST_F(WebRtcVideoEngineTest,
};
// FlexFEC is not active without field trial.
- engine_.Init();
const std::vector<VideoCodec> codecs_before = engine_.codecs();
EXPECT_EQ(codecs_before.end(), std::find_if(codecs_before.begin(),
codecs_before.end(), is_flexfec));
@@ -816,10 +770,7 @@ TEST_F(WebRtcVideoEngineTest,
// Test that external codecs are added to the end of the supported codec list.
TEST_F(WebRtcVideoEngineTest, ReportSupportedExternalCodecs) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec");
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodecType("FakeExternalCodec");
std::vector<cricket::VideoCodec> codecs(engine_.codecs());
ASSERT_GE(codecs.size(), 2u);
@@ -835,42 +786,38 @@ TEST_F(WebRtcVideoEngineTest, ReportSupportedExternalCodecs) {
// does show up in the codec list after it was added.
TEST_F(WebRtcVideoEngineTest, ReportSupportedExternalCodecsWithAddedCodec) {
// Set up external encoder factory with first codec, and initialize engine.
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec1");
- engine_.SetExternalEncoderFactory(&encoder_factory);
- engine_.Init();
+ encoder_factory_.AddSupportedVideoCodecType("FakeExternalCodec1");
// The first external codec will appear last in the vector.
std::vector<cricket::VideoCodec> codecs_before(engine_.codecs());
EXPECT_EQ("FakeExternalCodec1", codecs_before.back().name);
// Add second codec.
- encoder_factory.AddSupportedVideoCodecType("FakeExternalCodec2");
+ encoder_factory_.AddSupportedVideoCodecType("FakeExternalCodec2");
std::vector<cricket::VideoCodec> codecs_after(engine_.codecs());
EXPECT_EQ(codecs_before.size() + 1, codecs_after.size());
EXPECT_EQ("FakeExternalCodec2", codecs_after.back().name);
}
TEST_F(WebRtcVideoEngineTest, RegisterExternalDecodersIfSupported) {
- cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
- decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
+ decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
cricket::VideoRecvParameters parameters;
parameters.codecs.push_back(GetEngineCodec("VP8"));
std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs));
+ SetUpForExternalDecoderFactory(parameters.codecs));
EXPECT_TRUE(
channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
- ASSERT_EQ(1u, decoder_factory.decoders().size());
+ ASSERT_EQ(1u, decoder_factory_.decoders().size());
// Setting codecs of the same type should not reallocate the decoder.
EXPECT_TRUE(channel->SetRecvParameters(parameters));
- EXPECT_EQ(1, decoder_factory.GetNumCreatedDecoders());
+ EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders());
// Remove stream previously added to free the external decoder instance.
EXPECT_TRUE(channel->RemoveRecvStream(kSsrc));
- EXPECT_EQ(0u, decoder_factory.decoders().size());
+ EXPECT_EQ(0u, decoder_factory_.decoders().size());
}
// Verifies that we can set up decoders that are not internally supported.
@@ -879,20 +826,17 @@ TEST_F(WebRtcVideoEngineTest, RegisterExternalH264DecoderIfSupported) {
// can't even query the WebRtcVideoDecoderFactory for supported codecs.
// For now we add a FakeWebRtcVideoEncoderFactory to add H264 to supported
// codecs.
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("H264");
- engine_.SetExternalEncoderFactory(&encoder_factory);
- cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
- decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecH264);
+ encoder_factory_.AddSupportedVideoCodecType("H264");
+ decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecH264);
std::vector<cricket::VideoCodec> codecs;
codecs.push_back(GetEngineCodec("H264"));
std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalDecoderFactory(&decoder_factory, codecs));
+ SetUpForExternalDecoderFactory(codecs));
EXPECT_TRUE(
channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
- ASSERT_EQ(1u, decoder_factory.decoders().size());
+ ASSERT_EQ(1u, decoder_factory_.decoders().size());
}
class WebRtcVideoChannelBaseTest
@@ -915,31 +859,28 @@ class WebRtcVideoChannelBaseTest
// Verifies that id given in stream params is passed to the decoder factory.
TEST_F(WebRtcVideoEngineTest, StreamParamsIdPassedToDecoderFactory) {
- cricket::FakeWebRtcVideoDecoderFactory decoder_factory;
- decoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
+ decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8);
cricket::VideoRecvParameters parameters;
parameters.codecs.push_back(GetEngineCodec("VP8"));
std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalDecoderFactory(&decoder_factory, parameters.codecs));
+ SetUpForExternalDecoderFactory(parameters.codecs));
StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc);
sp.id = "FakeStreamParamsId";
EXPECT_TRUE(channel->AddRecvStream(sp));
- EXPECT_EQ(1u, decoder_factory.decoders().size());
+ EXPECT_EQ(1u, decoder_factory_.decoders().size());
- std::vector<cricket::VideoDecoderParams> params = decoder_factory.params();
+ std::vector<cricket::VideoDecoderParams> params = decoder_factory_.params();
ASSERT_EQ(1u, params.size());
EXPECT_EQ(sp.id, params[0].receive_stream_id);
}
TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("VP8");
+ encoder_factory_.AddSupportedVideoCodecType("VP8");
std::unique_ptr<FakeCall> fake_call(
new FakeCall(webrtc::Call::Config(&event_log_)));
- std::unique_ptr<VideoMediaChannel> channel(
- SetUpForExternalEncoderFactory(&encoder_factory));
+ std::unique_ptr<VideoMediaChannel> channel(SetUpForExternalEncoderFactory());
ASSERT_TRUE(
channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
cricket::VideoCodec codec = GetEngineCodec("VP8");
@@ -956,14 +897,14 @@ TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1));
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(1));
EXPECT_EQ(webrtc::kRealtimeVideo,
- encoder_factory.encoders().back()->GetCodecSettings().mode);
+ encoder_factory_.encoders().back()->GetCodecSettings().mode);
EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
EXPECT_TRUE(capturer.CaptureFrame());
// No change in content type, keep current encoder.
- EXPECT_EQ(1, encoder_factory.GetNumCreatedEncoders());
+ EXPECT_EQ(1, encoder_factory_.GetNumCreatedEncoders());
options.is_screencast.emplace(true);
EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
@@ -971,14 +912,14 @@ TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
// Change to screen content, recreate encoder. For the simulcast encoder
// adapter case, this will result in two calls since InitEncode triggers a
// a new instance.
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(2));
EXPECT_EQ(webrtc::kScreensharing,
- encoder_factory.encoders().back()->GetCodecSettings().mode);
+ encoder_factory_.encoders().back()->GetCodecSettings().mode);
EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
EXPECT_TRUE(capturer.CaptureFrame());
// Still screen content, no need to update encoder.
- EXPECT_EQ(2, encoder_factory.GetNumCreatedEncoders());
+ EXPECT_EQ(2, encoder_factory_.GetNumCreatedEncoders());
options.is_screencast.emplace(false);
options.video_noise_reduction.emplace(false);
@@ -986,13 +927,13 @@ TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
// Change back to regular video content, update encoder. Also change
// a non |is_screencast| option just to verify it doesn't affect recreation.
EXPECT_TRUE(capturer.CaptureFrame());
- ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(3));
+ ASSERT_TRUE(encoder_factory_.WaitForCreatedVideoEncoders(3));
EXPECT_EQ(webrtc::kRealtimeVideo,
- encoder_factory.encoders().back()->GetCodecSettings().mode);
+ encoder_factory_.encoders().back()->GetCodecSettings().mode);
// Remove stream previously added to free the external encoder instance.
EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
- EXPECT_EQ(0u, encoder_factory.encoders().size());
+ EXPECT_EQ(0u, encoder_factory_.encoders().size());
}
#define WEBRTC_BASE_TEST(test) \
@@ -1060,7 +1001,6 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest {
: WebRtcVideoEngineTest(field_trials), last_ssrc_(0) {}
void SetUp() override {
fake_call_.reset(new FakeCall(webrtc::Call::Config(&event_log_)));
- engine_.Init();
channel_.reset(engine_.CreateChannel(fake_call_.get(), GetMediaConfig(),
VideoOptions()));
channel_->OnReadyToSend(true);
@@ -1979,19 +1919,11 @@ class Vp9SettingsTest : public WebRtcVideoChannelTest {
virtual ~Vp9SettingsTest() {}
protected:
- void SetUp() override {
- engine_.SetExternalEncoderFactory(&encoder_factory_);
-
- WebRtcVideoChannelTest::SetUp();
- }
-
void TearDown() override {
// Remove references to encoder_factory_ since this will be destroyed
// before channel_ and engine_.
ASSERT_TRUE(channel_->SetSendParameters(send_parameters_));
}
-
- cricket::FakeWebRtcVideoEncoderFactory encoder_factory_;
};
TEST_F(Vp9SettingsTest, VerifyVp9SpecificSettings) {
@@ -4498,10 +4430,11 @@ TEST_F(WebRtcVideoChannelTest, ConfiguresLocalSsrcOnExistingReceivers) {
class WebRtcVideoChannelSimulcastTest : public testing::Test {
public:
WebRtcVideoChannelSimulcastTest()
- : fake_call_(webrtc::Call::Config(&event_log_)), last_ssrc_(0) {}
+ : fake_call_(webrtc::Call::Config(&event_log_)),
+ engine_(&encoder_factory_, &decoder_factory_),
+ last_ssrc_(0) {}
void SetUp() override {
- engine_.Init();
channel_.reset(
engine_.CreateChannel(&fake_call_, GetMediaConfig(), VideoOptions()));
channel_->OnReadyToSend(true);
@@ -4657,6 +4590,8 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test {
webrtc::RtcEventLogNullImpl event_log_;
FakeCall fake_call_;
+ cricket::FakeWebRtcVideoEncoderFactory encoder_factory_;
+ cricket::FakeWebRtcVideoDecoderFactory decoder_factory_;
WebRtcVideoEngine engine_;
std::unique_ptr<VideoMediaChannel> channel_;
uint32_t last_ssrc_;
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698