mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Refine code
This commit is contained in:
parent
69fc1ba711
commit
545a0efea3
3 changed files with 47 additions and 32 deletions
|
@ -633,6 +633,21 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
|||
|
||||
SrsMediaDesc& local_media_desc = local_sdp.media_descs_.back();
|
||||
|
||||
// Whether feature enabled in remote extmap.
|
||||
int remote_twcc_id = 0;
|
||||
if (true) {
|
||||
map<int, string> extmaps = remote_media_desc.get_extmaps();
|
||||
for(map<int, string>::iterator it = extmaps.begin(); it != extmaps.end(); ++it) {
|
||||
if (it->second == kTWCCExt) {
|
||||
remote_twcc_id = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (twcc_enabled && remote_twcc_id) {
|
||||
local_media_desc.extmaps_[remote_twcc_id] = kTWCCExt;
|
||||
}
|
||||
|
||||
if (remote_media_desc.is_audio()) {
|
||||
// TODO: check opus format specific param
|
||||
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("opus");
|
||||
|
@ -649,7 +664,7 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
|||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||
}
|
||||
}
|
||||
if (twcc_enabled) {
|
||||
if (twcc_enabled && remote_twcc_id) {
|
||||
if (rtcp_fb.at(j) == "transport-cc") {
|
||||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||
}
|
||||
|
@ -659,13 +674,6 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
|||
// Only choose one match opus codec.
|
||||
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()) {
|
||||
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no valid found opus payload type");
|
||||
|
@ -698,7 +706,7 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
|||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||
}
|
||||
}
|
||||
if (twcc_enabled) {
|
||||
if (twcc_enabled && remote_twcc_id) {
|
||||
if (rtcp_fb.at(j) == "transport-cc") {
|
||||
payload_type.rtcp_fb_.push_back(rtcp_fb.at(j));
|
||||
}
|
||||
|
@ -711,13 +719,6 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo
|
|||
|
||||
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.
|
||||
if (local_media_desc.payload_types_.empty() && ! backup_payloads.empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue