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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc

Issue 2265023002: Revert of Add pps id and sps id parsing to the h.264 depacketizer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 524 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
525 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 525 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
526 EXPECT_TRUE(payload.type.Video.isFirstPacket); 526 EXPECT_TRUE(payload.type.Video.isFirstPacket);
527 EXPECT_EQ(kH264SingleNalu, 527 EXPECT_EQ(kH264SingleNalu,
528 payload.type.Video.codecHeader.H264.packetization_type); 528 payload.type.Video.codecHeader.H264.packetization_type);
529 EXPECT_EQ(1280u, payload.type.Video.width); 529 EXPECT_EQ(1280u, payload.type.Video.width);
530 EXPECT_EQ(720u, payload.type.Video.height); 530 EXPECT_EQ(720u, payload.type.Video.height);
531 } 531 }
532 532
533 TEST_F(RtpDepacketizerH264Test, TestStapAKey) { 533 TEST_F(RtpDepacketizerH264Test, TestStapAKey) {
534 // clang-format off 534 uint8_t packet[16] = {kStapA, // F=0, NRI=0, Type=24.
535 const NaluInfo kExpectedNalus[] = { {H264::kSps, 0, -1}, 535 // Length, nal header, payload.
536 {H264::kPps, 1, 2}, 536 0, 0x02, kSps, 0xFF,
537 {H264::kIdr, -1, 0} }; 537 0, 0x03, kPps, 0xFF, 0x00,
538 uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24. 538 0, 0x04, kIdr, 0xFF, 0x00, 0x11};
539 // Length, nal header, payload. 539 RtpDepacketizer::ParsedPayload payload;
540 0, 0x18, kExpectedNalus[0].type,
541 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, 0xBA,
542 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, 0x00, 0x03,
543 0x2A, 0xE0, 0xF1, 0x83, 0x25,
544 0, 0xD, kExpectedNalus[1].type,
545 0x69, 0xFC, 0x0, 0x0, 0x3, 0x0, 0x7, 0xFF, 0xFF, 0xFF,
546 0xF6, 0x40,
547 0, 0xB, kExpectedNalus[2].type,
548 0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, 0x0};
549 // clang-format on
550 540
551 RtpDepacketizer::ParsedPayload payload;
552 ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); 541 ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
553 ExpectPacket(&payload, packet, sizeof(packet)); 542 ExpectPacket(&payload, packet, sizeof(packet));
554 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 543 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
555 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 544 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
556 EXPECT_TRUE(payload.type.Video.isFirstPacket); 545 EXPECT_TRUE(payload.type.Video.isFirstPacket);
557 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; 546 EXPECT_EQ(kH264StapA, payload.type.Video.codecHeader.H264.packetization_type);
558 EXPECT_EQ(kH264StapA, h264.packetization_type);
559 // NALU type for aggregated packets is the type of the first packet only. 547 // NALU type for aggregated packets is the type of the first packet only.
560 EXPECT_EQ(kSps, h264.nalu_type); 548 EXPECT_EQ(kSps, payload.type.Video.codecHeader.H264.nalu_type);
561 ASSERT_EQ(3u, h264.nalus_length);
562 for (size_t i = 0; i < h264.nalus_length; ++i) {
563 EXPECT_EQ(kExpectedNalus[i].type, h264.nalus[i].type)
564 << "Failed parsing nalu " << i;
565 EXPECT_EQ(kExpectedNalus[i].sps_id, h264.nalus[i].sps_id)
566 << "Failed parsing nalu " << i;
567 EXPECT_EQ(kExpectedNalus[i].pps_id, h264.nalus[i].pps_id)
568 << "Failed parsing nalu " << i;
569 }
570 } 549 }
571 550
572 TEST_F(RtpDepacketizerH264Test, TestStapANaluSpsWithResolution) { 551 TEST_F(RtpDepacketizerH264Test, TestStapANaluSpsWithResolution) {
573 uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24. 552 uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24.
574 // Length (2 bytes), nal header, payload. 553 // Length (2 bytes), nal header, payload.
575 0x00, 0x19, kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 554 0x00, 0x19, kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40,
576 0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 555 0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0,
577 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25, 0x80, 556 0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25, 0x80,
578 0x00, 0x03, kIdr, 0xFF, 0x00, 0x00, 0x04, kIdr, 0xFF, 557 0x00, 0x03, kIdr, 0xFF, 0x00, 0x00, 0x04, kIdr, 0xFF,
579 0x00, 0x11}; 558 0x00, 0x11};
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 ExpectPacket(&payload, packet, sizeof(packet)); 690 ExpectPacket(&payload, packet, sizeof(packet));
712 EXPECT_EQ(kVideoFrameDelta, payload.frame_type); 691 EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
713 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 692 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
714 EXPECT_TRUE(payload.type.Video.isFirstPacket); 693 EXPECT_TRUE(payload.type.Video.isFirstPacket);
715 EXPECT_EQ(kH264StapA, payload.type.Video.codecHeader.H264.packetization_type); 694 EXPECT_EQ(kH264StapA, payload.type.Video.codecHeader.H264.packetization_type);
716 // NALU type for aggregated packets is the type of the first packet only. 695 // NALU type for aggregated packets is the type of the first packet only.
717 EXPECT_EQ(kSlice, payload.type.Video.codecHeader.H264.nalu_type); 696 EXPECT_EQ(kSlice, payload.type.Video.codecHeader.H264.nalu_type);
718 } 697 }
719 698
720 TEST_F(RtpDepacketizerH264Test, TestFuA) { 699 TEST_F(RtpDepacketizerH264Test, TestFuA) {
721 // clang-format off 700 uint8_t packet1[3] = {
722 uint8_t packet1[] = {
723 kFuA, // F=0, NRI=0, Type=28. 701 kFuA, // F=0, NRI=0, Type=28.
724 kSBit | kIdr, // FU header. 702 kSBit | kIdr, // FU header.
725 0x85, 0xB8, 0x0, 0x4, 0x0, 0x0, 0x13, 0x93, 0x12, 0x0 // Payload. 703 0x01 // Payload.
726 }; 704 };
727 // clang-format on 705 const uint8_t kExpected1[2] = {kIdr, 0x01};
728 const uint8_t kExpected1[] = {kIdr, 0x85, 0xB8, 0x0, 0x4, 0x0,
729 0x0, 0x13, 0x93, 0x12, 0x0};
730 706
731 uint8_t packet2[] = { 707 uint8_t packet2[3] = {
732 kFuA, // F=0, NRI=0, Type=28. 708 kFuA, // F=0, NRI=0, Type=28.
733 kIdr, // FU header. 709 kIdr, // FU header.
734 0x02 // Payload. 710 0x02 // Payload.
735 }; 711 };
736 const uint8_t kExpected2[] = {0x02}; 712 const uint8_t kExpected2[1] = {0x02};
737 713
738 uint8_t packet3[] = { 714 uint8_t packet3[3] = {
739 kFuA, // F=0, NRI=0, Type=28. 715 kFuA, // F=0, NRI=0, Type=28.
740 kEBit | kIdr, // FU header. 716 kEBit | kIdr, // FU header.
741 0x03 // Payload. 717 0x03 // Payload.
742 }; 718 };
743 const uint8_t kExpected3[] = {0x03}; 719 const uint8_t kExpected3[1] = {0x03};
744 720
745 RtpDepacketizer::ParsedPayload payload; 721 RtpDepacketizer::ParsedPayload payload;
746 722
747 // We expect that the first packet is one byte shorter since the FU-A header 723 // We expect that the first packet is one byte shorter since the FU-A header
748 // has been replaced by the original nal header. 724 // has been replaced by the original nal header.
749 ASSERT_TRUE(depacketizer_->Parse(&payload, packet1, sizeof(packet1))); 725 ASSERT_TRUE(depacketizer_->Parse(&payload, packet1, sizeof(packet1)));
750 ExpectPacket(&payload, kExpected1, sizeof(kExpected1)); 726 ExpectPacket(&payload, kExpected1, sizeof(kExpected1));
751 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 727 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
752 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 728 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
753 EXPECT_TRUE(payload.type.Video.isFirstPacket); 729 EXPECT_TRUE(payload.type.Video.isFirstPacket);
754 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; 730 EXPECT_EQ(kH264FuA, payload.type.Video.codecHeader.H264.packetization_type);
755 EXPECT_EQ(kH264FuA, h264.packetization_type); 731 EXPECT_EQ(kIdr, payload.type.Video.codecHeader.H264.nalu_type);
756 EXPECT_EQ(kIdr, h264.nalu_type);
757 ASSERT_EQ(1u, h264.nalus_length);
758 EXPECT_EQ(static_cast<H264::NaluType>(kIdr), h264.nalus[0].type);
759 EXPECT_EQ(-1, h264.nalus[0].sps_id);
760 EXPECT_EQ(0, h264.nalus[0].pps_id);
761 732
762 // Following packets will be 2 bytes shorter since they will only be appended 733 // Following packets will be 2 bytes shorter since they will only be appended
763 // onto the first packet. 734 // onto the first packet.
764 payload = RtpDepacketizer::ParsedPayload(); 735 payload = RtpDepacketizer::ParsedPayload();
765 ASSERT_TRUE(depacketizer_->Parse(&payload, packet2, sizeof(packet2))); 736 ASSERT_TRUE(depacketizer_->Parse(&payload, packet2, sizeof(packet2)));
766 ExpectPacket(&payload, kExpected2, sizeof(kExpected2)); 737 ExpectPacket(&payload, kExpected2, sizeof(kExpected2));
767 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 738 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
768 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 739 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
769 EXPECT_FALSE(payload.type.Video.isFirstPacket); 740 EXPECT_FALSE(payload.type.Video.isFirstPacket);
770 { 741 EXPECT_EQ(kH264FuA, payload.type.Video.codecHeader.H264.packetization_type);
771 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; 742 EXPECT_EQ(kIdr, payload.type.Video.codecHeader.H264.nalu_type);
772 EXPECT_EQ(kH264FuA, h264.packetization_type);
773 EXPECT_EQ(kIdr, h264.nalu_type);
774 ASSERT_EQ(1u, h264.nalus_length);
775 EXPECT_EQ(static_cast<H264::NaluType>(kIdr), h264.nalus[0].type);
776 EXPECT_EQ(-1, h264.nalus[0].sps_id);
777 EXPECT_EQ(-1, h264.nalus[0].pps_id);
778 }
779 743
780 payload = RtpDepacketizer::ParsedPayload(); 744 payload = RtpDepacketizer::ParsedPayload();
781 ASSERT_TRUE(depacketizer_->Parse(&payload, packet3, sizeof(packet3))); 745 ASSERT_TRUE(depacketizer_->Parse(&payload, packet3, sizeof(packet3)));
782 ExpectPacket(&payload, kExpected3, sizeof(kExpected3)); 746 ExpectPacket(&payload, kExpected3, sizeof(kExpected3));
783 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 747 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
784 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 748 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
785 EXPECT_FALSE(payload.type.Video.isFirstPacket); 749 EXPECT_FALSE(payload.type.Video.isFirstPacket);
786 { 750 EXPECT_EQ(kH264FuA, payload.type.Video.codecHeader.H264.packetization_type);
787 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; 751 EXPECT_EQ(kIdr, payload.type.Video.codecHeader.H264.nalu_type);
788 EXPECT_EQ(kH264FuA, h264.packetization_type);
789 EXPECT_EQ(kIdr, h264.nalu_type);
790 ASSERT_EQ(1u, h264.nalus_length);
791 EXPECT_EQ(static_cast<H264::NaluType>(kIdr), h264.nalus[0].type);
792 EXPECT_EQ(-1, h264.nalus[0].sps_id);
793 EXPECT_EQ(-1, h264.nalus[0].pps_id);
794 }
795 } 752 }
796 753
797 TEST_F(RtpDepacketizerH264Test, TestEmptyPayload) { 754 TEST_F(RtpDepacketizerH264Test, TestEmptyPayload) {
798 // Using a wild pointer to crash on accesses from inside the depacketizer. 755 // Using a wild pointer to crash on accesses from inside the depacketizer.
799 uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711); 756 uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711);
800 RtpDepacketizer::ParsedPayload payload; 757 RtpDepacketizer::ParsedPayload payload;
801 EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0)); 758 EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0));
802 } 759 }
803 760
804 TEST_F(RtpDepacketizerH264Test, TestTruncatedFuaNalu) { 761 TEST_F(RtpDepacketizerH264Test, TestTruncatedFuaNalu) {
(...skipping 14 matching lines...) Expand all
819 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); 776 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
820 } 777 }
821 778
822 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) { 779 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) {
823 const uint8_t kPayload[] = {0x27, 0x80, 0x00}; 780 const uint8_t kPayload[] = {0x27, 0x80, 0x00};
824 RtpDepacketizer::ParsedPayload payload; 781 RtpDepacketizer::ParsedPayload payload;
825 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); 782 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
826 } 783 }
827 784
828 } // namespace webrtc 785 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_format_h264.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698