Expose new video codec factories in the PeerConnectionFactory API

This CL exposes the new type of video codec factories that represent all
video codecs in the PeerConnectionFactory API, i.e. no extra internal SW
video codecs will be added. Clients of the new functions will be
responsible for adding all SW video codecs themselves, and also handling
SW fallback and simulcast.

BUG=webrtc:7925
R=deadbeef@webrtc.org

Review-Url: https://codereview.webrtc.org/3004353002 .
Cr-Commit-Position: refs/heads/master@{#19866}
This commit is contained in:
Magnus Jedvert 2017-09-15 19:02:47 +02:00
parent 18f5427e4c
commit 58b0316f3d
5 changed files with 97 additions and 0 deletions

View File

@ -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<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> 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<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
rtc::scoped_refptr<AudioDeviceModule> default_adm,
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing);
// Create a new instance of PeerConnectionFactoryInterface with external audio
// mixer.
//

View File

@ -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<MediaEngineInterface> WebRtcMediaEngineFactory::Create(
rtc::scoped_refptr<webrtc::AudioDeviceModule> adm,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing) {
#ifdef HAVE_WEBRTC_VIDEO
typedef WebRtcVideoEngine VideoEngine;
std::tuple<std::unique_ptr<webrtc::VideoEncoderFactory>,
std::unique_ptr<webrtc::VideoDecoderFactory>>
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<MediaEngineInterface>(
new CompositeMediaEngine<WebRtcVoiceEngine, VideoEngine>(
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(

View File

@ -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<webrtc::AudioMixer> audio_mixer,
rtc::scoped_refptr<webrtc::AudioProcessing> 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<MediaEngineInterface> Create(
rtc::scoped_refptr<webrtc::AudioDeviceModule> adm,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
};
// Verify that extension IDs are within 1-byte extension range and are not

View File

@ -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",

View File

@ -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<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
std::move(call_factory), std::move(event_log_factory));
}
rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
rtc::scoped_refptr<AudioDeviceModule> default_adm,
rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<VideoEncoderFactory> video_encoder_factory,
std::unique_ptr<VideoDecoderFactory> video_decoder_factory,
rtc::scoped_refptr<AudioMixer> audio_mixer,
rtc::scoped_refptr<AudioProcessing> audio_processing) {
if (!audio_processing)
audio_processing = AudioProcessing::Create();
std::unique_ptr<cricket::MediaEngineInterface> 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<CallFactoryInterface> call_factory = CreateCallFactory();
std::unique_ptr<RtcEventLogFactoryInterface> 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<PeerConnectionFactoryInterface>
CreatePeerConnectionFactoryWithAudioMixer(
rtc::Thread* network_thread,