Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: webrtc/modules/video_coding/h264_sps_pps_tracker_unittest.cc

Issue 2651593004: Reland of "H264SpsPpsTracker.InsertSpsPpsNalus() should accept Nalus with header. (Closed)
Patch Set: Comment. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/h264_sps_pps_tracker.cc ('k') | webrtc/video/rtp_stream_receiver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9d4d64f97e7bba301b3aa740186ece176b2d2a4c 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,71 @@ 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));
+ if (idr_packet.dataPtr != kData) {
+ // In case CopyAndFixBitStream() prepends SPS/PPS nalus to the packet, it
+ // uses new uint8_t[] to allocate memory. Caller of CopyAndFixBitStream()
+ // needs to take care of freeing the memory.
+ delete[] idr_packet.dataPtr;
+ }
+}
+
+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
« no previous file with comments | « webrtc/modules/video_coding/h264_sps_pps_tracker.cc ('k') | webrtc/video/rtp_stream_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698