From 586bb739120075323e7f9bbbc2ca413f5f6de432 Mon Sep 17 00:00:00 2001 From: "LeiZhi.Mai" Date: Fri, 1 Dec 2023 10:44:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9webrtc=20offer=20sdp=E4=B8=AD?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=A1=8C=E7=9A=84=E6=83=85=E5=86=B5=20(#3038?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 7051e42f..89a9092c 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -267,16 +267,23 @@ void RtcSessionSdp::parse(const string &str) { static auto flag = registerAllItem(); RtcSdpBase *media = nullptr; auto lines = split(str, "\n"); - for(auto &line : lines){ + std::set line_set; + for (auto &line : lines) { trim(line); - if(line.size() < 3 || line[1] != '='){ + if (line.size() < 3 || line[1] != '=') { continue; } + + if (!line_set.emplace(line).second) { + continue; + } + auto key = line.substr(0, 1); auto value = line.substr(2); if (!strcasecmp(key.data(), "m")) { medias.emplace_back(RtcSdpBase()); media = &medias.back(); + line_set.clear(); } SdpItem::Ptr item;