From abd7ee227c2d770b47f9e082f61d5d971fcd4810 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 9 Sep 2015 23:37:07 +0800 Subject: [PATCH] support reload utc_time. 2.0.186 --- README.md | 1 + trunk/src/app/srs_app_config.cpp | 14 +++++++++++++- trunk/src/app/srs_app_log.cpp | 11 ++++++++++- trunk/src/app/srs_app_log.hpp | 3 +++ trunk/src/app/srs_app_reload.cpp | 5 +++++ trunk/src/app/srs_app_reload.hpp | 1 + trunk/src/core/srs_core.hpp | 2 +- 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81f70132b0..f35dc28df9 100755 --- a/README.md +++ b/README.md @@ -341,6 +341,7 @@ Remark: ## History +* v2.0, 2015-09-09, support reload utc_time. 2.0.186 * v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines. * v2.0, 2015-08-22, HTTP API support JSONP by specifies the query string callback=xxx. * v2.0, 2015-08-20, fix [#380][bug #380], srs-librtmp send sequence header when sps or pps changed. diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 871afb653a..8a945cc253 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -957,12 +957,24 @@ int SrsConfig::reload_conf(SrsConfig* conf) srs_trace("reload srs_log_file success."); } + // merge config: utc_time + if (!srs_directive_equals(root->get("utc_time"), old_root->get("utc_time"))) { + for (it = subscribes.begin(); it != subscribes.end(); ++it) { + ISrsReloadHandler* subscribe = *it; + if ((ret = subscribe->on_reload_utc_time()) != ERROR_SUCCESS) { + srs_error("notify subscribes reload utc_time failed. ret=%d", ret); + return ret; + } + } + srs_trace("reload utc_time success."); + } + // merge config: pithy_print_ms if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) { for (it = subscribes.begin(); it != subscribes.end(); ++it) { ISrsReloadHandler* subscribe = *it; if ((ret = subscribe->on_reload_pithy_print()) != ERROR_SUCCESS) { - srs_error("notify subscribes pithy_print_ms listen failed. ret=%d", ret); + srs_error("notify subscribes pithy_print_ms failed. ret=%d", ret); return ret; } } diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp index 5cc6ed14db..2062b17765 100644 --- a/trunk/src/app/srs_app_log.cpp +++ b/trunk/src/app/srs_app_log.cpp @@ -86,6 +86,7 @@ SrsFastLog::SrsFastLog() fd = -1; log_to_file_tank = false; + utc = false; } SrsFastLog::~SrsFastLog() @@ -111,6 +112,7 @@ int SrsFastLog::initialize() log_to_file_tank = _srs_config->get_log_tank_file(); _level = srs_get_log_level(_srs_config->get_log_level()); + utc = _srs_config->get_utc_time(); } return ret; @@ -221,6 +223,13 @@ void SrsFastLog::error(const char* tag, int context_id, const char* fmt, ...) write_log(fd, log_data, size, SrsLogLevel::Error); } +int SrsFastLog::on_reload_utc_time() +{ + utc = _srs_config->get_utc_time(); + + return ERROR_SUCCESS; +} + int SrsFastLog::on_reload_log_tank() { int ret = ERROR_SUCCESS; @@ -291,7 +300,7 @@ bool SrsFastLog::generate_header(bool error, const char* tag, int context_id, co // to calendar time struct tm* tm; - if (_srs_config && _srs_config->get_utc_time()) { + if (utc) { if ((tm = gmtime(&tv.tv_sec)) == NULL) { return false; } diff --git a/trunk/src/app/srs_app_log.hpp b/trunk/src/app/srs_app_log.hpp index a9900b9143..cd4be8e02f 100644 --- a/trunk/src/app/srs_app_log.hpp +++ b/trunk/src/app/srs_app_log.hpp @@ -73,6 +73,8 @@ class SrsFastLog : public ISrsLog, public ISrsReloadHandler int fd; // whether log to file tank bool log_to_file_tank; + // whether use utc time. + bool utc; public: SrsFastLog(); virtual ~SrsFastLog(); @@ -85,6 +87,7 @@ class SrsFastLog : public ISrsLog, public ISrsReloadHandler virtual void error(const char* tag, int context_id, const char* fmt, ...); // interface ISrsReloadHandler. public: + virtual int on_reload_utc_time(); virtual int on_reload_log_tank(); virtual int on_reload_log_level(); virtual int on_reload_log_file(); diff --git a/trunk/src/app/srs_app_reload.cpp b/trunk/src/app/srs_app_reload.cpp index ba4ab09ad1..e776ae6bdc 100644 --- a/trunk/src/app/srs_app_reload.cpp +++ b/trunk/src/app/srs_app_reload.cpp @@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen() return ERROR_SUCCESS; } +int ISrsReloadHandler::on_reload_utc_time() +{ + return ERROR_SUCCESS; +} + int ISrsReloadHandler::on_reload_max_conns() { return ERROR_SUCCESS; diff --git a/trunk/src/app/srs_app_reload.hpp b/trunk/src/app/srs_app_reload.hpp index ceb32194cb..2fead94b48 100644 --- a/trunk/src/app/srs_app_reload.hpp +++ b/trunk/src/app/srs_app_reload.hpp @@ -44,6 +44,7 @@ class ISrsReloadHandler ISrsReloadHandler(); virtual ~ISrsReloadHandler(); public: + virtual int on_reload_utc_time(); virtual int on_reload_max_conns(); virtual int on_reload_listen(); virtual int on_reload_pid(); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index aa29288ef3..3b0e10fc52 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 185 +#define VERSION_REVISION 186 // server info. #define RTMP_SIG_SRS_KEY "SRS"