blob: 83f32b4c1224e96db7b1ea73c1948744b0a22832 [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;
Uladzislau Sushabf0d0c12018-11-05 12:48:35 +030034@synthesize disableIPV6 = _disableIPV6;
35@synthesize disableIPV6OnWiFi = _disableIPV6OnWiFi;
deadbeef2059bb32017-07-26 18:25:43 -070036@synthesize maxIPv6Networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010037@synthesize disableLinkLocalNetworks = _disableLinkLocalNetworks;
hjon6d49a8e2016-01-26 13:06:42 -080038@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -080039@synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate;
hjon6d49a8e2016-01-26 13:06:42 -080040@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
41@synthesize iceBackupCandidatePairPingInterval =
42 _iceBackupCandidatePairPingInterval;
tkchinab8f82f2016-01-27 17:50:11 -080043@synthesize keyType = _keyType;
deadbeefbe0c96f2016-05-18 16:20:14 -070044@synthesize iceCandidatePoolSize = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -070045@synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts;
46@synthesize shouldPresumeWritableWhenFullyRelayed =
47 _shouldPresumeWritableWhenFullyRelayed;
skvlada5d94ff2017-02-02 13:02:30 -080048@synthesize iceCheckMinInterval = _iceCheckMinInterval;
Steve Antond295e402017-07-14 16:06:41 -070049@synthesize iceRegatherIntervalRange = _iceRegatherIntervalRange;
Steve Anton8cb344a2018-02-27 15:34:53 -080050@synthesize sdpSemantics = _sdpSemantics;
Zeke Chinef1140e2017-10-27 15:42:08 -070051@synthesize turnCustomizer = _turnCustomizer;
Zhi Huangb57e1692018-06-12 11:41:11 -070052@synthesize activeResetSrtpParams = _activeResetSrtpParams;
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -070053@synthesize useMediaTransport = _useMediaTransport;
Benjamin Wright8c27cca2018-10-25 10:16:44 -070054@synthesize cryptoOptions = _cryptoOptions;
hjon6d49a8e2016-01-26 13:06:42 -080055
56- (instancetype)init {
jtteh4eeb5372017-04-03 15:06:37 -070057 // Copy defaults.
Yuriy Pavlyshak8cec4fb2018-09-07 16:43:31 +020058 webrtc::PeerConnectionInterface::RTCConfiguration config;
jtteh465faf02017-04-04 14:00:16 -070059 return [self initWithNativeConfiguration:config];
jtteh4eeb5372017-04-03 15:06:37 -070060}
61
62- (instancetype)initWithNativeConfiguration:
jtteh465faf02017-04-04 14:00:16 -070063 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config {
hjon6d49a8e2016-01-26 13:06:42 -080064 if (self = [super init]) {
jtteh4eeb5372017-04-03 15:06:37 -070065 NSMutableArray *iceServers = [NSMutableArray array];
jtteh465faf02017-04-04 14:00:16 -070066 for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) {
jtteh4eeb5372017-04-03 15:06:37 -070067 RTCIceServer *iceServer = [[RTCIceServer alloc] initWithNativeServer:server];
68 [iceServers addObject:iceServer];
69 }
70 _iceServers = iceServers;
Michael Iedemaccee56b2018-07-05 15:28:24 +020071 if (!config.certificates.empty()) {
72 rtc::scoped_refptr<rtc::RTCCertificate> native_cert;
73 native_cert = config.certificates[0];
74 rtc::RTCCertificatePEM native_pem = native_cert->ToPEM();
75 _certificate =
76 [[RTCCertificate alloc] initWithPrivateKey:@(native_pem.private_key().c_str())
77 certificate:@(native_pem.certificate().c_str())];
78 }
hjon6d49a8e2016-01-26 13:06:42 -080079 _iceTransportPolicy =
jtteh465faf02017-04-04 14:00:16 -070080 [[self class] transportPolicyForTransportsType:config.type];
hjon6d49a8e2016-01-26 13:06:42 -080081 _bundlePolicy =
jtteh465faf02017-04-04 14:00:16 -070082 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
hjon6d49a8e2016-01-26 13:06:42 -080083 _rtcpMuxPolicy =
jtteh465faf02017-04-04 14:00:16 -070084 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
hjon6d49a8e2016-01-26 13:06:42 -080085 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
jtteh465faf02017-04-04 14:00:16 -070086 config.tcp_candidate_policy];
Honghai Zhang46007ae2016-06-03 16:31:32 -070087 _candidateNetworkPolicy = [[self class]
jtteh465faf02017-04-04 14:00:16 -070088 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
Honghai Zhang3108fc92016-05-11 10:10:39 -070089 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
jtteh465faf02017-04-04 14:00:16 -070090 config.continual_gathering_policy;
Honghai Zhang3108fc92016-05-11 10:10:39 -070091 _continualGatheringPolicy =
92 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy];
Uladzislau Sushabf0d0c12018-11-05 12:48:35 +030093 _disableIPV6 = config.disable_ipv6;
94 _disableIPV6OnWiFi = config.disable_ipv6_on_wifi;
deadbeef2059bb32017-07-26 18:25:43 -070095 _maxIPv6Networks = config.max_ipv6_networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +010096 _disableLinkLocalNetworks = config.disable_link_local_networks;
jtteh465faf02017-04-04 14:00:16 -070097 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
98 _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate;
99 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
hjon6d49a8e2016-01-26 13:06:42 -0800100 _iceBackupCandidatePairPingInterval =
jtteh465faf02017-04-04 14:00:16 -0700101 config.ice_backup_candidate_pair_ping_interval;
Piotr (Peter) Slatala693432d2018-10-30 16:52:06 -0700102 _useMediaTransport = config.use_media_transport;
tkchinab8f82f2016-01-27 17:50:11 -0800103 _keyType = RTCEncryptionKeyTypeECDSA;
jtteh465faf02017-04-04 14:00:16 -0700104 _iceCandidatePoolSize = config.ice_candidate_pool_size;
105 _shouldPruneTurnPorts = config.prune_turn_ports;
honghaizaf6b6e02016-07-11 15:09:26 -0700106 _shouldPresumeWritableWhenFullyRelayed =
jtteh465faf02017-04-04 14:00:16 -0700107 config.presume_writable_when_fully_relayed;
108 if (config.ice_check_min_interval) {
skvlada5d94ff2017-02-02 13:02:30 -0800109 _iceCheckMinInterval =
jtteh465faf02017-04-04 14:00:16 -0700110 [NSNumber numberWithInt:*config.ice_check_min_interval];
skvlada5d94ff2017-02-02 13:02:30 -0800111 }
Steve Antond295e402017-07-14 16:06:41 -0700112 if (config.ice_regather_interval_range) {
113 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interval_range.value();
114 _iceRegatherIntervalRange =
115 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRange];
116 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800117 _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700118 _turnCustomizer = config.turn_customizer;
Zhi Huangb57e1692018-06-12 11:41:11 -0700119 _activeResetSrtpParams = config.active_reset_srtp_params;
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700120 if (config.crypto_options) {
121 _cryptoOptions = [[RTCCryptoOptions alloc]
122 initWithSrtpEnableGcmCryptoSuites:config.crypto_options->srtp
123 .enable_gcm_crypto_suites
124 srtpEnableAes128Sha1_32CryptoCipher:config.crypto_options->srtp
125 .enable_aes128_sha1_32_crypto_cipher
126 srtpEnableEncryptedRtpHeaderExtensions:config.crypto_options->srtp
127 .enable_encrypted_rtp_header_extensions
128 sframeRequireFrameEncryption:config.crypto_options->sframe
129 .require_frame_encryption];
130 }
hjon6d49a8e2016-01-26 13:06:42 -0800131 }
132 return self;
133}
134
135- (NSString *)description {
Uladzislau Sushabf0d0c12018-11-05 12:48:35 +0300136 static NSString *formatString = @"RTCConfiguration: "
137 @"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n"
138 @"%d\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%@\n}\n";
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100139
Steve Anton8cb344a2018-02-27 15:34:53 -0800140 return [NSString
141 stringWithFormat:formatString,
142 _iceServers,
143 [[self class] stringForTransportPolicy:_iceTransportPolicy],
144 [[self class] stringForBundlePolicy:_bundlePolicy],
145 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
146 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
147 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
148 [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy],
149 [[self class] stringForSdpSemantics:_sdpSemantics],
150 _audioJitterBufferMaxPackets,
151 _audioJitterBufferFastAccelerate,
152 _iceConnectionReceivingTimeout,
153 _iceBackupCandidatePairPingInterval,
154 _iceCandidatePoolSize,
155 _shouldPruneTurnPorts,
156 _shouldPresumeWritableWhenFullyRelayed,
157 _iceCheckMinInterval,
158 _iceRegatherIntervalRange,
159 _disableLinkLocalNetworks,
Uladzislau Sushabf0d0c12018-11-05 12:48:35 +0300160 _disableIPV6,
161 _disableIPV6OnWiFi,
Zhi Huangb57e1692018-06-12 11:41:11 -0700162 _maxIPv6Networks,
Piotr (Peter) Slatalae0c2e972018-10-08 09:43:21 -0700163 _activeResetSrtpParams,
164 _useMediaTransport];
hjon6d49a8e2016-01-26 13:06:42 -0800165}
166
167#pragma mark - Private
168
hbosa73ca562016-05-17 03:28:58 -0700169- (webrtc::PeerConnectionInterface::RTCConfiguration *)
170 createNativeConfiguration {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200171 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
Honghai Zhangf7ddc062016-09-01 15:34:01 -0700172 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration(
173 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive));
hjon6d49a8e2016-01-26 13:06:42 -0800174
175 for (RTCIceServer *iceServer in _iceServers) {
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200176 nativeConfig->servers.push_back(iceServer.nativeServer);
hjon6d49a8e2016-01-26 13:06:42 -0800177 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200178 nativeConfig->type =
hjon6d49a8e2016-01-26 13:06:42 -0800179 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200180 nativeConfig->bundle_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800181 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200182 nativeConfig->rtcp_mux_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800183 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200184 nativeConfig->tcp_candidate_policy =
hjon6d49a8e2016-01-26 13:06:42 -0800185 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
Honghai Zhang46007ae2016-06-03 16:31:32 -0700186 nativeConfig->candidate_network_policy = [[self class]
187 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200188 nativeConfig->continual_gathering_policy = [[self class]
Honghai Zhang3108fc92016-05-11 10:10:39 -0700189 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
Uladzislau Sushabf0d0c12018-11-05 12:48:35 +0300190 nativeConfig->disable_ipv6 = _disableIPV6;
191 nativeConfig->disable_ipv6_on_wifi = _disableIPV6OnWiFi;
deadbeef2059bb32017-07-26 18:25:43 -0700192 nativeConfig->max_ipv6_networks = _maxIPv6Networks;
Daniel Lazarenko2870b0a2018-01-25 10:30:22 +0100193 nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200194 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
hayscc9f95002016-12-05 14:24:32 -0800195 nativeConfig->audio_jitter_buffer_fast_accelerate =
196 _audioJitterBufferFastAccelerate ? true : false;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200197 nativeConfig->ice_connection_receiving_timeout =
hjon6d49a8e2016-01-26 13:06:42 -0800198 _iceConnectionReceivingTimeout;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200199 nativeConfig->ice_backup_candidate_pair_ping_interval =
hjon6d49a8e2016-01-26 13:06:42 -0800200 _iceBackupCandidatePairPingInterval;
Piotr (Peter) Slatala88d8d7d2018-10-26 15:06:17 -0700201 nativeConfig->use_media_transport = _useMediaTransport;
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200202 rtc::KeyType keyType =
203 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType];
Michael Iedemaccee56b2018-07-05 15:28:24 +0200204 if (_certificate != nullptr) {
205 // if offered a pemcert use it...
206 RTC_LOG(LS_INFO) << "Have configured cert - using it.";
207 std::string pem_private_key = [[_certificate private_key] UTF8String];
208 std::string pem_certificate = [[_certificate certificate] UTF8String];
209 rtc::RTCCertificatePEM pem = rtc::RTCCertificatePEM(pem_private_key, pem_certificate);
210 rtc::scoped_refptr<rtc::RTCCertificate> certificate = rtc::RTCCertificate::FromPEM(pem);
211 RTC_LOG(LS_INFO) << "Created cert from PEM strings.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200212 if (!certificate) {
Michael Iedemaccee56b2018-07-05 15:28:24 +0200213 RTC_LOG(LS_ERROR) << "Failed to generate certificate from PEM.";
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200214 return nullptr;
tkchinab8f82f2016-01-27 17:50:11 -0800215 }
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200216 nativeConfig->certificates.push_back(certificate);
Michael Iedemaccee56b2018-07-05 15:28:24 +0200217 } else {
218 RTC_LOG(LS_INFO) << "Don't have configured cert.";
219 // Generate non-default certificate.
220 if (keyType != rtc::KT_DEFAULT) {
221 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
222 rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType),
223 absl::optional<uint64_t>());
224 if (!certificate) {
225 RTCLogError(@"Failed to generate certificate.");
226 return nullptr;
227 }
228 nativeConfig->certificates.push_back(certificate);
229 }
tkchinab8f82f2016-01-27 17:50:11 -0800230 }
deadbeefbe0c96f2016-05-18 16:20:14 -0700231 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize;
honghaizaf6b6e02016-07-11 15:09:26 -0700232 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700233 nativeConfig->presume_writable_when_fully_relayed =
honghaizaf6b6e02016-07-11 15:09:26 -0700234 _shouldPresumeWritableWhenFullyRelayed ? true : false;
skvlada5d94ff2017-02-02 13:02:30 -0800235 if (_iceCheckMinInterval != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +0200236 nativeConfig->ice_check_min_interval = absl::optional<int>(_iceCheckMinInterval.intValue);
skvlada5d94ff2017-02-02 13:02:30 -0800237 }
Steve Antond295e402017-07-14 16:06:41 -0700238 if (_iceRegatherIntervalRange != nil) {
239 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange(
240 _iceRegatherIntervalRange.nativeIntervalRange);
241 nativeConfig->ice_regather_interval_range =
Danil Chapovalov196100e2018-06-21 10:17:24 +0200242 absl::optional<rtc::IntervalRange>(*nativeIntervalRange);
Steve Antond295e402017-07-14 16:06:41 -0700243 }
Steve Anton8cb344a2018-02-27 15:34:53 -0800244 nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics];
Zeke Chinef1140e2017-10-27 15:42:08 -0700245 if (_turnCustomizer) {
246 nativeConfig->turn_customizer = _turnCustomizer;
247 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700248 nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false;
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700249 if (_cryptoOptions) {
250 webrtc::CryptoOptions nativeCryptoOptions;
251 nativeCryptoOptions.srtp.enable_gcm_crypto_suites =
252 _cryptoOptions.srtpEnableGcmCryptoSuites ? true : false;
253 nativeCryptoOptions.srtp.enable_aes128_sha1_32_crypto_cipher =
254 _cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher ? true : false;
255 nativeCryptoOptions.srtp.enable_encrypted_rtp_header_extensions =
256 _cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions ? true : false;
257 nativeCryptoOptions.sframe.require_frame_encryption =
258 _cryptoOptions.sframeRequireFrameEncryption ? true : false;
259 nativeConfig->crypto_options = absl::optional<webrtc::CryptoOptions>(nativeCryptoOptions);
260 }
261
Henrik Boströme06c2dd2016-05-13 13:50:38 +0200262 return nativeConfig.release();
hjon6d49a8e2016-01-26 13:06:42 -0800263}
264
hjon6d49a8e2016-01-26 13:06:42 -0800265+ (webrtc::PeerConnectionInterface::IceTransportsType)
266 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
267 switch (policy) {
268 case RTCIceTransportPolicyNone:
269 return webrtc::PeerConnectionInterface::kNone;
270 case RTCIceTransportPolicyRelay:
271 return webrtc::PeerConnectionInterface::kRelay;
272 case RTCIceTransportPolicyNoHost:
273 return webrtc::PeerConnectionInterface::kNoHost;
274 case RTCIceTransportPolicyAll:
275 return webrtc::PeerConnectionInterface::kAll;
276 }
277}
278
279+ (RTCIceTransportPolicy)transportPolicyForTransportsType:
280 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
281 switch (nativeType) {
282 case webrtc::PeerConnectionInterface::kNone:
283 return RTCIceTransportPolicyNone;
284 case webrtc::PeerConnectionInterface::kRelay:
285 return RTCIceTransportPolicyRelay;
286 case webrtc::PeerConnectionInterface::kNoHost:
287 return RTCIceTransportPolicyNoHost;
288 case webrtc::PeerConnectionInterface::kAll:
289 return RTCIceTransportPolicyAll;
290 }
291}
292
293+ (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
294 switch (policy) {
295 case RTCIceTransportPolicyNone:
296 return @"NONE";
297 case RTCIceTransportPolicyRelay:
298 return @"RELAY";
299 case RTCIceTransportPolicyNoHost:
300 return @"NO_HOST";
301 case RTCIceTransportPolicyAll:
302 return @"ALL";
303 }
304}
305
306+ (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
307 (RTCBundlePolicy)policy {
308 switch (policy) {
309 case RTCBundlePolicyBalanced:
310 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
311 case RTCBundlePolicyMaxCompat:
312 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
313 case RTCBundlePolicyMaxBundle:
314 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
315 }
316}
317
318+ (RTCBundlePolicy)bundlePolicyForNativePolicy:
319 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
320 switch (nativePolicy) {
321 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
322 return RTCBundlePolicyBalanced;
323 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
324 return RTCBundlePolicyMaxCompat;
325 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
326 return RTCBundlePolicyMaxBundle;
327 }
328}
329
330+ (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
331 switch (policy) {
332 case RTCBundlePolicyBalanced:
333 return @"BALANCED";
334 case RTCBundlePolicyMaxCompat:
335 return @"MAX_COMPAT";
336 case RTCBundlePolicyMaxBundle:
337 return @"MAX_BUNDLE";
338 }
339}
340
341+ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
342 (RTCRtcpMuxPolicy)policy {
343 switch (policy) {
344 case RTCRtcpMuxPolicyNegotiate:
345 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
346 case RTCRtcpMuxPolicyRequire:
347 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
348 }
349}
350
351+ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
352 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
353 switch (nativePolicy) {
354 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
355 return RTCRtcpMuxPolicyNegotiate;
356 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
357 return RTCRtcpMuxPolicyRequire;
358 }
359}
360
361+ (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
362 switch (policy) {
363 case RTCRtcpMuxPolicyNegotiate:
364 return @"NEGOTIATE";
365 case RTCRtcpMuxPolicyRequire:
366 return @"REQUIRE";
367 }
368}
369
370+ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
371 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
372 switch (policy) {
373 case RTCTcpCandidatePolicyEnabled:
374 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
375 case RTCTcpCandidatePolicyDisabled:
376 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
377 }
378}
379
Honghai Zhang46007ae2016-06-03 16:31:32 -0700380+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
381 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
382 switch (policy) {
383 case RTCCandidateNetworkPolicyAll:
384 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
385 case RTCCandidateNetworkPolicyLowCost:
386 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
387 }
388}
389
hjon6d49a8e2016-01-26 13:06:42 -0800390+ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
391 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
392 switch (nativePolicy) {
393 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
394 return RTCTcpCandidatePolicyEnabled;
395 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
396 return RTCTcpCandidatePolicyDisabled;
397 }
398}
399
400+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
401 switch (policy) {
402 case RTCTcpCandidatePolicyEnabled:
403 return @"TCP_ENABLED";
404 case RTCTcpCandidatePolicyDisabled:
405 return @"TCP_DISABLED";
406 }
407}
408
Honghai Zhang46007ae2016-06-03 16:31:32 -0700409+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
410 (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
411 switch (nativePolicy) {
412 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
413 return RTCCandidateNetworkPolicyAll;
414 case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
415 return RTCCandidateNetworkPolicyLowCost;
416 }
417}
418
419+ (NSString *)stringForCandidateNetworkPolicy:
420 (RTCCandidateNetworkPolicy)policy {
421 switch (policy) {
422 case RTCCandidateNetworkPolicyAll:
423 return @"CANDIDATE_ALL_NETWORKS";
424 case RTCCandidateNetworkPolicyLowCost:
425 return @"CANDIDATE_LOW_COST_NETWORKS";
426 }
427}
428
Honghai Zhang3108fc92016-05-11 10:10:39 -0700429+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
430 nativeContinualGatheringPolicyForPolicy:
431 (RTCContinualGatheringPolicy)policy {
432 switch (policy) {
433 case RTCContinualGatheringPolicyGatherOnce:
434 return webrtc::PeerConnectionInterface::GATHER_ONCE;
435 case RTCContinualGatheringPolicyGatherContinually:
436 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY;
437 }
438}
439
440+ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy:
441 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy {
442 switch (nativePolicy) {
443 case webrtc::PeerConnectionInterface::GATHER_ONCE:
444 return RTCContinualGatheringPolicyGatherOnce;
445 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY:
446 return RTCContinualGatheringPolicyGatherContinually;
447 }
448}
449
450+ (NSString *)stringForContinualGatheringPolicy:
451 (RTCContinualGatheringPolicy)policy {
452 switch (policy) {
453 case RTCContinualGatheringPolicyGatherOnce:
454 return @"GATHER_ONCE";
455 case RTCContinualGatheringPolicyGatherContinually:
456 return @"GATHER_CONTINUALLY";
457 }
458}
459
hbosf9da44d2016-06-09 03:18:28 -0700460+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
461 (RTCEncryptionKeyType)keyType {
462 switch (keyType) {
463 case RTCEncryptionKeyTypeRSA:
464 return rtc::KT_RSA;
465 case RTCEncryptionKeyTypeECDSA:
466 return rtc::KT_ECDSA;
467 }
468}
469
Steve Anton8cb344a2018-02-27 15:34:53 -0800470+ (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
471 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800472 case RTCSdpSemanticsPlanB:
473 return webrtc::SdpSemantics::kPlanB;
474 case RTCSdpSemanticsUnifiedPlan:
475 return webrtc::SdpSemantics::kUnifiedPlan;
476 }
477}
478
479+ (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics {
480 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800481 case webrtc::SdpSemantics::kPlanB:
482 return RTCSdpSemanticsPlanB;
483 case webrtc::SdpSemantics::kUnifiedPlan:
484 return RTCSdpSemanticsUnifiedPlan;
485 }
486}
487
488+ (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics {
489 switch (sdpSemantics) {
Steve Anton8cb344a2018-02-27 15:34:53 -0800490 case RTCSdpSemanticsPlanB:
491 return @"PLAN_B";
492 case RTCSdpSemanticsUnifiedPlan:
493 return @"UNIFIED_PLAN";
494 }
495}
496
hjon6d49a8e2016-01-26 13:06:42 -0800497@end