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
2016-01-11 13:15:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d81b2cb140d5386bc820f19ca863a3d5599a4377
d81b2cb1
1 parent
041040b8
support hls mount to vhost and reload
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
65 行增加
和
24 行删除
trunk/conf/full.conf
trunk/src/app/srs_app_http_static.cpp
trunk/src/app/srs_app_http_static.hpp
trunk/conf/full.conf
查看文件 @
d81b2cb
...
...
@@ -956,6 +956,7 @@ vhost with-hls.srs.com {
# [vhost], the vhost of stream.
# [app], the app of stream.
# [stream], the stream name of stream.
# recommend: [vhost]/[app]/[stream].m3u8
# default: [app]/[stream].m3u8
hls_m3u8_file
[
app
]/[
stream
].
m3u8
;
# the hls ts file name.
...
...
@@ -974,6 +975,7 @@ vhost with-hls.srs.com {
# [seq], the sequence number of ts.
# @see https://github.com/ossrs/srs/wiki/v2_CN_DVR#custom-path
# @see https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS#hls-config
# recommend: [vhost]/[app]/[stream]-[seq].ts
# default: [app]/[stream]-[seq].ts
hls_ts_file
[
app
]/[
stream
]-[
seq
].
ts
;
# whether use floor for the hls_ts_file path generation.
...
...
trunk/src/app/srs_app_http_static.cpp
查看文件 @
d81b2cb
...
...
@@ -206,10 +206,12 @@ int SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r
SrsHttpStaticServer
::
SrsHttpStaticServer
(
SrsServer
*
svr
)
{
server
=
svr
;
_srs_config
->
subscribe
(
this
);
}
SrsHttpStaticServer
::~
SrsHttpStaticServer
()
{
_srs_config
->
unsubscribe
(
this
);
}
int
SrsHttpStaticServer
::
initialize
()
...
...
@@ -227,36 +229,17 @@ int SrsHttpStaticServer::initialize()
continue
;
}
std
::
string
vhost
=
conf
->
arg0
();
if
(
!
_srs_config
->
get_vhost_http_enabled
(
vhost
))
{
continue
;
}
std
::
string
mount
=
_srs_config
->
get_vhost_http_mount
(
vhost
);
std
::
string
dir
=
_srs_config
->
get_vhost_http_dir
(
vhost
);
// replace the vhost variable
mount
=
srs_string_replace
(
mount
,
"[vhost]"
,
vhost
);
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
// the dir mount must always ends with "/"
if
(
mount
!=
"/"
&&
!
srs_string_ends_with
(
mount
,
"/"
))
{
mount
+=
"/"
;
}
// mount the http of vhost.
if
((
ret
=
mux
.
handle
(
mount
,
new
SrsVodStream
(
dir
)))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount dir=%s for vhost=%s failed. ret=%d"
,
dir
.
c_str
(),
vhost
.
c_str
(),
ret
);
string
pmount
;
string
vhost
=
conf
->
arg0
();
if
((
ret
=
mount_vhost
(
vhost
,
pmount
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
(
mount
==
"/"
)
{
if
(
p
mount
==
"/"
)
{
default_root_exists
=
true
;
std
::
string
dir
=
_srs_config
->
get_vhost_http_dir
(
vhost
);
srs_warn
(
"http: root mount to %s"
,
dir
.
c_str
());
}
srs_trace
(
"http: vhost=%s mount to %s"
,
vhost
.
c_str
(),
mount
.
c_str
());
}
if
(
!
default_root_exists
)
{
...
...
@@ -272,6 +255,59 @@ int SrsHttpStaticServer::initialize()
return
ret
;
}
int
SrsHttpStaticServer
::
mount_vhost
(
string
vhost
,
string
&
pmount
)
{
int
ret
=
ERROR_SUCCESS
;
// when vhost disabled, ignore.
if
(
!
_srs_config
->
get_vhost_enabled
(
vhost
))
{
return
ret
;
}
// when vhost http_static disabled, ignore.
if
(
!
_srs_config
->
get_vhost_http_enabled
(
vhost
))
{
return
ret
;
}
std
::
string
mount
=
_srs_config
->
get_vhost_http_mount
(
vhost
);
std
::
string
dir
=
_srs_config
->
get_vhost_http_dir
(
vhost
);
// replace the vhost variable
mount
=
srs_string_replace
(
mount
,
"[vhost]"
,
vhost
);
dir
=
srs_string_replace
(
dir
,
"[vhost]"
,
vhost
);
// remove the default vhost mount
mount
=
srs_string_replace
(
mount
,
SRS_CONSTS_RTMP_DEFAULT_VHOST
"/"
,
"/"
);
// the dir mount must always ends with "/"
if
(
mount
!=
"/"
&&
!
srs_string_ends_with
(
mount
,
"/"
))
{
mount
+=
"/"
;
}
// mount the http of vhost.
if
((
ret
=
mux
.
handle
(
mount
,
new
SrsVodStream
(
dir
)))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount dir=%s for vhost=%s failed. ret=%d"
,
dir
.
c_str
(),
vhost
.
c_str
(),
ret
);
return
ret
;
}
srs_trace
(
"http: vhost=%s mount to %s at %s"
,
vhost
.
c_str
(),
mount
.
c_str
(),
dir
.
c_str
());
pmount
=
mount
;
return
ret
;
}
int
SrsHttpStaticServer
::
on_reload_vhost_added
(
string
vhost
)
{
int
ret
=
ERROR_SUCCESS
;
string
pmount
;
if
((
ret
=
mount_vhost
(
vhost
,
pmount
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
int
SrsHttpStaticServer
::
on_reload_vhost_http_updated
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_http_static.hpp
查看文件 @
d81b2cb
...
...
@@ -65,8 +65,11 @@ public:
virtual
~
SrsHttpStaticServer
();
public
:
virtual
int
initialize
();
private
:
virtual
int
mount_vhost
(
std
::
string
vhost
,
std
::
string
&
pmount
);
// interface ISrsReloadHandler.
public:
virtual
int
on_reload_vhost_added
(
std
::
string
vhost
);
virtual
int
on_reload_vhost_http_updated
();
};
...
...
请
注册
或
登录
后发表评论