From 1228d07ff3d6666e4a469726968f757d807f0e23 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 29 Mar 2021 00:12:20 +0800 Subject: [PATCH] =?UTF-8?q?extmap=E6=94=AF=E6=8C=81=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 17 +++++++++++++---- webrtc/Sdp.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index e122eafa..e0888dfd 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -447,15 +447,24 @@ string SdpAttrSetup::toString() const { void SdpAttrExtmap::parse(const string &str) { char buf[128] = {0}; - if (sscanf(str.data(), "%" PRId32 " %127s", &index, buf) != 2) { - SDP_THROW(); + char direction_buf[32] = {0}; + if (sscanf(str.data(), "%" PRId32 "/%31[^ ] %127s", &index, direction_buf, buf) != 3) { + if (sscanf(str.data(), "%" PRId32 " %127s", &index, buf) != 2) { + SDP_THROW(); + } + } else { + direction = getRtpDirection(direction_buf); } ext = buf; } string SdpAttrExtmap::toString() const { if (value.empty()) { - value = to_string(index) + " " + ext; + if(direction == RtpDirection::invalid){ + value = to_string(index) + " " + ext; + } else { + value = to_string(index) + "/" + getRtpDirectionString(direction) + " " + ext; + } } return SdpItem::toString(); } @@ -693,7 +702,7 @@ void test_sdp(){ "a=fingerprint:sha-256 22:14:B5:AF:66:12:C7:C7:8D:EF:4B:DE:40:25:ED:5D:8F:17:54:DD:88:33:C0:13:2E:FD:1A:FA:7E:7A:1B:79\n" "a=setup:actpass\n" "a=mid:audio\n" - "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\n" + "a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:ssrc-audio-level\n" "a=sendrecv\n" "a=rtcp-mux\n" "a=rtpmap:111 opus/48000/2\n" diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 8af83f04..9c0d2740 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -293,8 +293,9 @@ public: class SdpAttrExtmap : public SdpItem { public: //https://aggresss.blog.csdn.net/article/details/106436703 - //a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level + //a=extmap:1[/sendonly] urn:ietf:params:rtp-hdrext:ssrc-audio-level int index; + RtpDirection direction{RtpDirection::invalid}; string ext; void parse(const string &str) override; string toString() const override;