From 9c0fb9e6761bbf838fe9196df09542e6989db5b4 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 19 Jul 2019 11:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B9:?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=9B=B4=E6=8E=A5rtsp=E6=8B=89=E6=B5=81?= =?UTF-8?q?=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/config.cpp | 2 ++ src/Common/config.h | 7 +++++++ src/Player/PlayerProxy.cpp | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 0e19df23..42aedb2d 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -161,11 +161,13 @@ namespace Rtsp { const string kAuthBasic = RTSP_FIELD"authBasic"; const string kHandshakeSecond = RTSP_FIELD"handshakeSecond"; const string kKeepAliveSecond = RTSP_FIELD"keepAliveSecond"; +const string kDirectProxy = RTSP_FIELD"directProxy";; onceToken token([](){ //默认Md5方式认证 mINI::Instance()[kAuthBasic] = 0; mINI::Instance()[kHandshakeSecond] = 15; mINI::Instance()[kKeepAliveSecond] = 15; + mINI::Instance()[kDirectProxy] = 1; },nullptr); } //namespace Rtsp diff --git a/src/Common/config.h b/src/Common/config.h index d396b5c7..72024617 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -202,6 +202,13 @@ extern const string kAuthBasic; extern const string kHandshakeSecond; //维持链接超时时间,默认15秒 extern const string kKeepAliveSecond; + +//rtsp拉流代理是否直接代理 +//直接代理后支持任意编码格式,但是会导致GOP缓存无法定位到I帧,可能会导致花屏 +//并且如果是tcp方式拉流,如果rtp大于mtu会导致无法使用udp方式代理 +//假定您的拉流源地址不是264或265或AAC,那么你可以使用直接代理的方式来支持rtsp代理 +//默认开启rtsp直接代理,rtmp由于没有这些问题,是强制开启直接代理的 +extern const string kDirectProxy; } //namespace Rtsp ////////////RTMP服务器配置/////////// diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index 01106446..6cac17d8 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -130,7 +130,10 @@ void PlayerProxy::play(const string &strUrlTmp) { MediaSource::Ptr mediaSource; if(dynamic_pointer_cast(_parser)){ //rtsp拉流 - mediaSource = std::make_shared(_strVhost,_strApp,_strSrc); + GET_CONFIG(bool,directProxy,Rtsp::kDirectProxy); + if(directProxy){ + mediaSource = std::make_shared(_strVhost,_strApp,_strSrc); + } }else if(dynamic_pointer_cast(_parser)){ //rtmp拉流 mediaSource = std::make_shared(_strVhost,_strApp,_strSrc);