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

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

Issue 2276473002: Rename FrameGenerator -> UlpfecPacketGenerator. (pt. 6b) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@headers-pt5-add_flexfec
Patch Set: gmock/test paths. Created 4 years, 2 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/fec_test_helper.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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include <list> 11 #include <list>
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/test/gtest.h"
16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
17 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" 16 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h"
18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" 17 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
19 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h" 18 #include "webrtc/modules/rtp_rtcp/source/producer_fec.h"
19 #include "webrtc/test/gtest.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 namespace { 23 namespace {
24 constexpr uint8_t kFecPayloadType = 96; 24 constexpr uint8_t kFecPayloadType = 96;
25 constexpr uint8_t kRedPayloadType = 97; 25 constexpr uint8_t kRedPayloadType = 97;
26 } // namespace 26 } // namespace
27 27
28 using ::webrtc::test::fec::FrameGenerator;
29 using ::webrtc::test::fec::RawRtpPacket; 28 using ::webrtc::test::fec::RawRtpPacket;
29 using ::webrtc::test::fec::UlpfecPacketGenerator;
30 30
31 void VerifyHeader(uint16_t seq_num, 31 void VerifyHeader(uint16_t seq_num,
32 uint32_t timestamp, 32 uint32_t timestamp,
33 int red_payload_type, 33 int red_payload_type,
34 int fec_payload_type, 34 int fec_payload_type,
35 RedPacket* packet, 35 RedPacket* packet,
36 bool marker_bit) { 36 bool marker_bit) {
37 EXPECT_GT(packet->length(), kRtpHeaderSize); 37 EXPECT_GT(packet->length(), kRtpHeaderSize);
38 EXPECT_TRUE(packet->data() != NULL); 38 EXPECT_TRUE(packet->data() != NULL);
39 uint8_t* data = packet->data(); 39 uint8_t* data = packet->data();
40 // Marker bit not set. 40 // Marker bit not set.
41 EXPECT_EQ(marker_bit ? 0x80 : 0, data[1] & 0x80); 41 EXPECT_EQ(marker_bit ? 0x80 : 0, data[1] & 0x80);
42 EXPECT_EQ(red_payload_type, data[1] & 0x7F); 42 EXPECT_EQ(red_payload_type, data[1] & 0x7F);
43 EXPECT_EQ(seq_num, (data[2] << 8) + data[3]); 43 EXPECT_EQ(seq_num, (data[2] << 8) + data[3]);
44 uint32_t parsed_timestamp = (data[4] << 24) + (data[5] << 16) + 44 uint32_t parsed_timestamp = (data[4] << 24) + (data[5] << 16) +
45 (data[6] << 8) + data[7]; 45 (data[6] << 8) + data[7];
46 EXPECT_EQ(timestamp, parsed_timestamp); 46 EXPECT_EQ(timestamp, parsed_timestamp);
47 EXPECT_EQ(static_cast<uint8_t>(fec_payload_type), data[kRtpHeaderSize]); 47 EXPECT_EQ(static_cast<uint8_t>(fec_payload_type), data[kRtpHeaderSize]);
48 } 48 }
49 49
50 class ProducerFecTest : public ::testing::Test { 50 class ProducerFecTest : public ::testing::Test {
51 protected: 51 protected:
52 ProducerFec producer_; 52 ProducerFec producer_;
53 FrameGenerator generator_; 53 UlpfecPacketGenerator generator_;
54 }; 54 };
55 55
56 // Verifies bug found via fuzzing, where a gap in the packet sequence caused us 56 // Verifies bug found via fuzzing, where a gap in the packet sequence caused us
57 // to move past the end of the current FEC packet mask byte without moving to 57 // to move past the end of the current FEC packet mask byte without moving to
58 // the next byte. That likely caused us to repeatedly read from the same byte, 58 // the next byte. That likely caused us to repeatedly read from the same byte,
59 // and if that byte didn't protect packets we would generate empty FEC. 59 // and if that byte didn't protect packets we would generate empty FEC.
60 TEST_F(ProducerFecTest, NoEmptyFecWithSeqNumGaps) { 60 TEST_F(ProducerFecTest, NoEmptyFecWithSeqNumGaps) {
61 struct Packet { 61 struct Packet {
62 size_t header_size; 62 size_t header_size;
63 size_t payload_size; 63 size_t payload_size;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ProducerFec::BuildRedPacket(packet->data, packet->length - kRtpHeaderSize, 199 ProducerFec::BuildRedPacket(packet->data, packet->length - kRtpHeaderSize,
200 kRtpHeaderSize, kRedPayloadType); 200 kRtpHeaderSize, kRedPayloadType);
201 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length()); 201 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length());
202 VerifyHeader(packet->header.header.sequenceNumber, 202 VerifyHeader(packet->header.header.sequenceNumber,
203 packet->header.header.timestamp, kRedPayloadType, 203 packet->header.header.timestamp, kRedPayloadType,
204 packet->header.header.payloadType, red_packet.get(), 204 packet->header.header.payloadType, red_packet.get(),
205 true); // Marker bit set. 205 true); // Marker bit set.
206 } 206 }
207 207
208 } // namespace webrtc 208 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/fec_test_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698