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
2014-04-13 13:27:51 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dc3c3cff8e4d7d7c40ba2740b2c824f62261ab1e
dc3c3cff
1 parent
c33ff4fd
support reload http_stream
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
212 行增加
和
1 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_reload.cpp
trunk/src/app/srs_app_reload.hpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
dc3c3cf
...
...
@@ -572,6 +572,11 @@ int SrsConfig::reload()
if
((
ret
=
reload_http_api
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// merge config: http_stream
if
((
ret
=
reload_http_stream
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// merge config: vhost
if
((
ret
=
reload_vhost
(
old_root
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -646,6 +651,71 @@ int SrsConfig::reload_http_api(SrsConfDirective* old_root)
return
ret
;
}
int
SrsConfig
::
reload_http_stream
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// state graph
// old_http_stream new_http_stream
// DISABLED => ENABLED
// ENABLED => DISABLED
// ENABLED => ENABLED (modified)
SrsConfDirective
*
new_http_stream
=
root
->
get
(
"http_stream"
);
SrsConfDirective
*
old_http_stream
=
old_root
->
get
(
"http_stream"
);
// DISABLED => ENABLED
if
(
!
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream disabled=>enabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload disabled=>enabled http_stream success."
);
return
ret
;
}
// ENABLED => DISABLED
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
!
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_disabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled=>disabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled=>disabled http_stream success."
);
return
ret
;
}
// ENABLED => ENABLED (modified)
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
)
&&
!
srs_directive_equals
(
old_http_stream
,
new_http_stream
)
)
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_updated
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled modified failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled modified http_stream success."
);
return
ret
;
}
srs_trace
(
"reload http_stream not changed success."
);
return
ret
;
}
int
SrsConfig
::
reload_vhost
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -774,6 +844,17 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
}
srs_trace
(
"vhost %s reload hls success."
,
vhost
.
c_str
());
}
// http, only one per vhost.
if
(
!
srs_directive_equals
(
new_vhost
->
get
(
"http"
),
old_vhost
->
get
(
"http"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_vhost_http_updated
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"vhost %s notify subscribes http failed. ret=%d"
,
vhost
.
c_str
(),
ret
);
return
ret
;
}
}
srs_trace
(
"vhost %s reload http success."
,
vhost
.
c_str
());
}
// transcode, many per vhost.
if
((
ret
=
reload_transcode
(
new_vhost
,
old_vhost
))
!=
ERROR_SUCCESS
)
{
return
ret
;
...
...
@@ -2232,6 +2313,11 @@ SrsConfDirective* SrsConfig::get_http_stream()
bool
SrsConfig
::
get_http_stream_enabled
()
{
SrsConfDirective
*
conf
=
get_http_stream
();
return
get_http_stream_enabled
(
conf
);
}
bool
SrsConfig
::
get_http_stream_enabled
(
SrsConfDirective
*
conf
)
{
if
(
!
conf
)
{
return
false
;
}
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
dc3c3cf
...
...
@@ -125,6 +125,7 @@ public:
virtual
int
reload
();
private
:
virtual
int
reload_http_api
(
SrsConfDirective
*
old_root
);
virtual
int
reload_http_stream
(
SrsConfDirective
*
old_root
);
virtual
int
reload_vhost
(
SrsConfDirective
*
old_root
);
virtual
int
reload_transcode
(
SrsConfDirective
*
new_vhost
,
SrsConfDirective
*
old_vhost
);
virtual
int
reload_ingest
(
SrsConfDirective
*
new_vhost
,
SrsConfDirective
*
old_vhost
);
...
...
@@ -231,6 +232,7 @@ private:
virtual
SrsConfDirective
*
get_http_stream
();
public
:
virtual
bool
get_http_stream_enabled
();
virtual
bool
get_http_stream_enabled
(
SrsConfDirective
*
conf
);
virtual
int
get_http_stream_listen
();
virtual
std
::
string
get_http_stream_dir
();
public
:
...
...
trunk/src/app/srs_app_reload.cpp
查看文件 @
dc3c3cf
...
...
@@ -75,6 +75,26 @@ int ISrsReloadHandler::on_reload_http_api_disabled()
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_http_stream_enabled
()
{
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_http_stream_disabled
()
{
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_http_stream_updated
()
{
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_vhost_http_updated
()
{
return
ERROR_SUCCESS
;
}
int
ISrsReloadHandler
::
on_reload_vhost_added
(
string
/*vhost*/
)
{
return
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_reload.hpp
查看文件 @
dc3c3cf
...
...
@@ -49,6 +49,10 @@ public:
virtual
int
on_reload_pithy_print
();
virtual
int
on_reload_http_api_enabled
();
virtual
int
on_reload_http_api_disabled
();
virtual
int
on_reload_http_stream_enabled
();
virtual
int
on_reload_http_stream_disabled
();
virtual
int
on_reload_http_stream_updated
();
virtual
int
on_reload_vhost_http_updated
();
virtual
int
on_reload_vhost_added
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_removed
(
std
::
string
vhost
);
virtual
int
on_reload_atc
(
std
::
string
vhost
);
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
dc3c3cf
...
...
@@ -618,16 +618,109 @@ int SrsServer::on_reload_pid()
return
acquire_pid_file
();
}
int
SrsServer
::
on_reload_vhost_added
(
std
::
string
vhost
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
if
(
!
_srs_config
->
get_vhost_http_enabled
(
vhost
))
{
return
ret
;
}
if
((
ret
=
on_reload_vhost_http_updated
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_reload_vhost_removed
(
std
::
string
vhost
)
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
if
((
ret
=
on_reload_vhost_http_updated
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_reload_vhost_http_updated
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
srs_freep
(
http_stream_handler
);
http_stream_handler
=
SrsHttpHandler
::
create_http_stream
();
if
((
ret
=
http_stream_handler
->
initialize
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
int
SrsServer
::
on_reload_http_api_enabled
()
{
return
listen_http_api
();
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_API
ret
=
listen_http_api
();
#endif
return
ret
;
}
int
SrsServer
::
on_reload_http_api_disabled
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_API
close_listeners
(
SrsListenerHttpApi
);
#endif
return
ret
;
}
int
SrsServer
::
on_reload_http_stream_enabled
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
ret
=
listen_http_stream
();
#endif
return
ret
;
}
int
SrsServer
::
on_reload_http_stream_disabled
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
close_listeners
(
SrsListenerHttpStream
);
#endif
return
ret
;
}
int
SrsServer
::
on_reload_http_stream_updated
()
{
int
ret
=
ERROR_SUCCESS
;
#ifdef SRS_HTTP_SERVER
if
((
ret
=
on_reload_http_stream_enabled
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
((
ret
=
on_reload_vhost_http_updated
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
#endif
return
ret
;
}
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
dc3c3cf
...
...
@@ -116,8 +116,14 @@ private:
public:
virtual
int
on_reload_listen
();
virtual
int
on_reload_pid
();
virtual
int
on_reload_vhost_added
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_removed
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_http_updated
();
virtual
int
on_reload_http_api_enabled
();
virtual
int
on_reload_http_api_disabled
();
virtual
int
on_reload_http_stream_enabled
();
virtual
int
on_reload_http_stream_disabled
();
virtual
int
on_reload_http_stream_updated
();
};
#endif
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论