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 "RTCIntervalRange+Private.h" |
16 #import "WebRTC/RTCLogging.h" | 17 #import "WebRTC/RTCLogging.h" |
17 | 18 |
18 #include "webrtc/rtc_base/rtccertificategenerator.h" | 19 #include "webrtc/rtc_base/rtccertificategenerator.h" |
19 #include "webrtc/rtc_base/sslidentity.h" | 20 #include "webrtc/rtc_base/sslidentity.h" |
20 | 21 |
21 @implementation RTCConfiguration | 22 @implementation RTCConfiguration |
22 | 23 |
23 @synthesize iceServers = _iceServers; | 24 @synthesize iceServers = _iceServers; |
24 @synthesize iceTransportPolicy = _iceTransportPolicy; | 25 @synthesize iceTransportPolicy = _iceTransportPolicy; |
25 @synthesize bundlePolicy = _bundlePolicy; | 26 @synthesize bundlePolicy = _bundlePolicy; |
26 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; | 27 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
27 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; | 28 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
28 @synthesize candidateNetworkPolicy = _candidateNetworkPolicy; | 29 @synthesize candidateNetworkPolicy = _candidateNetworkPolicy; |
29 @synthesize continualGatheringPolicy = _continualGatheringPolicy; | 30 @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
30 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; | 31 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
31 @synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate; | 32 @synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate; |
32 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; | 33 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
33 @synthesize iceBackupCandidatePairPingInterval = | 34 @synthesize iceBackupCandidatePairPingInterval = |
34 _iceBackupCandidatePairPingInterval; | 35 _iceBackupCandidatePairPingInterval; |
35 @synthesize keyType = _keyType; | 36 @synthesize keyType = _keyType; |
36 @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; | 37 @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; |
37 @synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts; | 38 @synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts; |
38 @synthesize shouldPresumeWritableWhenFullyRelayed = | 39 @synthesize shouldPresumeWritableWhenFullyRelayed = |
39 _shouldPresumeWritableWhenFullyRelayed; | 40 _shouldPresumeWritableWhenFullyRelayed; |
40 @synthesize iceCheckMinInterval = _iceCheckMinInterval; | 41 @synthesize iceCheckMinInterval = _iceCheckMinInterval; |
| 42 @synthesize iceRegatherIntervalRange = _iceRegatherIntervalRange; |
41 | 43 |
42 - (instancetype)init { | 44 - (instancetype)init { |
43 // Copy defaults. | 45 // Copy defaults. |
44 webrtc::PeerConnectionInterface::RTCConfiguration config( | 46 webrtc::PeerConnectionInterface::RTCConfiguration config( |
45 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive); | 47 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive); |
46 return [self initWithNativeConfiguration:config]; | 48 return [self initWithNativeConfiguration:config]; |
47 } | 49 } |
48 | 50 |
49 - (instancetype)initWithNativeConfiguration: | 51 - (instancetype)initWithNativeConfiguration: |
50 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config { | 52 (const webrtc::PeerConnectionInterface::RTCConfiguration &)config { |
(...skipping 25 matching lines...) Expand all Loading... |
76 config.ice_backup_candidate_pair_ping_interval; | 78 config.ice_backup_candidate_pair_ping_interval; |
77 _keyType = RTCEncryptionKeyTypeECDSA; | 79 _keyType = RTCEncryptionKeyTypeECDSA; |
78 _iceCandidatePoolSize = config.ice_candidate_pool_size; | 80 _iceCandidatePoolSize = config.ice_candidate_pool_size; |
79 _shouldPruneTurnPorts = config.prune_turn_ports; | 81 _shouldPruneTurnPorts = config.prune_turn_ports; |
80 _shouldPresumeWritableWhenFullyRelayed = | 82 _shouldPresumeWritableWhenFullyRelayed = |
81 config.presume_writable_when_fully_relayed; | 83 config.presume_writable_when_fully_relayed; |
82 if (config.ice_check_min_interval) { | 84 if (config.ice_check_min_interval) { |
83 _iceCheckMinInterval = | 85 _iceCheckMinInterval = |
84 [NSNumber numberWithInt:*config.ice_check_min_interval]; | 86 [NSNumber numberWithInt:*config.ice_check_min_interval]; |
85 } | 87 } |
| 88 if (config.ice_regather_interval_range) { |
| 89 const rtc::IntervalRange &nativeIntervalRange = config.ice_regather_interv
al_range.value(); |
| 90 _iceRegatherIntervalRange = |
| 91 [[RTCIntervalRange alloc] initWithNativeIntervalRange:nativeIntervalRa
nge]; |
| 92 } |
86 } | 93 } |
87 return self; | 94 return self; |
88 } | 95 } |
89 | 96 |
90 - (NSString *)description { | 97 - (NSString *)description { |
91 return [NSString stringWithFormat: | 98 return [NSString stringWithFormat: |
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", | 99 @"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}\n", |
93 _iceServers, | 100 _iceServers, |
94 [[self class] stringForTransportPolicy:_iceTransportPolicy], | 101 [[self class] stringForTransportPolicy:_iceTransportPolicy], |
95 [[self class] stringForBundlePolicy:_bundlePolicy], | 102 [[self class] stringForBundlePolicy:_bundlePolicy], |
96 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], | 103 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
97 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], | 104 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
98 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], | 105 [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], |
99 [[self class] | 106 [[self class] |
100 stringForContinualGatheringPolicy:_continualGatheringPolicy], | 107 stringForContinualGatheringPolicy:_continualGatheringPolicy], |
101 _audioJitterBufferMaxPackets, | 108 _audioJitterBufferMaxPackets, |
102 _audioJitterBufferFastAccelerate, | 109 _audioJitterBufferFastAccelerate, |
103 _iceConnectionReceivingTimeout, | 110 _iceConnectionReceivingTimeout, |
104 _iceBackupCandidatePairPingInterval, | 111 _iceBackupCandidatePairPingInterval, |
105 _iceCandidatePoolSize, | 112 _iceCandidatePoolSize, |
106 _shouldPruneTurnPorts, | 113 _shouldPruneTurnPorts, |
107 _shouldPresumeWritableWhenFullyRelayed, | 114 _shouldPresumeWritableWhenFullyRelayed, |
108 _iceCheckMinInterval]; | 115 _iceCheckMinInterval, |
| 116 _iceRegatherIntervalRange]; |
109 } | 117 } |
110 | 118 |
111 #pragma mark - Private | 119 #pragma mark - Private |
112 | 120 |
113 - (webrtc::PeerConnectionInterface::RTCConfiguration *) | 121 - (webrtc::PeerConnectionInterface::RTCConfiguration *) |
114 createNativeConfiguration { | 122 createNativeConfiguration { |
115 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> | 123 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
116 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration( | 124 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration( |
117 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive)); | 125 webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive)); |
118 | 126 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 nativeConfig->certificates.push_back(certificate); | 160 nativeConfig->certificates.push_back(certificate); |
153 } | 161 } |
154 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize; | 162 nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize; |
155 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false; | 163 nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false; |
156 nativeConfig->presume_writable_when_fully_relayed = | 164 nativeConfig->presume_writable_when_fully_relayed = |
157 _shouldPresumeWritableWhenFullyRelayed ? true : false; | 165 _shouldPresumeWritableWhenFullyRelayed ? true : false; |
158 if (_iceCheckMinInterval != nil) { | 166 if (_iceCheckMinInterval != nil) { |
159 nativeConfig->ice_check_min_interval = | 167 nativeConfig->ice_check_min_interval = |
160 rtc::Optional<int>(_iceCheckMinInterval.intValue); | 168 rtc::Optional<int>(_iceCheckMinInterval.intValue); |
161 } | 169 } |
| 170 if (_iceRegatherIntervalRange != nil) { |
| 171 std::unique_ptr<rtc::IntervalRange> nativeIntervalRange( |
| 172 _iceRegatherIntervalRange.nativeIntervalRange); |
| 173 nativeConfig->ice_regather_interval_range = |
| 174 rtc::Optional<rtc::IntervalRange>(*nativeIntervalRange); |
| 175 } |
162 | 176 |
163 return nativeConfig.release(); | 177 return nativeConfig.release(); |
164 } | 178 } |
165 | 179 |
166 + (webrtc::PeerConnectionInterface::IceTransportsType) | 180 + (webrtc::PeerConnectionInterface::IceTransportsType) |
167 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { | 181 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { |
168 switch (policy) { | 182 switch (policy) { |
169 case RTCIceTransportPolicyNone: | 183 case RTCIceTransportPolicyNone: |
170 return webrtc::PeerConnectionInterface::kNone; | 184 return webrtc::PeerConnectionInterface::kNone; |
171 case RTCIceTransportPolicyRelay: | 185 case RTCIceTransportPolicyRelay: |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 (RTCEncryptionKeyType)keyType { | 376 (RTCEncryptionKeyType)keyType { |
363 switch (keyType) { | 377 switch (keyType) { |
364 case RTCEncryptionKeyTypeRSA: | 378 case RTCEncryptionKeyTypeRSA: |
365 return rtc::KT_RSA; | 379 return rtc::KT_RSA; |
366 case RTCEncryptionKeyTypeECDSA: | 380 case RTCEncryptionKeyTypeECDSA: |
367 return rtc::KT_ECDSA; | 381 return rtc::KT_ECDSA; |
368 } | 382 } |
369 } | 383 } |
370 | 384 |
371 @end | 385 @end |
OLD | NEW |