#ifndef __VIDEOPLAYER_H__ #define __VIDEOPLAYER_H__ #include #include #include class QImage; struct AVFormatContext; class VideoPlayer { public: using FrameCallback = std::function; using ErrorCallback = std::function; VideoPlayer(); void setFrameCallback(FrameCallback &&callback); void setErrorCallback(ErrorCallback &&callback); ~VideoPlayer(); bool open(const std::string &deviceName); void close(); protected: void run(); private: AVFormatContext *m_formatContext = nullptr; bool m_exit = true; std::thread m_thread; FrameCallback m_callback; ErrorCallback m_errorCallback; }; #endif // __VIDEOPLAYER_H__