OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import "RTCConfiguration+Private.h" | 11 #import "RTCConfiguration+Private.h" |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #import "RTCIceServer+Private.h" | 15 #import "RTCIceServer+Private.h" |
16 #import "WebRTC/RTCLogging.h" | 16 #import "WebRTC/RTCLogging.h" |
17 | 17 |
18 #include "webrtc/base/rtccertificategenerator.h" | 18 #include "webrtc/base/rtccertificategenerator.h" |
19 #include "webrtc/base/sslidentity.h" | 19 #include "webrtc/base/sslidentity.h" |
20 | 20 |
21 @implementation RTCConfiguration | 21 @implementation RTCConfiguration |
22 | 22 |
23 @synthesize iceServers = _iceServers; | 23 @synthesize iceServers = _iceServers; |
24 @synthesize iceTransportPolicy = _iceTransportPolicy; | 24 @synthesize iceTransportPolicy = _iceTransportPolicy; |
25 @synthesize bundlePolicy = _bundlePolicy; | 25 @synthesize bundlePolicy = _bundlePolicy; |
26 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; | 26 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
27 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; | 27 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
| 28 @synthesize candidateNetworkPolicy = _candidateNetworkPolicy; |
28 @synthesize continualGatheringPolicy = _continualGatheringPolicy; | 29 @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
29 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; | 30 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
30 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; | 31 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
31 @synthesize iceBackupCandidatePairPingInterval = | 32 @synthesize iceBackupCandidatePairPingInterval = |
32 _iceBackupCandidatePairPingInterval; | 33 _iceBackupCandidatePairPingInterval; |
33 @synthesize keyType = _keyType; | 34 @synthesize keyType = _keyType; |
34 @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; | 35 @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; |
35 | 36 |
36 - (instancetype)init { | 37 - (instancetype)init { |
37 if (self = [super init]) { | 38 if (self = [super init]) { |
38 _iceServers = [NSMutableArray array]; | 39 _iceServers = [NSMutableArray array]; |
39 // Copy defaults. | 40 // Copy defaults. |
40 webrtc::PeerConnectionInterface::RTCConfiguration config; | 41 webrtc::PeerConnectionInterface::RTCConfiguration config; |
41 _iceTransportPolicy = | 42 _iceTransportPolicy = |
42 [[self class] transportPolicyForTransportsType:config.type]; | 43 [[self class] transportPolicyForTransportsType:config.type]; |
43 _bundlePolicy = | 44 _bundlePolicy = |
44 [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; | 45 [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; |
45 _rtcpMuxPolicy = | 46 _rtcpMuxPolicy = |
46 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; | 47 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; |
47 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: | 48 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: |
48 config.tcp_candidate_policy]; | 49 config.tcp_candidate_policy]; |
| 50 _candidateNetworkPolicy = [[self class] |
| 51 candidateNetworkPolicyForNativePolicy:config.candidate_network_policy]; |
49 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = | 52 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = |
50 config.continual_gathering_policy; | 53 config.continual_gathering_policy; |
51 _continualGatheringPolicy = | 54 _continualGatheringPolicy = |
52 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; | 55 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; |
53 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; | 56 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; |
54 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; | 57 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; |
55 _iceBackupCandidatePairPingInterval = | 58 _iceBackupCandidatePairPingInterval = |
56 config.ice_backup_candidate_pair_ping_interval; | 59 config.ice_backup_candidate_pair_ping_interval; |
57 _keyType = RTCEncryptionKeyTypeECDSA; | 60 _keyType = RTCEncryptionKeyTypeECDSA; |
58 _iceCandidatePoolSize = config.ice_candidate_pool_size; | 61 _iceCandidatePoolSize = config.ice_candidate_pool_size; |
59 } | 62 } |
60 return self; | 63 return self; |
61 } | 64 } |
62 | 65 |
63 - (NSString *)description { | 66 - (NSString *)description { |
64 return [NSString stringWithFormat: | 67 return [NSString stringWithFormat: |
65 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n}\n", | 68 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n}\n", |
66 _iceServers, | 69 _iceServers, |
67 [[self class] stringForTransportPolicy:_iceTransportPolicy], | 70 [[self class] stringForTransportPolicy:_iceTransportPolicy], |
68 [[self class] stringForBundlePolicy:_bundlePolicy], | 71 [[self class] stringForBundlePolicy:_bundlePolicy], |
69 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], | 72 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
70 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], | 73 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
| 74 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], |
71 [[self class] | 75 [[self class] |
72 stringForContinualGatheringPolicy:_continualGatheringPolicy], | 76 stringForContinualGatheringPolicy:_continualGatheringPolicy], |
73 _audioJitterBufferMaxPackets, | 77 _audioJitterBufferMaxPackets, |
74 _iceConnectionReceivingTimeout, | 78 _iceConnectionReceivingTimeout, |
75 _iceBackupCandidatePairPingInterval, | 79 _iceBackupCandidatePairPingInterval, |
76 _iceCandidatePoolSize]; | 80 _iceCandidatePoolSize]; |
77 } | 81 } |
78 | 82 |
79 #pragma mark - Private | 83 #pragma mark - Private |
80 | 84 |
81 - (webrtc::PeerConnectionInterface::RTCConfiguration *) | 85 - (webrtc::PeerConnectionInterface::RTCConfiguration *) |
82 createNativeConfiguration { | 86 createNativeConfiguration { |
83 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> | 87 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
84 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration()); | 88 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration()); |
85 | 89 |
86 for (RTCIceServer *iceServer in _iceServers) { | 90 for (RTCIceServer *iceServer in _iceServers) { |
87 nativeConfig->servers.push_back(iceServer.nativeServer); | 91 nativeConfig->servers.push_back(iceServer.nativeServer); |
88 } | 92 } |
89 nativeConfig->type = | 93 nativeConfig->type = |
90 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; | 94 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
91 nativeConfig->bundle_policy = | 95 nativeConfig->bundle_policy = |
92 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; | 96 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
93 nativeConfig->rtcp_mux_policy = | 97 nativeConfig->rtcp_mux_policy = |
94 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; | 98 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
95 nativeConfig->tcp_candidate_policy = | 99 nativeConfig->tcp_candidate_policy = |
96 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; | 100 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
| 101 nativeConfig->candidate_network_policy = [[self class] |
| 102 nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy]; |
97 nativeConfig->continual_gathering_policy = [[self class] | 103 nativeConfig->continual_gathering_policy = [[self class] |
98 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; | 104 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; |
99 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; | 105 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
100 nativeConfig->ice_connection_receiving_timeout = | 106 nativeConfig->ice_connection_receiving_timeout = |
101 _iceConnectionReceivingTimeout; | 107 _iceConnectionReceivingTimeout; |
102 nativeConfig->ice_backup_candidate_pair_ping_interval = | 108 nativeConfig->ice_backup_candidate_pair_ping_interval = |
103 _iceBackupCandidatePairPingInterval; | 109 _iceBackupCandidatePairPingInterval; |
104 rtc::KeyType keyType = | 110 rtc::KeyType keyType = |
105 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; | 111 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; |
106 // Generate non-default certificate. | 112 // Generate non-default certificate. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) | 233 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) |
228 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { | 234 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { |
229 switch (policy) { | 235 switch (policy) { |
230 case RTCTcpCandidatePolicyEnabled: | 236 case RTCTcpCandidatePolicyEnabled: |
231 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; | 237 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; |
232 case RTCTcpCandidatePolicyDisabled: | 238 case RTCTcpCandidatePolicyDisabled: |
233 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; | 239 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; |
234 } | 240 } |
235 } | 241 } |
236 | 242 |
| 243 + (webrtc::PeerConnectionInterface::CandidateNetworkPolicy) |
| 244 nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy { |
| 245 switch (policy) { |
| 246 case RTCCandidateNetworkPolicyAll: |
| 247 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll; |
| 248 case RTCCandidateNetworkPolicyLowCost: |
| 249 return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost; |
| 250 } |
| 251 } |
| 252 |
237 + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: | 253 + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: |
238 (RTCEncryptionKeyType)keyType { | 254 (RTCEncryptionKeyType)keyType { |
239 switch (keyType) { | 255 switch (keyType) { |
240 case RTCEncryptionKeyTypeRSA: | 256 case RTCEncryptionKeyTypeRSA: |
241 return rtc::KT_RSA; | 257 return rtc::KT_RSA; |
242 case RTCEncryptionKeyTypeECDSA: | 258 case RTCEncryptionKeyTypeECDSA: |
243 return rtc::KT_ECDSA; | 259 return rtc::KT_ECDSA; |
244 } | 260 } |
245 } | 261 } |
246 | 262 |
247 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: | 263 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: |
248 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { | 264 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { |
249 switch (nativePolicy) { | 265 switch (nativePolicy) { |
250 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: | 266 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: |
251 return RTCTcpCandidatePolicyEnabled; | 267 return RTCTcpCandidatePolicyEnabled; |
252 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: | 268 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: |
253 return RTCTcpCandidatePolicyDisabled; | 269 return RTCTcpCandidatePolicyDisabled; |
254 } | 270 } |
255 } | 271 } |
256 | 272 |
257 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { | 273 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { |
258 switch (policy) { | 274 switch (policy) { |
259 case RTCTcpCandidatePolicyEnabled: | 275 case RTCTcpCandidatePolicyEnabled: |
260 return @"TCP_ENABLED"; | 276 return @"TCP_ENABLED"; |
261 case RTCTcpCandidatePolicyDisabled: | 277 case RTCTcpCandidatePolicyDisabled: |
262 return @"TCP_DISABLED"; | 278 return @"TCP_DISABLED"; |
263 } | 279 } |
264 } | 280 } |
265 | 281 |
| 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 |
266 + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) | 302 + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) |
267 nativeContinualGatheringPolicyForPolicy: | 303 nativeContinualGatheringPolicyForPolicy: |
268 (RTCContinualGatheringPolicy)policy { | 304 (RTCContinualGatheringPolicy)policy { |
269 switch (policy) { | 305 switch (policy) { |
270 case RTCContinualGatheringPolicyGatherOnce: | 306 case RTCContinualGatheringPolicyGatherOnce: |
271 return webrtc::PeerConnectionInterface::GATHER_ONCE; | 307 return webrtc::PeerConnectionInterface::GATHER_ONCE; |
272 case RTCContinualGatheringPolicyGatherContinually: | 308 case RTCContinualGatheringPolicyGatherContinually: |
273 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; | 309 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; |
274 } | 310 } |
275 } | 311 } |
(...skipping 12 matching lines...) Expand all Loading... |
288 (RTCContinualGatheringPolicy)policy { | 324 (RTCContinualGatheringPolicy)policy { |
289 switch (policy) { | 325 switch (policy) { |
290 case RTCContinualGatheringPolicyGatherOnce: | 326 case RTCContinualGatheringPolicyGatherOnce: |
291 return @"GATHER_ONCE"; | 327 return @"GATHER_ONCE"; |
292 case RTCContinualGatheringPolicyGatherContinually: | 328 case RTCContinualGatheringPolicyGatherContinually: |
293 return @"GATHER_CONTINUALLY"; | 329 return @"GATHER_CONTINUALLY"; |
294 } | 330 } |
295 } | 331 } |
296 | 332 |
297 @end | 333 @end |
OLD | NEW |