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/system/rtc_export.h"
24 
25 namespace webrtc {
26 
27 // VideoTrackSource is a convenience base class for implementations of
28 // VideoTrackSourceInterface.
29 class RTC_EXPORT VideoTrackSource : public Notifier<VideoTrackSourceInterface> {
30  public:
31   explicit VideoTrackSource(bool remote);
32   void SetState(SourceState new_state);
33 
state()34   SourceState state() const override { return state_; }
remote()35   bool remote() const override { return remote_; }
36 
is_screencast()37   bool is_screencast() const override { return false; }
needs_denoising()38   absl::optional<bool> needs_denoising() const override {
39     return absl::nullopt;
40   }
41 
GetStats(Stats * stats)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 
SupportsEncodedOutput()48   bool SupportsEncodedOutput() const override { return false; }
GenerateKeyFrame()49   void GenerateKeyFrame() override {}
AddEncodedSink(rtc::VideoSinkInterface<RecordableEncodedFrame> * sink)50   void AddEncodedSink(
51       rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
RemoveEncodedSink(rtc::VideoSinkInterface<RecordableEncodedFrame> * sink)52   void RemoveEncodedSink(
53       rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
54 
55  protected:
56   virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
57 
58  private:
59   SequenceChecker worker_thread_checker_;
60   SourceState state_;
61   const bool remote_;
62 };
63 
64 }  // namespace webrtc
65 
66 #endif  //  PC_VIDEO_TRACK_SOURCE_H_
67