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-07-13 20:25:36 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5c4398f4a967f6baf3d787c66838fdc69ef79791
5c4398f4
1 parent
b3d3f9ce
refine bandwidth check/test, flash publish test is ok.
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
49 行增加
和
31 行删除
trunk/research/players/srs_bwt/release/srs_bwt.swf
trunk/research/players/srs_bwt/src/SrsBandwidth.as
trunk/src/app/srs_app_bandwidth.cpp
trunk/src/app/srs_app_kbps.cpp
trunk/src/app/srs_app_kbps.hpp
trunk/src/libs/srs_lib_bandwidth.cpp
trunk/src/libs/srs_lib_bandwidth.hpp
trunk/research/players/srs_bwt/release/srs_bwt.swf
查看文件 @
5c4398f
不能预览此文件类型
trunk/research/players/srs_bwt/src/SrsBandwidth.as
查看文件 @
5c4398f
...
...
@@ -394,7 +394,27 @@ package
private
function
publisher
()
:
void
{
var
data
:
Array
=
new
Array
()
;
var
data_size
:
int
=
100
;
/**
* the data size cannot too large, it will increase the test time.
* server need atleast got one packet, then timeout to stop the publish.
*
* cannot too small neither, it will limit the max publish kbps.
*
* the test values:
* test_s test_s
* data_size max_publish_kbps (no limit) (limit upload to 5KBps)
* 100 2116 6.5 7.3
* 200 4071 6.5 7.7
* 300 6438 6.5 10.3
* 400 9328 6.5 10.2
* 500 10377 6.5 10.0
* 600 13737 6.5 10.8
* 700 15635 6.5 12.0
* 800 18103 6.5 14.0
* 900 20484 6.5 14.2
* 1000 21447 6.5 16.8
*/
var
data_size
:
int
=
900
;
for
(
var
i
:
int
;
i
<
data_size
;
i
++
)
{
data
.
push
(
"SrS band check data from client's publishing......"
)
;
}
...
...
trunk/src/app/srs_app_bandwidth.cpp
查看文件 @
5c4398f
...
...
@@ -42,6 +42,9 @@ using namespace std;
// default sample duration, in ms
#define _SRS_BANDWIDTH_SAMPLE_DURATION_MS 3000
// wait for a while for flash to got all packets.
#define _SRS_BANDWIDTH_FINAL_WAIT_MS 600
SrsBandwidthSample
::
SrsBandwidthSample
()
{
duration_ms
=
_SRS_BANDWIDTH_SAMPLE_DURATION_MS
;
...
...
@@ -241,6 +244,8 @@ int SrsBandwidth::do_bandwidth_check(SrsKbpsLimit* limit)
if
((
ret
=
finial
(
play_sample
,
publish_sample
,
start_time
,
end_time
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
st_usleep
(
_SRS_BANDWIDTH_FINAL_WAIT_MS
*
1000
);
srs_info
(
"BW check finished."
);
return
ret
;
...
...
@@ -254,6 +259,7 @@ int SrsBandwidth::play_start(SrsBandwidthSample* sample, SrsKbpsLimit* limit)
// send start play command to client
SrsBandwidthPacket
*
pkt
=
SrsBandwidthPacket
::
create_start_play
();
pkt
->
data
->
set
(
"limit_kbps"
,
SrsAmf0Any
::
number
(
limit
->
limit_kbps
()));
pkt
->
data
->
set
(
"duration_ms"
,
SrsAmf0Any
::
number
(
sample
->
duration_ms
));
pkt
->
data
->
set
(
"interval_ms"
,
SrsAmf0Any
::
number
(
sample
->
interval_ms
));
...
...
@@ -349,6 +355,7 @@ int SrsBandwidth::publish_start(SrsBandwidthSample* sample, SrsKbpsLimit* limit)
// notify client to start publish
SrsBandwidthPacket
*
pkt
=
SrsBandwidthPacket
::
create_start_publish
();
pkt
->
data
->
set
(
"limit_kbps"
,
SrsAmf0Any
::
number
(
limit
->
limit_kbps
()));
pkt
->
data
->
set
(
"duration_ms"
,
SrsAmf0Any
::
number
(
sample
->
duration_ms
));
pkt
->
data
->
set
(
"interval_ms"
,
SrsAmf0Any
::
number
(
sample
->
interval_ms
));
...
...
trunk/src/app/srs_app_kbps.cpp
查看文件 @
5c4398f
...
...
@@ -257,6 +257,11 @@ SrsKbpsLimit::~SrsKbpsLimit()
{
}
int
SrsKbpsLimit
::
limit_kbps
()
{
return
_limit_kbps
;
}
void
SrsKbpsLimit
::
recv_limit
()
{
_kbps
->
sample
();
...
...
trunk/src/app/srs_app_kbps.hpp
查看文件 @
5c4398f
...
...
@@ -211,6 +211,10 @@ public:
virtual
~
SrsKbpsLimit
();
public
:
/**
* get the system limit kbps.
*/
virtual
int
limit_kbps
();
/**
* limit the recv bandwidth.
*/
virtual
void
recv_limit
();
...
...
trunk/src/libs/srs_lib_bandwidth.cpp
查看文件 @
5c4398f
...
...
@@ -130,29 +130,20 @@ int SrsBandwidthClient::bandwidth_check(
*
start_time
=
srs_get_system_time_ms
();
// play
int
duration_delta
=
0
;
int
bytes_delta
=
0
;
if
((
ret
=
play_start
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
play_checking
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
play_stop
(
duration_delta
,
bytes_delta
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
play_stop
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// play kbps used to refer for publish
int
actual_play_kbps
=
0
;
if
(
duration_delta
>
0
)
{
actual_play_kbps
=
bytes_delta
*
8
/
duration_delta
;
}
// max publish kbps, we set to 1.2*play_kbps:
actual_play_kbps
=
(
int
)(
actual_play_kbps
*
1.2
);
// publish
int
duration_ms
=
0
;
if
((
ret
=
publish_start
(
duration_ms
))
!=
ERROR_SUCCESS
)
{
int
actual_play_kbps
=
0
;
if
((
ret
=
publish_start
(
duration_ms
,
actual_play_kbps
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
publish_checking
(
duration_ms
,
actual_play_kbps
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -226,24 +217,12 @@ int SrsBandwidthClient::play_checking()
return
ret
;
}
int
SrsBandwidthClient
::
play_stop
(
int
&
duration_delta
,
int
&
bytes_delta
)
int
SrsBandwidthClient
::
play_stop
()
{
int
ret
=
ERROR_SUCCESS
;
if
(
true
)
{
SrsBandwidthPacket
*
pkt
=
NULL
;
if
((
ret
=
_srs_expect_bandwidth_packet2
(
_rtmp
,
_bandwidth_is_stop_play
,
&
pkt
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
SrsAutoFree
(
SrsBandwidthPacket
,
pkt
);
SrsAmf0Any
*
prop
=
NULL
;
if
((
prop
=
pkt
->
data
->
ensure_property_number
(
"duration_delta"
))
!=
NULL
)
{
duration_delta
=
(
int
)
prop
->
to_number
();
}
if
((
prop
=
pkt
->
data
->
ensure_property_number
(
"bytes_delta"
))
!=
NULL
)
{
bytes_delta
=
(
int
)
prop
->
to_number
();
}
if
((
ret
=
_srs_expect_bandwidth_packet
(
_rtmp
,
_bandwidth_is_stop_play
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
srs_info
(
"BW check recv play stop request."
);
...
...
@@ -261,7 +240,7 @@ int SrsBandwidthClient::play_stop(int& duration_delta, int& bytes_delta)
return
ret
;
}
int
SrsBandwidthClient
::
publish_start
(
int
&
duration_ms
)
int
SrsBandwidthClient
::
publish_start
(
int
&
duration_ms
,
int
&
play_kbps
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -276,6 +255,9 @@ int SrsBandwidthClient::publish_start(int& duration_ms)
if
((
prop
=
pkt
->
data
->
ensure_property_number
(
"duration_ms"
))
!=
NULL
)
{
duration_ms
=
(
int
)
prop
->
to_number
();
}
if
((
prop
=
pkt
->
data
->
ensure_property_number
(
"limit_kbps"
))
!=
NULL
)
{
play_kbps
=
(
int
)
prop
->
to_number
();
}
}
srs_info
(
"BW check recv publish begin request."
);
...
...
trunk/src/libs/srs_lib_bandwidth.hpp
查看文件 @
5c4398f
...
...
@@ -73,11 +73,11 @@ private:
*/
virtual
int
play_start
();
virtual
int
play_checking
();
virtual
int
play_stop
(
int
&
duration_delta
,
int
&
bytes_delta
);
virtual
int
play_stop
();
/**
* publish check/test, publishing bandwidth kbps.
*/
virtual
int
publish_start
(
int
&
duration_ms
);
virtual
int
publish_start
(
int
&
duration_ms
,
int
&
play_kbps
);
virtual
int
publish_checking
(
int
duration_ms
,
int
play_kbps
);
virtual
int
publish_stop
();
/**
...
...
请
注册
或
登录
后发表评论