zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
| 12 | #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" |
| 13 | #include "webrtc/api/peerconnectioninterface.h" |
| 14 | #include "webrtc/base/bind.h" |
| 15 | #include "webrtc/base/scoped_ref_ptr.h" |
| 16 | #include "webrtc/base/thread.h" |
| 17 | #include "webrtc/call/callfactoryinterface.h" |
| 18 | #include "webrtc/logging/rtc_event_log/rtc_event_log_factory_interface.h" |
| 19 | #include "webrtc/media/engine/webrtcmediaengine.h" |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame^] | 20 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 25 | rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 26 | rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) { |
| 27 | return CreatePeerConnectionFactoryWithAudioMixer( |
| 28 | nullptr /*network_thread*/, nullptr /*worker_thread*/, |
| 29 | nullptr /*signaling_thread*/, nullptr /*default_adm*/, |
| 30 | audio_encoder_factory, audio_decoder_factory, |
| 31 | nullptr /*video_encoder_factory*/, nullptr /*video_decoder_factory*/, |
| 32 | nullptr /*audio_mixer*/); |
| 33 | } |
| 34 | |
| 35 | rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 36 | CreatePeerConnectionFactory() { |
| 37 | return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(), |
| 38 | CreateBuiltinAudioDecoderFactory()); |
| 39 | } |
| 40 | |
| 41 | // Note: all the other CreatePeerConnectionFactory variants just end up calling |
| 42 | // this, ultimately. |
| 43 | rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 44 | CreatePeerConnectionFactoryWithAudioMixer( |
| 45 | rtc::Thread* network_thread, |
| 46 | rtc::Thread* worker_thread, |
| 47 | rtc::Thread* signaling_thread, |
| 48 | AudioDeviceModule* default_adm, |
| 49 | rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 50 | rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 51 | cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 52 | cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
| 53 | rtc::scoped_refptr<AudioMixer> audio_mixer) { |
| 54 | std::unique_ptr<cricket::MediaEngineInterface> media_engine( |
| 55 | cricket::WebRtcMediaEngineFactory::Create( |
| 56 | default_adm, audio_encoder_factory, audio_decoder_factory, |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame^] | 57 | video_encoder_factory, video_decoder_factory, audio_mixer, |
| 58 | AudioProcessing::Create())); |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 59 | |
| 60 | std::unique_ptr<CallFactoryInterface> call_factory = CreateCallFactory(); |
| 61 | |
| 62 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory = |
| 63 | CreateRtcEventLogFactory(); |
| 64 | |
| 65 | return CreateModularPeerConnectionFactory( |
| 66 | network_thread, worker_thread, signaling_thread, default_adm, |
| 67 | audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
| 68 | video_decoder_factory, audio_mixer, std::move(media_engine), |
| 69 | std::move(call_factory), std::move(event_log_factory)); |
| 70 | } |
| 71 | |
| 72 | rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 73 | CreatePeerConnectionFactoryWithAudioMixer( |
| 74 | rtc::Thread* network_thread, |
| 75 | rtc::Thread* worker_thread, |
| 76 | rtc::Thread* signaling_thread, |
| 77 | AudioDeviceModule* default_adm, |
| 78 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 79 | cricket::WebRtcVideoDecoderFactory* decoder_factory, |
| 80 | rtc::scoped_refptr<AudioMixer> audio_mixer) { |
| 81 | return CreatePeerConnectionFactoryWithAudioMixer( |
| 82 | network_thread, worker_thread, signaling_thread, default_adm, |
| 83 | CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(), |
| 84 | encoder_factory, decoder_factory, audio_mixer); |
| 85 | } |
| 86 | |
| 87 | rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 88 | rtc::Thread* network_thread, |
| 89 | rtc::Thread* worker_thread, |
| 90 | rtc::Thread* signaling_thread, |
| 91 | AudioDeviceModule* default_adm, |
| 92 | cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 93 | cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 94 | return CreatePeerConnectionFactoryWithAudioMixer( |
| 95 | network_thread, worker_thread, signaling_thread, default_adm, |
| 96 | encoder_factory, decoder_factory, nullptr); |
| 97 | } |
| 98 | |
| 99 | rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 100 | rtc::Thread* network_thread, |
| 101 | rtc::Thread* worker_thread, |
| 102 | rtc::Thread* signaling_thread, |
| 103 | AudioDeviceModule* default_adm, |
| 104 | rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 105 | rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 106 | cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 107 | cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { |
| 108 | return CreatePeerConnectionFactoryWithAudioMixer( |
| 109 | network_thread, worker_thread, signaling_thread, default_adm, |
| 110 | audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
| 111 | video_decoder_factory, nullptr); |
| 112 | } |
| 113 | |
| 114 | } // namespace webrtc |