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

HLS: Enable hls_ctx by default.

This commit is contained in:
winlin 2022-08-27 19:27:08 +08:00
parent ca7b5a1c4e
commit d39995cc31
4 changed files with 23 additions and 17 deletions

View file

@ -6390,7 +6390,7 @@ bool SrsConfig::get_vhost_hls_dts_directly(string vhost)
bool SrsConfig::get_hls_ctx_enabled(std::string vhost)
{
static bool DEFAULT = false;
static bool DEFAULT = true;
SrsConfDirective* conf = get_hls(vhost);
if (!conf) {

View file

@ -195,18 +195,20 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
srs_assert(hr);
SrsRequest* req = hr->to_request(hr->host())->as_http();
SrsAutoFree(SrsRequest, req);
// discovery vhost, resolve the vhost from config
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(req->vhost);
if (parsed_vhost) {
req->vhost = parsed_vhost->arg0();
}
SrsAutoFree(SrsRequest, req);
// If HLS stream is disabled, use SrsHttpFileServer to serve HLS, which is normal file server.
if (!_srs_config->get_hls_ctx_enabled(req->vhost)) {
return SrsHttpFileServer::serve_m3u8_ctx(w, r, fullpath);
}
// Serve as HLS stream, create a HLS session to serve it.
string ctx = hr->query_get(SRS_CONTEXT_IN_HLS);
if (!ctx.empty() && ctx_is_exist(ctx)) {
alive(ctx, NULL);
@ -231,8 +233,7 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
ss << "#EXTM3U" << SRS_CONSTS_LF;
ss << "#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1" << SRS_CONSTS_LF;
ss << hr->path() << "?" << SRS_CONTEXT_IN_HLS << "=" << ctx;
if (!hr->query().empty() && hr->query_get(SRS_CONTEXT_IN_HLS).empty())
{
if (!hr->query().empty() && hr->query_get(SRS_CONTEXT_IN_HLS).empty()) {
ss << "&" << hr->query();
}

View file

@ -1210,8 +1210,8 @@ VOID TEST(ProtocolHTTPTest, VodStreamHandlers)
__MOCK_HTTP_EXPECT_STREQ(200, "Hello, world!", w);
}
// TODO: should return "hls_ctx"
if (false) {
// Should return "hls_ctx"
if (true) {
SrsHttpMuxEntry e;
e.pattern = "/";
@ -1228,8 +1228,8 @@ VOID TEST(ProtocolHTTPTest, VodStreamHandlers)
__MOCK_HTTP_EXPECT_STRCT(200, "index.m3u8?hls_ctx=", w);
}
// TODO: should return "hls_ctx"
if (false) {
// Should return "hls_ctx"
if (true) {
SrsHttpMuxEntry e;
e.pattern = "/";