| 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 | |
| Harald Alvestrand | f0d5caf | 2025-04-07 09:08:51 | [diff] [blame] | 13 | #include "api/media_stream_interface.h" |
| 14 | #include "api/sequence_checker.h" |
| 15 | #include "api/video/video_frame.h" |
| 16 | #include "api/video/video_sink_interface.h" |
| 17 | #include "api/video/video_source_interface.h" |
| Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 18 | #include "rtc_base/checks.h" |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 19 | |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 20 | namespace webrtc { |
| 21 | |
| Jonas Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 22 | VideoTrackSource::VideoTrackSource(bool remote) |
| Tommi | c848268 | 2023-03-23 21:20:39 | [diff] [blame] | 23 | : state_(kInitializing), remote_(remote) {} |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 24 | |
| 25 | void VideoTrackSource::SetState(SourceState new_state) { |
| Tommi | 20d8d91 | 2022-02-08 20:12:15 | [diff] [blame] | 26 | RTC_DCHECK_RUN_ON(&signaling_thread_checker_); |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 27 | if (state_ != new_state) { |
| 28 | state_ = new_state; |
| 29 | FireOnChanged(); |
| 30 | } |
| 31 | } |
| 32 | |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 33 | void VideoTrackSource::AddOrUpdateSink(VideoSinkInterface<VideoFrame>* sink, |
| 34 | const VideoSinkWants& wants) { |
| Sebastian Jansson | c01367d | 2019-04-08 13:20:44 | [diff] [blame] | 35 | RTC_DCHECK(worker_thread_checker_.IsCurrent()); |
| Niels Möller | 5d67f82 | 2018-05-23 14:28:17 | [diff] [blame] | 36 | source()->AddOrUpdateSink(sink, wants); |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 37 | } |
| 38 | |
| Evan Shrubsole | e6a1f70 | 2025-04-15 14:55:42 | [diff] [blame] | 39 | void VideoTrackSource::RemoveSink(VideoSinkInterface<VideoFrame>* sink) { |
| Sebastian Jansson | c01367d | 2019-04-08 13:20:44 | [diff] [blame] | 40 | RTC_DCHECK(worker_thread_checker_.IsCurrent()); |
| Niels Möller | 5d67f82 | 2018-05-23 14:28:17 | [diff] [blame] | 41 | source()->RemoveSink(sink); |
| perkj | 0d3eef2 | 2016-03-09 01:39:17 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | } // namespace webrtc |