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
2015-03-08 12:55:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8bf60895a987ec5229d4113a9bff33a418f30abb
8bf60895
1 parent
fbbe46d2
refine the kbps of server.
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
27 行增加
和
34 行删除
trunk/src/app/srs_app_conn.hpp
trunk/src/app/srs_app_kbps.hpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_utility.cpp
trunk/src/app/srs_app_conn.hpp
查看文件 @
8bf6089
...
...
@@ -92,6 +92,7 @@ public:
virtual
void
on_thread_stop
();
public
:
/**
* reset and start sample of bytes.
* when server to get the kbps of connection,
* it cannot wait the connection terminated then get the kbps,
* it must sample the kbps every some interval, for instance, 9s to sample all connections kbps,
...
...
trunk/src/app/srs_app_kbps.hpp
查看文件 @
8bf6089
...
...
@@ -122,12 +122,12 @@ public:
* to statistic the kbps of io.
* itself can be a statistic source, for example, used for SRS bytes stat.
* there are two usage scenarios:
* 1. connections to calc kbps:
* 1. connections to calc kbps
by sample()
:
* set_io(in, out)
* sample()
* get_xxx_kbps().
* the connections know how many bytes already send/recv.
* 2. server to calc kbps:
* 2. server to calc kbps
by add_delta()
:
* set_io(NULL, NULL)
* for each connection in connections:
* add_delta(connections) // where connection is a IKbpsDelta*
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
8bf6089
...
...
@@ -745,8 +745,12 @@ void SrsServer::remove(SrsConnection* conn)
srs_info
(
"conn removed. conns=%d"
,
(
int
)
conns
.
size
());
// resample the resource of specified connection.
resample_kbps
(
conn
);
// resample the kbps to collect the delta.
conn
->
kbps_resample
();
// add delta of connection to server kbps.,
// for next sample() of server kbps can get the stat.
kbps
->
add_delta
(
conn
);
// all connections are created by server,
// so we free it here.
...
...
@@ -862,8 +866,8 @@ int SrsServer::do_cycle()
srs_update_network_devices
();
}
if
((
i
%
SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES
)
==
0
)
{
srs_info
(
"update network rtmp server info."
);
resample_kbps
(
NULL
);
srs_info
(
"update network server kbps info."
);
resample_kbps
();
srs_update_rtmp_server
((
int
)
conns
.
size
(),
kbps
);
}
#ifdef SRS_AUTO_HTTP_PARSER
...
...
@@ -1013,31 +1017,24 @@ void SrsServer::close_listeners(SrsListenerType type)
}
}
void
SrsServer
::
resample_kbps
(
SrsConnection
*
conn
,
bool
do_resample
)
void
SrsServer
::
resample_kbps
()
{
// resample all when conn is NULL.
if
(
!
conn
)
{
for
(
std
::
vector
<
SrsConnection
*>::
iterator
it
=
conns
.
begin
();
it
!=
conns
.
end
();
++
it
)
{
SrsConnection
*
client
=
*
it
;
srs_assert
(
client
);
// only resample, do resample when all finished.
resample_kbps
(
client
,
false
);
}
// collect delta from all clients.
for
(
std
::
vector
<
SrsConnection
*>::
iterator
it
=
conns
.
begin
();
it
!=
conns
.
end
();
++
it
)
{
SrsConnection
*
conn
=
*
it
;
// resample the kbps to collect the delta.
conn
->
kbps_resample
();
kbps
->
sample
();
return
;
// add delta of connection to server kbps.,
// for next sample() of server kbps can get the stat.
kbps
->
add_delta
(
conn
);
}
// resample for connection.
conn
->
kbps_resample
();
kbps
->
add_delta
(
conn
);
// resample for server.
if
(
do_resample
)
{
kbps
->
sample
();
}
// TODO: FXME: support all other connections.
// sample the kbps, get the stat.
kbps
->
sample
();
}
int
SrsServer
::
accept_client
(
SrsListenerType
type
,
st_netfd_t
client_stfd
)
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
8bf6089
...
...
@@ -278,12 +278,9 @@ private:
*/
virtual
void
close_listeners
(
SrsListenerType
type
);
/**
* resample the server kbps.
* if conn is NULL, resample all connections delta, then calc the total kbps.
* @param conn, the connection to do resample the kbps. NULL to resample all connections.
* @param do_resample, whether resample the server kbps. always false when sample a connection.
* resample the server kbs.
*/
virtual
void
resample_kbps
(
SrsConnection
*
conn
,
bool
do_resample
=
true
);
virtual
void
resample_kbps
();
// internal only
public:
/**
...
...
trunk/src/app/srs_app_utility.cpp
查看文件 @
8bf6089
...
...
@@ -1119,9 +1119,7 @@ void srs_api_dump_summaries(std::stringstream& ss)
<<
__SRS_JFIELD_ORG
(
"net_send_bytes"
,
ns_bytes
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"srs_sample_time"
,
nrs
->
sample_time
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"srs_recv_bytes"
,
nrs
->
rbytes
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"srs_recv_kbps"
,
nrs
->
rkbps
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"srs_send_bytes"
,
nrs
->
sbytes
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"srs_send_kbps"
,
nrs
->
skbps
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys"
,
nrs
->
nb_conn_sys
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_et"
,
nrs
->
nb_conn_sys_et
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_tw"
,
nrs
->
nb_conn_sys_tw
)
<<
__SRS_JFIELD_CONT
...
...
请
注册
或
登录
后发表评论