Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: webrtc/p2p/base/portallocator.h

Issue 2717893003: Making candidate pool size behave as decided in JSEP. (Closed)
Patch Set: Get rid of now-unnecessary test. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/p2p/base/portallocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 class PortAllocator : public sigslot::has_slots<> { 300 class PortAllocator : public sigslot::has_slots<> {
301 public: 301 public:
302 PortAllocator() : 302 PortAllocator() :
303 flags_(kDefaultPortAllocatorFlags), 303 flags_(kDefaultPortAllocatorFlags),
304 min_port_(0), 304 min_port_(0),
305 max_port_(0), 305 max_port_(0),
306 step_delay_(kDefaultStepDelay), 306 step_delay_(kDefaultStepDelay),
307 allow_tcp_listen_(true), 307 allow_tcp_listen_(true),
308 candidate_filter_(CF_ALL) { 308 candidate_filter_(CF_ALL) {
309 } 309 }
310
310 virtual ~PortAllocator() {} 311 virtual ~PortAllocator() {}
311 312
312 // This should be called on the PortAllocator's thread before the 313 // This should be called on the PortAllocator's thread before the
313 // PortAllocator is used. Subclasses may override this if necessary. 314 // PortAllocator is used. Subclasses may override this if necessary.
314 virtual void Initialize() {} 315 virtual void Initialize() {}
315 316
316 // Set STUN and TURN servers to be used in future sessions, and set 317 // Set STUN and TURN servers to be used in future sessions, and set
317 // candidate pool size, as described in JSEP. 318 // candidate pool size, as described in JSEP.
318 // 319 //
319 // If the servers are changing and the candidate pool size is nonzero, 320 // If the servers are changing, and the candidate pool size is nonzero, and
320 // existing pooled sessions will be destroyed and new ones created. 321 // FreezeCandidatePool hasn't been called, existing pooled sessions will be
322 // destroyed and new ones created.
321 // 323 //
322 // If the servers are not changing but the candidate pool size is, 324 // If the servers are not changing but the candidate pool size is, and
323 // pooled sessions will be either created or destroyed as necessary. 325 // FreezeCandidatePool hasn't been called, pooled sessions will be either
326 // created or destroyed as necessary.
324 // 327 //
325 // Returns true if the configuration could successfully be changed. 328 // Returns true if the configuration could successfully be changed.
326 bool SetConfiguration(const ServerAddresses& stun_servers, 329 bool SetConfiguration(const ServerAddresses& stun_servers,
327 const std::vector<RelayServerConfig>& turn_servers, 330 const std::vector<RelayServerConfig>& turn_servers,
328 int candidate_pool_size, 331 int candidate_pool_size,
329 bool prune_turn_ports); 332 bool prune_turn_ports);
330 333
331 const ServerAddresses& stun_servers() const { return stun_servers_; } 334 const ServerAddresses& stun_servers() const { return stun_servers_; }
332 335
333 const std::vector<RelayServerConfig>& turn_servers() const { 336 const std::vector<RelayServerConfig>& turn_servers() const {
(...skipping 22 matching lines...) Expand all
356 // If no pooled sessions are available, returns null. 359 // If no pooled sessions are available, returns null.
357 std::unique_ptr<PortAllocatorSession> TakePooledSession( 360 std::unique_ptr<PortAllocatorSession> TakePooledSession(
358 const std::string& content_name, 361 const std::string& content_name,
359 int component, 362 int component,
360 const std::string& ice_ufrag, 363 const std::string& ice_ufrag,
361 const std::string& ice_pwd); 364 const std::string& ice_pwd);
362 365
363 // Returns the next session that would be returned by TakePooledSession. 366 // Returns the next session that would be returned by TakePooledSession.
364 const PortAllocatorSession* GetPooledSession() const; 367 const PortAllocatorSession* GetPooledSession() const;
365 368
369 // After FreezeCandidatePool is called, changing the candidate pool size will
370 // no longer be allowed, and changing ICE servers will not cause pooled
371 // sessions to be recreated.
372 //
373 // Expected to be called when SetLocalDescription is called on a
374 // PeerConnection. Can be called safely on any thread as long as not
375 // simultaneously with SetConfiguration.
376 void FreezeCandidatePool();
377
378 // Discard any remaining pooled sessions.
379 void DiscardPooledSessions();
pthatcher1 2017/03/09 00:28:15 DiscardCandidatePool? To be consistent with Freez
Taylor Brandstetter 2017/03/09 14:59:03 Done
380
366 uint32_t flags() const { return flags_; } 381 uint32_t flags() const { return flags_; }
367 void set_flags(uint32_t flags) { flags_ = flags; } 382 void set_flags(uint32_t flags) { flags_ = flags; }
368 383
369 const std::string& user_agent() const { return agent_; } 384 const std::string& user_agent() const { return agent_; }
370 const rtc::ProxyInfo& proxy() const { return proxy_; } 385 const rtc::ProxyInfo& proxy() const { return proxy_; }
371 void set_proxy(const std::string& agent, const rtc::ProxyInfo& proxy) { 386 void set_proxy(const std::string& agent, const rtc::ProxyInfo& proxy) {
372 agent_ = agent; 387 agent_ = agent;
373 proxy_ = proxy; 388 proxy_ = proxy;
374 } 389 }
375 390
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 uint32_t step_delay_; 447 uint32_t step_delay_;
433 bool allow_tcp_listen_; 448 bool allow_tcp_listen_;
434 uint32_t candidate_filter_; 449 uint32_t candidate_filter_;
435 std::string origin_; 450 std::string origin_;
436 451
437 private: 452 private:
438 ServerAddresses stun_servers_; 453 ServerAddresses stun_servers_;
439 std::vector<RelayServerConfig> turn_servers_; 454 std::vector<RelayServerConfig> turn_servers_;
440 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. 455 int candidate_pool_size_ = 0; // Last value passed into SetConfiguration.
441 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; 456 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_;
457 bool candidate_pool_frozen_ = false;
442 bool prune_turn_ports_ = false; 458 bool prune_turn_ports_ = false;
443 459
444 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; 460 webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;
445 }; 461 };
446 462
447 } // namespace cricket 463 } // namespace cricket
448 464
449 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ 465 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/portallocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698