1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Merge branch 'develop' into 3.0release

This commit is contained in:
winlin 2018-03-25 20:00:33 +08:00
commit dba44c7c3f
4 changed files with 18 additions and 4 deletions

View file

@ -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

View file

@ -28,6 +28,7 @@
#include <srs_kernel_error.hpp>
#include <unistd.h>
#include <sstream>
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;
}

View file

@ -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.

View file

@ -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;
}