diff --git a/webrtc/media/BUILD.gn b/webrtc/media/BUILD.gn index c9055c80c6..fad410b2dd 100644 --- a/webrtc/media/BUILD.gn +++ b/webrtc/media/BUILD.gn @@ -143,6 +143,8 @@ rtc_static_library("rtc_audio_video") { "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 @@ rtc_static_library("rtc_audio_video") { "../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 @@ if (rtc_include_tests) { "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 @@ if (rtc_include_tests) { "../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 98% rename from webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc rename to webrtc/media/engine/simulcast_encoder_adapter.cc index dbf8b258ec..c33dfdd770 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 @@ -126,7 +126,8 @@ class TemporalLayersFactoryAdapter : public webrtc::TemporalLayersFactory { namespace webrtc { -SimulcastEncoderAdapter::SimulcastEncoderAdapter(VideoEncoderFactory* factory) +SimulcastEncoderAdapter::SimulcastEncoderAdapter( + cricket::WebRtcVideoEncoderFactory* factory) : inited_(0), factory_(factory), encoded_complete_callback_(nullptr), @@ -236,14 +237,14 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst, 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 @@ bool SimulcastEncoderAdapter::Initialized() const { 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 784c274acf..68af74a5a3 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 #include @@ -18,6 +18,7 @@ #include #include +#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 @@ namespace webrtc { 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 here. - explicit SimulcastEncoderAdapter(VideoEncoderFactory* factory); + explicit SimulcastEncoderAdapter(cricket::WebRtcVideoEncoderFactory* factory); virtual ~SimulcastEncoderAdapter(); // Implements VideoEncoder. @@ -107,7 +97,7 @@ class SimulcastEncoderAdapter : public VP8Encoder { void DestroyStoredEncoders(); volatile int inited_; // Accessed atomically. - const std::unique_ptr factory_; + cricket::WebRtcVideoEncoderFactory* const factory_; VideoCodec codec_; std::vector streaminfos_; EncodedImageCallback* encoded_complete_callback_; @@ -123,4 +113,4 @@ class SimulcastEncoderAdapter : public VP8Encoder { } // 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 b8ece61681..7865e5f1ba 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 #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 @@ namespace testing { 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& 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 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 factory_; }; TEST_F(TestSimulcastEncoderAdapter, TestKeyFrameRequestsOnAllStreams) { @@ -167,11 +184,18 @@ class MockVideoEncoder : public VideoEncoder { EncodedImageCallback* callback_; }; -class MockVideoEncoderFactory : public VideoEncoderFactory { +class MockVideoEncoderFactory : public cricket::WebRtcVideoEncoderFactory { public: - VideoEncoder* Create() override { - MockVideoEncoder* encoder = new - ::testing::NiceMock(); + MockVideoEncoderFactory() { + supported_codecs_.push_back(cricket::VideoCodec("VP8")); + } + + const std::vector& supported_codecs() const override { + return supported_codecs_; + } + + VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override { + MockVideoEncoder* encoder = new ::testing::NiceMock(); encoder->set_init_encode_return_value(init_encode_return_value_); const char* encoder_name = encoder_names_.empty() ? "codec_implementation_name" @@ -181,7 +205,7 @@ class MockVideoEncoderFactory : public VideoEncoderFactory { 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 @@ class MockVideoEncoderFactory : public VideoEncoderFactory { } private: + std::vector supported_codecs_; int32_t init_encode_return_value_ = 0; std::vector encoders_; std::vector encoder_names_; @@ -215,7 +240,7 @@ class TestSimulcastEncoderAdapterFakeHelper { // 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 @@ class TestSimulcastEncoderAdapterFakeHelper { } } - MockVideoEncoderFactory* factory() { return factory_; } + MockVideoEncoderFactory* factory() { return factory_.get(); } private: - MockVideoEncoderFactory* factory_; + std::unique_ptr factory_; }; static const int kTestTemporalLayerProfile[3] = {3, 2, 1}; diff --git a/webrtc/media/engine/webrtcvideoengine.cc b/webrtc/media/engine/webrtcvideoengine.cc index 55de5ae335..b6447329e2 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 @@ bool IsVideoContentTypeExtensionFieldTrialEnabled() { 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 @@ class WebRtcSimulcastEncoderFactory 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 d333264d93..67c8ccd239 100644 --- a/webrtc/modules/video_coding/BUILD.gn +++ b/webrtc/modules/video_coding/BUILD.gn @@ -212,8 +212,6 @@ rtc_static_library("webrtc_vp8") { "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 @@ rtc_static_library("webrtc_vp9") { } 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 @@ if (rtc_include_tests) { "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 @@ if (rtc_include_tests) { 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 8399d79704..9896c19c5d 100644 --- a/webrtc/modules/video_coding/DEPS +++ b/webrtc/modules/video_coding/DEPS @@ -4,7 +4,6 @@ include_rules = [ "+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 69b55e52ca..7d1cabf1a7 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 #include @@ -161,9 +161,6 @@ class Vp8TestDecodedImageCallback : public DecodedImageCallback { 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 @@ class TestVp8Simulcast : public ::testing::Test { } 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 @@ class TestVp8Simulcast : public ::testing::Test { } // 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 9d919cdd5b..1120fe07e4 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 45019871b1..106b513712 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 fe39a946b9..a1cb405e00 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 @@ TEST_F(PictureIdTest, PictureIdIncreasingAfterStreamCountChangeVp8) { 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, 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 @@ TEST_F( 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 ssrc_counts = {3, 1, 3}; diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc index 264c7a56bf..4b16df7428 100644 --- a/webrtc/video/video_quality_test.cc +++ b/webrtc/video/video_quality_test.cc @@ -1061,24 +1061,32 @@ class VideoAnalyzer : public PacketReceiver, 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& 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 supported_codecs_; std::set live_encoders_; }; diff --git a/webrtc/video/video_quality_test.h b/webrtc/video/video_quality_test.h index 0221f68993..2008c7348c 100644 --- a/webrtc/video/video_quality_test.h +++ b/webrtc/video/video_quality_test.h @@ -15,7 +15,7 @@ #include #include -#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 @@ class VideoQualityTest : public test::CallTest { std::unique_ptr trace_to_stderr_; std::unique_ptr frame_generator_; std::unique_ptr video_encoder_; - std::unique_ptr vp8_encoder_factory_; + std::unique_ptr vp8_encoder_factory_; std::vector> thumbnail_encoders_; std::vector thumbnail_send_configs_;