From daa06ffd4f9e773061c3a41bfd05e88a0bf24cca Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 18 Nov 2021 21:25:14 +0800 Subject: [PATCH] =?UTF-8?q?Refine:=20=E7=B2=BE=E7=AE=80webrtc=20sdp?= =?UTF-8?q?=E7=94=9F=E6=88=90ssrc=20line=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 55 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 33d1ad0a..04f40c53 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1022,7 +1022,33 @@ string RtcSession::toRtspSdp() const{ return sdp->toString(); } -void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector &items, uint32_t ssrc_num); +void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector &items, uint32_t ssrc_num) { + assert(ssrc_num); + SdpAttrSSRC ssrc; + ssrc.ssrc = ssrc_num; + + ssrc.attribute = "cname"; + ssrc.attribute_value = rtp_ssrc.cname; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + + if (!rtp_ssrc.msid.empty()) { + ssrc.attribute = "msid"; + ssrc.attribute_value = rtp_ssrc.msid; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } + + if (!rtp_ssrc.mslabel.empty()) { + ssrc.attribute = "mslabel"; + ssrc.attribute_value = rtp_ssrc.mslabel; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } + + if (!rtp_ssrc.label.empty()) { + ssrc.attribute = "label"; + ssrc.attribute_value = rtp_ssrc.label; + items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); + } +} RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ RtcSessionSdp::Ptr ret = std::make_shared(); @@ -1185,33 +1211,6 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{ } return ret; } -void addSdpAttrSSRC(const RtcSSRC &rtp_ssrc, vector &items, uint32_t ssrc_num) { - assert(ssrc_num); - SdpAttrSSRC ssrc; - ssrc.ssrc = ssrc_num; - - ssrc.attribute = "cname"; - ssrc.attribute_value = rtp_ssrc.cname; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - - if (!rtp_ssrc.msid.empty()) { - ssrc.attribute = "msid"; - ssrc.attribute_value = rtp_ssrc.msid; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } - - if (!rtp_ssrc.mslabel.empty()) { - ssrc.attribute = "mslabel"; - ssrc.attribute_value = rtp_ssrc.mslabel; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } - - if (!rtp_ssrc.label.empty()) { - ssrc.attribute = "label"; - ssrc.attribute_value = rtp_ssrc.label; - items.emplace_back(wrapSdpAttr(std::make_shared(ssrc))); - } -} string RtcSession::toString() const{ return toRtcSessionSdp()->toString();