extmap改回vector存放

This commit is contained in:
xia-chu 2021-05-10 10:14:42 +08:00
parent 45abc23e87
commit 985fe310b6
3 changed files with 11 additions and 18 deletions

View File

@ -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<SdpAttrRtcp>('a', "rtcp");
rtc_media.direction = media.getDirection();
{
rtc_media.extmap.clear();
auto arr = media.getAllItem<SdpAttrExtmap>('a', "extmap");
for (auto &ext : arr) {
rtc_media.extmap.emplace(ext.id, ext);
}
}
rtc_media.extmap = media.getAllItem<SdpAttrExtmap>('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<SdpCommon>("ice-lite")));
}
for (auto &pr : m.extmap) {
sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrExtmap>(pr.second)));
for (auto &ext : m.extmap) {
sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared<SdpAttrExtmap>(ext)));
}
if (m.direction != RtpDirection::invalid) {
sdp_media.items.emplace_back(wrapSdpAttr(std::make_shared<DirectionInterfaceImp>(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);
}
}

View File

@ -633,7 +633,7 @@ public:
SdpAttrFingerprint fingerprint;
//////// extmap ////////
map<uint8_t /*id*/, SdpAttrExtmap> extmap;
vector<SdpAttrExtmap> extmap;
//////// sctp ////////////
SdpAttrSctpMap sctpmap;

View File

@ -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);
}
}
}