feat: 光电吊舱新增公司平台推流地址

video_old
cbwu
parent 112e3c499c
commit f499648215

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

@ -50,7 +50,8 @@ void GDDCSet::initParam() {
ui->comboBox_streamSource->addItem("载荷端");
ui->comboBox_streamSource->setCurrentIndex(0);
ui->lineEdit_pushURL->setText(QStringLiteral("-1"));
ui->comboBox_pushURL->addItem(QStringLiteral("-1"));
ui->comboBox_pushURL->addItem(QStringLiteral("-1"));
ui->radioButton_NetCtrlUDP->setChecked(true);
ui->radioButton_NetCtrlTCP->setChecked(false);
@ -222,7 +223,7 @@ void GDDCSet::saveDataToLocalIni() {
// inBuf,
// strSysIniName);
m_pushURL = ui->lineEdit_pushURL->text();
m_pushURL = ui->comboBox_pushURL->currentText();
ba = m_pushURL.toLocal8Bit();
inBuf = ba.data();
::WritePrivateProfileStringA("光电吊舱-推流", "推流URL", inBuf,
@ -295,7 +296,10 @@ void GDDCSet::on_uavIDSpinBox_valueChanged(int arg1) {
if ("地面端" == streamSource) {
QString pushURL =
generatePushURL(uavID, QString::fromStdString(iter->second));
ui->lineEdit_pushURL->setText(pushURL);
QString pushURL2 =
generatePushURL2(uavID, QString::fromStdString(iter->second));
ui->comboBox_pushURL->setItemText(0, pushURL);
ui->comboBox_pushURL->setItemText(1, pushURL2);
} else {
QString pullURL =
generatePullURL(uavID, QString::fromStdString(iter->second));

@ -174,19 +174,6 @@
<string>推流地址:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_pushURL">
<property name="geometry">
<rect>
<x>80</x>
<y>100</y>
<width>421</width>
<height>23</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton_pushURL">
<property name="geometry">
<rect>
@ -255,6 +242,16 @@
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBox_pushURL">
<property name="geometry">
<rect>
<x>80</x>
<y>100</y>
<width>421</width>
<height>23</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">

@ -23,7 +23,7 @@
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,1,1,1,2,1">
<property name="spacing">
@ -44,7 +44,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -67,7 +67,7 @@
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
<number>12</number>
</property>
<property name="rightMargin">
<number>4</number>
@ -192,7 +192,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -221,7 +221,7 @@
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
<number>12</number>
</property>
<property name="rightMargin">
<number>4</number>
@ -400,7 +400,7 @@
</size>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="decimals">
<number>1</number>
@ -412,7 +412,7 @@
<double>25.000000000000000</double>
</property>
<property name="stepType">
<enum>QAbstractSpinBox::StepType::DefaultStepType</enum>
<enum>QAbstractSpinBox::DefaultStepType</enum>
</property>
</widget>
</item>
@ -434,7 +434,7 @@
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
<number>12</number>
</property>
<property name="rightMargin">
<number>4</number>
@ -620,7 +620,7 @@
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
<number>12</number>
</property>
<property name="rightMargin">
<number>4</number>
@ -631,7 +631,7 @@
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="2,3,2,3">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>5</number>
@ -941,7 +941,7 @@
<string>ISO</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
@ -1276,7 +1276,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1304,7 +1304,7 @@
}</string>
</property>
<property name="frameShape">
<enum>QFrame::Shape::Box</enum>
<enum>QFrame::Box</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">

@ -83,10 +83,11 @@ bool Cffmpeg_decode::open_input_file() {
av_dict_set(&avdic, "buffer_size", "4096000", 0);
// 设置超时断开连接时间,单位微秒//listen_timeout
// av_dict_set(&avdic, "listen_timeout", "200000", 0);
// 在尝试连接到一个流或网络资源时,等待的最长时间。如果在这个时间内无法建立连接,就会返回超时错误
av_dict_set(&avdic, "stimeout", "5000000", 0); // 设置超时5秒
// av_dict_set(&avdic, "max_delay", "300000", 0); // 设置最大时延300ms
av_dict_set(&avdic, "max_delay", "300000", 0); // 设置最大时延300ms
av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码
av_dict_set(&avdic, "preset", "faster", 0); // ultrafast
av_dict_set(&avdic, "preset", "ultrafast", 0); // faster
av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数
// 设置最大重试时间为1s,解决avformat_open_input打开空流时间过长问题
av_dict_set(&avdic, "max_interleave_delta", "1000000", 0);
@ -94,9 +95,10 @@ bool Cffmpeg_decode::open_input_file() {
// av_dict_set(&avdic, "reconnect", "1", 0); // 开启自动重连
// av_dict_set(&avdic, "reconnect_streamed", "1", 0); // 对于流媒体自动重连
av_dict_set(&avdic, "reconnect_delay_max", "5",
0); // 最大重连延时 5 秒f'f'f'f'f'f'f'f'f'f'f
0); // 最大重连延时 5 秒
// av_dict_set(&avdic, "rtsp_flags", "prefer_tcp", 0); // 保持TCP连接
// av_dict_set(&avdic, "timeout", "500000", 0); // 超时时间设置为500ms
// av_dict_set(&avdic, "timeout", "8000000",
// 0); // 超时时间包括连接和数据传输的时间设置为5s
// av_dict_set(&avdic, "probesize", "50000000", 0); // 增加探针大小1MB
// av_dict_set(&avdic, "analyzeduration", "5000000", 0); //
// av_dict_set(&avdic, "keepalive", "1", 0);
@ -323,10 +325,11 @@ void Cffmpeg_decode::run() {
double elapsed_system_time = av_gettime() - first_frame_system_time;
// 计算需要等待的时间(us)
double wait_time = elapsed_pts_time - elapsed_system_time;
// qDebug() << "pull stream sleep time:"
// << QString::number(wait_time / 1000.0);
if (wait_time > 0) {
// av_usleep(wait_time); // 延时以同步 PTS
qDebug() << "pull stream sleep time:"
<< QString::number(wait_time / 1000.0);
if (wait_time > 0 && bPushStreamFlag) {
av_usleep(wait_time); // 延时以同步 PTS
// sleepMsec(wait_time);
}
// 更新 previous_pts_time 为当前帧的 PTS
previous_pts_time = pts_time;

@ -2,6 +2,7 @@
#define CFFMPEG_DECODE_H
#include "ffmpeginclude.h"
#include "global.h"
#include <QCoreApplication>
#include <QDateTime>
#include <QDebug>

@ -144,10 +144,15 @@ int FFmpegPushStream::pushStream(AVPacket *pkt, int frm_cnt, int64_t startTime,
int64_t streamTime = pts_time - firstDts; // 计算帧的相对时间
auto now_time = av_gettime() - startTime; // 获取差值
int64_t delay = streamTime - now_time;
if (delay > 0) {
qDebug() << "****************PushStream sleep time:"
<< QString::number(delay / 1000);
delay = delay < MAXDELAY ? delay : MAXDELAY;
if (delay >= 0) {
// qDebug() << "****************PushStream sleep time:"
// << QString::number(delay / 1000);
av_usleep(delay);
// sleepMsec(delay);
} else {
// av_packet_unref(pkt);
// return 1;
}
// 计算延时后,重新指定时间戳
@ -175,9 +180,9 @@ int FFmpegPushStream::pushStream(AVPacket *pkt, int frm_cnt, int64_t startTime,
pkt->stream_index = 0;
int ret = av_interleaved_write_frame(outputFormatCtx, pkt);
if (ret < 0) {
// if (ret == -10053) {
// qDebug() << "网络不稳定";
// }
if (ret == -10053) {
qDebug() << "网络不稳定";
}
// if (ret == AVERROR(EPIPE) || ret == AVERROR(ECONNRESET)) {
// qDebug() << "网络不稳定1";
// }

@ -2,6 +2,7 @@
#define FFMPEGPUSHSTREAM_H
#include "ffmpeginclude.h"
#include "global.h"
#include <QDebug>
#include <QObject>
@ -24,6 +25,7 @@ private:
bool mInitStatus = false;
int64_t startTime;
int MAXCONNECT = 12;
int MAXDELAY = 40000; // 最大休眠时间40ms
public slots:
int pushStream(AVPacket *pkt, int frm_cnt, int64_t startTime,
int64_t firstDts);

@ -4,6 +4,7 @@
#include "cffmpeg_decode.h"
#include "ffmpeginclude.h"
#include "ffmpegpushstream.h"
#include "global.h"
#include <QCoreApplication>
#include <QDebug>
#include <QDir>

@ -2,7 +2,7 @@
global::global() {}
QString g_SoftwareVersion = "版本号V1.0.2.1024";
QString g_SoftwareVersion = "版本号V1.0.2.1_20241106";
QColor g_themeColor(51, 51, 51);
QString g_PushBtnStyle = /**正常情况下样式**/
@ -240,3 +240,38 @@ QString generatePullURL(int uavID, QString appName, QString uavName,
}
return rtmpUrl;
}
/**
* @brief
* @param msec
*/
void sleepMsec(int msec) {
if (msec <= 0)
return;
QEventLoop loop; // 定义一个新的事件循环
QTimer::singleShot(
msec, &loop, SLOT(quit())); // 创建单次定时器,槽函数为事件循环的退出函数
loop.exec(); // 事件循环开始执行,程序会卡在这里,直到定时时间到,本循环被退出
}
/**
* @brief
* @param uavID:ID
* @param appName:
* @param uavName:981cs
* @return
*/
QString generatePushURL2(int uavID, QString appName, QString uavName,
int clientID, QString pushDomain) {
QString rtmpUrl = "";
QString clientName = "";
if (0 == clientID) {
clientName = "gcs"; // 地面端
} else {
clientName = "uav"; // 载荷端
}
QString streamName =
uavName + "_" + QString::number(uavID) + "_" + clientName;
rtmpUrl = "rtmp://" + pushDomain + "/" + appName + "/" + streamName;
return rtmpUrl;
}

@ -4,6 +4,8 @@
#include <QColor>
#include <QCryptographicHash>
#include <QDateTime>
#include <QEventLoop>
#include <QTimer>
#include <map>
extern QString g_SoftwareVersion; // 软件版本号
@ -48,6 +50,19 @@ extern QString generatePushURL(int uavID, QString appName = "nmyj",
long expireTime = 6 * 3600,
QString pushKey = "ZRjGVcPYGhKib0rdgH");
/**
* @brief
* @param uavID:ID
* @param clientID: ID01
* @param appName:
* @param uavName:981cs
* @param pushDomain:
* @return
*/
extern QString generatePushURL2(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 0,
QString pushDomain = "182.92.130.23");
/**
* @brief
* @param uavID: ID
@ -60,13 +75,19 @@ extern QString generatePushURL(int uavID, QString appName = "nmyj",
* @return
*/
extern QString generatePullURL(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 1,
QString uavName = "981cs", int clientID = 0,
QString pullDomain = "play.uavideo.cn",
long expireTime = 6 * 3600,
QString pullKey = "HDaMVkLnIcr0mGhV8d");
extern std::map<int, std::string> g_mapAppName;
/**
* @brief
* @param msec
*/
void sleepMsec(int msec);
class global {
public:
global();

Loading…
Cancel
Save