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:10:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4c6cf959c155221f8e8e6115b43178068da98375
4c6cf959
1 parent
98647d6e
refine fast buffer, check available bytes to read.
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
14 行增加
和
15 行删除
trunk/src/kernel/srs_kernel_error.hpp
trunk/src/rtmp/srs_protocol_buffer.cpp
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
4c6cf95
...
...
@@ -60,7 +60,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_SYSTEM_PACKET_INVALID 1019
#define ERROR_SYSTEM_CLIENT_INVALID 1020
#define ERROR_SYSTEM_ASSERT_FAILED 1021
#define ERROR_
SYSTEM_SIZE_NEGATIVE
1022
#define ERROR_
READER_BUFFER_OVERFLOW
1022
#define ERROR_SYSTEM_CONFIG_INVALID 1023
#define ERROR_SYSTEM_CONFIG_DIRECTIVE 1024
#define ERROR_SYSTEM_CONFIG_BLOCK_START 1025
...
...
@@ -134,7 +134,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_OpenSslSha256DigestSize 2037
#define ERROR_OpenSslGetPeerPublicKey 2038
#define ERROR_OpenSslComputeSharedKey 2039
#define ERROR_RTMP_BUFFER_OVERFLOW 2040
//
// system control message,
// not an error, but special control logic.
...
...
trunk/src/rtmp/srs_protocol_buffer.cpp
查看文件 @
4c6cf95
...
...
@@ -169,18 +169,18 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
{
int
ret
=
ERROR_SUCCESS
;
if
(
required_size
<
0
)
{
ret
=
ERROR_SYSTEM_SIZE_NEGATIVE
;
srs_error
(
"size is negative. size=%d, ret=%d"
,
required_size
,
ret
);
// generally the required size is ok.
if
(
end
-
p
>=
required_size
)
{
return
ret
;
}
// when read payload and need to grow, reset buffer.
// or there is no space to read.
// must be positive.
srs_assert
(
required_size
>
0
);
// when read payload or there is no space to read,
// reset the buffer with exists bytes.
int
max_to_read
=
buffer
+
nb_buffer
-
end
;
if
(
end
-
p
<
required_size
&&
(
required_size
>
SRS_RTMP_MAX_MESSAGE_HEADER
||
max_to_read
<
required_size
)
)
{
if
(
required_size
>
SRS_RTMP_MAX_MESSAGE_HEADER
||
max_to_read
<
required_size
)
{
int
nb_cap
=
end
-
p
;
srs_verbose
(
"move fast buffer %d bytes"
,
nb_cap
);
if
(
nb_cap
<
nb_buffer
)
{
...
...
@@ -190,16 +190,16 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
}
}
while
(
end
-
p
<
required_size
)
{
// the max to read is the left bytes.
// directly check the available bytes to read in buffer.
max_to_read
=
buffer
+
nb_buffer
-
end
;
if
(
max_to_read
<=
0
)
{
ret
=
ERROR_RTMP_BUFFER_OVERFLOW
;
if
(
max_to_read
<
required_size
)
{
ret
=
ERROR_READER_BUFFER_OVERFLOW
;
srs_error
(
"buffer overflow, required=%d, max=%d, ret=%d"
,
required_size
,
nb_buffer
,
ret
);
return
ret
;
}
// buffer is ok, read required size of bytes.
while
(
end
-
p
<
required_size
)
{
ssize_t
nread
;
if
((
ret
=
reader
->
read
(
end
,
max_to_read
,
&
nread
))
!=
ERROR_SUCCESS
)
{
return
ret
;
...
...
请
注册
或
登录
后发表评论