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
2015-03-17 07:45:27 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
9c43c73d86ee1d9d8ccfea6ac4cf8460fff98658
9c43c73d
2 parents
33e57959
65f404fb
Merge branch 'develop' of
https://github.com/wenjiegit/simple-rtmp-server
into wenjiegit-develop
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
48 行增加
和
5 行删除
trunk/conf/full.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_hls.cpp
trunk/src/app/srs_app_hls.hpp
trunk/conf/full.conf
查看文件 @
9c43c73
...
...
@@ -526,6 +526,13 @@ vhost with-hls.srs.com {
# in a word, the hls_path is for vhost.
# default: ./objs/nginx/html
hls_path
./
objs
/
nginx
/
html
;
# the hls entry prefix, which is base url of ts url.
# if specified, the ts path in m3u8 will be like:
# http://your-server/live/livestream-0.ts
# http://your-server/live/livestream-1.ts
# ...
# optional, default to empty string.
hls_entry_prefix
http
://
your
-
server
/;
# the hls mount for hls_storage ram,
# which use srs embeded http server to delivery HLS,
# where the mount specifies the HTTP url to mount.
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
9c43c73
...
...
@@ -1480,7 +1480,7 @@ int SrsConfig::check_config()
}
else
if
(
n
==
"hls"
)
{
for
(
int
j
=
0
;
j
<
(
int
)
conf
->
directives
.
size
();
j
++
)
{
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if
(
m
!=
"enabled"
&&
m
!=
"hls_path"
&&
m
!=
"hls_fragment"
&&
m
!=
"hls_window"
&&
m
!=
"hls_on_error"
if
(
m
!=
"enabled"
&&
m
!=
"hls_
entry_prefix"
&&
m
!=
"hls_
path"
&&
m
!=
"hls_fragment"
&&
m
!=
"hls_window"
&&
m
!=
"hls_on_error"
&&
m
!=
"hls_storage"
&&
m
!=
"hls_mount"
&&
m
!=
"hls_td_ratio"
&&
m
!=
"hls_acodec"
&&
m
!=
"hls_vcodec"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
...
...
@@ -3138,6 +3138,33 @@ bool SrsConfig::get_hls_enabled(string vhost)
return
false
;
}
string
SrsConfig
::
get_hls_entry_prefix
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
if
(
!
hls
)
{
return
""
;
}
SrsConfDirective
*
conf
=
hls
->
get
(
"hls_entry_prefix"
);
if
(
!
conf
)
{
return
""
;
}
std
::
string
prefix
=
conf
->
arg0
();
if
(
prefix
.
empty
())
{
return
""
;
}
const
char
last
=
prefix
[
prefix
.
length
()
-
1
];
if
(
last
!=
'/'
)
{
return
prefix
.
append
(
"/"
);
}
return
prefix
;
}
string
SrsConfig
::
get_hls_path
(
string
vhost
)
{
SrsConfDirective
*
hls
=
get_hls
(
vhost
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
9c43c73
...
...
@@ -866,6 +866,10 @@ public:
*/
virtual
bool
get_hls_enabled
(
std
::
string
vhost
);
/**
* get the HLS m3u8 list ts segment entry prefix info.
*/
virtual
std
::
string
get_hls_entry_prefix
(
std
::
string
vhost
);
/**
* get the HLS ts/m3u8 file store path.
*/
virtual
std
::
string
get_hls_path
(
std
::
string
vhost
);
...
...
trunk/src/app/srs_app_hls.cpp
查看文件 @
9c43c73
...
...
@@ -203,13 +203,14 @@ int SrsHlsMuxer::sequence_no()
return
_sequence_no
;
}
int
SrsHlsMuxer
::
update_config
(
SrsRequest
*
r
,
string
path
,
int
fragment
,
int
window
)
int
SrsHlsMuxer
::
update_config
(
SrsRequest
*
r
,
string
hls_entry_prefix
,
string
path
,
int
fragment
,
int
window
)
{
int
ret
=
ERROR_SUCCESS
;
srs_freep
(
req
);
req
=
r
->
copy
();
entry_prefix
=
hls_entry_prefix
;
hls_path
=
path
;
hls_fragment
=
fragment
;
hls_window
=
window
;
...
...
@@ -301,7 +302,8 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
current
->
full_path
+=
filename
;
// TODO: support base url, and so on.
current
->
uri
=
filename
;
current
->
uri
+=
entry_prefix
;
current
->
uri
+=
filename
;
std
::
string
tmp_file
=
current
->
full_path
+
".tmp"
;
if
((
ret
=
current
->
muxer
->
open
(
tmp_file
.
c_str
()))
!=
ERROR_SUCCESS
)
{
...
...
@@ -668,6 +670,8 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment
int
hls_fragment
=
(
int
)
_srs_config
->
get_hls_fragment
(
vhost
);
int
hls_window
=
(
int
)
_srs_config
->
get_hls_window
(
vhost
);
// get the hls m3u8 ts list entry prefix config
std
::
string
entry_prefix
=
_srs_config
->
get_hls_entry_prefix
(
vhost
);
// get the hls path config
std
::
string
hls_path
=
_srs_config
->
get_hls_path
(
vhost
);
...
...
@@ -675,7 +679,7 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
// open muxer
if
((
ret
=
muxer
->
update_config
(
req
,
hls_path
,
hls_fragment
,
hls_window
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
muxer
->
update_config
(
req
,
entry_prefix
,
hls_path
,
hls_fragment
,
hls_window
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"m3u8 muxer update config failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_hls.hpp
查看文件 @
9c43c73
...
...
@@ -167,6 +167,7 @@ class SrsHlsMuxer
private
:
SrsRequest
*
req
;
private
:
std
::
string
entry_prefix
;
std
::
string
hls_path
;
int
hls_fragment
;
int
hls_window
;
...
...
@@ -207,7 +208,7 @@ public:
/**
* when publish, update the config for muxer.
*/
virtual
int
update_config
(
SrsRequest
*
r
,
std
::
string
path
,
int
fragment
,
int
window
);
virtual
int
update_config
(
SrsRequest
*
r
,
std
::
string
hls_entry_prefix
,
std
::
string
path
,
int
fragment
,
int
window
);
/**
* open a new segment(a new ts file),
* @param segment_start_dts use to calc the segment duration,
...
...
请
注册
或
登录
后发表评论