From bb9a02b817d41a86e18881a0713c6a07ed9e4b18 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 23 Apr 2019 11:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96rtsp=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E5=86=85=E5=AD=98=E5=8D=A0=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspSession.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index fa4d0c1f..3bdd4459 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -69,13 +69,13 @@ namespace mediakit { static unordered_map > g_mapGetter; //对g_mapGetter上锁保护 static recursive_mutex g_mtxGetter; - static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE; RtspSession::RtspSession(const Socket::Ptr &pSock) : TcpSession(pSock) { //设置15秒发送超时时间 pSock->setSendTimeOutSecond(15); - + //起始接收buffer缓存设置为4K,节省内存 + pSock->setReadBuffer(std::make_shared(4 * 1024)); DebugL << get_peer_ip(); } @@ -269,6 +269,10 @@ bool RtspSession::handleReq_RECORD(const Parser &parser){ rtp_info.pop_back(); sendRtspResponse("200 OK", {"RTP-Info",rtp_info}); SockUtil::setNoDelay(_sock->rawFD(),false); + if(_rtpType == Rtsp::RTP_TCP){ + //如果是rtsp推流服务器,并且是TCP推流,那么加大TCP接收缓存,这样能提升接收性能 + _sock->setReadBuffer(std::make_shared(128 * 1024)); + } (*this) << SocketFlags(kSockFlags); };