winlin

fix the hstrs bug on edge.

... ... @@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_http_stream.hpp>
#define SRS_STREAM_CACHE_CYCLE_SECONDS 30
#if defined(SRS_AUTO_HTTP_CORE)
#include <sys/types.h>
... ... @@ -107,6 +109,7 @@ int SrsStreamCache::cycle()
// TODO: FIXME: support reload.
if (fast_cache <= 0) {
st_sleep(SRS_STREAM_CACHE_CYCLE_SECONDS);
return ret;
}
... ... @@ -1139,8 +1142,10 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
}
// hstrs not enabled, ignore.
// for origin: generally set hstrs to 'off' and mount while stream is pushed to origin.
// for edge: must set hstrs to 'on' so that it could trigger rtmp stream before mount.
// 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;
... ... @@ -1177,12 +1182,18 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
SrsAutoFree(SrsRequest, r);
std::string sid = r->get_stream_url();
// check if the stream is enabled.
// check whether the http remux is enabled,
// for example, user disable the http flv then reload.
if (sflvs.find(sid) != sflvs.end()) {
SrsLiveEntry* s_entry = sflvs[sid];
if (!s_entry->stream->entry->enabled) {
srs_error("stream is disabled, hijack failed. ret=%d", ret);
return ret;
// only when the http entry is disabled, check the config whether http flv disable,
// for the http flv edge use hijack to trigger the edge ingester, we always mount it
// eventhough the origin does not exists the specified stream.
if (!_srs_config->get_vhost_http_remux_enabled(r->vhost)) {
srs_error("stream is disabled, hijack failed. ret=%d", ret);
return ret;
}
}
}
... ...