Skip to content

Commit f59a504

Browse files
committed
issue ossrs#4223: remove hls_acodec and hls_vcodec config.
1 parent 7951bf3 commit f59a504

7 files changed

+5
-95
lines changed

trunk/conf/full.conf

-16
Original file line numberDiff line numberDiff line change
@@ -1870,22 +1870,6 @@ vhost hls.srs.com {
18701870
# Overwrite by env SRS_VHOST_HLS_HLS_ENTRY_PREFIX for all vhosts.
18711871
# optional, default to empty string.
18721872
hls_entry_prefix http://your-server;
1873-
# the default audio codec of hls.
1874-
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
1875-
# so user can set the default codec for mp3.
1876-
# the available audio codec:
1877-
# aac, mp3, an
1878-
# Overwrite by env SRS_VHOST_HLS_HLS_ACODEC for all vhosts.
1879-
# default: aac
1880-
hls_acodec aac;
1881-
# the default video codec of hls.
1882-
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
1883-
# so user can set the default codec for pure audio(without video) to vn.
1884-
# the available video codec:
1885-
# h264, vn
1886-
# Overwrite by env SRS_VHOST_HLS_HLS_VCODEC for all vhosts.
1887-
# default: h264
1888-
hls_vcodec h264;
18891873
# whether cleanup the old expired ts files.
18901874
# Overwrite by env SRS_VHOST_HLS_HLS_CLEANUP for all vhosts.
18911875
# default: on

trunk/conf/mp3.conf

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ vhost __defaultVhost__ {
1414
}
1515
hls {
1616
enabled on;
17-
hls_acodec mp3;
1817
}
1918
}

trunk/conf/mp3.rtc.conf

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ vhost __defaultVhost__ {
2020
}
2121
hls {
2222
enabled on;
23-
hls_acodec mp3;
2423
}
2524
rtc {
2625
enabled on;

trunk/src/app/srs_app_config.cpp

-38
Original file line numberDiff line numberDiff line change
@@ -7127,44 +7127,6 @@ string SrsConfig::get_hls_on_error(string vhost)
71277127
return conf->arg0();
71287128
}
71297129

7130-
string SrsConfig::get_hls_acodec(string vhost)
7131-
{
7132-
SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.hls.hls_acodec"); // SRS_VHOST_HLS_HLS_ACODEC
7133-
7134-
static string DEFAULT = "aac";
7135-
7136-
SrsConfDirective* conf = get_hls(vhost);
7137-
if (!conf) {
7138-
return DEFAULT;
7139-
}
7140-
7141-
conf = conf->get("hls_acodec");
7142-
if (!conf || conf->arg0().empty()) {
7143-
return DEFAULT;
7144-
}
7145-
7146-
return conf->arg0();
7147-
}
7148-
7149-
string SrsConfig::get_hls_vcodec(string vhost)
7150-
{
7151-
SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.hls.hls_vcodec"); // SRS_VHOST_HLS_HLS_VCODEC
7152-
7153-
static string DEFAULT = "h264";
7154-
7155-
SrsConfDirective* conf = get_hls(vhost);
7156-
if (!conf) {
7157-
return DEFAULT;
7158-
}
7159-
7160-
conf = conf->get("hls_vcodec");
7161-
if (!conf || conf->arg0().empty()) {
7162-
return DEFAULT;
7163-
}
7164-
7165-
return conf->arg0();
7166-
}
7167-
71687130
int SrsConfig::get_vhost_hls_nb_notify(string vhost)
71697131
{
71707132
SRS_OVERWRITE_BY_ENV_INT("srs.vhost.hls.hls_nb_notify"); // SRS_VHOST_HLS_HLS_NB_NOTIFY

trunk/src/app/srs_app_config.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,6 @@ class SrsConfig
957957
// The ignore will ignore error and disable hls.
958958
// The disconnect will disconnect publish connection.
959959
virtual std::string get_hls_on_error(std::string vhost);
960-
// Get the HLS default audio codec.
961-
virtual std::string get_hls_acodec(std::string vhost);
962-
// Get the HLS default video codec.
963-
virtual std::string get_hls_vcodec(std::string vhost);
964960
// Whether cleanup the old ts files.
965961
virtual bool get_hls_cleanup(std::string vhost);
966962
// The timeout in srs_utime_t to dispose the hls.

trunk/src/app/srs_app_hls.cpp

+4-26
Original file line numberDiff line numberDiff line change
@@ -396,36 +396,14 @@ srs_error_t SrsHlsMuxer::segment_open()
396396
srs_assert(!current);
397397

398398
// load the default acodec from config.
399-
SrsAudioCodecId default_acodec = SrsAudioCodecIdAAC;
400-
if (true) {
401-
std::string default_acodec_str = _srs_config->get_hls_acodec(req->vhost);
402-
if (default_acodec_str == "mp3") {
403-
default_acodec = SrsAudioCodecIdMP3;
404-
} else if (default_acodec_str == "aac") {
405-
default_acodec = SrsAudioCodecIdAAC;
406-
} else if (default_acodec_str == "an") {
407-
default_acodec = SrsAudioCodecIdDisabled;
408-
} else {
409-
srs_warn("hls: use aac for other codec=%s", default_acodec_str.c_str());
410-
}
411-
}
399+
SrsAudioCodecId default_acodec = SrsAudioCodecIdDisabled;
400+
412401
// Now that we know the latest audio codec in stream, use it.
413402
if (latest_acodec_ != SrsAudioCodecIdForbidden) default_acodec = latest_acodec_;
414403

415404
// load the default vcodec from config.
416-
SrsVideoCodecId default_vcodec = SrsVideoCodecIdAVC;
417-
if (true) {
418-
std::string default_vcodec_str = _srs_config->get_hls_vcodec(req->vhost);
419-
if (default_vcodec_str == "h264") {
420-
default_vcodec = SrsVideoCodecIdAVC;
421-
} else if (default_vcodec_str == "h265") {
422-
default_vcodec = SrsVideoCodecIdHEVC;
423-
} else if (default_vcodec_str == "vn") {
424-
default_vcodec = SrsVideoCodecIdDisabled;
425-
} else {
426-
srs_warn("hls: use h264 for other codec=%s", default_vcodec_str.c_str());
427-
}
428-
}
405+
SrsVideoCodecId default_vcodec = SrsVideoCodecIdDisabled;
406+
429407
// Now that we know the latest video codec in stream, use it.
430408
if (latest_vcodec_ != SrsVideoCodecIdForbidden) default_vcodec = latest_vcodec_;
431409

trunk/src/utest/srs_utest_config.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -3716,13 +3716,11 @@ VOID TEST(ConfigMainTest, CheckVhostConfig5)
37163716

37173717
if (true) {
37183718
MockSrsConfig conf;
3719-
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;}}"));
3719+
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;}}"));
37203720
EXPECT_EQ(2.1, conf.get_hls_td_ratio("ossrs.net"));
37213721
EXPECT_EQ(3.1, conf.get_hls_aof_ratio("ossrs.net"));
37223722
EXPECT_EQ(10*SRS_UTIME_SECONDS, conf.get_hls_window("ossrs.net"));
37233723
EXPECT_STREQ("xxx", conf.get_hls_on_error("ossrs.net").c_str());
3724-
EXPECT_STREQ("xxx2", conf.get_hls_acodec("ossrs.net").c_str());
3725-
EXPECT_STREQ("xxx3", conf.get_hls_vcodec("ossrs.net").c_str());
37263724
EXPECT_EQ(5, conf.get_vhost_hls_nb_notify("ossrs.net"));
37273725
EXPECT_FALSE(conf.get_vhost_hls_dts_directly("ossrs.net"));
37283726
EXPECT_FALSE(conf.get_hls_cleanup("ossrs.net"));
@@ -5011,12 +5009,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHls)
50115009
SrsSetEnvConfig(hls_entry_prefix, "SRS_VHOST_HLS_HLS_ENTRY_PREFIX", "yyy");
50125010
EXPECT_STREQ("yyy", conf.get_hls_entry_prefix("__defaultVhost__").c_str());
50135011

5014-
SrsSetEnvConfig(hls_acodec, "SRS_VHOST_HLS_HLS_ACODEC", "yyy2");
5015-
EXPECT_STREQ("yyy2", conf.get_hls_acodec("__defaultVhost__").c_str());
5016-
5017-
SrsSetEnvConfig(hls_vcodec, "SRS_VHOST_HLS_HLS_VCODEC", "yyy3");
5018-
EXPECT_STREQ("yyy3", conf.get_hls_vcodec("__defaultVhost__").c_str());
5019-
50205012
SrsSetEnvConfig(hls_cleanup, "SRS_VHOST_HLS_HLS_CLEANUP", "off");
50215013
EXPECT_FALSE(conf.get_hls_cleanup("__defaultVhost__"));
50225014

0 commit comments

Comments
 (0)