mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
issue #4223: remove hls_acodec and hls_vcodec config.
This commit is contained in:
parent
7951bf3bd6
commit
f59a504173
7 changed files with 5 additions and 95 deletions
|
@ -1870,22 +1870,6 @@ vhost hls.srs.com {
|
||||||
# Overwrite by env SRS_VHOST_HLS_HLS_ENTRY_PREFIX for all vhosts.
|
# Overwrite by env SRS_VHOST_HLS_HLS_ENTRY_PREFIX for all vhosts.
|
||||||
# optional, default to empty string.
|
# optional, default to empty string.
|
||||||
hls_entry_prefix http://your-server;
|
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.
|
# whether cleanup the old expired ts files.
|
||||||
# Overwrite by env SRS_VHOST_HLS_HLS_CLEANUP for all vhosts.
|
# Overwrite by env SRS_VHOST_HLS_HLS_CLEANUP for all vhosts.
|
||||||
# default: on
|
# default: on
|
||||||
|
|
|
@ -14,6 +14,5 @@ vhost __defaultVhost__ {
|
||||||
}
|
}
|
||||||
hls {
|
hls {
|
||||||
enabled on;
|
enabled on;
|
||||||
hls_acodec mp3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ vhost __defaultVhost__ {
|
||||||
}
|
}
|
||||||
hls {
|
hls {
|
||||||
enabled on;
|
enabled on;
|
||||||
hls_acodec mp3;
|
|
||||||
}
|
}
|
||||||
rtc {
|
rtc {
|
||||||
enabled on;
|
enabled on;
|
||||||
|
|
|
@ -7127,44 +7127,6 @@ string SrsConfig::get_hls_on_error(string vhost)
|
||||||
return conf->arg0();
|
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)
|
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
|
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 ignore will ignore error and disable hls.
|
||||||
// The disconnect will disconnect publish connection.
|
// The disconnect will disconnect publish connection.
|
||||||
virtual std::string get_hls_on_error(std::string vhost);
|
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.
|
// Whether cleanup the old ts files.
|
||||||
virtual bool get_hls_cleanup(std::string vhost);
|
virtual bool get_hls_cleanup(std::string vhost);
|
||||||
// The timeout in srs_utime_t to dispose the hls.
|
// The timeout in srs_utime_t to dispose the hls.
|
||||||
|
|
|
@ -396,36 +396,14 @@ srs_error_t SrsHlsMuxer::segment_open()
|
||||||
srs_assert(!current);
|
srs_assert(!current);
|
||||||
|
|
||||||
// load the default acodec from config.
|
// load the default acodec from config.
|
||||||
SrsAudioCodecId default_acodec = SrsAudioCodecIdAAC;
|
SrsAudioCodecId default_acodec = SrsAudioCodecIdDisabled;
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now that we know the latest audio codec in stream, use it.
|
// Now that we know the latest audio codec in stream, use it.
|
||||||
if (latest_acodec_ != SrsAudioCodecIdForbidden) default_acodec = latest_acodec_;
|
if (latest_acodec_ != SrsAudioCodecIdForbidden) default_acodec = latest_acodec_;
|
||||||
|
|
||||||
// load the default vcodec from config.
|
// load the default vcodec from config.
|
||||||
SrsVideoCodecId default_vcodec = SrsVideoCodecIdAVC;
|
SrsVideoCodecId default_vcodec = SrsVideoCodecIdDisabled;
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now that we know the latest video codec in stream, use it.
|
// Now that we know the latest video codec in stream, use it.
|
||||||
if (latest_vcodec_ != SrsVideoCodecIdForbidden) default_vcodec = latest_vcodec_;
|
if (latest_vcodec_ != SrsVideoCodecIdForbidden) default_vcodec = latest_vcodec_;
|
||||||
|
|
||||||
|
|
|
@ -3716,13 +3716,11 @@ VOID TEST(ConfigMainTest, CheckVhostConfig5)
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
MockSrsConfig conf;
|
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(2.1, conf.get_hls_td_ratio("ossrs.net"));
|
||||||
EXPECT_EQ(3.1, conf.get_hls_aof_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_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("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_EQ(5, conf.get_vhost_hls_nb_notify("ossrs.net"));
|
||||||
EXPECT_FALSE(conf.get_vhost_hls_dts_directly("ossrs.net"));
|
EXPECT_FALSE(conf.get_vhost_hls_dts_directly("ossrs.net"));
|
||||||
EXPECT_FALSE(conf.get_hls_cleanup("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");
|
SrsSetEnvConfig(hls_entry_prefix, "SRS_VHOST_HLS_HLS_ENTRY_PREFIX", "yyy");
|
||||||
EXPECT_STREQ("yyy", conf.get_hls_entry_prefix("__defaultVhost__").c_str());
|
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");
|
SrsSetEnvConfig(hls_cleanup, "SRS_VHOST_HLS_HLS_CLEANUP", "off");
|
||||||
EXPECT_FALSE(conf.get_hls_cleanup("__defaultVhost__"));
|
EXPECT_FALSE(conf.get_hls_cleanup("__defaultVhost__"));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue