mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-21 01:13:37 +08:00
优化rtsp/http/rtmp服务器内存占用
This commit is contained in:
parent
bb9a02b817
commit
ebd2ed2d97
@ -103,6 +103,8 @@ get_mime_type(const char* name) {
|
|||||||
HttpSession::HttpSession(const Socket::Ptr &pSock) : TcpSession(pSock) {
|
HttpSession::HttpSession(const Socket::Ptr &pSock) : TcpSession(pSock) {
|
||||||
//设置15秒发送超时时间
|
//设置15秒发送超时时间
|
||||||
pSock->setSendTimeOutSecond(15);
|
pSock->setSendTimeOutSecond(15);
|
||||||
|
//起始接收buffer缓存设置为4K,节省内存
|
||||||
|
pSock->setReadBuffer(std::make_shared<BufferRaw>(4 * 1024));
|
||||||
|
|
||||||
GET_CONFIG_AND_REGISTER(string,rootPath,Http::kRootPath);
|
GET_CONFIG_AND_REGISTER(string,rootPath,Http::kRootPath);
|
||||||
_strPath = rootPath;
|
_strPath = rootPath;
|
||||||
@ -650,6 +652,9 @@ inline bool HttpSession::Handle_Req_POST(int64_t &content_len) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
|
//如果是post请求 并且totalContentLen数据超过maxReqSize,那么我们加大接收缓存提升性能
|
||||||
|
_sock->setReadBuffer(std::make_shared<BufferRaw>(256 * 1024));
|
||||||
|
|
||||||
//返回不固定长度的content
|
//返回不固定长度的content
|
||||||
content_len = -1;
|
content_len = -1;
|
||||||
auto parserCopy = _parser;
|
auto parserCopy = _parser;
|
||||||
|
@ -37,6 +37,8 @@ RtmpSession::RtmpSession(const Socket::Ptr &pSock) : TcpSession(pSock) {
|
|||||||
DebugL << get_peer_ip();
|
DebugL << get_peer_ip();
|
||||||
//设置15秒发送超时时间
|
//设置15秒发送超时时间
|
||||||
pSock->setSendTimeOutSecond(15);
|
pSock->setSendTimeOutSecond(15);
|
||||||
|
//起始接收buffer缓存设置为4K,节省内存
|
||||||
|
pSock->setReadBuffer(std::make_shared<BufferRaw>(4 * 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
RtmpSession::~RtmpSession() {
|
RtmpSession::~RtmpSession() {
|
||||||
@ -171,6 +173,8 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
|
|||||||
}
|
}
|
||||||
_pPublisherSrc.reset(new RtmpToRtspMediaSource(_mediaInfo._vhost,_mediaInfo._app,_mediaInfo._streamid));
|
_pPublisherSrc.reset(new RtmpToRtspMediaSource(_mediaInfo._vhost,_mediaInfo._app,_mediaInfo._streamid));
|
||||||
_pPublisherSrc->setListener(dynamic_pointer_cast<MediaSourceEvent>(shared_from_this()));
|
_pPublisherSrc->setListener(dynamic_pointer_cast<MediaSourceEvent>(shared_from_this()));
|
||||||
|
//如果是rtmp推流客户端,那么加大TCP接收缓存,这样能提升接收性能
|
||||||
|
_sock->setReadBuffer(std::make_shared<BufferRaw>(256 * 1024));
|
||||||
};
|
};
|
||||||
|
|
||||||
weak_ptr<RtmpSession> weakSelf = dynamic_pointer_cast<RtmpSession>(shared_from_this());
|
weak_ptr<RtmpSession> weakSelf = dynamic_pointer_cast<RtmpSession>(shared_from_this());
|
||||||
|
@ -271,7 +271,7 @@ bool RtspSession::handleReq_RECORD(const Parser &parser){
|
|||||||
SockUtil::setNoDelay(_sock->rawFD(),false);
|
SockUtil::setNoDelay(_sock->rawFD(),false);
|
||||||
if(_rtpType == Rtsp::RTP_TCP){
|
if(_rtpType == Rtsp::RTP_TCP){
|
||||||
//如果是rtsp推流服务器,并且是TCP推流,那么加大TCP接收缓存,这样能提升接收性能
|
//如果是rtsp推流服务器,并且是TCP推流,那么加大TCP接收缓存,这样能提升接收性能
|
||||||
_sock->setReadBuffer(std::make_shared<BufferRaw>(128 * 1024));
|
_sock->setReadBuffer(std::make_shared<BufferRaw>(256 * 1024));
|
||||||
}
|
}
|
||||||
(*this) << SocketFlags(kSockFlags);
|
(*this) << SocketFlags(kSockFlags);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user