From 9e8568e75360c2b85d6911560b6324588a22f37d Mon Sep 17 00:00:00 2001 From: yogo-zhangyingzhe <100331270+yogo-zhangyingzhe@users.noreply.github.com> Date: Sat, 8 Jul 2023 23:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0rtp=20ext:=20av1-rtp-spec=20(?= =?UTF-8?q?#2609)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xia-chu <771730766@qq.com> --- webrtc/RtpExt.cpp | 10 +++++++--- webrtc/RtpExt.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/webrtc/RtpExt.cpp b/webrtc/RtpExt.cpp index e1424ea7..dda65077 100644 --- a/webrtc/RtpExt.cpp +++ b/webrtc/RtpExt.cpp @@ -94,6 +94,7 @@ uint8_t RtpExtOneByte::getId() const { } void RtpExtOneByte::setId(uint8_t in) { + CHECK(in < (int)RtpExtType::reserved); id = in & 0x0F; } @@ -143,8 +144,6 @@ void appendExt(map &ret, uint8_t *ptr, const uint8_t *end) { ++ptr; continue; } - //15类型的rtp ext为保留 - CHECK(ext->getId() < (uint8_t) RtpExtType::reserved); CHECK(reinterpret_cast(ext) + Type::kMinSize <= end); CHECK(ext->getData() + ext->getSize() <= end); ret.emplace(ext->getId(), RtpExt(ext, isOneByteExt(), reinterpret_cast(ext->getData()), ext->getSize())); @@ -522,8 +521,13 @@ uint8_t RtpExt::getFramemarkingTID() const { } void RtpExt::setExtId(uint8_t ext_id) { - assert(ext_id > (int) RtpExtType::padding && ext_id <= (int) RtpExtType::reserved && _ext); + assert(ext_id > (int) RtpExtType::padding && _ext); if (_one_byte_ext) { + if (ext_id >= (int)RtpExtType::reserved) { + WarnL << "One byte rtp ext can not store id " << (int)ext_id << "(" << getExtName((RtpExtType)ext_id) << ") big than 14"; + clearExt(); + return; + } auto ptr = reinterpret_cast(_ext); ptr->setId(ext_id); } else { diff --git a/webrtc/RtpExt.h b/webrtc/RtpExt.h index 6345b394..524fa3bb 100644 --- a/webrtc/RtpExt.h +++ b/webrtc/RtpExt.h @@ -34,6 +34,7 @@ namespace mediakit { XX(playout_delay, "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay") \ XX(video_orientation, "urn:3gpp:video-orientation") \ XX(toffset, "urn:ietf:params:rtp-hdrext:toffset") \ + XX(av1, "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension") \ XX(encrypt, "urn:ietf:params:rtp-hdrext:encrypt") enum class RtpExtType : uint8_t { @@ -41,7 +42,7 @@ enum class RtpExtType : uint8_t { #define XX(type, uri) type, RTP_EXT_MAP(XX) #undef XX - reserved = encrypt, + reserved = 15, }; class RtcMedia;