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-01-08 15:52:44 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ac584a4db2a62e7afc065a273e07efacfab15506
ac584a4d
2 parents
44f5efda
46d71661
Merge pull request #279 from tufang14/develop
add client num for stream in statistic for #227
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
52 行增加
和
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
查看文件 @
ac584a4
...
...
@@ -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
查看文件 @
ac584a4
...
...
@@ -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
;
}
...
...
trunk/src/app/srs_app_statistic.cpp
查看文件 @
ac584a4
...
...
@@ -121,7 +121,35 @@ int SrsStatistic::on_client(int id, SrsRequest* req)
}
else
{
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
];
}
stream
->
clients
[
id
]
=
client
;
return
ret
;
}
int
SrsStatistic
::
on_close
(
int
id
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
int
,
SrsStatisticClient
*>::
iterator
it
;
it
=
clients
.
find
(
id
);
if
(
it
!=
clients
.
end
())
{
SrsStatisticClient
*
client
=
it
->
second
;
client
->
stream
->
clients
.
erase
(
id
);
srs_freep
(
client
);
clients
.
erase
(
it
);
}
return
ret
;
}
...
...
@@ -134,15 +162,21 @@ int SrsStatistic::dumps_vhosts(stringstream& ss)
{
int
ret
=
ERROR_SUCCESS
;
ss
<<
__SRS_JARRAY_START
;
std
::
map
<
std
::
string
,
SrsStatisticVhost
*>::
iterator
it
;
for
(
it
=
vhosts
.
begin
();
it
!=
vhosts
.
end
();
it
++
)
{
SrsStatisticVhost
*
vhost
=
it
->
second
;
if
(
it
!=
vhosts
.
begin
())
{
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 +184,22 @@ int SrsStatistic::dumps_streams(stringstream& ss)
{
int
ret
=
ERROR_SUCCESS
;
ss
<<
__SRS_JARRAY_START
;
std
::
map
<
std
::
string
,
SrsStatisticStream
*>::
iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
it
++
)
{
SrsStatisticStream
*
stream
=
it
->
second
;
if
(
it
!=
streams
.
begin
())
{
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
.
size
())
<<
__SRS_JOBJECT_END
;
}
ss
<<
__SRS_JARRAY_END
;
return
ret
;
}
...
...
trunk/src/app/srs_app_statistic.hpp
查看文件 @
ac584a4
...
...
@@ -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,6 +54,7 @@ public:
std
::
string
app
;
std
::
string
stream
;
std
::
string
url
;
std
::
map
<
int
,
SrsStatisticClient
*>
clients
;
public
:
SrsStatisticStream
();
virtual
~
SrsStatisticStream
();
...
...
@@ -89,6 +91,10 @@ public:
* @param req, the client request object.
*/
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
);
/**
* client close
*/
virtual
int
on_close
(
int
id
);
public
:
/**
* get the server id, used to identify the server.
...
...
请
注册
或
登录
后发表评论