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-06-10 16:06:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a639eb05966359b0df6b87411481e7c9a4862f08
a639eb05
1 parent
d48d739f
fix bug of buffer assert, erase can accept any value
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
29 行增加
和
12 行删除
trunk/research/librtmp/srs_detect_rtmp.c
trunk/src/kernel/srs_kernel_buffer.cpp
trunk/src/kernel/srs_kernel_buffer.hpp
trunk/src/utest/srs_utest_buffer.cpp
trunk/research/librtmp/srs_detect_rtmp.c
查看文件 @
a639eb0
...
...
@@ -79,8 +79,8 @@ int main(int argc, char** argv)
printf
(
"duration: %ds, timeout:%ds
\n
"
,
duration
,
timeout
);
if
(
duration
<=
0
||
timeout
<=
0
)
{
printf
(
"duration and timeout must be positive.
\n
"
);
ret
=
1
;
fprintf
(
stderr
,
"duration and timeout must be positive. ret=%d
\n
"
,
ret
);
exit
(
ret
);
return
ret
;
}
...
...
@@ -88,33 +88,33 @@ int main(int argc, char** argv)
rtmp
=
srs_rtmp_create
(
rtmp_url
);
if
((
ret
=
__srs_dns_resolve
(
rtmp
))
!=
0
)
{
printf
(
"dns resolve failed.
\n
"
);
fprintf
(
stderr
,
"dns resolve failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"dns resolve success
\n
"
);
time_dns_resolve
=
srs_get_time_ms
();
if
((
ret
=
__srs_connect_server
(
rtmp
))
!=
0
)
{
printf
(
"socket connect failed.
\n
"
);
fprintf
(
stderr
,
"socket connect failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"socket connect success
\n
"
);
time_socket_connect
=
srs_get_time_ms
();
if
((
ret
=
__srs_do_simple_handshake
(
rtmp
))
!=
0
)
{
printf
(
"do simple handshake failed.
\n
"
);
fprintf
(
stderr
,
"do simple handshake failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"do simple handshake success
\n
"
);
if
((
ret
=
srs_connect_app
(
rtmp
))
!=
0
)
{
printf
(
"connect vhost/app failed.
\n
"
);
fprintf
(
stderr
,
"connect vhost/app failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"connect vhost/app success
\n
"
);
if
((
ret
=
srs_play_stream
(
rtmp
))
!=
0
)
{
printf
(
"play stream failed.
\n
"
);
fprintf
(
stderr
,
"play stream failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"play stream success
\n
"
);
...
...
@@ -122,6 +122,7 @@ int main(int argc, char** argv)
for
(;;)
{
if
((
ret
=
srs_read_packet
(
rtmp
,
&
type
,
&
timestamp
,
&
data
,
&
size
))
!=
0
)
{
fprintf
(
stderr
,
"read packet failed. ret=%d
\n
"
,
ret
);
goto
rtmp_destroy
;
}
printf
(
"got packet: type=%s, time=%d, size=%d
\n
"
,
srs_type2string
(
type
),
timestamp
,
size
);
...
...
@@ -158,7 +159,7 @@ rtmp_destroy:
"
\"
%s
\"
:%d, "
// #6
"
\"
%s
\"
:%d, "
// #7
"
\"
%s
\"
:%d, "
// #8
"%s
%s%s
%s}"
,
"%s
,%s,%s,
%s}"
,
"code"
,
ret
,
//#0
// total = dns + tcp_connect + start_play + first_packet + last_packet
"total"
,
(
int
)(
time_cleanup
-
time_startup
),
//#1
...
...
@@ -173,12 +174,12 @@ rtmp_destroy:
// delay = actual - expect
"delay"
,
(
int
)(
timestamp
-
(
time_cleanup
-
time_first_packet
)),
//#8
// unit in ms.
"
\"
unit
\"
:
\"
ms
\"
,"
,
"
\"
remark0
\"
:
\"
total = dns + tcp_connect + start_play + first_packet + last_packet
\"
,"
,
"
\"
unit
\"
:
\"
ms
\"
"
,
"
\"
remark0
\"
:
\"
total = dns + tcp_connect + start_play + first_packet + last_packet
\"
"
,
"
\"
remark1
\"
:
\"
delay = stream - (time_cleanup - time_first_packet)
\"
"
,
"
\"
remark2
\"
:
\"
if code is not 0, user must ignore all data
\"
"
);
printf
(
"
\n
"
);
return
0
;
return
ret
;
}
...
...
trunk/src/kernel/srs_kernel_buffer.cpp
查看文件 @
a639eb0
...
...
@@ -58,7 +58,9 @@ char* SrsBuffer::bytes()
void
SrsBuffer
::
erase
(
int
size
)
{
srs_assert
(
size
>
0
);
if
(
size
<=
0
)
{
return
;
}
if
(
size
>=
length
())
{
data
.
clear
();
...
...
trunk/src/kernel/srs_kernel_buffer.hpp
查看文件 @
a639eb0
...
...
@@ -71,7 +71,7 @@ public:
* erase size of bytes from begin.
* @param size to erase size of bytes.
* clear if size greater than or equals to length()
* @remark
assert size is
positive.
* @remark
ignore size is not
positive.
*/
virtual
void
erase
(
int
size
);
/**
...
...
trunk/src/utest/srs_utest_buffer.cpp
查看文件 @
a639eb0
...
...
@@ -79,20 +79,34 @@ VOID TEST(BufferTest, EraseBytes)
{
SrsBuffer
b
;
b
.
erase
(
0
);
b
.
erase
(
-
1
);
EXPECT_EQ
(
0
,
b
.
length
());
char
winlin
[]
=
"winlin"
;
b
.
append
(
winlin
,
strlen
(
winlin
));
b
.
erase
(
b
.
length
());
EXPECT_EQ
(
0
,
b
.
length
());
b
.
erase
(
0
);
b
.
erase
(
-
1
);
EXPECT_EQ
(
0
,
b
.
length
());
b
.
append
(
winlin
,
strlen
(
winlin
));
b
.
erase
(
1
);
EXPECT_EQ
(
5
,
b
.
length
());
EXPECT_EQ
(
'i'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
4
]);
b
.
erase
(
2
);
EXPECT_EQ
(
3
,
b
.
length
());
EXPECT_EQ
(
'l'
,
b
.
bytes
()[
0
]);
EXPECT_EQ
(
'n'
,
b
.
bytes
()[
2
]);
b
.
erase
(
0
);
b
.
erase
(
-
1
);
EXPECT_EQ
(
3
,
b
.
length
());
b
.
erase
(
3
);
EXPECT_EQ
(
0
,
b
.
length
());
}
...
...
请
注册
或
登录
后发表评论