winlin

fix the hstrs bug on edge.

@@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -23,6 +23,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 23
24 #include <srs_app_http_stream.hpp> 24 #include <srs_app_http_stream.hpp>
25 25
  26 +#define SRS_STREAM_CACHE_CYCLE_SECONDS 30
  27 +
26 #if defined(SRS_AUTO_HTTP_CORE) 28 #if defined(SRS_AUTO_HTTP_CORE)
27 29
28 #include <sys/types.h> 30 #include <sys/types.h>
@@ -107,6 +109,7 @@ int SrsStreamCache::cycle() @@ -107,6 +109,7 @@ int SrsStreamCache::cycle()
107 109
108 // TODO: FIXME: support reload. 110 // TODO: FIXME: support reload.
109 if (fast_cache <= 0) { 111 if (fast_cache <= 0) {
  112 + st_sleep(SRS_STREAM_CACHE_CYCLE_SECONDS);
110 return ret; 113 return ret;
111 } 114 }
112 115
@@ -1139,8 +1142,10 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) @@ -1139,8 +1142,10 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
1139 } 1142 }
1140 1143
1141 // hstrs not enabled, ignore. 1144 // hstrs not enabled, ignore.
1142 - // for origin: generally set hstrs to 'off' and mount while stream is pushed to origin.  
1143 - // for edge: must set hstrs to 'on' so that it could trigger rtmp stream before mount. 1145 + // for origin, the http stream will be mount already when publish,
  1146 + // so it must never enter this line for stream already mounted.
  1147 + // for edge, the http stream is trigger by hstrs and mount by it,
  1148 + // so we only hijack when only edge and hstrs is on.
1144 entry = it->second; 1149 entry = it->second;
1145 if (!entry->hstrs) { 1150 if (!entry->hstrs) {
1146 return ret; 1151 return ret;
@@ -1177,12 +1182,18 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph) @@ -1177,12 +1182,18 @@ int SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandler** ph)
1177 SrsAutoFree(SrsRequest, r); 1182 SrsAutoFree(SrsRequest, r);
1178 1183
1179 std::string sid = r->get_stream_url(); 1184 std::string sid = r->get_stream_url();
1180 - // check if the stream is enabled. 1185 + // check whether the http remux is enabled,
  1186 + // for example, user disable the http flv then reload.
1181 if (sflvs.find(sid) != sflvs.end()) { 1187 if (sflvs.find(sid) != sflvs.end()) {
1182 SrsLiveEntry* s_entry = sflvs[sid]; 1188 SrsLiveEntry* s_entry = sflvs[sid];
1183 if (!s_entry->stream->entry->enabled) { 1189 if (!s_entry->stream->entry->enabled) {
1184 - srs_error("stream is disabled, hijack failed. ret=%d", ret);  
1185 - return ret; 1190 + // only when the http entry is disabled, check the config whether http flv disable,
  1191 + // for the http flv edge use hijack to trigger the edge ingester, we always mount it
  1192 + // eventhough the origin does not exists the specified stream.
  1193 + if (!_srs_config->get_vhost_http_remux_enabled(r->vhost)) {
  1194 + srs_error("stream is disabled, hijack failed. ret=%d", ret);
  1195 + return ret;
  1196 + }
1186 } 1197 }
1187 } 1198 }
1188 1199