78 lines
2.6 KiB
C++
78 lines
2.6 KiB
C++
// RecvDataHandler.h
|
|
#ifndef RECVDATAHANDLER_H
|
|
#define RECVDATAHANDLER_H
|
|
|
|
#include <QObject>
|
|
#include <QByteArray>
|
|
#include <QLabel>
|
|
#include <QGroupBox>
|
|
#include <QJsonDocument>
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
#include <QPixmap>
|
|
#include <QBuffer>
|
|
#include <QImage>
|
|
#include <QVBoxLayout>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QThread>
|
|
#include <QElapsedTimer>
|
|
#include <QLineEdit>
|
|
#include <QTextEdit>
|
|
|
|
#include "../Media/Media.h"
|
|
#include "../Media/VideoDecoder/FFmpegDecoder.h"
|
|
#include "../LicenseGenerate/LicenseGenerate.h"
|
|
#include "MsgTpye.h"
|
|
|
|
#define YUV420 1
|
|
#define YUV422 2
|
|
|
|
class DataHandler : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel,
|
|
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits, QObject* parent = nullptr);
|
|
~DataHandler();
|
|
|
|
public slots:
|
|
void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
|
|
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
|
|
|
|
signals:
|
|
void statusUpdated(const QString& clientAddress, int currentItemIndex, int currentFuncItemIndex,
|
|
bool success, const QString& currentItemLabel, const QString& currentFuncItemLabel);
|
|
|
|
private:
|
|
QLabel* leftLens_m_imageLabel;
|
|
QLabel* rightLens_m_imageLabel;
|
|
QLabel* videoLabel;
|
|
QTextEdit* licenseHwInfoEdit;
|
|
QByteArray allRecvData; // 完整的一帧数据
|
|
int remain = 0;
|
|
int start_run = 0;
|
|
long dataLen = 0;
|
|
FFmpegDecoder* ffmpegDecoder;
|
|
QByteArray *buffer;
|
|
QHash<QString, unsigned char> clientLastMsgId;
|
|
QMap<QString, QLineEdit*>* devInfoLineEdits;
|
|
QMap<int, QString> msgIdToCmdMap;
|
|
|
|
// 如果接收十六进制数据,转为二进制
|
|
QByteArray hexStringToByteArray(const QString& hexString);
|
|
void showVideo(const QString& client, const QByteArray& valData);
|
|
void clearAllRecvData();
|
|
void handleCmd(int msg_id, const QString& client, QByteArray actual_data);
|
|
void handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data);
|
|
void handleDevInfo(int msg_id, const QString& client, QByteArray actual_data);
|
|
void handleBackCmd(int msg_id, const QString& client, QByteArray actual_data);
|
|
void initializeMsgIdToCmdMap();
|
|
void updateLineEdit(int msg_id, const QByteArray& actual_data);
|
|
};
|
|
|
|
#endif // DATAHANDLER_H
|
|
|
|
|