Skip to content

Commit

Permalink
for ossrs#340, refine ts prefix code.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjie.zhao committed Mar 12, 2015
1 parent 10da182 commit 5969f72
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
7 changes: 7 additions & 0 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion trunk/conf/hls.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
12 changes: 11 additions & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_hls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5969f72

Please sign in to comment.