diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index b7dd0a52a2..16f3804d32 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -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. diff --git a/trunk/conf/hls.conf b/trunk/conf/hls.conf index 04695f5269..0bbf13ad51 100644 --- a/trunk/conf/hls.conf +++ b/trunk/conf/hls.conf @@ -9,7 +9,7 @@ vhost __defaultVhost__ { enabled on; hls_fragment 10; hls_window 60; -# hls_entry_prefix http://127.0.0.1/; + # hls_entry_prefix http://127.0.0.1/; hls_path ./objs/nginx/html; } } diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 582ef722f7..a5207afc46 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -3152,7 +3152,17 @@ string SrsConfig::get_hls_entry_prefix(string vhost) return ""; } - return conf->arg0(); + std::string hls_entry_prefix = conf->arg0(); + if (hls_entry_prefix.empty()) { + return ""; + } + + char last_char = hls_entry_prefix[hls_entry_prefix.length() - 1]; + if (last_char != '/') { + hls_entry_prefix.append("/"); + } + + return hls_entry_prefix; } string SrsConfig::get_hls_path(string vhost) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index e0ea1d456f..4e24df273f 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -203,14 +203,14 @@ int SrsHlsMuxer::sequence_no() return _sequence_no; } -int SrsHlsMuxer::update_config(SrsRequest* r, string _entry_prefix, 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 = _entry_prefix; + entry_prefix = hls_entry_prefix; hls_path = path; hls_fragment = fragment; hls_window = window; diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index 5c2394605a..be90b791da 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -208,7 +208,7 @@ class SrsHlsMuxer /** * when publish, update the config for muxer. */ - virtual int update_config(SrsRequest* r, std::string _entry_prefix, 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,