xref: /aosp_15_r20/external/webrtc/pc/video_track_source.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 
11 #include "pc/video_track_source.h"
12 
13 #include "rtc_base/checks.h"
14 
15 namespace webrtc {
16 
VideoTrackSource(bool remote)17 VideoTrackSource::VideoTrackSource(bool remote)
18     : state_(kInitializing), remote_(remote) {
19   worker_thread_checker_.Detach();
20 }
21 
SetState(SourceState new_state)22 void VideoTrackSource::SetState(SourceState new_state) {
23   RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
24   if (state_ != new_state) {
25     state_ = new_state;
26     FireOnChanged();
27   }
28 }
29 
AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame> * sink,const rtc::VideoSinkWants & wants)30 void VideoTrackSource::AddOrUpdateSink(
31     rtc::VideoSinkInterface<VideoFrame>* sink,
32     const rtc::VideoSinkWants& wants) {
33   RTC_DCHECK(worker_thread_checker_.IsCurrent());
34   source()->AddOrUpdateSink(sink, wants);
35 }
36 
RemoveSink(rtc::VideoSinkInterface<VideoFrame> * sink)37 void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
38   RTC_DCHECK(worker_thread_checker_.IsCurrent());
39   source()->RemoveSink(sink);
40 }
41 
42 }  //  namespace webrtc
43