blob: e7f5fad6ff2e9982072ef0fc4184f5fd0f359ae7 [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#ifndef API_CREATE_PEERCONNECTION_FACTORY_H_
12#define API_CREATE_PEERCONNECTION_FACTORY_H_
13
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010014#include <memory>
15
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"
19#include "api/fec_controller.h"
20#include "api/peerconnectioninterface.h"
21#include "api/transport/network_control.h"
22#include "rtc_base/scoped_ref_ptr.h"
23
24namespace cricket {
25class WebRtcVideoDecoderFactory;
26class WebRtcVideoEncoderFactory;
27} // namespace cricket
28
29namespace webrtc {
30
31class AudioDeviceModule;
32class AudioProcessing;
33class Thread;
34
35#if defined(USE_BUILTIN_SW_CODECS)
36// Create a new instance of PeerConnectionFactoryInterface.
37//
38// This method relies on the thread it's called on as the "signaling thread"
39// for the PeerConnectionFactory it creates.
40//
41// As such, if the current thread is not already running an rtc::Thread message
42// loop, an application using this method must eventually either call
43// rtc::Thread::Current()->Run(), or call
44// rtc::Thread::Current()->ProcessMessages() within the application's own
45// message loop.
46RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
47CreatePeerConnectionFactory(
48 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
49 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory);
50
51// Create a new instance of PeerConnectionFactoryInterface.
52//
53// |network_thread|, |worker_thread| and |signaling_thread| are
54// the only mandatory parameters.
55//
56// If non-null, a reference is added to |default_adm|, and ownership of
57// |video_encoder_factory| and |video_decoder_factory| is transferred to the
58// returned factory.
59// TODO(deadbeef): Use rtc::scoped_refptr<> and std::unique_ptr<> to make this
60// ownership transfer and ref counting more obvious.
61RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
62CreatePeerConnectionFactory(
63 rtc::Thread* network_thread,
64 rtc::Thread* worker_thread,
65 rtc::Thread* signaling_thread,
66 AudioDeviceModule* default_adm,
67 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
68 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
69 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
70 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
71
72// Create a new instance of PeerConnectionFactoryInterface with optional
73// external audio mixed and audio processing modules.
74//
75// If |audio_mixer| is null, an internal audio mixer will be created and used.
76// If |audio_processing| is null, an internal audio processing module will be
77// created and used.
78RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
79CreatePeerConnectionFactory(
80 rtc::Thread* network_thread,
81 rtc::Thread* worker_thread,
82 rtc::Thread* signaling_thread,
83 AudioDeviceModule* default_adm,
84 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
85 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
86 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
87 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
88 rtc::scoped_refptr<AudioMixer> audio_mixer,
89 rtc::scoped_refptr<AudioProcessing> audio_processing);
90
91// Create a new instance of PeerConnectionFactoryInterface with optional
92// external audio mixer, audio processing, and fec controller modules.
93//
94// If |audio_mixer| is null, an internal audio mixer will be created and used.
95// If |audio_processing| is null, an internal audio processing module will be
96// created and used.
97// If |fec_controller_factory| is null, an internal fec controller module will
98// be created and used.
99// If |network_controller_factory| is provided, it will be used if enabled via
100// field trial.
101RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
102CreatePeerConnectionFactory(
103 rtc::Thread* network_thread,
104 rtc::Thread* worker_thread,
105 rtc::Thread* signaling_thread,
106 AudioDeviceModule* default_adm,
107 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
108 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
109 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
110 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
111 rtc::scoped_refptr<AudioMixer> audio_mixer,
112 rtc::scoped_refptr<AudioProcessing> audio_processing,
113 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
114 std::unique_ptr<NetworkControllerFactoryInterface>
115 network_controller_factory = nullptr);
116#endif // defined(USE_BUILTIN_SW_CODECS)
117
118// Create a new instance of PeerConnectionFactoryInterface with optional video
119// codec factories. These video factories represents all video codecs, i.e. no
120// extra internal video codecs will be added.
121// When building WebRTC with rtc_use_builtin_sw_codecs = false, this is the
122// only available CreatePeerConnectionFactory overload.
123RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
124CreatePeerConnectionFactory(
125 rtc::Thread* network_thread,
126 rtc::Thread* worker_thread,
127 rtc::Thread* signaling_thread,
128 rtc::scoped_refptr<AudioDeviceModule> default_adm,
129 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
130 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
131 std::unique_ptr<VideoEncoderFactory> video_encoder_factory,
132 std::unique_ptr<VideoDecoderFactory> video_decoder_factory,
133 rtc::scoped_refptr<AudioMixer> audio_mixer,
134 rtc::scoped_refptr<AudioProcessing> audio_processing);
135
136#if defined(USE_BUILTIN_SW_CODECS)
137// Create a new instance of PeerConnectionFactoryInterface with external audio
138// mixer.
139//
140// If |audio_mixer| is null, an internal audio mixer will be created and used.
141RTC_EXPORT rtc::scoped_refptr<PeerConnectionFactoryInterface>
142CreatePeerConnectionFactoryWithAudioMixer(
143 rtc::Thread* network_thread,
144 rtc::Thread* worker_thread,
145 rtc::Thread* signaling_thread,
146 AudioDeviceModule* default_adm,
147 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
148 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
149 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
150 cricket::WebRtcVideoDecoderFactory* video_decoder_factory,
151 rtc::scoped_refptr<AudioMixer> audio_mixer);
152
153// Create a new instance of PeerConnectionFactoryInterface.
154// Same thread is used as worker and network thread.
155RTC_EXPORT inline rtc::scoped_refptr<PeerConnectionFactoryInterface>
156CreatePeerConnectionFactory(
157 rtc::Thread* worker_and_network_thread,
158 rtc::Thread* signaling_thread,
159 AudioDeviceModule* default_adm,
160 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory,
161 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory,
162 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
163 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) {
164 return CreatePeerConnectionFactory(
165 worker_and_network_thread, worker_and_network_thread, signaling_thread,
166 default_adm, audio_encoder_factory, audio_decoder_factory,
167 video_encoder_factory, video_decoder_factory);
168}
169#endif // defined(USE_BUILTIN_SW_CODECS)
170
171} // namespace webrtc
Mirko Bonadei3cf8f3e2018-11-19 09:17:51 +0100172
173#endif // API_CREATE_PEERCONNECTION_FACTORY_H_