blob: 4bd0450f690faa11f475c4063cd7823bf867349f [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;
Zhi Huangb57e1692018-06-12 11:41:11 -070048@synthesize activeResetSrtpParams = _activeResetSrtpParams;
hjon6d49a8e2016-01-26 13:06:42 -080049
50- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070051 // Copy defaults.
52 webrtc::PeerConnectionInterface::RTCConfiguration config(
53 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive);
jtteh465faf02017-04-04 14:00:16 -070054 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070055}
56
57- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070058 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080059 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070060 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070061 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070062 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
63 [iceServers addObject:iceServer];
64 }
65 _iceServers = iceServers;
hjon6d49a8e2016-01-26 13:06:42 -080066 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070067 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080068 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070069 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080070 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070071 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080072 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070073 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070074 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070075 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070076 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070077 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070078 _continualGatheringPolicy =
79 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
deadbeef2059bb32017-07-26 18:25:43 -070080 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010081 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070082 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
83 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
84 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -080085 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -070086 config.ice_backup_candidate_pair_ping_interval;
tkchinab8f82f2016-01-27 17:50:11 -080087 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -070088 _iceCandidatePoolSize = config.ice_candidate_pool_size;
89 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -070090 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -070091 config.presume_writable_when_fully_relayed;
92 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -080093 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -070094 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -080095 }
Steve Antond295e402017-07-14 16:06:41 -070096 if (config.ice_regather_interval_range) {
97 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
98 _iceRegatherIntervalRange =
99 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
100 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800101 _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700102 _turnCustomizer = config.turn_customizer;
Zhi Huangb57e1692018-06-12 11:41:11 -0700103 _activeResetSrtpParams = config.active_reset_srtp_params;
hjon6d49a8e2016-01-26 13:06:42 -0800104 }
105 return self;
106}
107
108- (NSString *)description {
Steve Anton8cb344a2018-02-27 15:34:53 -0800109 static NSString *formatString =
110 @"RTCConfiguration: "
Zhi Huangb57e1692018-06-12 11:41:11 -0700111 @"{\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";
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100112
Steve Anton8cb344a2018-02-27 15:34:53 -0800113 return [NSString
114 stringWithFormat:formatString,
115 _iceServers,
116 [[self class] stringForTransportPolicy:_iceTransportPolicy],
117 [[self class] stringForBundlePolicy:_bundlePolicy],
118 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
119 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
120 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
121 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
122 [[self class] stringForSdpSemantics:_sdpSemantics],
123 _audioJitterBufferMaxPackets,
124 _audioJitterBufferFastAccelerate,
125 _iceConnectionReceivingTimeout,
126 _iceBackupCandidatePairPingInterval,
127 _iceCandidatePoolSize,
128 _shouldPruneTurnPorts,
129 _shouldPresumeWritableWhenFullyRelayed,
130 _iceCheckMinInterval,
131 _iceRegatherIntervalRange,
132 _disableLinkLocalNetworks,
Zhi Huangb57e1692018-06-12 11:41:11 -0700133 _maxIPv6Networks,
134 _activeResetSrtpParams];
hjon6d49a8e2016-01-26 13:06:42 -0800135}
136
137#pragma mark - Private
138
hbosa73ca562016-05-17 03:28:58 -0700139- (webrtc::PeerConnectionInterface::RTCConfiguration *)
140 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200141 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700142 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
143 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800144
145 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200146 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800147 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200148 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800149 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200150 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800151 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200152 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800153 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200154 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800155 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700156 nativeConfig->candidate_network_policy = [[self class]
157 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200158 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700159 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
deadbeef2059bb32017-07-26 18:25:43 -0700160 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100161 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200162 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800163 nativeConfig->audio_jitter_buffer_fast_accelerate =
164 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200165 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800166 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200167 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800168 _iceBackupCandidatePairPingInterval;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200169 rtc::KeyType keyType =
170 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
171 // Generate non-default certificate.
172 if (keyType != rtc::KT_DEFAULT) {
173 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
174 rtc::RTCCertificateGenerator::GenerateCertificate(
175 rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
176 if (!certificate) {
hbosa73ca562016-05-17 03:28:58 -0700177 RTCLogError(@"Failed to generate certificate.");
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200178 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800179 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200180 nativeConfig->certificates.push_back(certificate);
tkchinab8f82f2016-01-27 17:50:11 -0800181 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700182 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700183 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700184 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700185 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800186 if (_iceCheckMinInterval != nil) {
187 nativeConfig->ice_check_min_interval =
188 rtc::Optional<int>(_iceCheckMinInterval.intValue);
189 }
Steve Antond295e402017-07-14 16:06:41 -0700190 if (_iceRegatherIntervalRange != nil) {
191 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
192 _iceRegatherIntervalRange.nativeIntervalRange);
193 nativeConfig->ice_regather_interval_range =
194 rtc::Optional<rtc::IntervalRange>(*nativeIntervalRange);
195 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800196 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700197 if (_turnCustomizer) {
198 nativeConfig->turn_customizer = _turnCustomizer;
199 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700200 nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200201 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800202}
203
hjon6d49a8e2016-01-26 13:06:42 -0800204+ (webrtc::PeerConnectionInterface::IceTransportsType)
205 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
206 switch (policy) {
207 case RTCIceTransportPolicyNone:
208 return webrtc::PeerConnectionInterface::kNone;
209 case RTCIceTransportPolicyRelay:
210 return webrtc::PeerConnectionInterface::kRelay;
211 case RTCIceTransportPolicyNoHost:
212 return webrtc::PeerConnectionInterface::kNoHost;
213 case RTCIceTransportPolicyAll:
214 return webrtc::PeerConnectionInterface::kAll;
215 }
216}
217
218+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
219 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
220 switch (nativeType) {
221 case webrtc::PeerConnectionInterface::kNone:
222 return RTCIceTransportPolicyNone;
223 case webrtc::PeerConnectionInterface::kRelay:
224 return RTCIceTransportPolicyRelay;
225 case webrtc::PeerConnectionInterface::kNoHost:
226 return RTCIceTransportPolicyNoHost;
227 case webrtc::PeerConnectionInterface::kAll:
228 return RTCIceTransportPolicyAll;
229 }
230}
231
232+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
233 switch (policy) {
234 case RTCIceTransportPolicyNone:
235 return @"NONE";
236 case RTCIceTransportPolicyRelay:
237 return @"RELAY";
238 case RTCIceTransportPolicyNoHost:
239 return @"NO_HOST";
240 case RTCIceTransportPolicyAll:
241 return @"ALL";
242 }
243}
244
245+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
246 (RTCBundlePolicy)policy {
247 switch (policy) {
248 case RTCBundlePolicyBalanced:
249 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
250 case RTCBundlePolicyMaxCompat:
251 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
252 case RTCBundlePolicyMaxBundle:
253 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
254 }
255}
256
257+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
258 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
259 switch (nativePolicy) {
260 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
261 return RTCBundlePolicyBalanced;
262 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
263 return RTCBundlePolicyMaxCompat;
264 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
265 return RTCBundlePolicyMaxBundle;
266 }
267}
268
269+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
270 switch (policy) {
271 case RTCBundlePolicyBalanced:
272 return @"BALANCED";
273 case RTCBundlePolicyMaxCompat:
274 return @"MAX_COMPAT";
275 case RTCBundlePolicyMaxBundle:
276 return @"MAX_BUNDLE";
277 }
278}
279
280+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
281 (RTCRtcpMuxPolicy)policy {
282 switch (policy) {
283 case RTCRtcpMuxPolicyNegotiate:
284 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
285 case RTCRtcpMuxPolicyRequire:
286 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
287 }
288}
289
290+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
291 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
292 switch (nativePolicy) {
293 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
294 return RTCRtcpMuxPolicyNegotiate;
295 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
296 return RTCRtcpMuxPolicyRequire;
297 }
298}
299
300+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
301 switch (policy) {
302 case RTCRtcpMuxPolicyNegotiate:
303 return @"NEGOTIATE";
304 case RTCRtcpMuxPolicyRequire:
305 return @"REQUIRE";
306 }
307}
308
309+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
310 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
311 switch (policy) {
312 case RTCTcpCandidatePolicyEnabled:
313 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
314 case RTCTcpCandidatePolicyDisabled:
315 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
316 }
317}
318
Honghai Zhang46007ae2016-06-03 16:31:32 -0700319+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
320 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
321 switch (policy) {
322 case RTCCandidateNetworkPolicyAll:
323 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
324 case RTCCandidateNetworkPolicyLowCost:
325 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
326 }
327}
328
hjon6d49a8e2016-01-26 13:06:42 -0800329+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
330 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
331 switch (nativePolicy) {
332 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
333 return RTCTcpCandidatePolicyEnabled;
334 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
335 return RTCTcpCandidatePolicyDisabled;
336 }
337}
338
339+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
340 switch (policy) {
341 case RTCTcpCandidatePolicyEnabled:
342 return @"TCP_ENABLED";
343 case RTCTcpCandidatePolicyDisabled:
344 return @"TCP_DISABLED";
345 }
346}
347
Honghai Zhang46007ae2016-06-03 16:31:32 -0700348+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
349 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
350 switch (nativePolicy) {
351 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
352 return RTCCandidateNetworkPolicyAll;
353 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
354 return RTCCandidateNetworkPolicyLowCost;
355 }
356}
357
358+ (NSString *)stringForCandidateNetworkPolicy:
359 (RTCCandidateNetworkPolicy)policy {
360 switch (policy) {
361 case RTCCandidateNetworkPolicyAll:
362 return @"CANDIDATE_ALL_NETWORKS";
363 case RTCCandidateNetworkPolicyLowCost:
364 return @"CANDIDATE_LOW_COST_NETWORKS";
365 }
366}
367
Honghai Zhang3108fc92016-05-11 10:10:39 -0700368+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
369 nativeContinualGatheringPolicyForPolicy:
370 (RTCContinualGatheringPolicy)policy {
371 switch (policy) {
372 case RTCContinualGatheringPolicyGatherOnce:
373 return webrtc::PeerConnectionInterface::GATHER_ONCE;
374 case RTCContinualGatheringPolicyGatherContinually:
375 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
376 }
377}
378
379+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
380 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
381 switch (nativePolicy) {
382 case webrtc::PeerConnectionInterface::GATHER_ONCE:
383 return RTCContinualGatheringPolicyGatherOnce;
384 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
385 return RTCContinualGatheringPolicyGatherContinually;
386 }
387}
388
389+ (NSString *)stringForContinualGatheringPolicy:
390 (RTCContinualGatheringPolicy)policy {
391 switch (policy) {
392 case RTCContinualGatheringPolicyGatherOnce:
393 return @"GATHER_ONCE";
394 case RTCContinualGatheringPolicyGatherContinually:
395 return @"GATHER_CONTINUALLY";
396 }
397}
398
hbosf9da44d2016-06-09 03:18:28 -0700399+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
400 (RTCEncryptionKeyType)keyType {
401 switch (keyType) {
402 case RTCEncryptionKeyTypeRSA:
403 return rtc::KT_RSA;
404 case RTCEncryptionKeyTypeECDSA:
405 return rtc::KT_ECDSA;
406 }
407}
408
Steve Anton8cb344a2018-02-27 15:34:53 -0800409+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
410 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800411 case RTCSdpSemanticsPlanB:
412 return webrtc::SdpSemantics::kPlanB;
413 case RTCSdpSemanticsUnifiedPlan:
414 return webrtc::SdpSemantics::kUnifiedPlan;
415 }
416}
417
418+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
419 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800420 case webrtc::SdpSemantics::kPlanB:
421 return RTCSdpSemanticsPlanB;
422 case webrtc::SdpSemantics::kUnifiedPlan:
423 return RTCSdpSemanticsUnifiedPlan;
424 }
425}
426
427+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
428 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800429 case RTCSdpSemanticsPlanB:
430 return @"PLAN_B";
431 case RTCSdpSemanticsUnifiedPlan:
432 return @"UNIFIED_PLAN";
433 }
434}
435
hjon6d49a8e2016-01-26 13:06:42 -0800436@end