From f2efa96015ceca382ad5ff49999d572293da9c01 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 5 Jan 2017 09:08:56 +0800 Subject: [PATCH] for #324, always enable hstrs. 3.0.10 --- README.md | 1 + trunk/conf/full.conf | 5 ---- trunk/conf/full.one.vhost.conf | 1 - trunk/conf/http.aac.live.conf | 2 -- trunk/conf/http.flv.live.conf | 1 - trunk/conf/http.flv.live.edge1.conf | 1 - trunk/conf/http.flv.live.edge2.conf | 1 - trunk/conf/http.mp3.live.conf | 2 -- trunk/conf/http.ts.live.conf | 1 - trunk/src/app/srs_app_config.cpp | 36 ++++++++------------------- trunk/src/app/srs_app_config.hpp | 4 --- trunk/src/app/srs_app_http_stream.cpp | 29 +++++---------------- trunk/src/app/srs_app_http_stream.hpp | 5 +--- trunk/src/core/srs_core.hpp | 2 +- 14 files changed, 19 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index ad303aae0..9a75f0e6a 100755 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ Please select your language: ### V3 changes +* v3.0, 2017-01-05, for [#324][bug #324], always enable hstrs. 3.0.10 * v3.0, 2016-12-15, fix [#717][bug #717], [#691][bug #691], http api/static/stream support cors. 3.0.9 * v3.0, 2016-12-08, support log rotate signal SIGUSR1. 3.0.8 * v3.0, 2016-12-07, fix typo and refine grammar. 3.0.7 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index cd77642d0..eb4e782a6 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -767,11 +767,6 @@ vhost http.remux.srs.com { # @remark the port of http is specified by http_server section. # default: [vhost]/[app]/[stream].flv mount [vhost]/[app]/[stream].flv; - # whether http stream trigger rtmp stream source when no stream available, - # for example, when encoder has not publish stream yet, - # user can play the http flv stream and wait for stream. - # default: off - hstrs off; } } diff --git a/trunk/conf/full.one.vhost.conf b/trunk/conf/full.one.vhost.conf index 2fd5c53e0..8d52fbc72 100644 --- a/trunk/conf/full.one.vhost.conf +++ b/trunk/conf/full.one.vhost.conf @@ -105,7 +105,6 @@ vhost vhost.srs.com { enabled off; fast_cache 30; mount [vhost]/[app]/[stream].flv; - hstrs on; } http_hooks { enabled off; diff --git a/trunk/conf/http.aac.live.conf b/trunk/conf/http.aac.live.conf index e3fdce78f..52c885240 100644 --- a/trunk/conf/http.aac.live.conf +++ b/trunk/conf/http.aac.live.conf @@ -14,7 +14,5 @@ vhost __defaultVhost__ { enabled on; fast_cache 30; mount [vhost]/[app]/[stream].aac; - hstrs on; - } } diff --git a/trunk/conf/http.flv.live.conf b/trunk/conf/http.flv.live.conf index 9b24ef0d3..09ba1dffc 100644 --- a/trunk/conf/http.flv.live.conf +++ b/trunk/conf/http.flv.live.conf @@ -13,6 +13,5 @@ vhost __defaultVhost__ { http_remux { enabled on; mount [vhost]/[app]/[stream].flv; - hstrs on; } } diff --git a/trunk/conf/http.flv.live.edge1.conf b/trunk/conf/http.flv.live.edge1.conf index 7873fce5c..f77110219 100644 --- a/trunk/conf/http.flv.live.edge1.conf +++ b/trunk/conf/http.flv.live.edge1.conf @@ -19,6 +19,5 @@ vhost __defaultVhost__ { http_remux { enabled on; mount [vhost]/[app]/[stream].flv; - hstrs on; } } diff --git a/trunk/conf/http.flv.live.edge2.conf b/trunk/conf/http.flv.live.edge2.conf index edc59ebd6..a41c4a38f 100644 --- a/trunk/conf/http.flv.live.edge2.conf +++ b/trunk/conf/http.flv.live.edge2.conf @@ -19,6 +19,5 @@ vhost __defaultVhost__ { http_remux { enabled on; mount [vhost]/[app]/[stream].flv; - hstrs on; } } diff --git a/trunk/conf/http.mp3.live.conf b/trunk/conf/http.mp3.live.conf index 4962f8552..be8edceb7 100644 --- a/trunk/conf/http.mp3.live.conf +++ b/trunk/conf/http.mp3.live.conf @@ -14,7 +14,5 @@ vhost __defaultVhost__ { enabled on; fast_cache 30; mount [vhost]/[app]/[stream].mp3; - hstrs on; - } } diff --git a/trunk/conf/http.ts.live.conf b/trunk/conf/http.ts.live.conf index dd1b2be8e..d46c24b9c 100644 --- a/trunk/conf/http.ts.live.conf +++ b/trunk/conf/http.ts.live.conf @@ -13,6 +13,5 @@ vhost __defaultVhost__ { http_remux { enabled on; mount [vhost]/[app]/[stream].ts; - hstrs on; } } diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index b2b0e108f..1c207f7b0 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -367,6 +367,15 @@ int srs_config_transform_vhost(SrsConfDirective* root) continue; } + // SRS3.0, ignore hstrs, always on. + // SRS1/2: + // vhost { http_remux { hstrs; } } + if (n == "http_remux") { + SrsConfDirective* hstrs = conf->get("hstrs"); + conf->remove(hstrs); + srs_freep(hstrs); + } + // SRS3.0, change the refer style // SRS1/2: // vhost { refer; refer_play; refer_publish; } @@ -2553,8 +2562,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsJsonObject* obj) http_remux->set("fast_cache", sdir->dumps_arg0_to_integer()); } else if (sdir->name == "mount") { http_remux->set("mount", sdir->dumps_arg0_to_str()); - } else if (sdir->name == "hstrs") { - http_remux->set("hstrs", sdir->dumps_arg0_to_boolean()); } } } @@ -3903,7 +3910,7 @@ int SrsConfig::check_config() } else if (n == "http_remux") { for (int j = 0; j < (int)conf->directives.size(); j++) { string m = conf->at(j)->name.c_str(); - if (m != "enabled" && m != "mount" && m != "fast_cache" && m != "hstrs") { + if (m != "enabled" && m != "mount" && m != "fast_cache") { ret = ERROR_SYSTEM_CONFIG_INVALID; srs_error("unsupported vhost http_remux directive %s, ret=%d", m.c_str(), ret); return ret; @@ -6751,29 +6758,6 @@ string SrsConfig::get_vhost_http_remux_mount(string vhost) return conf->arg0(); } -bool SrsConfig::get_vhost_http_remux_hstrs(string vhost) -{ - // the HSTRS must default to false for origin. - static bool DEFAULT = false; - - SrsConfDirective* conf = get_vhost(vhost); - if (!conf) { - return DEFAULT; - } - - conf = conf->get("http_remux"); - if (!conf) { - return DEFAULT; - } - - conf = conf->get("hstrs"); - if (!conf || conf->arg0().empty()) { - return DEFAULT; - } - - return SRS_CONF_PERFER_TRUE(conf->arg0()); -} - SrsConfDirective* SrsConfig::get_heartbeart() { return root->get("heartbeat"); diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 43932e7b8..ae2cc28bd 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -1358,10 +1358,6 @@ public: * used to generate the flv stream mount path. */ virtual std::string get_vhost_http_remux_mount(std::string vhost); - /** - * get whether the hstrs(http stream trigger rtmp source) enabled. - */ - virtual bool get_vhost_http_remux_hstrs(std::string vhost); // http heartbeart section private: /** diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index fc2f0c0d4..37d32a8d2 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -622,10 +622,9 @@ int SrsLiveStream::streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrM return ret; } -SrsLiveEntry::SrsLiveEntry(std::string m, bool h) +SrsLiveEntry::SrsLiveEntry(std::string m) { mount = m; - hstrs = h; stream = NULL; cache = NULL; @@ -640,11 +639,6 @@ SrsLiveEntry::SrsLiveEntry(std::string m, bool h) _is_aac = (ext == ".aac"); } -void SrsLiveEntry::reset_hstrs(bool h) -{ - hstrs = h; -} - bool SrsLiveEntry::is_flv() { return _is_flv; @@ -806,7 +800,7 @@ int SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r) // remove the default vhost mount mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); - entry = new SrsLiveEntry(mount, tmpl->hstrs); + entry = new SrsLiveEntry(mount); entry->cache = new SrsBufferCache(s, r); entry->stream = new SrsLiveStream(s, r, entry->cache); @@ -906,9 +900,6 @@ int SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost) string old_tmpl_mount = tmpl->mount; string new_tmpl_mount = _srs_config->get_vhost_http_remux_mount(vhost); - bool hstrs = _srs_config->get_vhost_http_remux_hstrs(vhost); - - tmpl->reset_hstrs(hstrs); /** * TODO: not support to reload different mount url for the time being. @@ -920,11 +911,7 @@ int SrsHttpStreamServer::on_reload_vhost_http_remux_updated(string vhost) // do http mount directly with SrsRequest and SrsSource if stream is played already. if (req) { std::string sid = req->get_stream_url(); - - if (sflvs.find(sid) != sflvs.end()) { - SrsLiveEntry* stream = sflvs[sid]; - stream->reset_hstrs(hstrs); - } + // remount stream. if ((ret = http_mount(source, req)) != ERROR_SUCCESS) { srs_trace("vhost %s http_remux reload failed", vhost.c_str()); @@ -971,15 +958,12 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) return ret; } - // hstrs not enabled, ignore. + // hstrs always enabled. // for origin, the http stream will be mount already when publish, // so it must never enter this line for stream already mounted. // for edge, the http stream is trigger by hstrs and mount by it, // so we only hijack when only edge and hstrs is on. entry = it->second; - if (!entry->hstrs) { - return ret; - } // check entry and request extension. if (entry->is_flv()) { @@ -1048,7 +1032,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) // trigger edge to fetch from origin. bool vhost_is_edge = _srs_config->get_vhost_is_edge(r->vhost); - srs_trace("hstrs: source url=%s, is_edge=%d, source_id=%d[%d]", + srs_trace("flv: source url=%s, is_edge=%d, source_id=%d[%d]", r->get_stream_url().c_str(), vhost_is_edge, s->source_id(), s->source_id()); return ret; @@ -1083,8 +1067,7 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost) } SrsLiveEntry* entry = new SrsLiveEntry( - _srs_config->get_vhost_http_remux_mount(vhost), - _srs_config->get_vhost_http_remux_hstrs(vhost) + _srs_config->get_vhost_http_remux_mount(vhost) ); tflvs[vhost] = entry; diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index 115e31fb9..9da35ba10 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -252,14 +252,11 @@ public: // for template, the mount contains variables. // for concrete stream, the mount is url to access. std::string mount; - // whether hstrs(http stream trigger rtmp source) - bool hstrs; SrsLiveStream* stream; SrsBufferCache* cache; - SrsLiveEntry(std::string m, bool h); - void reset_hstrs(bool h); + SrsLiveEntry(std::string m); bool is_flv(); bool is_ts(); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index f9da936e0..afb5e91a2 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 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 9 +#define VERSION_REVISION 10 // generated by configure, only macros. #include