diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index 13e78e6455..3753da4d09 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -112,6 +112,8 @@ class AudioDeviceModule; class AudioMixer; class CallFactoryInterface; class MediaConstraintsInterface; +class VideoDecoderFactory; +class VideoEncoderFactory; // MediaStream container interface. class StreamCollectionInterface : public rtc::RefCountInterface { @@ -1116,6 +1118,21 @@ rtc::scoped_refptr CreatePeerConnectionFactory( rtc::scoped_refptr audio_mixer, rtc::scoped_refptr audio_processing); +// 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. +rtc::scoped_refptr CreatePeerConnectionFactory( + rtc::Thread* network_thread, + rtc::Thread* worker_thread, + rtc::Thread* signaling_thread, + rtc::scoped_refptr default_adm, + rtc::scoped_refptr audio_encoder_factory, + rtc::scoped_refptr audio_decoder_factory, + std::unique_ptr video_encoder_factory, + std::unique_ptr video_decoder_factory, + rtc::scoped_refptr audio_mixer, + rtc::scoped_refptr audio_processing); + // Create a new instance of PeerConnectionFactoryInterface with external audio // mixer. // diff --git a/media/engine/webrtcmediaengine.cc b/media/engine/webrtcmediaengine.cc index 99b6041a18..888b6a9d98 100644 --- a/media/engine/webrtcmediaengine.cc +++ b/media/engine/webrtcmediaengine.cc @@ -14,6 +14,8 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" #include "media/engine/webrtcvoiceengine.h" #ifdef HAVE_WEBRTC_VIDEO @@ -121,6 +123,32 @@ MediaEngineInterface* WebRtcMediaEngineFactory::Create( video_decoder_factory, audio_mixer, audio_processing); } +std::unique_ptr WebRtcMediaEngineFactory::Create( + rtc::scoped_refptr adm, + rtc::scoped_refptr audio_encoder_factory, + rtc::scoped_refptr audio_decoder_factory, + std::unique_ptr video_encoder_factory, + std::unique_ptr video_decoder_factory, + rtc::scoped_refptr audio_mixer, + rtc::scoped_refptr audio_processing) { +#ifdef HAVE_WEBRTC_VIDEO + typedef WebRtcVideoEngine VideoEngine; + std::tuple, + std::unique_ptr> + video_args(std::move(video_encoder_factory), + std::move(video_decoder_factory)); +#else + typedef NullWebRtcVideoEngine VideoEngine; + std::tuple<> video_args; +#endif + return std::unique_ptr( + new CompositeMediaEngine( + std::forward_as_tuple(adm, audio_encoder_factory, + audio_decoder_factory, audio_mixer, + audio_processing), + std::move(video_args))); +} + namespace { // Remove mutually exclusive extensions with lower priority. void DiscardRedundantExtensions( diff --git a/media/engine/webrtcmediaengine.h b/media/engine/webrtcmediaengine.h index f24f7c7c9f..b9713e985b 100644 --- a/media/engine/webrtcmediaengine.h +++ b/media/engine/webrtcmediaengine.h @@ -22,6 +22,8 @@ class AudioDecoderFactory; class AudioDeviceModule; class AudioMixer; class AudioProcessing; +class VideoDecoderFactory; +class VideoEncoderFactory; } namespace cricket { class WebRtcVideoDecoderFactory; @@ -81,6 +83,18 @@ class WebRtcMediaEngineFactory { WebRtcVideoDecoderFactory* video_decoder_factory, rtc::scoped_refptr audio_mixer, rtc::scoped_refptr apm); + + // Create a MediaEngineInterface with optional video codec factories. These + // video factories represents all video codecs, i.e. no extra internal video + // codecs will be added. + static std::unique_ptr Create( + rtc::scoped_refptr adm, + rtc::scoped_refptr audio_encoder_factory, + rtc::scoped_refptr audio_decoder_factory, + std::unique_ptr video_encoder_factory, + std::unique_ptr video_decoder_factory, + rtc::scoped_refptr audio_mixer, + rtc::scoped_refptr audio_processing); }; // Verify that extension IDs are within 1-byte extension range and are not diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 8c6b5a64cb..6339ffbfbb 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -203,6 +203,7 @@ rtc_static_library("create_pc_factory") { "../api/audio_codecs:audio_codecs_api", "../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory", + "../api/video_codecs:video_codecs_api", "../call", "../call:call_interfaces", "../logging:rtc_event_log_api", diff --git a/pc/createpeerconnectionfactory.cc b/pc/createpeerconnectionfactory.cc index a62a7ae6f0..ed0ff2a383 100644 --- a/pc/createpeerconnectionfactory.cc +++ b/pc/createpeerconnectionfactory.cc @@ -11,9 +11,12 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/peerconnectioninterface.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" #include "call/callfactoryinterface.h" #include "logging/rtc_event_log/rtc_event_log_factory_interface.h" #include "media/engine/webrtcmediaengine.h" +#include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/bind.h" #include "rtc_base/scoped_ref_ptr.h" @@ -74,6 +77,40 @@ rtc::scoped_refptr CreatePeerConnectionFactory( std::move(call_factory), std::move(event_log_factory)); } +rtc::scoped_refptr CreatePeerConnectionFactory( + rtc::Thread* network_thread, + rtc::Thread* worker_thread, + rtc::Thread* signaling_thread, + rtc::scoped_refptr default_adm, + rtc::scoped_refptr audio_encoder_factory, + rtc::scoped_refptr audio_decoder_factory, + std::unique_ptr video_encoder_factory, + std::unique_ptr video_decoder_factory, + rtc::scoped_refptr audio_mixer, + rtc::scoped_refptr audio_processing) { + if (!audio_processing) + audio_processing = AudioProcessing::Create(); + + std::unique_ptr media_engine = + cricket::WebRtcMediaEngineFactory::Create( + default_adm, audio_encoder_factory, audio_decoder_factory, + std::move(video_encoder_factory), std::move(video_decoder_factory), + audio_mixer, audio_processing); + + std::unique_ptr call_factory = CreateCallFactory(); + + std::unique_ptr event_log_factory = + CreateRtcEventLogFactory(); + + return CreateModularPeerConnectionFactory( + network_thread, worker_thread, signaling_thread, default_adm, + audio_encoder_factory, audio_decoder_factory, + nullptr /* external_video_encoder_factory */, + nullptr /* external_video_decoder_factory */, audio_mixer, + std::move(media_engine), std::move(call_factory), + std::move(event_log_factory)); +} + rtc::scoped_refptr CreatePeerConnectionFactoryWithAudioMixer( rtc::Thread* network_thread,