From 842257edaaa4b4a864aa5aacc4372dda328b608c Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Thu, 6 May 2021 12:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84rtcp=20ext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/Rtsp.cpp | 13 +++++++++++-- src/Rtsp/Rtsp.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index 73f84434..bd2f165c 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -458,18 +458,27 @@ size_t RtpHeader::getExtSize() const { return 0; } auto ext_ptr = &payload + getCsrcSize(); - uint16_t reserved = AV_RB16(ext_ptr); + //uint16_t reserved = AV_RB16(ext_ptr); //每个ext占用4字节 return AV_RB16(ext_ptr + 2) << 2; } +uint16_t RtpHeader::getExtReserved() const{ + //rtp有ext + if (!ext) { + return 0; + } + auto ext_ptr = &payload + getCsrcSize(); + return AV_RB16(ext_ptr); +} + uint8_t *RtpHeader::getExtData() { if (!ext) { return nullptr; } auto ext_ptr = &payload + getCsrcSize(); //多出的4个字节分别为reserved、ext_len - return ext_ptr + 4 + getExtSize(); + return ext_ptr + 4; } size_t RtpHeader::getPayloadOffset() const { diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index 20307f45..aa3b81fb 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -119,6 +119,8 @@ public: //返回ext字段字节长度 size_t getExtSize() const; + //返回ext reserved值 + uint16_t getExtReserved() const; //返回ext段首地址,不存在时返回nullptr uint8_t *getExtData();