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 #ifndef PC_VIDEO_TRACK_SOURCE_H_ 12 #define PC_VIDEO_TRACK_SOURCE_H_ 13 14 #include "absl/types/optional.h" 15 #include "api/media_stream_interface.h" 16 #include "api/notifier.h" 17 #include "api/sequence_checker.h" 18 #include "api/video/recordable_encoded_frame.h" 19 #include "api/video/video_frame.h" 20 #include "api/video/video_sink_interface.h" 21 #include "api/video/video_source_interface.h" 22 #include "media/base/media_channel.h" 23 #include "rtc_base/checks.h" 24 #include "rtc_base/system/no_unique_address.h" 25 #include "rtc_base/system/rtc_export.h" 26 #include "rtc_base/thread_annotations.h" 27 28 namespace webrtc { 29 30 // VideoTrackSource is a convenience base class for implementations of 31 // VideoTrackSourceInterface. 32 class RTC_EXPORT VideoTrackSource : public Notifier<VideoTrackSourceInterface> { 33 public: 34 explicit VideoTrackSource(bool remote); 35 void SetState(SourceState new_state); 36 state()37 SourceState state() const override { 38 RTC_DCHECK_RUN_ON(&signaling_thread_checker_); 39 return state_; 40 } remote()41 bool remote() const override { return remote_; } 42 is_screencast()43 bool is_screencast() const override { return false; } needs_denoising()44 absl::optional<bool> needs_denoising() const override { 45 return absl::nullopt; 46 } 47 GetStats(Stats * stats)48 bool GetStats(Stats* stats) override { return false; } 49 50 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, 51 const rtc::VideoSinkWants& wants) override; 52 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override; 53 SupportsEncodedOutput()54 bool SupportsEncodedOutput() const override { return false; } GenerateKeyFrame()55 void GenerateKeyFrame() override {} AddEncodedSink(rtc::VideoSinkInterface<RecordableEncodedFrame> * sink)56 void AddEncodedSink( 57 rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {} RemoveEncodedSink(rtc::VideoSinkInterface<RecordableEncodedFrame> * sink)58 void RemoveEncodedSink( 59 rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {} 60 61 protected: 62 virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0; 63 64 private: 65 RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_; 66 RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_; 67 SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_); 68 const bool remote_; 69 }; 70 71 } // namespace webrtc 72 73 #endif // PC_VIDEO_TRACK_SOURCE_H_ 74