diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 757aac80..6f08007e 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -292,7 +292,6 @@ string RtcSessionSdp::toString() const { ////////////////////////////////////////////////////////////////////////////////////////// #define SDP_THROW() throw std::invalid_argument(StrPrinter << "解析sdp " << getKey() << " 字段失败:" << str) -#define SDP_THROW2() throw std::invalid_argument(StrPrinter << "生成sdp " << getKey() << " 字段失败") void SdpTime::parse(const string &str) { if (sscanf(str.data(), "%" SCNu64 " %" SCNu64, &start, &stop) != 2) { @@ -842,13 +841,7 @@ void RtcSession::loadFrom(const string &str, bool check) { } rtc_media.rtcp_addr = media.getItemClass('a', "rtcp"); rtc_media.direction = media.getDirection(); - { - rtc_media.extmap.clear(); - auto arr = media.getAllItem('a', "extmap"); - for (auto &ext : arr) { - rtc_media.extmap.emplace(ext.id, ext); - } - } + rtc_media.extmap = media.getAllItem('a', "extmap"); rtc_media.rtcp_mux = media.getItem('a', "rtcp-mux").operator bool(); rtc_media.rtcp_rsize = media.getItem('a', "rtcp-rsize").operator bool(); @@ -1111,8 +1104,8 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ if (m.ice_lite) { sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared("ice-lite"))); } - for (auto &pr : m.extmap) { - sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared(pr.second))); + for (auto &ext : m.extmap) { + sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared(ext))); } if (m.direction != RtpDirection::invalid) { sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared(m.direction))); @@ -1664,9 +1657,9 @@ RETRY: } //对方和我方都支持的扩展,那么我们才支持 - for (auto &pr : offer_media.extmap) { - if (configure.extmap.find(RtpExt::getExtType(pr.second.ext)) != configure.extmap.end()) { - answer_media.extmap.emplace(pr); + for (auto &ext : offer_media.extmap) { + if (configure.extmap.find(RtpExt::getExtType(ext.ext)) != configure.extmap.end()) { + answer_media.extmap.emplace_back(ext); } } diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 3a111649..34c510ef 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -633,7 +633,7 @@ public: SdpAttrFingerprint fingerprint; //////// extmap //////// - map extmap; + vector extmap; //////// sctp //////////// SdpAttrSctpMap sctpmap; diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index db01b69c..d7aa1a49 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -414,10 +414,10 @@ void WebRtcTransportImp::onStartWebRTC() { } if (m.type != TrackApplication) { //记录rtp ext类型与id的关系,方便接收或发送rtp时修改rtp ext id - for (auto &pr : m.extmap) { - auto ext_type = RtpExt::getExtType(pr.second.ext); - _rtp_ext_id_to_type.emplace(pr.second.id, ext_type); - _rtp_ext_type_to_id.emplace(ext_type, pr.second.id); + for (auto &ext : m.extmap) { + auto ext_type = RtpExt::getExtType(ext.ext); + _rtp_ext_id_to_type.emplace(ext.id, ext_type); + _rtp_ext_type_to_id.emplace(ext_type, ext.id); } } }