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-12 22:22:56 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3a1b3dd142a1ff8e31c3c287e94e38649cbc474f
3a1b3dd1
1 parent
d8ed7cc9
fix bandwidth bug, config item interval to float.
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
38 行增加
和
16 行删除
trunk/research/players/srs_bwt.html
trunk/research/players/srs_bwt/src/srs.bandwidth.js
trunk/src/app/srs_app_bandwidth.cpp
trunk/src/app/srs_app_config.cpp
trunk/src/rtmp/srs_protocol_rtmp.cpp
trunk/research/players/srs_bwt.html
查看文件 @
3a1b3dd
...
...
@@ -41,6 +41,7 @@
}
function
on_start_bandwidth_test
()
{
$
(
"#div_container"
).
remove
();
$
(
"#progress_bar"
).
removeClass
(
"bar-danger"
);
var
div_container
=
$
(
"<div/>"
);
$
(
div_container
).
attr
(
"id"
,
"div_container"
);
...
...
@@ -68,6 +69,9 @@
", srs_id:"
+
srs_id
+
", srs_pid:"
+
srs_pid
+
", ip:"
+
srs_server_ip
);
}
bandwidth
.
on_error
=
function
(
code
)
{
$
(
"#progress_bar"
).
addClass
(
"bar-danger"
);
}
bandwidth
.
render
(
url
);
}
function
on_stop_bandwidth_test
()
{
...
...
trunk/research/players/srs_bwt/src/srs.bandwidth.js
查看文件 @
3a1b3dd
...
...
@@ -49,8 +49,8 @@ function SrsBandwidth(container, width, height, private_object) {
// the callback set data.
this
.
percent
=
0
;
this
.
status
=
""
;
this
.
report
=
""
;
this
.
server
=
""
;
this
.
completed
=
false
;
}
/**
* user can set some callback, then start the bandwidth.
...
...
@@ -106,6 +106,12 @@ SrsBandwidth.prototype.check_bandwidth = function(url) {
this
.
stop
();
SrsBandwidth
.
__bandwidths
.
push
(
this
);
// the callback set data.
this
.
percent
=
0
;
this
.
status
=
""
;
this
.
server
=
""
;
this
.
completed
=
false
;
if
(
url
)
{
this
.
stream_url
=
url
;
}
...
...
@@ -136,6 +142,8 @@ SrsBandwidth.prototype.on_srs_info = function(srs_server, srs_primary_authors, s
}
SrsBandwidth
.
prototype
.
on_complete
=
function
(
start_time
,
end_time
,
play_kbps
,
publish_kbps
,
play_bytes
,
publish_bytes
,
play_time
,
publish_time
)
{
}
SrsBandwidth
.
prototype
.
on_error
=
function
(
code
)
{
}
function
__srs_find_bandwidth
(
id
)
{
for
(
var
i
=
0
;
i
<
SrsBandwidth
.
__bandwidths
.
length
;
i
++
)
{
var
bandwidth
=
SrsBandwidth
.
__bandwidths
[
i
];
...
...
@@ -164,24 +172,36 @@ function __srs_on_update_status(id, code, data) {
var
status
=
""
;
switch
(
code
){
case
"NetConnection.Connect.Failed"
:
if
(
bandwidth
.
completed
)
{
return
;
}
bandwidth
.
on_error
(
code
);
status
=
"连接服务器失败!"
;
break
;
case
"NetConnection.Connect.Rejected"
:
status
=
"服务器拒绝连接!"
;
if
(
bandwidth
.
completed
)
{
return
;
}
bandwidth
.
completed
=
true
;
bandwidth
.
on_update_progress
(
100
);
bandwidth
.
on_error
(
code
);
status
=
"服务器拒绝连接,测速过于频繁!"
;
break
;
case
"NetConnection.Connect.Success"
:
status
=
"连接服务器成功!"
;
break
;
case
"NetConnection.Connect.Closed"
:
if
(
bandwidth
.
report
)
{
if
(
bandwidth
.
completed
)
{
return
;
}
bandwidth
.
on_error
(
code
);
status
=
"连接已断开!"
;
break
;
case
"srs.bwtc.play.start"
:
status
=
"开始测试下行带宽"
;
break
;
case
"srs.bwtc.play.stop"
:
bandwidth
.
completed
=
true
;
status
=
"下行带宽测试完毕,"
+
data
+
"kbps,开始测试上行带宽。"
;
break
;
default
:
...
...
@@ -202,7 +222,7 @@ function __srs_on_complete(id, start_time, end_time, play_kbps, publish_kbps, pl
var
status
=
"检测结束: "
+
bandwidth
.
server
+
" 上行: "
+
publish_kbps
+
" kbps"
+
" 下行: "
+
play_kbps
+
" kbps"
+
" 测试时间: "
+
Number
((
end_time
-
start_time
)
/
1000
).
toFixed
(
1
)
+
" 秒"
;
bandwidth
.
report
=
status
;
bandwidth
.
status
=
status
;
bandwidth
.
on_update_status
(
status
);
bandwidth
.
on_complete
(
start_time
,
end_time
,
play_kbps
,
publish_kbps
,
play_bytes
,
publish_bytes
,
play_time
,
publish_time
);
...
...
trunk/src/app/srs_app_bandwidth.cpp
查看文件 @
3a1b3dd
...
...
@@ -78,7 +78,7 @@ int SrsBandwidth::bandwidth_check(SrsRtmpServer* rtmp, SrsRequest* req, string l
// reject the connection in the interval window.
if
(
last_check_time
>
0
&&
time_now
-
last_check_time
<
interval_ms
)
{
ret
=
ERROR_SYSTEM_BANDWIDTH_DENIED
;
srs_trace
(
"
bandcheck denied
, "
srs_trace
(
"
reject
, "
"last_check=%"
PRId64
", now=%"
PRId64
", interval=%d"
,
last_check_time
,
time_now
,
interval_ms
);
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
3a1b3dd
...
...
@@ -1866,20 +1866,20 @@ int SrsConfig::get_bw_check_interval_ms(const string &vhost)
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
;
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
*
1000
;
}
conf
=
conf
->
get
(
"bandcheck"
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
;
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
*
1000
;
}
conf
=
conf
->
get
(
"interval
_ms
"
);
conf
=
conf
->
get
(
"interval"
);
if
(
!
conf
)
{
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
;
return
SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL
*
1000
;
}
return
::
ato
i
(
conf
->
arg0
().
c_str
())
*
1000
;
return
::
ato
f
(
conf
->
arg0
().
c_str
())
*
1000
;
}
int
SrsConfig
::
get_bw_check_limit_kbps
(
const
string
&
vhost
)
...
...
trunk/src/rtmp/srs_protocol_rtmp.cpp
查看文件 @
3a1b3dd
...
...
@@ -910,12 +910,10 @@ void SrsRtmpServer::response_connect_reject(SrsRequest *req, const char* desc)
{
int
ret
=
ERROR_SUCCESS
;
SrsConnectAppResPacket
*
pkt
=
new
SrsConnectAppResPacket
();
pkt
->
command_name
=
"_error"
;
pkt
->
props
->
set
(
StatusLevel
,
SrsAmf0Any
::
str
(
StatusLevelError
));
pkt
->
props
->
set
(
StatusCode
,
SrsAmf0Any
::
str
(
StatusCodeConnectRejected
));
pkt
->
props
->
set
(
StatusDescription
,
SrsAmf0Any
::
str
(
desc
));
//pkt->props->set("objectEncoding", SrsAmf0Any::number(req->objectEncoding));
SrsOnStatusCallPacket
*
pkt
=
new
SrsOnStatusCallPacket
();
pkt
->
data
->
set
(
StatusLevel
,
SrsAmf0Any
::
str
(
StatusLevelError
));
pkt
->
data
->
set
(
StatusCode
,
SrsAmf0Any
::
str
(
StatusCodeConnectRejected
));
pkt
->
data
->
set
(
StatusDescription
,
SrsAmf0Any
::
str
(
desc
));
if
((
ret
=
protocol
->
send_and_free_packet
(
pkt
,
0
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"send connect app response rejected message failed. ret=%d"
,
ret
);
...
...
请
注册
或
登录
后发表评论