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 15:43:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a23b5b9a4be78460f7c6ad683b66cf7af2741148
a23b5b9a
1 parent
d026861e
for bug#241, simplify the buffer, donot change its size.
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
17 行增加
和
44 行删除
trunk/src/app/srs_app_recv_thread.cpp
trunk/src/core/srs_core_performance.hpp
trunk/src/rtmp/srs_protocol_buffer.cpp
trunk/src/rtmp/srs_protocol_buffer.hpp
trunk/src/rtmp/srs_protocol_rtmp.cpp
trunk/src/rtmp/srs_protocol_rtmp.hpp
trunk/src/rtmp/srs_protocol_stack.cpp
trunk/src/rtmp/srs_protocol_stack.hpp
trunk/src/app/srs_app_recv_thread.cpp
查看文件 @
a23b5b9
...
...
@@ -295,7 +295,7 @@ void SrsPublishRecvThread::on_thread_start()
// enable the merge read
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241
rtmp
->
set_merge_read
(
true
,
nb_rbuf
,
this
);
rtmp
->
set_merge_read
(
true
,
this
);
#endif
}
...
...
@@ -311,7 +311,7 @@ void SrsPublishRecvThread::on_thread_stop()
#ifdef SRS_PERF_MERGED_READ
// disable the merge read
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241
rtmp
->
set_merge_read
(
false
,
0
,
NULL
);
rtmp
->
set_merge_read
(
false
,
NULL
);
#endif
}
...
...
trunk/src/core/srs_core_performance.hpp
查看文件 @
a23b5b9
...
...
@@ -39,40 +39,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* when it on and read small bytes, we sleep to wait more data.,
* that is, we merge some data to read together.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
* @remark other macros:
* SOCKET_MAX_BUF, the max size of user-space buffer.
* SOCKET_READ_SIZE, the user space buffer for socket.
* SRS_MR_MAX_BITRATE_KBPS, the kbps of stream for system to guess the sleep time.
* SRS_MR_AVERAGE_BITRATE_KBPS, the average kbps of system.
* SRS_MR_MIN_BITRATE_KBPS, the min kbps of system.
* SRS_MR_MAX_SLEEP_MS, the max sleep time, the latency+ when sleep+.
* SRS_MR_SMALL_BYTES, sleep when got small bytes, the latency+ when small+.
* SRS_MR_SMALL_PERCENT, to calc the small bytes = SRS_MR_SOCKET_BUFFER/percent.
* SRS_MR_SOCKET_BUFFER, the socket buffer to set fd.
* @remark the actual socket buffer used to set the buffer user-space size.
* buffer = min(SOCKET_MAX_BUF, SRS_MR_SOCKET_BUFFER, SOCKET_READ_SIZE)
* small bytes = max(buffer/SRS_MR_SMALL_PERCENT, SRS_MR_SMALL_BYTES)
* sleep = calc the sleep by kbps and buffer.
* @remark the main merged-read algorithm:
* while true:
* nread = read from socket.
* sleep if nread < small bytes
* process bytes.
* @example, for the default settings, this algorithm will use:
* socket buffer set to 64KB,
* user space buffer set to 64KB,
* buffer=65536B, small=4096B, sleep=780ms
* that is, when got nread bytes smaller than 4KB, sleep(780ms).
*/
#if 1
// to enable merged read.
#define SRS_PERF_MERGED_READ
// the max sleep time in ms
#define SRS_MR_MAX_SLEEP_MS
100
0
#define SRS_MR_MAX_SLEEP_MS
78
0
// the max small bytes to group
#define SRS_MR_SMALL_BYTES 4096
// the underlayer api will set to SRS_MR_SOCKET_BUFFER bytes.
// 4KB=4096, 8KB=8192, 16KB=16384, 32KB=32768, 64KB=65536
// 4KB=4096, 8KB=8192, 16KB=16384, 32KB=32768, 64KB=65536,
// 128KB=131072, 256KB=262144, 512KB=524288
// the buffer should set to SRS_MR_MAX_SLEEP_MS*kbps/8,
// for example, your system delivery stream in 1000kbps,
// sleep 800ms for small bytes, the buffer should set to:
// 800*1000/8=100000B(about 128KB).
#define SRS_MR_SOCKET_BUFFER 65536
#endif
...
...
trunk/src/rtmp/srs_protocol_buffer.cpp
查看文件 @
a23b5b9
...
...
@@ -186,17 +186,10 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
}
#ifdef SRS_PERF_MERGED_READ
void
SrsFastBuffer
::
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
)
void
SrsFastBuffer
::
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
)
{
merged_read
=
v
;
_handler
=
handler
;
// limit the max buffer.
int
buffer_size
=
srs_min
(
max_buffer
,
SRS_MR_SOCKET_BUFFER
);
if
(
v
&&
buffer_size
!=
nb_buffer
)
{
reset_buffer
(
buffer_size
);
}
}
#endif
...
...
trunk/src/rtmp/srs_protocol_buffer.hpp
查看文件 @
a23b5b9
...
...
@@ -157,11 +157,10 @@ public:
* when it on and read small bytes, we sleep to wait more data.,
* that is, we merge some data to read together.
* @param v true to ename merged read.
* @param max_buffer the max buffer size, the socket buffer.
* @param handler the handler when merge read is enabled.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
*/
virtual
void
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
);
virtual
void
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
);
#endif
private
:
virtual
void
reset_buffer
(
int
size
);
...
...
trunk/src/rtmp/srs_protocol_rtmp.cpp
查看文件 @
a23b5b9
...
...
@@ -746,9 +746,9 @@ void SrsRtmpServer::set_auto_response(bool v)
}
#ifdef SRS_PERF_MERGED_READ
void
SrsRtmpServer
::
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
)
void
SrsRtmpServer
::
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
)
{
protocol
->
set_merge_read
(
v
,
max_buffer
,
handler
);
protocol
->
set_merge_read
(
v
,
handler
);
}
#endif
...
...
trunk/src/rtmp/srs_protocol_rtmp.hpp
查看文件 @
a23b5b9
...
...
@@ -350,11 +350,10 @@ public:
* when it on and read small bytes, we sleep to wait more data.,
* that is, we merge some data to read together.
* @param v true to ename merged read.
* @param max_buffer the max buffer size, the socket buffer.
* @param handler the handler when merge read is enabled.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
*/
virtual
void
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
);
virtual
void
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
);
#endif
/**
* set/get the recv timeout in us.
...
...
trunk/src/rtmp/srs_protocol_stack.cpp
查看文件 @
a23b5b9
...
...
@@ -497,9 +497,9 @@ int SrsProtocol::manual_response_flush()
}
#ifdef SRS_PERF_MERGED_READ
void
SrsProtocol
::
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
)
void
SrsProtocol
::
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
)
{
in_buffer
->
set_merge_read
(
v
,
max_buffer
,
handler
);
in_buffer
->
set_merge_read
(
v
,
handler
);
}
#endif
...
...
trunk/src/rtmp/srs_protocol_stack.hpp
查看文件 @
a23b5b9
...
...
@@ -284,11 +284,10 @@ public:
* when it on and read small bytes, we sleep to wait more data.,
* that is, we merge some data to read together.
* @param v true to ename merged read.
* @param max_buffer the max buffer size, the socket buffer.
* @param handler the handler when merge read is enabled.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
*/
virtual
void
set_merge_read
(
bool
v
,
int
max_buffer
,
IMergeReadHandler
*
handler
);
virtual
void
set_merge_read
(
bool
v
,
IMergeReadHandler
*
handler
);
#endif
public
:
/**
...
...
请
注册
或
登录
后发表评论