Mirko Bonadei | 3cf8f3e | 2018-11-19 09:17:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 "api/create_peerconnection_factory.h" |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 12 | |
| 13 | #include <memory> |
| 14 | #include <utility> |
| 15 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 16 | #include "api/audio/audio_mixer.h" |
| 17 | #include "api/audio_codecs/audio_decoder_factory.h" |
| 18 | #include "api/audio_codecs/audio_encoder_factory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 19 | #include "api/call/call_factory_interface.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 20 | #include "api/fec_controller.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "api/peer_connection_interface.h" |
Mirko Bonadei | d970807 | 2019-01-25 20:26:48 +0100 | [diff] [blame] | 22 | #include "api/scoped_refptr.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 23 | #include "api/transport/network_control.h" |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 24 | #include "api/video_codecs/video_decoder_factory.h" |
| 25 | #include "api/video_codecs/video_encoder_factory.h" |
| 26 | #include "logging/rtc_event_log/rtc_event_log_factory.h" |
| 27 | #include "logging/rtc_event_log/rtc_event_log_factory_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 28 | #include "media/base/media_engine.h" |
| 29 | #include "media/engine/webrtc_media_engine.h" |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 30 | #include "modules/audio_device/include/audio_device.h" |
| 31 | #include "modules/audio_processing/include/audio_processing.h" |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 32 | #include "rtc_base/thread.h" |
| 33 | |
| 34 | namespace webrtc { |
| 35 | |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 36 | rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 37 | rtc::Thread* network_thread, |
| 38 | rtc::Thread* worker_thread, |
| 39 | rtc::Thread* signaling_thread, |
| 40 | rtc::scoped_refptr<AudioDeviceModule> default_adm, |
| 41 | rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 42 | rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 43 | std::unique_ptr<VideoEncoderFactory> video_encoder_factory, |
| 44 | std::unique_ptr<VideoDecoderFactory> video_decoder_factory, |
| 45 | rtc::scoped_refptr<AudioMixer> audio_mixer, |
| 46 | rtc::scoped_refptr<AudioProcessing> audio_processing) { |
| 47 | if (!audio_processing) |
| 48 | audio_processing = AudioProcessingBuilder().Create(); |
| 49 | |
| 50 | std::unique_ptr<cricket::MediaEngineInterface> media_engine = |
| 51 | cricket::WebRtcMediaEngineFactory::Create( |
| 52 | default_adm, audio_encoder_factory, audio_decoder_factory, |
| 53 | std::move(video_encoder_factory), std::move(video_decoder_factory), |
| 54 | audio_mixer, audio_processing); |
| 55 | |
| 56 | std::unique_ptr<CallFactoryInterface> call_factory = CreateCallFactory(); |
| 57 | |
| 58 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory = |
| 59 | CreateRtcEventLogFactory(); |
| 60 | PeerConnectionFactoryDependencies dependencies; |
| 61 | dependencies.network_thread = network_thread; |
| 62 | dependencies.worker_thread = worker_thread; |
| 63 | dependencies.signaling_thread = signaling_thread; |
| 64 | dependencies.media_engine = std::move(media_engine); |
| 65 | dependencies.call_factory = std::move(call_factory); |
| 66 | dependencies.event_log_factory = std::move(event_log_factory); |
| 67 | return CreateModularPeerConnectionFactory(std::move(dependencies)); |
| 68 | } |
| 69 | |
Mirko Bonadei | 2ff3f49 | 2018-11-22 09:00:13 +0100 | [diff] [blame] | 70 | } // namespace webrtc |