2021-04-10 08:13:19 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
|
|
|
#include "api/video/video_frame.h"
|
2021-12-15 10:24:25 +03:00
|
|
|
#include "api/video/video_sink_interface.h"
|
2021-04-10 08:13:19 +03:00
|
|
|
#include "modules/video_capture/video_capture.h"
|
2021-12-15 10:24:25 +03:00
|
|
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
2021-05-08 07:47:40 +03:00
|
|
|
#include "video_engine/desktop_capture_impl.h"
|
2021-04-10 08:13:19 +03:00
|
|
|
|
|
|
|
class nsIWidget;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace widget {
|
|
|
|
class HeadlessWidget;
|
|
|
|
}
|
|
|
|
|
2021-05-08 07:47:40 +03:00
|
|
|
class HeadlessWindowCapturer : public webrtc::VideoCaptureModuleEx {
|
2021-04-10 08:13:19 +03:00
|
|
|
public:
|
2021-05-08 07:47:40 +03:00
|
|
|
static rtc::scoped_refptr<webrtc::VideoCaptureModuleEx> Create(mozilla::widget::HeadlessWidget*);
|
2021-04-10 08:13:19 +03:00
|
|
|
|
|
|
|
void RegisterCaptureDataCallback(
|
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* dataCallback) override;
|
|
|
|
void DeRegisterCaptureDataCallback(
|
|
|
|
rtc::VideoSinkInterface<webrtc::VideoFrame>* dataCallback) override;
|
|
|
|
int32_t StopCaptureIfAllClientsClose() override;
|
|
|
|
|
2021-05-08 07:47:40 +03:00
|
|
|
void RegisterRawFrameCallback(webrtc::RawFrameCallback* rawFrameCallback) override;
|
|
|
|
void DeRegisterRawFrameCallback(webrtc::RawFrameCallback* rawFrameCallback) override;
|
|
|
|
|
2021-04-10 08:13:19 +03:00
|
|
|
int32_t SetCaptureRotation(webrtc::VideoRotation) override { return -1; }
|
|
|
|
bool SetApplyRotation(bool) override { return false; }
|
|
|
|
bool GetApplyRotation() override { return true; }
|
|
|
|
|
|
|
|
const char* CurrentDeviceName() const override { return "Headless window"; }
|
|
|
|
|
|
|
|
// Platform dependent
|
|
|
|
int32_t StartCapture(const webrtc::VideoCaptureCapability& capability) override;
|
|
|
|
bool FocusOnSelectedSource() override { return false; }
|
|
|
|
int32_t StopCapture() override;
|
|
|
|
bool CaptureStarted() override;
|
|
|
|
int32_t CaptureSettings(webrtc::VideoCaptureCapability& settings) override {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
HeadlessWindowCapturer(mozilla::widget::HeadlessWidget*);
|
|
|
|
~HeadlessWindowCapturer() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void NotifyFrameCaptured(const webrtc::VideoFrame& frame);
|
|
|
|
|
|
|
|
mozilla::widget::HeadlessWidget* mWindow = nullptr;
|
2021-12-15 10:24:25 +03:00
|
|
|
rtc::RecursiveCriticalSection _callBackCs;
|
2021-04-10 08:13:19 +03:00
|
|
|
std::set<rtc::VideoSinkInterface<webrtc::VideoFrame>*> _dataCallBacks;
|
2021-05-08 07:47:40 +03:00
|
|
|
std::set<webrtc::RawFrameCallback*> _rawFrameCallbacks;
|
2021-04-10 08:13:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|