feat:新增UDP推流人机交互界面

user_login
wanghaoyu 3 days ago
parent 2afb94baac
commit ef1b56d0db

@ -3,6 +3,7 @@ SOURCES += \
$$PWD/gddcdlg.cpp \
$$PWD/gddcSet.cpp \
$$PWD/gddcStateInfo.cpp \
$$PWD/udppushdlg.cpp \
HEADERS += \
$$PWD/gddcCmdDlg.h \
@ -11,13 +12,14 @@ HEADERS += \
$$PWD/gddcStateInfo.h \
$$PWD/structDefineMyslef.h \
$$PWD/DCFrameCkCmd.h \
$$PWD/udppushdlg.h \
FORMS += \
$$PWD/gddcCmdDlg.ui \
$$PWD/gddcdlg.ui \
$$PWD/gddcSet.ui \
$$PWD/gddcStateInfo.ui \
$$PWD/udppushdlg.ui \
RESOURCES += \
$$PWD/res.qrc

@ -18,6 +18,11 @@ GDDCSet::GDDCSet(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCSet) {
std::unique_ptr<QSettings> configIni = std::make_unique<QSettings>(urlFile, QSettings::IniFormat);
QString podIp = configIni->value("Pod/IP").toString();
initPullURL(podIp);
m_udpPushDlg = new udpPushDlg(this);
m_udpPushDlg->setWindowFlags(Qt::Dialog);
m_udpPushDlg->setWindowModality(Qt::WindowModal);//设置为模态对话框
connect(this->m_udpPushDlg,&udpPushDlg::sendUdpPushUrl,this,&GDDCSet::processUdpUrl);
}
GDDCSet::~GDDCSet() {
@ -56,12 +61,14 @@ void GDDCSet::initParam() {
ui->comboBox_playURL1->setEditable(true);
ui->comboBox_streamSource->addItem("地面端");
ui->comboBox_streamSource->addItem("载荷端");
ui->comboBox_streamSource->addItem("局域网");
ui->comboBox_streamSource->setCurrentIndex(0);
// 应急厅指挥平台----->push.uavideo.cn
ui->comboBox_pushURL->addItem(QStringLiteral("应急厅指挥平台"));
// 应急厅铁塔平台----->182.92.130.23
ui->comboBox_pushURL->addItem(QStringLiteral("应急厅铁塔平台"));
ui->comboBox_pushURL->addItem(QStringLiteral("局域网设备平台"));
ui->radioButton_NetCtrlUDP->setChecked(true);
ui->radioButton_NetCtrlTCP->setChecked(false);
@ -118,6 +125,7 @@ void GDDCSet::initParam() {
// 视频连接-显示窗口1-连接
void GDDCSet::on_pushButton_ConnectURL1_clicked() {
ui->pushButton_ConnectURL1->setEnabled(false);
qDebug() << "点击后的拉流地址" << ui->comboBox_playURL1->currentText();
saveDataToLocalIni();
if (ui->pushButton_ConnectURL1->text() == "连接") {
emit SignalStartConnect(1);
@ -403,3 +411,46 @@ void GDDCSet::on_radioButton_clicked() {
ui->uavIDSpinBox->setEnabled(true);
}
}
void GDDCSet::on_comboBox_pushURL_activated(int index)
{
if(index == 2)//下拉列表选中局域网设备推流
{
if(!m_udpPushDlg->isVisible())
{
m_udpPushDlg->show();
}
qDebug()<<"当前索引:"<< index;
m_udpPushDlg->setStateByPushOrPull(udpPushDlg::pushStreamUrl);
}
}
void GDDCSet::processUdpUrl(QString udpUrl, int index)
{
switch(index)
{
case udpPushDlg::pushStreamUrl:
m_pushURL = udpUrl;
break;
case udpPushDlg::pullStreamUrl:
ui->comboBox_playURL1->setCurrentText(udpUrl);
break;
default:
break;
}
}
void GDDCSet::on_comboBox_streamSource_activated(int index)
{
if(index == 2)//下拉列表选中局域网设备拉流
{
if(!m_udpPushDlg->isVisible())
{
m_udpPushDlg->show();
}
qDebug()<<"当前索引:"<< index;
m_udpPushDlg->setStateByPushOrPull(udpPushDlg::pullStreamUrl);
}
}

@ -10,6 +10,8 @@
#include "Src/GDDC/structDefineMyslef.h"
#include "global.h"
#include "udppushdlg.h"
namespace Ui {
class GDDCSet;
}
@ -26,7 +28,8 @@ private:
std::map<int, QString> mapPushURL_yjzh;
std::map<int, QString> mapPushURL_yjtt;
public:
udpPushDlg* m_udpPushDlg;
public:
void initUDPSocket(); // 初始化UDPSocket
void initWindow(); // 初始化窗口
@ -72,6 +75,9 @@ private slots:
void on_uavIDSpinBox_valueChanged(int arg1);
void on_comboBox_streamSource_currentIndexChanged(int index);
void on_radioButton_clicked();
void on_comboBox_pushURL_activated(int index);
void processUdpUrl(QString udpUrl, int index);
void on_comboBox_streamSource_activated(int index);
};
#endif // GDDCSET_H

@ -95,6 +95,8 @@ void GDDCdlg::initWindow() {
// Qt::UniqueConnection);
connect(ui->WgtffmpegVideo, &VideoWidget::sendErrorMessageSignal, this,
&GDDCdlg::showErrorMessage, Qt::UniqueConnection);
connect(m_DlgGDDCSet->m_udpPushDlg,&udpPushDlg::sendErrorMessageSignal,this,
&GDDCdlg::showErrorMessage);
ui->WgtffmpegVideo->setVedioSaveFileDirPath("./Video");
}
@ -522,6 +524,7 @@ void GDDCdlg::startConnectURL1() {
*/
VideoWidget *videoWidget = ui->WgtffmpegVideo;
qDebug() << "当前拉流地址" << m_DlgGDDCSet->m_playURL1;
if (!videoWidget->play(m_DlgGDDCSet->m_playURL1,true)) {
g_notifyManager->notify("获取视频流失败!", "", 2, 3000);
// ui->WgtffmpegVideo->stopPlay();

@ -0,0 +1,87 @@
#include "udppushdlg.h"
#include "ui_udppushdlg.h"
#include <QRegularExpression>
#include <QRegularExpressionValidator>
udpPushDlg::udpPushDlg(QWidget *parent)
: QWidget(parent)
, ui(new Ui::udpPushDlg)
{
ui->setupUi(this);
this->setFixedSize(400,300);
initLineEdit();
QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini";
_configIni = std::make_unique<QSettings>(urlFile, QSettings::IniFormat);
showParam4Ini();
}
udpPushDlg::~udpPushDlg()
{
delete ui;
}
void udpPushDlg::initLineEdit()
{
// 定义正则表达式:允许大写字母、小写字母、数字和特殊符号
QRegularExpression regExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
// 创建验证器
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
QRegularExpression rx("[0-9]+"); // 只允许数字
QRegularExpressionValidator *validator1 = new QRegularExpressionValidator(rx, this);
// 设置验证器
ui->lineEdit->setValidator(validator);
ui->lineEdit_2->setValidator(validator1);
}
void udpPushDlg::showParam4Ini()
{
QString udpPushIp = _configIni->value("UDPPushStream/IP").toString();
int udpPushPort = _configIni->value("UDPPushStream/Port").toInt();
ui->lineEdit->setText(udpPushIp);
ui->lineEdit_2->setText(QString::number(udpPushPort));
}
void udpPushDlg::setStateByPushOrPull(udpUrlType tpye)
{
m_state = tpye;
}
//保存界面IP及端口号参数
void udpPushDlg::saveParam2Ini()
{
_configIni->setValue("UDPPushStream/IP", ui->lineEdit->text());
_configIni->setValue("UDPPushStream/Port", ui->lineEdit_2->text());
}
//点击确定按钮
void udpPushDlg::on_okPushBtn_clicked()
{
if(ui->lineEdit->text().isEmpty())
{
emit sendErrorMessageSignal("输入IP地址不能为空",3);
return;
}
if(ui->lineEdit_2->text().isEmpty())
{
emit sendErrorMessageSignal("输入端口号不能为空",3);
return;
}
if(this->isVisible())
this->hide();
m_udpPushUrl = QString("udp://%1:%2").arg(ui->lineEdit->text()).arg(ui->lineEdit_2->text());
if(m_state == pushStreamUrl)
emit sendUdpPushUrl(m_udpPushUrl, pushStreamUrl);
else if(m_state == pullStreamUrl)
emit sendUdpPushUrl(m_udpPushUrl, pullStreamUrl);
saveParam2Ini();
}

@ -0,0 +1,38 @@
#ifndef UDPPUSHDLG_H
#define UDPPUSHDLG_H
#include <QWidget>
#include <QSettings>
namespace Ui {
class udpPushDlg;
}
class udpPushDlg : public QWidget
{
Q_OBJECT
public:
explicit udpPushDlg(QWidget *parent = nullptr);
~udpPushDlg();
enum udpUrlType{ pullStreamUrl=0, pushStreamUrl=1};
void setStateByPushOrPull(udpUrlType tpye); //设置推拉流状态
private slots:
void on_okPushBtn_clicked();
private:
Ui::udpPushDlg *ui;
QString m_udpPushUrl;//udp推流地址
void initLineEdit();
void saveParam2Ini();
void showParam4Ini();
std::unique_ptr<QSettings> _configIni; //配置文件写入
int m_state = -1; //推拉流状态初始化为-1
signals:
void sendErrorMessageSignal(QString message, int type);
void sendUdpPushUrl(QString udpUrl, int index);
};
#endif // UDPPUSHDLG_H

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>udpPushDlg</class>
<widget class="QWidget" name="udpPushDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>网络设置</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>局域网视频流网络设置</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>57</y>
<width>201</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>113</y>
<width>51</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>端口号:</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>57</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>IP:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>90</x>
<y>113</y>
<width>201</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="okPushBtn">
<property name="geometry">
<rect>
<x>200</x>
<y>169</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,59 @@
#include "udppushdlg.h"
#include "ui_udppushdlg.h"
#include <QRegularExpression>
#include <QRegularExpressionValidator>
udpPushDlg::udpPushDlg(QWidget *parent)
: QWidget(parent)
, ui(new Ui::udpPushDlg)
{
ui->setupUi(this);
this->setFixedSize(400,300);
initLineEdit();
}
udpPushDlg::~udpPushDlg()
{
delete ui;
}
void udpPushDlg::initLineEdit()
{
// 定义正则表达式:允许大写字母、小写字母、数字和特殊符号
QRegularExpression regExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
// 创建验证器
QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this);
QRegularExpression rx("[0-9]+"); // 只允许数字
QRegularExpressionValidator *validator1 = new QRegularExpressionValidator(rx, this);
// 设置验证器
ui->lineEdit->setValidator(validator);
ui->lineEdit_2->setValidator(validator1);
}
//点击确定按钮
void udpPushDlg::on_okPushBtn_clicked()
{
if(ui->lineEdit->text().isEmpty())
{
emit sendErrorMessageSignal("输入IP地址不能为空",3);
return;
}
if(ui->lineEdit_2->text().isEmpty())
{
emit sendErrorMessageSignal("输入端口号不能为空",3);
return;
}
if(this->isVisible())
this->hide();
m_udpPushUrl = QString("udp://%1:%2").arg(ui->lineEdit->text()).arg(ui->lineEdit_2->text());
emit sendUdpPushUrl(m_udpPushUrl, pushStreamUrl);
}

@ -0,0 +1,33 @@
#ifndef UDPPUSHDLG_H
#define UDPPUSHDLG_H
#include <QWidget>
namespace Ui {
class udpPushDlg;
}
class udpPushDlg : public QWidget
{
Q_OBJECT
public:
explicit udpPushDlg(QWidget *parent = nullptr);
~udpPushDlg();
enum udpUrlType{ pullStreamUrl=0, pushStreamUrl=1};
private slots:
void on_okPushBtn_clicked();
private:
Ui::udpPushDlg *ui;
QString m_udpPushUrl;//udp推流地址
void initLineEdit();
signals:
void sendErrorMessageSignal(QString message, int type);
void sendUdpPushUrl(QString url, int index);
};
#endif // UDPPUSHDLG_H

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>udpPushDlg</class>
<widget class="QWidget" name="udpPushDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>网络设置</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>局域网视频流网络设置</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>57</y>
<width>201</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>113</y>
<width>51</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>端口号:</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>57</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>IP:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>90</x>
<y>113</y>
<width>201</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="okPushBtn">
<property name="geometry">
<rect>
<x>200</x>
<y>169</y>
<width>80</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -254,7 +254,7 @@ void PushStream::pushStream(int64_t startTime) {
av_packet_unref(inputPacket);
av_packet_free(&inputPacket);
} else {
QThread::usleep(1000);
av_usleep(1000);
}
}

Loading…
Cancel
Save