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
qiang.li
2015-01-07 23:27:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
46d716612cd17512df56ed4f130c07448ec2ddc7
46d71661
1 parent
08e9f6ef
add client num for stream in statistic
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
15 行增加
和
39 行删除
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_statistic.cpp
trunk/src/app/srs_app_statistic.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
46d7166
...
...
@@ -200,6 +200,7 @@ int SrsRtmpConn::do_cycle()
ret
=
service_cycle
();
http_hooks_on_close
();
SrsStatistic
::
instance
()
->
on_close
(
_srs_context
->
get_id
());
return
ret
;
}
...
...
@@ -398,8 +399,7 @@ int SrsRtmpConn::stream_service_cycle()
// update the statistic when source disconveried.
SrsStatistic
*
stat
=
SrsStatistic
::
instance
();
int
client_id
=
_srs_context
->
get_id
();
if
((
ret
=
stat
->
on_client
(
client_id
,
req
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
stat
->
on_client
(
_srs_context
->
get_id
(),
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"stat client failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -446,15 +446,9 @@ int SrsRtmpConn::stream_service_cycle()
return
ret
;
}
if
((
ret
=
stat
->
on_client_play_start
(
client_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"stat client play start failed. ret=%d"
,
ret
);
return
ret
;
}
srs_info
(
"start to play stream %s success"
,
req
->
stream
.
c_str
());
ret
=
playing
(
source
);
http_hooks_on_stop
();
stat
->
on_client_play_stop
(
client_id
);
return
ret
;
}
...
...
trunk/src/app/srs_app_statistic.cpp
查看文件 @
46d7166
...
...
@@ -50,7 +50,6 @@ SrsStatisticStream::SrsStatisticStream()
{
id
=
__srs_generate_id
();
vhost
=
NULL
;
clients
=
0
;
}
SrsStatisticStream
::~
SrsStatisticStream
()
...
...
@@ -133,30 +132,22 @@ int SrsStatistic::on_client(int id, SrsRequest* req)
client
=
clients
[
id
];
}
return
ret
;
}
int
SrsStatistic
::
on_client_play_start
(
int
id
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
int
,
SrsStatisticClient
*>::
iterator
it
;
it
=
clients
.
find
(
id
);
if
(
it
!=
clients
.
end
())
{
it
->
second
->
stream
->
clients
++
;
}
stream
->
clients
[
id
]
=
client
;
return
ret
;
}
int
SrsStatistic
::
on_cl
ient_play_stop
(
int
id
)
int
SrsStatistic
::
on_cl
ose
(
int
id
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
int
,
SrsStatisticClient
*>::
iterator
it
;
it
=
clients
.
find
(
id
);
if
(
it
!=
clients
.
end
())
{
it
->
second
->
stream
->
clients
--
;
SrsStatisticClient
*
client
=
it
->
second
;
client
->
stream
->
clients
.
erase
(
id
);
srs_freep
(
client
);
clients
.
erase
(
it
);
}
return
ret
;
...
...
@@ -172,13 +163,10 @@ int SrsStatistic::dumps_vhosts(stringstream& ss)
int
ret
=
ERROR_SUCCESS
;
ss
<<
__SRS_JARRAY_START
;
bool
first
=
true
;
std
::
map
<
std
::
string
,
SrsStatisticVhost
*>::
iterator
it
;
for
(
it
=
vhosts
.
begin
();
it
!=
vhosts
.
end
();
it
++
)
{
SrsStatisticVhost
*
vhost
=
it
->
second
;
if
(
first
)
{
first
=
false
;
}
else
{
if
(
it
!=
vhosts
.
begin
())
{
ss
<<
__SRS_JFIELD_CONT
;
}
...
...
@@ -197,13 +185,10 @@ int SrsStatistic::dumps_streams(stringstream& ss)
int
ret
=
ERROR_SUCCESS
;
ss
<<
__SRS_JARRAY_START
;
bool
first
=
true
;
std
::
map
<
std
::
string
,
SrsStatisticStream
*>::
iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
it
++
)
{
SrsStatisticStream
*
stream
=
it
->
second
;
if
(
first
)
{
first
=
false
;
}
else
{
if
(
it
!=
streams
.
begin
())
{
ss
<<
__SRS_JFIELD_CONT
;
}
...
...
@@ -211,7 +196,7 @@ int SrsStatistic::dumps_streams(stringstream& ss)
<<
__SRS_JFIELD_ORG
(
"id"
,
stream
->
id
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"name"
,
stream
->
stream
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"vhost"
,
stream
->
vhost
->
id
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"clients"
,
stream
->
clients
)
<<
__SRS_JFIELD_ORG
(
"clients"
,
stream
->
clients
.
size
()
)
<<
__SRS_JOBJECT_END
;
}
ss
<<
__SRS_JARRAY_END
;
...
...
trunk/src/app/srs_app_statistic.hpp
查看文件 @
46d7166
...
...
@@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
class
SrsRequest
;
struct
SrsStatisticClient
;
struct
SrsStatisticVhost
{
...
...
@@ -53,7 +54,7 @@ public:
std
::
string
app
;
std
::
string
stream
;
std
::
string
url
;
int64_t
clients
;
std
::
map
<
int
,
SrsStatisticClient
*>
clients
;
public
:
SrsStatisticStream
();
virtual
~
SrsStatisticStream
();
...
...
@@ -91,13 +92,9 @@ public:
*/
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
);
/**
* client start play
*/
virtual
int
on_client_play_start
(
int
id
);
/**
* client stop play
* client close
*/
virtual
int
on_cl
ient_play_stop
(
int
id
);
virtual
int
on_cl
ose
(
int
id
);
public
:
/**
* get the server id, used to identify the server.
...
...
请
注册
或
登录
后发表评论