1.增加取图后默认保存图像,YUV和JPG各保存一张; 2.修复出现QTcpSocket对象的问题和QTcpSocket对象导致的线程安全问题
|
@ -154,7 +154,10 @@ QImage convertYUV420ToQImage(const QByteArray& yuv420Data, int width, int height
|
|||
void DataHandler::showPic(QSize labelSize, int lens_n,
|
||||
int width, int height, int format, const QByteArray* valData)
|
||||
{
|
||||
//QByteArray yuvData = valData.mid(6);
|
||||
qDebug() << "lens_n = " << lens_n;
|
||||
qDebug() << "format = " << format;
|
||||
qDebug() << "width = " << width;
|
||||
qDebug() << "height = " << height;
|
||||
qDebug() << "yuvData size = " << valData->size();
|
||||
|
||||
QImage image;
|
||||
|
@ -169,12 +172,10 @@ void DataHandler::showPic(QSize labelSize, int lens_n,
|
|||
return;
|
||||
}
|
||||
|
||||
// 旋转图像90度
|
||||
QTransform transform;
|
||||
transform.rotate(90); // 可以调整旋转角度
|
||||
QImage rotatedImage = image.transformed(transform);
|
||||
|
||||
QImage scaledImage = rotatedImage.scaled(labelSize, Qt::KeepAspectRatio);
|
||||
QImage scaledImage = rotatedImage.scaled(labelSize, Qt::KeepAspectRatio);
|
||||
QPixmap pixmap = QPixmap::fromImage(scaledImage);
|
||||
if (lens_n == 0) {
|
||||
//leftLens_m_imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ImageEnrollWindow.h"
|
||||
#include "PasswordEnrollWindow.h"
|
||||
|
||||
#if TEST_TCP_MOVE_TO_MAIN
|
||||
ClientHandler::ClientHandler(QTcpSocket* socket,
|
||||
QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
|
||||
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
|
@ -11,6 +12,14 @@ ClientHandler::ClientHandler(QTcpSocket* socket,
|
|||
QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
|
||||
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, int isBackBoardOrAllBoard, QObject* parent)
|
||||
: QObject(parent), socket(socket),
|
||||
#else
|
||||
ClientHandler::ClientHandler(QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
|
||||
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig,
|
||||
QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
|
||||
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, int isBackBoardOrAllBoard, QObject* parent)
|
||||
: QObject(parent),
|
||||
#endif
|
||||
frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
|
||||
frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson),
|
||||
frontBoardLicenseJson(frontBoardLicenseJson),
|
||||
|
@ -24,14 +33,30 @@ ClientHandler::ClientHandler(QTcpSocket* socket,
|
|||
currentFrontBoardIndex(0), currentLicenseIndex(0), currentUuidIndex(0),
|
||||
currentBackBoardIndex(0)
|
||||
{
|
||||
#if TEST_TCP_MOVE_TO_MAIN
|
||||
connect(socket, &QTcpSocket::readyRead, this, &ClientHandler::onDataReceived);
|
||||
connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::onDisconnected);
|
||||
|
||||
qint64 bufferSize = socket->socketOption(QAbstractSocket::ReceiveBufferSizeSocketOption).toLongLong();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
ClientHandler::~ClientHandler() {
|
||||
#if !TEST_TCP_MOVE_TO_MAIN
|
||||
void ClientHandler::initialize(QTcpSocket* socket)
|
||||
{
|
||||
this->socket = socket;
|
||||
|
||||
// 连接信号槽,将其放在同一线程中处理
|
||||
connect(socket, &QTcpSocket::readyRead, this, &ClientHandler::onDataReceived);
|
||||
connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::onDisconnected);
|
||||
|
||||
// 其他的 socket 操作都将在这个线程中进行
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ClientHandler::~ClientHandler()
|
||||
{
|
||||
qDebug() << "ClientHandler destroyed for clientId:" << clientId;
|
||||
}
|
||||
|
||||
|
@ -125,6 +150,30 @@ QString ClientHandler::getClientAddress() const
|
|||
return socket->peerAddress().toString() + ":" + QString::number(socket->peerPort());
|
||||
}
|
||||
|
||||
#if !TEST_TCP_MOVE_TO_MAIN
|
||||
void ClientHandler::onSendData(const QByteArray& data, int isBoardType)
|
||||
{
|
||||
qDebug() << "Sending data isBoardType:" << isBoardType;
|
||||
QByteArray prefix;
|
||||
QDataStream stream(&prefix, QIODevice::WriteOnly);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
stream << quint32(0x55AA55AA);
|
||||
if (isBoardType != 0) {
|
||||
stream << quint16(0x0421);
|
||||
}
|
||||
else {
|
||||
stream << quint16(0x0420);
|
||||
}
|
||||
stream << quint32(data.size());
|
||||
prefix.append(data);
|
||||
|
||||
qDebug() << "Sending data:" << prefix.toHex();
|
||||
|
||||
socket->write(prefix);
|
||||
socket->flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
void ClientHandler::sendDataToClient(const QByteArray& data)
|
||||
{
|
||||
emit sendData(data, isBackBoardOrAllBoard);
|
||||
|
@ -180,7 +229,7 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
|
|||
}
|
||||
QString itemData = QJsonDocument(currentItem).toJson();
|
||||
//emit sendData(itemData.toUtf8());
|
||||
sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
|
||||
// 设置超时处理
|
||||
if (currentItem.contains("timeout")) {
|
||||
|
@ -212,7 +261,7 @@ void ClientHandler::sendGetVideoItem(int itemIndex, int GetVideoCamIndex)
|
|||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo");
|
||||
}
|
||||
else {
|
||||
sendJsonItem(getVideoJson, itemIndex, "", "handleVideo");
|
||||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +385,7 @@ void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemInd
|
|||
|
||||
QString itemData = QJsonDocument(jsonItem).toJson();
|
||||
//emit sendData(itemData.toUtf8());
|
||||
sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
|
||||
if (jsonItem.contains("timeout")) {
|
||||
int timeout = jsonItem.value("timeout").toInt();
|
||||
|
@ -397,7 +446,7 @@ void ClientHandler::sendNextItem()
|
|||
}
|
||||
}
|
||||
//emit sendData(itemData.toUtf8());
|
||||
sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
|
||||
if (currentItem.contains("timeout")) {
|
||||
int timeout = currentItem.value("timeout").toInt();
|
||||
|
|
|
@ -24,26 +24,37 @@
|
|||
|
||||
#include "DelUserWindows.h"
|
||||
|
||||
#define TEST_TCP_MOVE_TO_MAIN 0
|
||||
|
||||
class ClientHandler : public QObject, public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
#if TEST_TCP_MOVE_TO_MAIN
|
||||
explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest,
|
||||
QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig, QJsonArray backBoardDevInfoJson,
|
||||
QJsonArray backBoardUuidJson, QJsonArray getPicJson, QJsonArray getVideoJson,
|
||||
int clientId, int isBackBoardOrAllBoard, QObject* parent = nullptr);
|
||||
|
||||
#else
|
||||
explicit ClientHandler(QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest,
|
||||
QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig, QJsonArray backBoardDevInfoJson,
|
||||
QJsonArray backBoardUuidJson, QJsonArray getPicJson, QJsonArray getVideoJson,
|
||||
int clientId, int isBackBoardOrAllBoard, QObject* parent = nullptr);
|
||||
#endif
|
||||
~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; }
|
||||
|
||||
#if !TEST_TCP_MOVE_TO_MAIN
|
||||
void ClientHandler::initialize(QTcpSocket* socket);
|
||||
#endif
|
||||
|
||||
// QRunnable 的虚函数,在线程池中执行
|
||||
void run() override;
|
||||
// 开始处理客户端
|
||||
|
@ -103,12 +114,15 @@ signals:
|
|||
void allItemsProcessed(const QString& client, int itemsProcessedCount);
|
||||
// 通知主线程启动定时器
|
||||
void startTimeout(int timeout);
|
||||
void selectClientDisconnected(int clientId);
|
||||
void startReadTimer(int clientId);
|
||||
void stopReadTimer(int clientId);
|
||||
void sendDataToSomeClient(int clientId, const QByteArray& data);
|
||||
void selectClientDisconnected(int client_Id);
|
||||
void startReadTimer(int client_Id);
|
||||
void stopReadTimer(int client_Id);
|
||||
void sendDataToSomeClient(int client_Id, const QByteArray& data);
|
||||
|
||||
public slots:
|
||||
#if !TEST_TCP_MOVE_TO_MAIN
|
||||
void onSendData(const QByteArray& data, int isBoardType);
|
||||
#endif
|
||||
// 处理数据接收
|
||||
void onDataReceived();
|
||||
// 处理超时
|
||||
|
|
|
@ -130,7 +130,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
|||
|
||||
qDebug() << "read file data size:" << recvdata.size();
|
||||
#endif
|
||||
qDebug() << "---Received data size:" << recvData.size();
|
||||
//qDebug() << "---Received data size:" << recvData.size();
|
||||
// 将接收到的数据追加到buffer
|
||||
buffer->append(recvData);
|
||||
|
||||
|
@ -143,47 +143,16 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
|||
(static_cast<unsigned char>(buffer->at(7)) << 8) |
|
||||
(static_cast<unsigned char>(buffer->at(6)));
|
||||
//qDebug() << "---Received dataSize:" << dataSize;
|
||||
//qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper();
|
||||
/*qDebug() << "---(static_cast<unsigned char>(buffer->at(0)):" << QString::number(static_cast<unsigned char>(buffer->at(0)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(1)):" << QString::number(static_cast<unsigned char>(buffer->at(1)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(2)):" << QString::number(static_cast<unsigned char>(buffer->at(2)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(3)):" << QString::number(static_cast<unsigned char>(buffer->at(3)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(4)):" << QString::number(static_cast<unsigned char>(buffer->at(4)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(5)):" << QString::number(static_cast<unsigned char>(buffer->at(5)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(6)):" << QString::number(static_cast<unsigned char>(buffer->at(6)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(7)):" << QString::number(static_cast<unsigned char>(buffer->at(7)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(8)):" << QString::number(static_cast<unsigned char>(buffer->at(8)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(9)):" << QString::number(static_cast<unsigned char>(buffer->at(9)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << QString::number(static_cast<unsigned char>(buffer->at(10)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << QString::number(static_cast<unsigned char>(buffer->at(11)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << QString::number(static_cast<unsigned char>(buffer->at(12)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << QString::number(static_cast<unsigned char>(buffer->at(13)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << QString::number(static_cast<unsigned char>(buffer->at(14)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << QString::number(static_cast<unsigned char>(buffer->at(15)), 16).toUpper();*/
|
||||
//qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper();
|
||||
// 第11字节为返回 OK/NG
|
||||
bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00);
|
||||
int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小
|
||||
|
||||
if (buffer->size() >= totalSize) {
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(0)):" << QString::number(static_cast<unsigned char>(buffer->at(0)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(1)):" << QString::number(static_cast<unsigned char>(buffer->at(1)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(2)):" << QString::number(static_cast<unsigned char>(buffer->at(2)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(3)):" << QString::number(static_cast<unsigned char>(buffer->at(3)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(4)):" << QString::number(static_cast<unsigned char>(buffer->at(4)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(5)):" << QString::number(static_cast<unsigned char>(buffer->at(5)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(6)):" << QString::number(static_cast<unsigned char>(buffer->at(6)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(7)):" << QString::number(static_cast<unsigned char>(buffer->at(7)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(8)):" << QString::number(static_cast<unsigned char>(buffer->at(8)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(9)):" << QString::number(static_cast<unsigned char>(buffer->at(9)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << QString::number(static_cast<unsigned char>(buffer->at(10)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << QString::number(static_cast<unsigned char>(buffer->at(11)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << QString::number(static_cast<unsigned char>(buffer->at(12)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << QString::number(static_cast<unsigned char>(buffer->at(13)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << QString::number(static_cast<unsigned char>(buffer->at(14)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << QString::number(static_cast<unsigned char>(buffer->at(15)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(16)):" << QString::number(static_cast<unsigned char>(buffer->at(16)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(17)):" << QString::number(static_cast<unsigned char>(buffer->at(17)), 16).toUpper();
|
||||
qDebug() << "---(static_cast<unsigned char>(buffer->at(18)):" << QString::number(static_cast<unsigned char>(buffer->at(18)), 16).toUpper();
|
||||
// 调试查看收到的前19个字节
|
||||
/*for (int i = 0; i < 19; i++) {
|
||||
qDebug() << "buffer->at(" << i << "):" << QString::number(static_cast<unsigned char>(buffer->at(i)), 16).toUpper();
|
||||
}*/
|
||||
// 去掉前面 11 字节
|
||||
QByteArray data = buffer->mid(11, dataSize);
|
||||
//QByteArray data = buffer->mid(10, dataSize);
|
||||
|
@ -305,20 +274,15 @@ void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray a
|
|||
break;
|
||||
case GET_IMG:
|
||||
{
|
||||
qDebug() << "--- showPic actual_data.size():" << actual_data.size();
|
||||
int lens_n = static_cast<unsigned char>(actual_data[1]);
|
||||
int width = (static_cast<unsigned char>(actual_data[3]) << 8) | static_cast<unsigned char>(actual_data[2]);
|
||||
int height = (static_cast<unsigned char>(actual_data[5]) << 8) | static_cast<unsigned char>(actual_data[4]);
|
||||
int format = static_cast<unsigned char>(actual_data[6]);
|
||||
qDebug() << "lens_n = " << lens_n;
|
||||
qDebug() << "format = " << format;
|
||||
qDebug() << "width = " << width;
|
||||
qDebug() << "height = " << height;
|
||||
qint32 picSize = width * height * 1.5;
|
||||
|
||||
QByteArray yuvData = actual_data.mid(7);
|
||||
qDebug() << "--- showPic width * height * 1.5:" << picSize;
|
||||
qDebug() << "--- showPic picBuffer.size():" << picBuffer->size();
|
||||
qDebug() << "showPic width * height * 1.5:" << picSize;
|
||||
qDebug() << "showPic picBuffer.size():" << picBuffer->size();
|
||||
if (yuvData.size() + picBuffer->size() == picSize) {
|
||||
picBuffer->append(yuvData);
|
||||
showPic(labelSize, lens_n, width, height, format, picBuffer);
|
||||
|
|
|
@ -64,7 +64,6 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
qDebug() << "The client IP address is back board or all board";
|
||||
isBackBoardOrAllBoard = clientId;
|
||||
}
|
||||
|
||||
stopMdnsService();
|
||||
connectedClientsCount ++;
|
||||
updateServerButtonText();
|
||||
|
@ -87,11 +86,26 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
});
|
||||
|
||||
QThread* thread = new QThread(this);
|
||||
#if TEST_TCP_MOVE_TO_MAIN
|
||||
ClientHandler* handler = new ClientHandler(socket, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||
frontBoardDevInfoJson, frontBoardLicenseJson,
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, clientId, isBackBoardOrAllBoard, nullptr);
|
||||
|
||||
#else
|
||||
ClientHandler* handler = new ClientHandler(frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||
frontBoardDevInfoJson, frontBoardLicenseJson,
|
||||
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
|
||||
backBoardUuidJson, getPicJson, getVideoJson, clientId, isBackBoardOrAllBoard, nullptr);
|
||||
/*
|
||||
* 一定要先取消父对象,否则报错:QObject::moveToThread: Cannot move objects with a parent
|
||||
* 父对象负责管理子对象的生命周期,如果子对象被移动到其他线程,可能会导致线程安全问题或不一致的对象状态
|
||||
*/
|
||||
socket->setParent(nullptr);
|
||||
// 将 socket 移动到新的线程中
|
||||
socket->moveToThread(thread);
|
||||
// 将 socket 传递到 handler
|
||||
handler->initialize(socket);
|
||||
#endif
|
||||
// 将 ClientHandler 移到线程池中的线程
|
||||
handler->moveToThread(thread);
|
||||
|
||||
|
@ -103,8 +117,7 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
backBoardUuidJson, getPicJson, getVideoJson, nullptr);
|
||||
// 将 DataHandler 移到线程池中的线程
|
||||
dataHandler->moveToThread(thread);
|
||||
|
||||
|
||||
#if TEST_TCP_MOVE_TO_MAIN
|
||||
// 将sendData信号连接到主线程中的槽上
|
||||
connect(handler, &ClientHandler::sendData, this, [socket](const QByteArray& data, int isBoardType) {
|
||||
/*socket->write(data);
|
||||
|
@ -128,7 +141,9 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
socket->write(prefix);
|
||||
socket->flush();
|
||||
});
|
||||
|
||||
#else
|
||||
connect(handler, &ClientHandler::sendData, handler, &ClientHandler::onSendData, Qt::QueuedConnection);
|
||||
#endif
|
||||
connect(handler, &ClientHandler::startTimeout, this, [this, clientId](int timeout) {
|
||||
this->onStartTimeout(clientId, timeout);
|
||||
});
|
||||
|
@ -140,8 +155,7 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
connect(handler, &ClientHandler::clientDisconnected, this, &MainWidget::onClientDisconnected);
|
||||
connect(handler, &ClientHandler::allItemsProcessed, this, &MainWidget::onAllItemsProcessed);
|
||||
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
|
||||
|
||||
|
||||
|
||||
dataHandlers[clientId] = dataHandler;
|
||||
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
||||
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
||||
|
@ -161,12 +175,9 @@ MainWidget::MainWidget(QWidget* parent) :
|
|||
// 启动新的线程
|
||||
thread->start();
|
||||
|
||||
connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer);
|
||||
connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer);
|
||||
//handler->getClientId() == handler->preVideoClientId
|
||||
//qDebug() << "---- handler->getClientId():" << handler->getClientId();
|
||||
//qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId;
|
||||
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
|
||||
connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer);
|
||||
connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer);
|
||||
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
|
||||
|
||||
// 创建和管理定时器
|
||||
QTimer* readTimer = new QTimer(this);
|
||||
|
@ -1100,24 +1111,6 @@ void MainWidget::stopMdnsService()
|
|||
mServiceProvider->stopServiceBroadcast();
|
||||
}
|
||||
|
||||
#if TEST_UDP_BROADCAST
|
||||
void MainWidget::sendMulticastMessage()
|
||||
{
|
||||
QByteArray datagram = "--------------------------------- Test multicast message from MainWidget";
|
||||
QHostAddress groupAddress("224.0.0.251");
|
||||
quint16 port = 5353;
|
||||
|
||||
qint64 sentBytes = multicastSocket->writeDatagram(datagram, groupAddress, port);
|
||||
if (sentBytes == -1) {
|
||||
qWarning() << "Failed to send multicast message:" << multicastSocket->errorString();
|
||||
}
|
||||
else {
|
||||
qDebug() << "Multicast message sentBytes:" << sentBytes;
|
||||
qDebug() << "Multicast message sent:" << datagram;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 处理开始服务器按键点击事件
|
||||
void MainWidget::onStartServerClicked()
|
||||
{
|
||||
|
@ -1192,7 +1185,6 @@ void MainWidget::onSendGetPicClicked()
|
|||
if (connectedClientsCount) {
|
||||
QPushButton* button = qobject_cast<QPushButton*>(sender());
|
||||
int itemIndex = button->property("getPicIndex").toInt();
|
||||
|
||||
if (itemIndex < 2) {
|
||||
button->setStyleSheet("background-color: green;");
|
||||
if (lastClickedGetPicCamIndex != -1 && lastClickedGetPicCamIndex != itemIndex) {
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "../Network/ClientHandler.h"
|
||||
#include "../Network/httpClient.h"
|
||||
|
||||
|
||||
#include "../Network/mdns/qmdnsengine/include/server.h"
|
||||
#include "../Network/mdns/qmdnsengine/include/hostname.h"
|
||||
#include "../Network/mdns/qmdnsengine/include/provider.h"
|
||||
|
|
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |