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

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

Issue 2039353002: Fix issue with parsing of incorrect (empty) Stap-A H264 NAL units. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet))); 562 ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
563 ExpectPacket(&payload, packet, sizeof(packet)); 563 ExpectPacket(&payload, packet, sizeof(packet));
564 EXPECT_EQ(kVideoFrameKey, payload.frame_type); 564 EXPECT_EQ(kVideoFrameKey, payload.frame_type);
565 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec); 565 EXPECT_EQ(kRtpVideoH264, payload.type.Video.codec);
566 EXPECT_TRUE(payload.type.Video.isFirstPacket); 566 EXPECT_TRUE(payload.type.Video.isFirstPacket);
567 EXPECT_EQ(kH264StapA, payload.type.Video.codecHeader.H264.packetization_type); 567 EXPECT_EQ(kH264StapA, payload.type.Video.codecHeader.H264.packetization_type);
568 EXPECT_EQ(1280u, payload.type.Video.width); 568 EXPECT_EQ(1280u, payload.type.Video.width);
569 EXPECT_EQ(720u, payload.type.Video.height); 569 EXPECT_EQ(720u, payload.type.Video.height);
570 } 570 }
571 571
572 TEST_F(RtpDepacketizerH264Test, TestEmptyStapARejected) {
573 uint8_t lone_empty_packet[] = {kStapA, 0x00, 0x00};
574
575 uint8_t leading_empty_packet[] = {kStapA, 0x00, 0x00, 0x00, 0x04,
576 kIdr, 0xFF, 0x00, 0x11};
577
578 uint8_t middle_empty_packet[] = {kStapA, 0x00, 0x03, kIdr, 0xFF, 0x00, 0x00,
579 0x00, 0x00, 0x04, kIdr, 0xFF, 0x00, 0x11};
580
581 uint8_t trailing_empty_packet[] = {kStapA, 0x00, 0x03, kIdr,
582 0xFF, 0x00, 0x00, 0x00};
583
584 RtpDepacketizer::ParsedPayload payload;
585
586 EXPECT_FALSE(depacketizer_->Parse(&payload, lone_empty_packet,
587 sizeof(lone_empty_packet)));
588 EXPECT_FALSE(depacketizer_->Parse(&payload, leading_empty_packet,
589 sizeof(leading_empty_packet)));
590 EXPECT_FALSE(depacketizer_->Parse(&payload, middle_empty_packet,
591 sizeof(middle_empty_packet)));
592 EXPECT_FALSE(depacketizer_->Parse(&payload, trailing_empty_packet,
593 sizeof(trailing_empty_packet)));
594 }
595
572 TEST_F(RtpDepacketizerH264Test, DepacketizeWithRewriting) { 596 TEST_F(RtpDepacketizerH264Test, DepacketizeWithRewriting) {
573 rtc::Buffer in_buffer; 597 rtc::Buffer in_buffer;
574 rtc::Buffer out_buffer; 598 rtc::Buffer out_buffer;
575 599
576 uint8_t kHeader[2] = {kStapA}; 600 uint8_t kHeader[2] = {kStapA};
577 in_buffer.AppendData(kHeader, 1); 601 in_buffer.AppendData(kHeader, 1);
578 out_buffer.AppendData(kHeader, 1); 602 out_buffer.AppendData(kHeader, 1);
579 603
580 ByteWriter<uint16_t>::WriteBigEndian(kHeader, sizeof(kOriginalSps)); 604 ByteWriter<uint16_t>::WriteBigEndian(kHeader, sizeof(kOriginalSps));
581 in_buffer.AppendData(kHeader, 2); 605 in_buffer.AppendData(kHeader, 2);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); 776 EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
753 } 777 }
754 778
755 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) { 779 TEST_F(RtpDepacketizerH264Test, TestShortSpsPacket) {
756 const uint8_t kPayload[] = {0x27, 0x80, 0x00}; 780 const uint8_t kPayload[] = {0x27, 0x80, 0x00};
757 RtpDepacketizer::ParsedPayload payload; 781 RtpDepacketizer::ParsedPayload payload;
758 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload))); 782 EXPECT_TRUE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
759 } 783 }
760 784
761 } // 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