From eb3bbf1bca5c82d48b47c4e12d851daa6537047b Mon Sep 17 00:00:00 2001 From: Haibo Chen Date: Tue, 12 Oct 2021 09:15:21 +0800 Subject: [PATCH 1/3] For #2549: Fix duration issue for HLS on_hls. v4.0.176 --- trunk/doc/CHANGELOG.md | 1 + trunk/scripts/git.commit.sh | 3 ++- trunk/src/app/srs_app_hls.cpp | 23 +++++++++++++++++------ trunk/src/app/srs_app_hls.hpp | 2 ++ trunk/src/core/srs_core_version4.hpp | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 814b9fa3a..fba3b3737 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-10-12, Merge [#2549](https://github.com/ossrs/srs/pull/2549): Fix duration issue for HLS on_hls. v4.0.176 * v4.0, 2021-10-11, Fix [#1641](https://github.com/ossrs/srs/issues/1641), HLS/RTC picture corrupt for SPS/PPS lost. v4.0.175 * v4.0, 2021-10-11, RTC: Refine config, aac to rtmp_to_rtc, bframe to keep_bframe. v4.0.174 * v4.0, 2021-10-10, For [#1641](https://github.com/ossrs/srs/issues/1641), Support RTMP publish and play regression test. v4.0.173 diff --git a/trunk/scripts/git.commit.sh b/trunk/scripts/git.commit.sh index fd83d907b..509da3c3c 100755 --- a/trunk/scripts/git.commit.sh +++ b/trunk/scripts/git.commit.sh @@ -1,4 +1,5 @@ #!/bin/bash -for file in $(git remote); do echo ""; git push $file $@; done +#for file in $(git remote); do echo ""; git push $file $@; done +for file in $(git remote -v|grep -v https|grep push|awk '{print $1}'); do echo ""; echo "git push $file $@"; git push $file $@; done diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 144045064..c2780e622 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -63,6 +63,17 @@ void SrsHlsSegment::config_cipher(unsigned char* key,unsigned char* iv) SrsEncFileWriter* fw = (SrsEncFileWriter*)writer; fw->config_cipher(key, iv); +} + +srs_error_t SrsHlsSegment::rename() +{ + if (true) { + std::stringstream ss; + ss << srsu2msi(duration()); + uri = srs_string_replace(uri, "[duration]", ss.str()); + } + + return SrsFragment::rename(); } SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsContextId c, SrsRequest* r, string p, string t, string m, string mu, int s, srs_utime_t d) @@ -607,6 +618,11 @@ srs_error_t SrsHlsMuxer::do_segment_close() bool matchMinDuration = current->duration() >= SRS_HLS_SEGMENT_MIN_DURATION; bool matchMaxDuration = current->duration() <= max_td * 2 * 1000; if (matchMinDuration && matchMaxDuration) { + // rename from tmp to real path + if ((err = current->rename()) != srs_success) { + return srs_error_wrap(err, "rename"); + } + // use async to call the http hooks, for it will cause thread switch. if ((err = async->execute(new SrsDvrAsyncCallOnHls(_srs_context->get_id(), req, current->fullpath(), current->uri, m3u8, m3u8_url, current->sequence_no, current->duration()))) != srs_success) { @@ -620,12 +636,7 @@ srs_error_t SrsHlsMuxer::do_segment_close() // close the muxer of finished segment. srs_freep(current->tscw); - - // rename from tmp to real path - if ((err = current->rename()) != srs_success) { - return srs_error_wrap(err, "rename"); - } - + segments->append(current); current = NULL; } else { diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index e8afe4db4..90b13736d 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -57,6 +57,8 @@ public: virtual ~SrsHlsSegment(); public: void config_cipher(unsigned char* key,unsigned char* iv); + // replace the placeholder + virtual srs_error_t rename(); }; // The hls async call: on_hls diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index f95505861..013745cf5 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 175 +#define VERSION_REVISION 176 #endif From 219198d0ee9f27cef600750da5f8cfbc9d9bbad6 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 12 Oct 2021 09:20:46 +0800 Subject: [PATCH 2/3] Release 4.0 dev6, v4.0.176, 143675 lines. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 329383246..cafee91e3 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ A big THANK YOU goes to: ## Releases +* 2021-10-12, Release [v4.0.176](https://github.com/ossrs/srs/releases/tag/v4.0.176), 4.0 dev6, v4.0.176, 143675 lines. * 2021-09-05, Release [v4.0.161](https://github.com/ossrs/srs/releases/tag/v4.0.161), 4.0 dev5, v4.0.161, 145865 lines. * 2021-08-15, Release [v4.0.156](https://github.com/ossrs/srs/releases/tag/v4.0.156), 4.0 dev4, v4.0.156, 145490 lines. * 2021-08-14, Release [v4.0.153](https://github.com/ossrs/srs/releases/tag/v4.0.153), 4.0 dev3, v4.0.153, 145506 lines. From 5d5df7923bf719faecd8a8732be43655d4bb6e53 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 12 Oct 2021 14:02:35 +0800 Subject: [PATCH 3/3] Config: If docker.conf does not exists, try srs.conf --- trunk/src/app/srs_app_config.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 75045d170..fae390c39 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1984,6 +1984,16 @@ srs_error_t SrsConfig::parse_options(int argc, char** argv) if (config_file.empty()) { return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "no config, read help: %s -h", argv[0]); } + + // For docker, if config is not specified, try srs.conf instead. + string try_config = srs_string_replace(config_file, "docker.conf", "srs.conf"); + if (!srs_path_exists(config_file) && try_config != config_file) { + if (!srs_path_exists(try_config)) { + return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "no config file %s or %s", config_file.c_str(), try_config.c_str()); + } + srs_warn("user config %s does not exists, use %s instead", config_file.c_str(), try_config.c_str()); + config_file = try_config; + } err = parse_file(config_file.c_str());