blob: a357085caf016bacc957f9401076958f7bd9a22c [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 =
Danil Chapovalov196100e2018-06-21 10:17:24 +0200174 rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType),
175 absl::optional<uint64_t>());
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200176 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) {
Danil Chapovalov196100e2018-06-21 10:17:24 +0200187 nativeConfig->ice_check_min_interval = absl::optional<int>(_iceCheckMinInterval.intValue);
skvlada5d94ff2017-02-02 13:02:30 -0800188 }
Steve Antond295e402017-07-14 16:06:41 -0700189 if (_iceRegatherIntervalRange != nil) {
190 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
191 _iceRegatherIntervalRange.nativeIntervalRange);
192 nativeConfig->ice_regather_interval_range =
Danil Chapovalov196100e2018-06-21 10:17:24 +0200193 absl::optional<rtc::IntervalRange>(*nativeIntervalRange);
Steve Antond295e402017-07-14 16:06:41 -0700194 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800195 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700196 if (_turnCustomizer) {
197 nativeConfig->turn_customizer = _turnCustomizer;
198 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700199 nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200200 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800201}
202
hjon6d49a8e2016-01-26 13:06:42 -0800203+ (webrtc::PeerConnectionInterface::IceTransportsType)
204 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
205 switch (policy) {
206 case RTCIceTransportPolicyNone:
207 return webrtc::PeerConnectionInterface::kNone;
208 case RTCIceTransportPolicyRelay:
209 return webrtc::PeerConnectionInterface::kRelay;
210 case RTCIceTransportPolicyNoHost:
211 return webrtc::PeerConnectionInterface::kNoHost;
212 case RTCIceTransportPolicyAll:
213 return webrtc::PeerConnectionInterface::kAll;
214 }
215}
216
217+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
218 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
219 switch (nativeType) {
220 case webrtc::PeerConnectionInterface::kNone:
221 return RTCIceTransportPolicyNone;
222 case webrtc::PeerConnectionInterface::kRelay:
223 return RTCIceTransportPolicyRelay;
224 case webrtc::PeerConnectionInterface::kNoHost:
225 return RTCIceTransportPolicyNoHost;
226 case webrtc::PeerConnectionInterface::kAll:
227 return RTCIceTransportPolicyAll;
228 }
229}
230
231+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
232 switch (policy) {
233 case RTCIceTransportPolicyNone:
234 return @"NONE";
235 case RTCIceTransportPolicyRelay:
236 return @"RELAY";
237 case RTCIceTransportPolicyNoHost:
238 return @"NO_HOST";
239 case RTCIceTransportPolicyAll:
240 return @"ALL";
241 }
242}
243
244+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
245 (RTCBundlePolicy)policy {
246 switch (policy) {
247 case RTCBundlePolicyBalanced:
248 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
249 case RTCBundlePolicyMaxCompat:
250 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
251 case RTCBundlePolicyMaxBundle:
252 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
253 }
254}
255
256+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
257 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
258 switch (nativePolicy) {
259 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
260 return RTCBundlePolicyBalanced;
261 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
262 return RTCBundlePolicyMaxCompat;
263 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
264 return RTCBundlePolicyMaxBundle;
265 }
266}
267
268+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
269 switch (policy) {
270 case RTCBundlePolicyBalanced:
271 return @"BALANCED";
272 case RTCBundlePolicyMaxCompat:
273 return @"MAX_COMPAT";
274 case RTCBundlePolicyMaxBundle:
275 return @"MAX_BUNDLE";
276 }
277}
278
279+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
280 (RTCRtcpMuxPolicy)policy {
281 switch (policy) {
282 case RTCRtcpMuxPolicyNegotiate:
283 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
284 case RTCRtcpMuxPolicyRequire:
285 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
286 }
287}
288
289+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
290 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
291 switch (nativePolicy) {
292 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
293 return RTCRtcpMuxPolicyNegotiate;
294 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
295 return RTCRtcpMuxPolicyRequire;
296 }
297}
298
299+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
300 switch (policy) {
301 case RTCRtcpMuxPolicyNegotiate:
302 return @"NEGOTIATE";
303 case RTCRtcpMuxPolicyRequire:
304 return @"REQUIRE";
305 }
306}
307
308+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
309 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
310 switch (policy) {
311 case RTCTcpCandidatePolicyEnabled:
312 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
313 case RTCTcpCandidatePolicyDisabled:
314 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
315 }
316}
317
Honghai Zhang46007ae2016-06-03 16:31:32 -0700318+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
319 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
320 switch (policy) {
321 case RTCCandidateNetworkPolicyAll:
322 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
323 case RTCCandidateNetworkPolicyLowCost:
324 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
325 }
326}
327
hjon6d49a8e2016-01-26 13:06:42 -0800328+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
329 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
330 switch (nativePolicy) {
331 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
332 return RTCTcpCandidatePolicyEnabled;
333 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
334 return RTCTcpCandidatePolicyDisabled;
335 }
336}
337
338+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
339 switch (policy) {
340 case RTCTcpCandidatePolicyEnabled:
341 return @"TCP_ENABLED";
342 case RTCTcpCandidatePolicyDisabled:
343 return @"TCP_DISABLED";
344 }
345}
346
Honghai Zhang46007ae2016-06-03 16:31:32 -0700347+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
348 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
349 switch (nativePolicy) {
350 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
351 return RTCCandidateNetworkPolicyAll;
352 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
353 return RTCCandidateNetworkPolicyLowCost;
354 }
355}
356
357+ (NSString *)stringForCandidateNetworkPolicy:
358 (RTCCandidateNetworkPolicy)policy {
359 switch (policy) {
360 case RTCCandidateNetworkPolicyAll:
361 return @"CANDIDATE_ALL_NETWORKS";
362 case RTCCandidateNetworkPolicyLowCost:
363 return @"CANDIDATE_LOW_COST_NETWORKS";
364 }
365}
366
Honghai Zhang3108fc92016-05-11 10:10:39 -0700367+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
368 nativeContinualGatheringPolicyForPolicy:
369 (RTCContinualGatheringPolicy)policy {
370 switch (policy) {
371 case RTCContinualGatheringPolicyGatherOnce:
372 return webrtc::PeerConnectionInterface::GATHER_ONCE;
373 case RTCContinualGatheringPolicyGatherContinually:
374 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
375 }
376}
377
378+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
379 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
380 switch (nativePolicy) {
381 case webrtc::PeerConnectionInterface::GATHER_ONCE:
382 return RTCContinualGatheringPolicyGatherOnce;
383 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
384 return RTCContinualGatheringPolicyGatherContinually;
385 }
386}
387
388+ (NSString *)stringForContinualGatheringPolicy:
389 (RTCContinualGatheringPolicy)policy {
390 switch (policy) {
391 case RTCContinualGatheringPolicyGatherOnce:
392 return @"GATHER_ONCE";
393 case RTCContinualGatheringPolicyGatherContinually:
394 return @"GATHER_CONTINUALLY";
395 }
396}
397
hbosf9da44d2016-06-09 03:18:28 -0700398+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
399 (RTCEncryptionKeyType)keyType {
400 switch (keyType) {
401 case RTCEncryptionKeyTypeRSA:
402 return rtc::KT_RSA;
403 case RTCEncryptionKeyTypeECDSA:
404 return rtc::KT_ECDSA;
405 }
406}
407
Steve Anton8cb344a2018-02-27 15:34:53 -0800408+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
409 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800410 case RTCSdpSemanticsPlanB:
411 return webrtc::SdpSemantics::kPlanB;
412 case RTCSdpSemanticsUnifiedPlan:
413 return webrtc::SdpSemantics::kUnifiedPlan;
414 }
415}
416
417+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
418 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800419 case webrtc::SdpSemantics::kPlanB:
420 return RTCSdpSemanticsPlanB;
421 case webrtc::SdpSemantics::kUnifiedPlan:
422 return RTCSdpSemanticsUnifiedPlan;
423 }
424}
425
426+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
427 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800428 case RTCSdpSemanticsPlanB:
429 return @"PLAN_B";
430 case RTCSdpSemanticsUnifiedPlan:
431 return @"UNIFIED_PLAN";
432 }
433}
434
hjon6d49a8e2016-01-26 13:06:42 -0800435@end