blob: 223c5dd6691d3f78af52081ed4c4772010d2926d [file] [log] [blame]
ossu7bb87ee2017-01-23 04:56:25 -08001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_VIDEO_TRACK_SOURCE_H_
12#define PC_VIDEO_TRACK_SOURCE_H_
ossu7bb87ee2017-01-23 04:56:25 -080013
Harald Alvestrand5761e7b2021-01-29 14:45:08 +000014#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 09:11:00 -080015#include "api/media_stream_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/notifier.h"
Harald Alvestrand5761e7b2021-01-29 14:45:08 +000017#include "api/video/recordable_encoded_frame.h"
18#include "api/video/video_frame.h"
Niels Möllerc6ce9c52018-05-11 11:15:30 +020019#include "api/video/video_sink_interface.h"
Harald Alvestrand5761e7b2021-01-29 14:45:08 +000020#include "api/video/video_source_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "media/base/media_channel.h"
Artem Titovc8421c42021-02-02 10:57:19 +010022#include "rtc_base/synchronization/sequence_checker.h"
Mirko Bonadei3b56ee72018-10-15 17:15:12 +020023#include "rtc_base/system/rtc_export.h"
ossu7bb87ee2017-01-23 04:56:25 -080024
ossu7bb87ee2017-01-23 04:56:25 -080025namespace webrtc {
26
Niels Möller5d67f822018-05-23 16:28:17 +020027// VideoTrackSource is a convenience base class for implementations of
28// VideoTrackSourceInterface.
Mirko Bonadei3b56ee72018-10-15 17:15:12 +020029class RTC_EXPORT VideoTrackSource : public Notifier<VideoTrackSourceInterface> {
ossu7bb87ee2017-01-23 04:56:25 -080030 public:
Niels Möller5d67f822018-05-23 16:28:17 +020031 explicit VideoTrackSource(bool remote);
ossu7bb87ee2017-01-23 04:56:25 -080032 void SetState(SourceState new_state);
ossu7bb87ee2017-01-23 04:56:25 -080033
34 SourceState state() const override { return state_; }
35 bool remote() const override { return remote_; }
36
37 bool is_screencast() const override { return false; }
Danil Chapovalov66cadcc2018-06-19 16:47:43 +020038 absl::optional<bool> needs_denoising() const override {
39 return absl::nullopt;
40 }
ossu7bb87ee2017-01-23 04:56:25 -080041
42 bool GetStats(Stats* stats) override { return false; }
43
44 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
45 const rtc::VideoSinkWants& wants) override;
46 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
47
Markus Handell6efc14b2020-05-05 20:11:13 +020048 bool SupportsEncodedOutput() const override { return false; }
49 void GenerateKeyFrame() override {}
50 void AddEncodedSink(
51 rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
52 void RemoveEncodedSink(
53 rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
54
Niels Möller5d67f822018-05-23 16:28:17 +020055 protected:
Niels Möllerc17ca532018-05-31 15:36:49 +020056 virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
Niels Möller5d67f822018-05-23 16:28:17 +020057
ossu7bb87ee2017-01-23 04:56:25 -080058 private:
Artem Titovc8421c42021-02-02 10:57:19 +010059 SequenceChecker worker_thread_checker_;
ossu7bb87ee2017-01-23 04:56:25 -080060 SourceState state_;
61 const bool remote_;
62};
63
64} // namespace webrtc
65
Steve Anton10542f22019-01-11 09:11:00 -080066#endif // PC_VIDEO_TRACK_SOURCE_H_