DxgiCapturer.cpp 864 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "DxgiCapturer.h"
  2. #include <cassert>
  3. namespace avrecorder {
  4. namespace video {
  5. DxgiCapturer::DxgiCapturer() : d(nullptr) {}
  6. DxgiCapturer::~DxgiCapturer() { close(); }
  7. bool DxgiCapturer::open(const CaptureTarget& target, int width, int height) {
  8. #ifdef PLATFORM_WINDOWS
  9. close();
  10. if (target.type != CaptureTargetType::Monitor) return false;
  11. // 这里只做简单示例,实际应根据 monitorIdx 获取坐标
  12. m_left = 0; m_top = 0; m_width = width; m_height = height;
  13. // TODO: 初始化 d,创建 D3D 设备等
  14. return true;
  15. #else
  16. return false;
  17. #endif
  18. }
  19. void DxgiCapturer::close() {
  20. #ifdef PLATFORM_WINDOWS
  21. // TODO: 释放 d
  22. #endif
  23. }
  24. AVFrame* DxgiCapturer::getFrame() {
  25. #ifdef PLATFORM_WINDOWS
  26. // TODO: 获取帧
  27. return nullptr;
  28. #else
  29. return nullptr;
  30. #endif
  31. }
  32. } // namespace video
  33. } // namespace avrecorder