base_capturer.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef BASE_CAPTURER_H
  2. #define BASE_CAPTURER_H
  3. #include <Windows.h>
  4. extern "C" {
  5. #include <libavutil/frame.h>
  6. }
  7. class BaseCapturer
  8. {
  9. public:
  10. virtual ~BaseCapturer() = default;
  11. // 基本操作接口
  12. virtual bool Open(int width, int height) = 0;
  13. virtual void Close() = 0;
  14. virtual AVFrame* GetFrame() = 0;
  15. // 获取捕获器信息
  16. virtual int GetWidth() const = 0;
  17. virtual int GetHeight() const = 0;
  18. // 可选功能
  19. virtual void SetDrawCursor(bool isDrawCursor) {}
  20. virtual HDC GetHdc() { return nullptr; }
  21. virtual HDC GetHdc(int borderWidth, int borderHeight) { return nullptr; }
  22. };
  23. // 窗口捕获器基类
  24. class WindowCapturer : public BaseCapturer
  25. {
  26. public:
  27. virtual bool OpenWindow(HWND hwnd, int width, int height) = 0;
  28. // 实现基类方法
  29. bool Open(int width, int height) override { return false; }
  30. };
  31. // 屏幕捕获器基类
  32. class MonitorCapturer : public BaseCapturer
  33. {
  34. public:
  35. virtual bool OpenMonitor(int monitorIdx, int left, int top, int width, int height) = 0;
  36. // 实现基类方法
  37. bool Open(int width, int height) override { return false; }
  38. };
  39. #endif // BASE_CAPTURER_H