Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLS: restore HLS information when republish stream.(#3088) #3126

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions trunk/conf/hls.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ vhost __defaultVhost__ {
hls_path ./objs/nginx/html;
hls_fragment 10;
hls_window 60;
hls_continuous on;
Copy link
Member

@winlinvip winlinvip Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to: hls_recover would be better, corresponding to the panic-recover concept in Go.

TRANS_BY_GPT4

}
}
69 changes: 43 additions & 26 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ srs_error_t srs_config_transform_vhost(SrsConfDirective* root)
// SRS3+:
// vhost { play { shadow; } }
if (n == "time_jitter" || n == "mix_correct" || n == "atc" || n == "atc_auto"
|| n == "mw_latency" || n == "gop_cache" || n == "gop_cache_max_frames"
|| n == "mw_latency" || n == "gop_cache" || n == "gop_cache_max_frames"
|| n == "queue_length" || n == "send_min_interval"
|| n == "reduce_sequence_header") {
it = dir->directives.erase(it);
Expand Down Expand Up @@ -1553,7 +1553,7 @@ srs_error_t SrsConfig::reload_vhost(SrsConfDirective* old_root)
}
srs_trace("vhost %s reload publish success.", vhost.c_str());
}

// transcode, many per vhost.
if ((err = reload_transcode(new_vhost, old_vhost)) != srs_success) {
return srs_error_wrap(err, "reload transcode");
Expand Down Expand Up @@ -1596,14 +1596,14 @@ srs_error_t SrsConfig::reload_conf(SrsConfig* conf)
return srs_error_wrap(err, "listen");
}
}

// merge config: max_connections
if (!srs_directive_equals(root->get("max_connections"), old_root->get("max_connections"))) {
if ((err = do_reload_max_connections()) != srs_success) {
return srs_error_wrap(err, "max connections");;
}
}

// merge config: pithy_print_ms
if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) {
if ((err = do_reload_pithy_print_ms()) != srs_success) {
Expand Down Expand Up @@ -2609,7 +2609,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_ctx" && m != "hls_ts_ctx") {
&& m != "hls_key_file_path" && m != "hls_key_url" && m != "hls_dts_directly" && m != "hls_ctx" && m != "hls_ts_ctx" && m != "hls_continuous") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.hls.%s of %s", m.c_str(), vhost->arg0().c_str());
}

Expand Down Expand Up @@ -2828,7 +2828,7 @@ srs_error_t SrsConfig::parse_buffer(SrsConfigBuffer* buffer)
if ((err = root->parse(buffer, this)) != srs_success) {
return srs_error_wrap(err, "root parse");
}

return err;
}

Expand Down Expand Up @@ -2988,7 +2988,7 @@ vector<string> SrsConfig::get_listens()
if (!srs_getenv("srs.listen").empty()) { // SRS_LISTEN
return srs_string_split(srs_getenv("srs.listen"), " ");
}

SrsConfDirective* conf = root->get("listen");
if (!conf) {
return ports;
Expand Down Expand Up @@ -4747,7 +4747,7 @@ int SrsConfig::get_gop_cache_max_frames(string vhost)
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return ::atoi(conf->arg0().c_str());
}

Expand Down Expand Up @@ -5372,12 +5372,12 @@ srs_utime_t SrsConfig::get_publish_kickoff_for_idle(SrsConfDirective* vhost)
SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.publish.kickoff_for_idle"); // SRS_VHOST_PUBLISH_KICKOFF_FOR_IDLE

static srs_utime_t DEFAULT = 0 * SRS_UTIME_SECONDS;

SrsConfDirective* conf = vhost;
if (!conf) {
return DEFAULT;
}

conf = conf->get("publish");
if (!conf) {
return DEFAULT;
Expand All @@ -5387,7 +5387,7 @@ srs_utime_t SrsConfig::get_publish_kickoff_for_idle(SrsConfDirective* vhost)
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
}

Expand Down Expand Up @@ -6683,17 +6683,17 @@ int SrsConfig::get_dash_window_size(std::string vhost)
SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.dash.dash_window_size"); // SRS_VHOST_DASH_DASH_WINDOW_SIZE

static int DEFAULT = 5;

SrsConfDirective* conf = get_dash(vhost);
if (!conf) {
return DEFAULT;
}

conf = conf->get("dash_window_size");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return ::atoi(conf->arg0().c_str());
}

Expand All @@ -6702,17 +6702,17 @@ bool SrsConfig::get_dash_cleanup(std::string vhost)
SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.dash.dash_cleanup"); // SRS_VHOST_DASH_DASH_CLEANUP

static bool DEFAULT = true;

SrsConfDirective* conf = get_dash(vhost);
if (!conf) {
return DEFAULT;
}

conf = conf->get("dash_cleanup");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_TRUE(conf->arg0());
}

Expand All @@ -6721,17 +6721,17 @@ srs_utime_t SrsConfig::get_dash_dispose(std::string vhost)
SRS_OVERWRITE_BY_ENV_SECONDS("srs.vhost.dash.dash_dispose"); // SRS_VHOST_DASH_DASH_DISPOSE

static srs_utime_t DEFAULT = 0;

SrsConfDirective* conf = get_dash(vhost);
if (!conf) {
return DEFAULT;
}

conf = conf->get("dash_dispose");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
}

Expand Down Expand Up @@ -7234,6 +7234,23 @@ string SrsConfig::get_hls_key_url(std::string vhost)
return conf->arg0();
}

bool SrsConfig::get_hls_continuous(string vhost)
{
static bool DEFAULT = true;

SrsConfDirective* conf = get_hls(vhost);
if (!conf) {
return DEFAULT;
}

conf = conf->get("hls_continuous");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_TRUE(conf->arg0());
}

SrsConfDirective *SrsConfig::get_hds(const string &vhost)
{
SrsConfDirective* conf = get_vhost(vhost);
Expand Down Expand Up @@ -7619,22 +7636,22 @@ bool SrsConfig::get_http_api_auth_enabled()
SRS_OVERWRITE_BY_ENV_BOOL("srs.http_api.auth.enabled"); // SRS_HTTP_API_AUTH_ENABLED

static bool DEFAULT = false;

SrsConfDirective* conf = root->get("http_api");
if (!conf) {
return DEFAULT;
}

conf = conf->get("auth");
if (!conf) {
return DEFAULT;
}

conf = conf->get("enabled");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_FALSE(conf->arg0());
}

Expand Down Expand Up @@ -8043,7 +8060,7 @@ string SrsConfig::get_srto_passphrase()
if (!conf) {
return DEFAULT;
}

conf = conf->get("passphrase");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
Expand All @@ -8060,7 +8077,7 @@ int SrsConfig::get_srto_pbkeylen()
if (!conf) {
return DEFAULT;
}

conf = conf->get("pbkeylen");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ class SrsConfig
virtual bool get_hls_ctx_enabled(std::string vhost);
// Whether enable session for ts file.
virtual bool get_hls_ts_ctx_enabled(std::string vhost);
// Toggles HLS continuous mode.
// In this mode HLS sequence number is started from where it stopped last time.
// Old fragments are kept. Default is on.
virtual bool get_hls_continuous(std::string vhost);
// hds section
private:
// Get the hds directive of vhost.
Expand Down
Loading