#ifndef PLAYTHREAD_H
#define PLAYTHREAD_H

#include <QThread>
#include <QImage>

#include "videoplay.h"

#include <atomic>

class PlayThread : public QThread
{
    Q_OBJECT
public:
    PlayThread(QObject* parent = nullptr);

    void setMedia(HMedia media);

    void setPlayState(int state);

signals:
    void sendFrame(QImage frame);

protected:
    void run();

private:
    bool yuv420ToRgb(unsigned char *pYUV, unsigned char *pRGB, int width, int height, bool rgbState);


private:
    VideoPlay videoPlay;
    HMedia mMedia;

    HFrame mFrame;

    // -1 停止， 0暂停， 1播放
    std::atomic<int> mPlayState;
};

#endif // PLAYTHREAD_H
