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