From 6ecd21cd6c48ca8043d058182a9a18bd26d317db Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Wed, 30 Jan 2019 17:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=8E=9F=E6=9D=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspSession.cpp | 27 ++------------------------- src/Rtsp/RtspSession.h | 2 -- tests/test_server.cpp | 2 +- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 823ed03e..ffc7cc86 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -70,42 +70,19 @@ static unordered_map > g_mapGetter; //对g_mapGetter上锁保护 static recursive_mutex g_mtxGetter; -//rtsp会话个数统计 -static recursive_mutex g_mtxSessionCounter; -static unordered_map > g_mapSessionCounter; - static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE; -uint32_t RtspSession::getSessionCountOnInterface(const string &ifr){ - lock_guard lck(g_mtxSessionCounter); - if(ifr.empty()){ - int i = 0; - for(auto &pr : g_mapSessionCounter){ - i += pr.second; - } - return i; - } - return g_mapSessionCounter[ifr]; -} - RtspSession::RtspSession(const Socket::Ptr &pSock) : TcpSession(pSock) { //设置10秒发送缓存 - pSock->setSendBufSecond(30); + pSock->setSendBufSecond(10); //设置15秒发送超时时间 - pSock->setSendTimeOutSecond(45); + pSock->setSendTimeOutSecond(15); DebugL << get_peer_ip(); - - lock_guard lck(g_mtxSessionCounter); - ++(g_mapSessionCounter[get_local_ip()]); } RtspSession::~RtspSession() { DebugL << get_peer_ip(); - - lock_guard lck(g_mtxSessionCounter); - --(g_mapSessionCounter[get_local_ip()]); - } void RtspSession::onError(const SockException& err) { diff --git a/src/Rtsp/RtspSession.h b/src/Rtsp/RtspSession.h index 0c0e9689..3c7a1c8e 100644 --- a/src/Rtsp/RtspSession.h +++ b/src/Rtsp/RtspSession.h @@ -28,7 +28,6 @@ #define SESSION_RTSPSESSION_H_ #include -#include #include #include #include "Util/util.h" @@ -80,7 +79,6 @@ public: void onRecv(const Buffer::Ptr &pBuf) override; void onError(const SockException &err) override; void onManager() override; - static uint32_t getSessionCountOnInterface(const string &ifr); protected: //RtspSplitter override /** diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 8b8d8a83..53abdd47 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -266,7 +266,7 @@ int main(int argc,char *argv[]) { //指定RTP over TCP(播放rtsp时有效) (*player)[RtspPlayer::kRtpType] = PlayerBase::RTP_TCP; //开始播放,如果播放失败或者播放中止,将会自动重试若干次,重试次数在配置文件中配置,默认一直重试 - //player->play(url); + player->play(url); //需要保存PlayerProxy,否则作用域结束就会销毁该对象 proxyMap.emplace(to_string(i), player); ++i;