1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix #1405: Support guessing IBMF first. v5.0.58

This commit is contained in:
winlin 2022-09-01 19:28:16 +08:00
parent e027d28c4d
commit 783aea7ac3
10 changed files with 81 additions and 25 deletions

View file

@ -2499,7 +2499,8 @@ srs_error_t SrsConfig::check_normal_config()
} else if (n == "publish") {
for (int j = 0; j < (int)conf->directives.size(); j++) {
string m = conf->at(j)->name;
if (m != "mr" && m != "mr_latency" && m != "firstpkt_timeout" && m != "normal_timeout" && m != "parse_sps") {
if (m != "mr" && m != "mr_latency" && m != "firstpkt_timeout" && m != "normal_timeout"
&& m != "parse_sps" && m != "try_annexb_first") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal vhost.publish.%s of %s", m.c_str(), vhost->arg0().c_str());
}
}
@ -4379,23 +4380,46 @@ int SrsConfig::get_chunk_size(string vhost)
bool SrsConfig::get_parse_sps(string vhost)
{
static bool DEFAULT = true;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("publish");
if (!conf) {
return DEFAULT;
}
conf = conf->get("parse_sps");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return SRS_CONF_PERFER_TRUE(conf->arg0());
}
bool SrsConfig::try_annexb_first(string vhost)
{
static bool DEFAULT = true;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("publish");
if (!conf) {
return DEFAULT;
}
conf = conf->get("try_annexb_first");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return SRS_CONF_PERFER_TRUE(conf->arg0());
}

View file

@ -593,6 +593,8 @@ public:
virtual int get_chunk_size(std::string vhost);
// Whether parse the sps when publish stream to SRS.
virtual bool get_parse_sps(std::string vhost);
// Whether try ANNEXB first when parsing SPS/PPS.
virtual bool try_annexb_first(std::string vhost);
// Whether mr is enabled for vhost.
// @param vhost, the vhost to get the mr.
virtual bool get_mr_enabled(std::string vhost);

View file

@ -752,6 +752,9 @@ srs_error_t SrsRtcFromRtmpBridge::initialize(SrsRequest* r)
return srs_error_wrap(err, "format initialize");
}
// Setup the SPS/PPS parsing strategy.
format->try_annexb_first = _srs_config->try_annexb_first(r->vhost);
int bitrate = 48000; // The output bitrate in bps.
if ((err = codec_->initialize(SrsAudioCodecIdAAC, SrsAudioCodecIdOpus, kAudioChannel, kAudioSamplerate,
bitrate)) != srs_success) {
@ -1309,6 +1312,9 @@ srs_error_t SrsRtmpFromRtcBridge::initialize(SrsRequest* r)
return srs_error_wrap(err, "format initialize");
}
// Setup the SPS/PPS parsing strategy.
format->try_annexb_first = _srs_config->try_annexb_first(r->vhost);
return err;
}

View file

@ -858,6 +858,9 @@ srs_error_t SrsOriginHub::initialize(SrsLiveSource* s, SrsRequest* r)
if ((err = format->initialize()) != srs_success) {
return srs_error_wrap(err, "format initialize");
}
// Setup the SPS/PPS parsing strategy.
format->try_annexb_first = _srs_config->try_annexb_first(r->vhost);
if ((err = hls->initialize(this, req_)) != srs_success) {
return srs_error_wrap(err, "hls initialize");