perkj | 11e1805 | 2016-03-07 21:03:23 | [diff] [blame] | 1 | /* |
perkj | 11e1805 | 2016-03-07 21:03:23 | [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 17:11:00 | [diff] [blame] | 11 | #include "pc/video_track_source.h" |
perkj | 11e1805 | 2016-03-07 21:03:23 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 14 | |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 15 | namespace webrtc { |
| 16 | |
Jonas Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 17 | VideoTrackSource::VideoTrackSource(bool remote) |
Niels Möller | c17ca53 | 2018-05-31 13:36:49 | [diff] [blame] | 18 | : state_(kInitializing), remote_(remote) { |
Sebastian Jansson | c01367d | 2019-04-08 13:20:44 | [diff] [blame] | 19 | worker_thread_checker_.Detach(); |
nisse | 5b68ab5 | 2016-04-07 14:45:54 | [diff] [blame] | 20 | } |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 21 | |
| 22 | void VideoTrackSource::SetState(SourceState new_state) { |
| 23 | if (state_ != new_state) { |
| 24 | state_ = new_state; |
| 25 | FireOnChanged(); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | void VideoTrackSource::AddOrUpdateSink( |
nisse | acd935b | 2016-11-11 11:55:13 | [diff] [blame] | 30 | rtc::VideoSinkInterface<VideoFrame>* sink, |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 31 | const rtc::VideoSinkWants& wants) { |
Sebastian Jansson | c01367d | 2019-04-08 13:20:44 | [diff] [blame] | 32 | RTC_DCHECK(worker_thread_checker_.IsCurrent()); |
Niels Möller | 5d67f82 | 2018-05-23 14:28:17 | [diff] [blame] | 33 | source()->AddOrUpdateSink(sink, wants); |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 34 | } |
| 35 | |
nisse | acd935b | 2016-11-11 11:55:13 | [diff] [blame] | 36 | void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { |
Sebastian Jansson | c01367d | 2019-04-08 13:20:44 | [diff] [blame] | 37 | RTC_DCHECK(worker_thread_checker_.IsCurrent()); |
Niels Möller | 5d67f82 | 2018-05-23 14:28:17 | [diff] [blame] | 38 | source()->RemoveSink(sink); |
perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | } // namespace webrtc |