#ifndef VIDEOSERVICE_H #define VIDEOSERVICE_H #include "thread_queue.h" #include #include #include #include extern "C" { #include #include #include #include #include } void AVFormatContextDeleter(AVFormatContext *context); void AVCodecContextDeleter(AVCodecContext *context); class VideoService { private: std::unique_ptr> formatContext; std::unique_ptr> codecContext; ThreadQueue packetQueue; ThreadQueue frameQueue; ThreadQueue audioQueue; std::string_view filename; std::jthread decodePacketThread; std::jthread decodeFrameThread; int videoStreamIndex; int audioStreamIndex; int waitDelay = 50; unsigned int width; unsigned int height; std::stop_source stopSource; std::shared_ptr window; std::unique_ptr sprite; std::unique_ptr texture; public: VideoService(std::string_view filename, std::shared_ptr window); ~VideoService() { if (decodePacketThread.joinable()) { decodePacketThread.join(); } if (decodeFrameThread.joinable()) { decodeFrameThread.join(); } } void InitContext(); void Decode(); void PaintFrame(); void Play(); }; #endif