OpenTera WebRTC API (C++) 1.2.5
VideoSource.h
1 #ifndef OPENTERA_WEBRTC_NATIVE_CLIENT_SOURCES_VIDEO_SOURCE_H
2 #define OPENTERA_WEBRTC_NATIVE_CLIENT_SOURCES_VIDEO_SOURCE_H
3 
4 #include <OpenteraWebrtcNativeClient/Configurations/VideoSourceConfiguration.h>
5 #include <OpenteraWebrtcNativeClient/Utils/ClassMacro.h>
6 
7 #include <media/base/adapted_video_track_source.h>
8 #include <opencv2/core/mat.hpp>
9 #include <rtc_base/ref_counted_object.h>
10 
11 namespace opentera
12 {
13 
20  class VideoSource : public rtc::AdaptedVideoTrackSource
21  {
22  VideoSourceConfiguration m_configuration;
23  cv::Mat m_yuvImg;
24  cv::Mat m_resizedImg;
25 
26  public:
27  explicit VideoSource(VideoSourceConfiguration configuration);
28  ~VideoSource() override = default;
29 
30  DECLARE_NOT_COPYABLE(VideoSource);
31  DECLARE_NOT_MOVABLE(VideoSource);
32 
33  void sendFrame(const cv::Mat& bgrImg, int64_t timestampUs);
34 
35  bool is_screencast() const override;
36  absl::optional<bool> needs_denoising() const override;
37  bool remote() const override;
38  webrtc::MediaSourceInterface::SourceState state() const override;
39 
40  // Methods to fake a ref counted object, so the Python binding is easier to
41  // make because we can use a shared_ptr
42  void AddRef() const override;
43  rtc::RefCountReleaseStatus Release() const override;
44  };
45 
50  inline bool VideoSource::is_screencast() const { return m_configuration.isScreencast(); }
51 
56  inline absl::optional<bool> VideoSource::needs_denoising() const { return m_configuration.needsDenoising(); }
57 
62  inline bool VideoSource::remote() const { return false; }
63 
68  inline webrtc::MediaSourceInterface::SourceState VideoSource::state() const
69  {
70  return webrtc::MediaSourceInterface::kLive;
71  }
72 }
73 
74 #endif
Represents a configuration of a video source that can be added to a WebRTC call.
Definition: VideoSourceConfiguration.h:10
bool isScreencast() const
Indicates if this source is screencast.
Definition: VideoSourceConfiguration.h:52
bool needsDenoising() const
Indicates if this source needs denoising.
Definition: VideoSourceConfiguration.h:46
Represents a video source that can be added to a WebRTC call.
Definition: VideoSource.h:21
bool remote() const override
Indicates if this source is remote.
Definition: VideoSource.h:62
VideoSource(VideoSourceConfiguration configuration)
Creates a VideoSource.
Definition: VideoSource.cpp:16
bool is_screencast() const override
Indicates if this source is screencast.
Definition: VideoSource.h:50
void sendFrame(const cv::Mat &bgrImg, int64_t timestampUs)
Sends a frame to the WebRTC transport layer.
Definition: VideoSource.cpp:27
absl::optional< bool > needs_denoising() const override
Indicates if this source needs denoising.
Definition: VideoSource.h:56
webrtc::MediaSourceInterface::SourceState state() const override
Indicates if this source is live.
Definition: VideoSource.h:68