feat: 新增光电吊舱推流地址生成

video_old
cbwu 6 months ago
parent 21b58b8502
commit 94585567e6

@ -273,3 +273,15 @@ void GDDCSet::setNetCtrlText(QString param) {
void GDDCSet::setPushStreamText(QString param) {
ui->pushButton_pushURL->setText(param);
}
// uavID值改变事件
void GDDCSet::on_uavIDSpinBox_valueChanged(int arg1) {
int uavID = arg1;
auto iter = g_mapAppName.find(uavID);
if (iter != g_mapAppName.end()) {
QString pushURL =
generatePushURL(uavID, QString::fromStdString(iter->second));
ui->lineEdit_pushURL->setText(pushURL);
} else {
}
}

@ -2,6 +2,7 @@
#define GDDCSET_H
#include "Src/GDDC/structDefineMyslef.h"
#include "global.h"
#include <QByteArray>
#include <QDir>
#include <QWidget>
@ -32,12 +33,11 @@ public:
QString m_playURL2; // 光电吊舱-视频连接-显示窗口2-URL地址
QString m_pushURL; // 光电吊舱-推流URL地址
MyPairNetwork m_myPairNetwork; // 网络通信结构体
QString m_FlowType; // 流类型
QString m_FlowType; // 流类型
QString streamTypeToflowType(QString);
QString flowTypeTostreamType(QString);
void setConnectURL1Text(QString);
void setConnectURL2Text(QString);
void setNetCtrlText(QString);
@ -61,7 +61,8 @@ private slots:
void on_pushButton_serialControlConnect_clicked(); // 串口控制-连接
void on_pushButton_NetCtrlConnect_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);
};
#endif // GDDCSET_H

@ -34,7 +34,7 @@
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>440</x>
<x>500</x>
<y>60</y>
<width>61</width>
<height>21</height>
@ -47,9 +47,9 @@
<widget class="QComboBox" name="comboBox_streamType">
<property name="geometry">
<rect>
<x>510</x>
<x>560</x>
<y>60</y>
<width>72</width>
<width>61</width>
<height>23</height>
</rect>
</property>
@ -70,7 +70,7 @@
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>20</x>
<x>10</x>
<y>60</y>
<width>71</width>
<height>21</height>
@ -83,9 +83,9 @@
<widget class="QComboBox" name="comboBox_playURL1">
<property name="geometry">
<rect>
<x>90</x>
<x>80</x>
<y>60</y>
<width>331</width>
<width>411</width>
<height>23</height>
</rect>
</property>
@ -93,9 +93,9 @@
<widget class="QPushButton" name="pushButton_ConnectURL1">
<property name="geometry">
<rect>
<x>600</x>
<x>630</x>
<y>60</y>
<width>80</width>
<width>61</width>
<height>23</height>
</rect>
</property>
@ -155,7 +155,7 @@
<widget class="QLabel" name="label_14">
<property name="geometry">
<rect>
<x>20</x>
<x>10</x>
<y>100</y>
<width>71</width>
<height>21</height>
@ -168,19 +168,22 @@
<widget class="QLineEdit" name="lineEdit_pushURL">
<property name="geometry">
<rect>
<x>90</x>
<x>80</x>
<y>100</y>
<width>491</width>
<width>411</width>
<height>23</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton_pushURL">
<property name="geometry">
<rect>
<x>600</x>
<x>630</x>
<y>100</y>
<width>80</width>
<width>61</width>
<height>23</height>
</rect>
</property>
@ -188,6 +191,38 @@
<string>推送</string>
</property>
</widget>
<widget class="QLabel" name="label_15">
<property name="geometry">
<rect>
<x>500</x>
<y>100</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>飞机ID:</string>
</property>
</widget>
<widget class="QSpinBox" name="uavIDSpinBox">
<property name="geometry">
<rect>
<x>560</x>
<y>100</y>
<width>61</width>
<height>23</height>
</rect>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="stepType">
<enum>QAbstractSpinBox::StepType::DefaultStepType</enum>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">

@ -154,3 +154,52 @@ uint16_t calCRC16(const uint8_t *cpu8Data, uint16_t u16Len) {
}
return u16CRC;
}
/**
* @brief MD5
* @param str
* @return MD5
*/
QString calculateMD5(const QString &str) {
QByteArray hash =
QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5);
return hash.toHex();
}
/**
* @brief
* @param uavID: ID
* @param uavName: 981cs
* @param clientID: ID01
* @param pushDomain:
* @param appName: app
* @param expireTime: 1h
* @return
*/
QString generatePushURL(int uavID, QString appName, QString uavName,
int clientID, QString pushDomain, long expireTime,
QString pushKey) {
QString clientName = "";
if (0 == clientID) {
clientName = "gcs"; // 地面端
} else {
clientName = "uav"; // 载荷端
}
QString streamName =
uavName + "_" + QString::number(uavID) + "_" + clientName;
QString pushURL = "";
if (pushKey == "") {
pushURL = "rtmp://" + pushDomain + "/" + appName + "/" + streamName;
} else {
// 计算鉴权串
long timeStamp = QDateTime::currentMSecsSinceEpoch() / 1000 + expireTime;
QString stringToMd5 = "/" + appName + "/" + streamName + "-" +
QString::number(timeStamp) + "-0-0-" + pushKey;
QString authKey = calculateMD5(stringToMd5);
pushURL = "rtmp://" + pushDomain + "/" + appName + "/" + streamName +
"?auth_key=" + QString::number(timeStamp) + "-0-0-" + authKey;
}
return pushURL;
}
std::map<int, std::string> g_mapAppName;

@ -2,8 +2,11 @@
#define GLOBAL_H
#include <QColor>
#include <QCryptographicHash>
#include <QDateTime>
#include <map>
extern QString g_SoftwareVersion; //软件版本号
extern QString g_SoftwareVersion; // 软件版本号
/*******************系统颜色***************************************/
extern QColor g_themeColor;
@ -21,10 +24,35 @@ extern QString g_ToolBtnSelStyle;
*/
extern uint16_t calCRC16(const uint8_t *cpu8Data, uint16_t u16Len);
class global
{
/**
* @brief MD5
* @param str
* @return MD5
*/
extern QString calculateMD5(const QString &str);
/**
* @brief
* @param uavID: ID
* @param uavName: 981cs
* @param clientID: ID01
* @param pushDomain:
* @param appName: app
* @param expireTime: 1h
* @param pushKey: Key
* @return
*/
extern QString generatePushURL(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 0,
QString pushDomain = "push.htsdfp.com",
long expireTime = 4 * 3600,
QString pushKey = "2G2Fu4MXO9D9Hrs7");
extern std::map<int, std::string> g_mapAppName;
class global {
public:
global();
global();
};
#endif // GLOBAL_H

@ -34,6 +34,8 @@ MainWindow::MainWindow(QWidget *parent)
QString appDir = QCoreApplication::applicationDirPath() + "/app";
qDebug() << "Open file fail " << appDir;
initUAVIDMap();
}
MainWindow::~MainWindow() {
@ -357,3 +359,14 @@ void MainWindow::changeBtnColor(int num) {
break;
}
}
/**
* @brief UAVIDAPPName
*/
void MainWindow::initUAVIDMap() {
g_mapAppName[5] = "nmyj";
g_mapAppName[7] = "nmyj";
for (int i = 8; i < 13; ++i) {
g_mapAppName[i] = "jsyj";
}
}

@ -74,5 +74,11 @@ private:
public:
void changeBtnColor(int num);
private:
/**
* @brief UAVIDAPPName
*/
void initUAVIDMap();
};
#endif // MAINWINDOW_H

Loading…
Cancel
Save