Index: webrtc/pc/peerconnection.cc |
diff --git a/webrtc/pc/peerconnection.cc b/webrtc/pc/peerconnection.cc |
index 48ffebe222d1c6482d81e27d244ee6f4e79dbc25..2c8c97886402a89fca049badd75bc7fe245aa106 100644 |
--- a/webrtc/pc/peerconnection.cc |
+++ b/webrtc/pc/peerconnection.cc |
@@ -1259,10 +1259,24 @@ void PeerConnection::SetLocalDescription( |
signaling_thread()->Post(RTC_FROM_HERE, this, |
MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
+ // According to JSEP, after setLocalDescription, changing the candidate pool |
+ // size is not allowed, and changing the set of ICE servers will not result |
+ // in new candidates being gathered. |
+ port_allocator_->FreezeCandidatePool(); |
+ |
// MaybeStartGathering needs to be called after posting |
// MSG_SET_SESSIONDESCRIPTION_SUCCESS, so that we don't signal any candidates |
// before signaling that SetLocalDescription completed. |
session_->MaybeStartGathering(); |
+ |
+ if (desc->type() == SessionDescriptionInterface::kAnswer) { |
+ // TODO(deadbeef): We already had to hop to the network thread for |
+ // MaybeStartGathering... |
+ network_thread()->Invoke<void>( |
+ RTC_FROM_HERE, |
+ rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, |
+ port_allocator_.get())); |
+ } |
} |
void PeerConnection::SetRemoteDescription( |
@@ -1373,6 +1387,15 @@ void PeerConnection::SetRemoteDescription( |
SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
signaling_thread()->Post(RTC_FROM_HERE, this, |
MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
+ |
+ if (desc->type() == SessionDescriptionInterface::kAnswer) { |
+ // TODO(deadbeef): We already had to hop to the network thread for |
+ // MaybeStartGathering... |
+ network_thread()->Invoke<void>( |
+ RTC_FROM_HERE, |
+ rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, |
+ port_allocator_.get())); |
+ } |
} |
PeerConnectionInterface::RTCConfiguration PeerConnection::GetConfiguration() { |
@@ -1538,6 +1561,10 @@ void PeerConnection::Close() { |
session_->Close(); |
event_log_.reset(); |
+ network_thread()->Invoke<void>( |
+ RTC_FROM_HERE, |
+ rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, |
+ port_allocator_.get())); |
} |
void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/, |