diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 5d1925fd8..9d78a8516 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -1046,6 +1046,7 @@ vhost hls.srs.com { # [999], replace this const to current millisecond. # [timestamp],replace this const to current UNIX timestamp in ms. # [seq], the sequence number of ts. + # [duration], replace this const to current ts duration. # @see https://github.com/ossrs/srs/wiki/v2_CN_DVR#custom-path # @see https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS#hls-config # default: [app]/[stream]-[seq].ts diff --git a/trunk/src/app/srs_app_fragment.cpp b/trunk/src/app/srs_app_fragment.cpp index 1c73307ab..f158078fd 100644 --- a/trunk/src/app/srs_app_fragment.cpp +++ b/trunk/src/app/srs_app_fragment.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace std; SrsFragment::SrsFragment() @@ -126,11 +127,16 @@ srs_error_t SrsFragment::rename() string full_path = fullpath(); string tmp_file = tmppath(); - + int tempdur = (int)duration(); + if (true) { + std::stringstream ss; + ss << tempdur; + full_path = srs_string_replace(full_path, "[duration]", ss.str()); + } if (::rename(tmp_file.c_str(), full_path.c_str()) < 0) { return srs_error_new(ERROR_SYSTEM_FRAGMENT_RENAME, "rename %s to %s", tmp_file.c_str(), full_path.c_str()); } - + filepath = full_path; return err; } diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index f6dacc659..b9484705e 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -688,7 +688,14 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file) ss << "#EXTINF:" << segment->duration() / 1000.0 << ", no desc" << SRS_CONSTS_LF; // {file name}\n - ss << segment->uri << SRS_CONSTS_LF; + std::string seg_uri = segment->uri; + if (true) { + std::stringstream stemp; + stemp << (int)(segment->duration()); + seg_uri = srs_string_replace(seg_uri, "[duration]", stemp.str()); + } + //ss << segment->uri << SRS_CONSTS_LF; + ss << seg_uri << SRS_CONSTS_LF; } // write m3u8 to writer. diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 1e4142ee5..13bbc68aa 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -546,7 +546,7 @@ int srs_do_create_dir_recursively(string dir) { int ret = srs_do_create_dir_recursively(dir); - if (ret == ERROR_SYSTEM_DIR_EXISTS) { + if (ret == ERROR_SYSTEM_DIR_EXISTS || ret == ERROR_SUCCESS) { return srs_success; }