From f1da765a02981af5fa7d13d27d54e633464a3936 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Wed, 27 Mar 2024 11:43:13 +0900 Subject: [PATCH 1/2] Add empty payload packet handling to H264DEpacketizer --- src/h264rtpdepacketizer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/h264rtpdepacketizer.cpp b/src/h264rtpdepacketizer.cpp index 024a46b3b..36a5061f0 100644 --- a/src/h264rtpdepacketizer.cpp +++ b/src/h264rtpdepacketizer.cpp @@ -42,6 +42,12 @@ message_vector H264RtpDepacketizer::buildFrames(message_vector::iterator begin, auto pktParsed = reinterpret_cast(pkt->data()); auto headerSize = sizeof(rtc::RtpHeader) + pktParsed->csrcCount() + pktParsed->getExtensionHeaderSize(); + + if (pkt->size() == headerSize) { + PLOG_VERBOSE << "H.264 RTP packet has empty payload"; + continue; + } + auto nalUnitHeader = NalUnitHeader{std::to_integer(pkt->at(headerSize))}; if (fua_buffer.size() != 0 || nalUnitHeader.unitType() == naluTypeFUA) { From c5c80b8760af3ec767314e18489193a18736fdaa Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Wed, 27 Mar 2024 14:41:03 +0900 Subject: [PATCH 2/2] Add padding handling --- src/h264rtpdepacketizer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/h264rtpdepacketizer.cpp b/src/h264rtpdepacketizer.cpp index 36a5061f0..e897ba664 100644 --- a/src/h264rtpdepacketizer.cpp +++ b/src/h264rtpdepacketizer.cpp @@ -42,10 +42,15 @@ message_vector H264RtpDepacketizer::buildFrames(message_vector::iterator begin, auto pktParsed = reinterpret_cast(pkt->data()); auto headerSize = sizeof(rtc::RtpHeader) + pktParsed->csrcCount() + pktParsed->getExtensionHeaderSize(); + auto paddingSize = 0; - if (pkt->size() == headerSize) { + if (pktParsed->padding()) { + paddingSize = std::to_integer(pkt->at(pkt->size() - 1)); + } + + if (pkt->size() == headerSize + paddingSize) { PLOG_VERBOSE << "H.264 RTP packet has empty payload"; - continue; + continue; } auto nalUnitHeader = NalUnitHeader{std::to_integer(pkt->at(headerSize))};