From f625b3fbf391bb2000650f490d5644849e073cca Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 8 May 2021 11:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=A4=84=E7=90=86=E7=9A=84rt?= =?UTF-8?q?p=20ext=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/RtpExt.cpp | 11 +++++++++++ webrtc/RtpExt.h | 1 + webrtc/WebRtcTransport.cpp | 1 + 3 files changed, 13 insertions(+) diff --git a/webrtc/RtpExt.cpp b/webrtc/RtpExt.cpp index 8189b9e9..a0f47bf1 100644 --- a/webrtc/RtpExt.cpp +++ b/webrtc/RtpExt.cpp @@ -525,6 +525,17 @@ void RtpExt::setExtId(uint8_t ext_id) { } } +void RtpExt::clearExt(){ + assert(_ptr); + if (_one_byte_ext) { + auto ptr = reinterpret_cast(_ptr); + memset(ptr, (int) RtpExtType::padding, RtpExtOneByte::kMinSize + ptr->getSize()); + } else { + auto ptr = reinterpret_cast(_ptr); + memset(ptr, (int) RtpExtType::padding, RtpExtTwoByte::kMinSize + ptr->getSize()); + } +} + void RtpExt::setType(RtpExtType type) { _type = type; } diff --git a/webrtc/RtpExt.h b/webrtc/RtpExt.h index d3975410..3d916def 100644 --- a/webrtc/RtpExt.h +++ b/webrtc/RtpExt.h @@ -90,6 +90,7 @@ public: //危险函数,必须保证关联的RtpHeader对象有效 void setExtId(uint8_t ext_id); + void clearExt(); private: RtpExt(void *ptr, bool one_byte_ext, const char *str, size_t size); diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 74f544dd..325debf4 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -663,6 +663,7 @@ static void changeRtpExtId(const RtpPacket::Ptr &rtp, const Type &map) { auto it = map.find((Type::key_type) pr.first); if (it == map.end()) { WarnL << "未处理的rtp ext, 类型不识别:" << (int) pr.first; + pr.second.clearExt(); continue; } setExtType(pr.second, it->first);