#ifndef PROJECT_PLAYER_H #define PROJECT_PLAYER_H #include "ffcpp/MediaFile.h" #include "ffcpp/Scaler.h" #include "TSQueue.h" #include #include #include #include #include namespace ffcpp { struct IVideoSink { virtual AVPixelFormat getPixelFormat() const noexcept = 0; virtual void drawFrame(void* pixelsData, int pitch) = 0; virtual void drawPlanarYUVFrame(const void *yPlane, const void *uPlane, const void *vPlane, int yPitch, int uPitch, int vPitch) = 0; }; struct IAudioSink { virtual void setPauseCallback(std::function callback) = 0; virtual void setAudioDataCallback(std::function callback) = 0; }; enum class PlayerState { Shutdown, Stopped, Playing, Paused }; class Player { private: std::shared_ptr _vSink; std::unique_ptr _curMedia; StreamPtr _aStream; StreamPtr _vStream; ScalerPtr _scaler; PlayerState _state; TSQueue _decodedFrames; std::thread _decodeThread; std::thread _vPlayThread; std::mutex _mutex; std::condition_variable _stateCond; public: Player(std::shared_ptr vSink); ~Player(); void setMedia(std::string path); void setVideoSize(size_t width, size_t height); void play(); private: void decode(); void displayFrames(); }; } #endif //PROJECT_PLAYER_H