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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 virtual void Initialize() {} | 291 virtual void Initialize() {} |
292 | 292 |
293 // Set STUN and TURN servers to be used in future sessions, and set | 293 // Set STUN and TURN servers to be used in future sessions, and set |
294 // candidate pool size, as described in JSEP. | 294 // candidate pool size, as described in JSEP. |
295 // | 295 // |
296 // If the servers are changing and the candidate pool size is nonzero, | 296 // If the servers are changing and the candidate pool size is nonzero, |
297 // existing pooled sessions will be destroyed and new ones created. | 297 // existing pooled sessions will be destroyed and new ones created. |
298 // | 298 // |
299 // If the servers are not changing but the candidate pool size is, | 299 // If the servers are not changing but the candidate pool size is, |
300 // pooled sessions will be either created or destroyed as necessary. | 300 // pooled sessions will be either created or destroyed as necessary. |
301 void SetConfiguration(const ServerAddresses& stun_servers, | 301 // |
| 302 // Returns true if the configuration could successfully be changed. |
| 303 bool SetConfiguration(const ServerAddresses& stun_servers, |
302 const std::vector<RelayServerConfig>& turn_servers, | 304 const std::vector<RelayServerConfig>& turn_servers, |
303 int candidate_pool_size, | 305 int candidate_pool_size, |
304 bool prune_turn_ports); | 306 bool prune_turn_ports); |
305 | 307 |
306 const ServerAddresses& stun_servers() const { return stun_servers_; } | 308 const ServerAddresses& stun_servers() const { return stun_servers_; } |
307 | 309 |
308 const std::vector<RelayServerConfig>& turn_servers() const { | 310 const std::vector<RelayServerConfig>& turn_servers() const { |
309 return turn_servers_; | 311 return turn_servers_; |
310 } | 312 } |
311 | 313 |
312 int candidate_pool_size() const { return target_pooled_session_count_; } | 314 int candidate_pool_size() const { return candidate_pool_size_; } |
313 | 315 |
314 // Sets the network types to ignore. | 316 // Sets the network types to ignore. |
315 // Values are defined by the AdapterType enum. | 317 // Values are defined by the AdapterType enum. |
316 // For instance, calling this with | 318 // For instance, calling this with |
317 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and | 319 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and |
318 // loopback interfaces. | 320 // loopback interfaces. |
319 virtual void SetNetworkIgnoreMask(int network_ignore_mask) = 0; | 321 virtual void SetNetworkIgnoreMask(int network_ignore_mask) = 0; |
320 | 322 |
321 std::unique_ptr<PortAllocatorSession> CreateSession( | 323 std::unique_ptr<PortAllocatorSession> CreateSession( |
322 const std::string& content_name, | 324 const std::string& content_name, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 int min_port_; | 407 int min_port_; |
406 int max_port_; | 408 int max_port_; |
407 uint32_t step_delay_; | 409 uint32_t step_delay_; |
408 bool allow_tcp_listen_; | 410 bool allow_tcp_listen_; |
409 uint32_t candidate_filter_; | 411 uint32_t candidate_filter_; |
410 std::string origin_; | 412 std::string origin_; |
411 | 413 |
412 private: | 414 private: |
413 ServerAddresses stun_servers_; | 415 ServerAddresses stun_servers_; |
414 std::vector<RelayServerConfig> turn_servers_; | 416 std::vector<RelayServerConfig> turn_servers_; |
415 // The last size passed into SetConfiguration. | 417 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. |
416 int target_pooled_session_count_ = 0; | |
417 // This variable represents the total number of pooled sessions | |
418 // both owned by this class and taken by TakePooledSession. | |
419 int allocated_pooled_session_count_ = 0; | |
420 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; | 418 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
421 bool prune_turn_ports_ = false; | 419 bool prune_turn_ports_ = false; |
422 | 420 |
423 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; | 421 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; |
424 }; | 422 }; |
425 | 423 |
426 } // namespace cricket | 424 } // namespace cricket |
427 | 425 |
428 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 426 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
OLD | NEW |