|
18 | 18 | #define JNI_WEBRTC_MEDIA_VIDEO_TRACK_DESKTOP_SOURCE_H_ |
19 | 19 |
|
20 | 20 | #include "api/video/i420_buffer.h" |
21 | | -#include "api/video/video_frame.h" |
22 | | -#include "api/video/video_sink_interface.h" |
23 | | -#include "media/base/video_adapter.h" |
24 | | -#include "media/base/video_broadcaster.h" |
25 | | -#include "pc/video_track_source.h" |
| 21 | +#include "media/base/adapted_video_track_source.h" |
26 | 22 | #include "modules/desktop_capture/desktop_capturer.h" |
27 | 23 | #include "rtc_base/thread.h" |
28 | 24 |
|
29 | 25 | namespace jni |
30 | 26 | { |
31 | | - class VideoTrackDesktopSource : public webrtc::VideoTrackSource, public webrtc::DesktopCapturer::Callback |
| 27 | + class VideoTrackDesktopSource : public rtc::AdaptedVideoTrackSource, public webrtc::DesktopCapturer::Callback |
32 | 28 | { |
33 | | - public: |
34 | | - VideoTrackDesktopSource(); |
35 | | - ~VideoTrackDesktopSource(); |
| 29 | + public: |
| 30 | + VideoTrackDesktopSource(); |
| 31 | + ~VideoTrackDesktopSource(); |
36 | 32 |
|
37 | | - void setSourceId(webrtc::DesktopCapturer::SourceId source, bool isWindow); |
38 | | - void setFrameRate(const uint16_t frameRate); |
39 | | - void setMaxFrameSize(webrtc::DesktopSize size); |
40 | | - void setFocusSelectedSource(bool focus); |
| 33 | + void setSourceId(webrtc::DesktopCapturer::SourceId source, bool isWindow); |
| 34 | + void setFrameRate(const uint16_t frameRate); |
| 35 | + void setMaxFrameSize(webrtc::DesktopSize size); |
| 36 | + void setFocusSelectedSource(bool focus); |
41 | 37 |
|
42 | | - void start(); |
43 | | - void stop(); |
44 | | - void terminate(); |
| 38 | + void start(); |
| 39 | + void stop(); |
| 40 | + void terminate(); |
45 | 41 |
|
46 | | - // VideoSourceInterface implementation. |
47 | | - void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame> * sink, const rtc::VideoSinkWants & wants) override; |
48 | | - void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame> * sink) override; |
| 42 | + // AdaptedVideoTrackSource implementation. |
| 43 | + virtual bool is_screencast() const override; |
| 44 | + virtual std::optional<bool> needs_denoising() const override; |
| 45 | + SourceState state() const override; |
| 46 | + bool remote() const override; |
49 | 47 |
|
50 | | - // VideoTrackSource implementation. |
51 | | - rtc::VideoSourceInterface<webrtc::VideoFrame>* source() override; |
| 48 | + // DesktopCapturer::Callback implementation. |
| 49 | + void OnCaptureResult(webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> frame) override; |
52 | 50 |
|
53 | | - // VideoTrackSourceInterface implementation. |
54 | | - bool GetStats(webrtc::VideoTrackSourceInterface::Stats * stats) override; |
55 | | - void ProcessConstraints(const webrtc::VideoTrackSourceConstraints & constraints) override; |
56 | | - virtual bool is_screencast() const override; |
57 | | - virtual std::optional<bool> needs_denoising() const override; |
58 | | - SourceState state() const override; |
59 | | - bool remote() const override; |
| 51 | + private: |
| 52 | + void capture(); |
| 53 | + void process(std::unique_ptr<webrtc::DesktopFrame>& frame); |
60 | 54 |
|
61 | | - // DesktopCapturer::Callback implementation. |
62 | | - void OnCaptureResult(webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> frame) override; |
| 55 | + private: |
| 56 | + uint16_t frameRate; |
| 57 | + bool isCapturing; |
| 58 | + bool focusSelectedSource; |
63 | 59 |
|
64 | | - protected: |
65 | | - bool AdaptFrame(int width, int height, int64_t time_us, int* out_width, int* out_height, int* crop_width, int* crop_height, int* crop_x, int* crop_y); |
66 | | - void OnFrameDropped(); |
| 60 | + webrtc::DesktopSize maxFrameSize; |
67 | 61 |
|
68 | | - private: |
69 | | - void capture(); |
70 | | - void process(std::unique_ptr<webrtc::DesktopFrame> & frame); |
71 | | - void updateVideoAdapter(); |
| 62 | + webrtc::MediaSourceInterface::SourceState sourceState; |
72 | 63 |
|
73 | | - private: |
74 | | - uint16_t frameRate; |
75 | | - bool isCapturing; |
76 | | - bool focusSelectedSource; |
| 64 | + webrtc::DesktopCapturer::SourceId sourceId; |
| 65 | + bool sourceIsWindow; |
77 | 66 |
|
78 | | - webrtc::DesktopSize maxFrameSize; |
| 67 | + std::unique_ptr<webrtc::DesktopFrame> lastFrame; |
79 | 68 |
|
80 | | - rtc::VideoBroadcaster broadcaster; |
81 | | - cricket::VideoAdapter videoAdapter; |
| 69 | + std::unique_ptr<rtc::Thread> captureThread; |
82 | 70 |
|
83 | | - webrtc::MediaSourceInterface::SourceState sourceState; |
84 | | - |
85 | | - webrtc::DesktopCapturer::SourceId sourceId; |
86 | | - bool sourceIsWindow; |
87 | | - |
88 | | - std::unique_ptr<webrtc::DesktopFrame> lastFrame; |
89 | | - |
90 | | - std::unique_ptr<rtc::Thread> captureThread; |
91 | | - |
92 | | - rtc::scoped_refptr<webrtc::I420Buffer> buffer; |
93 | | - |
94 | | - webrtc::Mutex statsMutex; |
95 | | - std::optional<Stats> stats RTC_GUARDED_BY(statsMutex); |
| 71 | + rtc::scoped_refptr<webrtc::I420Buffer> buffer; |
96 | 72 | }; |
97 | 73 | } |
98 | 74 |
|
|
0 commit comments