Chromium Code Reviews| 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 |
| 11 #include "webrtc/api/videotracksource.h" | 11 #include "webrtc/api/videotracksource.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "webrtc/base/bind.h" | |
| 16 | |
| 17 namespace webrtc { | 15 namespace webrtc { |
| 18 | 16 |
| 19 VideoTrackSource::VideoTrackSource( | 17 VideoTrackSource::VideoTrackSource( |
| 20 rtc::VideoSourceInterface<cricket::VideoFrame>* source, | 18 rtc::VideoSourceInterface<cricket::VideoFrame>* source, |
| 21 rtc::Thread* worker_thread, | 19 rtc::Thread* worker_thread, |
| 22 bool remote) | 20 bool remote) |
| 23 : source_(source), | 21 : source_(source), |
| 24 worker_thread_(worker_thread), | 22 worker_thread_(worker_thread), |
| 25 state_(kInitializing), | 23 state_(kInitializing), |
| 26 remote_(remote) {} | 24 remote_(remote) {} |
| 27 | 25 |
| 28 void VideoTrackSource::SetState(SourceState new_state) { | 26 void VideoTrackSource::SetState(SourceState new_state) { |
| 29 if (state_ != new_state) { | 27 if (state_ != new_state) { |
| 30 state_ = new_state; | 28 state_ = new_state; |
| 31 FireOnChanged(); | 29 FireOnChanged(); |
| 32 } | 30 } |
| 33 } | 31 } |
| 34 | 32 |
| 35 void VideoTrackSource::OnSourceDestroyed() { | 33 void VideoTrackSource::OnSourceDestroyed() { |
| 36 source_ = nullptr; | 34 source_ = nullptr; |
| 37 } | 35 } |
| 38 | 36 |
| 39 void VideoTrackSource::AddOrUpdateSink( | 37 void VideoTrackSource::AddOrUpdateSink( |
| 40 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 38 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 41 const rtc::VideoSinkWants& wants) { | 39 const rtc::VideoSinkWants& wants) { |
| 40 RTC_CHECK(worker_thread_->IsCurrent()); | |
|
nisse-webrtc
2016/04/05 10:13:46
These RTC_CHECKs are now the only use of |worker_t
perkj_webrtc
2016/04/05 11:02:37
yes please and name accordingly.
nisse-webrtc
2016/04/05 11:43:55
I'm deleting the constructor argument as well (the
| |
| 42 if (!source_) { | 41 if (!source_) { |
| 43 return; | 42 return; |
| 44 } | 43 } |
| 45 worker_thread_->Invoke<void>(rtc::Bind( | 44 source_->AddOrUpdateSink(sink, wants); |
| 46 &rtc::VideoSourceInterface<cricket::VideoFrame>::AddOrUpdateSink, source_, | |
| 47 sink, wants)); | |
| 48 } | 45 } |
| 49 | 46 |
| 50 void VideoTrackSource::RemoveSink( | 47 void VideoTrackSource::RemoveSink( |
| 51 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { | 48 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
| 49 RTC_CHECK(worker_thread_->IsCurrent()); | |
| 52 if (!source_) { | 50 if (!source_) { |
| 53 return; | 51 return; |
| 54 } | 52 } |
| 55 worker_thread_->Invoke<void>( | 53 source_->RemoveSink(sink); |
| 56 rtc::Bind(&rtc::VideoSourceInterface<cricket::VideoFrame>::RemoveSink, | |
| 57 source_, sink)); | |
| 58 } | 54 } |
| 59 | 55 |
| 60 } // namespace webrtc | 56 } // namespace webrtc |
| OLD | NEW |