GdiCapturer.h 829 B

1234567891011121314151617181920212223242526272829303132333435
  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. void drawCursor(HDC hdc);
  17. HDC _srcHdc = nullptr;
  18. HDC _dstHdc = nullptr;
  19. HBITMAP _bitmap = nullptr;
  20. BITMAPINFO _bitmapInfo;
  21. int m_width = 0;
  22. int m_height = 0;
  23. AVFrame* _frame = nullptr;
  24. bool m_drawCursor = true;
  25. HWND m_hwnd = nullptr;
  26. };
  27. } // namespace video
  28. } // namespace avrecorder
  29. #endif // GDICAPTURER_H