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