diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc index b30e84078c..9d7b6e550c 100644 --- a/modules/video_coding/packet_buffer.cc +++ b/modules/video_coding/packet_buffer.cc @@ -279,6 +279,14 @@ std::vector> PacketBuffer::FindFrames( int idr_height = -1; bool full_frame_found = false; while (true) { + // GFD is only attached to first packet of frame, so update check on + // every packet. + if (buffer_[start_index] != nullptr) { + is_generic = buffer_[start_index]->video_header.generic.has_value(); + if (is_generic) { + is_h264_descriptor = false; + } + } ++tested_packets; if (!is_h264_descriptor) { diff --git a/modules/video_coding/packet_buffer_unittest.cc b/modules/video_coding/packet_buffer_unittest.cc index 39b9eea6cd..925d8f2876 100644 --- a/modules/video_coding/packet_buffer_unittest.cc +++ b/modules/video_coding/packet_buffer_unittest.cc @@ -827,6 +827,18 @@ TEST_F(PacketBufferH264FrameGap, DisallowFrameGapForH264NoGeneric) { IsEmpty()); } +TEST_F(PacketBufferH264FrameGap, + AllowFrameGapForH264WithGenericOnFirstPacketOnly) { + bool generic = true; + InsertH264(1, kKeyFrame, kFirst, kLast, 1001, {}, 0, 0, generic); + InsertH264(3, kDeltaFrame, kFirst, kNotLast, 1003, {}, 0, 0, generic); + // Second packet is not generic, but we can still output frame with 2 packets. + EXPECT_THAT( + InsertH264(4, kDeltaFrame, kNotFirst, kLast, 1003, {}, 0, 0, !generic) + .packets, + SizeIs(2)); +} + } // namespace } // namespace video_coding } // namespace webrtc