GdiCapturer.h 797 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef GDICAPTURER_H
  2. #define GDICAPTURER_H
  3. #include "IVideoCapturer.h"
  4. #include <Windows.h>
  5. namespace avrecorder {
  6. namespace video {
  7. class GdiCapturer : public IVideoCapturer {
  8. public:
  9. GdiCapturer() = default;
  10. ~GdiCapturer() override { close(); }
  11. bool open(const CaptureTarget& target, int width, int height) override;
  12. void close() override;
  13. AVFrame* getFrame() override;
  14. void setDrawCursor(bool enable) override { m_drawCursor = enable; }
  15. private:
  16. HDC _srcHdc = nullptr;
  17. HDC _dstHdc = nullptr;
  18. HBITMAP _bitmap = nullptr;
  19. BITMAPINFO _bitmapInfo;
  20. int m_width = 0;
  21. int m_height = 0;
  22. AVFrame* _frame = nullptr;
  23. bool m_drawCursor = true;
  24. HWND m_hwnd = nullptr;
  25. };
  26. } // namespace video
  27. } // namespace avrecorder
  28. #endif // GDICAPTURER_H