OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 std::string content_name_; | 214 std::string content_name_; |
215 int component_; | 215 int component_; |
216 std::string ice_ufrag_; | 216 std::string ice_ufrag_; |
217 std::string ice_pwd_; | 217 std::string ice_pwd_; |
218 | 218 |
219 // SetIceParameters is an implementation detail which only PortAllocator | 219 // SetIceParameters is an implementation detail which only PortAllocator |
220 // should be able to call. | 220 // should be able to call. |
221 friend class PortAllocator; | 221 friend class PortAllocator; |
222 }; | 222 }; |
223 | 223 |
224 // Note that this class should only be used on one thread. | 224 // This class can be constructed on any thread, but every other method |
225 // This includes calling the destructor. | 225 // (including the destructor) should be called on a different thread. |
skvlad
2016/06/23 22:15:55
Do we have a way to verify that the "other thread"
Taylor Brandstetter
2016/06/23 22:59:07
Yeah, we can call "DetachFromThread" in the constr
| |
226 // This allows constructing a PortAllocator subclass on one thread and | |
227 // passing it into an object that uses it on a different thread. | |
226 class PortAllocator : public sigslot::has_slots<> { | 228 class PortAllocator : public sigslot::has_slots<> { |
227 public: | 229 public: |
228 PortAllocator() : | 230 PortAllocator() : |
229 flags_(kDefaultPortAllocatorFlags), | 231 flags_(kDefaultPortAllocatorFlags), |
230 min_port_(0), | 232 min_port_(0), |
231 max_port_(0), | 233 max_port_(0), |
232 step_delay_(kDefaultStepDelay), | 234 step_delay_(kDefaultStepDelay), |
233 allow_tcp_listen_(true), | 235 allow_tcp_listen_(true), |
234 candidate_filter_(CF_ALL) { | 236 candidate_filter_(CF_ALL) { |
235 // This will allow us to have old behavior on non webrtc clients. | |
236 } | 237 } |
237 virtual ~PortAllocator() {} | 238 virtual ~PortAllocator() {} |
238 | 239 |
240 // This should be called on the PortAllocator's thread before the | |
241 // PortAllocator is used. Subclasses may override this if necessary. | |
242 virtual void Initialize() {} | |
243 | |
239 // Set STUN and TURN servers to be used in future sessions, and set | 244 // Set STUN and TURN servers to be used in future sessions, and set |
240 // candidate pool size, as described in JSEP. | 245 // candidate pool size, as described in JSEP. |
241 // | 246 // |
242 // If the servers are changing and the candidate pool size is nonzero, | 247 // If the servers are changing and the candidate pool size is nonzero, |
243 // existing pooled sessions will be destroyed and new ones created. | 248 // existing pooled sessions will be destroyed and new ones created. |
244 // | 249 // |
245 // If the servers are not changing but the candidate pool size is, | 250 // If the servers are not changing but the candidate pool size is, |
246 // pooled sessions will be either created or destroyed as necessary. | 251 // pooled sessions will be either created or destroyed as necessary. |
247 void SetConfiguration(const ServerAddresses& stun_servers, | 252 void SetConfiguration(const ServerAddresses& stun_servers, |
248 const std::vector<RelayServerConfig>& turn_servers, | 253 const std::vector<RelayServerConfig>& turn_servers, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 int target_pooled_session_count_ = 0; | 353 int target_pooled_session_count_ = 0; |
349 // This variable represents the total number of pooled sessions | 354 // This variable represents the total number of pooled sessions |
350 // both owned by this class and taken by TakePooledSession. | 355 // both owned by this class and taken by TakePooledSession. |
351 int allocated_pooled_session_count_ = 0; | 356 int allocated_pooled_session_count_ = 0; |
352 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; | 357 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
353 }; | 358 }; |
354 | 359 |
355 } // namespace cricket | 360 } // namespace cricket |
356 | 361 |
357 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 362 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
OLD | NEW |