perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 1 | /* |
perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #include "pc/video_track_source.h" |
perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 14 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 15 | namespace webrtc { |
| 16 | |
| 17 | VideoTrackSource::VideoTrackSource( |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 18 | bool remote) |
Niels Möller | c17ca53 | 2018-05-31 15:36:49 +0200 | [diff] [blame] | 19 | : state_(kInitializing), remote_(remote) { |
nisse | 5b68ab5 | 2016-04-07 07:45:54 -0700 | [diff] [blame] | 20 | worker_thread_checker_.DetachFromThread(); |
| 21 | } |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 22 | |
| 23 | void VideoTrackSource::SetState(SourceState new_state) { |
| 24 | if (state_ != new_state) { |
| 25 | state_ = new_state; |
| 26 | FireOnChanged(); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void VideoTrackSource::AddOrUpdateSink( |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 31 | rtc::VideoSinkInterface<VideoFrame>* sink, |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 32 | const rtc::VideoSinkWants& wants) { |
nisse | 5b68ab5 | 2016-04-07 07:45:54 -0700 | [diff] [blame] | 33 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
Niels Möller | 5d67f82 | 2018-05-23 16:28:17 +0200 | [diff] [blame] | 34 | source()->AddOrUpdateSink(sink, wants); |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 35 | } |
| 36 | |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 37 | void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { |
nisse | 5b68ab5 | 2016-04-07 07:45:54 -0700 | [diff] [blame] | 38 | RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
Niels Möller | 5d67f82 | 2018-05-23 16:28:17 +0200 | [diff] [blame] | 39 | source()->RemoveSink(sink); |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | } // namespace webrtc |