Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
ebd2ed2d
Commit
ebd2ed2d
authored
5 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化rtsp/http/rtmp服务器内存占用
parent
bb9a02b8
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
1 行删除
+10
-1
src/Http/HttpSession.cpp
+5
-0
src/Rtmp/RtmpSession.cpp
+4
-0
src/Rtsp/RtspSession.cpp
+1
-1
没有找到文件。
src/Http/HttpSession.cpp
查看文件 @
ebd2ed2d
...
@@ -103,6 +103,8 @@ get_mime_type(const char* name) {
...
@@ -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) {
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpSession.cpp
查看文件 @
ebd2ed2d
...
@@ -37,6 +37,8 @@ RtmpSession::RtmpSession(const Socket::Ptr &pSock) : TcpSession(pSock) {
...
@@ -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) {
...
@@ -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
());
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtspSession.cpp
查看文件 @
ebd2ed2d
...
@@ -271,7 +271,7 @@ bool RtspSession::handleReq_RECORD(const Parser &parser){
...
@@ -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
);
};
};
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论