don't save total duration if hls_total_file is not configured
正在显示
2 个修改的文件
包含
24 行增加
和
20 行删除
@@ -73,7 +73,7 @@ const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER; | @@ -73,7 +73,7 @@ const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER; | ||
73 | #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" | 73 | #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" |
74 | #define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8" | 74 | #define SRS_CONF_DEFAULT_HLS_M3U8_FILE "[app]/[stream].m3u8" |
75 | #define SRS_CONF_DEFAULT_HLS_TOTAL_M3U8_FILE "" | 75 | #define SRS_CONF_DEFAULT_HLS_TOTAL_M3U8_FILE "" |
76 | -#define SRS_CONF_DEFAULT_HLS_TOTAL_FILE "[app]/[stream]_total" | 76 | +#define SRS_CONF_DEFAULT_HLS_TOTAL_FILE "" |
77 | #define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts" | 77 | #define SRS_CONF_DEFAULT_HLS_TS_FILE "[app]/[stream]-[seq].ts" |
78 | #define SRS_CONF_DEFAULT_HLS_TS_FLOOR false | 78 | #define SRS_CONF_DEFAULT_HLS_TS_FLOOR false |
79 | #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 | 79 | #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 |
@@ -833,26 +833,30 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -833,26 +833,30 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
833 | } | 833 | } |
834 | srs_info("write total m3u8 %s success.", m3u8_total_file.c_str()); | 834 | srs_info("write total m3u8 %s success.", m3u8_total_file.c_str()); |
835 | 835 | ||
836 | - this->total_duraion += currentSeg->duration; | ||
837 | - SrsFileWriter total_writer; | ||
838 | - //write total duration to total | ||
839 | - std::stringstream ss_total; | ||
840 | - | ||
841 | - std::string total_tmp = total + ".tmp"; | ||
842 | - ret = total_writer.open(total_tmp); | ||
843 | - ss_total.precision(3); | ||
844 | - ss_total.setf(std::ios::fixed, std::ios::floatfield); | ||
845 | - ss_total << total_duraion; | ||
846 | - | ||
847 | - if ((ret = total_writer.write((char*) ss_total.str().c_str(), | ||
848 | - (int) ss_total.str().length(), NULL)) != ERROR_SUCCESS) { | ||
849 | - srs_error("write total temp:%s failed. ret=%d",(char*) total_tmp.c_str(), ret); | ||
850 | - return ret; | ||
851 | - } | 836 | + if (!total_url.empty()) { |
837 | + this->total_duraion += currentSeg->duration; | ||
838 | + SrsFileWriter total_writer; | ||
839 | + //write total duration to total | ||
840 | + std::stringstream ss_total; | ||
841 | + | ||
842 | + std::string total_tmp = total + ".tmp"; | ||
843 | + ret = total_writer.open(total_tmp); | ||
844 | + ss_total.precision(3); | ||
845 | + ss_total.setf(std::ios::fixed, std::ios::floatfield); | ||
846 | + ss_total << total_duraion; | ||
847 | + | ||
848 | + if ((ret = total_writer.write((char*) ss_total.str().c_str(), | ||
849 | + (int) ss_total.str().length(), NULL)) != ERROR_SUCCESS) { | ||
850 | + srs_error("write total temp:%s failed. ret=%d", | ||
851 | + (char* ) total_tmp.c_str(), ret); | ||
852 | + return ret; | ||
853 | + } | ||
852 | 854 | ||
853 | - if(rename(total_tmp.c_str(), total.c_str()) < 0) { | ||
854 | - ret = ERROR_HLS_WRITE_FAILED; | ||
855 | - srs_error("rename total file failed. %s => %s, ret=%d", total_tmp.c_str(), total.c_str(), ret); | 855 | + if (rename(total_tmp.c_str(), total.c_str()) < 0) { |
856 | + ret = ERROR_HLS_WRITE_FAILED; | ||
857 | + srs_error("rename total file failed. %s => %s, ret=%d", | ||
858 | + total_tmp.c_str(), total.c_str(), ret); | ||
859 | + } | ||
856 | } | 860 | } |
857 | } | 861 | } |
858 | 862 |
-
请 注册 或 登录 后发表评论