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-06 22:20:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
08e9f6ef42ecbb7be34550d0cde64aa19bc215d7
08e9f6ef
1 parent
532a4840
add play client num in statistic
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
76 行增加
和
8 行删除
trunk/src/app/srs_app_http_api.cpp
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_http_api.cpp
查看文件 @
08e9f6e
...
...
@@ -530,9 +530,7 @@ int SrsApiVhosts::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_ERROR
(
ret
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"server"
,
stat
->
server_id
())
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"vhosts"
,
__SRS_JARRAY_START
)
<<
data
.
str
()
<<
__SRS_JARRAY_END
<<
__SRS_JFIELD_ORG
(
"vhosts"
,
data
.
str
())
<<
__SRS_JOBJECT_END
;
return
res_json
(
skt
,
req
,
ss
.
str
());
...
...
@@ -562,9 +560,7 @@ int SrsApiStreams::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_ERROR
(
ret
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"server"
,
stat
->
server_id
())
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"streams"
,
__SRS_JARRAY_START
)
<<
data
.
str
()
<<
__SRS_JARRAY_END
<<
__SRS_JFIELD_ORG
(
"streams"
,
data
.
str
())
<<
__SRS_JOBJECT_END
;
return
res_json
(
skt
,
req
,
ss
.
str
());
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
08e9f6e
...
...
@@ -398,7 +398,8 @@ int SrsRtmpConn::stream_service_cycle()
// update the statistic when source disconveried.
SrsStatistic
*
stat
=
SrsStatistic
::
instance
();
if
((
ret
=
stat
->
on_client
(
_srs_context
->
get_id
(),
req
))
!=
ERROR_SUCCESS
)
{
int
client_id
=
_srs_context
->
get_id
();
if
((
ret
=
stat
->
on_client
(
client_id
,
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"stat client failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -445,9 +446,15 @@ 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
查看文件 @
08e9f6e
...
...
@@ -50,6 +50,7 @@ SrsStatisticStream::SrsStatisticStream()
{
id
=
__srs_generate_id
();
vhost
=
NULL
;
clients
=
0
;
}
SrsStatisticStream
::~
SrsStatisticStream
()
...
...
@@ -122,6 +123,42 @@ int SrsStatistic::on_client(int id, SrsRequest* req)
stream
=
streams
[
url
];
}
// create client if not exists
SrsStatisticClient
*
client
=
NULL
;
if
(
clients
.
find
(
id
)
==
clients
.
end
())
{
client
=
new
SrsStatisticClient
();
client
->
stream
=
stream
;
clients
[
id
]
=
client
;
}
else
{
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
++
;
}
return
ret
;
}
int
SrsStatistic
::
on_client_play_stop
(
int
id
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
int
,
SrsStatisticClient
*>::
iterator
it
;
it
=
clients
.
find
(
id
);
if
(
it
!=
clients
.
end
())
{
it
->
second
->
stream
->
clients
--
;
}
return
ret
;
}
...
...
@@ -134,14 +171,23 @@ 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
{
ss
<<
__SRS_JFIELD_CONT
;
}
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_ORG
(
"id"
,
vhost
->
id
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"name"
,
vhost
->
vhost
)
<<
__SRS_JOBJECT_END
;
}
ss
<<
__SRS_JARRAY_END
;
return
ret
;
}
...
...
@@ -150,15 +196,25 @@ 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
{
ss
<<
__SRS_JFIELD_CONT
;
}
ss
<<
__SRS_JOBJECT_START
<<
__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_ORG
(
"vhost"
,
stream
->
vhost
->
id
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"clients"
,
stream
->
clients
)
<<
__SRS_JOBJECT_END
;
}
ss
<<
__SRS_JARRAY_END
;
return
ret
;
}
...
...
trunk/src/app/srs_app_statistic.hpp
查看文件 @
08e9f6e
...
...
@@ -53,6 +53,7 @@ public:
std
::
string
app
;
std
::
string
stream
;
std
::
string
url
;
int64_t
clients
;
public
:
SrsStatisticStream
();
virtual
~
SrsStatisticStream
();
...
...
@@ -89,6 +90,14 @@ public:
* @param req, the client request object.
*/
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
);
/**
* client start play
*/
virtual
int
on_client_play_start
(
int
id
);
/**
* client stop play
*/
virtual
int
on_client_play_stop
(
int
id
);
public
:
/**
* get the server id, used to identify the server.
...
...
请
注册
或
登录
后发表评论