From b0be928a50d1fa05a0a65eebbafd801abe2f4e31 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Mon, 2 Dec 2024 09:12:21 -0800 Subject: [PATCH] Cleanup H264 packetization unit tests improve consistency, formatting and style BUG=None Change-Id: Iad382d9a7194b0606c1aa9c7d264dfacf03cde1f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/369462 Reviewed-by: Sergey Silkin Reviewed-by: Danil Chapovalov Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/main@{#43479} --- .../video_rtp_depacketizer_h264_unittest.cc | 303 ++++++++++-------- 1 file changed, 174 insertions(+), 129 deletions(-) diff --git a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc index 8330bf2d6b..5e7820b275 100644 --- a/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc +++ b/modules/rtp_rtcp/source/video_rtp_depacketizer_h264_unittest.cc @@ -33,27 +33,23 @@ using ::testing::Eq; using ::testing::IsEmpty; using ::testing::SizeIs; -enum Nalu { - kSlice = 1, - kIdr = 5, - kSei = 6, - kSps = 7, - kPps = 8, - kStapA = 24, - kFuA = 28 +// clang-format off: split example data on NAL unit boundaries. +constexpr uint8_t kOriginalSps[] = { + H264::kSps, 0x00, 0x00, 0x03, 0x03, + 0xF4, 0x05, 0x03, 0xC7, 0xC0 }; - -constexpr uint8_t kOriginalSps[] = {kSps, 0x00, 0x00, 0x03, 0x03, - 0xF4, 0x05, 0x03, 0xC7, 0xC0}; -constexpr uint8_t kRewrittenSps[] = {kSps, 0x00, 0x00, 0x03, 0x03, - 0xF4, 0x05, 0x03, 0xC7, 0xE0, - 0x1B, 0x41, 0x10, 0x8D, 0x00}; -constexpr uint8_t kIdrOne[] = {kIdr, 0xFF, 0x00, 0x00, 0x04}; -constexpr uint8_t kIdrTwo[] = {kIdr, 0xFF, 0x00, 0x11}; +constexpr uint8_t kRewrittenSps[] = { + H264::kSps, 0x00, 0x00, 0x03, 0x03, + 0xF4, 0x05, 0x03, 0xC7, 0xE0, + 0x1B, 0x41, 0x10, 0x8D, 0x00 +}; +constexpr uint8_t kIdrOne[] = {H264::kIdr, 0xFF, 0x00, 0x00, 0x04}; +constexpr uint8_t kIdrTwo[] = {H264::kIdr, 0xFF, 0x00, 0x11}; +// clang-format on TEST(VideoRtpDepacketizerH264Test, SingleNalu) { - uint8_t packet[2] = {0x05, 0xFF}; // F=0, NRI=0, Type=5 (IDR). - rtc::CopyOnWriteBuffer rtp_payload(packet); + const uint8_t kPayload[] = {H264::kIdr, 0xFF}; // F=0, NRI=0, Type=5 (IDR). + rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -67,14 +63,19 @@ TEST(VideoRtpDepacketizerH264Test, SingleNalu) { const RTPVideoHeaderH264& h264 = absl::get(parsed->video_header.video_type_header); EXPECT_EQ(h264.packetization_type, kH264SingleNalu); - EXPECT_EQ(h264.nalu_type, kIdr); + EXPECT_EQ(h264.nalu_type, H264::kIdr); } TEST(VideoRtpDepacketizerH264Test, SingleNaluSpsWithResolution) { - uint8_t packet[] = {kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, - 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, - 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25}; - rtc::CopyOnWriteBuffer rtp_payload(packet); + // clang-format off: split example data on NAL unit boundaries. + const uint8_t kPayload[] = { + H264::kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, + 0x40, 0x50, 0x05, 0xBA, 0x10, 0x00, + 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, + 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25 + }; + // clang-format on + rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -93,23 +94,26 @@ TEST(VideoRtpDepacketizerH264Test, SingleNaluSpsWithResolution) { } TEST(VideoRtpDepacketizerH264Test, StapAKey) { - // clang-format off const NaluInfo kExpectedNalus[] = { {H264::kSps, 0, -1}, {H264::kPps, 1, 2}, {H264::kIdr, -1, 0} }; - uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24. - // Length, nal header, payload. - 0, 0x18, kExpectedNalus[0].type, - 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 0xBA, - 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x03, - 0x2A, 0xE0, 0xF1, 0x83, 0x25, - 0, 0xD, kExpectedNalus[1].type, - 0x69, 0xFC, 0x0, 0x0, 0x3, 0x0, 0x7, 0xFF, 0xFF, 0xFF, - 0xF6, 0x40, - 0, 0xB, kExpectedNalus[2].type, - 0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, 0x0}; + // clang-format off: split example data on NAL unit boundaries. + const uint8_t kPayload[] = { + H264::kStapA, // F=0, NRI=0, Type=24. + // Length (2 bytes), nal header, payload. + 0x00, 0x18, + kExpectedNalus[0].type, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, + 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x2A, 0xE0, + 0xF1, 0x83, 0x25, + 0x00, 0xD, + kExpectedNalus[1].type, 0x69, 0xFC, 0x0, 0x0, 0x3, 0x0, 0x7, 0xFF, 0xFF, + 0xFF, 0xF6, 0x40, + 0x00, 0xB, + kExpectedNalus[2].type, 0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, + 0x0 + }; // clang-format on - rtc::CopyOnWriteBuffer rtp_payload(packet); + rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -122,21 +126,27 @@ TEST(VideoRtpDepacketizerH264Test, StapAKey) { EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); const auto& h264 = absl::get(parsed->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264StapA); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264StapA); // NALU type for aggregated packets is the type of the first packet only. - EXPECT_EQ(h264.nalu_type, kSps); + EXPECT_EQ(h264.nalu_type, H264::kSps); EXPECT_THAT(h264.nalus, ElementsAreArray(kExpectedNalus)); } TEST(VideoRtpDepacketizerH264Test, StapANaluSpsWithResolution) { - uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24. - // Length (2 bytes), nal header, payload. - 0x00, 0x19, kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, - 0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, - 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25, 0x80, - 0x00, 0x03, kIdr, 0xFF, 0x00, 0x00, 0x04, kIdr, 0xFF, - 0x00, 0x11}; - rtc::CopyOnWriteBuffer rtp_payload(packet); + // clang-format off: split example data on NAL unit boundaries. + const uint8_t kPayload[] = { + H264::kStapA, // F=0, NRI=0, Type=24. + // Length (2 bytes), nal header, payload. + 0x00, 0x19, + H264::kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 0xBA, 0x10, + 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, + 0x25, 0x80, 0x00, 0x03, + H264::kIdr, 0xFF, 0x00, + 0x00, 0x04, + H264::kIdr, 0xFF, 0x00, 0x11 + }; + // clang-format on + rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -151,17 +161,33 @@ TEST(VideoRtpDepacketizerH264Test, StapANaluSpsWithResolution) { EXPECT_EQ(parsed->video_header.height, 720u); const auto& h264 = absl::get(parsed->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264StapA); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264StapA); } TEST(VideoRtpDepacketizerH264Test, EmptyStapARejected) { - uint8_t lone_empty_packet[] = {kStapA, 0x00, 0x00}; - uint8_t leading_empty_packet[] = {kStapA, 0x00, 0x00, 0x00, 0x04, - kIdr, 0xFF, 0x00, 0x11}; - uint8_t middle_empty_packet[] = {kStapA, 0x00, 0x03, kIdr, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x04, kIdr, 0xFF, 0x00, 0x11}; - uint8_t trailing_empty_packet[] = {kStapA, 0x00, 0x03, kIdr, - 0xFF, 0x00, 0x00, 0x00}; + // clang-format off: split example data on NAL unit boundaries. + uint8_t lone_empty_packet[] = { + H264::kStapA, 0x00, 0x00 + }; + uint8_t leading_empty_packet[] = { + H264::kStapA, + 0x00, 0x00, // Empty STAP-A is invalid. + 0x00, 0x04, + H264::kIdr, 0xFF, 0x00, 0x11 + }; + uint8_t middle_empty_packet[] = { + H264::kStapA, + 0x00, 0x03, + H264::kIdr, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x04, + H264::kIdr, 0xFF, 0x00, 0x11 + }; + uint8_t trailing_empty_packet[] = { + H264::kStapA, + 0x00, 0x03, + H264::kIdr, 0xFF, 0x00, 0x00, 0x00 + }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; EXPECT_FALSE(depacketizer.Parse(rtc::CopyOnWriteBuffer(lone_empty_packet))); @@ -176,7 +202,7 @@ TEST(VideoRtpDepacketizerH264Test, DepacketizeWithRewriting) { rtc::CopyOnWriteBuffer in_buffer; rtc::Buffer out_buffer; - uint8_t kHeader[2] = {kStapA}; + uint8_t kHeader[] = {H264::kStapA, 0x00}; in_buffer.AppendData(kHeader, 1); out_buffer.AppendData(kHeader, 1); @@ -211,7 +237,7 @@ TEST(VideoRtpDepacketizerH264Test, DepacketizeWithDoubleRewriting) { rtc::CopyOnWriteBuffer in_buffer; rtc::Buffer out_buffer; - uint8_t kHeader[2] = {kStapA}; + uint8_t kHeader[] = {H264::kStapA, 0x00}; in_buffer.AppendData(kHeader, 1); out_buffer.AppendData(kHeader, 1); @@ -253,11 +279,19 @@ TEST(VideoRtpDepacketizerH264Test, DepacketizeWithDoubleRewriting) { } TEST(VideoRtpDepacketizerH264Test, StapADelta) { - uint8_t packet[16] = {kStapA, // F=0, NRI=0, Type=24. - // Length, nal header, payload. - 0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF, 0x00, 0, - 0x04, kSlice, 0xFF, 0x00, 0x11}; - rtc::CopyOnWriteBuffer rtp_payload(packet); + // clang-format off: split example data on NAL unit boundaries. + const uint8_t kPayload[] = { + H264::kStapA, // F=0, NRI=0, Type=24. + // Length (2 bytes), nal header, payload. + 0x00, 0x02, + H264::kSlice, 0xFF, + 0x00, 0x03, + H264::kSlice, 0xFF, 0x00, + 0x00, 0x04, + H264::kSlice, 0xFF, 0x00, 0x11 + }; + // clang-format on + rtc::CopyOnWriteBuffer rtp_payload(kPayload); VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -272,39 +306,40 @@ TEST(VideoRtpDepacketizerH264Test, StapADelta) { EXPECT_TRUE(parsed->video_header.is_first_packet_in_frame); const RTPVideoHeaderH264& h264 = absl::get(parsed->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264StapA); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264StapA); // NALU type for aggregated packets is the type of the first packet only. - EXPECT_EQ(h264.nalu_type, kSlice); + EXPECT_EQ(h264.nalu_type, H264::kSlice); } TEST(VideoRtpDepacketizerH264Test, FuA) { - // clang-format off - uint8_t packet1[] = { - kFuA, // F=0, NRI=0, Type=28. - kH264SBit | kIdr, // FU header. - 0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, 0x0 // Payload. + // clang-format off: split example data on NAL unit boundaries. + const uint8_t kPayload1[] = { + H264::kFuA, // F=0, NRI=0, Type=28. + kH264SBit | H264::kIdr, // FU header. + 0x85, 0xB8, 0x00, 0x04, 0x00, 0x00, 0x13, 0x93, 0x12, 0x00 // Payload. }; - // clang-format on - const uint8_t kExpected1[] = {kIdr, 0x85, 0xB8, 0x0, 0x4, 0x0, - 0x0, 0x13, 0x93, 0x12, 0x0}; + const uint8_t kExpected1[] = { + H264::kIdr, 0x85, 0xB8, 0x00, 0x04, 0x00, + 0x00, 0x13, 0x93, 0x12, 0x00}; - uint8_t packet2[] = { - kFuA, // F=0, NRI=0, Type=28. - kIdr, // FU header. - 0x02 // Payload. + const uint8_t kPayload2[] = { + H264::kFuA, // F=0, NRI=0, Type=28. + H264::kIdr, // FU header. + 0x02 // Payload. }; const uint8_t kExpected2[] = {0x02}; - uint8_t packet3[] = { - kFuA, // F=0, NRI=0, Type=28. - kH264EBit | kIdr, // FU header. - 0x03 // Payload. + const uint8_t kPayload3[] = { + H264::kFuA, // F=0, NRI=0, Type=28. + kH264EBit | H264::kIdr, // FU header. + 0x03 // Payload. }; const uint8_t kExpected3[] = {0x03}; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed1 = - depacketizer.Parse(rtc::CopyOnWriteBuffer(packet1)); + depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload1)); ASSERT_TRUE(parsed1); // We expect that the first packet is one byte shorter since the FU-A header // has been replaced by the original nal header. @@ -317,17 +352,17 @@ TEST(VideoRtpDepacketizerH264Test, FuA) { { const RTPVideoHeaderH264& h264 = absl::get(parsed1->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264FuA); - EXPECT_EQ(h264.nalu_type, kIdr); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264FuA); + EXPECT_EQ(h264.nalu_type, H264::kIdr); ASSERT_THAT(h264.nalus, SizeIs(1)); - EXPECT_EQ(h264.nalus[0].type, static_cast(kIdr)); + EXPECT_EQ(h264.nalus[0].type, H264::kIdr); EXPECT_EQ(h264.nalus[0].sps_id, -1); EXPECT_EQ(h264.nalus[0].pps_id, 0); } // Following packets will be 2 bytes shorter since they will only be appended // onto the first packet. - auto parsed2 = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet2)); + auto parsed2 = depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload2)); EXPECT_THAT(rtc::MakeArrayView(parsed2->video_payload.cdata(), parsed2->video_payload.size()), ElementsAreArray(kExpected2)); @@ -336,13 +371,13 @@ TEST(VideoRtpDepacketizerH264Test, FuA) { { const RTPVideoHeaderH264& h264 = absl::get(parsed2->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264FuA); - EXPECT_EQ(h264.nalu_type, kIdr); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264FuA); + EXPECT_EQ(h264.nalu_type, H264::kIdr); // NALU info is only expected for the first FU-A packet. EXPECT_THAT(h264.nalus, IsEmpty()); } - auto parsed3 = depacketizer.Parse(rtc::CopyOnWriteBuffer(packet3)); + auto parsed3 = depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload3)); EXPECT_THAT(rtc::MakeArrayView(parsed3->video_payload.cdata(), parsed3->video_payload.size()), ElementsAreArray(kExpected3)); @@ -351,8 +386,8 @@ TEST(VideoRtpDepacketizerH264Test, FuA) { { const RTPVideoHeaderH264& h264 = absl::get(parsed3->video_header.video_type_header); - EXPECT_EQ(h264.packetization_type, kH264FuA); - EXPECT_EQ(h264.nalu_type, kIdr); + EXPECT_EQ(h264.packetization_type, H264PacketizationTypes::kH264FuA); + EXPECT_EQ(h264.nalu_type, H264::kIdr); // NALU info is only expected for the first FU-A packet. EXPECT_THAT(h264.nalus, IsEmpty()); } @@ -390,7 +425,7 @@ TEST(VideoRtpDepacketizerH264Test, TruncationJustAfterSingleStapANalu) { TEST(VideoRtpDepacketizerH264Test, SeiPacket) { const uint8_t kPayload[] = { - kSei, // F=0, NRI=0, Type=6. + H264::kSei, // F=0, NRI=0, Type=6. 0x03, 0x03, 0x03, 0x03 // Payload. }; VideoRtpDepacketizerH264 depacketizer; @@ -400,9 +435,9 @@ TEST(VideoRtpDepacketizerH264Test, SeiPacket) { absl::get(parsed->video_header.video_type_header); EXPECT_EQ(parsed->video_header.frame_type, VideoFrameType::kVideoFrameDelta); EXPECT_EQ(h264.packetization_type, kH264SingleNalu); - EXPECT_EQ(h264.nalu_type, kSei); + EXPECT_EQ(h264.nalu_type, H264::kSei); ASSERT_THAT(h264.nalus, SizeIs(1)); - EXPECT_EQ(h264.nalus[0].type, static_cast(kSei)); + EXPECT_EQ(h264.nalus[0].type, H264::kSei); EXPECT_EQ(h264.nalus[0].sps_id, -1); EXPECT_EQ(h264.nalus[0].pps_id, -1); } @@ -415,7 +450,7 @@ TEST(VideoRtpDepacketizerH264Test, ShortSpsPacket) { TEST(VideoRtpDepacketizerH264Test, BadSps) { const uint8_t kPayload[] = { - kSps, 0x42, 0x41, 0x2a, 0xd3, 0x93, 0xd3, 0x3b // Payload. + H264::kSps, 0x42, 0x41, 0x2a, 0xd3, 0x93, 0xd3, 0x3b // Payload. }; VideoRtpDepacketizerH264 depacketizer; EXPECT_FALSE(depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload))); @@ -423,7 +458,7 @@ TEST(VideoRtpDepacketizerH264Test, BadSps) { TEST(VideoRtpDepacketizerH264Test, BadPps) { const uint8_t kPayload[] = { - kPps, + H264::kPps, 0x00 // Payload. }; VideoRtpDepacketizerH264 depacketizer; @@ -432,7 +467,7 @@ TEST(VideoRtpDepacketizerH264Test, BadPps) { TEST(VideoRtpDepacketizerH264Test, BadSlice) { const uint8_t kPayload[] = { - kIdr, + H264::kIdr, 0xc0 // Payload. }; VideoRtpDepacketizerH264 depacketizer; @@ -441,39 +476,47 @@ TEST(VideoRtpDepacketizerH264Test, BadSlice) { TEST(VideoRtpDepacketizerH264Test, StapASpsPpsMultiSlice) { // A STAP-A containing a black 320x192 key frame with multiple slices. + // clang-format off: split example data on NAL unit boundaries. const uint8_t kPayload[] = { - // clang-format off - 0x67, 0x42, 0xc0, 0x15, 0x8c, 0x68, 0x14, 0x19, // STAP-A, SPS. - 0x79, 0xe0, 0x1e, 0x11, 0x08, 0xd4, 0x00, 0x04, 0x68, 0xce, 0x3c, 0x80, - 0x00, 0x2e, // PPS. + H264::kStapA, // F=0, NRI=0, Type=24. + 0x00, 0x10, + 0x67, 0x42, 0xc0, 0x15, 0x8c, 0x68, 0x14, 0x19, // SPS. + 0x79, 0xe0, 0x1e, 0x11, 0x08, 0xd4, 0x00, 0x04, + 0x00, 0x06, + 0x68, 0xce, 0x3c, 0x80, 0x00, 0x2e, // PPS. // Slices. + 0x00, 0x30, 0x65, 0xb8, 0x00, 0x04, 0x08, 0x79, 0x31, 0x40, 0x00, 0x42, 0xae, 0x4d, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xc9, 0xd6, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xbc, 0x00, 0x2f, + 0x00, 0x2f, 0x65, 0x05, 0x2e, 0x00, 0x01, 0x02, 0x1e, 0x4c, 0x50, 0x00, 0x10, 0xab, 0x93, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x75, 0xba, 0xeb, 0xae, 0xba, - 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xaf, 0x00, - 0x30, 0x65, 0x02, 0x8b, 0x80, 0x00, 0x40, 0x87, 0x93, 0x14, 0x00, 0x04, - 0x2a, 0xe4, 0xdc, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9d, 0x6e, 0xba, 0xeb, - 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, - 0xc0, 0x00, 0x30, 0x65, 0x03, 0xcb, 0x80, 0x00, 0x40, 0x87, 0x93, 0x14, - 0x00, 0x04, 0x2a, 0xe4, 0xdc, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, - 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9d, 0x6e, - 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, - 0xba, 0xeb, 0xc0, 0x00, 0x30, 0x65, 0x01, 0x42, 0xe0, 0x00, 0x10, 0x21, - 0xe4, 0xc5, 0x00, 0x01, 0x0a, 0xb9, 0x37, 0x27, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x5b, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, - 0xba, 0xeb, 0xae, 0xba, 0xf0, 0x00, 0x30, 0x65, 0x01, 0x92, 0xe0, 0x00, - 0x10, 0x21, 0xe4, 0xc5, 0x00, 0x01, 0x0a, 0xb9, 0x37, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x5b, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, - 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xf0 - // clang-format on + 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xaf, + 0x00, 0x30, + 0x65, 0x02, 0x8b, 0x80, 0x00, 0x40, 0x87, 0x93, 0x14, 0x00, 0x04, 0x2a, + 0xe4, 0xdc, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, + 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9d, 0x6e, 0xba, 0xeb, 0xae, + 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xc0, + 0x00, 0x30, + 0x65, 0x03, 0xcb, 0x80, 0x00, 0x40, 0x87, 0x93, 0x14, 0x00, 0x04, 0x2a, + 0xe4, 0xdc, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, + 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9d, 0x6e, 0xba, 0xeb, 0xae, + 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xc0, + 0x00, 0x30, + 0x65, 0x01, 0x42, 0xe0, 0x00, 0x10, 0x21, 0xe4, 0xc5, 0x00, 0x01, 0x0a, + 0xb9, 0x37, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x5b, 0xae, 0xba, 0xeb, + 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xf0, + 0x00, 0x30, + 0x65, 0x01, 0x92, 0xe0, 0x00, 0x10, 0x21, 0xe4, 0xc5, 0x00, 0x01, 0x0a, + 0xb9, 0x37, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x5b, 0xae, 0xba, 0xeb, + 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xeb, 0xae, 0xba, 0xf0 }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -485,16 +528,16 @@ TEST(VideoRtpDepacketizerH264Test, StapASpsPpsMultiSlice) { TEST(VideoRtpDepacketizerH264Test, SecondSliceIdrNalu) { // First few bytes of a second slice of an IDR nalu with // first_mb_in_slice = 480. + // clang-format off: split example data on NAL unit boundaries. const uint8_t kPayload[] = { - // clang-format off 0x65, 0x00, 0xf0, 0x88, 0x82, 0x01, 0x3b, 0xff, 0xdf, 0xfe, 0x0b, 0xbb, 0xfc, 0xb4, 0x30, 0xd1, 0x00, 0xef, 0xfd, 0xef, 0x0e, 0x79, 0x8b, 0x74, 0x9b, 0x44, 0xf3, 0xb8, 0x65, 0x8f, 0xa1, 0x92, 0x30, 0xf9, 0x40, 0x06, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x18, 0x87, 0x4f, 0x6a, 0xfe, 0x60, 0x03, 0x9f, 0xfe, 0xd8, 0x8b, 0xa6, 0x67, 0x31 - // clang-format on }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -504,11 +547,11 @@ TEST(VideoRtpDepacketizerH264Test, SecondSliceIdrNalu) { } TEST(VideoRtpDepacketizerH264Test, AudSetsFirstPacketInFrame) { + // clang-format off: split example data on NAL unit boundaries. const uint8_t kPayload[] = { - // clang-format off - 0x09, 0x10 // AUD. - // clang-format on + H264::kAud, 0x10 }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -518,10 +561,12 @@ TEST(VideoRtpDepacketizerH264Test, AudSetsFirstPacketInFrame) { } TEST(VideoRtpDepacketizerH264Test, PpsSetsFirstPacketInFrame) { + // clang-format off: split example data on NAL unit boundaries. const uint8_t kPayload[] = { - 0x08, 0x69, 0xFC, 0x0, 0x0, 0x3, 0x0, - 0x7, 0xFF, 0xFF, 0xFF, 0xF6, 0x40 // PPS. + H264::kPps, 0x69, 0xFC, 0x00, 0x00, 0x03, 0x00, + 0x07, 0xFF, 0xFF, 0xFF, 0xF6, 0x40 }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -531,9 +576,11 @@ TEST(VideoRtpDepacketizerH264Test, PpsSetsFirstPacketInFrame) { } TEST(VideoRtpDepacketizerH264Test, SeiSetsFirstPacketInFrame) { + // clang-format off: split example data on NAL unit boundaries. const uint8_t kPayload[] = { - 0x06, 0x05, 0x04, 0xDE, 0xAD, 0xBE, 0xEF, 0x80 // SEI. + H264::kSei, 0x05, 0x04, 0xDE, 0xAD, 0xBE, 0xEF, 0x80 }; + // clang-format on VideoRtpDepacketizerH264 depacketizer; std::optional parsed = @@ -543,9 +590,7 @@ TEST(VideoRtpDepacketizerH264Test, SeiSetsFirstPacketInFrame) { } TEST(VideoRtpDepacketizerH264Test, EmptyNaluPayload) { - const uint8_t kPayload[] = { - 0x10, // End of sequence. - }; + const uint8_t kPayload[] = {H264::kEndOfSequence}; VideoRtpDepacketizerH264 depacketizer; std::optional parsed = depacketizer.Parse(rtc::CopyOnWriteBuffer(kPayload));