blob: 0d15e8cadf66639b5b960e5abd65f8c9e9668575 [file] [log] [blame]
Mirko Bonadei3cf8f3e2018-11-19 09:17:51 +01001/*
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 Bonadei2ff3f492018-11-22 09:00:13 +010012
13#include <memory>
14#include <utility>
15
Yves Gerey3e707812018-11-28 16:47:49 +010016#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 Anton10542f22019-01-11 09:11:00 -080019#include "api/call/call_factory_interface.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "api/fec_controller.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/peer_connection_interface.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010022#include "api/scoped_refptr.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "api/transport/network_control.h"
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010024#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 Anton10542f22019-01-11 09:11:00 -080028#include "media/base/media_engine.h"
29#include "media/engine/webrtc_media_engine.h"
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010030#include "modules/audio_device/include/audio_device.h"
31#include "modules/audio_processing/include/audio_processing.h"
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010032#include "rtc_base/thread.h"
33
34namespace webrtc {
35
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010036rtc::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 Bonadei2ff3f492018-11-22 09:00:13 +010070} // namespace webrtc