diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index be668ad5ef..ed30c1d936 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -1435,6 +1435,8 @@ rtc::scoped_refptr CreatePeerConnectionFactory( // Create a new instance of PeerConnectionFactoryInterface with optional video // codec factories. These video factories represents all video codecs, i.e. no // extra internal video codecs will be added. +// When building WebRTC with rtc_use_builtin_sw_codecs = false, this is the +// only available CreatePeerConnectionFactory overload. rtc::scoped_refptr CreatePeerConnectionFactory( rtc::Thread* network_thread, rtc::Thread* worker_thread, diff --git a/media/engine/internaldecoderfactory.cc b/media/engine/internaldecoderfactory.cc index 04baffd9d5..c9cd861f6b 100644 --- a/media/engine/internaldecoderfactory.cc +++ b/media/engine/internaldecoderfactory.cc @@ -12,11 +12,9 @@ #include "api/video_codecs/sdp_video_format.h" #include "media/base/mediaconstants.h" -#if defined(USE_BUILTIN_SW_CODECS) #include "modules/video_coding/codecs/h264/include/h264.h" -#include "modules/video_coding/codecs/vp8/include/vp8.h" // nogncheck -#include "modules/video_coding/codecs/vp9/include/vp9.h" // nogncheck -#endif +#include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "modules/video_coding/codecs/vp9/include/vp9.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -25,19 +23,16 @@ namespace webrtc { std::vector InternalDecoderFactory::GetSupportedFormats() const { std::vector formats; -#if defined(USE_BUILTIN_SW_CODECS) formats.push_back(SdpVideoFormat(cricket::kVp8CodecName)); if (VP9Decoder::IsSupported()) formats.push_back(SdpVideoFormat(cricket::kVp9CodecName)); for (const SdpVideoFormat& h264_format : SupportedH264Codecs()) formats.push_back(h264_format); -#endif return formats; } std::unique_ptr InternalDecoderFactory::CreateVideoDecoder( const SdpVideoFormat& format) { -#if defined(USE_BUILTIN_SW_CODECS) if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName)) return VP8Decoder::Create(); @@ -48,7 +43,6 @@ std::unique_ptr InternalDecoderFactory::CreateVideoDecoder( if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) return H264Decoder::Create(); -#endif RTC_LOG(LS_ERROR) << "Trying to create decoder for unsupported format"; return nullptr; diff --git a/media/engine/internalencoderfactory.cc b/media/engine/internalencoderfactory.cc index d093b25915..2f7df9f58f 100644 --- a/media/engine/internalencoderfactory.cc +++ b/media/engine/internalencoderfactory.cc @@ -13,11 +13,9 @@ #include #include "api/video_codecs/sdp_video_format.h" -#if defined(USE_BUILTIN_SW_CODECS) #include "modules/video_coding/codecs/h264/include/h264.h" -#include "modules/video_coding/codecs/vp8/include/vp8.h" // nogncheck -#include "modules/video_coding/codecs/vp9/include/vp9.h" // nogncheck -#endif +#include "modules/video_coding/codecs/vp8/include/vp8.h" +#include "modules/video_coding/codecs/vp9/include/vp9.h" #include "rtc_base/logging.h" namespace webrtc { @@ -25,14 +23,12 @@ namespace webrtc { std::vector InternalEncoderFactory::GetSupportedFormats() const { std::vector supported_codecs; -#if defined(USE_BUILTIN_SW_CODECS) supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName)); if (webrtc::VP9Encoder::IsSupported()) supported_codecs.push_back(SdpVideoFormat(cricket::kVp9CodecName)); for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs()) supported_codecs.push_back(format); -#endif return supported_codecs; } @@ -47,7 +43,6 @@ VideoEncoderFactory::CodecInfo InternalEncoderFactory::QueryVideoEncoder( std::unique_ptr InternalEncoderFactory::CreateVideoEncoder( const SdpVideoFormat& format) { -#if defined(USE_BUILTIN_SW_CODECS) if (cricket::CodecNamesEq(format.name, cricket::kVp8CodecName)) return VP8Encoder::Create(); @@ -56,7 +51,6 @@ std::unique_ptr InternalEncoderFactory::CreateVideoEncoder( if (cricket::CodecNamesEq(format.name, cricket::kH264CodecName)) return H264Encoder::Create(cricket::VideoCodec(format)); -#endif RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " << format.name; diff --git a/media/engine/webrtcmediaengine_unittest.cc b/media/engine/webrtcmediaengine_unittest.cc index 85170e24e5..8cd8d16bae 100644 --- a/media/engine/webrtcmediaengine_unittest.cc +++ b/media/engine/webrtcmediaengine_unittest.cc @@ -12,7 +12,10 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" #include "media/engine/webrtcmediaengine.h" +#include "modules/audio_processing/include/audio_processing.h" #include "test/gtest.h" using webrtc::RtpExtension; @@ -238,8 +241,11 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensions_RemoveRedundantBwe_3) { TEST(WebRtcMediaEngineFactoryTest, CreateWithBuiltinDecoders) { std::unique_ptr engine(WebRtcMediaEngineFactory::Create( - nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), - webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, nullptr)); + nullptr /* adm */, webrtc::CreateBuiltinAudioEncoderFactory(), + webrtc::CreateBuiltinAudioDecoderFactory(), + webrtc::CreateBuiltinVideoEncoderFactory(), + webrtc::CreateBuiltinVideoDecoderFactory(), nullptr /* audio_mixer */, + webrtc::AudioProcessingBuilder().Create())); EXPECT_TRUE(engine); } diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index bcdd9b18b3..c6e30a5821 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -739,6 +739,7 @@ if (rtc_include_tests) { "../../api/video_codecs:video_codecs_api", "../../common_video", "../../media:rtc_h264_profile_id", + "../../media:rtc_internal_video_codecs", "../../media:rtc_media_base", "../../rtc_base:rtc_base", "../../test:fileutils", @@ -822,6 +823,7 @@ if (rtc_include_tests) { if (rtc_use_h264) { sources += [ "codecs/h264/h264_encoder_impl_unittest.cc" ] } + deps = [ ":codec_globals_headers", ":encoded_frame", diff --git a/ortc/BUILD.gn b/ortc/BUILD.gn index d2c8cb2251..a45799cffa 100644 --- a/ortc/BUILD.gn +++ b/ortc/BUILD.gn @@ -36,6 +36,8 @@ rtc_static_library("ortc") { "../api:libjingle_peerconnection_api", "../api:optional", "../api:ortc_api", + "../api/video_codecs:builtin_video_decoder_factory", + "../api/video_codecs:builtin_video_encoder_factory", "../call:call_interfaces", "../call:rtp_sender", "../logging:rtc_event_log_api", diff --git a/ortc/ortcfactory.cc b/ortc/ortcfactory.cc index dd3c6db614..fa2b05cce3 100644 --- a/ortc/ortcfactory.cc +++ b/ortc/ortcfactory.cc @@ -17,6 +17,8 @@ #include "api/mediastreamtrackproxy.h" #include "api/proxy.h" #include "api/rtcerror.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" #include "api/videosourceproxy.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "media/base/mediaconstants.h" @@ -551,8 +553,11 @@ OrtcFactory::CreateMediaEngine_w() { // AudioDeviceModule will be used. return std::unique_ptr( cricket::WebRtcMediaEngineFactory::Create( - adm_, audio_encoder_factory_, audio_decoder_factory_, nullptr, - nullptr, nullptr, webrtc::AudioProcessingBuilder().Create())); + rtc::scoped_refptr(adm_), + audio_encoder_factory_, audio_decoder_factory_, + webrtc::CreateBuiltinVideoEncoderFactory(), + webrtc::CreateBuiltinVideoDecoderFactory(), nullptr, + webrtc::AudioProcessingBuilder().Create())); } } // namespace webrtc diff --git a/pc/createpeerconnectionfactory.cc b/pc/createpeerconnectionfactory.cc index 11650ec0fb..72e578277d 100644 --- a/pc/createpeerconnectionfactory.cc +++ b/pc/createpeerconnectionfactory.cc @@ -67,7 +67,6 @@ rtc::scoped_refptr CreatePeerConnectionFactory( network_thread, worker_thread, signaling_thread, std::move(media_engine), std::move(call_factory), std::move(event_log_factory)); } -#endif rtc::scoped_refptr CreatePeerConnectionFactory( rtc::Thread* network_thread, @@ -102,6 +101,7 @@ rtc::scoped_refptr CreatePeerConnectionFactory( std::move(call_factory), std::move(event_log_factory), std::move(fec_controller_factory)); } +#endif rtc::scoped_refptr CreatePeerConnectionFactory( rtc::Thread* network_thread, diff --git a/pc/peerconnection_jsep_unittest.cc b/pc/peerconnection_jsep_unittest.cc index 635591caaa..b4142411cc 100644 --- a/pc/peerconnection_jsep_unittest.cc +++ b/pc/peerconnection_jsep_unittest.cc @@ -10,6 +10,8 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" #include "media/engine/webrtcmediaengine.h" #include "modules/audio_processing/include/audio_processing.h" #include "pc/mediasession.h" @@ -44,20 +46,20 @@ using ::testing::UnorderedElementsAre; class PeerConnectionFactoryForJsepTest : public PeerConnectionFactory { public: PeerConnectionFactoryForJsepTest() - : PeerConnectionFactory( - rtc::Thread::Current(), - rtc::Thread::Current(), - rtc::Thread::Current(), - rtc::WrapUnique(cricket::WebRtcMediaEngineFactory::Create( - FakeAudioCaptureModule::Create(), - CreateBuiltinAudioEncoderFactory(), - CreateBuiltinAudioDecoderFactory(), - nullptr, - nullptr, - nullptr, - AudioProcessingBuilder().Create())), - CreateCallFactory(), - nullptr) {} + : PeerConnectionFactory(rtc::Thread::Current(), + rtc::Thread::Current(), + rtc::Thread::Current(), + cricket::WebRtcMediaEngineFactory::Create( + rtc::scoped_refptr( + FakeAudioCaptureModule::Create()), + CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + CreateBuiltinVideoEncoderFactory(), + CreateBuiltinVideoDecoderFactory(), + nullptr, + AudioProcessingBuilder().Create()), + CreateCallFactory(), + nullptr) {} std::unique_ptr CreateSctpTransportInternalFactory() { diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc index ef8d47ba11..ef3f317de4 100644 --- a/pc/peerconnectioninterface_unittest.cc +++ b/pc/peerconnectioninterface_unittest.cc @@ -634,13 +634,16 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory { CreatePeerConnectionFactoryForTest() { auto audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); auto audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); + auto video_encoder_factory = webrtc::CreateBuiltinVideoEncoderFactory(); + auto video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory(); // Use fake audio device module since we're only testing the interface // level, and using a real one could make tests flaky when run in parallel. auto media_engine = std::unique_ptr( cricket::WebRtcMediaEngineFactory::Create( FakeAudioCaptureModule::Create(), audio_encoder_factory, - audio_decoder_factory, nullptr, nullptr, nullptr, + audio_decoder_factory, std::move(video_encoder_factory), + std::move(video_decoder_factory), nullptr, webrtc::AudioProcessingBuilder().Create())); std::unique_ptr call_factory = diff --git a/test/BUILD.gn b/test/BUILD.gn index c62d3494ae..fd6fa3c161 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -580,7 +580,7 @@ rtc_source_set("test_common") { "../modules/video_coding:video_coding_utility", "../modules/video_coding:webrtc_h264", "../modules/video_coding:webrtc_multiplex", - "../modules/video_coding:webrtc_vp8", + "../modules/video_coding:webrtc_vp8_helpers", "../modules/video_coding:webrtc_vp9", "../rtc_base:checks", "../rtc_base:rtc_base_approved",