mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
rtc: support publish twcc using twcc config
This commit is contained in:
parent
d5e91694d5
commit
9840ad8d55
3 changed files with 43 additions and 0 deletions
|
@ -5128,6 +5128,23 @@ bool SrsConfig::get_rtc_nack_enabled(string vhost)
|
||||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_rtc_twcc_enabled(string vhost)
|
||||||
|
{
|
||||||
|
static bool DEFAULT = true;
|
||||||
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
if (!conf) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
conf = conf->get("twcc");
|
||||||
|
if (!conf) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
conf = conf->get("enabled");
|
||||||
|
if (!conf || conf->arg0().empty()) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||||
|
}
|
||||||
SrsConfDirective* SrsConfig::get_vhost(string vhost, bool try_default_vhost)
|
SrsConfDirective* SrsConfig::get_vhost(string vhost, bool try_default_vhost)
|
||||||
{
|
{
|
||||||
srs_assert(root);
|
srs_assert(root);
|
||||||
|
|
|
@ -549,6 +549,7 @@ public:
|
||||||
srs_utime_t get_rtc_stun_timeout(std::string vhost);
|
srs_utime_t get_rtc_stun_timeout(std::string vhost);
|
||||||
bool get_rtc_stun_strict_check(std::string vhost);
|
bool get_rtc_stun_strict_check(std::string vhost);
|
||||||
bool get_rtc_nack_enabled(std::string vhost);
|
bool get_rtc_nack_enabled(std::string vhost);
|
||||||
|
bool get_rtc_twcc_enabled(std::string vhost);
|
||||||
|
|
||||||
// vhost specified section
|
// vhost specified section
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -611,6 +611,7 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
||||||
local_sdp.group_policy_ = "BUNDLE";
|
local_sdp.group_policy_ = "BUNDLE";
|
||||||
|
|
||||||
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
|
bool nack_enabled = _srs_config->get_rtc_nack_enabled(req->vhost);
|
||||||
|
bool twcc_enabled = _srs_config->get_rtc_twcc_enabled(req->vhost);
|
||||||
|
|
||||||
for (size_t i = 0; i < remote_sdp.media_descs_.size(); ++i) {
|
for (size_t i = 0; i < remote_sdp.media_descs_.size(); ++i) {
|
||||||
const SrsMediaDesc& remote_media_desc = remote_sdp.media_descs_[i];
|
const SrsMediaDesc& remote_media_desc = remote_sdp.media_descs_[i];
|
||||||
|
@ -639,11 +640,23 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
||||||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (twcc_enabled) {
|
||||||
|
if (rtcp_fb.at(j) == "transport-cc") {
|
||||||
|
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only choose one match opus codec.
|
// Only choose one match opus codec.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
map<int, string> extmaps = remote_media_desc.get_extmaps();
|
||||||
|
for(map<int, string>::iterator it_ext = extmaps.begin(); it_ext != extmaps.end(); ++it_ext) {
|
||||||
|
if (it_ext->second == kTWCCExt) {
|
||||||
|
local_media_desc.extmaps_[it_ext->first] = kTWCCExt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (local_media_desc.payload_types_.empty()) {
|
if (local_media_desc.payload_types_.empty()) {
|
||||||
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no valid found opus payload type");
|
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no valid found opus payload type");
|
||||||
|
@ -676,6 +689,11 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
||||||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (twcc_enabled) {
|
||||||
|
if (rtcp_fb.at(j) == "transport-cc") {
|
||||||
|
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only choose first match H.264 payload type.
|
// Only choose first match H.264 payload type.
|
||||||
|
@ -684,6 +702,13 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
||||||
|
|
||||||
backup_payloads.push_back(*iter);
|
backup_payloads.push_back(*iter);
|
||||||
}
|
}
|
||||||
|
map<int, string> extmaps = remote_media_desc.get_extmaps();
|
||||||
|
for(map<int, string>::iterator it_ext = extmaps.begin(); it_ext != extmaps.end(); ++it_ext) {
|
||||||
|
if (it_ext->second == kTWCCExt) {
|
||||||
|
local_media_desc.extmaps_[it_ext->first] = kTWCCExt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try my best to pick at least one media payload type.
|
// Try my best to pick at least one media payload type.
|
||||||
if (local_media_desc.payload_types_.empty() && ! backup_payloads.empty()) {
|
if (local_media_desc.payload_types_.empty() && ! backup_payloads.empty()) {
|
||||||
|
|
Loading…
Reference in a new issue