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

Unified Diff: webrtc/api/peerconnection.cc

Issue 1975453002: Add PeerConnection IsClosed check. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modified the checks. Modified the peerconnectioninterface unit test. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/peerconnection.cc
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 506a21582f7ae0ce6f4dffa34497ac72b4dc14ee..890007652cafc53bf3ed3de38c98158eae82315d 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(
@@ -982,6 +988,9 @@ void PeerConnection::SetLocalDescription(
SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) {
TRACE_EVENT0("webrtc", "PeerConnection::SetLocalDescription");
+ if (IsClosed()) {
+ return;
+ }
if (!VERIFY(observer != nullptr)) {
LOG(LS_ERROR) << "SetLocalDescription - observer is NULL.";
return;
@@ -1060,6 +1069,9 @@ void PeerConnection::SetRemoteDescription(
SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) {
TRACE_EVENT0("webrtc", "PeerConnection::SetRemoteDescription");
+ if (IsClosed()) {
+ return;
+ }
if (!VERIFY(observer != nullptr)) {
LOG(LS_ERROR) << "SetRemoteDescription - observer is NULL.";
return;
@@ -1175,6 +1187,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);
}
@@ -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);
}
@@ -1390,6 +1414,9 @@ void PeerConnection::ChangeSignalingState(
void PeerConnection::OnAudioTrackAdded(AudioTrackInterface* track,
MediaStreamInterface* stream) {
+ if (IsClosed()) {
+ return;
+ }
auto sender = FindSenderForTrack(track);
if (sender != senders_.end()) {
// We already have a sender for this track, so just change the stream_id
@@ -1420,6 +1447,9 @@ void PeerConnection::OnAudioTrackAdded(AudioTrackInterface* track,
// indefinitely, when we have unified plan SDP.
void PeerConnection::OnAudioTrackRemoved(AudioTrackInterface* track,
MediaStreamInterface* stream) {
+ if (IsClosed()) {
+ return;
+ }
auto sender = FindSenderForTrack(track);
if (sender == senders_.end()) {
LOG(LS_WARNING) << "RtpSender for track with id " << track->id()
@@ -1432,6 +1462,9 @@ void PeerConnection::OnAudioTrackRemoved(AudioTrackInterface* track,
void PeerConnection::OnVideoTrackAdded(VideoTrackInterface* track,
MediaStreamInterface* stream) {
+ if (IsClosed()) {
+ return;
+ }
auto sender = FindSenderForTrack(track);
if (sender != senders_.end()) {
// We already have a sender for this track, so just change the stream_id
@@ -1454,6 +1487,9 @@ void PeerConnection::OnVideoTrackAdded(VideoTrackInterface* track,
void PeerConnection::OnVideoTrackRemoved(VideoTrackInterface* track,
MediaStreamInterface* stream) {
+ if (IsClosed()) {
+ return;
+ }
auto sender = FindSenderForTrack(track);
if (sender == senders_.end()) {
LOG(LS_WARNING) << "RtpSender for track with id " << track->id()
« no previous file with comments | « no previous file | webrtc/api/peerconnectioninterface_unittest.cc » ('j') | webrtc/api/peerconnectioninterface_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698