blob: 92b334bad7871159dc9a6c8465882f1ba4c56715 [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;
Zeke Chinef1140e2017-10-27 15:42:08 -070046@synthesize turnCustomizer = _turnCustomizer;
hjon6d49a8e2016-01-26 13:06:42 -080047
48- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070049 // Copy defaults.
50 webrtc::PeerConnectionInterface::RTCConfiguration config(
51 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive);
jtteh465faf02017-04-04 14:00:16 -070052 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070053}
54
55- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070056 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080057 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070058 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070059 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070060 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
61 [iceServers addObject:iceServer];
62 }
63 _iceServers = iceServers;
hjon6d49a8e2016-01-26 13:06:42 -080064 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070065 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080066 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070067 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080068 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070069 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080070 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070071 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070072 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070073 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070074 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070075 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070076 _continualGatheringPolicy =
77 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
deadbeef2059bb32017-07-26 18:25:43 -070078 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010079 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070080 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
81 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
82 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -080083 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -070084 config.ice_backup_candidate_pair_ping_interval;
tkchinab8f82f2016-01-27 17:50:11 -080085 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -070086 _iceCandidatePoolSize = config.ice_candidate_pool_size;
87 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -070088 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -070089 config.presume_writable_when_fully_relayed;
90 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -080091 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -070092 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -080093 }
Steve Antond295e402017-07-14 16:06:41 -070094 if (config.ice_regather_interval_range) {
95 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
96 _iceRegatherIntervalRange =
97 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
98 }
Zeke Chinef1140e2017-10-27 15:42:08 -070099 _turnCustomizer = config.turn_customizer;
hjon6d49a8e2016-01-26 13:06:42 -0800100 }
101 return self;
102}
103
104- (NSString *)description {
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100105 static NSString *formatString = @"RTCConfiguration: "
106 @"{\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";
107
deadbeef2059bb32017-07-26 18:25:43 -0700108 return
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100109 [NSString stringWithFormat:formatString,
deadbeef2059bb32017-07-26 18:25:43 -0700110 _iceServers,
111 [[self class] stringForTransportPolicy:_iceTransportPolicy],
112 [[self class] stringForBundlePolicy:_bundlePolicy],
113 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
114 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
115 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
116 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
117 _audioJitterBufferMaxPackets,
118 _audioJitterBufferFastAccelerate,
119 _iceConnectionReceivingTimeout,
120 _iceBackupCandidatePairPingInterval,
121 _iceCandidatePoolSize,
122 _shouldPruneTurnPorts,
123 _shouldPresumeWritableWhenFullyRelayed,
124 _iceCheckMinInterval,
125 _iceRegatherIntervalRange,
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100126 _disableLinkLocalNetworks,
deadbeef2059bb32017-07-26 18:25:43 -0700127 _maxIPv6Networks];
hjon6d49a8e2016-01-26 13:06:42 -0800128}
129
130#pragma mark - Private
131
hbosa73ca562016-05-17 03:28:58 -0700132- (webrtc::PeerConnectionInterface::RTCConfiguration *)
133 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200134 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700135 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
136 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800137
138 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200139 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800140 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200141 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800142 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200143 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800144 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200145 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800146 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200147 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800148 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700149 nativeConfig->candidate_network_policy = [[self class]
150 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200151 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700152 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
deadbeef2059bb32017-07-26 18:25:43 -0700153 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100154 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200155 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800156 nativeConfig->audio_jitter_buffer_fast_accelerate =
157 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200158 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800159 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200160 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800161 _iceBackupCandidatePairPingInterval;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200162 rtc::KeyType keyType =
163 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
164 // Generate non-default certificate.
165 if (keyType != rtc::KT_DEFAULT) {
166 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
167 rtc::RTCCertificateGenerator::GenerateCertificate(
168 rtc::KeyParams(keyType), rtc::Optional<uint64_t>());
169 if (!certificate) {
hbosa73ca562016-05-17 03:28:58 -0700170 RTCLogError(@"Failed to generate certificate.");
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200171 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800172 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200173 nativeConfig->certificates.push_back(certificate);
tkchinab8f82f2016-01-27 17:50:11 -0800174 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700175 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700176 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700177 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700178 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800179 if (_iceCheckMinInterval != nil) {
180 nativeConfig->ice_check_min_interval =
181 rtc::Optional<int>(_iceCheckMinInterval.intValue);
182 }
Steve Antond295e402017-07-14 16:06:41 -0700183 if (_iceRegatherIntervalRange != nil) {
184 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
185 _iceRegatherIntervalRange.nativeIntervalRange);
186 nativeConfig->ice_regather_interval_range =
187 rtc::Optional<rtc::IntervalRange>(*nativeIntervalRange);
188 }
Zeke Chinef1140e2017-10-27 15:42:08 -0700189 if (_turnCustomizer) {
190 nativeConfig->turn_customizer = _turnCustomizer;
191 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200192 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800193}
194
hjon6d49a8e2016-01-26 13:06:42 -0800195+ (webrtc::PeerConnectionInterface::IceTransportsType)
196 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
197 switch (policy) {
198 case RTCIceTransportPolicyNone:
199 return webrtc::PeerConnectionInterface::kNone;
200 case RTCIceTransportPolicyRelay:
201 return webrtc::PeerConnectionInterface::kRelay;
202 case RTCIceTransportPolicyNoHost:
203 return webrtc::PeerConnectionInterface::kNoHost;
204 case RTCIceTransportPolicyAll:
205 return webrtc::PeerConnectionInterface::kAll;
206 }
207}
208
209+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
210 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
211 switch (nativeType) {
212 case webrtc::PeerConnectionInterface::kNone:
213 return RTCIceTransportPolicyNone;
214 case webrtc::PeerConnectionInterface::kRelay:
215 return RTCIceTransportPolicyRelay;
216 case webrtc::PeerConnectionInterface::kNoHost:
217 return RTCIceTransportPolicyNoHost;
218 case webrtc::PeerConnectionInterface::kAll:
219 return RTCIceTransportPolicyAll;
220 }
221}
222
223+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
224 switch (policy) {
225 case RTCIceTransportPolicyNone:
226 return @"NONE";
227 case RTCIceTransportPolicyRelay:
228 return @"RELAY";
229 case RTCIceTransportPolicyNoHost:
230 return @"NO_HOST";
231 case RTCIceTransportPolicyAll:
232 return @"ALL";
233 }
234}
235
236+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
237 (RTCBundlePolicy)policy {
238 switch (policy) {
239 case RTCBundlePolicyBalanced:
240 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
241 case RTCBundlePolicyMaxCompat:
242 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
243 case RTCBundlePolicyMaxBundle:
244 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
245 }
246}
247
248+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
249 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
250 switch (nativePolicy) {
251 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
252 return RTCBundlePolicyBalanced;
253 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
254 return RTCBundlePolicyMaxCompat;
255 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
256 return RTCBundlePolicyMaxBundle;
257 }
258}
259
260+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
261 switch (policy) {
262 case RTCBundlePolicyBalanced:
263 return @"BALANCED";
264 case RTCBundlePolicyMaxCompat:
265 return @"MAX_COMPAT";
266 case RTCBundlePolicyMaxBundle:
267 return @"MAX_BUNDLE";
268 }
269}
270
271+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
272 (RTCRtcpMuxPolicy)policy {
273 switch (policy) {
274 case RTCRtcpMuxPolicyNegotiate:
275 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
276 case RTCRtcpMuxPolicyRequire:
277 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
278 }
279}
280
281+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
282 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
283 switch (nativePolicy) {
284 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
285 return RTCRtcpMuxPolicyNegotiate;
286 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
287 return RTCRtcpMuxPolicyRequire;
288 }
289}
290
291+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
292 switch (policy) {
293 case RTCRtcpMuxPolicyNegotiate:
294 return @"NEGOTIATE";
295 case RTCRtcpMuxPolicyRequire:
296 return @"REQUIRE";
297 }
298}
299
300+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
301 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
302 switch (policy) {
303 case RTCTcpCandidatePolicyEnabled:
304 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
305 case RTCTcpCandidatePolicyDisabled:
306 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
307 }
308}
309
Honghai Zhang46007ae2016-06-03 16:31:32 -0700310+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
311 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
312 switch (policy) {
313 case RTCCandidateNetworkPolicyAll:
314 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
315 case RTCCandidateNetworkPolicyLowCost:
316 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
317 }
318}
319
hjon6d49a8e2016-01-26 13:06:42 -0800320+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
321 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
322 switch (nativePolicy) {
323 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
324 return RTCTcpCandidatePolicyEnabled;
325 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
326 return RTCTcpCandidatePolicyDisabled;
327 }
328}
329
330+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
331 switch (policy) {
332 case RTCTcpCandidatePolicyEnabled:
333 return @"TCP_ENABLED";
334 case RTCTcpCandidatePolicyDisabled:
335 return @"TCP_DISABLED";
336 }
337}
338
Honghai Zhang46007ae2016-06-03 16:31:32 -0700339+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
340 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
341 switch (nativePolicy) {
342 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
343 return RTCCandidateNetworkPolicyAll;
344 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
345 return RTCCandidateNetworkPolicyLowCost;
346 }
347}
348
349+ (NSString *)stringForCandidateNetworkPolicy:
350 (RTCCandidateNetworkPolicy)policy {
351 switch (policy) {
352 case RTCCandidateNetworkPolicyAll:
353 return @"CANDIDATE_ALL_NETWORKS";
354 case RTCCandidateNetworkPolicyLowCost:
355 return @"CANDIDATE_LOW_COST_NETWORKS";
356 }
357}
358
Honghai Zhang3108fc92016-05-11 10:10:39 -0700359+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
360 nativeContinualGatheringPolicyForPolicy:
361 (RTCContinualGatheringPolicy)policy {
362 switch (policy) {
363 case RTCContinualGatheringPolicyGatherOnce:
364 return webrtc::PeerConnectionInterface::GATHER_ONCE;
365 case RTCContinualGatheringPolicyGatherContinually:
366 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
367 }
368}
369
370+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
371 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
372 switch (nativePolicy) {
373 case webrtc::PeerConnectionInterface::GATHER_ONCE:
374 return RTCContinualGatheringPolicyGatherOnce;
375 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
376 return RTCContinualGatheringPolicyGatherContinually;
377 }
378}
379
380+ (NSString *)stringForContinualGatheringPolicy:
381 (RTCContinualGatheringPolicy)policy {
382 switch (policy) {
383 case RTCContinualGatheringPolicyGatherOnce:
384 return @"GATHER_ONCE";
385 case RTCContinualGatheringPolicyGatherContinually:
386 return @"GATHER_CONTINUALLY";
387 }
388}
389
hbosf9da44d2016-06-09 03:18:28 -0700390+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
391 (RTCEncryptionKeyType)keyType {
392 switch (keyType) {
393 case RTCEncryptionKeyTypeRSA:
394 return rtc::KT_RSA;
395 case RTCEncryptionKeyTypeECDSA:
396 return rtc::KT_ECDSA;
397 }
398}
399
hjon6d49a8e2016-01-26 13:06:42 -0800400@end