feat:新增UDP推流人机交互界面
parent
2afb94baac
commit
ef1b56d0db
@ -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>
|
Loading…
Reference in New Issue