OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 state_(kInitializing), | 25 state_(kInitializing), |
26 remote_(remote) {} | 26 remote_(remote) {} |
27 | 27 |
28 void VideoTrackSource::SetState(SourceState new_state) { | 28 void VideoTrackSource::SetState(SourceState new_state) { |
29 if (state_ != new_state) { | 29 if (state_ != new_state) { |
30 state_ = new_state; | 30 state_ = new_state; |
31 FireOnChanged(); | 31 FireOnChanged(); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
| 35 void VideoTrackSource::OnSourceDestroyed() { |
| 36 source_ = nullptr; |
| 37 } |
| 38 |
35 void VideoTrackSource::AddOrUpdateSink( | 39 void VideoTrackSource::AddOrUpdateSink( |
36 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 40 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
37 const rtc::VideoSinkWants& wants) { | 41 const rtc::VideoSinkWants& wants) { |
| 42 if (!source_) { |
| 43 return; |
| 44 } |
38 worker_thread_->Invoke<void>(rtc::Bind( | 45 worker_thread_->Invoke<void>(rtc::Bind( |
39 &rtc::VideoSourceInterface<cricket::VideoFrame>::AddOrUpdateSink, source_, | 46 &rtc::VideoSourceInterface<cricket::VideoFrame>::AddOrUpdateSink, source_, |
40 sink, wants)); | 47 sink, wants)); |
41 } | 48 } |
42 | 49 |
43 void VideoTrackSource::RemoveSink( | 50 void VideoTrackSource::RemoveSink( |
44 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { | 51 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
| 52 if (!source_) { |
| 53 return; |
| 54 } |
45 worker_thread_->Invoke<void>( | 55 worker_thread_->Invoke<void>( |
46 rtc::Bind(&rtc::VideoSourceInterface<cricket::VideoFrame>::RemoveSink, | 56 rtc::Bind(&rtc::VideoSourceInterface<cricket::VideoFrame>::RemoveSink, |
47 source_, sink)); | 57 source_, sink)); |
48 } | 58 } |
49 | 59 |
50 } // namespace webrtc | 60 } // namespace webrtc |
OLD | NEW |