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