Skip to content

Commit 3dc1a17

Browse files
committed
H265RtpDepacketizer: Fix multiple NAL units handling
Based on the fix for H264RtpDepacketizer in #1167 (commit 4fc4e9b).
1 parent 2773d01 commit 3dc1a17

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/h265rtpdepacketizer.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ message_vector H265RtpDepacketizer::buildFrames(message_vector::iterator begin,
6262
message_vector out = {};
6363
auto accessUnit = binary{};
6464
auto frameInfo = std::make_shared<FrameInfo>(payloadType, timestamp);
65-
auto nFrags = 0;
6665

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

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

0 commit comments

Comments
 (0)