Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-12-04 22:00:09 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
98647d6e6730edfd437b791b1df58f32427eb344
98647d6e
1 parent
76af04c5
limit the user-space buffer size to 128KB, 128MB for 1k publishers.
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
17 行增加
和
5 行删除
trunk/src/app/srs_app_recv_thread.cpp
trunk/src/rtmp/srs_protocol_buffer.cpp
trunk/src/app/srs_app_recv_thread.cpp
查看文件 @
98647d6
...
...
@@ -429,7 +429,8 @@ void SrsPublishRecvThread::set_socket_buffer(int sleep_ms)
// sleep 800ms for small bytes, the buffer should set to:
// 800*1000/8=100000B(about 128KB).
// 2000*3000/8=750000B(about 732KB).
int
kbps
=
3000
;
// 2000*5000/8=1250000B(about 1220KB).
int
kbps
=
5000
;
int
socket_buffer_size
=
sleep_ms
*
kbps
/
8
;
// socket recv buffer, system will double it.
...
...
trunk/src/rtmp/srs_protocol_buffer.cpp
查看文件 @
98647d6
...
...
@@ -28,8 +28,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_utility.hpp>
#include <srs_core_performance.hpp>
// the default recv buffer size
#define SRS_DEFAULT_RECV_BUFFER_SIZE 32768
// the default recv buffer size, 128KB.
#define SRS_DEFAULT_RECV_BUFFER_SIZE 131072
// limit user-space buffer to 256KB, for 3Mbps stream delivery.
// 800*2000/8=200000B(about 195KB).
// @remark it's ok for higher stream, the buffer is ok for one chunk is 256KB.
#define SRS_MAX_SOCKET_BUFFER 262144
// the max header size,
// @see SrsProtocol::read_message_header().
...
...
@@ -100,15 +105,21 @@ SrsFastBuffer::SrsFastBuffer()
void
SrsFastBuffer
::
set_buffer
(
int
buffer_size
)
{
// the user-space buffer size limit to a max value.
int
nb_max_buf
=
srs_min
(
buffer_size
,
SRS_MAX_SOCKET_BUFFER
);
if
(
nb_max_buf
<
buffer_size
)
{
srs_warn
(
"limit the user-space buffer from %d to %d"
,
buffer_size
,
nb_max_buf
);
}
// only realloc when buffer changed bigger
if
(
buffer_size
<=
nb_buffer
)
{
if
(
nb_max_buf
<=
nb_buffer
)
{
return
;
}
int
start
=
p
-
buffer
;
int
cap
=
end
-
p
;
char
*
buf
=
new
char
[
buffer_size
];
char
*
buf
=
new
char
[
nb_max_buf
];
if
(
cap
>
0
)
{
memcpy
(
buf
,
buffer
,
nb_buffer
);
}
...
...
请
注册
或
登录
后发表评论