ivideocapturer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef IVIDEOCAPURER_H
  2. #define IVIDEOCAPURER_H
  3. #include "basic/frame.h"
  4. #include <cstdint>
  5. #include <memory>
  6. #include "qwindowdefs_win.h"
  7. namespace avrecorder {
  8. namespace video {
  9. // 平台宏定义
  10. #if defined(_WIN32)
  11. #define PLATFORM_WINDOWS
  12. #elif defined(__APPLE__)
  13. #define PLATFORM_MACOS
  14. #elif defined(__linux__)
  15. #define PLATFORM_LINUX
  16. #endif
  17. // 捕获目标类型
  18. enum class CaptureTargetType {
  19. Window,
  20. Monitor,
  21. // 预留更多类型,如 macOS 的 CGWindowID、X11 Window 等
  22. };
  23. // 捕获目标描述
  24. struct CaptureTarget {
  25. CaptureTargetType type;
  26. union {
  27. #ifdef PLATFORM_WINDOWS
  28. HWND hwnd;
  29. int monitorIdx;
  30. #endif
  31. #ifdef PLATFORM_MACOS
  32. uint32_t cgWindowId;
  33. uint32_t displayId;
  34. #endif
  35. #ifdef PLATFORM_LINUX
  36. unsigned long x11Window;
  37. int x11Screen;
  38. #endif
  39. };
  40. };
  41. // 捕获方式
  42. enum class CaptureMethod {
  43. GDI,
  44. DXGI,
  45. WGC,
  46. // 预留更多方式,如 macOS/Linux
  47. };
  48. // 统一视频捕获接口
  49. class IVideoCapturer {
  50. public:
  51. virtual ~IVideoCapturer() = default;
  52. virtual bool open(const CaptureTarget& target, int width, int height) = 0;
  53. virtual void close() = 0;
  54. virtual AVFrame* getFrame() = 0;
  55. virtual void setDrawCursor(bool enable) = 0;
  56. };
  57. } // namespace video
  58. } // namespace avrecorder
  59. #endif // IVIDEOCAPURER_H