blob: 73a0fa9aa5fd80db4cd27cd293b650b7b800695f [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;
hjon6d49a8e2016-01-26 13:06:42 -080051
52- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070053 // Copy defaults.
Yuriy Pavlyshak8cec4fb2018-09-07 16:43:31 +020054 webrtc::PeerConnectionInterface::RTCConfiguration config;
jtteh465faf02017-04-04 14:00:16 -070055 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070056}
57
58- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070059 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080060 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070061 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070062 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070063 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
64 [iceServers addObject:iceServer];
65 }
66 _iceServers = iceServers;
Michael Iedemaccee56b2018-07-05 15:28:24 +020067 if (!config.certificates.empty()) {
68 rtc::scoped_refptr<rtc::RTCCertificate> native_cert;
69 native_cert = config.certificates[0];
70 rtc::RTCCertificatePEM native_pem = native_cert->ToPEM();
71 _certificate =
72 [[RTCCertificate alloc] initWithPrivateKey:@(native_pem.private_key().c_str())
73 certificate:@(native_pem.certificate().c_str())];
74 }
hjon6d49a8e2016-01-26 13:06:42 -080075 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070076 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080077 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070078 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080079 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070080 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080081 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070082 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070083 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070084 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070085 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070086 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070087 _continualGatheringPolicy =
88 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
deadbeef2059bb32017-07-26 18:25:43 -070089 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010090 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070091 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
92 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
93 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -080094 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -070095 config.ice_backup_candidate_pair_ping_interval;
tkchinab8f82f2016-01-27 17:50:11 -080096 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -070097 _iceCandidatePoolSize = config.ice_candidate_pool_size;
98 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -070099 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -0700100 config.presume_writable_when_fully_relayed;
101 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -0800102 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -0700103 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -0800104 }
Steve Antond295e402017-07-14 16:06:41 -0700105 if (config.ice_regather_interval_range) {
106 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
107 _iceRegatherIntervalRange =
108 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
109 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800110 _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700111 _turnCustomizer = config.turn_customizer;
Zhi Huangb57e1692018-06-12 11:41:11 -0700112 _activeResetSrtpParams = config.active_reset_srtp_params;
hjon6d49a8e2016-01-26 13:06:42 -0800113 }
114 return self;
115}
116
117- (NSString *)description {
Steve Anton8cb344a2018-02-27 15:34:53 -0800118 static NSString *formatString =
119 @"RTCConfiguration: "
Zhi Huangb57e1692018-06-12 11:41:11 -0700120 @"{\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 +0100121
Steve Anton8cb344a2018-02-27 15:34:53 -0800122 return [NSString
123 stringWithFormat:formatString,
124 _iceServers,
125 [[self class] stringForTransportPolicy:_iceTransportPolicy],
126 [[self class] stringForBundlePolicy:_bundlePolicy],
127 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
128 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
129 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
130 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
131 [[self class] stringForSdpSemantics:_sdpSemantics],
132 _audioJitterBufferMaxPackets,
133 _audioJitterBufferFastAccelerate,
134 _iceConnectionReceivingTimeout,
135 _iceBackupCandidatePairPingInterval,
136 _iceCandidatePoolSize,
137 _shouldPruneTurnPorts,
138 _shouldPresumeWritableWhenFullyRelayed,
139 _iceCheckMinInterval,
140 _iceRegatherIntervalRange,
141 _disableLinkLocalNetworks,
Zhi Huangb57e1692018-06-12 11:41:11 -0700142 _maxIPv6Networks,
143 _activeResetSrtpParams];
hjon6d49a8e2016-01-26 13:06:42 -0800144}
145
146#pragma mark - Private
147
hbosa73ca562016-05-17 03:28:58 -0700148- (webrtc::PeerConnectionInterface::RTCConfiguration *)
149 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200150 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700151 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
152 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800153
154 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200155 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800156 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200157 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800158 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200159 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800160 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200161 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800162 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200163 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800164 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700165 nativeConfig->candidate_network_policy = [[self class]
166 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200167 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700168 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
deadbeef2059bb32017-07-26 18:25:43 -0700169 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100170 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200171 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800172 nativeConfig->audio_jitter_buffer_fast_accelerate =
173 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200174 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800175 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200176 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800177 _iceBackupCandidatePairPingInterval;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200178 rtc::KeyType keyType =
179 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
Michael Iedemaccee56b2018-07-05 15:28:24 +0200180 if (_certificate != nullptr) {
181 // if offered a pemcert use it...
182 RTC_LOG(LS_INFO) << "Have configured cert - using it.";
183 std::string pem_private_key = [[_certificate private_key] UTF8String];
184 std::string pem_certificate = [[_certificate certificate] UTF8String];
185 rtc::RTCCertificatePEM pem = rtc::RTCCertificatePEM(pem_private_key, pem_certificate);
186 rtc::scoped_refptr<rtc::RTCCertificate> certificate = rtc::RTCCertificate::FromPEM(pem);
187 RTC_LOG(LS_INFO) << "Created cert from PEM strings.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200188 if (!certificate) {
Michael Iedemaccee56b2018-07-05 15:28:24 +0200189 RTC_LOG(LS_ERROR) << "Failed to generate certificate from PEM.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200190 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800191 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200192 nativeConfig->certificates.push_back(certificate);
Michael Iedemaccee56b2018-07-05 15:28:24 +0200193 } else {
194 RTC_LOG(LS_INFO) << "Don't have configured cert.";
195 // Generate non-default certificate.
196 if (keyType != rtc::KT_DEFAULT) {
197 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
198 rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType),
199 absl::optional<uint64_t>());
200 if (!certificate) {
201 RTCLogError(@"Failed to generate certificate.");
202 return nullptr;
203 }
204 nativeConfig->certificates.push_back(certificate);
205 }
tkchinab8f82f2016-01-27 17:50:11 -0800206 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700207 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700208 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700209 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700210 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800211 if (_iceCheckMinInterval != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +0200212 nativeConfig->ice_check_min_interval = absl::optional<int>(_iceCheckMinInterval.intValue);
skvlada5d94ff2017-02-02 13:02:30 -0800213 }
Steve Antond295e402017-07-14 16:06:41 -0700214 if (_iceRegatherIntervalRange != nil) {
215 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
216 _iceRegatherIntervalRange.nativeIntervalRange);
217 nativeConfig->ice_regather_interval_range =
Danil Chapovalov196100e2018-06-21 10:17:24 +0200218 absl::optional<rtc::IntervalRange>(*nativeIntervalRange);
Steve Antond295e402017-07-14 16:06:41 -0700219 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800220 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700221 if (_turnCustomizer) {
222 nativeConfig->turn_customizer = _turnCustomizer;
223 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700224 nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200225 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800226}
227
hjon6d49a8e2016-01-26 13:06:42 -0800228+ (webrtc::PeerConnectionInterface::IceTransportsType)
229 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
230 switch (policy) {
231 case RTCIceTransportPolicyNone:
232 return webrtc::PeerConnectionInterface::kNone;
233 case RTCIceTransportPolicyRelay:
234 return webrtc::PeerConnectionInterface::kRelay;
235 case RTCIceTransportPolicyNoHost:
236 return webrtc::PeerConnectionInterface::kNoHost;
237 case RTCIceTransportPolicyAll:
238 return webrtc::PeerConnectionInterface::kAll;
239 }
240}
241
242+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
243 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
244 switch (nativeType) {
245 case webrtc::PeerConnectionInterface::kNone:
246 return RTCIceTransportPolicyNone;
247 case webrtc::PeerConnectionInterface::kRelay:
248 return RTCIceTransportPolicyRelay;
249 case webrtc::PeerConnectionInterface::kNoHost:
250 return RTCIceTransportPolicyNoHost;
251 case webrtc::PeerConnectionInterface::kAll:
252 return RTCIceTransportPolicyAll;
253 }
254}
255
256+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
257 switch (policy) {
258 case RTCIceTransportPolicyNone:
259 return @"NONE";
260 case RTCIceTransportPolicyRelay:
261 return @"RELAY";
262 case RTCIceTransportPolicyNoHost:
263 return @"NO_HOST";
264 case RTCIceTransportPolicyAll:
265 return @"ALL";
266 }
267}
268
269+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
270 (RTCBundlePolicy)policy {
271 switch (policy) {
272 case RTCBundlePolicyBalanced:
273 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
274 case RTCBundlePolicyMaxCompat:
275 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
276 case RTCBundlePolicyMaxBundle:
277 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
278 }
279}
280
281+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
282 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
283 switch (nativePolicy) {
284 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
285 return RTCBundlePolicyBalanced;
286 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
287 return RTCBundlePolicyMaxCompat;
288 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
289 return RTCBundlePolicyMaxBundle;
290 }
291}
292
293+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
294 switch (policy) {
295 case RTCBundlePolicyBalanced:
296 return @"BALANCED";
297 case RTCBundlePolicyMaxCompat:
298 return @"MAX_COMPAT";
299 case RTCBundlePolicyMaxBundle:
300 return @"MAX_BUNDLE";
301 }
302}
303
304+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
305 (RTCRtcpMuxPolicy)policy {
306 switch (policy) {
307 case RTCRtcpMuxPolicyNegotiate:
308 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
309 case RTCRtcpMuxPolicyRequire:
310 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
311 }
312}
313
314+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
315 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
316 switch (nativePolicy) {
317 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
318 return RTCRtcpMuxPolicyNegotiate;
319 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
320 return RTCRtcpMuxPolicyRequire;
321 }
322}
323
324+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
325 switch (policy) {
326 case RTCRtcpMuxPolicyNegotiate:
327 return @"NEGOTIATE";
328 case RTCRtcpMuxPolicyRequire:
329 return @"REQUIRE";
330 }
331}
332
333+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
334 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
335 switch (policy) {
336 case RTCTcpCandidatePolicyEnabled:
337 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
338 case RTCTcpCandidatePolicyDisabled:
339 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
340 }
341}
342
Honghai Zhang46007ae2016-06-03 16:31:32 -0700343+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
344 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
345 switch (policy) {
346 case RTCCandidateNetworkPolicyAll:
347 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
348 case RTCCandidateNetworkPolicyLowCost:
349 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
350 }
351}
352
hjon6d49a8e2016-01-26 13:06:42 -0800353+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
354 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
355 switch (nativePolicy) {
356 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
357 return RTCTcpCandidatePolicyEnabled;
358 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
359 return RTCTcpCandidatePolicyDisabled;
360 }
361}
362
363+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
364 switch (policy) {
365 case RTCTcpCandidatePolicyEnabled:
366 return @"TCP_ENABLED";
367 case RTCTcpCandidatePolicyDisabled:
368 return @"TCP_DISABLED";
369 }
370}
371
Honghai Zhang46007ae2016-06-03 16:31:32 -0700372+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
373 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
374 switch (nativePolicy) {
375 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
376 return RTCCandidateNetworkPolicyAll;
377 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
378 return RTCCandidateNetworkPolicyLowCost;
379 }
380}
381
382+ (NSString *)stringForCandidateNetworkPolicy:
383 (RTCCandidateNetworkPolicy)policy {
384 switch (policy) {
385 case RTCCandidateNetworkPolicyAll:
386 return @"CANDIDATE_ALL_NETWORKS";
387 case RTCCandidateNetworkPolicyLowCost:
388 return @"CANDIDATE_LOW_COST_NETWORKS";
389 }
390}
391
Honghai Zhang3108fc92016-05-11 10:10:39 -0700392+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
393 nativeContinualGatheringPolicyForPolicy:
394 (RTCContinualGatheringPolicy)policy {
395 switch (policy) {
396 case RTCContinualGatheringPolicyGatherOnce:
397 return webrtc::PeerConnectionInterface::GATHER_ONCE;
398 case RTCContinualGatheringPolicyGatherContinually:
399 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
400 }
401}
402
403+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
404 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
405 switch (nativePolicy) {
406 case webrtc::PeerConnectionInterface::GATHER_ONCE:
407 return RTCContinualGatheringPolicyGatherOnce;
408 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
409 return RTCContinualGatheringPolicyGatherContinually;
410 }
411}
412
413+ (NSString *)stringForContinualGatheringPolicy:
414 (RTCContinualGatheringPolicy)policy {
415 switch (policy) {
416 case RTCContinualGatheringPolicyGatherOnce:
417 return @"GATHER_ONCE";
418 case RTCContinualGatheringPolicyGatherContinually:
419 return @"GATHER_CONTINUALLY";
420 }
421}
422
hbosf9da44d2016-06-09 03:18:28 -0700423+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
424 (RTCEncryptionKeyType)keyType {
425 switch (keyType) {
426 case RTCEncryptionKeyTypeRSA:
427 return rtc::KT_RSA;
428 case RTCEncryptionKeyTypeECDSA:
429 return rtc::KT_ECDSA;
430 }
431}
432
Steve Anton8cb344a2018-02-27 15:34:53 -0800433+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
434 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800435 case RTCSdpSemanticsPlanB:
436 return webrtc::SdpSemantics::kPlanB;
437 case RTCSdpSemanticsUnifiedPlan:
438 return webrtc::SdpSemantics::kUnifiedPlan;
439 }
440}
441
442+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
443 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800444 case webrtc::SdpSemantics::kPlanB:
445 return RTCSdpSemanticsPlanB;
446 case webrtc::SdpSemantics::kUnifiedPlan:
447 return RTCSdpSemanticsUnifiedPlan;
448 }
449}
450
451+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
452 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800453 case RTCSdpSemanticsPlanB:
454 return @"PLAN_B";
455 case RTCSdpSemanticsUnifiedPlan:
456 return @"UNIFIED_PLAN";
457 }
458}
459
hjon6d49a8e2016-01-26 13:06:42 -0800460@end