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