Skip to content

Commit

Permalink
H265RtpDepacketizer: Fix multiple NAL units handling
Browse files Browse the repository at this point in the history
Based on the fix for H264RtpDepacketizer in #1167 (commit
4fc4e9b).
  • Loading branch information
edmonds committed Oct 28, 2024
1 parent 2773d01 commit 3dc1a17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/h265rtpdepacketizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ message_vector H265RtpDepacketizer::buildFrames(message_vector::iterator begin,
message_vector out = {};
auto accessUnit = binary{};
auto frameInfo = std::make_shared<FrameInfo>(payloadType, timestamp);
auto nFrags = 0;

for (auto it = begin; it != end; ++it) {
auto pkt = it->get();
Expand All @@ -87,7 +86,11 @@ message_vector H265RtpDepacketizer::buildFrames(message_vector::iterator begin,
auto nalUnitFragmentHeader = H265NalUnitFragmentHeader{
std::to_integer<uint8_t>(pkt->at(rtpHeaderSize + sizeof(H265NalUnitHeader)))};

if (nFrags++ == 0) {
// RFC 7798: "When set to 1, the S bit indicates the start of a fragmented
// NAL unit, i.e., the first byte of the FU payload is also the first byte of
// the payload of the fragmented NAL unit. When the FU payload is not the start
// of the fragmented NAL unit payload, the S bit MUST be set to 0."
if (nalUnitFragmentHeader.isStart() || accessUnit.empty()) {
addSeparator(accessUnit);
nalUnitHeader.setUnitType(nalUnitFragmentHeader.unitType());
accessUnit.emplace_back(byte(nalUnitHeader._first));
Expand Down

0 comments on commit 3dc1a17

Please sign in to comment.