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