Fix is_first_packet_in_frame for SEI and PPS NALUs

PacketBuffer will ignore any non-idr frame which is firs packet has not
is_first_packet_in_frame set to true if there was a packet loss in the
previous frame even if the cseqs are continous:

https://issues.webrtc.org/issues/368335257#comment14

This CL sets this flag to true to SEI and PPS nal units that would have
caused the delta frames after an idr frame to be dropped in case of loss.

Bug: webrtc:368335257
Change-Id: Ic7150297d7fb4ed274c7d99175ff367100b5cf75
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364241
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43168}
This commit is contained in:
Sergio Garcia Murillo 2024-10-03 16:07:51 +02:00 committed by WebRTC LUCI CQ
parent 62b245c64f
commit fb803de683
2 changed files with 29 additions and 2 deletions

View File

@ -188,6 +188,7 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessStapAOrSingleNalu(
<< "Failed to parse PPS id and SPS id from PPS slice.";
return std::nullopt;
}
parsed_payload->video_header.is_first_packet_in_frame = true;
break;
}
case H264::NaluType::kIdr:
@ -212,12 +213,13 @@ std::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessStapAOrSingleNalu(
case H264::NaluType::kAud:
parsed_payload->video_header.is_first_packet_in_frame = true;
break;
case H264::NaluType::kSei:
parsed_payload->video_header.is_first_packet_in_frame = true;
break;
// Slices below don't contain SPS or PPS ids.
case H264::NaluType::kEndOfSequence:
case H264::NaluType::kEndOfStream:
case H264::NaluType::kFiller:
case H264::NaluType::kSei:
break;
case H264::NaluType::kStapA:
case H264::NaluType::kFuA:
RTC_LOG(LS_WARNING) << "Unexpected STAP-A or FU-A received.";

View File

@ -517,5 +517,30 @@ TEST(VideoRtpDepacketizerH264Test, AudSetsFirstPacketInFrame) {
EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame);
}
TEST(VideoRtpDepacketizerH264Test, PpsSetsFirstPacketInFrame) {
const uint8_t kPayload[] = {
0x08, 0x69, 0xFC, 0x0, 0x0, 0x3, 0x0,
0x7, 0xFF, 0xFF, 0xFF, 0xF6, 0x40 // PPS.
};
VideoRtpDepacketizerH264 depacketizer;
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload));
ASSERT_TRUE(parsed);
EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame);
}
TEST(VideoRtpDepacketizerH264Test, SeiSetsFirstPacketInFrame) {
const uint8_t kPayload[] = {
0x06, 0x05, 0x04, 0xDE, 0xAD, 0xBE, 0xEF, 0x80 // SEI.
};
VideoRtpDepacketizerH264 depacketizer;
std::optional<VideoRtpDepacketizer::ParsedRtpPayload> parsed =
depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload));
ASSERT_TRUE(parsed);
EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame);
}
} // namespace
} // namespace webrtc