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