Index: webrtc/p2p/base/portallocator.h |
diff --git a/webrtc/p2p/base/portallocator.h b/webrtc/p2p/base/portallocator.h |
index 016a7dc996b41acca85987323274637b1951a730..87285925db9e213ac550a0a594e84fa7562a70ce 100644 |
--- a/webrtc/p2p/base/portallocator.h |
+++ b/webrtc/p2p/base/portallocator.h |
@@ -306,6 +306,7 @@ class PortAllocator : public sigslot::has_slots<> { |
allow_tcp_listen_(true), |
candidate_filter_(CF_ALL) { |
} |
+ |
virtual ~PortAllocator() {} |
// This should be called on the PortAllocator's thread before the |
@@ -315,11 +316,13 @@ class PortAllocator : public sigslot::has_slots<> { |
// Set STUN and TURN servers to be used in future sessions, and set |
// candidate pool size, as described in JSEP. |
// |
- // If the servers are changing and the candidate pool size is nonzero, |
- // existing pooled sessions will be destroyed and new ones created. |
+ // If the servers are changing, and the candidate pool size is nonzero, and |
+ // FreezeCandidatePool hasn't been called, existing pooled sessions will be |
+ // destroyed and new ones created. |
// |
- // If the servers are not changing but the candidate pool size is, |
- // pooled sessions will be either created or destroyed as necessary. |
+ // If the servers are not changing but the candidate pool size is, and |
+ // FreezeCandidatePool hasn't been called, pooled sessions will be either |
+ // created or destroyed as necessary. |
// |
// Returns true if the configuration could successfully be changed. |
bool SetConfiguration(const ServerAddresses& stun_servers, |
@@ -362,6 +365,18 @@ class PortAllocator : public sigslot::has_slots<> { |
// Returns the next session that would be returned by TakePooledSession. |
const PortAllocatorSession* GetPooledSession() const; |
+ // After FreezeCandidatePool is called, changing the candidate pool size will |
+ // no longer be allowed, and changing ICE servers will not cause pooled |
+ // sessions to be recreated. |
+ // |
+ // Expected to be called when SetLocalDescription is called on a |
+ // PeerConnection. Can be called safely on any thread as long as not |
+ // simultaneously with SetConfiguration. |
+ void FreezeCandidatePool(); |
+ |
+ // Discard any remaining pooled sessions. |
+ void DiscardCandidatePool(); |
+ |
uint32_t flags() const { return flags_; } |
void set_flags(uint32_t flags) { flags_ = flags; } |
@@ -429,6 +444,7 @@ class PortAllocator : public sigslot::has_slots<> { |
std::vector<RelayServerConfig> turn_servers_; |
int candidate_pool_size_ = 0; // Last value passed into SetConfiguration. |
std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
+ bool candidate_pool_frozen_ = false; |
bool prune_turn_ports_ = false; |
webrtc::MetricsObserverInterface* metrics_observer_ = nullptr; |