feat: 新增吊舱拉流地址生成

video_old
cbwu
parent 94585567e6
commit 33cf0cb360

@ -14,7 +14,7 @@ QMAKE_PROJECT_DEPTH = 0
# QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" # QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"
#程序版本 #程序版本
VERSION = 1.0.0.1219 VERSION = 1.0.0.1009
#程序版本 #程序版本
QMAKE_TARGET_COMPANY = "HTSDFP" QMAKE_TARGET_COMPANY = "HTSDFP"

@ -37,15 +37,17 @@ void GDDCSet::initParam() {
// 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.55.65:554/live/track0"); ui->comboBox_playURL1->addItem(
QStringLiteral("rtsp://192.168.55.65:554/live/track0"));
ui->comboBox_playURL1->setCurrentIndex(0);
// ui->comboBox_playURL1->addItem( // ui->comboBox_playURL1->addItem(
// "rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid"); // "rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid");
ui->comboBox_playURL1->setEditable(true); ui->comboBox_playURL1->setEditable(true);
ui->comboBox_streamSource->addItem("地面端");
ui->comboBox_streamSource->addItem("载荷端");
ui->comboBox_streamSource->setCurrentIndex(0);
ui->lineEdit_pushURL->setText( ui->lineEdit_pushURL->setText(QStringLiteral("-1"));
QStringLiteral("rtmp://182.92.130.23/app/stream99"));
/*"rtsp://192.168.1.160:554/live/track0"*/
/*"rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid"*/
ui->radioButton_NetCtrlUDP->setChecked(true); ui->radioButton_NetCtrlUDP->setChecked(true);
ui->radioButton_NetCtrlTCP->setChecked(false); ui->radioButton_NetCtrlTCP->setChecked(false);
@ -62,10 +64,10 @@ void GDDCSet::initParam() {
m_FlowType = streamTypeToflowType(QString::fromUtf8(inBuf)); m_FlowType = streamTypeToflowType(QString::fromUtf8(inBuf));
ui->comboBox_streamType->setCurrentText(flowTypeTostreamType(m_FlowType)); ui->comboBox_streamType->setCurrentText(flowTypeTostreamType(m_FlowType));
::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口1", "播放URL", "-1", // ::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口1", "播放URL", "-1",
inBuf, 100, strSysIniName); // inBuf, 100, strSysIniName);
m_playURL1 = QString::fromUtf8(inBuf); // m_playURL1 = QString::fromUtf8(inBuf);
ui->comboBox_playURL1->setCurrentText(m_playURL1); // ui->comboBox_playURL1->setCurrentText(m_playURL1);
// ::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", "-1", // ::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", "-1",
// inBuf, 100, strSysIniName); // inBuf, 100, strSysIniName);
@ -75,7 +77,7 @@ void GDDCSet::initParam() {
::GetPrivateProfileStringA("光电吊舱-推流", "推流URL", "-1", inBuf, 100, ::GetPrivateProfileStringA("光电吊舱-推流", "推流URL", "-1", inBuf, 100,
strSysIniName); strSysIniName);
m_pushURL = QString::fromUtf8(inBuf); m_pushURL = QString::fromUtf8(inBuf);
ui->lineEdit_pushURL->setText(m_pushURL); // ui->lineEdit_pushURL->setText(m_pushURL);
::GetPrivateProfileStringA("光电吊舱-网络控制", "远端IP", "-1", inBuf, 100, ::GetPrivateProfileStringA("光电吊舱-网络控制", "远端IP", "-1", inBuf, 100,
strSysIniName); strSysIniName);
@ -106,6 +108,7 @@ void GDDCSet::on_pushButton_ConnectURL1_clicked() {
emit SignalStopConnect(1); emit SignalStopConnect(1);
ui->pushButton_ConnectURL1->setText("连接"); ui->pushButton_ConnectURL1->setText("连接");
} }
// this->on_pushButton_pushURL_clicked();
} }
// 视频连接-显示窗口2-连接 // 视频连接-显示窗口2-连接
@ -146,7 +149,6 @@ void GDDCSet::on_pushButton_NetCtrlConnect_clicked() {
} else { } else {
emit SignalStartConnect(5); emit SignalStartConnect(5);
} }
ui->pushButton_NetCtrlConnect->setText("断开"); ui->pushButton_NetCtrlConnect->setText("断开");
} else { } else {
emit SignalStopConnect(4); emit SignalStopConnect(4);
@ -226,6 +228,13 @@ void GDDCSet::saveDataToLocalIni() {
m_playURL1 = ui->comboBox_playURL1->currentText(); m_playURL1 = ui->comboBox_playURL1->currentText();
} }
void GDDCSet::initPullURL(QString remoteIP) {
if (!remoteIP.isEmpty()) {
m_playURL1 = "rtsp://" + remoteIP + ":554/live/track0";
}
ui->comboBox_playURL1->setCurrentText(m_playURL1);
}
// //流类型 // //流类型
// void GDDCSet::on_comboBox_streamType_currentIndexChanged(int index) // void GDDCSet::on_comboBox_streamType_currentIndexChanged(int index)
// { // {
@ -276,12 +285,36 @@ void GDDCSet::setPushStreamText(QString param) {
// uavID值改变事件 // uavID值改变事件
void GDDCSet::on_uavIDSpinBox_valueChanged(int arg1) { void GDDCSet::on_uavIDSpinBox_valueChanged(int arg1) {
QString streamSource = ui->comboBox_streamSource->currentText();
int uavID = arg1; int uavID = arg1;
auto iter = g_mapAppName.find(uavID); auto iter = g_mapAppName.find(uavID);
if (iter != g_mapAppName.end()) { if (iter != g_mapAppName.end()) {
QString pushURL = if ("地面端" == streamSource) {
generatePushURL(uavID, QString::fromStdString(iter->second)); QString pushURL =
ui->lineEdit_pushURL->setText(pushURL); generatePushURL(uavID, QString::fromStdString(iter->second));
ui->lineEdit_pushURL->setText(pushURL);
} else {
QString pullURL =
generatePullURL(uavID, QString::fromStdString(iter->second));
ui->comboBox_playURL1->setItemText(0, pullURL);
}
} else { } else {
} }
} }
// 切换拉流来源
void GDDCSet::on_comboBox_streamSource_currentIndexChanged(int index) {
if (0 == index) {
ui->pushButton_pushURL->setEnabled(true);
ui->comboBox_playURL1->setItemText(0, m_playURL1);
} else if (1 == index) {
ui->pushButton_pushURL->setEnabled(false);
int uavID = ui->uavIDSpinBox->value();
auto iter = g_mapAppName.find(uavID);
if (iter != g_mapAppName.end()) {
QString pullURL =
generatePullURL(uavID, QString::fromStdString(iter->second));
ui->comboBox_playURL1->setItemText(0, pullURL);
}
}
}

@ -23,10 +23,11 @@ private:
Ui::GDDCSet *ui; Ui::GDDCSet *ui;
public: public:
void initUDPSocket(); // 初始化UDPSocket void initUDPSocket(); // 初始化UDPSocket
void initWindow(); // 初始化窗口 void initWindow(); // 初始化窗口
void initParam(); // 初始化参数 void initParam(); // 初始化参数
void saveDataToLocalIni(); // 保存数据至本地ini文件 void saveDataToLocalIni(); // 保存数据至本地ini文件
void initPullURL(QString remoteIP);
QByteArray m_configIniPath; // ini配置文件路径 QByteArray m_configIniPath; // ini配置文件路径
QString m_playURL1; // 光电吊舱-视频连接-显示窗口1-URL地址 QString m_playURL1; // 光电吊舱-视频连接-显示窗口1-URL地址
@ -34,7 +35,6 @@ public:
QString m_pushURL; // 光电吊舱-推流URL地址 QString m_pushURL; // 光电吊舱-推流URL地址
MyPairNetwork m_myPairNetwork; // 网络通信结构体 MyPairNetwork m_myPairNetwork; // 网络通信结构体
QString m_FlowType; // 流类型 QString m_FlowType; // 流类型
QString streamTypeToflowType(QString); QString streamTypeToflowType(QString);
QString flowTypeTostreamType(QString); QString flowTypeTostreamType(QString);
@ -63,6 +63,7 @@ private slots:
void on_pushButton_pushURL_clicked(); // 推流 void on_pushButton_pushURL_clicked(); // 推流
// void on_comboBox_streamType_currentIndexChanged(int index); // void on_comboBox_streamType_currentIndexChanged(int index);
void on_uavIDSpinBox_valueChanged(int arg1); void on_uavIDSpinBox_valueChanged(int arg1);
void on_comboBox_streamSource_currentIndexChanged(int index);
}; };
#endif // GDDCSET_H #endif // GDDCSET_H

@ -29,14 +29,14 @@
<string>视频连接</string> <string>视频连接</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>500</x> <x>510</x>
<y>60</y> <y>60</y>
<width>61</width> <width>51</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
@ -85,7 +85,7 @@
<rect> <rect>
<x>80</x> <x>80</x>
<y>60</y> <y>60</y>
<width>411</width> <width>301</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
@ -194,7 +194,7 @@
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>500</x> <x>510</x>
<y>100</y> <y>100</y>
<width>61</width> <width>61</width>
<height>21</height> <height>21</height>
@ -207,20 +207,43 @@
<widget class="QSpinBox" name="uavIDSpinBox"> <widget class="QSpinBox" name="uavIDSpinBox">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>560</x> <x>570</x>
<y>100</y> <y>100</y>
<width>61</width> <width>51</width>
<height>23</height> <height>23</height>
</rect> </rect>
</property> </property>
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> <enum>QAbstractSpinBox::NoButtons</enum>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>255</number> <number>255</number>
</property> </property>
<property name="stepType"> <property name="stepType">
<enum>QAbstractSpinBox::StepType::DefaultStepType</enum> <enum>QAbstractSpinBox::DefaultStepType</enum>
</property>
</widget>
<widget class="QLabel" name="label_16">
<property name="geometry">
<rect>
<x>390</x>
<y>60</y>
<width>51</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>流来源:</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_streamSource">
<property name="geometry">
<rect>
<x>440</x>
<y>60</y>
<width>61</width>
<height>23</height>
</rect>
</property> </property>
</widget> </widget>
</widget> </widget>
@ -237,7 +260,7 @@
<string>串口控制</string> <string>串口控制</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<widget class="QPushButton" name="pushButton_serialControlConnect"> <widget class="QPushButton" name="pushButton_serialControlConnect">
<property name="geometry"> <property name="geometry">
@ -325,7 +348,7 @@
<string>网络控制</string> <string>网络控制</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<widget class="QPushButton" name="pushButton_NetCtrlConnect"> <widget class="QPushButton" name="pushButton_NetCtrlConnect">
<property name="geometry"> <property name="geometry">

@ -339,6 +339,13 @@ void GDDCdlg::resizeUI() {
ui->pushButShowStatePage->raise(); ui->pushButShowStatePage->raise();
} }
void GDDCdlg::setGlobalSetMap(
std::unordered_map<QString, settingStruct> &gSetMap) {
if (m_DlgGDDCSet) {
m_DlgGDDCSet->initPullURL(gSetMap["光电吊舱"].net.remoteIp);
}
}
// 定时器处理 // 定时器处理
void GDDCdlg::GDDCControlTimeOut() { void GDDCdlg::GDDCControlTimeOut() {
if (m_GDDCCmdDlg->sendTimes > 0) { // 优先发送次数指令 if (m_GDDCCmdDlg->sendTimes > 0) { // 优先发送次数指令

@ -22,8 +22,8 @@
// #include "ui_gddcStateInfo.h" //吊舱状态信息显示对话框 // #include "ui_gddcStateInfo.h" //吊舱状态信息显示对话框
// #include "ui_gddcSet.h" // #include "ui_gddcSet.h"
#include "QProcess" #include "QProcess"
#include <QThread>
#include <QMessageBox> #include <QMessageBox>
#include <QThread>
#define cmdLength 44 #define cmdLength 44
namespace Ui { namespace Ui {
@ -49,6 +49,7 @@ public:
void initParam(); // 初始化参数 void initParam(); // 初始化参数
void initSignalSlot(); // 初始化信号与槽 void initSignalSlot(); // 初始化信号与槽
void resizeUI(); // 重新设置布局 void resizeUI(); // 重新设置布局
void setGlobalSetMap(std::unordered_map<QString, settingStruct> &gSetMap);
GDDCSet *m_DlgGDDCSet; // 光电吊舱设置对话框 GDDCSet *m_DlgGDDCSet; // 光电吊舱设置对话框
GDDCCmdDlg *m_GDDCCmdDlg; // 光电吊舱控制对话框 GDDCCmdDlg *m_GDDCCmdDlg; // 光电吊舱控制对话框
@ -64,7 +65,6 @@ public:
quint16 localPort; // 本地port quint16 localPort; // 本地port
QProcess *process; // 执行CMD QProcess *process; // 执行CMD
QThread workerThread; // 线程 QThread workerThread; // 线程
// bool eventFilter(QObject *,QEvent *); //事件过滤器 // bool eventFilter(QObject *,QEvent *); //事件过滤器
void mousePressEvent(QMouseEvent *event); // 事件过滤器 void mousePressEvent(QMouseEvent *event); // 事件过滤器
void mouseMoveEvent(QMouseEvent *event); // 事件过滤器 void mouseMoveEvent(QMouseEvent *event); // 事件过滤器

@ -155,7 +155,8 @@ int FFmpegPushStream::pushStream(AVPacket *pkt, int frm_cnt, int64_t startTime,
* @brief * @brief
*/ */
void FFmpegPushStream::stopPush() { void FFmpegPushStream::stopPush() {
av_write_trailer(outputFormatCtx); if (mInitStatus)
av_write_trailer(outputFormatCtx);
// 关闭输出 // 关闭输出
if (outputFormatCtx && !(outputFormatCtx->flags & AVFMT_NOFILE)) { if (outputFormatCtx && !(outputFormatCtx->flags & AVFMT_NOFILE)) {
avio_close(outputFormatCtx->pb); avio_close(outputFormatCtx->pb);

@ -2,7 +2,7 @@
global::global() {} global::global() {}
QString g_SoftwareVersion = "版本号V1.0.0.0919"; QString g_SoftwareVersion = "版本号V1.0.0.1009";
QColor g_themeColor(51, 51, 51); QColor g_themeColor(51, 51, 51);
QString g_PushBtnStyle = /**正常情况下样式**/ QString g_PushBtnStyle = /**正常情况下样式**/
@ -203,3 +203,40 @@ QString generatePushURL(int uavID, QString appName, QString uavName,
} }
std::map<int, std::string> g_mapAppName; std::map<int, std::string> g_mapAppName;
/**
* @brief
* @param uavID: ID
* @param appName: app
* @param uavName: 981cs
* @param clientID: ID01
* @param pullDomain:
* @param expireTime: 1h
* @param pullKey: Key
* @return
*/
QString generatePullURL(int uavID, QString appName, QString uavName,
int clientID, QString pullDomain, long expireTime,
QString pullKey) {
QString rtmpUrl = "";
QString clientName = "";
if (0 == clientID) {
clientName = "gcs"; // 地面端
} else {
clientName = "uav"; // 载荷端
}
QString streamName =
uavName + "_" + QString::number(uavID) + "_" + clientName;
if (pullKey == "") {
rtmpUrl = "rtmp://" + pullDomain + "/" + appName + "/" + streamName;
} else {
// 计算鉴权串
long timeStamp = QDateTime::currentMSecsSinceEpoch() / 1000 + expireTime;
QString stringToMd5 = "/" + appName + "/" + streamName + "-" +
QString::number(timeStamp) + "-0-0-" + pullKey;
QString authKey = calculateMD5(stringToMd5);
rtmpUrl = "rtmp://" + pullDomain + "/" + appName + "/" + streamName +
"?auth_key=" + QString::number(timeStamp) + "-0-0-" + authKey;
}
return rtmpUrl;
}

@ -37,7 +37,7 @@ extern QString calculateMD5(const QString &str);
* @param uavName: 981cs * @param uavName: 981cs
* @param clientID: ID01 * @param clientID: ID01
* @param pushDomain: * @param pushDomain:
* @param appName: app * @param appName
* @param expireTime: 1h * @param expireTime: 1h
* @param pushKey: Key * @param pushKey: Key
* @return * @return
@ -45,8 +45,25 @@ extern QString calculateMD5(const QString &str);
extern QString generatePushURL(int uavID, QString appName = "nmyj", extern QString generatePushURL(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 0, QString uavName = "981cs", int clientID = 0,
QString pushDomain = "push.htsdfp.com", QString pushDomain = "push.htsdfp.com",
long expireTime = 4 * 3600, long expireTime = 6 * 3600,
QString pushKey = "2G2Fu4MXO9D9Hrs7"); QString pushKey = "ZRjGVcPYGhKib0rdgH");
/**
* @brief
* @param uavID: ID
* @param appName: app
* @param uavName: 981cs
* @param clientID: ID01
* @param pullDomain:
* @param expireTime: 1h
* @param pullKey: Key
* @return
*/
extern QString generatePullURL(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 1,
QString pullDomain = "play.htsdfp.com",
long expireTime = 6 * 3600,
QString pullKey = "HDaMVkLnIcr0mGhV8d");
extern std::map<int, std::string> g_mapAppName; extern std::map<int, std::string> g_mapAppName;

@ -84,6 +84,7 @@ void MainWindow::initWindow() {
// 使用类中的get方法获取配置文件中的IP // 使用类中的get方法获取配置文件中的IP
m_allSetMap = m_HomePagedlg->settingWidget->getAllParam(); m_allSetMap = m_HomePagedlg->settingWidget->getAllParam();
m_GDDCdlg->setGlobalSetMap(m_allSetMap);
qDebug() << "=============设备配置================"; qDebug() << "=============设备配置================";
qDebug() << "光电吊舱------"; qDebug() << "光电吊舱------";
qDebug() << "远端ip" << m_allSetMap["光电吊舱"].net.remoteIp; qDebug() << "远端ip" << m_allSetMap["光电吊舱"].net.remoteIp;

Loading…
Cancel
Save