1.调通所有与服务器HTTP连接的接口 2.更新图语License从服务器查询和U盘获取后上报,前板可直接使用产测工具写入License 3.优化接收到前板的H264解码后出现视频卡的问题 4.更新从前板取图后旋转 5.增加ffmpeg解码的视频分辨率获取
This commit is contained in:
@@ -8,7 +8,7 @@ ClientHandler::ClientHandler(QTcpSocket* socket,
|
||||
QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
|
||||
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig,
|
||||
QJsonArray backBoardDevInfoJson,
|
||||
QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
|
||||
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent)
|
||||
: QObject(parent), socket(socket),
|
||||
frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
|
||||
@@ -16,7 +16,7 @@ ClientHandler::ClientHandler(QTcpSocket* socket,
|
||||
frontBoardLicenseJson(frontBoardLicenseJson),
|
||||
backBoardOneClickTest(backBoardOneClickTest), backBoardTest(backBoardTest),
|
||||
backBoardFuncConfig(backBoardFuncConfig), backBoardDevInfoJson(backBoardDevInfoJson),
|
||||
getPicJson(getPicJson), getVideoJson(getVideoJson),
|
||||
backBoardUuidJson(backBoardUuidJson), getPicJson(getPicJson), getVideoJson(getVideoJson),
|
||||
currentItemIndex(0), clientId(clientId),
|
||||
isManualSend(false), isSingleSend(false), isClickedSend(false), size(0),
|
||||
isFirstDataReceived(true), processDataFunction(nullptr),
|
||||
@@ -35,15 +35,17 @@ ClientHandler::~ClientHandler() {
|
||||
qDebug() << "ClientHandler destroyed for clientId:" << clientId;
|
||||
}
|
||||
|
||||
void ClientHandler::startReadVideoDataTimer()
|
||||
void ClientHandler::startReadVideoDataTimer(int client_Id)
|
||||
{
|
||||
emit startReadTimer(clientId);
|
||||
//emit startReadTimer(clientId);
|
||||
emit startReadTimer(client_Id);
|
||||
//qDebug() << "------ startClientReadTimer clientId:" << clientId;
|
||||
}
|
||||
|
||||
void ClientHandler::stopReadVideoDataTimer()
|
||||
void ClientHandler::stopReadVideoDataTimer(int client_Id)
|
||||
{
|
||||
emit stopReadTimer(clientId);
|
||||
//emit stopReadTimer(clientId);
|
||||
emit stopReadTimer(client_Id);
|
||||
}
|
||||
|
||||
qint64 getFreeMemory() {
|
||||
@@ -121,18 +123,30 @@ void ClientHandler::sendDataToClient(const QByteArray& data)
|
||||
|
||||
void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString& itemType)
|
||||
{
|
||||
currentJson = jsonArray;
|
||||
currentJsonItem = itemIndex;
|
||||
QMutexLocker locker(&mutex);
|
||||
if (itemType == "License") {
|
||||
|
||||
}
|
||||
isSingleSend = true;
|
||||
isClickedSend = true;
|
||||
isRecvImgData = false;
|
||||
if (itemType == "handleVideo") {
|
||||
if(itemIndex == 0)
|
||||
isRecvVideoData = 1;
|
||||
else
|
||||
isRecvVideoData = 0;
|
||||
startReadVideoDataTimer();
|
||||
if (itemIndex == 0) {
|
||||
qDebug() << "0 itemIndex: " << itemIndex;
|
||||
isSingleSend = false;
|
||||
isClickedSend = false;
|
||||
}
|
||||
else {
|
||||
qDebug() << "!0 itemIndex: " << itemIndex;
|
||||
stopReadVideoDataTimer(preVideoClientId);
|
||||
}
|
||||
}
|
||||
if (itemType == "getPic") {
|
||||
isSingleSend = false;
|
||||
isClickedSend = false;
|
||||
isRecvImgData = true;
|
||||
}
|
||||
qDebug() << "itemIndex:" << itemIndex;
|
||||
qDebug() << "jsonArray.size():" << jsonArray.size();
|
||||
@@ -197,17 +211,7 @@ void ClientHandler::sendLicenseItem(int itemIndex, const QString text)
|
||||
qDebug() << "Invalid itemIndex";
|
||||
return;
|
||||
}
|
||||
QJsonObject item = frontBoardLicenseJson[itemIndex].toObject();
|
||||
QString label = item["lable"].toString();
|
||||
if (label == "write_license") {
|
||||
LicenseConfirmWindow dialog("你确定要发送此授权项吗?");
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
sendJsonItem(frontBoardLicenseJson, itemIndex, text, "License");
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendJsonItem(frontBoardLicenseJson, itemIndex, text, "License");
|
||||
}
|
||||
sendJsonItem(frontBoardLicenseJson, itemIndex, text, "License");
|
||||
}
|
||||
|
||||
void ClientHandler::sendUuidItem(int itemIndex, const QString text)
|
||||
@@ -333,14 +337,6 @@ void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemInd
|
||||
}
|
||||
}
|
||||
|
||||
//void ClientHandler::sendLicenseItem()
|
||||
//{
|
||||
// if (currentLicenseIndex < frontBoardLicenseJson.size()) {
|
||||
//
|
||||
// currentLicenseIndex ++;
|
||||
// }
|
||||
//}
|
||||
|
||||
void ClientHandler::sendDevInfoItem()
|
||||
{
|
||||
// 前板
|
||||
@@ -371,6 +367,9 @@ void ClientHandler::sendNextItem()
|
||||
isClickedSend = true;
|
||||
qDebug() << "------> locker(&mutex) :" << itemsProcessedCount;
|
||||
if (currentItemIndex < frontBoardOneClickTest.size()) {
|
||||
currentJson = frontBoardOneClickTest;
|
||||
currentJsonItem = currentItemIndex;
|
||||
|
||||
currentItem = frontBoardOneClickTest[currentItemIndex].toObject();
|
||||
QString itemData = QJsonDocument(currentItem).toJson();
|
||||
//qDebug() << "Sending item index:" << currentItemIndex << "data:" << itemData;
|
||||
@@ -411,19 +410,29 @@ void ClientHandler::sendNextItem()
|
||||
}
|
||||
|
||||
void ClientHandler::RNDISClient1Data(QByteArray& data) {
|
||||
qDebug() << " RNDISClient1Data size:" << data.size();
|
||||
//qDebug() << " RNDISClient1Data size:" << data.size();
|
||||
isRecvVideoData = false;
|
||||
isStartVideo = false;
|
||||
}
|
||||
|
||||
void ClientHandler::RNDISClient2Data(QByteArray& data) {
|
||||
qDebug() << " RNDISClient2Data size:" << data.size();
|
||||
//qDebug() << " RNDISClient2Data size:" << data.size();
|
||||
isRecvVideoData = true;
|
||||
isStartVideo = true;
|
||||
//qDebug() << " isRecvVideoData:" << isRecvVideoData;
|
||||
}
|
||||
|
||||
void ClientHandler::RNDISClient3Data(QByteArray& data) {
|
||||
qDebug() << " RNDISClient3Data size:" << data.size();
|
||||
//qDebug() << " RNDISClient3Data size:" << data.size();
|
||||
isRecvVideoData = false;
|
||||
isStartVideo = false;
|
||||
}
|
||||
|
||||
void ClientHandler::RNDISClient4Data(QByteArray& data) {
|
||||
//qDebug() << " RNDISClient4Data size:" << data.size();
|
||||
//qDebug() << " RNDISClient4Data size:" << data.size();
|
||||
isRecvVideoData = false;
|
||||
isStartVideo = false;
|
||||
}
|
||||
|
||||
bool ClientHandler::RNDISFirstData(QByteArray& data) {
|
||||
@@ -431,9 +440,9 @@ bool ClientHandler::RNDISFirstData(QByteArray& data) {
|
||||
//int clientType = data.at(0); // 根据实际数据格式提取标识
|
||||
bool ret = true;
|
||||
unsigned char clientType = static_cast<unsigned char>(data[10]);
|
||||
qDebug() << " clientType :" << clientType;
|
||||
//qDebug() << " clientType :" << clientType;
|
||||
QByteArray tmpdata = data.left(11);
|
||||
qDebug() << " tmpdata :" << tmpdata.toHex().data();
|
||||
//qDebug() << " clientType :" << clientType << " tmpdata :" << tmpdata.toHex().data();
|
||||
switch (clientType) {
|
||||
case 0x01:
|
||||
processDataFunction = &ClientHandler::RNDISClient1Data;
|
||||
@@ -441,12 +450,15 @@ bool ClientHandler::RNDISFirstData(QByteArray& data) {
|
||||
socket->setReadBufferSize(20 * 1024);
|
||||
break;
|
||||
case 0x02:
|
||||
qDebug() << " clientId :" << clientId;
|
||||
processDataFunction = &ClientHandler::RNDISClient2Data;
|
||||
socket->setReadBufferSize(100 * 1024);
|
||||
data = data.mid(11);
|
||||
(this->*processDataFunction)(data);
|
||||
setThreadPriority(QThread::HighPriority);
|
||||
preVideoClientId = clientId;
|
||||
//qDebug() << " clientType :" << clientType << " preVideoClientId :" << preVideoClientId << " tmpdata :" << tmpdata.toHex().data();
|
||||
startReadVideoDataTimer(preVideoClientId);
|
||||
break;
|
||||
case 0x03:
|
||||
processDataFunction = &ClientHandler::RNDISClient3Data;
|
||||
@@ -503,12 +515,13 @@ void ClientHandler::setThreadPriority(QThread::Priority priority) {
|
||||
void ClientHandler::onDataReceived()
|
||||
{
|
||||
// 接收其他数据 添加区分 视频与其他数据 的标志位
|
||||
qDebug() << "isRecvVideoData:" << isRecvVideoData;
|
||||
qDebug() << "isPowerOnSend:" << isPowerOnSend;
|
||||
qDebug() << "isClickedSend:" << isClickedSend;
|
||||
qDebug() << "isSingleSend:" << isSingleSend;
|
||||
//qDebug() << "isRecvVideoData:" << isRecvVideoData;
|
||||
//qDebug() << "isPowerOnSend:" << isPowerOnSend;
|
||||
//qDebug() << "isClickedSend:" << isClickedSend;
|
||||
//qDebug() << "isSingleSend:" << isSingleSend;
|
||||
//qDebug() << "isRecvImgData:" << isRecvImgData;
|
||||
if (!isRecvVideoData &&
|
||||
(isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
|
||||
(isRecvImgData || isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
|
||||
QByteArray allData;
|
||||
while (socket->bytesAvailable() > 0) {
|
||||
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
||||
@@ -527,7 +540,7 @@ void ClientHandler::onDataReceived()
|
||||
}
|
||||
if (!allData.isEmpty()) {
|
||||
//emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
|
||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "");
|
||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "", currentJson, currentJsonItem);
|
||||
if (!isSingleSend && !isPowerOnSend) {
|
||||
currentItemIndex ++;
|
||||
itemsProcessedCount ++;
|
||||
@@ -566,11 +579,19 @@ void ClientHandler::onDataReceived()
|
||||
// 接收视频流数据 isRecvVideoData 置 0
|
||||
else if (isRecvVideoData && (!dataProcessingActive)) {
|
||||
dataProcessingActive = true;
|
||||
isRecvVideoData = false;
|
||||
if (!isStartVideo) {
|
||||
isRecvVideoData = false;
|
||||
}
|
||||
QTimer::singleShot(0, this, &ClientHandler::processPendingData);
|
||||
}
|
||||
else {
|
||||
else if(!isRecvVideoData && !isRecvImgData){
|
||||
if (preVideoClientId == clientId) {
|
||||
qDebug() << "-----------------" << preVideoClientId << "isRecvVideoData:" << isRecvVideoData;
|
||||
}
|
||||
|
||||
socket->readAll();
|
||||
//QByteArray data = socket->readAll();
|
||||
//qDebug() << "Received data:" << data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,6 +612,7 @@ void ClientHandler::processPendingData()
|
||||
|
||||
if (bytesRead > 0) {
|
||||
buffer.resize(bytesRead);
|
||||
//qDebug() << "buffer.data():" << buffer.data();
|
||||
allData.append(buffer);
|
||||
qint64 bytesAvailableAfter = socket->bytesAvailable();
|
||||
/*qDebug() << "--1--Received data size:" << buffer.size() << "clientId:" << clientId
|
||||
@@ -626,7 +648,7 @@ void ClientHandler::processPendingData()
|
||||
}
|
||||
|
||||
if (!allData.isEmpty()) {
|
||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
|
||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "", currentJson, currentJsonItem);
|
||||
}
|
||||
|
||||
// 如果还有数据需要处理,继续调度处理任务
|
||||
@@ -668,7 +690,7 @@ void ClientHandler::onTimeout()
|
||||
//QString itemData = currentItem.value("data").toString();
|
||||
//emit statusUpdated(socket->peerAddress().toString(), currentItemIndex, false, itemData);
|
||||
emit statusUpdated(getClientAddress(), currentItemIndex + 1, currentFuncItemIndex + 1,
|
||||
false, getCurrentItemLable(), getCurrentFuncItemLable());
|
||||
false, getCurrentItemLable(), getCurrentFuncItemLable(), currentJson, currentJsonItem);
|
||||
if (!isSingleSend && !isPowerOnSend) {
|
||||
currentItemIndex ++;
|
||||
itemsProcessedCount ++;
|
||||
|
||||
@@ -32,13 +32,14 @@ public:
|
||||
explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest,
|
||||
QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig, QJsonArray backBoardDevInfoJson,
|
||||
QJsonArray getPicJson, QJsonArray getVideoJson,
|
||||
QJsonArray backBoardUuidJson, QJsonArray getPicJson, QJsonArray getVideoJson,
|
||||
int clientId, QObject* parent = nullptr);
|
||||
|
||||
~ClientHandler();
|
||||
|
||||
int preVideoClientId = 0;
|
||||
int controlClientId = 0;
|
||||
void sendDevInfoItem();
|
||||
|
||||
//int preVideoClientId = 0;
|
||||
bool isData_Stuck() const;
|
||||
//static int pre_H264_clientId; // 预览H264的客户端ID
|
||||
QTcpSocket* getSocket() const { return socket; }
|
||||
@@ -87,13 +88,15 @@ public:
|
||||
signals:
|
||||
// 数据接收信号
|
||||
void dataReceived(const QString& client, const QByteArray& data, unsigned char msg_id, int currentRecvItemIndex,
|
||||
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
|
||||
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData,
|
||||
const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
void handleData(QByteArray& data);
|
||||
// 数据发送信号
|
||||
void sendData(const QByteArray& data);
|
||||
// 状态更新信号
|
||||
void statusUpdated(const QString& client, int itemIndex, int funcItemIndex,
|
||||
bool success, const QString& itemData, const QString& funcItemData);
|
||||
bool success, const QString& itemData, const QString& funcItemData,
|
||||
const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
// 客户端断开连接信号
|
||||
void clientDisconnected(ClientHandler* handler);
|
||||
// json文件配置项发送完毕
|
||||
@@ -116,8 +119,8 @@ public slots:
|
||||
void onTimeoutRead();
|
||||
void checkConnectionStatus(); // 定期检查连接状态
|
||||
void processPendingData();
|
||||
void startReadVideoDataTimer();
|
||||
void stopReadVideoDataTimer();
|
||||
void startReadVideoDataTimer(int client_Id);
|
||||
void stopReadVideoDataTimer(int client_Id);
|
||||
|
||||
private:
|
||||
QTcpSocket* socket; // 客户端 socket
|
||||
@@ -130,16 +133,19 @@ private:
|
||||
QJsonArray backBoardTest; // 后板单项测试 JSON
|
||||
QJsonArray backBoardFuncConfig; // 后板功能配置参数 JSON
|
||||
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
||||
QJsonArray backBoardUuidJson; // 后板UUID和SN参数 JSON
|
||||
QJsonArray jsonConfig; // 测试区 JSON 配置
|
||||
QJsonArray funcJsonConfig; // 功能区 JSON 配置
|
||||
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
|
||||
QJsonArray getPicJson; // 发送取图指令 JSON 配置
|
||||
QJsonArray getVideoJson; // 发送拉视频指令 JSON 配置
|
||||
QJsonArray currentJson; // 当前处理的json
|
||||
int currentJsonItem = -1;
|
||||
int currentItemIndex; // 当前处理的测试 JSON 项目索引
|
||||
int currentFuncItemIndex; // 当前处理的功能 JSON 项目索引
|
||||
int clientId; // 新增的客户端编号
|
||||
int preVideoClientId = 0;
|
||||
int controlClientId = 1;
|
||||
|
||||
|
||||
int itemsProcessedCount; // 跟踪处理项目的数量
|
||||
QJsonObject currentItem; // 测试 json文件中当前发送的项
|
||||
QJsonObject currentFuncItem; // 功能 json文件中当前发送的项
|
||||
@@ -148,6 +154,8 @@ private:
|
||||
bool isSingleSend; // 单独点击按键发送的标志
|
||||
bool isClickedSend; // 点击按键发送的标志,没有点击不接收数据
|
||||
bool isRecvVideoData;
|
||||
bool isRecvImgData = false;
|
||||
bool isStartVideo = false;
|
||||
bool isPowerOnSend = false; // 上电发送设备信息
|
||||
//QTimer* timeoutTimer; // 超时定时器
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ HttpClient::HttpClient(QObject* parent)
|
||||
|
||||
void HttpClient::sendPostRequest(const QNetworkRequest& request, const QByteArray& jsonData)
|
||||
{
|
||||
qDebug() << "jsonData" << jsonData.data();
|
||||
qDebug() << "jsonData" << jsonData;
|
||||
networkManager->post(request, jsonData);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user