Index: webrtc/api/peerconnection.cc |
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc |
index 7f1f4523781685f062bfa0f7e8b639fd1cc1b8d4..21b37859105de73c0538f8e8c275e8d65481fa3f 100644 |
--- a/webrtc/api/peerconnection.cc |
+++ b/webrtc/api/peerconnection.cc |
@@ -522,6 +522,14 @@ PeerConnection::~PeerConnection() { |
for (const auto& receiver : receivers_) { |
receiver->Stop(); |
} |
+ // Destroy stats_ because it depends on session_. |
+ stats_.reset(nullptr); |
+ // Now destroy session_ before destroying other members, |
+ // because its destruction fires signals (such as VoiceChannelDestroyed) |
+ // which will trigger some final actions in PeerConnection... |
+ session_.reset(nullptr); |
+ // port_allocator_ lives on the worker thread and should be destroyed there. |
+ worker_thread()->Invoke<void>([this] { port_allocator_.reset(nullptr); }); |
} |
bool PeerConnection::Initialize( |
@@ -543,7 +551,9 @@ bool PeerConnection::Initialize( |
if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
return false; |
} |
- port_allocator_->SetIceServers(stun_servers, turn_servers); |
+ worker_thread()->Invoke<void>(rtc::Bind( |
+ &cricket::PortAllocator::SetConfiguration, port_allocator_.get(), |
pthatcher1
2016/05/05 21:51:24
I'm a little confused. Some things on PortAllocat
Taylor Brandstetter
2016/05/06 03:53:34
That's the way it's always been. I agree it should
|
+ stun_servers, turn_servers, configuration.ice_candidate_pool_size)); |
// To handle both internal and externally created port allocator, we will |
// enable BUNDLE here. |
@@ -1144,18 +1154,20 @@ void PeerConnection::SetRemoteDescription( |
signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
} |
-bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { |
+bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) { |
TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); |
if (port_allocator_) { |
cricket::ServerAddresses stun_servers; |
std::vector<cricket::RelayServerConfig> turn_servers; |
- if (!ParseIceServers(config.servers, &stun_servers, &turn_servers)) { |
+ if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
return false; |
} |
- port_allocator_->SetIceServers(stun_servers, turn_servers); |
+ worker_thread()->Invoke<void>(rtc::Bind( |
+ &cricket::PortAllocator::SetConfiguration, port_allocator_.get(), |
+ stun_servers, turn_servers, configuration.ice_candidate_pool_size)); |
} |
- session_->SetIceConfig(session_->ParseIceConfig(config)); |
- return session_->SetIceTransports(config.type); |
+ session_->SetIceConfig(session_->ParseIceConfig(configuration)); |
+ return session_->SetIceTransports(configuration.type); |
} |
bool PeerConnection::AddIceCandidate( |