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-04 22:47:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a4a93613d0cda57f51ea4f4cb8a60f2965d9c100
a4a93613
1 parent
8d534d34
add statistic for stream
显示空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
189 行增加
和
49 行删除
trunk/configure
trunk/src/app/srs_app_edge.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/app/srs_app_statistic.cpp
trunk/src/app/srs_app_statistic.hpp
trunk/configure
查看文件 @
a4a9361
...
...
@@ -389,7 +389,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_pithy_print"
"srs_app_reload"
"srs_app_http_api"
"srs_app_http_conn"
"srs_app_http_hooks"
"srs_app_json"
"srs_app_ingest"
"srs_app_ffmpeg"
"srs_app_utility"
"srs_app_dvr"
"srs_app_edge"
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_avc_aac"
"srs_app_recv_thread"
)
"srs_app_recv_thread"
"srs_app_statistic"
)
APP_INCS
=
"src/app"
;
MODULE_DIR
=
${
APP_INCS
}
. auto/modules.sh
APP_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
fi
...
...
trunk/src/app/srs_app_edge.hpp
查看文件 @
a4a9361
...
...
@@ -188,10 +188,6 @@ public:
* when ingester start to play stream.
*/
virtual
int
on_ingest_play
();
/**
* get state info.
*/
virtual
int
get_state
()
{
return
state
;
}
};
/**
...
...
@@ -223,10 +219,6 @@ public:
* proxy unpublish stream to edge.
*/
virtual
void
on_proxy_unpublish
();
/**
* get state info.
*/
virtual
int
get_state
()
{
return
state
;
}
};
#endif
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
a4a9361
...
...
@@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef SRS_AUTO_HTTP_API
#include <sstream>
#include <set>
using
namespace
std
;
#include <srs_kernel_log.hpp>
...
...
@@ -35,7 +36,7 @@ using namespace std;
#include <srs_app_json.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_s
ource
.hpp>
#include <srs_app_s
tatistic
.hpp>
#include <srs_protocol_rtmp.hpp>
SrsApiRoot
::
SrsApiRoot
()
...
...
@@ -153,7 +154,7 @@ int SrsApiV1::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
<<
__SRS_JFIELD_STR
(
"authors"
,
"the primary authors and contributors"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"requests"
,
"the request itself, for http debug"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"vhosts"
,
"list all vhosts"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"streams
?(name/vhost)=xxx
"
,
"list streams that match the name or vhost"
)
<<
__SRS_JFIELD_STR
(
"streams"
,
"list streams that match the name or vhost"
)
<<
__SRS_JOBJECT_END
<<
__SRS_JOBJECT_END
;
...
...
@@ -523,16 +524,26 @@ int SrsApiVhosts::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
{
std
::
stringstream
ss
;
std
::
set
<
std
::
string
>
vhost_set
;
SrsStreamInfoMap
*
pool
=
SrsStatistic
::
instance
()
->
get_pool
();
SrsStreamInfoMap
::
iterator
it
;
for
(
it
=
pool
->
begin
();
it
!=
pool
->
end
();
it
++
)
{
if
(
it
->
second
->
_req
==
NULL
)
continue
;
vhost_set
.
insert
(
it
->
second
->
_req
->
vhost
);
}
ss
<<
__SRS_JARRAY_START
;
bool
first
=
true
;
std
::
map
<
std
::
string
,
SrsSource
*>
*
source_pool
=
SrsSource
::
get_source_pool
();
std
::
map
<
std
::
string
,
SrsSource
*>::
iterator
it
;
for
(
it
=
source_pool
->
begin
();
it
!=
source_pool
->
end
();
it
++
)
{
SrsRequest
*
source_req
=
it
->
second
->
get_reqinfo
();
if
(
first
)
first
=
false
;
else
ss
<<
__SRS_JFIELD_CONT
;
ss
<<
"
\"
"
<<
source_req
->
vhost
<<
"
\"
"
;
std
::
set
<
std
::
string
>::
iterator
it_set
;
for
(
it_set
=
vhost_set
.
begin
();
it_set
!=
vhost_set
.
end
();
it_set
++
)
{
if
(
first
)
{
first
=
false
;
}
else
{
ss
<<
__SRS_JFIELD_CONT
;
}
ss
<<
"
\"
"
<<
(
*
it_set
)
<<
"
\"
"
;
}
ss
<<
__SRS_JARRAY_END
;
...
...
@@ -558,24 +569,29 @@ int SrsApiStreams::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
std
::
string
query_name
=
req
->
query_get
(
"name"
);
std
::
string
query_vhost
=
req
->
query_get
(
"vhost"
);
if
(
query_name
.
size
()
>
0
||
query_vhost
.
size
()
>
0
)
{
if
(
query_name
.
size
()
>
0
||
query_vhost
.
size
()
>
0
)
{
ss
<<
__SRS_JARRAY_START
;
bool
first
=
true
;
std
::
map
<
std
::
string
,
SrsSource
*>
*
source_pool
=
SrsSource
::
get_source_pool
();
std
::
map
<
std
::
string
,
SrsSource
*>::
iterator
it
;
for
(
it
=
source_pool
->
begin
();
it
!=
source_pool
->
end
();
it
++
)
{
SrsSource
*
source
=
it
->
second
;
SrsRequest
*
source_req
=
source
->
get_reqinfo
();
if
(
source_req
->
stream
==
query_name
||
source_req
->
vhost
==
query_vhost
)
{
if
(
first
)
first
=
false
;
else
ss
<<
__SRS_JFIELD_CONT
;
SrsStreamInfoMap
*
pool
=
SrsStatistic
::
instance
()
->
get_pool
();
SrsStreamInfoMap
::
iterator
it
;
for
(
it
=
pool
->
begin
();
it
!=
pool
->
end
();
it
++
)
{
SrsRequest
*
reqinfo
=
it
->
second
->
_req
;
if
(
reqinfo
==
NULL
)
continue
;
if
(
reqinfo
->
stream
==
query_name
||
reqinfo
->
vhost
==
query_vhost
)
{
if
(
first
)
{
first
=
false
;
}
else
{
ss
<<
__SRS_JFIELD_CONT
;
}
ss
<<
__SRS_JOBJECT_START
<<
__SRS_JFIELD_STR
(
"name"
,
source_req
->
stream
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"url"
,
source_req
->
tcUrl
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"clients"
,
source
->
get_consumers_size
())
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"status"
,
(
source
->
can_publish
()
?
"idle"
:
"streaming"
))
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"type"
,
source
->
get_source_type
())
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"name"
,
reqinfo
->
stream
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"url"
,
reqinfo
->
tcUrl
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"clients"
,
0
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"status"
,
"idle"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"type"
,
""
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"codec"
,
""
)
<<
__SRS_JOBJECT_END
;
}
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
a4a9361
...
...
@@ -51,6 +51,7 @@ using namespace std;
#include <srs_app_recv_thread.hpp>
#include <srs_core_performance.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_app_statistic.hpp>
// when stream is busy, for example, streaming is already
// publishing, when a new client to request to publish,
...
...
@@ -382,6 +383,8 @@ int SrsRtmpConn::stream_service_cycle()
}
srs_assert
(
source
!=
NULL
);
SrsStatistic
::
instance
()
->
add_request_info
(
source
,
req
);
// check ASAP, to fail it faster if invalid.
if
(
type
!=
SrsRtmpConnPlay
&&
!
vhost_is_edge
)
{
// check publish available
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
a4a9361
...
...
@@ -1807,13 +1807,3 @@ void SrsSource::destroy_forwarders()
forwarders
.
clear
();
}
std
::
string
SrsSource
::
get_source_type
()
{
if
(
play_edge
->
get_state
()
==
SrsEdgeStateIngestConnected
)
{
return
"origin pull"
;
}
else
if
(
publish_edge
->
get_state
()
==
SrsEdgeStatePublish
)
{
return
"edge publish"
;
}
else
{
return
"normal publish"
;
}
}
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
a4a9361
...
...
@@ -486,12 +486,6 @@ public:
private
:
virtual
int
create_forwarders
();
virtual
void
destroy_forwarders
();
//get information
public:
static
std
::
map
<
std
::
string
,
SrsSource
*>*
get_source_pool
()
{
return
&
pool
;
}
virtual
SrsRequest
*
get_reqinfo
()
{
return
_req
;
}
virtual
std
::
size_t
get_consumers_size
()
{
return
consumers
.
size
();
}
virtual
std
::
string
get_source_type
();
};
#endif
...
...
trunk/src/app/srs_app_statistic.cpp
0 → 100644
查看文件 @
a4a9361
/*
The MIT License (MIT)
Copyright (c) 2013-2015 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_statistic.hpp>
#include <srs_protocol_rtmp.hpp>
SrsStreamInfo
::
SrsStreamInfo
()
{
_req
=
NULL
;
}
SrsStreamInfo
::~
SrsStreamInfo
()
{
if
(
_req
!=
NULL
)
delete
_req
;
}
SrsStatistic
*
SrsStatistic
::
_instance
=
NULL
;
SrsStatistic
::
SrsStatistic
()
{
}
SrsStatistic
::~
SrsStatistic
()
{
SrsStreamInfoMap
::
iterator
it
;
for
(
it
=
pool
.
begin
();
it
!=
pool
.
end
();
it
++
)
{
delete
it
->
second
;
}
}
SrsStreamInfoMap
*
SrsStatistic
::
get_pool
()
{
return
&
pool
;
}
SrsStreamInfo
*
SrsStatistic
::
get
(
void
*
p
)
{
SrsStreamInfoMap
::
iterator
it
=
pool
.
find
(
p
);
if
(
it
==
pool
.
end
())
{
pool
[
p
]
=
new
SrsStreamInfo
();
return
pool
[
p
];
}
else
{
return
it
->
second
;
}
}
void
SrsStatistic
::
add_request_info
(
void
*
p
,
SrsRequest
*
req
)
{
SrsStreamInfo
*
info
=
get
(
p
);
if
(
info
->
_req
==
NULL
)
info
->
_req
=
req
->
copy
();
}
\ No newline at end of file
...
...
trunk/src/app/srs_app_statistic.hpp
0 → 100644
查看文件 @
a4a9361
/*
The MIT License (MIT)
Copyright (c) 2013-2015 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_STATISTIC_HPP
#define SRS_APP_STATISTIC_HPP
/*
#include <srs_app_statistic.hpp>
*/
#include <srs_core.hpp>
#include <map>
class
SrsRequest
;
class
SrsStreamInfo
{
public
:
SrsStreamInfo
();
virtual
~
SrsStreamInfo
();
SrsRequest
*
_req
;
};
typedef
std
::
map
<
void
*
,
SrsStreamInfo
*>
SrsStreamInfoMap
;
class
SrsStatistic
{
public
:
static
SrsStatistic
*
instance
()
{
if
(
_instance
==
NULL
)
{
_instance
=
new
SrsStatistic
();
}
return
_instance
;
}
virtual
SrsStreamInfoMap
*
get_pool
();
virtual
void
add_request_info
(
void
*
p
,
SrsRequest
*
req
);
private
:
SrsStatistic
();
virtual
~
SrsStatistic
();
static
SrsStatistic
*
_instance
;
SrsStreamInfoMap
pool
;
virtual
SrsStreamInfo
*
get
(
void
*
p
);
};
#endif
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论