VideoCaptureManager.h 878 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef VIDEOCAPTUREMANAGER_H
  2. #define VIDEOCAPTUREMANAGER_H
  3. #include "IVideoCapturer.h"
  4. #include "VideoCapturerFactory.h"
  5. #include <memory>
  6. namespace avrecorder {
  7. namespace video {
  8. class VideoCaptureManager {
  9. public:
  10. bool open(const CaptureTarget& target, CaptureMethod method, int width, int height) {
  11. m_capturer = VideoCapturerFactory::create(method);
  12. if (!m_capturer) return false;
  13. return m_capturer->open(target, width, height);
  14. }
  15. void close() {
  16. if (m_capturer) m_capturer->close();
  17. }
  18. AVFrame* getFrame() {
  19. return m_capturer ? m_capturer->getFrame() : nullptr;
  20. }
  21. void setDrawCursor(bool enable) {
  22. if (m_capturer) m_capturer->setDrawCursor(enable);
  23. }
  24. private:
  25. std::unique_ptr<IVideoCapturer> m_capturer;
  26. };
  27. } // namespace video
  28. } // namespace avrecorder
  29. #endif // VIDEOCAPTUREMANAGER_H