From f59a504173a0a7c8fc38337c8842a51b2b242da5 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Fri, 8 Nov 2024 16:58:55 +0800 Subject: [PATCH] issue #4223: remove hls_acodec and hls_vcodec config. --- trunk/conf/full.conf | 16 ------------ trunk/conf/mp3.conf | 1 - trunk/conf/mp3.rtc.conf | 1 - trunk/src/app/srs_app_config.cpp | 38 ---------------------------- trunk/src/app/srs_app_config.hpp | 4 --- trunk/src/app/srs_app_hls.cpp | 30 +++------------------- trunk/src/utest/srs_utest_config.cpp | 10 +------- 7 files changed, 5 insertions(+), 95 deletions(-) diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index a84309c22..6c95d297e 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -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 diff --git a/trunk/conf/mp3.conf b/trunk/conf/mp3.conf index d3e0f01ad..5d32488ef 100644 --- a/trunk/conf/mp3.conf +++ b/trunk/conf/mp3.conf @@ -14,6 +14,5 @@ vhost __defaultVhost__ { } hls { enabled on; - hls_acodec mp3; } } diff --git a/trunk/conf/mp3.rtc.conf b/trunk/conf/mp3.rtc.conf index 6268e0ae5..482f66e96 100644 --- a/trunk/conf/mp3.rtc.conf +++ b/trunk/conf/mp3.rtc.conf @@ -20,7 +20,6 @@ vhost __defaultVhost__ { } hls { enabled on; - hls_acodec mp3; } rtc { enabled on; diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index eeae92ef1..deac53303 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -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 diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index e7432d14c..523580a93 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -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. diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 9bc9bdfcb..b0846627e 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -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_; diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 8999dabfe..1ba9ec6f7 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -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__"));