Skip to content

Commit

Permalink
for #324, always enable hstrs. 3.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 5, 2017
1 parent b4a8156 commit f2efa96
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 72 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
1 change: 0 additions & 1 deletion trunk/conf/full.one.vhost.conf
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ vhost vhost.srs.com {
enabled off;
fast_cache 30;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
http_hooks {
enabled off;
Expand Down
2 changes: 0 additions & 2 deletions trunk/conf/http.aac.live.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ vhost __defaultVhost__ {
enabled on;
fast_cache 30;
mount [vhost]/[app]/[stream].aac;
hstrs on;

}
}
1 change: 0 additions & 1 deletion trunk/conf/http.flv.live.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ vhost __defaultVhost__ {
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
}
1 change: 0 additions & 1 deletion trunk/conf/http.flv.live.edge1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ vhost __defaultVhost__ {
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
}
1 change: 0 additions & 1 deletion trunk/conf/http.flv.live.edge2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ vhost __defaultVhost__ {
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
}
2 changes: 0 additions & 2 deletions trunk/conf/http.mp3.live.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ vhost __defaultVhost__ {
enabled on;
fast_cache 30;
mount [vhost]/[app]/[stream].mp3;
hstrs on;

}
}
1 change: 0 additions & 1 deletion trunk/conf/http.ts.live.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ vhost __defaultVhost__ {
http_remux {
enabled on;
mount [vhost]/[app]/[stream].ts;
hstrs on;
}
}
36 changes: 10 additions & 26 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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());
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,10 +1358,6 @@ class SrsConfig
* 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:
/**
Expand Down
29 changes: 6 additions & 23 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand All @@ -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());
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions trunk/src/app/srs_app_http_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,11 @@ struct SrsLiveEntry
// 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();
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <srs_auto_headers.hpp>
Expand Down

0 comments on commit f2efa96

Please sign in to comment.