diff --git a/Src/GDDC/gddcSet.cpp b/Src/GDDC/gddcSet.cpp index d935778..2f2fe8e 100644 --- a/Src/GDDC/gddcSet.cpp +++ b/Src/GDDC/gddcSet.cpp @@ -158,10 +158,10 @@ void GDDCSet::on_pushButton_pushURL_clicked() { saveDataToLocalIni(); if (ui->pushButton_pushURL->text() == "推送") { emit SignalStartConnect(6); - //ui->pushButton_pushURL->setText("停止推送"); + // ui->pushButton_pushURL->setText("停止推送"); } else { emit SignalStopConnect(6); - //ui->pushButton_pushURL->setText("推送"); + // ui->pushButton_pushURL->setText("推送"); } } @@ -208,11 +208,11 @@ void GDDCSet::saveDataToLocalIni() { ::WritePrivateProfileStringA("光电吊舱-视频连接-显示窗口1", "播放URL", inBuf, strSysIniName); - // m_playURL2 = ui->lineEdit_playURL2->text(); // ba = m_playURL2.toLocal8Bit(); // inBuf = ba.data(); - // ::WritePrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", inBuf, + // ::WritePrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", + // inBuf, // strSysIniName); m_pushURL = ui->lineEdit_pushURL->text(); @@ -239,49 +239,35 @@ void GDDCSet::saveDataToLocalIni() { // break; // } // } -QString GDDCSet::streamTypeToflowType(QString type) -{ - if(type == "RTSP") - { - return "TCP"; - } - else if(type == "RTMP") - { - return "UDP"; - } - else - return "TCP"; +QString GDDCSet::streamTypeToflowType(QString type) { + if (type == "RTSP") { + return "UDP"; + } else if (type == "RTMP") { + return "TCP"; + } else + return "TCP"; } -QString GDDCSet::flowTypeTostreamType(QString type) -{ - if(type == "TCP") - { - return "RTSP"; - } - else if(type == "UDP") - { - return "RTMP"; - } - else - return "RTSP"; +QString GDDCSet::flowTypeTostreamType(QString type) { + if (type == "TCP") { + return "RTMP"; + } else if (type == "UDP") { + return "RTSP"; + } else + return "RTSP"; } -void GDDCSet::setConnectURL1Text(QString param) -{ - ui->pushButton_ConnectURL1->setText(param); +void GDDCSet::setConnectURL1Text(QString param) { + ui->pushButton_ConnectURL1->setText(param); } -void GDDCSet::setConnectURL2Text(QString param) -{ - ui->pushButton_ConnectURL1->setText(param); +void GDDCSet::setConnectURL2Text(QString param) { + ui->pushButton_ConnectURL1->setText(param); } -void GDDCSet::setNetCtrlText(QString param) -{ - ui->pushButton_NetCtrlConnect->setText(param); +void GDDCSet::setNetCtrlText(QString param) { + ui->pushButton_NetCtrlConnect->setText(param); } -void GDDCSet::setPushStreamText(QString param) -{ - ui->pushButton_pushURL->setText(param); +void GDDCSet::setPushStreamText(QString param) { + ui->pushButton_pushURL->setText(param); } diff --git a/Src/ModelCamera/modelcameradlg.cpp b/Src/ModelCamera/modelcameradlg.cpp index e9212d7..f2a08d3 100644 --- a/Src/ModelCamera/modelcameradlg.cpp +++ b/Src/ModelCamera/modelcameradlg.cpp @@ -4,9 +4,9 @@ ModelCameraDlg::ModelCameraDlg(QWidget *parent) : QDialog(parent), ui(new Ui::ModelCameraDlg) { ui->setupUi(this); - ui->videoIPLineEdit->setText( - QStringLiteral("rtmp://liteavapp.qcloud.com/live/" - "liteavdemoplayerstreamid")); // rtsp://192.168.5.70:8554/LIVE + ui->videoIPLineEdit->setText(QStringLiteral( + "rtmp://liteavapp.qcloud.com/live/" + "liteavdemoplayerstreamid")); // rtsp://192.168.5.70:8554/LIVE ui->pushStreamIPEdit->setText( QStringLiteral("rtmp://182.92.130.23/app/stream999")); ui->cameraVideoWidget->setVedioSaveFileDirPath("./3DCameraVideo"); diff --git a/Src/Video/cffmpeg_decode.cpp b/Src/Video/cffmpeg_decode.cpp index 6db2a99..049ef6b 100644 --- a/Src/Video/cffmpeg_decode.cpp +++ b/Src/Video/cffmpeg_decode.cpp @@ -62,25 +62,23 @@ void Cffmpeg_decode::setPushStream(bool bPushStream) { bool Cffmpeg_decode::open_input_file() { if (_url.isEmpty()) return 0; - m_rtsp_transport = _url.left(4) == "rtmp" ? "tcp" : "udp"; + if (!m_bSetRtspTransport) { + m_rtsp_transport = _url.left(4) == "rtmp" ? "tcp" : "udp"; + } + //========================解码============================ AVDictionary *avdic = NULL; - // 以udp方式打开,如果以tcp方式打开将udp替换为tcp - int ret = av_dict_set(&avdic, "rtsp_transport", - m_rtsp_transport.toUtf8().data(), 0); // 如果设置失败,则设置UDP传输 - if (avdic == NULL || ret < 0) { - if (m_rtsp_transport == "tcp") - av_dict_set(&avdic, "rtsp_transport", "udp", 0); - else - av_dict_set(&avdic, "rtsp_transport", "tcp", 0); - } + if (m_rtsp_transport == "udp") + av_dict_set(&avdic, "rtsp_transport", "udp", 0); + else + av_dict_set(&avdic, "rtsp_transport", "tcp", 0); // 设置缓存大小,1080p可将值调大 av_dict_set(&avdic, "buffer_size", "4096000", 0); // 设置超时断开连接时间,单位微秒//listen_timeout // av_dict_set(&avdic, "listen_timeout", "200000", 0); - av_dict_set(&avdic, "stimeout", "2000000", 0); // 设置超时2秒 - av_dict_set(&avdic, "max_delay", "3", 0); // 设置最大时延 + av_dict_set(&avdic, "stimeout", "3000000", 0); // 设置超时3秒 + av_dict_set(&avdic, "max_delay", "300000", 0); // 设置最大时延300ms av_dict_set(&avdic, "tune", "zerolatency", 0); // 实时编码 av_dict_set(&avdic, "preset", "ultrafast", 0); av_dict_set(&avdic, "threads", "auto", 0); // 自动开启线程数 @@ -99,7 +97,7 @@ bool Cffmpeg_decode::open_input_file() { return 0; } // 从输入流中找到第一个视频流 - for (int i = 0; i < inputFormatCtx->nb_streams; i++) { + for (uint i = 0; i < inputFormatCtx->nb_streams; i++) { if (inputFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { videoStreamIndex = i; @@ -166,7 +164,7 @@ bool Cffmpeg_decode::open_input_file() { } // 裸流保存初始化 - // m_saveVideoFlag = openSave(); + m_saveVideoFlag = openSave(); return true; } @@ -247,7 +245,6 @@ void Cffmpeg_decode::run() { first_frame_system_time = av_gettime(); // 系统时间(秒) previous_pts_time = pts_time; } - // 转化为RGB图像并显示 sws_scale(swsCtx, // yuvFrame->data, // @@ -413,4 +410,7 @@ void Cffmpeg_decode::saveDone() { m_saveVideoFlag = false; } -void Cffmpeg_decode::setFlowType(QString param) { m_rtsp_transport = param; } +void Cffmpeg_decode::setFlowType(QString param) { + m_rtsp_transport = param; + m_bSetRtspTransport = true; +}