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-03 12:57:13 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8d534d34709cf343535b5a0d17fa1aaab425d25c
8d534d34
1 parent
f8ec7c70
get stream info use http api #227
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
135 行增加
和
2 行删除
trunk/src/app/srs_app_edge.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_http_api.hpp
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/app/srs_app_edge.hpp
查看文件 @
8d534d3
...
...
@@ -188,6 +188,10 @@ public:
* when ingester start to play stream.
*/
virtual
int
on_ingest_play
();
/**
* get state info.
*/
virtual
int
get_state
()
{
return
state
;
}
};
/**
...
...
@@ -219,6 +223,10 @@ 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
查看文件 @
8d534d3
...
...
@@ -35,6 +35,8 @@ using namespace std;
#include <srs_app_json.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_source.hpp>
#include <srs_protocol_rtmp.hpp>
SrsApiRoot
::
SrsApiRoot
()
{
...
...
@@ -122,6 +124,8 @@ SrsApiV1::SrsApiV1()
handlers
.
push_back
(
new
SrsApiMemInfos
());
handlers
.
push_back
(
new
SrsApiAuthors
());
handlers
.
push_back
(
new
SrsApiRequests
());
handlers
.
push_back
(
new
SrsApiVhosts
());
handlers
.
push_back
(
new
SrsApiStreams
());
}
SrsApiV1
::~
SrsApiV1
()
...
...
@@ -147,7 +151,9 @@ int SrsApiV1::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
<<
__SRS_JFIELD_STR
(
"system_proc_stats"
,
"the system process stats"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"meminfos"
,
"the meminfo of system"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"authors"
,
"the primary authors and contributors"
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_STR
(
"requests"
,
"the request itself, for http debug"
)
<<
__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_JOBJECT_END
<<
__SRS_JOBJECT_END
;
...
...
@@ -500,6 +506,88 @@ int SrsApiAuthors::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
return
res_json
(
skt
,
req
,
ss
.
str
());
}
SrsApiVhosts
::
SrsApiVhosts
()
{
}
SrsApiVhosts
::~
SrsApiVhosts
()
{
}
bool
SrsApiVhosts
::
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
/*pchild*/
)
{
return
srs_path_equals
(
"/vhosts"
,
path
,
length
);
}
int
SrsApiVhosts
::
do_process_request
(
SrsStSocket
*
skt
,
SrsHttpMessage
*
req
)
{
std
::
stringstream
ss
;
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
<<
"
\"
"
;
}
ss
<<
__SRS_JARRAY_END
;
return
res_json
(
skt
,
req
,
ss
.
str
());
}
SrsApiStreams
::
SrsApiStreams
()
{
}
SrsApiStreams
::~
SrsApiStreams
()
{
}
bool
SrsApiStreams
::
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
/*pchild*/
)
{
return
srs_path_equals
(
"/streams"
,
path
,
length
);
}
int
SrsApiStreams
::
do_process_request
(
SrsStSocket
*
skt
,
SrsHttpMessage
*
req
)
{
std
::
stringstream
ss
;
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
)
{
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
;
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
(
"codec"
,
""
)
<<
__SRS_JOBJECT_END
;
}
}
ss
<<
__SRS_JARRAY_END
;
}
else
{
return
res_error
(
skt
,
req
,
400
,
"Bad Request"
,
"unknown query"
);
}
return
res_json
(
skt
,
req
,
ss
.
str
());
}
SrsHttpApi
::
SrsHttpApi
(
SrsServer
*
srs_server
,
st_netfd_t
client_stfd
,
SrsHttpHandler
*
_handler
)
:
SrsConnection
(
srs_server
,
client_stfd
)
{
...
...
trunk/src/app/srs_app_http_api.hpp
查看文件 @
8d534d3
...
...
@@ -164,6 +164,28 @@ protected:
virtual
int
do_process_request
(
SrsStSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsApiVhosts
:
public
SrsHttpHandler
{
public
:
SrsApiVhosts
();
virtual
~
SrsApiVhosts
();
public
:
virtual
bool
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
pchild
);
protected
:
virtual
int
do_process_request
(
SrsStSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsApiStreams
:
public
SrsHttpHandler
{
public
:
SrsApiStreams
();
virtual
~
SrsApiStreams
();
public
:
virtual
bool
can_handle
(
const
char
*
path
,
int
length
,
const
char
**
pchild
);
protected
:
virtual
int
do_process_request
(
SrsStSocket
*
skt
,
SrsHttpMessage
*
req
);
};
class
SrsHttpApi
:
public
SrsConnection
{
private
:
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
8d534d3
...
...
@@ -1807,4 +1807,13 @@ 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
查看文件 @
8d534d3
...
...
@@ -486,6 +486,12 @@ 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
...
...
请
注册
或
登录
后发表评论