| OLD | NEW |
| 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 payload = RtpDepacketizer::ParsedPayload(); | 764 payload = RtpDepacketizer::ParsedPayload(); |
| 765 ASSERT_TRUE(depacketizer_->Parse(&payload, packet2, sizeof(packet2))); | 765 ASSERT_TRUE(depacketizer_->Parse(&payload, packet2, sizeof(packet2))); |
| 766 ExpectPacket(&payload, kExpected2, sizeof(kExpected2)); | 766 ExpectPacket(&payload, kExpected2, sizeof(kExpected2)); |
| 767 EXPECT_EQ(kVideoFrameKey, payload.frame_type); | 767 EXPECT_EQ(kVideoFrameKey, payload.frame_type); |
| 768 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); | 768 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); |
| 769 EXPECT_FALSE(payload.type.Video.isFirstPacket); | 769 EXPECT_FALSE(payload.type.Video.isFirstPacket); |
| 770 { | 770 { |
| 771 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; | 771 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; |
| 772 EXPECT_EQ(kH264FuA, h264.packetization_type); | 772 EXPECT_EQ(kH264FuA, h264.packetization_type); |
| 773 EXPECT_EQ(kIdr, h264.nalu_type); | 773 EXPECT_EQ(kIdr, h264.nalu_type); |
| 774 ASSERT_EQ(1u, h264.nalus_length); | 774 // NALU info is only expected for the first FU-A packet. |
| 775 EXPECT_EQ(static_cast<H264::NaluType>(kIdr), h264.nalus[0].type); | 775 EXPECT_EQ(0u, h264.nalus_length); |
| 776 EXPECT_EQ(-1, h264.nalus[0].sps_id); | |
| 777 EXPECT_EQ(-1, h264.nalus[0].pps_id); | |
| 778 } | 776 } |
| 779 | 777 |
| 780 payload = RtpDepacketizer::ParsedPayload(); | 778 payload = RtpDepacketizer::ParsedPayload(); |
| 781 ASSERT_TRUE(depacketizer_->Parse(&payload, packet3, sizeof(packet3))); | 779 ASSERT_TRUE(depacketizer_->Parse(&payload, packet3, sizeof(packet3))); |
| 782 ExpectPacket(&payload, kExpected3, sizeof(kExpected3)); | 780 ExpectPacket(&payload, kExpected3, sizeof(kExpected3)); |
| 783 EXPECT_EQ(kVideoFrameKey, payload.frame_type); | 781 EXPECT_EQ(kVideoFrameKey, payload.frame_type); |
| 784 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); | 782 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); |
| 785 EXPECT_FALSE(payload.type.Video.isFirstPacket); | 783 EXPECT_FALSE(payload.type.Video.isFirstPacket); |
| 786 { | 784 { |
| 787 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; | 785 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; |
| 788 EXPECT_EQ(kH264FuA, h264.packetization_type); | 786 EXPECT_EQ(kH264FuA, h264.packetization_type); |
| 789 EXPECT_EQ(kIdr, h264.nalu_type); | 787 EXPECT_EQ(kIdr, h264.nalu_type); |
| 790 ASSERT_EQ(1u, h264.nalus_length); | 788 // NALU info is only expected for the first FU-A packet. |
| 791 EXPECT_EQ(static_cast<H264::NaluType>(kIdr), h264.nalus[0].type); | 789 ASSERT_EQ(0u, h264.nalus_length); |
| 792 EXPECT_EQ(-1, h264.nalus[0].sps_id); | |
| 793 EXPECT_EQ(-1, h264.nalus[0].pps_id); | |
| 794 } | 790 } |
| 795 } | 791 } |
| 796 | 792 |
| 797 TEST_F(RtpDepacketizerH264Test, TestEmptyPayload) { | 793 TEST_F(RtpDepacketizerH264Test, TestEmptyPayload) { |
| 798 // Using a wild pointer to crash on accesses from inside the depacketizer. | 794 // Using a wild pointer to crash on accesses from inside the depacketizer. |
| 799 uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711); | 795 uint8_t* garbage_ptr = reinterpret_cast<uint8_t*>(0x4711); |
| 800 RtpDepacketizer::ParsedPayload payload; | 796 RtpDepacketizer::ParsedPayload payload; |
| 801 EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0)); | 797 EXPECT_FALSE(depacketizer_->Parse(&payload, garbage_ptr, 0)); |
| 802 } | 798 } |
| 803 | 799 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 818 RtpDepacketizer::ParsedPayload payload; | 814 RtpDepacketizer::ParsedPayload payload; |
| 819 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); | 815 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); |
| 820 } | 816 } |
| 821 | 817 |
| 822 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) { | 818 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) { |
| 823 const uint8_t kPayload[] = {0x27, 0x80, 0x00}; | 819 const uint8_t kPayload[] = {0x27, 0x80, 0x00}; |
| 824 RtpDepacketizer::ParsedPayload payload; | 820 RtpDepacketizer::ParsedPayload payload; |
| 825 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); | 821 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); |
| 826 } | 822 } |
| 827 | 823 |
| 824 TEST_F(RtpDepacketizerH264Test, TestSeiPacket) { |
| 825 const uint8_t kPayload[] = { |
| 826 kSei, // F=0, NRI=0, Type=6. |
| 827 0x03, 0x03, 0x03, 0x03 // Payload. |
| 828 }; |
| 829 RtpDepacketizer::ParsedPayload payload; |
| 830 ASSERT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); |
| 831 const RTPVideoHeaderH264& h264 = payload.type.Video.codecHeader.H264; |
| 832 EXPECT_EQ(kH264SingleNalu, h264.packetization_type); |
| 833 EXPECT_EQ(kSei, h264.nalu_type); |
| 834 ASSERT_EQ(1u, h264.nalus_length); |
| 835 EXPECT_EQ(static_cast<H264::NaluType>(kSei), h264.nalus[0].type); |
| 836 EXPECT_EQ(-1, h264.nalus[0].sps_id); |
| 837 EXPECT_EQ(-1, h264.nalus[0].pps_id); |
| 838 } |
| 839 |
| 828 } // namespace webrtc | 840 } // namespace webrtc |
| OLD | NEW |