blob: 4e5aa1975082c3bda82c1c27f7fdd721985a395a [file] [log] [blame]
Jon Hjelleda99da82016-01-20 13:40:30 -08001/*
2 * Copyright 2015 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
Mirko Bonadei317a1f02019-09-17 17:06:18 +020011#include <memory>
12
magjedb8853ca2017-08-29 03:57:22 -070013#import "RTCPeerConnectionFactory+Native.h"
tkchin9eeb6242016-04-27 01:54:20 -070014#import "RTCPeerConnectionFactory+Private.h"
Yura Yaroshevichbf567122018-01-02 13:33:16 +030015#import "RTCPeerConnectionFactoryOptions+Private.h"
Jon Hjelleda99da82016-01-20 13:40:30 -080016
tkchind4bfbfc2016-08-30 11:56:05 -070017#import "RTCAudioSource+Private.h"
tkchin9eeb6242016-04-27 01:54:20 -070018#import "RTCAudioTrack+Private.h"
tkchind4bfbfc2016-08-30 11:56:05 -070019#import "RTCMediaConstraints+Private.h"
tkchin9eeb6242016-04-27 01:54:20 -070020#import "RTCMediaStream+Private.h"
21#import "RTCPeerConnection+Private.h"
22#import "RTCVideoSource+Private.h"
23#import "RTCVideoTrack+Private.h"
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020024#import "base/RTCLogging.h"
25#import "base/RTCVideoDecoderFactory.h"
26#import "base/RTCVideoEncoderFactory.h"
Artem Titov63ee39d2022-05-13 14:46:42 +000027#import "helpers/NSString+StdString.h"
Byoungchan Lee32c4ecb2021-10-28 15:49:46 +090028#include "rtc_base/checks.h"
Taylor Brandstetterea7fbfb2020-08-19 16:41:54 -070029#include "sdk/objc/native/api/network_monitor_factory.h"
Yury Yaroshevich19a6e942022-03-11 09:22:08 +010030#include "sdk/objc/native/api/ssl_certificate_verifier.h"
Taylor Brandstetterea7fbfb2020-08-19 16:41:54 -070031#include "system_wrappers/include/field_trial.h"
32
kthelgasonfb143122017-07-25 07:55:58 -070033#ifndef HAVE_NO_MEDIA
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020034#import "components/video_codec/RTCVideoDecoderFactoryH264.h"
35#import "components/video_codec/RTCVideoEncoderFactoryH264.h"
magjedb8853ca2017-08-29 03:57:22 -070036// The no-media version PeerConnectionFactory doesn't depend on these files, but the gn check tool
37// is not smart enough to take the #ifdef into account.
Anders Carlsson7e042812017-10-05 16:55:38 +020038#include "api/audio_codecs/builtin_audio_decoder_factory.h" // nogncheck
39#include "api/audio_codecs/builtin_audio_encoder_factory.h" // nogncheck
Danil Chapovalov4ba04b72019-06-26 15:49:47 +020040#include "api/rtc_event_log/rtc_event_log_factory.h"
Danil Chapovalovaaa11432019-05-17 13:20:14 +020041#include "api/task_queue/default_task_queue_factory.h"
Erik Språngceb44952020-09-22 11:36:35 +020042#include "api/transport/field_trial_based_config.h"
Anders Carlsson7e042812017-10-05 16:55:38 +020043#include "modules/audio_device/include/audio_device.h" // nogncheck
44#include "modules/audio_processing/include/audio_processing.h" // nogncheck
Anders Carlsson3ff50fb2018-02-01 15:47:05 +010045
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020046#include "sdk/objc/native/api/video_decoder_factory.h"
47#include "sdk/objc/native/api/video_encoder_factory.h"
48#include "sdk/objc/native/src/objc_video_decoder_factory.h"
49#include "sdk/objc/native/src/objc_video_encoder_factory.h"
kthelgasonfb143122017-07-25 07:55:58 -070050#endif
kwibergbfefb032016-05-01 14:53:46 -070051
Peter Hanspers8d95e3b2018-05-15 10:22:36 +020052#if defined(WEBRTC_IOS)
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020053#import "sdk/objc/native/api/audio_device_module.h"
Peter Hanspers8d95e3b2018-05-15 10:22:36 +020054#endif
55
zhihuanga4c113a2017-06-28 14:05:44 -070056// Adding the nogncheck to disable the including header check.
57// The no-media version PeerConnectionFactory doesn't depend on media related
58// C++ target.
59// TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++
60// API layer.
Steve Anton10542f22019-01-11 09:11:00 -080061#include "media/engine/webrtc_media_engine.h" // nogncheck
Kári Tristan Helgasoncbe74352016-11-09 10:43:26 +010062
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020063@implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) {
danilchape9021a32016-05-17 01:52:02 -070064 std::unique_ptr<rtc::Thread> _networkThread;
kwibergbfefb032016-05-01 14:53:46 -070065 std::unique_ptr<rtc::Thread> _workerThread;
danilchape9021a32016-05-17 01:52:02 -070066 std::unique_ptr<rtc::Thread> _signalingThread;
tkchinfce0e2c2016-08-30 12:58:11 -070067 BOOL _hasStartedAecDump;
Jon Hjelleda99da82016-01-20 13:40:30 -080068}
69
70@synthesize nativeFactory = _nativeFactory;
71
Peter Hanspers8d95e3b2018-05-15 10:22:36 +020072- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule {
73#if defined(WEBRTC_IOS)
74 return webrtc::CreateAudioDeviceModule();
75#else
76 return nullptr;
77#endif
78}
79
Jon Hjelleda99da82016-01-20 13:40:30 -080080- (instancetype)init {
kthelgasonfb143122017-07-25 07:55:58 -070081#ifdef HAVE_NO_MEDIA
Anders Carlsson7e042812017-10-05 16:55:38 +020082 return [self initWithNoMedia];
Magnus Jedvert8b4e92d2018-04-13 15:36:43 +020083#else
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020084 return [self
85 initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
86 nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
87 nativeVideoEncoderFactory:webrtc::ObjCToNativeVideoEncoderFactory([[RTC_OBJC_TYPE(
88 RTCVideoEncoderFactoryH264) alloc] init])
89 nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory([[RTC_OBJC_TYPE(
90 RTCVideoDecoderFactoryH264) alloc] init])
Niels Möller03486fc2022-04-25 10:46:59 +020091 audioDeviceModule:[self audioDeviceModule].get()
Niels Möller938bc332020-06-10 17:36:17 +020092 audioProcessingModule:nullptr];
kthelgasonfb143122017-07-25 07:55:58 -070093#endif
94}
95
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020096- (instancetype)
97 initWithEncoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
Niels Möller938bc332020-06-10 17:36:17 +020098 decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory {
magjedb8853ca2017-08-29 03:57:22 -070099#ifdef HAVE_NO_MEDIA
Anders Carlsson7e042812017-10-05 16:55:38 +0200100 return [self initWithNoMedia];
magjedb8853ca2017-08-29 03:57:22 -0700101#else
Anders Carlsson7e042812017-10-05 16:55:38 +0200102 std::unique_ptr<webrtc::VideoEncoderFactory> native_encoder_factory;
103 std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
104 if (encoderFactory) {
Anders Carlsson3ff50fb2018-02-01 15:47:05 +0100105 native_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory);
Anders Carlsson7e042812017-10-05 16:55:38 +0200106 }
107 if (decoderFactory) {
Anders Carlsson3ff50fb2018-02-01 15:47:05 +0100108 native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory);
Anders Carlsson7e042812017-10-05 16:55:38 +0200109 }
magjedb8853ca2017-08-29 03:57:22 -0700110 return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
111 nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
Anders Carlsson7e042812017-10-05 16:55:38 +0200112 nativeVideoEncoderFactory:std::move(native_encoder_factory)
Sean Rosenbaume5c42652017-10-30 07:50:17 -0700113 nativeVideoDecoderFactory:std::move(native_decoder_factory)
Niels Möller03486fc2022-04-25 10:46:59 +0200114 audioDeviceModule:[self audioDeviceModule].get()
Niels Möller938bc332020-06-10 17:36:17 +0200115 audioProcessingModule:nullptr];
magjedb8853ca2017-08-29 03:57:22 -0700116#endif
117}
Anders Carlsson7e042812017-10-05 16:55:38 +0200118- (instancetype)initNative {
kthelgasonfb143122017-07-25 07:55:58 -0700119 if (self = [super init]) {
danilchape9021a32016-05-17 01:52:02 -0700120 _networkThread = rtc::Thread::CreateWithSocketServer();
Yura Yaroshevichcef06502018-05-01 00:58:43 +0300121 _networkThread->SetName("network_thread", _networkThread.get());
danilchape9021a32016-05-17 01:52:02 -0700122 BOOL result = _networkThread->Start();
Byoungchan Lee32c4ecb2021-10-28 15:49:46 +0900123 RTC_DCHECK(result) << "Failed to start network thread.";
danilchape9021a32016-05-17 01:52:02 -0700124
125 _workerThread = rtc::Thread::Create();
Yura Yaroshevichcef06502018-05-01 00:58:43 +0300126 _workerThread->SetName("worker_thread", _workerThread.get());
Jon Hjelleda99da82016-01-20 13:40:30 -0800127 result = _workerThread->Start();
Byoungchan Lee32c4ecb2021-10-28 15:49:46 +0900128 RTC_DCHECK(result) << "Failed to start worker thread.";
Jon Hjelleda99da82016-01-20 13:40:30 -0800129
danilchape9021a32016-05-17 01:52:02 -0700130 _signalingThread = rtc::Thread::Create();
Yura Yaroshevichcef06502018-05-01 00:58:43 +0300131 _signalingThread->SetName("signaling_thread", _signalingThread.get());
danilchape9021a32016-05-17 01:52:02 -0700132 result = _signalingThread->Start();
Byoungchan Lee32c4ecb2021-10-28 15:49:46 +0900133 RTC_DCHECK(result) << "Failed to start signaling thread.";
Anders Carlsson7e042812017-10-05 16:55:38 +0200134 }
135 return self;
136}
137
138- (instancetype)initWithNoMedia {
139 if (self = [self initNative]) {
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200140 webrtc::PeerConnectionFactoryDependencies dependencies;
141 dependencies.network_thread = _networkThread.get();
142 dependencies.worker_thread = _workerThread.get();
143 dependencies.signaling_thread = _signalingThread.get();
Taylor Brandstetterea7fbfb2020-08-19 16:41:54 -0700144 if (webrtc::field_trial::IsEnabled("WebRTC-Network-UseNWPathMonitor")) {
145 dependencies.network_monitor_factory = webrtc::CreateNetworkMonitorFactory();
146 }
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200147 _nativeFactory = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
Anders Carlsson7e042812017-10-05 16:55:38 +0200148 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
149 }
150 return self;
151}
152
153- (instancetype)initWithNativeAudioEncoderFactory:
154 (rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
155 nativeAudioDecoderFactory:
156 (rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
157 nativeVideoEncoderFactory:
158 (std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
159 nativeVideoDecoderFactory:
Sean Rosenbaume5c42652017-10-30 07:50:17 -0700160 (std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
Sebastian Jansson77c0a622019-04-23 10:24:03 +0200161 audioDeviceModule:(webrtc::AudioDeviceModule *)audioDeviceModule
Sam Zackrisson6124aac2017-11-13 14:56:02 +0100162 audioProcessingModule:
163 (rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule {
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700164 return [self initWithNativeAudioEncoderFactory:audioEncoderFactory
165 nativeAudioDecoderFactory:audioDecoderFactory
166 nativeVideoEncoderFactory:std::move(videoEncoderFactory)
167 nativeVideoDecoderFactory:std::move(videoDecoderFactory)
168 audioDeviceModule:audioDeviceModule
169 audioProcessingModule:audioProcessingModule
Niels Möller938bc332020-06-10 17:36:17 +0200170 networkControllerFactory:nullptr];
Sebastian Jansson77c0a622019-04-23 10:24:03 +0200171}
172- (instancetype)initWithNativeAudioEncoderFactory:
173 (rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
174 nativeAudioDecoderFactory:
175 (rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
176 nativeVideoEncoderFactory:
177 (std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
178 nativeVideoDecoderFactory:
179 (std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
180 audioDeviceModule:(webrtc::AudioDeviceModule *)audioDeviceModule
181 audioProcessingModule:
182 (rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule
183 networkControllerFactory:
184 (std::unique_ptr<webrtc::NetworkControllerFactoryInterface>)
Niels Möller938bc332020-06-10 17:36:17 +0200185 networkControllerFactory {
Anders Carlsson7e042812017-10-05 16:55:38 +0200186 if (self = [self initNative]) {
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700187 webrtc::PeerConnectionFactoryDependencies dependencies;
188 dependencies.network_thread = _networkThread.get();
189 dependencies.worker_thread = _workerThread.get();
190 dependencies.signaling_thread = _signalingThread.get();
Taylor Brandstetterea7fbfb2020-08-19 16:41:54 -0700191 if (webrtc::field_trial::IsEnabled("WebRTC-Network-UseNWPathMonitor")) {
192 dependencies.network_monitor_factory = webrtc::CreateNetworkMonitorFactory();
193 }
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200194#ifndef HAVE_NO_MEDIA
195 dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
Erik Språngceb44952020-09-22 11:36:35 +0200196 dependencies.trials = std::make_unique<webrtc::FieldTrialBasedConfig>();
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200197 cricket::MediaEngineDependencies media_deps;
198 media_deps.adm = std::move(audioDeviceModule);
199 media_deps.task_queue_factory = dependencies.task_queue_factory.get();
200 media_deps.audio_encoder_factory = std::move(audioEncoderFactory);
201 media_deps.audio_decoder_factory = std::move(audioDecoderFactory);
202 media_deps.video_encoder_factory = std::move(videoEncoderFactory);
203 media_deps.video_decoder_factory = std::move(videoDecoderFactory);
204 if (audioProcessingModule) {
205 media_deps.audio_processing = std::move(audioProcessingModule);
206 } else {
207 media_deps.audio_processing = webrtc::AudioProcessingBuilder().Create();
208 }
Erik Språngceb44952020-09-22 11:36:35 +0200209 media_deps.trials = dependencies.trials.get();
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200210 dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
211 dependencies.call_factory = webrtc::CreateCallFactory();
212 dependencies.event_log_factory =
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200213 std::make_unique<webrtc::RtcEventLogFactory>(dependencies.task_queue_factory.get());
Sebastian Jansson77c0a622019-04-23 10:24:03 +0200214 dependencies.network_controller_factory = std::move(networkControllerFactory);
Danil Chapovalovaaa11432019-05-17 13:20:14 +0200215#endif
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700216 _nativeFactory = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
Anders Carlsson7e042812017-10-05 16:55:38 +0200217 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
218 }
219 return self;
Anders Carlsson7e042812017-10-05 16:55:38 +0200220}
221
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200222- (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints:
223 (nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints {
tkchind4bfbfc2016-08-30 11:56:05 -0700224 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
225 if (constraints) {
226 nativeConstraints = constraints.nativeConstraints;
227 }
Niels Möller2d02e082018-05-21 11:23:35 +0200228 cricket::AudioOptions options;
229 CopyConstraintsIntoAudioOptions(nativeConstraints.get(), &options);
230
tkchind4bfbfc2016-08-30 11:56:05 -0700231 rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
Niels Möller2d02e082018-05-21 11:23:35 +0200232 _nativeFactory->CreateAudioSource(options);
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200233 return [[RTC_OBJC_TYPE(RTCAudioSource) alloc] initWithFactory:self nativeAudioSource:source];
tkchind4bfbfc2016-08-30 11:56:05 -0700234}
235
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200236- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithTrackId:(NSString *)trackId {
237 RTC_OBJC_TYPE(RTCAudioSource) *audioSource = [self audioSourceWithConstraints:nil];
tkchind4bfbfc2016-08-30 11:56:05 -0700238 return [self audioTrackWithSource:audioSource trackId:trackId];
239}
240
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200241- (RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrackWithSource:(RTC_OBJC_TYPE(RTCAudioSource) *)source
242 trackId:(NSString *)trackId {
243 return [[RTC_OBJC_TYPE(RTCAudioTrack) alloc] initWithFactory:self source:source trackId:trackId];
tkchind4bfbfc2016-08-30 11:56:05 -0700244}
245
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200246- (RTC_OBJC_TYPE(RTCVideoSource) *)videoSource {
247 return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self
248 signalingThread:_signalingThread.get()
249 workerThread:_workerThread.get()];
magjedabb84b82017-03-28 01:56:41 -0700250}
251
Saúl Ibarra Corretgé4d0760e2021-08-06 16:17:12 +0200252- (RTC_OBJC_TYPE(RTCVideoSource) *)videoSourceForScreenCast:(BOOL)forScreenCast {
253 return [[RTC_OBJC_TYPE(RTCVideoSource) alloc] initWithFactory:self
254 signalingThread:_signalingThread.get()
255 workerThread:_workerThread.get()
256 isScreenCast:forScreenCast];
257}
258
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200259- (RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrackWithSource:(RTC_OBJC_TYPE(RTCVideoSource) *)source
260 trackId:(NSString *)trackId {
261 return [[RTC_OBJC_TYPE(RTCVideoTrack) alloc] initWithFactory:self source:source trackId:trackId];
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -0700262}
263
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200264- (RTC_OBJC_TYPE(RTCMediaStream) *)mediaStreamWithStreamId:(NSString *)streamId {
265 return [[RTC_OBJC_TYPE(RTCMediaStream) alloc] initWithFactory:self streamId:streamId];
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -0700266}
267
Yura Yaroshevichd140c8f2021-03-02 23:25:10 +0300268- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *)
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200269 peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
270 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
271 delegate:
272 (nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
273 return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self
274 configuration:configuration
275 constraints:constraints
Yury Yaroshevich19a6e942022-03-11 09:22:08 +0100276 certificateVerifier:nil
277 delegate:delegate];
278}
279
280- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *)
281 peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
282 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
283 certificateVerifier:
284 (id<RTC_OBJC_TYPE(RTCSSLCertificateVerifier)>)certificateVerifier
285 delegate:
286 (nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
287 return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self
288 configuration:configuration
289 constraints:constraints
290 certificateVerifier:certificateVerifier
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200291 delegate:delegate];
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -0700292}
293
Yura Yaroshevichd140c8f2021-03-02 23:25:10 +0300294- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *)
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200295 peerConnectionWithDependencies:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
296 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
Jonas Oreland285f83d2020-02-07 10:30:08 +0100297 dependencies:(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200298 delegate:(id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate {
299 return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithDependencies:self
300 configuration:configuration
301 constraints:constraints
302 dependencies:std::move(dependencies)
303 delegate:delegate];
Jonas Oreland285f83d2020-02-07 10:30:08 +0100304}
305
Mirko Bonadeia81e9c82020-05-04 16:14:32 +0200306- (void)setOptions:(nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options {
Yura Yaroshevichbf567122018-01-02 13:33:16 +0300307 RTC_DCHECK(options != nil);
308 _nativeFactory->SetOptions(options.nativeOptions);
309}
310
Magnus Jedvertf83dc8b2017-08-29 09:49:43 +0000311- (BOOL)startAecDumpWithFilePath:(NSString *)filePath
312 maxSizeInBytes:(int64_t)maxSizeInBytes {
tkchinfce0e2c2016-08-30 12:58:11 -0700313 RTC_DCHECK(filePath.length);
314 RTC_DCHECK_GT(maxSizeInBytes, 0);
315
316 if (_hasStartedAecDump) {
317 RTCLogError(@"Aec dump already started.");
318 return NO;
319 }
Niels Möllere4ac7232019-06-24 09:39:56 +0200320 FILE *f = fopen(filePath.UTF8String, "wb");
321 if (!f) {
322 RTCLogError(@"Error opening file: %@. Error: %s", filePath, strerror(errno));
tkchinfce0e2c2016-08-30 12:58:11 -0700323 return NO;
324 }
Niels Möllere4ac7232019-06-24 09:39:56 +0200325 _hasStartedAecDump = _nativeFactory->StartAecDump(f, maxSizeInBytes);
tkchinfce0e2c2016-08-30 12:58:11 -0700326 return _hasStartedAecDump;
327}
328
329- (void)stopAecDump {
330 _nativeFactory->StopAecDump();
331 _hasStartedAecDump = NO;
332}
333
Jon Hjelleda99da82016-01-20 13:40:30 -0800334@end