Files
capture/PlayThread.h
T
2024-06-20 10:57:08 +07:00

145 lines
2.4 KiB
C++

#ifndef PLAYTHREAD_H
#define PLAYTHREAD_H
#include <QObject>
#include "QRunnable"
#include "QDebug"
#include "QThread"
#include "QElapsedTimer"
#include "QtMath"
#include "QThreadPool"
#include "QFile"
#include "QDateTime"
#include "QDataStream"
#include "QHostAddress"
#include "ParsePack.h"
#include "QThread"
#include "QWaitCondition"
#include "QMutex"
#include "Config/Config.h"
#include "QTimer"
#include "PerformanceTimer.h"
class PlayThread : public QObject, public QRunnable
{
Q_OBJECT
public:
explicit PlayThread(QObject *parent = nullptr);
~PlayThread();
void run() override;
qint64 time_tick = 0;
int64_t newpos = 0;
int CurrentProgress = 0;
uint8_t play_state = 0;
bool play_start = false;
float times = 1;//倍数
public slots:
void resetData();
void playData(QList<QByteArray> data, QMap<quint16, QList<QByteArray> > data2);
void appendPlayData(quint32 ip, quint16 port, QByteArray data);
void setNewPos(int64_t pos)
{
if(pos <= size())
{
newpos = pos;
//newpos 最后会比size还大
isChangedPos = true;
//qDebug() << newpos;
}
}
void setPlayState(uint8_t flag)
{
play_state = flag;
play_start = flag;
currentTick = QDateTime::currentMSecsSinceEpoch();
qDebug() << "play state" << flag;
}
void resetState(bool flag)
{
if(flag)
{
play_state = 0;
isChangedPos = false;
time_tick = 0;
}
}
void setplay_control(bool flag)
{
play_control = flag;
}
void setTimes(qreal t)
{
if((t > 0) && (t < 100))
{
times = t;
}
}
int size()
{
return FrameData.size();
}
signals:
void progress(uint64_t all,uint64_t current);
void transmit(QHostAddress ip,quint16 port,QByteArray data);
void status(quint32 stat);
void delaytime(qint64 length,qint64 current);
void timestamp(QDateTime time);
private:
QByteArray datagram;
Packer_t packer;
Parser_t parser;
QList<QByteArray> FrameData;
QMap<quint16,QList<QByteArray>> port_data;
bool isChangedPos = false;
bool play_control = true;
qint64 currentTick = 0;
uint32_t frame_count = 0;
bool istimeout = false;
};
#endif // PLAYTHREAD_H