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