光电吊舱设置页面交付修改,隐藏未开发接口;解决rtsp流再次连接时软件崩溃问题;解决rtsp地址错误时软件崩溃问题;视频流解析类显示页面增加自适应比例变换功能

pull/5/head
caoyuhui 7 months ago
parent 5fae81f44f
commit bf2b90f651

@ -24,6 +24,18 @@ void GDDCSet::initWindow()
{ {
this->setWindowTitle("通信设置"); this->setWindowTitle("通信设置");
setAttribute(Qt::WA_QuitOnClose,false); setAttribute(Qt::WA_QuitOnClose,false);
//交付时隐藏部分未开发接口
ui->label_2->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->lineEdit_playURL2->hide();
ui->lineEdit_playport2->hide();
ui->pushButton_ConnectURL2->hide();
ui->groupBox_2->hide();
ui->radioButton_NetCtrlTCP->hide();
ui->label->hide();
ui->lineEdit_playport1->hide();
} }
void GDDCSet::initUDPSocket() void GDDCSet::initUDPSocket()
{ {
@ -36,10 +48,11 @@ void GDDCSet::initParam()
// setting.setIniCodec(QTextCodec::codecForName("UTF-8")); //重点 // setting.setIniCodec(QTextCodec::codecForName("UTF-8")); //重点
ui->comboBox_streamType->addItem("RTSP"); ui->comboBox_streamType->addItem("RTSP");
ui->comboBox_streamType->addItem("UDP Raw"); //ui->comboBox_streamType->addItem("UDP Raw");
ui->comboBox_streamType->addItem("UDP 422"); //ui->comboBox_streamType->addItem("UDP 422");
ui->comboBox_streamType->addItem("UDP TS"); //ui->comboBox_streamType->addItem("UDP TS");
ui->comboBox_playURL1->addItem("rtsp://192.168.1.160:554/live/track0"); ui->comboBox_playURL1->addItem("rtsp://192.168.1.160:554/live/track0");
ui->comboBox_playURL1->addItem("rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid");
ui->comboBox_playURL1->setEditable(true); ui->comboBox_playURL1->setEditable(true);
/*"rtsp://192.168.1.160:554/live/track0"*/ /*"rtsp://192.168.1.160:554/live/track0"*/

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>761</width> <width>761</width>
<height>506</height> <height>387</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -22,14 +22,14 @@
<x>30</x> <x>30</x>
<y>10</y> <y>10</y>
<width>701</width> <width>701</width>
<height>211</height> <height>141</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>视频连接</string> <string>视频连接</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="geometry"> <property name="geometry">
@ -203,7 +203,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
<y>230</y> <y>280</y>
<width>701</width> <width>701</width>
<height>80</height> <height>80</height>
</rect> </rect>
@ -212,7 +212,7 @@
<string>串口控制</string> <string>串口控制</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
<widget class="QPushButton" name="pushButton_serialControlConnect"> <widget class="QPushButton" name="pushButton_serialControlConnect">
<property name="geometry"> <property name="geometry">
@ -291,7 +291,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
<y>330</y> <y>180</y>
<width>701</width> <width>701</width>
<height>141</height> <height>141</height>
</rect> </rect>
@ -300,7 +300,7 @@
<string>网络控制</string> <string>网络控制</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
<widget class="QPushButton" name="pushButton_NetCtrlConnect"> <widget class="QPushButton" name="pushButton_NetCtrlConnect">
<property name="geometry"> <property name="geometry">

@ -31,14 +31,13 @@ void GDDCStateInfo::initParam()
//ui->tableViewShowIState->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); //ui->tableViewShowIState->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
// 表格宽度自动根据UI进行计算不可手动调整宽度 // 表格宽度自动根据UI进行计算不可手动调整宽度
//ui->tableViewShowIState->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //ui->tableViewShowIState->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
// 固定表格高度不可扩展,不可手动调整高度 // 固定表格高度不可扩展,不可手动调整高度
ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
// 表格高度随内容自动扩展 // 表格高度随内容自动扩展
//ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); //ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
// 表格高度自动根据UI进行计算不可手动调整高度 // 表格高度自动根据UI进行计算不可手动调整高度
//ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); //ui->tableViewShowIState->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableViewShowIState->setEditTriggers(QAbstractItemView::NoEditTriggers); // 不可编辑
ui->tableViewShowIState->setColumnWidth(0,100); ui->tableViewShowIState->setColumnWidth(0,100);
ui->tableViewShowIState->setColumnWidth(1,100); ui->tableViewShowIState->setColumnWidth(1,100);

@ -273,20 +273,21 @@ void GDDCdlg::resizeUI()
/*******视频区位置和大小设置********/ /*******视频区位置和大小设置********/
double VideoAreaHeight = GDDCPageHeight-cmdAreaHeight; //视频区高度 double VideoAreaHeight = GDDCPageHeight-cmdAreaHeight; //视频区高度
double VideoAreaWidth = GDDCPageWidth-stateAreaWidth; //视频区宽度 double VideoAreaWidth = GDDCPageWidth-stateAreaWidth; //视频区宽度
//高度值相对比较大 // //高度值相对比较大
if(VideoAreaHeight*16>VideoAreaWidth*9) // if(VideoAreaHeight*16>VideoAreaWidth*9)
{ // {
double setVideoAreaWidth = VideoAreaWidth;//等于吊舱页面宽度-状态区高度 // double setVideoAreaWidth = VideoAreaWidth;//等于吊舱页面宽度-状态区高度
double setVideoAreaHeight = VideoAreaWidth*9/16; // double setVideoAreaHeight = VideoAreaWidth*9/16;
ui->WgtffmpegVideo->setGeometry(0,0.5*(VideoAreaHeight-setVideoAreaHeight),(int)setVideoAreaWidth,(int)setVideoAreaHeight); // ui->WgtffmpegVideo->setGeometry(0,0.5*(VideoAreaHeight-setVideoAreaHeight),(int)setVideoAreaWidth,(int)setVideoAreaHeight);
} // }
//宽度值相对比较大 // //宽度值相对比较大
else // else
{ // {
double setVideoAreaHeight = VideoAreaHeight;//等于吊舱页面高度-控制区高度 // double setVideoAreaHeight = VideoAreaHeight;//等于吊舱页面高度-控制区高度
double setVideoAreaWidth = VideoAreaHeight*16/9; // double setVideoAreaWidth = VideoAreaHeight*16/9;
ui->WgtffmpegVideo->setGeometry(0.5*(VideoAreaWidth-setVideoAreaWidth),0,(int)setVideoAreaWidth,(int)setVideoAreaHeight); // ui->WgtffmpegVideo->setGeometry(0.5*(VideoAreaWidth-setVideoAreaWidth),0,(int)setVideoAreaWidth,(int)setVideoAreaHeight);
} // }
ui->WgtffmpegVideo->setGeometry(0,0,(int)VideoAreaWidth,(int)VideoAreaHeight);
/**************设置按钮****************/ /**************设置按钮****************/
ui->pushButtonSet->setGeometry(GDDCPageWidth-stateAreaWidth-45,0,40,40); ui->pushButtonSet->setGeometry(GDDCPageWidth-stateAreaWidth-45,0,40,40);
@ -374,10 +375,12 @@ void GDDCdlg::startConnectURL1()
if(!connectFlag[0]) if(!connectFlag[0])
{ {
connectFlag[0] = true ; connectFlag[0] = true ;
//Is_openVideo = true;
//ui->WgtffmpegVideo->Isplay(Is_openVideo); //ui->WgtffmpegVideo->Isplay(Is_openVideo);
//ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
ui->WgtffmpegVideo->play(); ui->WgtffmpegVideo->play();
ui->WgtffmpegVideo->setUrl(m_DlgGDDCSet->m_playURL1); ui->WgtffmpegVideo->setUrl(m_DlgGDDCSet->m_playURL1);
ui->WgtffmpegVideo->m_PlayStatus =Is_openVideo;
} }
} }
@ -387,7 +390,8 @@ void GDDCdlg::stopConnectURL1()
if(connectFlag[0]) if(connectFlag[0])
{ {
connectFlag[0] = false ; connectFlag[0] = false ;
ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo; //Is_openVideo = false;
//ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
ui->WgtffmpegVideo->stop(); ui->WgtffmpegVideo->stop();
} }
} }

@ -82,7 +82,7 @@ public:
public: public:
bool pointSelectionTracking; //选点跟踪 bool pointSelectionTracking; //选点跟踪
bool Is_openVideo; //视频是否已打开,默认未打开 bool Is_openVideo; //视频是否已打开,默认未打开
std::vector<bool> connectFlag; // 0视频流11视频流22串口通信3网口通信 std::vector<bool> connectFlag; // 0视频流11视频流22串口通信3网口通信
bool isCmdPageShow; //控制页是否显示 bool isCmdPageShow; //控制页是否显示
bool isStatePageShow; //状态页是否显示 bool isStatePageShow; //状态页是否显示
bool detectionAreaSetting; //检测区域设置 bool detectionAreaSetting; //检测区域设置

@ -41,7 +41,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LayoutDirection::LeftToRight</enum>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@ -83,16 +83,16 @@
</size> </size>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::NoFocus</enum> <enum>Qt::FocusPolicy::NoFocus</enum>
</property> </property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum> <enum>Qt::ContextMenuPolicy::NoContextMenu</enum>
</property> </property>
<property name="acceptDrops"> <property name="acceptDrops">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LayoutDirection::LeftToRight</enum>
</property> </property>
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>false</bool> <bool>false</bool>
@ -104,8 +104,8 @@
<widget class="QPushButton" name="pushButShowCmdPage"> <widget class="QPushButton" name="pushButShowCmdPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>470</x> <x>480</x>
<y>380</y> <y>310</y>
<width>80</width> <width>80</width>
<height>20</height> <height>20</height>
</rect> </rect>
@ -146,12 +146,15 @@
<height>192</height> <height>192</height>
</rect> </rect>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget> </widget>
<widget class="QWidget" name="subWidgetCmd" native="true"> <widget class="QWidget" name="subWidgetCmd" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>350</x> <x>260</x>
<y>410</y> <y>380</y>
<width>331</width> <width>331</width>
<height>71</height> <height>71</height>
</rect> </rect>
@ -160,8 +163,8 @@
<widget class="QPushButton" name="pushButShowStatePage"> <widget class="QPushButton" name="pushButShowStatePage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>630</x> <x>640</x>
<y>320</y> <y>310</y>
<width>80</width> <width>80</width>
<height>20</height> <height>20</height>
</rect> </rect>

@ -1,5 +1,4 @@
#include "cffmpeg_decode.h" #include "cffmpeg_decode.h"
Cffmpeg_decode::Cffmpeg_decode() Cffmpeg_decode::Cffmpeg_decode()
{ {
fmtCtx = avformat_alloc_context(); fmtCtx = avformat_alloc_context();
@ -30,7 +29,7 @@ bool Cffmpeg_decode::open_input_file()
AVDictionary* avdic = NULL; AVDictionary* avdic = NULL;
av_dict_set(&avdic, "buffer_size", "2048000", 0); //设置缓存大小1080p可将值调大 av_dict_set(&avdic, "buffer_size", "2048000", 0); //设置缓存大小1080p可将值调大
av_dict_set(&avdic, "rtsp_transport", "udp", 0); //以udp方式打开如果以tcp方式打开将udp替换为tcp av_dict_set(&avdic, "rtsp_transport", "udp", 0); //以udp方式打开如果以tcp方式打开将udp替换为tcp
av_dict_set(&avdic, "stimeout", "2000000", 0); //设置超时断开连接时间,单位微秒 av_dict_set(&avdic, "listen_timeout", "200000", 0); //设置超时断开连接时间,单位微秒
av_dict_set(&avdic, "max_delay", "3000", 0); //设置最大时延 av_dict_set(&avdic, "max_delay", "3000", 0); //设置最大时延
av_dict_set(&avdic, "tune", "zerolatency", 0); av_dict_set(&avdic, "tune", "zerolatency", 0);
av_dict_set(&avdic, "preset", "ultrafast", 0); av_dict_set(&avdic, "preset", "ultrafast", 0);
@ -101,10 +100,12 @@ bool Cffmpeg_decode::open_input_file()
return true; return true;
} }
//线程里持续执行
void Cffmpeg_decode::run() void Cffmpeg_decode::run()
{ {
if(!open_input_file()){ if(!open_input_file()){
qDebug()<<"Please open video file first."; qDebug()<<"Please open video file first.";
emit sendConnectFail(1);
IsstopPlay = true; IsstopPlay = true;
return; return;
} }

@ -27,7 +27,8 @@ extern "C"{
} }
class Cffmpeg_decode: public QThread //class Cffmpeg_decode: public QThread
class Cffmpeg_decode: public QObject
{ {
public: public:
explicit Cffmpeg_decode(); explicit Cffmpeg_decode();
@ -35,22 +36,19 @@ public:
Q_OBJECT Q_OBJECT
public: public:
void setUrl(QString url); void setUrl(QString url);
bool open_input_file(); bool open_input_file();
bool IsstopPlay= false; bool IsstopPlay= false;
protected: public slots:
void run(); void run();
signals: signals:
void sendQImage(QImage); void sendQImage(QImage);
void sendConnectFail(int);
private: private:
AVFormatContext *fmtCtx =NULL; AVFormatContext *fmtCtx =NULL;
const AVCodec *videoCodec =NULL; const AVCodec *videoCodec =NULL;
AVCodecContext *videoCodecCtx=NULL; AVCodecContext *videoCodecCtx=NULL;
AVPacket *pkt = NULL; AVPacket *pkt = NULL;
AVFrame *yuvFrame = NULL; AVFrame *yuvFrame = NULL;

@ -1,10 +0,0 @@
[光电吊舱-网络控制]
本地IP=-1
本地Port=65535
远端IP=-1
远端Port=65535
[光电吊舱-视频连接-显示窗口2]
播放URL=33333
播放Port=-1
[光电吊舱-视频连接-显示窗口1]
播放Port=-1

@ -1,5 +1,6 @@
#include "ffmpegvideodlg.h" #include "ffmpegvideodlg.h"
#include "ui_ffmpegvideodlg.h" #include "ui_ffmpegvideodlg.h"
#include <QMessageBox>
ffmpegvideoDlg::ffmpegvideoDlg(QWidget *parent) ffmpegvideoDlg::ffmpegvideoDlg(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -7,25 +8,25 @@ ffmpegvideoDlg::ffmpegvideoDlg(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
iniWindow(); iniWindow();
ffmpeg = new Cffmpeg_decode;
// this->resize(640,480);
} }
ffmpegvideoDlg::~ffmpegvideoDlg() ffmpegvideoDlg::~ffmpegvideoDlg()
{ {
if(ffmpeg->isRunning()){ stop();
stop();
}
delete ffmpeg;
delete ui; delete ui;
} }
void ffmpegvideoDlg::iniWindow() void ffmpegvideoDlg::iniWindow()
{ {
QString VideoFilePath = QDir::currentPath()+"./Video";
} QDir VideoDir (VideoFilePath);
if(!VideoDir.exists())
{
VideoDir.mkdir(VideoFilePath);
qDebug()<<"文件夹创建成功";
}
}
void ffmpegvideoDlg::setUrl(QString url) void ffmpegvideoDlg::setUrl(QString url)
{ {
ffmpeg->setUrl(url); ffmpeg->setUrl(url);
@ -33,61 +34,86 @@ void ffmpegvideoDlg::setUrl(QString url)
void ffmpegvideoDlg::play() void ffmpegvideoDlg::play()
{ {
QString VideoFilePath = QDir::currentPath()+"./Video";
QDir VideoDir (VideoFilePath);
if(!VideoDir.exists())
{
VideoDir.mkdir(VideoFilePath);
qDebug()<<"文件夹创建成功";
}
if(!m_PlayStatus) if(!m_PlayStatus)
{ {
connect(ffmpeg,SIGNAL(sendQImage(QImage)),this,SLOT(receiveQImage(QImage))); m_PlayStatus = true;
connect(ffmpeg,&Cffmpeg_decode::finished,ffmpeg,&Cffmpeg_decode::deleteLater); ffmpeg = new Cffmpeg_decode;
ffmpeg->IsstopPlay = false;
} ffmpeg->moveToThread(&workerThread);
connect(&workerThread,&QThread::finished,ffmpeg,&QObject::deleteLater); //线程发送结束标志
if(!ffmpeg->isRunning()) connect(this, &ffmpegvideoDlg::operate, ffmpeg, &Cffmpeg_decode::run); //线程开始处理数据
{ connect(ffmpeg,SIGNAL(sendQImage(QImage)),this,SLOT(receiveQImage(QImage))); //发送解析的图片
connect(ffmpeg,SIGNAL(sendConnectFail(int)),this,SLOT(showMessagBox(int))); //发送错误信息提示
ffmpeg->start(); workerThread.start();
emit this->operate(); //启用线程信号
} }
} }
void ffmpegvideoDlg::stop() void ffmpegvideoDlg::stop()
{ {
if(ffmpeg->isRunning() && !ffmpeg->IsstopPlay ){ if(m_PlayStatus)
{
ffmpeg->IsstopPlay = true; m_PlayStatus = false;
ffmpeg->requestInterruption(); ffmpeg->IsstopPlay = true; //线程结束标志
ffmpeg->quit(); workerThread.quit(); //线程退出时自动delete线程里的类
ffmpeg->wait(); workerThread.wait();
img.fill(Qt::black);
ffmpeg = nullptr;
} }
img.fill(Qt::black);
} }
//绘图事件
void ffmpegvideoDlg::paintEvent(QPaintEvent *) void ffmpegvideoDlg::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.drawImage(0,0,img); painter.drawImage(m_ax,m_ay,img);
}
//区域大小改变事件
void ffmpegvideoDlg::resizeEvent(QResizeEvent *event)
{
//区域1920*1080自适应
double VideoAreaHeight = this->height();
double VideoAreaWidth = this->width();
//高度值相对比较大
if(VideoAreaHeight*16>VideoAreaWidth*9)
{
m_setVideoAreaWidth = VideoAreaWidth;
m_setVideoAreaHeight = VideoAreaWidth*9/16;
m_ax = 0;
m_ay = 0.5*(VideoAreaHeight-m_setVideoAreaHeight);
}
//宽度值相对比较大
else
{
m_setVideoAreaHeight = VideoAreaHeight;
m_setVideoAreaWidth = VideoAreaHeight*16/9;
m_ax = 0.5*(VideoAreaWidth-m_setVideoAreaWidth);
m_ay = 0;
}
} }
void ffmpegvideoDlg::receiveQImage(const QImage &rImg) void ffmpegvideoDlg::receiveQImage(const QImage &rImg)
{ {
img = rImg.scaled(this->size());
//img = rImg.scaled(this->size());
QSize imgsize(m_setVideoAreaWidth,m_setVideoAreaHeight);
img = rImg.scaled(imgsize);
update(); update();
} }
//显示不同提示消息
void ffmpegvideoDlg::showMessagBox(int type)
{
switch (type) {
case 1:
QMessageBox::information(NULL,tr("提示"),"获取视频失败",QMessageBox::Ok);
break;
default:
break;
}
}
bool ffmpegvideoDlg::Isplay(bool IsstopPlay) bool ffmpegvideoDlg::Isplay(bool IsstopPlay)
{ {
return ffmpeg->IsstopPlay = IsstopPlay; return ffmpeg->IsstopPlay = IsstopPlay;
} }

@ -54,15 +54,24 @@ public:
bool Isplay(bool IsstopPlay); bool Isplay(bool IsstopPlay);
bool m_PlayStatus =false; bool m_PlayStatus =false;
double m_setVideoAreaWidth;
double m_setVideoAreaHeight;
double m_ax;
double m_ay;
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *event);
private slots: private slots:
void receiveQImage(const QImage &rImg); void receiveQImage(const QImage &rImg);
void showMessagBox(int);
signals:
void operate();
private: private:
Cffmpeg_decode *ffmpeg; Cffmpeg_decode *ffmpeg;
QThread workerThread;
QImage img; QImage img;
}; };

@ -200,7 +200,7 @@ QFrame#frameGDDCPage
QTableView QTableView
{ {
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
font: 12pt "Microsoft YaHei UI"; font: 10pt "Microsoft YaHei UI";
border:none; border:none;
background-color: rgba(50, 50, 50, 50); /*rgba(150, 223, 155, 50)*/ background-color: rgba(50, 50, 50, 50); /*rgba(150, 223, 155, 50)*/
selection-background-color: rgba(96, 96, 96, 0); /*选中区域的背景色,设置成透明96,96,96*/ selection-background-color: rgba(96, 96, 96, 0); /*选中区域的背景色,设置成透明96,96,96*/

Loading…
Cancel
Save