Skip to content

Commit

Permalink
Fix ossrs#2570, remove useless audio track info in PMT when no audio
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Nov 22, 2021
1 parent 2d2d6d7 commit b20c546
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 85 deletions.
14 changes: 0 additions & 14 deletions trunk/conf/full.conf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1400,20 +1400,6 @@ vhost hls.srs.com {
# ...
# 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
# 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
# default: h264
hls_vcodec h264;
# whether cleanup the old expired ts files.
# default: on
hls_cleanup on;
Expand Down
36 changes: 1 addition & 35 deletions trunk/src/app/srs_app_config.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ srs_error_t SrsConfig::check_normal_config()
for (int j = 0; j < (int)conf->directives.size(); j++) {
string m = conf->at(j)->name;
if (m != "enabled" && m != "hls_entry_prefix" && m != "hls_path" && m != "hls_fragment" && m != "hls_window" && m != "hls_on_error"
&& m != "hls_storage" && m != "hls_mount" && m != "hls_td_ratio" && m != "hls_aof_ratio" && m != "hls_acodec" && m != "hls_vcodec"
&& m != "hls_storage" && m != "hls_mount" && m != "hls_td_ratio" && m != "hls_aof_ratio"
&& 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") {
Expand Down Expand Up @@ -6288,40 +6288,6 @@ string SrsConfig::get_hls_on_error(string vhost)
return conf->arg0();
}

string SrsConfig::get_hls_acodec(string vhost)
{
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)
{
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)
{
static int DEFAULT = 64;
Expand Down
4 changes: 0 additions & 4 deletions trunk/src/app/srs_app_config.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -905,10 +905,6 @@ class SrsConfig
// 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.
Expand Down
33 changes: 1 addition & 32 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,38 +358,7 @@ srs_error_t SrsHlsMuxer::segment_open()

// when segment open, the current segment must be NULL.
srs_assert(!current);

// load the default acodec from config.
/*
SrsAudioCodecId default_acodec = SrsAudioCodecIdForbidden;
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());
}
}
// load the default vcodec from config.
SrsVideoCodecId default_vcodec = SrsVideoCodecIdForbidden;
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 == "vn") {
default_vcodec = SrsVideoCodecIdDisabled;
} else {
srs_warn("hls: use h264 for other codec=%s", default_vcodec_str.c_str());
}
}
*/



// new segment.
current = new SrsHlsSegment(context, last_segment_acoded_id, last_segment_vcoded_id, writer);
if (last_segment_acoded_id != SrsAudioCodecIdForbidden || last_segment_vcoded_id != SrsVideoCodecIdForbidden) {
Expand Down

0 comments on commit b20c546

Please sign in to comment.