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
2013-12-22 17:38:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
084ad79534d888ebdaeddad0c1dbd6efbbf93723
084ad795
1 parent
94551817
refine the bandwidth test
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
32 行增加
和
18 行删除
README.md
trunk/src/core/srs_core_bandwidth.cpp
trunk/src/core/srs_core_bandwidth.hpp
trunk/src/core/srs_core_protocol.cpp
README.md
查看文件 @
084ad79
...
...
@@ -217,6 +217,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
*
nginx v1.5.0: 139524 lines
<br/>
### History
*
v0.9, 2013-12-22, merge from wenjie, support banwidth test.
*
v0.9, 2013-12-22, merge from wenjie: support set chunk size at vhost level
*
v0.9, 2013-12-21, add
[
players
](
http://demo.srs.com/players
)
for play and publish.
*
v0.9, 2013-12-15, ensure the HLS(ts) is continous when republish stream.
...
...
trunk/src/core/srs_core_bandwidth.cpp
查看文件 @
084ad79
...
...
@@ -170,6 +170,11 @@ int SrsBandwidth::do_bandwidth_check()
int
play_kbps
=
play_bytes
*
8
/
play_actual_duration_ms
;
int
publish_kbps
=
publish_bytes
*
8
/
publish_actual_duration_ms
;
srs_trace
(
"bandwidth check finished. start=%"
PRId64
"ms, end=%"
PRId64
"ms, "
"duartion=%dms, play=%dkbps, publish=%dkbps, tcUrl=%s, ret=%#x"
,
start_time
,
end_time
,
(
int
)(
end_time
-
start_time
),
play_kbps
,
publish_kbps
,
req
->
tcUrl
.
c_str
(),
ret
);
// send finished msg
SrsBandwidthPacket
*
pkt
=
SrsBandwidthPacket
::
create_finish
();
pkt
->
data
->
set
(
"code"
,
new
SrsAmf0Number
(
ERROR_SUCCESS
));
...
...
@@ -193,19 +198,20 @@ int SrsBandwidth::do_bandwidth_check()
SrsCommonMessage
*
msg
=
NULL
;
SrsBandwidthPacket
*
pkt
=
NULL
;
if
((
ret
=
srs_rtmp_expect_message
<
SrsBandwidthPacket
>
(
protocol
,
&
msg
,
&
pkt
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"expect final message failed. ret=%d"
,
ret
);
return
ret
;
// info level to ignore and return success.
srs_info
(
"expect final message failed. ret=%d"
,
ret
);
return
ERROR_SUCCESS
;
}
SrsAutoFree
(
SrsCommonMessage
,
msg
,
false
);
srs_info
(
"get final message succes."
);
srs_info
(
"get final message succes
s
."
);
if
(
pkt
->
is_flash_final
())
{
srs_
trace
(
"BW check recv flash final response."
);
srs_
info
(
"BW check recv flash final response."
);
break
;
}
}
srs_
trace
(
"BW check finished."
);
srs_
info
(
"BW check finished."
);
return
ret
;
}
...
...
@@ -230,7 +236,7 @@ int SrsBandwidth::check_play(
srs_error
(
"send bandwidth check start play message failed. ret=%d"
,
ret
);
return
ret
;
}
srs_
trace
(
"BW check begin."
);
srs_
info
(
"BW check begin."
);
}
while
(
true
)
{
...
...
@@ -245,7 +251,7 @@ int SrsBandwidth::check_play(
srs_info
(
"get bandwidth message succes."
);
if
(
pkt
->
is_starting_play
())
{
srs_
trace
(
"BW check recv play begin response."
);
srs_
info
(
"BW check recv play begin response."
);
break
;
}
}
...
...
@@ -293,7 +299,7 @@ int SrsBandwidth::check_play(
}
}
actual_duration_ms
=
srs_get_system_time_ms
()
-
current_time
;
srs_
trace
(
"BW check send play bytes over."
);
srs_
info
(
"BW check send play bytes over."
);
if
(
true
)
{
// notify client to stop play
...
...
@@ -308,7 +314,7 @@ int SrsBandwidth::check_play(
srs_error
(
"send bandwidth check stop play message failed. ret=%d"
,
ret
);
return
ret
;
}
srs_
trace
(
"BW check stop play bytes."
);
srs_
info
(
"BW check stop play bytes."
);
}
while
(
true
)
{
...
...
@@ -323,7 +329,7 @@ int SrsBandwidth::check_play(
srs_info
(
"get bandwidth message succes."
);
if
(
pkt
->
is_stopped_play
())
{
srs_
trace
(
"BW check recv stop play response."
);
srs_
info
(
"BW check recv stop play response."
);
break
;
}
}
...
...
@@ -351,7 +357,7 @@ int SrsBandwidth::check_publish(
srs_error
(
"send bandwidth check start publish message failed. ret=%d"
,
ret
);
return
ret
;
}
srs_
trace
(
"BW check publish begin."
);
srs_
info
(
"BW check publish begin."
);
}
while
(
true
)
{
...
...
@@ -366,7 +372,7 @@ int SrsBandwidth::check_publish(
srs_info
(
"get bandwidth message succes."
);
if
(
pkt
->
is_starting_publish
())
{
srs_
trace
(
"BW check recv publish begin response."
);
srs_
info
(
"BW check recv publish begin response."
);
break
;
}
}
...
...
@@ -399,7 +405,7 @@ int SrsBandwidth::check_publish(
}
}
actual_duration_ms
=
srs_get_system_time_ms
()
-
current_time
;
srs_
trace
(
"BW check recv publish data over."
);
srs_
info
(
"BW check recv publish data over."
);
if
(
true
)
{
// notify client to stop publish
...
...
@@ -414,7 +420,7 @@ int SrsBandwidth::check_publish(
srs_error
(
"send bandwidth check stop publish message failed. ret=%d"
,
ret
);
return
ret
;
}
srs_
trace
(
"BW check stop publish bytes."
);
srs_
info
(
"BW check stop publish bytes."
);
}
// expect client to stop publish
...
...
@@ -435,7 +441,7 @@ int SrsBandwidth::check_publish(
srs_info
(
"get bandwidth message succes."
);
if
(
pkt
->
is_stopped_publish
())
{
srs_
trace
(
"BW check recv stop publish response."
);
srs_
info
(
"BW check recv stop publish response."
);
break
;
}
}
...
...
trunk/src/core/srs_core_bandwidth.hpp
查看文件 @
084ad79
...
...
@@ -60,9 +60,12 @@ class SrsRtmp;
* | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1)
* | |
* | <--------------report |
* | final---------------> | finalClientPacket(2)
* | <END> |
* 1. when flash client, server ignore the publish stopped result.
* and flash client should close connection when got the report.
* 1. when flash client, server ignore the publish stopped result,
* and directly send the report to flash client.
* 2. flash client only. when got report, flash client should send out
* a final packet and close the connection immediately.
*/
class
SrsBandwidth
{
...
...
trunk/src/core/srs_core_protocol.cpp
查看文件 @
084ad79
...
...
@@ -231,6 +231,8 @@ messages.
#define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished"
// for flash, it will sendout a final call,
// used to confirm got the report.
// actually, client send out this packet and close the connection,
// so server may cannot got this packet, ignore is ok.
#define SRS_BW_CHECK_FLASH_FINAL "finalClientPacket"
// client only
...
...
@@ -1356,7 +1358,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol)
||
command
==
SRS_BW_CHECK_START_PUBLISH
||
command
==
SRS_BW_CHECK_STOPPED_PLAY
||
command
==
SRS_BW_CHECK_STOP_PLAY
||
command
==
SRS_BW_CHECK_STOP_PUBLISH
)
||
command
==
SRS_BW_CHECK_STOP_PUBLISH
||
command
==
SRS_BW_CHECK_STOPPED_PUBLISH
||
command
==
SRS_BW_CHECK_FLASH_FINAL
)
{
srs_info
(
"decode the AMF0/AMF3 band width check message."
);
packet
=
new
SrsBandwidthPacket
();
...
...
请
注册
或
登录
后发表评论