Support external audio mixer in webrtc 2.
An external audio mixer will be passed from PeerConnectionFactory to
AudioTransportProxy.
This CL has rewritten based on reverted CL
https://codereview.chromium.org/2539213003/
The only difference is that
static MediaEngineInterface* Create(
webrtc::AudioDeviceModule* adm,
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
audio_decoder_factory,
WebRtcVideoEncoderFactory* video_encoder_factory,
WebRtcVideoDecoderFactory* video_decoder_factory);
in media/engine/webrtcmediaengine.h is kept in this CL instead of
replaced for backward compatibility.
BUG=webrtc:6457
Review-Url: https://codereview.webrtc.org/2570993002
Cr-Commit-Position: refs/heads/master@{#15580}
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/api/peerconnectionfactory.cc
index e76701e..9da6e57 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/api/peerconnectionfactory.cc
@@ -57,27 +57,9 @@
AudioDeviceModule* default_adm,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
- rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
- new rtc::RefCountedObject<PeerConnectionFactory>(
- network_thread,
- worker_thread,
- signaling_thread,
- default_adm,
- CreateBuiltinAudioDecoderFactory(),
- encoder_factory,
- decoder_factory));
-
- // Call Initialize synchronously but make sure its executed on
- // |signaling_thread|.
- MethodCall0<PeerConnectionFactory, bool> call(
- pc_factory.get(),
- &PeerConnectionFactory::Initialize);
- bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
-
- if (!result) {
- return nullptr;
- }
- return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
+ return CreatePeerConnectionFactoryWithAudioMixer(
+ network_thread, worker_thread, signaling_thread, default_adm,
+ encoder_factory, decoder_factory, nullptr);
}
PeerConnectionFactory::PeerConnectionFactory()
@@ -95,6 +77,33 @@
worker_thread_->Start();
}
+rtc::scoped_refptr<PeerConnectionFactoryInterface>
+CreatePeerConnectionFactoryWithAudioMixer(
+ rtc::Thread* network_thread,
+ rtc::Thread* worker_thread,
+ rtc::Thread* signaling_thread,
+ AudioDeviceModule* default_adm,
+ cricket::WebRtcVideoEncoderFactory* encoder_factory,
+ cricket::WebRtcVideoDecoderFactory* decoder_factory,
+ rtc::scoped_refptr<AudioMixer> audio_mixer) {
+ rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
+ new rtc::RefCountedObject<PeerConnectionFactory>(
+ network_thread, worker_thread, signaling_thread, default_adm,
+ CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory,
+ audio_mixer));
+
+ // Call Initialize synchronously but make sure it is executed on
+ // |signaling_thread|.
+ MethodCall0<PeerConnectionFactory, bool> call(
+ pc_factory.get(), &PeerConnectionFactory::Initialize);
+ bool result = call.Marshal(RTC_FROM_HERE, signaling_thread);
+
+ if (!result) {
+ return nullptr;
+ }
+ return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
+}
+
PeerConnectionFactory::PeerConnectionFactory(
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
@@ -103,7 +112,8 @@
const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
audio_decoder_factory,
cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
- cricket::WebRtcVideoDecoderFactory* video_decoder_factory)
+ cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
+ rtc::scoped_refptr<AudioMixer> audio_mixer)
: owns_ptrs_(false),
wraps_current_thread_(false),
network_thread_(network_thread),
@@ -112,7 +122,8 @@
default_adm_(default_adm),
audio_decoder_factory_(audio_decoder_factory),
video_encoder_factory_(video_encoder_factory),
- video_decoder_factory_(video_decoder_factory) {
+ video_decoder_factory_(video_decoder_factory),
+ external_audio_mixer_(audio_mixer) {
RTC_DCHECK(network_thread);
RTC_DCHECK(worker_thread);
RTC_DCHECK(signaling_thread);
@@ -336,10 +347,8 @@
cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
return cricket::WebRtcMediaEngineFactory::Create(
- default_adm_.get(),
- audio_decoder_factory_,
- video_encoder_factory_.get(),
- video_decoder_factory_.get());
+ default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(),
+ video_decoder_factory_.get(), external_audio_mixer_);
}
} // namespace webrtc