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
2013-12-08 10:46:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
30099dfa09d9989360276afd82b0dc9202d150a0
30099dfa
1 parent
260bde69
support multiple http hooks for a event.
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
28 行增加
和
15 行删除
README.md
trunk/conf/srs.conf
trunk/src/core/srs_core_client.cpp
trunk/src/core/srs_core_config.cpp
trunk/src/core/srs_core_config.hpp
README.md
查看文件 @
30099df
...
...
@@ -190,6 +190,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
*
nginx v1.5.0: 139524 lines
<br/>
### History
*
v0.8, 2013-12-08, support multiple http hooks for a event.
*
v0.8, 2013-12-07, support http callback hooks, on_connect.
*
v0.8, 2013-12-07, support network based cli and json result, add CherryPy 3.2.4.
*
v0.8, 2013-12-07, update http/hls/rtmp load test tool
[
st_load
](
https://github.com/winlinvip/st-load
)
, use srs rtmp sdk.
...
...
trunk/conf/srs.conf
查看文件 @
30099df
...
...
@@ -87,12 +87,14 @@ vhost dev {
hls_window
30
;
#forward 127.0.0.1:19350;
#forward 127.0.0.1:1936;
on_connect
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
clients
;
http_hooks
{
on_connect
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
clients
http
://
localhost
:
8085
/
api
/
v1
/
clients
;
on_close
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
clients
;
on_publish
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
streams
;
on_unpublish
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
streams
;
on_play
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
sessions
;
on_stop
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
sessions
;
}
transcode
{
enabled
off
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
...
...
@@ -133,6 +135,7 @@ vhost dev {
}
# the http hook callback vhost, srs will invoke the hooks for specified events.
vhost
hooks
.
callback
.
vhost
.
com
{
http_hooks
{
# when client connect to vhost/app, call the hook,
# the request in the POST data string is a object encode by json:
# {
...
...
@@ -142,7 +145,10 @@ vhost hooks.callback.vhost.com {
# if valid, the hook must return HTTP code 200(Stauts OK) and response
# an int value specifies the error code(0 corresponding to success):
# 0
on_connect
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
clients
;
# support multiple api hooks, format:
# on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN
on_connect
http
://
127
.
0
.
0
.
1
:
8085
/
api
/
v1
/
clients
http
://
localhost
:
8085
/
api
/
v1
/
clients
;
}
}
# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction
vhost
mirror
.
transcode
.
vhost
.
com
{
...
...
trunk/src/core/srs_core_client.cpp
100644 → 100755
查看文件 @
30099df
...
...
@@ -251,16 +251,19 @@ int SrsClient::check_vhost()
#ifdef SRS_HTTP
// HTTP: on_connect
std
::
string
on_connect
=
config
->
get_vhost_on_connect
(
req
->
vhost
);
if
(
on_connect
.
empty
())
{
SrsConfDirective
*
on_connect
=
config
->
get_vhost_on_connect
(
req
->
vhost
);
if
(
!
on_connect
)
{
srs_info
(
"ignore the empty http callback: on_connect"
);
return
ret
;
}
if
((
ret
=
http_hooks
->
on_connect
(
on_connect
,
ip
,
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client failed. ret=%d"
,
ret
);
for
(
int
i
=
0
;
i
<
(
int
)
on_connect
->
args
.
size
();
i
++
)
{
std
::
string
url
=
on_connect
->
args
.
at
(
i
);
if
((
ret
=
http_hooks
->
on_connect
(
url
,
ip
,
req
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"hook client failed. url=%s, ret=%d"
,
url
.
c_str
(),
ret
);
return
ret
;
}
}
#endif
return
ret
;
...
...
trunk/src/core/srs_core_config.cpp
100644 → 100755
查看文件 @
30099df
...
...
@@ -344,7 +344,10 @@ int SrsConfDirective::read_token(SrsFileBuffer* buffer, std::vector<std::string>
memcpy
(
word
,
pstart
,
len
);
word
[
len
-
1
]
=
0
;
args
.
push_back
(
word
);
std
::
string
word_str
=
word
;
if
(
!
word_str
.
empty
())
{
args
.
push_back
(
word_str
);
}
srs_freepa
(
word
);
if
(
ch
==
';'
)
{
...
...
@@ -559,20 +562,20 @@ SrsConfDirective* SrsConfig::get_vhost(std::string vhost)
return
NULL
;
}
std
::
string
SrsConfig
::
get_vhost_on_connect
(
std
::
string
vhost
)
SrsConfDirective
*
SrsConfig
::
get_vhost_on_connect
(
std
::
string
vhost
)
{
SrsConfDirective
*
vhost_conf
=
get_vhost
(
vhost
);
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
vhost_conf
)
{
return
""
;
if
(
!
conf
)
{
return
NULL
;
}
SrsConfDirective
*
conf
=
vhost_conf
->
get
(
"on_connect"
);
conf
=
conf
->
get
(
"http_hooks"
);
if
(
!
conf
)
{
return
""
;
return
NULL
;
}
return
conf
->
arg0
();
return
conf
->
get
(
"on_connect"
);
}
bool
SrsConfig
::
get_vhost_enabled
(
std
::
string
vhost
)
...
...
trunk/src/core/srs_core_config.hpp
100644 → 100755
查看文件 @
30099df
...
...
@@ -119,7 +119,7 @@ public:
public
:
virtual
SrsConfDirective
*
get_vhost
(
std
::
string
vhost
);
virtual
bool
get_vhost_enabled
(
std
::
string
vhost
);
virtual
std
::
string
get_vhost_on_connect
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_vhost_on_connect
(
std
::
string
vhost
);
virtual
SrsConfDirective
*
get_transcode
(
std
::
string
vhost
,
std
::
string
scope
);
virtual
bool
get_transcode_enabled
(
SrsConfDirective
*
transcode
);
virtual
std
::
string
get_transcode_ffmpeg
(
SrsConfDirective
*
transcode
);
...
...
请
注册
或
登录
后发表评论