blob: bdf4fb6e43997e378608e4b57d55e08e89acc64e [file] [log] [blame]
hjon6d49a8e2016-01-26 13:06:42 -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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "RTCConfiguration+Private.h"
hjon6d49a8e2016-01-26 13:06:42 -080012
jbauch555604a2016-04-26 03:13:22 -070013#include <memory>
14
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020015#import "RTCCertificate.h"
Zeke Chinef1140e2017-10-27 15:42:08 -070016#import "RTCConfiguration+Native.h"
tkchin9eeb6242016-04-27 01:54:20 -070017#import "RTCIceServer+Private.h"
Steve Antond295e402017-07-14 16:06:41 -070018#import "RTCIntervalRange+Private.h"
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020019#import "base/RTCLogging.h"
tkchinab8f82f2016-01-27 17:50:11 -080020
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/rtccertificategenerator.h"
22#include "rtc_base/sslidentity.h"
hjon6d49a8e2016-01-26 13:06:42 -080023
24@implementation RTCConfiguration
25
26@synthesize iceServers = _iceServers;
Michael Iedemaccee56b2018-07-05 15:28:24 +020027@synthesize certificate = _certificate;
hjon6d49a8e2016-01-26 13:06:42 -080028@synthesize iceTransportPolicy = _iceTransportPolicy;
29@synthesize bundlePolicy = _bundlePolicy;
30@synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
31@synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
Honghai Zhang46007ae2016-06-03 16:31:32 -070032@synthesize candidateNetworkPolicy = _candidateNetworkPolicy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070033@synthesize continualGatheringPolicy = _continualGatheringPolicy;
deadbeef2059bb32017-07-26 18:25:43 -070034@synthesize maxIPv6Networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010035@synthesize disableLinkLocalNetworks = _disableLinkLocalNetworks;
hjon6d49a8e2016-01-26 13:06:42 -080036@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -080037@synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate;
hjon6d49a8e2016-01-26 13:06:42 -080038@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
39@synthesize iceBackupCandidatePairPingInterval =
40 _iceBackupCandidatePairPingInterval;
tkchinab8f82f2016-01-27 17:50:11 -080041@synthesize keyType = _keyType;
deadbeefbe0c96f2016-05-18 16:20:14 -070042@synthesize iceCandidatePoolSize = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -070043@synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts;
44@synthesize shouldPresumeWritableWhenFullyRelayed =
45 _shouldPresumeWritableWhenFullyRelayed;
skvlada5d94ff2017-02-02 13:02:30 -080046@synthesize iceCheckMinInterval = _iceCheckMinInterval;
Steve Antond295e402017-07-14 16:06:41 -070047@synthesize iceRegatherIntervalRange = _iceRegatherIntervalRange;
Steve Anton8cb344a2018-02-27 15:34:53 -080048@synthesize sdpSemantics = _sdpSemantics;
Zeke Chinef1140e2017-10-27 15:42:08 -070049@synthesize turnCustomizer = _turnCustomizer;
Zhi Huangb57e1692018-06-12 11:41:11 -070050@synthesize activeResetSrtpParams = _activeResetSrtpParams;
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070051@synthesize useMediaTransport = _useMediaTransport;
hjon6d49a8e2016-01-26 13:06:42 -080052
53- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070054 // Copy defaults.
Yuriy Pavlyshak8cec4fb2018-09-07 16:43:31 +020055 webrtc::PeerConnectionInterface::RTCConfiguration config;
jtteh465faf02017-04-04 14:00:16 -070056 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070057}
58
59- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070060 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080061 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070062 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070063 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070064 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
65 [iceServers addObject:iceServer];
66 }
67 _iceServers = iceServers;
Michael Iedemaccee56b2018-07-05 15:28:24 +020068 if (!config.certificates.empty()) {
69 rtc::scoped_refptr<rtc::RTCCertificate> native_cert;
70 native_cert = config.certificates[0];
71 rtc::RTCCertificatePEM native_pem = native_cert->ToPEM();
72 _certificate =
73 [[RTCCertificate alloc] initWithPrivateKey:@(native_pem.private_key().c_str())
74 certificate:@(native_pem.certificate().c_str())];
75 }
hjon6d49a8e2016-01-26 13:06:42 -080076 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070077 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080078 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070079 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080080 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070081 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080082 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070083 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070084 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070085 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070086 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070087 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070088 _continualGatheringPolicy =
89 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
deadbeef2059bb32017-07-26 18:25:43 -070090 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010091 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070092 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
93 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
94 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -080095 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -070096 config.ice_backup_candidate_pair_ping_interval;
tkchinab8f82f2016-01-27 17:50:11 -080097 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -070098 _iceCandidatePoolSize = config.ice_candidate_pool_size;
99 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -0700100 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -0700101 config.presume_writable_when_fully_relayed;
102 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -0800103 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -0700104 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -0800105 }
Steve Antond295e402017-07-14 16:06:41 -0700106 if (config.ice_regather_interval_range) {
107 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
108 _iceRegatherIntervalRange =
109 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
110 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800111 _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700112 _turnCustomizer = config.turn_customizer;
Zhi Huangb57e1692018-06-12 11:41:11 -0700113 _activeResetSrtpParams = config.active_reset_srtp_params;
hjon6d49a8e2016-01-26 13:06:42 -0800114 }
115 return self;
116}
117
118- (NSString *)description {
Steve Anton8cb344a2018-02-27 15:34:53 -0800119 static NSString *formatString =
120 @"RTCConfiguration: "
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700121 @"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%@\n%@\n%d\n%d\n%d\n%@\n}\n";
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100122
Steve Anton8cb344a2018-02-27 15:34:53 -0800123 return [NSString
124 stringWithFormat:formatString,
125 _iceServers,
126 [[self class] stringForTransportPolicy:_iceTransportPolicy],
127 [[self class] stringForBundlePolicy:_bundlePolicy],
128 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
129 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
130 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
131 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
132 [[self class] stringForSdpSemantics:_sdpSemantics],
133 _audioJitterBufferMaxPackets,
134 _audioJitterBufferFastAccelerate,
135 _iceConnectionReceivingTimeout,
136 _iceBackupCandidatePairPingInterval,
137 _iceCandidatePoolSize,
138 _shouldPruneTurnPorts,
139 _shouldPresumeWritableWhenFullyRelayed,
140 _iceCheckMinInterval,
141 _iceRegatherIntervalRange,
142 _disableLinkLocalNetworks,
Zhi Huangb57e1692018-06-12 11:41:11 -0700143 _maxIPv6Networks,
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700144 _activeResetSrtpParams,
145 _useMediaTransport];
hjon6d49a8e2016-01-26 13:06:42 -0800146}
147
148#pragma mark - Private
149
hbosa73ca562016-05-17 03:28:58 -0700150- (webrtc::PeerConnectionInterface::RTCConfiguration *)
151 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200152 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700153 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
154 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800155
156 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200157 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800158 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200159 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800160 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200161 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800162 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200163 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800164 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200165 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800166 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700167 nativeConfig->candidate_network_policy = [[self class]
168 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200169 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700170 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
deadbeef2059bb32017-07-26 18:25:43 -0700171 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100172 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200173 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800174 nativeConfig->audio_jitter_buffer_fast_accelerate =
175 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200176 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800177 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200178 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800179 _iceBackupCandidatePairPingInterval;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200180 rtc::KeyType keyType =
181 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
Michael Iedemaccee56b2018-07-05 15:28:24 +0200182 if (_certificate != nullptr) {
183 // if offered a pemcert use it...
184 RTC_LOG(LS_INFO) << "Have configured cert - using it.";
185 std::string pem_private_key = [[_certificate private_key] UTF8String];
186 std::string pem_certificate = [[_certificate certificate] UTF8String];
187 rtc::RTCCertificatePEM pem = rtc::RTCCertificatePEM(pem_private_key, pem_certificate);
188 rtc::scoped_refptr<rtc::RTCCertificate> certificate = rtc::RTCCertificate::FromPEM(pem);
189 RTC_LOG(LS_INFO) << "Created cert from PEM strings.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200190 if (!certificate) {
Michael Iedemaccee56b2018-07-05 15:28:24 +0200191 RTC_LOG(LS_ERROR) << "Failed to generate certificate from PEM.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200192 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800193 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200194 nativeConfig->certificates.push_back(certificate);
Michael Iedemaccee56b2018-07-05 15:28:24 +0200195 } else {
196 RTC_LOG(LS_INFO) << "Don't have configured cert.";
197 // Generate non-default certificate.
198 if (keyType != rtc::KT_DEFAULT) {
199 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
200 rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType),
201 absl::optional<uint64_t>());
202 if (!certificate) {
203 RTCLogError(@"Failed to generate certificate.");
204 return nullptr;
205 }
206 nativeConfig->certificates.push_back(certificate);
207 }
tkchinab8f82f2016-01-27 17:50:11 -0800208 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700209 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700210 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700211 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700212 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800213 if (_iceCheckMinInterval != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +0200214 nativeConfig->ice_check_min_interval = absl::optional<int>(_iceCheckMinInterval.intValue);
skvlada5d94ff2017-02-02 13:02:30 -0800215 }
Steve Antond295e402017-07-14 16:06:41 -0700216 if (_iceRegatherIntervalRange != nil) {
217 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
218 _iceRegatherIntervalRange.nativeIntervalRange);
219 nativeConfig->ice_regather_interval_range =
Danil Chapovalov196100e2018-06-21 10:17:24 +0200220 absl::optional<rtc::IntervalRange>(*nativeIntervalRange);
Steve Antond295e402017-07-14 16:06:41 -0700221 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800222 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700223 if (_turnCustomizer) {
224 nativeConfig->turn_customizer = _turnCustomizer;
225 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700226 nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200227 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800228}
229
hjon6d49a8e2016-01-26 13:06:42 -0800230+ (webrtc::PeerConnectionInterface::IceTransportsType)
231 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
232 switch (policy) {
233 case RTCIceTransportPolicyNone:
234 return webrtc::PeerConnectionInterface::kNone;
235 case RTCIceTransportPolicyRelay:
236 return webrtc::PeerConnectionInterface::kRelay;
237 case RTCIceTransportPolicyNoHost:
238 return webrtc::PeerConnectionInterface::kNoHost;
239 case RTCIceTransportPolicyAll:
240 return webrtc::PeerConnectionInterface::kAll;
241 }
242}
243
244+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
245 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
246 switch (nativeType) {
247 case webrtc::PeerConnectionInterface::kNone:
248 return RTCIceTransportPolicyNone;
249 case webrtc::PeerConnectionInterface::kRelay:
250 return RTCIceTransportPolicyRelay;
251 case webrtc::PeerConnectionInterface::kNoHost:
252 return RTCIceTransportPolicyNoHost;
253 case webrtc::PeerConnectionInterface::kAll:
254 return RTCIceTransportPolicyAll;
255 }
256}
257
258+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
259 switch (policy) {
260 case RTCIceTransportPolicyNone:
261 return @"NONE";
262 case RTCIceTransportPolicyRelay:
263 return @"RELAY";
264 case RTCIceTransportPolicyNoHost:
265 return @"NO_HOST";
266 case RTCIceTransportPolicyAll:
267 return @"ALL";
268 }
269}
270
271+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
272 (RTCBundlePolicy)policy {
273 switch (policy) {
274 case RTCBundlePolicyBalanced:
275 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
276 case RTCBundlePolicyMaxCompat:
277 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
278 case RTCBundlePolicyMaxBundle:
279 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
280 }
281}
282
283+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
284 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
285 switch (nativePolicy) {
286 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
287 return RTCBundlePolicyBalanced;
288 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
289 return RTCBundlePolicyMaxCompat;
290 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
291 return RTCBundlePolicyMaxBundle;
292 }
293}
294
295+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
296 switch (policy) {
297 case RTCBundlePolicyBalanced:
298 return @"BALANCED";
299 case RTCBundlePolicyMaxCompat:
300 return @"MAX_COMPAT";
301 case RTCBundlePolicyMaxBundle:
302 return @"MAX_BUNDLE";
303 }
304}
305
306+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
307 (RTCRtcpMuxPolicy)policy {
308 switch (policy) {
309 case RTCRtcpMuxPolicyNegotiate:
310 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
311 case RTCRtcpMuxPolicyRequire:
312 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
313 }
314}
315
316+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
317 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
318 switch (nativePolicy) {
319 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
320 return RTCRtcpMuxPolicyNegotiate;
321 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
322 return RTCRtcpMuxPolicyRequire;
323 }
324}
325
326+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
327 switch (policy) {
328 case RTCRtcpMuxPolicyNegotiate:
329 return @"NEGOTIATE";
330 case RTCRtcpMuxPolicyRequire:
331 return @"REQUIRE";
332 }
333}
334
335+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
336 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
337 switch (policy) {
338 case RTCTcpCandidatePolicyEnabled:
339 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
340 case RTCTcpCandidatePolicyDisabled:
341 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
342 }
343}
344
Honghai Zhang46007ae2016-06-03 16:31:32 -0700345+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
346 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
347 switch (policy) {
348 case RTCCandidateNetworkPolicyAll:
349 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
350 case RTCCandidateNetworkPolicyLowCost:
351 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
352 }
353}
354
hjon6d49a8e2016-01-26 13:06:42 -0800355+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
356 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
357 switch (nativePolicy) {
358 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
359 return RTCTcpCandidatePolicyEnabled;
360 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
361 return RTCTcpCandidatePolicyDisabled;
362 }
363}
364
365+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
366 switch (policy) {
367 case RTCTcpCandidatePolicyEnabled:
368 return @"TCP_ENABLED";
369 case RTCTcpCandidatePolicyDisabled:
370 return @"TCP_DISABLED";
371 }
372}
373
Honghai Zhang46007ae2016-06-03 16:31:32 -0700374+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
375 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
376 switch (nativePolicy) {
377 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
378 return RTCCandidateNetworkPolicyAll;
379 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
380 return RTCCandidateNetworkPolicyLowCost;
381 }
382}
383
384+ (NSString *)stringForCandidateNetworkPolicy:
385 (RTCCandidateNetworkPolicy)policy {
386 switch (policy) {
387 case RTCCandidateNetworkPolicyAll:
388 return @"CANDIDATE_ALL_NETWORKS";
389 case RTCCandidateNetworkPolicyLowCost:
390 return @"CANDIDATE_LOW_COST_NETWORKS";
391 }
392}
393
Honghai Zhang3108fc92016-05-11 10:10:39 -0700394+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
395 nativeContinualGatheringPolicyForPolicy:
396 (RTCContinualGatheringPolicy)policy {
397 switch (policy) {
398 case RTCContinualGatheringPolicyGatherOnce:
399 return webrtc::PeerConnectionInterface::GATHER_ONCE;
400 case RTCContinualGatheringPolicyGatherContinually:
401 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
402 }
403}
404
405+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
406 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
407 switch (nativePolicy) {
408 case webrtc::PeerConnectionInterface::GATHER_ONCE:
409 return RTCContinualGatheringPolicyGatherOnce;
410 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
411 return RTCContinualGatheringPolicyGatherContinually;
412 }
413}
414
415+ (NSString *)stringForContinualGatheringPolicy:
416 (RTCContinualGatheringPolicy)policy {
417 switch (policy) {
418 case RTCContinualGatheringPolicyGatherOnce:
419 return @"GATHER_ONCE";
420 case RTCContinualGatheringPolicyGatherContinually:
421 return @"GATHER_CONTINUALLY";
422 }
423}
424
hbosf9da44d2016-06-09 03:18:28 -0700425+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
426 (RTCEncryptionKeyType)keyType {
427 switch (keyType) {
428 case RTCEncryptionKeyTypeRSA:
429 return rtc::KT_RSA;
430 case RTCEncryptionKeyTypeECDSA:
431 return rtc::KT_ECDSA;
432 }
433}
434
Steve Anton8cb344a2018-02-27 15:34:53 -0800435+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
436 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800437 case RTCSdpSemanticsPlanB:
438 return webrtc::SdpSemantics::kPlanB;
439 case RTCSdpSemanticsUnifiedPlan:
440 return webrtc::SdpSemantics::kUnifiedPlan;
441 }
442}
443
444+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
445 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800446 case webrtc::SdpSemantics::kPlanB:
447 return RTCSdpSemanticsPlanB;
448 case webrtc::SdpSemantics::kUnifiedPlan:
449 return RTCSdpSemanticsUnifiedPlan;
450 }
451}
452
453+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
454 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800455 case RTCSdpSemanticsPlanB:
456 return @"PLAN_B";
457 case RTCSdpSemanticsUnifiedPlan:
458 return @"UNIFIED_PLAN";
459 }
460}
461
hjon6d49a8e2016-01-26 13:06:42 -0800462@end