Index: webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc |
diff --git a/webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc b/webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc |
index 83330b934ed9b9ebf1195f8c067197e672be25b5..fc9e87f66b90b38b3b6a6c40192e45e0c24562a3 100644 |
--- a/webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc |
+++ b/webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc |
@@ -261,5 +261,65 @@ TEST_F(TestH264SpsPpsTracker, SpsPpsIdrInStapA) { |
delete[] packet.dataPtr; |
} |
+TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBand) { |
+ constexpr uint8_t kData[] = {1, 2, 3}; |
+ |
+ // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos. |
+ const std::vector<uint8_t> sps( |
+ {0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00, |
+ 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60}); |
+ const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0}); |
+ tracker_.InsertSpsPpsNalus(sps, pps); |
+ |
+ // Insert first packet of the IDR. |
+ VCMPacket idr_packet = GetDefaultPacket(); |
+ idr_packet.video_header.is_first_packet_in_frame = true; |
+ AddIdr(&idr_packet, 0); |
+ idr_packet.dataPtr = kData; |
+ idr_packet.sizeBytes = sizeof(kData); |
+ EXPECT_EQ(H264SpsPpsTracker::kInsert, |
+ tracker_.CopyAndFixBitstream(&idr_packet)); |
+} |
+ |
+TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandWrongNaluHeader) { |
+ constexpr uint8_t kData[] = {1, 2, 3}; |
+ |
+ // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos. |
+ // Nalu headers manupilated afterwards. |
+ const std::vector<uint8_t> sps( |
+ {0xff, 0x7a, 0x00, 0x0d, 0xbc, 0xd9, 0x41, 0x41, 0xfa, 0x10, 0x00, 0x00, |
+ 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x03, 0xc0, 0xf1, 0x42, 0x99, 0x60}); |
+ const std::vector<uint8_t> pps({0xff, 0xeb, 0xe3, 0xcb, 0x22, 0xc0}); |
+ tracker_.InsertSpsPpsNalus(sps, pps); |
+ |
+ // Insert first packet of the IDR. |
+ VCMPacket idr_packet = GetDefaultPacket(); |
+ idr_packet.video_header.is_first_packet_in_frame = true; |
+ AddIdr(&idr_packet, 0); |
+ idr_packet.dataPtr = kData; |
+ idr_packet.sizeBytes = sizeof(kData); |
+ EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe, |
+ tracker_.CopyAndFixBitstream(&idr_packet)); |
+} |
+ |
+TEST_F(TestH264SpsPpsTracker, SpsPpsOutOfBandIncompleteNalu) { |
+ constexpr uint8_t kData[] = {1, 2, 3}; |
+ |
+ // Generated by "ffmpeg -r 30 -f avfoundation -i "default" out.h264" on macos. |
+ // Nalus damaged afterwards. |
+ const std::vector<uint8_t> sps({0x67, 0x7a, 0x00, 0x0d, 0xbc, 0xd9}); |
+ const std::vector<uint8_t> pps({0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0}); |
+ tracker_.InsertSpsPpsNalus(sps, pps); |
+ |
+ // Insert first packet of the IDR. |
+ VCMPacket idr_packet = GetDefaultPacket(); |
+ idr_packet.video_header.is_first_packet_in_frame = true; |
+ AddIdr(&idr_packet, 0); |
+ idr_packet.dataPtr = kData; |
+ idr_packet.sizeBytes = sizeof(kData); |
+ EXPECT_EQ(H264SpsPpsTracker::kRequestKeyframe, |
+ tracker_.CopyAndFixBitstream(&idr_packet)); |
+} |
+ |
} // namespace video_coding |
} // namespace webrtc |