1.增加整机测试工厂信息输入; 2. 增加前后板连接后自动发送获取设备版本信息指令; 3. 优化UI布局代码
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
FFmpegDecoder::FFmpegDecoder(QObject* parent) :
|
||||
QThread(parent),
|
||||
videoLabel(nullptr),
|
||||
videoLabel_back(nullptr),
|
||||
resolutionEdit(nullptr),
|
||||
resolutionEdit_back(nullptr),
|
||||
abort(false),
|
||||
restart(false),
|
||||
formatContext(nullptr),
|
||||
@@ -24,6 +26,7 @@ FFmpegDecoder::~FFmpegDecoder()
|
||||
qDebug() << "Destroying FFmpegDecoder thread";
|
||||
mutex.lock();
|
||||
abort = true;
|
||||
isStartVideo = false;
|
||||
condition.wakeOne();
|
||||
mutex.unlock();
|
||||
wait();
|
||||
@@ -34,7 +37,13 @@ FFmpegDecoder::~FFmpegDecoder()
|
||||
|
||||
void FFmpegDecoder::processVideo(int itemIndex)
|
||||
{
|
||||
QLabel* originalLabel = this->videoLabel;
|
||||
QLabel* originalLabel;
|
||||
if (isBackBoardOrAllBoard) {
|
||||
originalLabel = this->videoLabel_back;
|
||||
}
|
||||
else {
|
||||
originalLabel = this->videoLabel;
|
||||
}
|
||||
if ((FocusWindowWidth != 0) && (FocusWindowHeight != 0)) {
|
||||
qDebug() << "------ processVideo";
|
||||
FocusWindowDialog* dialog = nullptr;
|
||||
@@ -54,25 +63,18 @@ void FFmpegDecoder::processVideo(int itemIndex)
|
||||
qDebug() << "------ Other scaled resolutions use 480x640";
|
||||
dialog = new FocusWindowDialog(nullptr, QSize(480, 640));
|
||||
}
|
||||
#if 0
|
||||
// 将视频显示的 QLabel 切换为对话框内的 videoDisplayLabel
|
||||
this->videoLabel = dialog->videoDisplayLabel;
|
||||
if ((dialog->exec() == QDialog::Accepted) || (dialog->exec() == QDialog::Rejected)) {
|
||||
this->videoLabel = originalLabel;
|
||||
}
|
||||
#else
|
||||
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel; // 更新临时标签
|
||||
this->videoLabelChanged = true; // 设置标志位,表示标签已更改
|
||||
this->videoLabelTemp = dialog->videoDisplayLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
|
||||
if ((dialog->exec() == QDialog::Accepted) || (dialog->exec() == QDialog::Rejected)) {
|
||||
mutex.lock();
|
||||
this->videoLabelTemp = originalLabel; // 还原回原始标签
|
||||
this->videoLabelChanged = true; // 设置标志位
|
||||
this->videoLabelTemp = originalLabel;
|
||||
this->videoLabelChanged = true;
|
||||
mutex.unlock();
|
||||
}
|
||||
#endif
|
||||
delete dialog;
|
||||
}
|
||||
else {
|
||||
@@ -89,17 +91,23 @@ void FFmpegDecoder::initialize()
|
||||
void FFmpegDecoder::stopFFmpegDecoder()
|
||||
{
|
||||
mutex.lock();
|
||||
abort = true;
|
||||
abort = true;
|
||||
isStartVideo = false;
|
||||
condition.wakeOne();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void FFmpegDecoder::decodeFile(const QString& videoFilePath, QLabel* videoDisplayLabel, QLineEdit* VideoResolutionEdit)
|
||||
void FFmpegDecoder::decodeFile(const QString& videoFilePath, int isBackBoardOrAllBoard,
|
||||
QLabel* videoDisplayLabel, QLabel* videoDisplayLabel_back,
|
||||
QLineEdit* VideoResolutionEdit, QLineEdit* VideoResolutionEdit_back)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
this->filePath = videoFilePath;
|
||||
this->videoLabel = videoDisplayLabel;
|
||||
this->resolutionEdit = VideoResolutionEdit;
|
||||
this->filePath = videoFilePath;
|
||||
this->videoLabel = videoDisplayLabel;
|
||||
this->videoLabel_back = videoDisplayLabel_back;
|
||||
this->resolutionEdit = VideoResolutionEdit;
|
||||
this->resolutionEdit_back = VideoResolutionEdit_back;
|
||||
this->isBackBoardOrAllBoard = isBackBoardOrAllBoard;
|
||||
if (!isRunning()) {
|
||||
qDebug() << "Starting decoder thread";
|
||||
start(NormalPriority);
|
||||
@@ -112,7 +120,13 @@ void FFmpegDecoder::run()
|
||||
{
|
||||
QFile file(filePath);
|
||||
qint64 fileSize = 0;
|
||||
QLabel* currentVideoLabel = videoLabel;
|
||||
QLabel* currentVideoLabel;
|
||||
if (isBackBoardOrAllBoard) {
|
||||
currentVideoLabel = videoLabel_back;
|
||||
}
|
||||
else {
|
||||
currentVideoLabel = videoLabel;
|
||||
}
|
||||
while (!isInterruptionRequested()) {
|
||||
mutex.lock();
|
||||
while (!restart && !abort) {
|
||||
@@ -132,18 +146,19 @@ void FFmpegDecoder::run()
|
||||
currentVideoLabel->setFixedSize(labelSize);
|
||||
qDebug() << "Adjusting video label size to: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||
}
|
||||
qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||
//qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "Failed to open file:" << filePath;
|
||||
continue;
|
||||
}
|
||||
if (!initializeFFmpeg(filePath)) {
|
||||
qDebug() << "Failed to initialize FFmpeg for file:" << filePath;
|
||||
//qDebug() << "Failed to initialize FFmpeg for file:" << filePath;
|
||||
cleanup();
|
||||
file.close();
|
||||
continue;
|
||||
}
|
||||
isStartVideo = true;
|
||||
restart = false;
|
||||
while (!abort) {
|
||||
qint64 currentFileSize = file.size();
|
||||
@@ -220,7 +235,7 @@ bool FFmpegDecoder::initializeFFmpeg(const QString& filePath)
|
||||
}
|
||||
|
||||
if (avformat_find_stream_info(formatContext, nullptr) < 0) {
|
||||
qWarning() << "Failed to retrieve stream info";
|
||||
//qWarning() << "Failed to retrieve stream info";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -300,8 +315,14 @@ QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
|
||||
FocusWindowHeight = height;
|
||||
}
|
||||
QString resolutionText = QString::number(width) + " x " + QString::number(height);
|
||||
//resolutionEdit->setText(resolutionText);
|
||||
QMetaObject::invokeMethod(resolutionEdit, "setText", Qt::QueuedConnection, Q_ARG(QString, resolutionText));
|
||||
|
||||
if (isBackBoardOrAllBoard) {
|
||||
QMetaObject::invokeMethod(resolutionEdit_back, "setText", Qt::QueuedConnection, Q_ARG(QString, resolutionText));
|
||||
}
|
||||
else {
|
||||
QMetaObject::invokeMethod(resolutionEdit, "setText", Qt::QueuedConnection, Q_ARG(QString, resolutionText));
|
||||
}
|
||||
|
||||
//qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height;
|
||||
|
||||
AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
|
||||
|
||||
Reference in New Issue
Block a user