Remove webrtc::VideoEncoderFactory
Replace the use of webrtc::VideoEncoderFactory with
cricket::WebRtcVideoEncoderFactory and remove the adapter classes
between these two factory types.
Some code changes were necessary in order to accomplish this:
* Move SimulcastEncoderAdapter from
webrtc/modules/video_coding/codecs/vp8 to webrtc/media/engine (that's
where it's used).
* Rename simulcast_unittest.h to simulcast_test_utility.h and make it
into it's own target, because it's used from both
simulcast_unittest.cc and simulcast_encoder_adapter_unittest.cc.
* Remove ownership of the encoder factory from SimulcastEncoderAdapter,
and make the necessary changes in surrounding code.
The goal with this CL is to clean up the code, and also to free up
the name webrtc::VideoEncoderFactory for future use.
BUG=webrtc:7925
Review-Url: https://codereview.webrtc.org/2964953002
Cr-Commit-Position: refs/heads/master@{#18945}
diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn
index c9055c8..fad410b 100644
--- a/webrtc/media/BUILD.gn
+++ b/webrtc/media/BUILD.gn
@@ -143,6 +143,8 @@
"engine/payload_type_mapper.h",
"engine/simulcast.cc",
"engine/simulcast.h",
+ "engine/simulcast_encoder_adapter.cc",
+ "engine/simulcast_encoder_adapter.h",
"engine/videodecodersoftwarefallbackwrapper.cc",
"engine/videodecodersoftwarefallbackwrapper.h",
"engine/videoencodersoftwarefallbackwrapper.cc",
@@ -228,6 +230,7 @@
"../base:rtc_base",
"../base:rtc_base_approved",
"../base:rtc_task_queue",
+ "../base:sequenced_task_checker",
"../call",
"../common_video:common_video",
"../modules/audio_coding:rent_a_codec",
@@ -436,6 +439,7 @@
"engine/internaldecoderfactory_unittest.cc",
"engine/nullwebrtcvideoengine_unittest.cc",
"engine/payload_type_mapper_unittest.cc",
+ "engine/simulcast_encoder_adapter_unittest.cc",
"engine/simulcast_unittest.cc",
"engine/videodecodersoftwarefallbackwrapper_unittest.cc",
"engine/videoencodersoftwarefallbackwrapper_unittest.cc",
@@ -513,6 +517,7 @@
"../logging:rtc_event_log_api",
"../modules/audio_device:mock_audio_device",
"../modules/audio_processing:audio_processing",
+ "../modules/video_coding:simulcast_test_utility",
"../modules/video_coding:video_coding_utility",
"../modules/video_coding:webrtc_vp8",
"../p2p:p2p_test_utils",
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc b/webrtc/media/engine/simulcast_encoder_adapter.cc
similarity index 97%
rename from webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
rename to webrtc/media/engine/simulcast_encoder_adapter.cc
index dbf8b25..c33dfdd 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
+++ b/webrtc/media/engine/simulcast_encoder_adapter.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
#include <algorithm>
@@ -126,7 +126,8 @@
namespace webrtc {
-SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory)
+SimulcastEncoderAdapter::SimulcastEncoderAdapter(
+ cricket::WebRtcVideoEncoderFactory* factory)
: inited_(0),
factory_(factory),
encoded_complete_callback_(nullptr),
@@ -236,14 +237,14 @@
encoder = stored_encoders_.top();
stored_encoders_.pop();
} else {
- encoder = factory_->Create();
+ encoder = factory_->CreateVideoEncoder(cricket::VideoCodec("VP8"));
}
ret = encoder->InitEncode(&stream_codec, number_of_cores, max_payload_size);
if (ret < 0) {
// Explicitly destroy the current encoder; because we haven't registered a
// StreamInfo for it yet, Release won't do anything about it.
- factory_->Destroy(encoder);
+ factory_->DestroyVideoEncoder(encoder);
Release();
return ret;
}
@@ -500,7 +501,7 @@
void SimulcastEncoderAdapter::DestroyStoredEncoders() {
while (!stored_encoders_.empty()) {
VideoEncoder* encoder = stored_encoders_.top();
- factory_->Destroy(encoder);
+ factory_->DestroyVideoEncoder(encoder);
stored_encoders_.pop();
}
}
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h b/webrtc/media/engine/simulcast_encoder_adapter.h
similarity index 83%
rename from webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h
rename to webrtc/media/engine/simulcast_encoder_adapter.h
index 784c274..68af74a 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h
+++ b/webrtc/media/engine/simulcast_encoder_adapter.h
@@ -9,8 +9,8 @@
*
*/
-#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_
-#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_
+#ifndef WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
+#define WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
#include <memory>
#include <stack>
@@ -18,6 +18,7 @@
#include <utility>
#include <vector>
+#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#include "webrtc/rtc_base/atomicops.h"
#include "webrtc/rtc_base/sequenced_task_checker.h"
@@ -26,24 +27,13 @@
class SimulcastRateAllocator;
-// TODO(brandtr): Remove this class and replace its use with a
-// WebRtcVideoEncoderFactory.
-class VideoEncoderFactory {
- public:
- virtual VideoEncoder* Create() = 0;
- virtual void Destroy(VideoEncoder* encoder) = 0;
- virtual ~VideoEncoderFactory() {}
-};
-
// SimulcastEncoderAdapter implements simulcast support by creating multiple
// webrtc::VideoEncoder instances with the given VideoEncoderFactory.
// The object is created and destroyed on the worker thread, but all public
// interfaces should be called from the encoder task queue.
class SimulcastEncoderAdapter : public VP8Encoder {
public:
- // TODO(brandtr): Make it clear that the ownership of |factory| is transferred
- // by only accepting a std::unique_ptr<VideoEncoderFactory> here.
- explicit SimulcastEncoderAdapter(VideoEncoderFactory* factory);
+ explicit SimulcastEncoderAdapter(cricket::WebRtcVideoEncoderFactory* factory);
virtual ~SimulcastEncoderAdapter();
// Implements VideoEncoder.
@@ -107,7 +97,7 @@
void DestroyStoredEncoders();
volatile int inited_; // Accessed atomically.
- const std::unique_ptr<VideoEncoderFactory> factory_;
+ cricket::WebRtcVideoEncoderFactory* const factory_;
VideoCodec codec_;
std::vector<StreamInfo> streaminfos_;
EncodedImageCallback* encoded_complete_callback_;
@@ -123,4 +113,4 @@
} // namespace webrtc
-#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_ENCODER_ADAPTER_H_
+#endif // WEBRTC_MEDIA_ENGINE_SIMULCAST_ENCODER_ADAPTER_H_
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc b/webrtc/media/engine/simulcast_encoder_adapter_unittest.cc
similarity index 94%
rename from webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
rename to webrtc/media/engine/simulcast_encoder_adapter_unittest.cc
index b8ece61..7865e5f 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
+++ b/webrtc/media/engine/simulcast_encoder_adapter_unittest.cc
@@ -13,8 +13,8 @@
#include <vector>
#include "webrtc/common_video/include/video_frame_buffer.h"
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
+#include "webrtc/modules/video_coding/codecs/vp8/simulcast_test_utility.h"
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
#include "webrtc/test/gmock.h"
@@ -23,22 +23,39 @@
class TestSimulcastEncoderAdapter : public TestVp8Simulcast {
public:
- TestSimulcastEncoderAdapter()
- : TestVp8Simulcast(new SimulcastEncoderAdapter(new Vp8EncoderFactory()),
- VP8Decoder::Create()) {}
+ TestSimulcastEncoderAdapter() : factory_(new Vp8EncoderFactory()) {}
protected:
- class Vp8EncoderFactory : public VideoEncoderFactory {
+ class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory {
public:
- VideoEncoder* Create() override { return VP8Encoder::Create(); }
+ Vp8EncoderFactory() {
+ supported_codecs_.push_back(cricket::VideoCodec("VP8"));
+ }
- void Destroy(VideoEncoder* encoder) override { delete encoder; }
+ const std::vector<cricket::VideoCodec>& supported_codecs() const override {
+ return supported_codecs_;
+ }
+
+ VideoEncoder* CreateVideoEncoder(
+ const cricket::VideoCodec& codec) override {
+ return VP8Encoder::Create();
+ }
+
+ void DestroyVideoEncoder(VideoEncoder* encoder) override { delete encoder; }
virtual ~Vp8EncoderFactory() {}
+
+ private:
+ std::vector<cricket::VideoCodec> supported_codecs_;
};
- virtual void SetUp() { TestVp8Simulcast::SetUp(); }
- virtual void TearDown() { TestVp8Simulcast::TearDown(); }
+ VP8Encoder* CreateEncoder() override {
+ return new SimulcastEncoderAdapter(factory_.get());
+ }
+ VP8Decoder* CreateDecoder() override { return VP8Decoder::Create(); }
+
+ private:
+ std::unique_ptr<Vp8EncoderFactory> factory_;
};
TEST_F(TestSimulcastEncoderAdapter, TestKeyFrameRequestsOnAllStreams) {
@@ -167,11 +184,18 @@
EncodedImageCallback* callback_;
};
-class MockVideoEncoderFactory : public VideoEncoderFactory {
+class MockVideoEncoderFactory : public cricket::WebRtcVideoEncoderFactory {
public:
- VideoEncoder* Create() override {
- MockVideoEncoder* encoder = new
- ::testing::NiceMock<MockVideoEncoder>();
+ MockVideoEncoderFactory() {
+ supported_codecs_.push_back(cricket::VideoCodec("VP8"));
+ }
+
+ const std::vector<cricket::VideoCodec>& supported_codecs() const override {
+ return supported_codecs_;
+ }
+
+ VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override {
+ MockVideoEncoder* encoder = new ::testing::NiceMock<MockVideoEncoder>();
encoder->set_init_encode_return_value(init_encode_return_value_);
const char* encoder_name = encoder_names_.empty()
? "codec_implementation_name"
@@ -181,7 +205,7 @@
return encoder;
}
- void Destroy(VideoEncoder* encoder) override {
+ void DestroyVideoEncoder(VideoEncoder* encoder) override {
for (size_t i = 0; i < encoders_.size(); ++i) {
if (encoders_[i] == encoder) {
encoders_.erase(encoders_.begin() + i);
@@ -202,6 +226,7 @@
}
private:
+ std::vector<cricket::VideoCodec> supported_codecs_;
int32_t init_encode_return_value_ = 0;
std::vector<MockVideoEncoder*> encoders_;
std::vector<const char*> encoder_names_;
@@ -215,7 +240,7 @@
// Can only be called once as the SimulcastEncoderAdapter will take the
// ownership of |factory_|.
VP8Encoder* CreateMockEncoderAdapter() {
- return new SimulcastEncoderAdapter(factory_);
+ return new SimulcastEncoderAdapter(factory_.get());
}
void ExpectCallSetChannelParameters(uint32_t packetLoss, int64_t rtt) {
@@ -227,10 +252,10 @@
}
}
- MockVideoEncoderFactory* factory() { return factory_; }
+ MockVideoEncoderFactory* factory() { return factory_.get(); }
private:
- MockVideoEncoderFactory* factory_;
+ std::unique_ptr<MockVideoEncoderFactory> factory_;
};
static const int kTestTemporalLayerProfile[3] = {3, 2, 1};
diff --git a/webrtc/media/engine/webrtcvideoengine.cc b/webrtc/media/engine/webrtcvideoengine.cc
index 55de5ae..b644732 100644
--- a/webrtc/media/engine/webrtcvideoengine.cc
+++ b/webrtc/media/engine/webrtcvideoengine.cc
@@ -25,12 +25,12 @@
#include "webrtc/media/engine/internaldecoderfactory.h"
#include "webrtc/media/engine/internalencoderfactory.h"
#include "webrtc/media/engine/simulcast.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
#include "webrtc/media/engine/videodecodersoftwarefallbackwrapper.h"
#include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h"
#include "webrtc/media/engine/webrtcmediaengine.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
#include "webrtc/media/engine/webrtcvoiceengine.h"
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
#include "webrtc/rtc_base/copyonwritebuffer.h"
#include "webrtc/rtc_base/logging.h"
#include "webrtc/rtc_base/stringutils.h"
@@ -62,28 +62,6 @@
return webrtc::field_trial::IsEnabled("WebRTC-VideoContentTypeExtension");
}
-// Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory.
-class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory {
- public:
- // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned
- // by e.g. PeerConnectionFactory.
- explicit EncoderFactoryAdapter(cricket::WebRtcVideoEncoderFactory* factory)
- : factory_(factory) {}
- virtual ~EncoderFactoryAdapter() {}
-
- // Implement webrtc::VideoEncoderFactory.
- webrtc::VideoEncoder* Create() override {
- return factory_->CreateVideoEncoder(VideoCodec(kVp8CodecName));
- }
-
- void Destroy(webrtc::VideoEncoder* encoder) override {
- return factory_->DestroyVideoEncoder(encoder);
- }
-
- private:
- cricket::WebRtcVideoEncoderFactory* const factory_;
-};
-
// An encoder factory that wraps Create requests for simulcastable codec types
// with a webrtc::SimulcastEncoderAdapter. Non simulcastable codec type
// requests are just passed through to the contained encoder factory.
@@ -113,8 +91,7 @@
RTC_DCHECK(factory_ != NULL);
// If it's a codec type we can simulcast, create a wrapped encoder.
if (CodecNamesEq(codec.name.c_str(), kVp8CodecName)) {
- return new webrtc::SimulcastEncoderAdapter(
- new EncoderFactoryAdapter(factory_));
+ return new webrtc::SimulcastEncoderAdapter(factory_);
}
webrtc::VideoEncoder* encoder = factory_->CreateVideoEncoder(codec);
if (encoder) {
diff --git a/webrtc/modules/video_coding/BUILD.gn b/webrtc/modules/video_coding/BUILD.gn
index d333264..67c8ccd 100644
--- a/webrtc/modules/video_coding/BUILD.gn
+++ b/webrtc/modules/video_coding/BUILD.gn
@@ -212,8 +212,6 @@
"codecs/vp8/include/vp8_common_types.h",
"codecs/vp8/screenshare_layers.cc",
"codecs/vp8/screenshare_layers.h",
- "codecs/vp8/simulcast_encoder_adapter.cc",
- "codecs/vp8/simulcast_encoder_adapter.h",
"codecs/vp8/simulcast_rate_allocator.cc",
"codecs/vp8/simulcast_rate_allocator.h",
"codecs/vp8/temporal_layers.h",
@@ -279,6 +277,27 @@
}
if (rtc_include_tests) {
+ rtc_source_set("simulcast_test_utility") {
+ testonly = true
+ sources = [
+ "codecs/vp8/simulcast_test_utility.h",
+ ]
+
+ if (!build_with_chromium && is_clang) {
+ # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
+ suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
+ }
+
+ deps = [
+ ":video_coding",
+ ":webrtc_vp8",
+ "../../api:video_frame_api",
+ "../../base:rtc_base_approved",
+ "../../common_video:common_video",
+ "../../test:test_support",
+ ]
+ }
+
rtc_executable("video_quality_measurement") {
testonly = true
@@ -508,9 +527,7 @@
"codecs/test/videoprocessor_unittest.cc",
"codecs/vp8/default_temporal_layers_unittest.cc",
"codecs/vp8/screenshare_layers_unittest.cc",
- "codecs/vp8/simulcast_encoder_adapter_unittest.cc",
"codecs/vp8/simulcast_unittest.cc",
- "codecs/vp8/simulcast_unittest.h",
"decoding_state_unittest.cc",
"frame_buffer2_unittest.cc",
"generic_encoder_unittest.cc",
@@ -547,6 +564,7 @@
sources += [ "codecs/h264/h264_encoder_impl_unittest.cc" ]
}
deps = [
+ ":simulcast_test_utility",
":video_codecs_test_framework",
":video_coding",
":video_coding_utility",
diff --git a/webrtc/modules/video_coding/DEPS b/webrtc/modules/video_coding/DEPS
index 8399d79..9896c19 100644
--- a/webrtc/modules/video_coding/DEPS
+++ b/webrtc/modules/video_coding/DEPS
@@ -4,7 +4,6 @@
"+vpx",
"+webrtc/base",
"+webrtc/common_video",
- "+webrtc/media/base",
"+webrtc/system_wrappers",
"+webrtc/rtc_tools",
]
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h b/webrtc/modules/video_coding/codecs/vp8/simulcast_test_utility.h
similarity index 98%
rename from webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h
rename to webrtc/modules/video_coding/codecs/vp8/simulcast_test_utility.h
index 69b55e5..7d1cabf 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_test_utility.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_
-#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_
+#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_
+#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_
#include <algorithm>
#include <map>
@@ -161,9 +161,6 @@
class TestVp8Simulcast : public ::testing::Test {
public:
- TestVp8Simulcast(VP8Encoder* encoder, VP8Decoder* decoder)
- : encoder_(encoder), decoder_(decoder) {}
-
static void SetPlane(uint8_t* data,
uint8_t value,
int width,
@@ -244,11 +241,20 @@
}
protected:
- void SetUp() override { SetUpCodec(kDefaultTemporalLayerProfile); }
+ virtual VP8Encoder* CreateEncoder() = 0;
+ virtual VP8Decoder* CreateDecoder() = 0;
+
+ void SetUp() override {
+ encoder_.reset(CreateEncoder());
+ decoder_.reset(CreateDecoder());
+ SetUpCodec(kDefaultTemporalLayerProfile);
+ }
void TearDown() override {
encoder_->Release();
decoder_->Release();
+ encoder_.reset();
+ decoder_.reset();
}
void SetUpCodec(const int* temporal_layer_profile) {
@@ -746,4 +752,4 @@
} // namespace testing
} // namespace webrtc
-#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_
+#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.cc
index 9d919cd..1120fe0 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.cc
@@ -8,19 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h"
+#include "webrtc/modules/video_coding/codecs/vp8/simulcast_test_utility.h"
namespace webrtc {
namespace testing {
class TestVp8Impl : public TestVp8Simulcast {
- public:
- TestVp8Impl()
- : TestVp8Simulcast(VP8Encoder::Create(), VP8Decoder::Create()) {}
-
protected:
- virtual void SetUp() { TestVp8Simulcast::SetUp(); }
- virtual void TearDown() { TestVp8Simulcast::TearDown(); }
+ VP8Encoder* CreateEncoder() override { return VP8Encoder::Create(); }
+ VP8Decoder* CreateDecoder() override { return VP8Decoder::Create(); }
};
TEST_F(TestVp8Impl, TestKeyFrameRequestsOnAllStreams) {
diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc
index 4501987..106b513 100644
--- a/webrtc/video/end_to_end_tests.cc
+++ b/webrtc/video/end_to_end_tests.cc
@@ -22,6 +22,7 @@
#include "webrtc/media/base/fakevideorenderer.h"
#include "webrtc/media/base/mediaconstants.h"
#include "webrtc/media/engine/internalencoderfactory.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
@@ -32,7 +33,6 @@
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
#include "webrtc/rtc_base/checks.h"
diff --git a/webrtc/video/picture_id_tests.cc b/webrtc/video/picture_id_tests.cc
index fe39a94..a1cb405 100644
--- a/webrtc/video/picture_id_tests.cc
+++ b/webrtc/video/picture_id_tests.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/media/engine/internalencoderfactory.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
#include "webrtc/modules/video_coding/sequence_number_util.h"
#include "webrtc/test/call_test.h"
@@ -291,32 +291,10 @@
TestPictureIdContinuousAfterReconfigure(ssrc_counts);
}
-class VideoEncoderFactoryAdapter : public webrtc::VideoEncoderFactory {
- public:
- explicit VideoEncoderFactoryAdapter(
- cricket::WebRtcVideoEncoderFactory* factory)
- : factory_(factory) {}
- virtual ~VideoEncoderFactoryAdapter() {}
-
- // Implements webrtc::VideoEncoderFactory.
- webrtc::VideoEncoder* Create() override {
- return factory_->CreateVideoEncoder(
- cricket::VideoCodec(cricket::kVp8CodecName));
- }
-
- void Destroy(webrtc::VideoEncoder* encoder) override {
- return factory_->DestroyVideoEncoder(encoder);
- }
-
- private:
- cricket::WebRtcVideoEncoderFactory* const factory_;
-};
-
TEST_F(PictureIdTest,
PictureIdContinuousAfterReconfigureSimulcastEncoderAdapter) {
cricket::InternalEncoderFactory internal_encoder_factory;
- SimulcastEncoderAdapter simulcast_encoder_adapter(
- new VideoEncoderFactoryAdapter(&internal_encoder_factory));
+ SimulcastEncoderAdapter simulcast_encoder_adapter(&internal_encoder_factory);
SetupEncoder(&simulcast_encoder_adapter);
TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1});
}
@@ -324,8 +302,7 @@
TEST_F(PictureIdTest,
PictureIdIncreasingAfterRecreateStreamSimulcastEncoderAdapter) {
cricket::InternalEncoderFactory internal_encoder_factory;
- SimulcastEncoderAdapter simulcast_encoder_adapter(
- new VideoEncoderFactoryAdapter(&internal_encoder_factory));
+ SimulcastEncoderAdapter simulcast_encoder_adapter(&internal_encoder_factory);
SetupEncoder(&simulcast_encoder_adapter);
TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1});
}
@@ -337,8 +314,7 @@
PictureIdTest,
DISABLED_PictureIdIncreasingAfterStreamCountChangeSimulcastEncoderAdapter) {
cricket::InternalEncoderFactory internal_encoder_factory;
- SimulcastEncoderAdapter simulcast_encoder_adapter(
- new VideoEncoderFactoryAdapter(&internal_encoder_factory));
+ SimulcastEncoderAdapter simulcast_encoder_adapter(&internal_encoder_factory);
// Make sure that that the picture id is not reset if the stream count goes
// down and then up.
std::vector<int> ssrc_counts = {3, 1, 3};
diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc
index 264c7a5..4b16df7 100644
--- a/webrtc/video/video_quality_test.cc
+++ b/webrtc/video/video_quality_test.cc
@@ -1061,24 +1061,32 @@
rtc::Event done_;
};
-class Vp8EncoderFactory : public VideoEncoderFactory {
+class Vp8EncoderFactory : public cricket::WebRtcVideoEncoderFactory {
public:
- Vp8EncoderFactory() = default;
+ Vp8EncoderFactory() {
+ supported_codecs_.push_back(cricket::VideoCodec("VP8"));
+ }
~Vp8EncoderFactory() override { RTC_CHECK(live_encoders_.empty()); }
- VideoEncoder* Create() override {
+ const std::vector<cricket::VideoCodec>& supported_codecs() const override {
+ return supported_codecs_;
+ }
+
+ VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override {
VideoEncoder* encoder = VP8Encoder::Create();
live_encoders_.insert(encoder);
return encoder;
}
- void Destroy(VideoEncoder* encoder) override {
+ void DestroyVideoEncoder(VideoEncoder* encoder) override {
auto it = live_encoders_.find(encoder);
RTC_CHECK(it != live_encoders_.end());
live_encoders_.erase(it);
delete encoder;
}
+ private:
+ std::vector<cricket::VideoCodec> supported_codecs_;
std::set<VideoEncoder*> live_encoders_;
};
diff --git a/webrtc/video/video_quality_test.h b/webrtc/video/video_quality_test.h
index 0221f68..2008c73 100644
--- a/webrtc/video/video_quality_test.h
+++ b/webrtc/video/video_quality_test.h
@@ -15,7 +15,7 @@
#include <string>
#include <vector>
-#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
+#include "webrtc/media/engine/simulcast_encoder_adapter.h"
#include "webrtc/test/call_test.h"
#include "webrtc/test/frame_generator.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
@@ -138,7 +138,7 @@
std::unique_ptr<test::TraceToStderr> trace_to_stderr_;
std::unique_ptr<test::FrameGenerator> frame_generator_;
std::unique_ptr<VideoEncoder> video_encoder_;
- std::unique_ptr<VideoEncoderFactory> vp8_encoder_factory_;
+ std::unique_ptr<cricket::WebRtcVideoEncoderFactory> vp8_encoder_factory_;
std::vector<std::unique_ptr<VideoEncoder>> thumbnail_encoders_;
std::vector<VideoSendStream::Config> thumbnail_send_configs_;