| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef BASE_CAPTURER_H
- #define BASE_CAPTURER_H
- #include <Windows.h>
- extern "C" {
- #include <libavutil/frame.h>
- }
- class BaseCapturer
- {
- public:
- virtual ~BaseCapturer() = default;
- // 基本操作接口
- virtual bool Open(int width, int height) = 0;
- virtual void Close() = 0;
- virtual AVFrame* GetFrame() = 0;
- // 获取捕获器信息
- virtual int GetWidth() const = 0;
- virtual int GetHeight() const = 0;
- // 可选功能
- virtual void SetDrawCursor(bool isDrawCursor) {}
- virtual HDC GetHdc() { return nullptr; }
- virtual HDC GetHdc(int borderWidth, int borderHeight) { return nullptr; }
- };
- // 窗口捕获器基类
- class WindowCapturer : public BaseCapturer
- {
- public:
- virtual bool OpenWindow(HWND hwnd, int width, int height) = 0;
- // 实现基类方法
- bool Open(int width, int height) override { return false; }
- };
- // 屏幕捕获器基类
- class MonitorCapturer : public BaseCapturer
- {
- public:
- virtual bool OpenMonitor(int monitorIdx, int left, int top, int width, int height) = 0;
- // 实现基类方法
- bool Open(int width, int height) override { return false; }
- };
- #endif // BASE_CAPTURER_H
|