mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
HLS: Support config hls_ctx to disable HLS streaming.
This commit is contained in:
parent
6dc86b8a2e
commit
2c569f568c
4 changed files with 32 additions and 1 deletions
|
@ -1499,6 +1499,14 @@ vhost hls.srs.com {
|
|||
# the key root URL, use this can support https.
|
||||
# @remark It's optional.
|
||||
hls_key_url https://localhost:8080;
|
||||
# Whether enable hls_ctx.
|
||||
# hls_ctx used to keep track of subsequent m3u8 requests.
|
||||
# if on, hls client info can be collected in stat module,
|
||||
# if on, on_play/on_stop can be called in http hook module.
|
||||
# otherwise not;
|
||||
# When request stopped, http hook or stat with special time effected, that is 2*hls_window,
|
||||
# Default: off
|
||||
hls_ctx on;
|
||||
|
||||
# Special control controls.
|
||||
###########################################
|
||||
|
|
|
@ -2701,7 +2701,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
&& m != "hls_storage" && m != "hls_mount" && m != "hls_td_ratio" && m != "hls_aof_ratio" && m != "hls_acodec" && m != "hls_vcodec"
|
||||
&& m != "hls_m3u8_file" && m != "hls_ts_file" && m != "hls_ts_floor" && m != "hls_cleanup" && m != "hls_nb_notify"
|
||||
&& m != "hls_wait_keyframe" && m != "hls_dispose" && m != "hls_keys" && m != "hls_fragments_per_key" && m != "hls_key_file"
|
||||
&& m != "hls_key_file_path" && m != "hls_key_url" && m != "hls_dts_directly") {
|
||||
&& m != "hls_key_file_path" && m != "hls_key_url" && m != "hls_dts_directly" && m != "hls_ctx") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.hls.%s of %s", m.c_str(), vhost->arg0().c_str());
|
||||
}
|
||||
|
||||
|
@ -6388,6 +6388,23 @@ bool SrsConfig::get_vhost_hls_dts_directly(string vhost)
|
|||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_hls_ctx_enabled(std::string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
SrsConfDirective* conf = get_hls(vhost);
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("hls_ctx");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_hls_cleanup(string vhost)
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
|
|
@ -956,6 +956,8 @@ public:
|
|||
virtual int get_vhost_hls_nb_notify(std::string vhost);
|
||||
// Whether turn the FLV timestamp to TS DTS.
|
||||
virtual bool get_vhost_hls_dts_directly(std::string vhost);
|
||||
// Whether enable hls_ctx
|
||||
virtual bool get_hls_ctx_enabled(std::string vhost);
|
||||
// hds section
|
||||
private:
|
||||
// Get the hds directive of vhost.
|
||||
|
|
|
@ -202,6 +202,10 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
|
|||
}
|
||||
|
||||
SrsAutoFree(SrsRequest, req);
|
||||
|
||||
if (!_srs_config->get_hls_ctx_enabled(req->vhost)) {
|
||||
return SrsHttpFileServer::serve_m3u8_ctx(w, r, fullpath);
|
||||
}
|
||||
|
||||
string ctx = hr->query_get(SRS_CONTEXT_IN_HLS);
|
||||
if (!ctx.empty() && ctx_is_exist(ctx)) {
|
||||
|
|
Loading…
Reference in a new issue