1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #324, always enable hstrs. 3.0.10

This commit is contained in:
winlin 2017-01-05 09:08:56 +08:00
parent b4a815641b
commit f2efa96015
14 changed files with 19 additions and 72 deletions

View file

@ -132,6 +132,7 @@ Please select your language:
### V3 changes ### 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-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-08, support log rotate signal SIGUSR1. 3.0.8
* v3.0, 2016-12-07, fix typo and refine grammar. 3.0.7 * v3.0, 2016-12-07, fix typo and refine grammar. 3.0.7

View file

@ -767,11 +767,6 @@ vhost http.remux.srs.com {
# @remark the port of http is specified by http_server section. # @remark the port of http is specified by http_server section.
# default: [vhost]/[app]/[stream].flv # default: [vhost]/[app]/[stream].flv
mount [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;
} }
} }

View file

@ -105,7 +105,6 @@ vhost vhost.srs.com {
enabled off; enabled off;
fast_cache 30; fast_cache 30;
mount [vhost]/[app]/[stream].flv; mount [vhost]/[app]/[stream].flv;
hstrs on;
} }
http_hooks { http_hooks {
enabled off; enabled off;

View file

@ -14,7 +14,5 @@ vhost __defaultVhost__ {
enabled on; enabled on;
fast_cache 30; fast_cache 30;
mount [vhost]/[app]/[stream].aac; mount [vhost]/[app]/[stream].aac;
hstrs on;
} }
} }

View file

@ -13,6 +13,5 @@ vhost __defaultVhost__ {
http_remux { http_remux {
enabled on; enabled on;
mount [vhost]/[app]/[stream].flv; mount [vhost]/[app]/[stream].flv;
hstrs on;
} }
} }

View file

@ -19,6 +19,5 @@ vhost __defaultVhost__ {
http_remux { http_remux {
enabled on; enabled on;
mount [vhost]/[app]/[stream].flv; mount [vhost]/[app]/[stream].flv;
hstrs on;
} }
} }

View file

@ -19,6 +19,5 @@ vhost __defaultVhost__ {
http_remux { http_remux {
enabled on; enabled on;
mount [vhost]/[app]/[stream].flv; mount [vhost]/[app]/[stream].flv;
hstrs on;
} }
} }

View file

@ -14,7 +14,5 @@ vhost __defaultVhost__ {
enabled on; enabled on;
fast_cache 30; fast_cache 30;
mount [vhost]/[app]/[stream].mp3; mount [vhost]/[app]/[stream].mp3;
hstrs on;
} }
} }

View file

@ -13,6 +13,5 @@ vhost __defaultVhost__ {
http_remux { http_remux {
enabled on; enabled on;
mount [vhost]/[app]/[stream].ts; mount [vhost]/[app]/[stream].ts;
hstrs on;
} }
} }

View file

@ -367,6 +367,15 @@ int srs_config_transform_vhost(SrsConfDirective* root)
continue; 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 // SRS3.0, change the refer style
// SRS1/2: // SRS1/2:
// vhost { refer; refer_play; refer_publish; } // 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()); http_remux->set("fast_cache", sdir->dumps_arg0_to_integer());
} else if (sdir->name == "mount") { } else if (sdir->name == "mount") {
http_remux->set("mount", sdir->dumps_arg0_to_str()); 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") { } else if (n == "http_remux") {
for (int j = 0; j < (int)conf->directives.size(); j++) { for (int j = 0; j < (int)conf->directives.size(); j++) {
string m = conf->at(j)->name.c_str(); 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; ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported vhost http_remux directive %s, ret=%d", m.c_str(), ret); srs_error("unsupported vhost http_remux directive %s, ret=%d", m.c_str(), ret);
return ret; return ret;
@ -6751,29 +6758,6 @@ string SrsConfig::get_vhost_http_remux_mount(string vhost)
return conf->arg0(); 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() SrsConfDirective* SrsConfig::get_heartbeart()
{ {
return root->get("heartbeat"); return root->get("heartbeat");

View file

@ -1358,10 +1358,6 @@ public:
* used to generate the flv stream mount path. * used to generate the flv stream mount path.
*/ */
virtual std::string get_vhost_http_remux_mount(std::string vhost); 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 // http heartbeart section
private: private:
/** /**

View file

@ -622,10 +622,9 @@ int SrsLiveStream::streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrM
return ret; return ret;
} }
SrsLiveEntry::SrsLiveEntry(std::string m, bool h) SrsLiveEntry::SrsLiveEntry(std::string m)
{ {
mount = m; mount = m;
hstrs = h;
stream = NULL; stream = NULL;
cache = NULL; cache = NULL;
@ -640,11 +639,6 @@ SrsLiveEntry::SrsLiveEntry(std::string m, bool h)
_is_aac = (ext == ".aac"); _is_aac = (ext == ".aac");
} }
void SrsLiveEntry::reset_hstrs(bool h)
{
hstrs = h;
}
bool SrsLiveEntry::is_flv() bool SrsLiveEntry::is_flv()
{ {
return _is_flv; return _is_flv;
@ -806,7 +800,7 @@ int SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r)
// remove the default vhost mount // remove the default vhost mount
mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); 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->cache = new SrsBufferCache(s, r);
entry->stream = new SrsLiveStream(s, r, entry->cache); 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 old_tmpl_mount = tmpl->mount;
string new_tmpl_mount = _srs_config->get_vhost_http_remux_mount(vhost); 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. * 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. // do http mount directly with SrsRequest and SrsSource if stream is played already.
if (req) { if (req) {
std::string sid = req->get_stream_url(); std::string sid = req->get_stream_url();
if (sflvs.find(sid) != sflvs.end()) {
SrsLiveEntry* stream = sflvs[sid];
stream->reset_hstrs(hstrs);
}
// remount stream. // remount stream.
if ((ret = http_mount(source, req)) != ERROR_SUCCESS) { if ((ret = http_mount(source, req)) != ERROR_SUCCESS) {
srs_trace("vhost %s http_remux reload failed", vhost.c_str()); srs_trace("vhost %s http_remux reload failed", vhost.c_str());
@ -971,15 +958,12 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
return ret; return ret;
} }
// hstrs not enabled, ignore. // hstrs always enabled.
// for origin, the http stream will be mount already when publish, // for origin, the http stream will be mount already when publish,
// so it must never enter this line for stream already mounted. // so it must never enter this line for stream already mounted.
// for edge, the http stream is trigger by hstrs and mount by it, // for edge, the http stream is trigger by hstrs and mount by it,
// so we only hijack when only edge and hstrs is on. // so we only hijack when only edge and hstrs is on.
entry = it->second; entry = it->second;
if (!entry->hstrs) {
return ret;
}
// check entry and request extension. // check entry and request extension.
if (entry->is_flv()) { if (entry->is_flv()) {
@ -1048,7 +1032,7 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
// trigger edge to fetch from origin. // trigger edge to fetch from origin.
bool vhost_is_edge = _srs_config->get_vhost_is_edge(r->vhost); 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()); r->get_stream_url().c_str(), vhost_is_edge, s->source_id(), s->source_id());
return ret; return ret;
@ -1083,8 +1067,7 @@ int SrsHttpStreamServer::initialize_flv_entry(std::string vhost)
} }
SrsLiveEntry* entry = new SrsLiveEntry( SrsLiveEntry* entry = new SrsLiveEntry(
_srs_config->get_vhost_http_remux_mount(vhost), _srs_config->get_vhost_http_remux_mount(vhost)
_srs_config->get_vhost_http_remux_hstrs(vhost)
); );
tflvs[vhost] = entry; tflvs[vhost] = entry;

View file

@ -252,14 +252,11 @@ public:
// for template, the mount contains variables. // for template, the mount contains variables.
// for concrete stream, the mount is url to access. // for concrete stream, the mount is url to access.
std::string mount; std::string mount;
// whether hstrs(http stream trigger rtmp source)
bool hstrs;
SrsLiveStream* stream; SrsLiveStream* stream;
SrsBufferCache* cache; SrsBufferCache* cache;
SrsLiveEntry(std::string m, bool h); SrsLiveEntry(std::string m);
void reset_hstrs(bool h);
bool is_flv(); bool is_flv();
bool is_ts(); bool is_ts();

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 9 #define VERSION_REVISION 10
// generated by configure, only macros. // generated by configure, only macros.
#include <srs_auto_headers.hpp> #include <srs_auto_headers.hpp>