Index: webrtc/api/peerconnection.cc |
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc |
index 506a21582f7ae0ce6f4dffa34497ac72b4dc14ee..56b2bc8728a21183bfc41491c3f355f5903cb3a9 100644 |
--- a/webrtc/api/peerconnection.cc |
+++ b/webrtc/api/peerconnection.cc |
@@ -758,6 +758,9 @@ bool PeerConnection::RemoveTrack(RtpSenderInterface* sender) { |
rtc::scoped_refptr<DtmfSenderInterface> PeerConnection::CreateDtmfSender( |
AudioTrackInterface* track) { |
TRACE_EVENT0("webrtc", "PeerConnection::CreateDtmfSender"); |
+ if (IsClosed()) { |
+ return nullptr; |
+ } |
if (!track) { |
LOG(LS_ERROR) << "CreateDtmfSender - track is NULL."; |
return NULL; |
@@ -780,6 +783,9 @@ rtc::scoped_refptr<RtpSenderInterface> PeerConnection::CreateSender( |
const std::string& kind, |
const std::string& stream_id) { |
TRACE_EVENT0("webrtc", "PeerConnection::CreateSender"); |
+ if (IsClosed()) { |
+ return nullptr; |
+ } |
rtc::scoped_refptr<RtpSenderInterface> new_sender; |
if (kind == MediaStreamTrackInterface::kAudioKind) { |
new_sender = RtpSenderProxy::Create( |
@@ -1175,6 +1181,9 @@ bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { |
bool PeerConnection::AddIceCandidate( |
const IceCandidateInterface* ice_candidate) { |
TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
+ if (IsClosed()) { |
+ return false; |
+ } |
return session_->ProcessIceMessage(ice_candidate); |
} |
@@ -1296,6 +1305,9 @@ void PeerConnection::OnMessage(rtc::Message* msg) { |
void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
const std::string& track_id, |
uint32_t ssrc) { |
+ if (IsClosed()) { |
+ return; |
+ } |
Taylor Brandstetter
2016/05/11 22:18:36
This and CreateVideoReceiver are internal methods,
Zhi Huang
2016/05/12 01:25:49
Done.
|
receivers_.push_back(RtpReceiverProxy::Create( |
signaling_thread(), |
new AudioRtpReceiver(stream, track_id, ssrc, session_.get()))); |
@@ -1304,6 +1316,9 @@ void PeerConnection::CreateAudioReceiver(MediaStreamInterface* stream, |
void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream, |
const std::string& track_id, |
uint32_t ssrc) { |
+ if (IsClosed()) { |
+ return; |
+ } |
receivers_.push_back(RtpReceiverProxy::Create( |
signaling_thread(), |
new VideoRtpReceiver(stream, track_id, factory_->worker_thread(), ssrc, |
@@ -1360,17 +1375,26 @@ void PeerConnection::OnIceGatheringChange( |
void PeerConnection::OnIceCandidate(const IceCandidateInterface* candidate) { |
RTC_DCHECK(signaling_thread()->IsCurrent()); |
+ if (IsClosed()) { |
+ return; |
+ } |
observer_->OnIceCandidate(candidate); |
} |
void PeerConnection::OnIceCandidatesRemoved( |
const std::vector<cricket::Candidate>& candidates) { |
RTC_DCHECK(signaling_thread()->IsCurrent()); |
+ if (IsClosed()) { |
+ return; |
+ } |
observer_->OnIceCandidatesRemoved(candidates); |
} |
void PeerConnection::OnIceConnectionReceivingChange(bool receiving) { |
RTC_DCHECK(signaling_thread()->IsCurrent()); |
+ if (IsClosed()) { |
+ return; |
+ } |
observer_->OnIceConnectionReceivingChange(receiving); |
} |