issue #4223: remove hls_acodec and hls_vcodec config.

pull/4225/head
Jacob Su 3 months ago
parent 7951bf3bd6
commit f59a504173

@ -1870,22 +1870,6 @@ vhost hls.srs.com {
# Overwrite by env SRS_VHOST_HLS_HLS_ENTRY_PREFIX for all vhosts.
# optional, default to empty string.
hls_entry_prefix http://your-server;
# the default audio codec of hls.
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
# so user can set the default codec for mp3.
# the available audio codec:
# aac, mp3, an
# Overwrite by env SRS_VHOST_HLS_HLS_ACODEC for all vhosts.
# default: aac
hls_acodec aac;
# the default video codec of hls.
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
# so user can set the default codec for pure audio(without video) to vn.
# the available video codec:
# h264, vn
# Overwrite by env SRS_VHOST_HLS_HLS_VCODEC for all vhosts.
# default: h264
hls_vcodec h264;
# whether cleanup the old expired ts files.
# Overwrite by env SRS_VHOST_HLS_HLS_CLEANUP for all vhosts.
# default: on

@ -14,6 +14,5 @@ vhost __defaultVhost__ {
}
hls {
enabled on;
hls_acodec mp3;
}
}

@ -20,7 +20,6 @@ vhost __defaultVhost__ {
}
hls {
enabled on;
hls_acodec mp3;
}
rtc {
enabled on;

@ -7127,44 +7127,6 @@ string SrsConfig::get_hls_on_error(string vhost)
return conf->arg0();
}
string SrsConfig::get_hls_acodec(string vhost)
{
SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.hls.hls_acodec"); // SRS_VHOST_HLS_HLS_ACODEC
static string DEFAULT = "aac";
SrsConfDirective* conf = get_hls(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("hls_acodec");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_hls_vcodec(string vhost)
{
SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.hls.hls_vcodec"); // SRS_VHOST_HLS_HLS_VCODEC
static string DEFAULT = "h264";
SrsConfDirective* conf = get_hls(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("hls_vcodec");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return conf->arg0();
}
int SrsConfig::get_vhost_hls_nb_notify(string vhost)
{
SRS_OVERWRITE_BY_ENV_INT("srs.vhost.hls.hls_nb_notify"); // SRS_VHOST_HLS_HLS_NB_NOTIFY

@ -957,10 +957,6 @@ public:
// The ignore will ignore error and disable hls.
// The disconnect will disconnect publish connection.
virtual std::string get_hls_on_error(std::string vhost);
// Get the HLS default audio codec.
virtual std::string get_hls_acodec(std::string vhost);
// Get the HLS default video codec.
virtual std::string get_hls_vcodec(std::string vhost);
// Whether cleanup the old ts files.
virtual bool get_hls_cleanup(std::string vhost);
// The timeout in srs_utime_t to dispose the hls.

@ -396,36 +396,14 @@ srs_error_t SrsHlsMuxer::segment_open()
srs_assert(!current);
// load the default acodec from config.
SrsAudioCodecId default_acodec = SrsAudioCodecIdAAC;
if (true) {
std::string default_acodec_str = _srs_config->get_hls_acodec(req->vhost);
if (default_acodec_str == "mp3") {
default_acodec = SrsAudioCodecIdMP3;
} else if (default_acodec_str == "aac") {
default_acodec = SrsAudioCodecIdAAC;
} else if (default_acodec_str == "an") {
default_acodec = SrsAudioCodecIdDisabled;
} else {
srs_warn("hls: use aac for other codec=%s", default_acodec_str.c_str());
}
}
SrsAudioCodecId default_acodec = SrsAudioCodecIdDisabled;
// Now that we know the latest audio codec in stream, use it.
if (latest_acodec_ != SrsAudioCodecIdForbidden) default_acodec = latest_acodec_;
// load the default vcodec from config.
SrsVideoCodecId default_vcodec = SrsVideoCodecIdAVC;
if (true) {
std::string default_vcodec_str = _srs_config->get_hls_vcodec(req->vhost);
if (default_vcodec_str == "h264") {
default_vcodec = SrsVideoCodecIdAVC;
} else if (default_vcodec_str == "h265") {
default_vcodec = SrsVideoCodecIdHEVC;
} else if (default_vcodec_str == "vn") {
default_vcodec = SrsVideoCodecIdDisabled;
} else {
srs_warn("hls: use h264 for other codec=%s", default_vcodec_str.c_str());
}
}
SrsVideoCodecId default_vcodec = SrsVideoCodecIdDisabled;
// Now that we know the latest video codec in stream, use it.
if (latest_vcodec_ != SrsVideoCodecIdForbidden) default_vcodec = latest_vcodec_;

@ -3716,13 +3716,11 @@ VOID TEST(ConfigMainTest, CheckVhostConfig5)
if (true) {
MockSrsConfig conf;
HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "vhost ossrs.net{hls{hls_td_ratio 2.1;hls_aof_ratio 3.1;hls_window 10;hls_on_error xxx;hls_acodec xxx2;hls_vcodec xxx3;hls_nb_notify 5;hls_dts_directly off;hls_cleanup off;hls_dispose 10;hls_wait_keyframe off;}}"));
HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "vhost ossrs.net{hls{hls_td_ratio 2.1;hls_aof_ratio 3.1;hls_window 10;hls_on_error xxx;hls_nb_notify 5;hls_dts_directly off;hls_cleanup off;hls_dispose 10;hls_wait_keyframe off;}}"));
EXPECT_EQ(2.1, conf.get_hls_td_ratio("ossrs.net"));
EXPECT_EQ(3.1, conf.get_hls_aof_ratio("ossrs.net"));
EXPECT_EQ(10*SRS_UTIME_SECONDS, conf.get_hls_window("ossrs.net"));
EXPECT_STREQ("xxx", conf.get_hls_on_error("ossrs.net").c_str());
EXPECT_STREQ("xxx2", conf.get_hls_acodec("ossrs.net").c_str());
EXPECT_STREQ("xxx3", conf.get_hls_vcodec("ossrs.net").c_str());
EXPECT_EQ(5, conf.get_vhost_hls_nb_notify("ossrs.net"));
EXPECT_FALSE(conf.get_vhost_hls_dts_directly("ossrs.net"));
EXPECT_FALSE(conf.get_hls_cleanup("ossrs.net"));
@ -5011,12 +5009,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHls)
SrsSetEnvConfig(hls_entry_prefix, "SRS_VHOST_HLS_HLS_ENTRY_PREFIX", "yyy");
EXPECT_STREQ("yyy", conf.get_hls_entry_prefix("__defaultVhost__").c_str());
SrsSetEnvConfig(hls_acodec, "SRS_VHOST_HLS_HLS_ACODEC", "yyy2");
EXPECT_STREQ("yyy2", conf.get_hls_acodec("__defaultVhost__").c_str());
SrsSetEnvConfig(hls_vcodec, "SRS_VHOST_HLS_HLS_VCODEC", "yyy3");
EXPECT_STREQ("yyy3", conf.get_hls_vcodec("__defaultVhost__").c_str());
SrsSetEnvConfig(hls_cleanup, "SRS_VHOST_HLS_HLS_CLEANUP", "off");
EXPECT_FALSE(conf.get_hls_cleanup("__defaultVhost__"));

Loading…
Cancel
Save