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();