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