blob: e318a9f97763b4cccf654f7604da77ce8712a148 [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
Zeke Chinef1140e2017-10-27 15:42:08 -070015#import "RTCConfiguration+Native.h"
tkchin9eeb6242016-04-27 01:54:20 -070016#import "RTCIceServer+Private.h"
Steve Antond295e402017-07-14 16:06:41 -070017#import "RTCIntervalRange+Private.h"
tkchin9eeb6242016-04-27 01:54:20 -070018#import "WebRTC/RTCLogging.h"
tkchinab8f82f2016-01-27 17:50:11 -080019
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/rtccertificategenerator.h"
21#include "rtc_base/sslidentity.h"
hjon6d49a8e2016-01-26 13:06:42 -080022
23@implementation RTCConfiguration
24
25@synthesize iceServers = _iceServers;
26@synthesize iceTransportPolicy = _iceTransportPolicy;
27@synthesize bundlePolicy = _bundlePolicy;
28@synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
29@synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
Honghai Zhang46007ae2016-06-03 16:31:32 -070030@synthesize candidateNetworkPolicy = _candidateNetworkPolicy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070031@synthesize continualGatheringPolicy = _continualGatheringPolicy;
deadbeef2059bb32017-07-26 18:25:43 -070032@synthesize maxIPv6Networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010033@synthesize disableLinkLocalNetworks = _disableLinkLocalNetworks;
hjon6d49a8e2016-01-26 13:06:42 -080034@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -080035@synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate;
hjon6d49a8e2016-01-26 13:06:42 -080036@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
37@synthesize iceBackupCandidatePairPingInterval =
38 _iceBackupCandidatePairPingInterval;
tkchinab8f82f2016-01-27 17:50:11 -080039@synthesize keyType = _keyType;
deadbeefbe0c96f2016-05-18 16:20:14 -070040@synthesize iceCandidatePoolSize = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -070041@synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts;
42@synthesize shouldPresumeWritableWhenFullyRelayed =
43 _shouldPresumeWritableWhenFullyRelayed;
skvlada5d94ff2017-02-02 13:02:30 -080044@synthesize iceCheckMinInterval = _iceCheckMinInterval;
Steve Antond295e402017-07-14 16:06:41 -070045@synthesize iceRegatherIntervalRange = _iceRegatherIntervalRange;
Steve Anton8cb344a2018-02-27 15:34:53 -080046@synthesize sdpSemantics = _sdpSemantics;
Zeke Chinef1140e2017-10-27 15:42:08 -070047@synthesize turnCustomizer = _turnCustomizer;
hjon6d49a8e2016-01-26 13:06:42 -080048
49- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070050 // Copy defaults.
51 webrtc::PeerConnectionInterface::RTCConfiguration config(
52 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive);
jtteh465faf02017-04-04 14:00:16 -070053 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070054}
55
56- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070057 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080058 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070059 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070060 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070061 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
62 [iceServers addObject:iceServer];
63 }
64 _iceServers = iceServers;
hjon6d49a8e2016-01-26 13:06:42 -080065 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070066 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080067 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070068 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080069 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070070 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080071 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070072 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070073 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070074 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070075 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070076 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070077 _continualGatheringPolicy =
78 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
deadbeef2059bb32017-07-26 18:25:43 -070079 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010080 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070081 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
82 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
83 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -080084 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -070085 config.ice_backup_candidate_pair_ping_interval;
tkchinab8f82f2016-01-27 17:50:11 -080086 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -070087 _iceCandidatePoolSize = config.ice_candidate_pool_size;
88 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -070089 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -070090 config.presume_writable_when_fully_relayed;
91 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -080092 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -070093 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -080094 }
Steve Antond295e402017-07-14 16:06:41 -070095 if (config.ice_regather_interval_range) {
96 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
97 _iceRegatherIntervalRange =
98 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
99 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800100 _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700101 _turnCustomizer = config.turn_customizer;
hjon6d49a8e2016-01-26 13:06:42 -0800102 }
103 return self;
104}
105
106- (NSString *)description {
Steve Anton8cb344a2018-02-27 15:34:53 -0800107 static NSString *formatString =
108 @"RTCConfiguration: "
109 @"{\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}\n";
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100110
Steve Anton8cb344a2018-02-27 15:34:53 -0800111 return [NSString
112 stringWithFormat:formatString,
113 _iceServers,
114 [[self class] stringForTransportPolicy:_iceTransportPolicy],
115 [[self class] stringForBundlePolicy:_bundlePolicy],
116 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
117 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
118 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
119 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
120 [[self class] stringForSdpSemantics:_sdpSemantics],
121 _audioJitterBufferMaxPackets,
122 _audioJitterBufferFastAccelerate,
123 _iceConnectionReceivingTimeout,
124 _iceBackupCandidatePairPingInterval,
125 _iceCandidatePoolSize,
126 _shouldPruneTurnPorts,
127 _shouldPresumeWritableWhenFullyRelayed,
128 _iceCheckMinInterval,
129 _iceRegatherIntervalRange,
130 _disableLinkLocalNetworks,
131 _maxIPv6Networks];
hjon6d49a8e2016-01-26 13:06:42 -0800132}
133
134#pragma mark - Private
135
hbosa73ca562016-05-17 03:28:58 -0700136- (webrtc::PeerConnectionInterface::RTCConfiguration *)
137 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200138 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700139 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
140 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800141
142 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200143 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800144 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200145 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800146 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200147 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800148 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200149 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800150 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200151 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800152 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700153 nativeConfig->candidate_network_policy = [[self class]
154 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200155 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700156 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
deadbeef2059bb32017-07-26 18:25:43 -0700157 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100158 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200159 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800160 nativeConfig->audio_jitter_buffer_fast_accelerate =
161 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200162 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800163 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200164 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800165 _iceBackupCandidatePairPingInterval;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200166 rtc::KeyType keyType =
167 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
168 // Generate non-default certificate.
169 if (keyType != rtc::KT_DEFAULT) {
170 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
171 rtc::RTCCertificateGenerator::GenerateCertificate(
172 rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
173 if (!certificate) {
hbosa73ca562016-05-17 03:28:58 -0700174 RTCLogError(@"Failed to generate certificate.");
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200175 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800176 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200177 nativeConfig->certificates.push_back(certificate);
tkchinab8f82f2016-01-27 17:50:11 -0800178 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700179 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700180 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700181 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700182 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800183 if (_iceCheckMinInterval != nil) {
184 nativeConfig->ice_check_min_interval =
185 rtc::Optional<int>(_iceCheckMinInterval.intValue);
186 }
Steve Antond295e402017-07-14 16:06:41 -0700187 if (_iceRegatherIntervalRange != nil) {
188 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
189 _iceRegatherIntervalRange.nativeIntervalRange);
190 nativeConfig->ice_regather_interval_range =
191 rtc::Optional<rtc::IntervalRange>(*nativeIntervalRange);
192 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800193 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700194 if (_turnCustomizer) {
195 nativeConfig->turn_customizer = _turnCustomizer;
196 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200197 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800198}
199
hjon6d49a8e2016-01-26 13:06:42 -0800200+ (webrtc::PeerConnectionInterface::IceTransportsType)
201 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
202 switch (policy) {
203 case RTCIceTransportPolicyNone:
204 return webrtc::PeerConnectionInterface::kNone;
205 case RTCIceTransportPolicyRelay:
206 return webrtc::PeerConnectionInterface::kRelay;
207 case RTCIceTransportPolicyNoHost:
208 return webrtc::PeerConnectionInterface::kNoHost;
209 case RTCIceTransportPolicyAll:
210 return webrtc::PeerConnectionInterface::kAll;
211 }
212}
213
214+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
215 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
216 switch (nativeType) {
217 case webrtc::PeerConnectionInterface::kNone:
218 return RTCIceTransportPolicyNone;
219 case webrtc::PeerConnectionInterface::kRelay:
220 return RTCIceTransportPolicyRelay;
221 case webrtc::PeerConnectionInterface::kNoHost:
222 return RTCIceTransportPolicyNoHost;
223 case webrtc::PeerConnectionInterface::kAll:
224 return RTCIceTransportPolicyAll;
225 }
226}
227
228+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
229 switch (policy) {
230 case RTCIceTransportPolicyNone:
231 return @"NONE";
232 case RTCIceTransportPolicyRelay:
233 return @"RELAY";
234 case RTCIceTransportPolicyNoHost:
235 return @"NO_HOST";
236 case RTCIceTransportPolicyAll:
237 return @"ALL";
238 }
239}
240
241+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
242 (RTCBundlePolicy)policy {
243 switch (policy) {
244 case RTCBundlePolicyBalanced:
245 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
246 case RTCBundlePolicyMaxCompat:
247 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
248 case RTCBundlePolicyMaxBundle:
249 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
250 }
251}
252
253+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
254 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
255 switch (nativePolicy) {
256 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
257 return RTCBundlePolicyBalanced;
258 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
259 return RTCBundlePolicyMaxCompat;
260 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
261 return RTCBundlePolicyMaxBundle;
262 }
263}
264
265+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
266 switch (policy) {
267 case RTCBundlePolicyBalanced:
268 return @"BALANCED";
269 case RTCBundlePolicyMaxCompat:
270 return @"MAX_COMPAT";
271 case RTCBundlePolicyMaxBundle:
272 return @"MAX_BUNDLE";
273 }
274}
275
276+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
277 (RTCRtcpMuxPolicy)policy {
278 switch (policy) {
279 case RTCRtcpMuxPolicyNegotiate:
280 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
281 case RTCRtcpMuxPolicyRequire:
282 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
283 }
284}
285
286+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
287 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
288 switch (nativePolicy) {
289 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
290 return RTCRtcpMuxPolicyNegotiate;
291 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
292 return RTCRtcpMuxPolicyRequire;
293 }
294}
295
296+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
297 switch (policy) {
298 case RTCRtcpMuxPolicyNegotiate:
299 return @"NEGOTIATE";
300 case RTCRtcpMuxPolicyRequire:
301 return @"REQUIRE";
302 }
303}
304
305+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
306 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
307 switch (policy) {
308 case RTCTcpCandidatePolicyEnabled:
309 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
310 case RTCTcpCandidatePolicyDisabled:
311 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
312 }
313}
314
Honghai Zhang46007ae2016-06-03 16:31:32 -0700315+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
316 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
317 switch (policy) {
318 case RTCCandidateNetworkPolicyAll:
319 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
320 case RTCCandidateNetworkPolicyLowCost:
321 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
322 }
323}
324
hjon6d49a8e2016-01-26 13:06:42 -0800325+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
326 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
327 switch (nativePolicy) {
328 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
329 return RTCTcpCandidatePolicyEnabled;
330 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
331 return RTCTcpCandidatePolicyDisabled;
332 }
333}
334
335+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
336 switch (policy) {
337 case RTCTcpCandidatePolicyEnabled:
338 return @"TCP_ENABLED";
339 case RTCTcpCandidatePolicyDisabled:
340 return @"TCP_DISABLED";
341 }
342}
343
Honghai Zhang46007ae2016-06-03 16:31:32 -0700344+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
345 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
346 switch (nativePolicy) {
347 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
348 return RTCCandidateNetworkPolicyAll;
349 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
350 return RTCCandidateNetworkPolicyLowCost;
351 }
352}
353
354+ (NSString *)stringForCandidateNetworkPolicy:
355 (RTCCandidateNetworkPolicy)policy {
356 switch (policy) {
357 case RTCCandidateNetworkPolicyAll:
358 return @"CANDIDATE_ALL_NETWORKS";
359 case RTCCandidateNetworkPolicyLowCost:
360 return @"CANDIDATE_LOW_COST_NETWORKS";
361 }
362}
363
Honghai Zhang3108fc92016-05-11 10:10:39 -0700364+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
365 nativeContinualGatheringPolicyForPolicy:
366 (RTCContinualGatheringPolicy)policy {
367 switch (policy) {
368 case RTCContinualGatheringPolicyGatherOnce:
369 return webrtc::PeerConnectionInterface::GATHER_ONCE;
370 case RTCContinualGatheringPolicyGatherContinually:
371 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
372 }
373}
374
375+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
376 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
377 switch (nativePolicy) {
378 case webrtc::PeerConnectionInterface::GATHER_ONCE:
379 return RTCContinualGatheringPolicyGatherOnce;
380 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
381 return RTCContinualGatheringPolicyGatherContinually;
382 }
383}
384
385+ (NSString *)stringForContinualGatheringPolicy:
386 (RTCContinualGatheringPolicy)policy {
387 switch (policy) {
388 case RTCContinualGatheringPolicyGatherOnce:
389 return @"GATHER_ONCE";
390 case RTCContinualGatheringPolicyGatherContinually:
391 return @"GATHER_CONTINUALLY";
392 }
393}
394
hbosf9da44d2016-06-09 03:18:28 -0700395+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
396 (RTCEncryptionKeyType)keyType {
397 switch (keyType) {
398 case RTCEncryptionKeyTypeRSA:
399 return rtc::KT_RSA;
400 case RTCEncryptionKeyTypeECDSA:
401 return rtc::KT_ECDSA;
402 }
403}
404
Steve Anton8cb344a2018-02-27 15:34:53 -0800405+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
406 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800407 case RTCSdpSemanticsPlanB:
408 return webrtc::SdpSemantics::kPlanB;
409 case RTCSdpSemanticsUnifiedPlan:
410 return webrtc::SdpSemantics::kUnifiedPlan;
411 }
412}
413
414+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
415 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800416 case webrtc::SdpSemantics::kPlanB:
417 return RTCSdpSemanticsPlanB;
418 case webrtc::SdpSemantics::kUnifiedPlan:
419 return RTCSdpSemanticsUnifiedPlan;
420 }
421}
422
423+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
424 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800425 case RTCSdpSemanticsPlanB:
426 return @"PLAN_B";
427 case RTCSdpSemanticsUnifiedPlan:
428 return @"UNIFIED_PLAN";
429 }
430}
431
hjon6d49a8e2016-01-26 13:06:42 -0800432@end