Skip to content

Commit

Permalink
Merge pull request #1061 from melpon/fix-rtp-header-ext
Browse files Browse the repository at this point in the history
Ensure rtpExtHeaderSize is a multiple of 4
  • Loading branch information
paullouisageneau committed Jan 7, 2024
1 parent 722ace3 commit 198a2ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rtppacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ binary_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool setMark) {
rtpExtHeaderSize += 4;
}

rtpExtHeaderSize = (rtpExtHeaderSize + 3) & ~3;

auto msg = std::make_shared<binary>(rtpHeaderSize + rtpExtHeaderSize + payload->size());
auto *rtp = (RtpHeader *)msg->data();
rtp->setPayloadType(rtpConfig->payloadType);
Expand All @@ -60,8 +62,7 @@ binary_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool setMark) {
auto extHeader = rtp->getExtensionHeader();
extHeader->setProfileSpecificId(0xbede);

auto headerLength = static_cast<uint16_t>(rtpExtHeaderSize - 4);
headerLength = static_cast<uint16_t>((headerLength + 3) / 4);
auto headerLength = static_cast<uint16_t>(rtpExtHeaderSize / 4) - 1;

extHeader->setHeaderLength(headerLength);
extHeader->clearBody();
Expand Down

0 comments on commit 198a2ec

Please sign in to comment.