Index: webrtc/api/videotracksource.cc |
diff --git a/webrtc/api/videotracksource.cc b/webrtc/api/videotracksource.cc |
index 3b5e19a5b733aef9d1cefe9ba40dc49cde9b1fcb..f8212d7a70cab20cfce2d4dc5349bb172b06cc4f 100644 |
--- a/webrtc/api/videotracksource.cc |
+++ b/webrtc/api/videotracksource.cc |
@@ -32,9 +32,16 @@ void VideoTrackSource::SetState(SourceState new_state) { |
} |
} |
+void VideoTrackSource::OnSourceDestroyed() { |
+ source_ = nullptr; |
+} |
+ |
void VideoTrackSource::AddOrUpdateSink( |
rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
const rtc::VideoSinkWants& wants) { |
+ if (!source_) { |
+ return; |
+ } |
worker_thread_->Invoke<void>(rtc::Bind( |
&rtc::VideoSourceInterface<cricket::VideoFrame>::AddOrUpdateSink, source_, |
sink, wants)); |
@@ -42,6 +49,9 @@ void VideoTrackSource::AddOrUpdateSink( |
void VideoTrackSource::RemoveSink( |
rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
+ if (!source_) { |
+ return; |
+ } |
worker_thread_->Invoke<void>( |
rtc::Bind(&rtc::VideoSourceInterface<cricket::VideoFrame>::RemoveSink, |
source_, sink)); |