hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "RTCConfiguration+Private.h" |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 12 | |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 13 | #include <memory> |
| 14 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 15 | #import "RTCIceServer+Private.h" |
| 16 | #import "WebRTC/RTCLogging.h" |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 17 | |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 18 | #include "webrtc/base/rtccertificategenerator.h" |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 19 | #include "webrtc/base/sslidentity.h" |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 20 | |
| 21 | @implementation RTCConfiguration |
| 22 | |
| 23 | @synthesize iceServers = _iceServers; |
| 24 | @synthesize iceTransportPolicy = _iceTransportPolicy; |
| 25 | @synthesize bundlePolicy = _bundlePolicy; |
| 26 | @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
| 27 | @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 28 | @synthesize candidateNetworkPolicy = _candidateNetworkPolicy; |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 29 | @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 30 | @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 31 | @synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 32 | @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
| 33 | @synthesize iceBackupCandidatePairPingInterval = |
| 34 | _iceBackupCandidatePairPingInterval; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 35 | @synthesize keyType = _keyType; |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 36 | @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 37 | @synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts; |
| 38 | @synthesize shouldPresumeWritableWhenFullyRelayed = |
| 39 | _shouldPresumeWritableWhenFullyRelayed; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 40 | @synthesize iceCheckMinInterval = _iceCheckMinInterval; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 41 | |
| 42 | - (instancetype)init { |
| 43 | if (self = [super init]) { |
| 44 | _iceServers = [NSMutableArray array]; |
| 45 | // Copy defaults. |
Honghai Zhang | f7ddc06 | 2016-09-01 15:34:01 -0700 | [diff] [blame] | 46 | webrtc::PeerConnectionInterface::RTCConfiguration config( |
| 47 | webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 48 | _iceTransportPolicy = |
| 49 | [[self class] transportPolicyForTransportsType:config.type]; |
| 50 | _bundlePolicy = |
| 51 | [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; |
| 52 | _rtcpMuxPolicy = |
| 53 | [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; |
| 54 | _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: |
| 55 | config.tcp_candidate_policy]; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 56 | _candidateNetworkPolicy = [[self class] |
| 57 | candidateNetworkPolicyForNativePolicy:config.candidate_network_policy]; |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 58 | webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = |
| 59 | config.continual_gathering_policy; |
| 60 | _continualGatheringPolicy = |
| 61 | [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 62 | _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 63 | _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 64 | _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; |
| 65 | _iceBackupCandidatePairPingInterval = |
| 66 | config.ice_backup_candidate_pair_ping_interval; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 67 | _keyType = RTCEncryptionKeyTypeECDSA; |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 68 | _iceCandidatePoolSize = config.ice_candidate_pool_size; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 69 | _shouldPruneTurnPorts = config.prune_turn_ports; |
| 70 | _shouldPresumeWritableWhenFullyRelayed = |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 71 | config.presume_writable_when_fully_relayed; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 72 | if (config.ice_check_min_interval) { |
| 73 | _iceCheckMinInterval = |
| 74 | [NSNumber numberWithInt:*config.ice_check_min_interval]; |
| 75 | } |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 76 | } |
| 77 | return self; |
| 78 | } |
| 79 | |
| 80 | - (NSString *)description { |
| 81 | return [NSString stringWithFormat: |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 82 | @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%@\n}\n", |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 83 | _iceServers, |
| 84 | [[self class] stringForTransportPolicy:_iceTransportPolicy], |
| 85 | [[self class] stringForBundlePolicy:_bundlePolicy], |
| 86 | [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
| 87 | [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 88 | [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 89 | [[self class] |
| 90 | stringForContinualGatheringPolicy:_continualGatheringPolicy], |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 91 | _audioJitterBufferMaxPackets, |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 92 | _audioJitterBufferFastAccelerate, |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 93 | _iceConnectionReceivingTimeout, |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 94 | _iceBackupCandidatePairPingInterval, |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 95 | _iceCandidatePoolSize, |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 96 | _shouldPruneTurnPorts, |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 97 | _shouldPresumeWritableWhenFullyRelayed, |
| 98 | _iceCheckMinInterval]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | #pragma mark - Private |
| 102 | |
hbos | a73ca56 | 2016-05-17 03:28:58 -0700 | [diff] [blame] | 103 | - (webrtc::PeerConnectionInterface::RTCConfiguration *) |
| 104 | createNativeConfiguration { |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 105 | std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
Honghai Zhang | f7ddc06 | 2016-09-01 15:34:01 -0700 | [diff] [blame] | 106 | nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration( |
| 107 | webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive)); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 108 | |
| 109 | for (RTCIceServer *iceServer in _iceServers) { |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 110 | nativeConfig->servers.push_back(iceServer.nativeServer); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 111 | } |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 112 | nativeConfig->type = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 113 | [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 114 | nativeConfig->bundle_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 115 | [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 116 | nativeConfig->rtcp_mux_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 117 | [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 118 | nativeConfig->tcp_candidate_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 119 | [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 120 | nativeConfig->candidate_network_policy = [[self class] |
| 121 | nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 122 | nativeConfig->continual_gathering_policy = [[self class] |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 123 | nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 124 | nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 125 | nativeConfig->audio_jitter_buffer_fast_accelerate = |
| 126 | _audioJitterBufferFastAccelerate ? true : false; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 127 | nativeConfig->ice_connection_receiving_timeout = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 128 | _iceConnectionReceivingTimeout; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 129 | nativeConfig->ice_backup_candidate_pair_ping_interval = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 130 | _iceBackupCandidatePairPingInterval; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 131 | rtc::KeyType keyType = |
| 132 | [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; |
| 133 | // Generate non-default certificate. |
| 134 | if (keyType != rtc::KT_DEFAULT) { |
| 135 | rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
| 136 | rtc::RTCCertificateGenerator::GenerateCertificate( |
| 137 | rtc::KeyParams(keyType), rtc::Optional<uint64_t>()); |
| 138 | if (!certificate) { |
hbos | a73ca56 | 2016-05-17 03:28:58 -0700 | [diff] [blame] | 139 | RTCLogError(@"Failed to generate certificate."); |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 140 | return nullptr; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 141 | } |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 142 | nativeConfig->certificates.push_back(certificate); |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 143 | } |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 144 | nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 145 | nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false; |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 146 | nativeConfig->presume_writable_when_fully_relayed = |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 147 | _shouldPresumeWritableWhenFullyRelayed ? true : false; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 148 | if (_iceCheckMinInterval != nil) { |
| 149 | nativeConfig->ice_check_min_interval = |
| 150 | rtc::Optional<int>(_iceCheckMinInterval.intValue); |
| 151 | } |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 152 | |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 153 | return nativeConfig.release(); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 154 | } |
| 155 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 156 | + (webrtc::PeerConnectionInterface::IceTransportsType) |
| 157 | nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { |
| 158 | switch (policy) { |
| 159 | case RTCIceTransportPolicyNone: |
| 160 | return webrtc::PeerConnectionInterface::kNone; |
| 161 | case RTCIceTransportPolicyRelay: |
| 162 | return webrtc::PeerConnectionInterface::kRelay; |
| 163 | case RTCIceTransportPolicyNoHost: |
| 164 | return webrtc::PeerConnectionInterface::kNoHost; |
| 165 | case RTCIceTransportPolicyAll: |
| 166 | return webrtc::PeerConnectionInterface::kAll; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | + (RTCIceTransportPolicy)transportPolicyForTransportsType: |
| 171 | (webrtc::PeerConnectionInterface::IceTransportsType)nativeType { |
| 172 | switch (nativeType) { |
| 173 | case webrtc::PeerConnectionInterface::kNone: |
| 174 | return RTCIceTransportPolicyNone; |
| 175 | case webrtc::PeerConnectionInterface::kRelay: |
| 176 | return RTCIceTransportPolicyRelay; |
| 177 | case webrtc::PeerConnectionInterface::kNoHost: |
| 178 | return RTCIceTransportPolicyNoHost; |
| 179 | case webrtc::PeerConnectionInterface::kAll: |
| 180 | return RTCIceTransportPolicyAll; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | + (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy { |
| 185 | switch (policy) { |
| 186 | case RTCIceTransportPolicyNone: |
| 187 | return @"NONE"; |
| 188 | case RTCIceTransportPolicyRelay: |
| 189 | return @"RELAY"; |
| 190 | case RTCIceTransportPolicyNoHost: |
| 191 | return @"NO_HOST"; |
| 192 | case RTCIceTransportPolicyAll: |
| 193 | return @"ALL"; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | + (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy: |
| 198 | (RTCBundlePolicy)policy { |
| 199 | switch (policy) { |
| 200 | case RTCBundlePolicyBalanced: |
| 201 | return webrtc::PeerConnectionInterface::kBundlePolicyBalanced; |
| 202 | case RTCBundlePolicyMaxCompat: |
| 203 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; |
| 204 | case RTCBundlePolicyMaxBundle: |
| 205 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | + (RTCBundlePolicy)bundlePolicyForNativePolicy: |
| 210 | (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy { |
| 211 | switch (nativePolicy) { |
| 212 | case webrtc::PeerConnectionInterface::kBundlePolicyBalanced: |
| 213 | return RTCBundlePolicyBalanced; |
| 214 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat: |
| 215 | return RTCBundlePolicyMaxCompat; |
| 216 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle: |
| 217 | return RTCBundlePolicyMaxBundle; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | + (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy { |
| 222 | switch (policy) { |
| 223 | case RTCBundlePolicyBalanced: |
| 224 | return @"BALANCED"; |
| 225 | case RTCBundlePolicyMaxCompat: |
| 226 | return @"MAX_COMPAT"; |
| 227 | case RTCBundlePolicyMaxBundle: |
| 228 | return @"MAX_BUNDLE"; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy: |
| 233 | (RTCRtcpMuxPolicy)policy { |
| 234 | switch (policy) { |
| 235 | case RTCRtcpMuxPolicyNegotiate: |
| 236 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate; |
| 237 | case RTCRtcpMuxPolicyRequire: |
| 238 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy: |
| 243 | (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy { |
| 244 | switch (nativePolicy) { |
| 245 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate: |
| 246 | return RTCRtcpMuxPolicyNegotiate; |
| 247 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: |
| 248 | return RTCRtcpMuxPolicyRequire; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy { |
| 253 | switch (policy) { |
| 254 | case RTCRtcpMuxPolicyNegotiate: |
| 255 | return @"NEGOTIATE"; |
| 256 | case RTCRtcpMuxPolicyRequire: |
| 257 | return @"REQUIRE"; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) |
| 262 | nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { |
| 263 | switch (policy) { |
| 264 | case RTCTcpCandidatePolicyEnabled: |
| 265 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; |
| 266 | case RTCTcpCandidatePolicyDisabled: |
| 267 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; |
| 268 | } |
| 269 | } |
| 270 | |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 271 | + (webrtc::PeerConnectionInterface::CandidateNetworkPolicy) |
| 272 | nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy { |
| 273 | switch (policy) { |
| 274 | case RTCCandidateNetworkPolicyAll: |
| 275 | return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll; |
| 276 | case RTCCandidateNetworkPolicyLowCost: |
| 277 | return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost; |
| 278 | } |
| 279 | } |
| 280 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 281 | + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: |
| 282 | (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { |
| 283 | switch (nativePolicy) { |
| 284 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: |
| 285 | return RTCTcpCandidatePolicyEnabled; |
| 286 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: |
| 287 | return RTCTcpCandidatePolicyDisabled; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { |
| 292 | switch (policy) { |
| 293 | case RTCTcpCandidatePolicyEnabled: |
| 294 | return @"TCP_ENABLED"; |
| 295 | case RTCTcpCandidatePolicyDisabled: |
| 296 | return @"TCP_DISABLED"; |
| 297 | } |
| 298 | } |
| 299 | |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 300 | + (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy: |
| 301 | (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy { |
| 302 | switch (nativePolicy) { |
| 303 | case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll: |
| 304 | return RTCCandidateNetworkPolicyAll; |
| 305 | case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost: |
| 306 | return RTCCandidateNetworkPolicyLowCost; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | + (NSString *)stringForCandidateNetworkPolicy: |
| 311 | (RTCCandidateNetworkPolicy)policy { |
| 312 | switch (policy) { |
| 313 | case RTCCandidateNetworkPolicyAll: |
| 314 | return @"CANDIDATE_ALL_NETWORKS"; |
| 315 | case RTCCandidateNetworkPolicyLowCost: |
| 316 | return @"CANDIDATE_LOW_COST_NETWORKS"; |
| 317 | } |
| 318 | } |
| 319 | |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 320 | + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) |
| 321 | nativeContinualGatheringPolicyForPolicy: |
| 322 | (RTCContinualGatheringPolicy)policy { |
| 323 | switch (policy) { |
| 324 | case RTCContinualGatheringPolicyGatherOnce: |
| 325 | return webrtc::PeerConnectionInterface::GATHER_ONCE; |
| 326 | case RTCContinualGatheringPolicyGatherContinually: |
| 327 | return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | + (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy: |
| 332 | (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy { |
| 333 | switch (nativePolicy) { |
| 334 | case webrtc::PeerConnectionInterface::GATHER_ONCE: |
| 335 | return RTCContinualGatheringPolicyGatherOnce; |
| 336 | case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY: |
| 337 | return RTCContinualGatheringPolicyGatherContinually; |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | + (NSString *)stringForContinualGatheringPolicy: |
| 342 | (RTCContinualGatheringPolicy)policy { |
| 343 | switch (policy) { |
| 344 | case RTCContinualGatheringPolicyGatherOnce: |
| 345 | return @"GATHER_ONCE"; |
| 346 | case RTCContinualGatheringPolicyGatherContinually: |
| 347 | return @"GATHER_CONTINUALLY"; |
| 348 | } |
| 349 | } |
| 350 | |
hbos | f9da44d | 2016-06-09 03:18:28 -0700 | [diff] [blame] | 351 | + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: |
| 352 | (RTCEncryptionKeyType)keyType { |
| 353 | switch (keyType) { |
| 354 | case RTCEncryptionKeyTypeRSA: |
| 355 | return rtc::KT_RSA; |
| 356 | case RTCEncryptionKeyTypeECDSA: |
| 357 | return rtc::KT_ECDSA; |
| 358 | } |
| 359 | } |
| 360 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 361 | @end |