48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#ifndef PROJECT_PLAYER_H
|
|
#define PROJECT_PLAYER_H
|
|
|
|
#include "ffcpp/MediaFile.h"
|
|
#include <memory>
|
|
#include <thread>
|
|
|
|
namespace ffcpp {
|
|
|
|
struct IVideoSink {
|
|
virtual AVPixelFormat getPixelFormat() const noexcept = 0;
|
|
virtual int getWidth() const noexcept = 0;
|
|
virtual int getHeight() 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;
|
|
};
|
|
|
|
enum class PlayerState {
|
|
Stopped,
|
|
Playing,
|
|
Paused
|
|
};
|
|
|
|
class Player {
|
|
private:
|
|
std::shared_ptr<IVideoSink> _vSink;
|
|
std::unique_ptr<MediaFile> _curMedia;
|
|
StreamPtr _aStream;
|
|
StreamPtr _vStream;
|
|
std::thread _decodeThread;
|
|
PlayerState _state;
|
|
|
|
public:
|
|
Player(std::shared_ptr<IVideoSink> vSink);
|
|
~Player();
|
|
|
|
void setMedia(std::string path);
|
|
void play();
|
|
|
|
private:
|
|
void decode();
|
|
};
|
|
|
|
}
|
|
|
|
#endif //PROJECT_PLAYER_H
|