| Index: webrtc/pc/videotrack.cc
|
| diff --git a/webrtc/pc/videotrack.cc b/webrtc/pc/videotrack.cc
|
| index 494d728b1eaad2ba204308cbb84f708af2706304..f106460164731f4b32facb3201403a4c3e6bf66c 100644
|
| --- a/webrtc/pc/videotrack.cc
|
| +++ b/webrtc/pc/videotrack.cc
|
| @@ -15,11 +15,12 @@
|
| namespace webrtc {
|
|
|
| VideoTrack::VideoTrack(const std::string& label,
|
| - VideoTrackSourceInterface* video_source)
|
| + VideoTrackSourceInterface* video_source,
|
| + rtc::Thread* worker_thread)
|
| : MediaStreamTrack<VideoTrackInterface>(label),
|
| + worker_thread_(worker_thread),
|
| video_source_(video_source),
|
| content_hint_(ContentHint::kNone) {
|
| - worker_thread_checker_.DetachFromThread();
|
| video_source_->RegisterObserver(this);
|
| }
|
|
|
| @@ -35,7 +36,7 @@ std::string VideoTrack::kind() const {
|
| // thread.
|
| void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
|
| const rtc::VideoSinkWants& wants) {
|
| - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
| + RTC_DCHECK(worker_thread_->IsCurrent());
|
| VideoSourceBase::AddOrUpdateSink(sink, wants);
|
| rtc::VideoSinkWants modified_wants = wants;
|
| modified_wants.black_frames = !enabled();
|
| @@ -43,7 +44,7 @@ void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
|
| }
|
|
|
| void VideoTrack::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
|
| - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
| + RTC_DCHECK(worker_thread_->IsCurrent());
|
| VideoSourceBase::RemoveSink(sink);
|
| video_source_->RemoveSink(sink);
|
| }
|
| @@ -63,13 +64,14 @@ void VideoTrack::set_content_hint(ContentHint hint) {
|
|
|
| bool VideoTrack::set_enabled(bool enable) {
|
| RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread());
|
| - for (auto& sink_pair : sink_pairs()) {
|
| - rtc::VideoSinkWants modified_wants = sink_pair.wants;
|
| - modified_wants.black_frames = !enable;
|
| - // video_source_ is a proxy object, marshalling the call to the
|
| - // worker thread.
|
| - video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
|
| - }
|
| + worker_thread_->Invoke<void>(RTC_FROM_HERE, [enable, this] {
|
| + RTC_DCHECK(worker_thread_->IsCurrent());
|
| + for (auto& sink_pair : sink_pairs()) {
|
| + rtc::VideoSinkWants modified_wants = sink_pair.wants;
|
| + modified_wants.black_frames = !enable;
|
| + video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
|
| + }
|
| + });
|
| return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
|
| }
|
|
|
| @@ -84,9 +86,10 @@ void VideoTrack::OnChanged() {
|
|
|
| rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
|
| const std::string& id,
|
| - VideoTrackSourceInterface* source) {
|
| + VideoTrackSourceInterface* source,
|
| + rtc::Thread* worker_thread) {
|
| rtc::RefCountedObject<VideoTrack>* track =
|
| - new rtc::RefCountedObject<VideoTrack>(id, source);
|
| + new rtc::RefCountedObject<VideoTrack>(id, source, worker_thread);
|
| return track;
|
| }
|
|
|
|
|