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