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 authored Nov 30, 2023
2 parents 499398a + 07e0a6b commit fa3aa01
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 @@ -40,6 +40,8 @@ message_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool mark) {
if (rtpExtHeaderSize != 0)
rtpExtHeaderSize += 4;

rtpExtHeaderSize = (rtpExtHeaderSize + 3) & ~3;

auto message = make_message(RtpHeaderSize + rtpExtHeaderSize + payload->size());
auto *rtp = (RtpHeader *)message->data();
rtp->setPayloadType(rtpConfig->payloadType);
Expand All @@ -57,8 +59,7 @@ message_ptr RtpPacketizer::packetize(shared_ptr<binary> payload, bool mark) {
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 fa3aa01

Please sign in to comment.