mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 07:22:23 +08:00
适配ZLToolKit(更新定时器)
This commit is contained in:
@@ -153,7 +153,7 @@ void RtspPlayer::onConnect(const SockException &err){
|
||||
strongSelf->onPlayResult_l(SockException(Err_timeout,"play rtsp timeout"));
|
||||
strongSelf->teardown();
|
||||
return false;
|
||||
},getExecutor()));
|
||||
},getPoller()));
|
||||
}
|
||||
|
||||
void RtspPlayer::onRecv(const Buffer::Ptr& pBuf) {
|
||||
@@ -352,7 +352,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int uiTrackIndex)
|
||||
return false;
|
||||
}
|
||||
return strongSelf->sendOptions();
|
||||
},getExecutor()));
|
||||
},getPoller()));
|
||||
pause(false);
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},getExecutor()));
|
||||
},getPoller()));
|
||||
}
|
||||
onPlayResult(ex);
|
||||
}
|
||||
|
||||
@@ -70,19 +70,42 @@ static unordered_map<string, weak_ptr<RtspSession> > g_mapGetter;
|
||||
//对g_mapGetter上锁保护
|
||||
static recursive_mutex g_mtxGetter;
|
||||
|
||||
//rtsp会话个数统计
|
||||
static recursive_mutex g_mtxSessionCounter;
|
||||
static unordered_map<string,atomic<uint32_t > > g_mapSessionCounter;
|
||||
|
||||
static int kSockFlags = SOCKET_DEFAULE_FLAGS | FLAG_MORE;
|
||||
|
||||
uint32_t RtspSession::getSessionCountOnInterface(const string &ifr){
|
||||
lock_guard<recursive_mutex> 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(10);
|
||||
pSock->setSendBufSecond(30);
|
||||
//设置15秒发送超时时间
|
||||
pSock->setSendTimeOutSecond(15);
|
||||
pSock->setSendTimeOutSecond(45);
|
||||
|
||||
DebugL << get_peer_ip();
|
||||
|
||||
lock_guard<recursive_mutex> lck(g_mtxSessionCounter);
|
||||
++(g_mapSessionCounter[get_local_ip()]);
|
||||
}
|
||||
|
||||
RtspSession::~RtspSession() {
|
||||
DebugL << get_peer_ip();
|
||||
|
||||
lock_guard<recursive_mutex> lck(g_mtxSessionCounter);
|
||||
--(g_mapSessionCounter[get_local_ip()]);
|
||||
|
||||
}
|
||||
|
||||
void RtspSession::onError(const SockException& err) {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#define SESSION_RTSPSESSION_H_
|
||||
|
||||
#include <set>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "Util/util.h"
|
||||
@@ -79,6 +80,7 @@ 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
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user