From 90b5ed2202210c9cdeaed2322f47bcd2a3989b75 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 4 Sep 2021 12:29:07 +0800 Subject: [PATCH] For #2282, #2181, Remove reload for dvr_apply. 4.0.160 --- trunk/conf/full.conf | 1 + trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_config.cpp | 85 ---------------------------- trunk/src/app/srs_app_config.hpp | 5 -- trunk/src/app/srs_app_dvr.cpp | 29 ---------- trunk/src/app/srs_app_dvr.hpp | 3 - trunk/src/app/srs_app_http_api.cpp | 31 ---------- trunk/src/app/srs_app_reload.cpp | 5 -- trunk/src/app/srs_app_reload.hpp | 1 - trunk/src/core/srs_core_version4.hpp | 2 +- 10 files changed, 3 insertions(+), 160 deletions(-) diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 5a93333f7f..b99a399bc5 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -1481,6 +1481,7 @@ vhost dvr.srs.com { # /, apply to specified stream of app. # for example, to dvr the following two streams: # live/stream1 live/stream2 + # @remark Reload is disabled, @see https://github.com/ossrs/srs/issues/2181 # default: all dvr_apply all; # the dvr plan. canbe: diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index bfc932f6ab..2c65885773 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-09-04, For [#2282](https://github.com/ossrs/srs/pull/2282), [#2181](https://github.com/ossrs/srs/issues/2181), Remove reload for dvr_apply. 4.0.160 * v4.0, 2021-08-28, RTC: Merge [#1859](https://github.com/ossrs/srs/pull/1859), Enhancement: Add param and stream to on_connect. 4.0.159 * v4.0, 2021-08-27, RTC: Merge [#2544](https://github.com/ossrs/srs/pull/2544), Support for multiple SPS/PPS, then pick the first one. 4.0.158 * v4.0, 2021-08-17, RTC: Merge [#2470](https://github.com/ossrs/srs/pull/2470), RTC: Fix rtc to rtmp sync timestamp using sender report. 4.0.157 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 25b1a62161..c90c622fec 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1406,17 +1406,6 @@ srs_error_t SrsConfig::reload_vhost(SrsConfDirective* old_root) } srs_trace("vhost %s reload dvr success.", vhost.c_str()); } - // dvr_apply, the dynamic dvr filter. - if (true) { - // we must reload the dvr_apply, for it's apply to specified stream, - // and we donot want one stream reload take effect on another one. - // @see https://github.com/ossrs/srs/issues/459#issuecomment-140296597 - SrsConfDirective* nda = new_vhost->get("dvr")? new_vhost->get("dvr")->get("dvr_apply") : NULL; - SrsConfDirective* oda = old_vhost->get("dvr")? old_vhost->get("dvr")->get("dvr_apply") : NULL; - if (!srs_directive_equals(nda, oda) && (err = do_reload_vhost_dvr_apply(vhost)) != srs_success) { - return srs_error_wrap(err, "reload dvr_apply"); - } - } // exec, only one per vhost if (!srs_directive_equals(new_vhost->get("exec"), old_vhost->get("exec"))) { @@ -3201,64 +3190,6 @@ srs_error_t SrsConfig::raw_enable_vhost(string vhost, bool& applied) return err; } - -srs_error_t SrsConfig::raw_enable_dvr(string vhost, string stream, bool& applied) -{ - srs_error_t err = srs_success; - - applied = false; - - SrsConfDirective* conf = root->get("vhost", vhost); - srs_assert(conf); - - conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); - - if (conf->args.size() == 1 && (conf->arg0() == "all" || conf->arg0() == "none")) { - conf->args.clear(); - } - - if (std::find(conf->args.begin(), conf->args.end(), stream) == conf->args.end()) { - conf->args.push_back(stream); - } - - if ((err = do_reload_vhost_dvr_apply(vhost)) != srs_success) { - return srs_error_wrap(err, "reload vhost dvr"); - } - - applied = true; - - return err; -} - -srs_error_t SrsConfig::raw_disable_dvr(string vhost, string stream, bool& applied) -{ - srs_error_t err = srs_success; - - applied = false; - - SrsConfDirective* conf = root->get("vhost", vhost); - srs_assert(conf); - - conf = conf->get_or_create("dvr")->get_or_create("dvr_apply"); - - std::vector::iterator it; - - if ((it = std::find(conf->args.begin(), conf->args.end(), stream)) != conf->args.end()) { - conf->args.erase(it); - } - - if (conf->args.empty()) { - conf->args.push_back("none"); - } - - if ((err = do_reload_vhost_dvr_apply(vhost)) != srs_success) { - return srs_error_wrap(err, "reload vhost dvr"); - } - - applied = true; - - return err; -} // LCOV_EXCL_STOP srs_error_t SrsConfig::do_reload_listen() @@ -3426,22 +3357,6 @@ srs_error_t SrsConfig::do_reload_vhost_removed(string vhost) return err; } -srs_error_t SrsConfig::do_reload_vhost_dvr_apply(string vhost) -{ - srs_error_t err = srs_success; - - vector::iterator it; - for (it = subscribes.begin(); it != subscribes.end(); ++it) { - ISrsReloadHandler* subscribe = *it; - if ((err = subscribe->on_reload_vhost_dvr_apply(vhost)) != srs_success) { - return srs_error_wrap(err, "vhost %s notify subscribes dvr_apply failed", vhost.c_str()); - } - } - srs_trace("vhost %s reload dvr_apply success.", vhost.c_str()); - - return err; -} - string SrsConfig::config() { return config_file; diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 4a54d51a25..40fbc7959f 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -371,10 +371,6 @@ class SrsConfig virtual srs_error_t raw_disable_vhost(std::string vhost, bool& applied); // RAW enable the disabled vhost. virtual srs_error_t raw_enable_vhost(std::string vhost, bool& applied); - // RAW enable the dvr of stream of vhost. - virtual srs_error_t raw_enable_dvr(std::string vhost, std::string stream, bool& applied); - // RAW disable the dvr of stream of vhost. - virtual srs_error_t raw_disable_dvr(std::string vhost, std::string stream, bool& applied); private: virtual srs_error_t do_reload_listen(); virtual srs_error_t do_reload_pid(); @@ -386,7 +382,6 @@ class SrsConfig virtual srs_error_t do_reload_pithy_print_ms(); virtual srs_error_t do_reload_vhost_added(std::string vhost); virtual srs_error_t do_reload_vhost_removed(std::string vhost); - virtual srs_error_t do_reload_vhost_dvr_apply(std::string vhost); public: // Get the config file path. virtual std::string config(); diff --git a/trunk/src/app/srs_app_dvr.cpp b/trunk/src/app/srs_app_dvr.cpp index 763789bf93..281f4aa6fb 100644 --- a/trunk/src/app/srs_app_dvr.cpp +++ b/trunk/src/app/srs_app_dvr.cpp @@ -1008,32 +1008,3 @@ srs_error_t SrsDvr::on_video(SrsSharedPtrMessage* shared_video, SrsFormat* forma return plan->on_video(shared_video, format); } -srs_error_t SrsDvr::on_reload_vhost_dvr_apply(string vhost) -{ - srs_error_t err = srs_success; - - SrsConfDirective* conf = _srs_config->get_dvr_apply(req->vhost); - bool v = srs_config_apply_filter(conf, req); - - // the apply changed, republish the dvr. - if (v == actived) { - return err; - } - actived = v; - - on_unpublish(); - if (!actived) { - return err; - } - - if ((err = on_publish()) != srs_success) { - return srs_error_wrap(err, "on publish"); - } - if ((err = hub->on_dvr_request_sh()) != srs_success) { - return srs_error_wrap(err, "request sh"); - } - - return err; -} - - diff --git a/trunk/src/app/srs_app_dvr.hpp b/trunk/src/app/srs_app_dvr.hpp index 19709e0f5f..0e2b6c968f 100644 --- a/trunk/src/app/srs_app_dvr.hpp +++ b/trunk/src/app/srs_app_dvr.hpp @@ -250,9 +250,6 @@ class SrsDvr : public ISrsReloadHandler // mux the video packets to dvr. // @param shared_video, directly ptr, copy it if need to save it. virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format); -// Interface ISrsReloadHandler -public: - virtual srs_error_t on_reload_vhost_dvr_apply(std::string vhost); }; #endif diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 81c7add7e0..6e9bec311c 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1198,37 +1198,6 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* } else { // TODO: support other param. } - } else if (scope == "dvr") { - std::string action = r->query_get("param"); - std::string stream = r->query_get("data"); - extra += "/" + stream + " to " + action; - - if (action != "enable" && action != "disable") { - return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); - } - - // the vhost must exists. - if (!_srs_config->get_vhost(value, false)) { - return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_PARAMS); - } - - if (!_srs_config->get_dvr_enabled(value)) { - return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); - } - - if (action == "enable") { - if ((err = _srs_config->raw_enable_dvr(value, stream, applied)) != srs_success) { - int code = srs_error_code(err); - srs_error_reset(err); - return srs_api_response_code(w, r, code); - } - } else { - if ((err = _srs_config->raw_disable_dvr(value, stream, applied)) != srs_success) { - int code = srs_error_code(err); - srs_error_reset(err); - return srs_api_response_code(w, r, code); - } - } } else { // TODO: support other scope. } diff --git a/trunk/src/app/srs_app_reload.cpp b/trunk/src/app/srs_app_reload.cpp index 99c05b99dc..c341a051ae 100644 --- a/trunk/src/app/srs_app_reload.cpp +++ b/trunk/src/app/srs_app_reload.cpp @@ -163,11 +163,6 @@ srs_error_t ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/) return srs_success; } -srs_error_t ISrsReloadHandler::on_reload_vhost_dvr_apply(string /*vhost*/) -{ - return srs_success; -} - srs_error_t ISrsReloadHandler::on_reload_vhost_publish(string /*vhost*/) { return srs_success; diff --git a/trunk/src/app/srs_app_reload.hpp b/trunk/src/app/srs_app_reload.hpp index da44e8fcee..a4e837e970 100644 --- a/trunk/src/app/srs_app_reload.hpp +++ b/trunk/src/app/srs_app_reload.hpp @@ -53,7 +53,6 @@ class ISrsReloadHandler virtual srs_error_t on_reload_vhost_hls(std::string vhost); virtual srs_error_t on_reload_vhost_hds(std::string vhost); virtual srs_error_t on_reload_vhost_dvr(std::string vhost); - virtual srs_error_t on_reload_vhost_dvr_apply(std::string vhost); virtual srs_error_t on_reload_vhost_publish(std::string vhost); virtual srs_error_t on_reload_vhost_tcp_nodelay(std::string vhost); virtual srs_error_t on_reload_vhost_realtime(std::string vhost); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 5b8d99e0ba..24846b0764 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 159 +#define VERSION_REVISION 160 #endif