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-05 12:57:48 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ae63af6a4adb2a788aaff184b1617d8d82639eb7
ae63af6a
1 parent
97bea514
refine code, implements the stat.:
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
51 行增加
和
4 行删除
trunk/src/app/srs_app_statistic.cpp
trunk/src/app/srs_app_statistic.hpp
trunk/src/app/srs_app_statistic.cpp
查看文件 @
ae63af6
...
...
@@ -23,7 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_statistic.hpp>
#include <sstream>
using
namespace
std
;
#include <srs_protocol_rtmp.hpp>
#include <srs_app_json.hpp>
SrsStatistic
*
SrsStatistic
::
_instance
=
new
SrsStatistic
();
...
...
@@ -61,20 +65,63 @@ SrsStatistic* SrsStatistic::instance()
return
_instance
;
}
int
SrsStatistic
::
on_client
(
int
id
,
SrsRequest
*
req
)
int
SrsStatistic
::
on_client
(
int
id
,
SrsRequest
*
req
)
{
int
ret
=
ERROR_SUCCESS
;
// create vhost if not exists.
SrsStatisticVhost
*
vhost
=
NULL
;
if
(
vhosts
.
find
(
req
->
vhost
)
==
vhosts
.
end
())
{
vhost
=
new
SrsStatisticVhost
();
vhost
->
vhost
=
req
->
vhost
;
vhosts
[
req
->
vhost
]
=
vhost
;
}
else
{
vhost
=
vhosts
[
req
->
vhost
];
}
// the url to identify the stream.
std
::
string
url
=
req
->
get_stream_url
();
// create stream if not exists.
SrsStatisticStream
*
stream
=
NULL
;
if
(
streams
.
find
(
url
)
==
streams
.
end
())
{
stream
=
new
SrsStatisticStream
();
stream
->
vhost
=
vhost
;
stream
->
stream
=
url
;
streams
[
url
]
=
stream
;
}
else
{
stream
=
streams
[
url
];
}
return
ret
;
}
int
SrsStatistic
::
dumps_vhosts
(
st
d
::
st
ringstream
&
ss
)
int
SrsStatistic
::
dumps_vhosts
(
stringstream
&
ss
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
std
::
string
,
SrsStatisticVhost
*>::
iterator
it
;
for
(
it
=
vhosts
.
begin
();
it
!=
vhosts
.
end
();
it
++
)
{
SrsStatisticVhost
*
vhost
=
it
->
second
;
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_STR
(
"name"
,
vhost
->
vhost
)
<<
__SRS_JOBJECT_END
;
}
return
ret
;
}
int
SrsStatistic
::
dumps_streams
(
st
d
::
st
ringstream
&
ss
)
int
SrsStatistic
::
dumps_streams
(
stringstream
&
ss
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
map
<
std
::
string
,
SrsStatisticStream
*>::
iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
it
++
)
{
SrsStatisticStream
*
stream
=
it
->
second
;
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_STR
(
"url"
,
stream
->
stream
)
<<
__SRS_JOBJECT_END
;
}
return
ret
;
}
...
...
trunk/src/app/srs_app_statistic.hpp
查看文件 @
ae63af6
...
...
@@ -77,7 +77,7 @@ public:
* @param id, the client srs id.
* @param req, the client request object.
*/
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
);
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
);
public
:
/**
* dumps the vhosts to sstream in json.
...
...
请
注册
或
登录
后发表评论