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

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

Issue 2260803002: Generalize FEC header formatting. (pt. 4) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Lint fix. Created 4 years, 3 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
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
(...skipping 21 matching lines...) Expand all
32 using ::testing::Args; 32 using ::testing::Args;
33 using ::testing::ElementsAreArray; 33 using ::testing::ElementsAreArray;
34 using ::testing::Return; 34 using ::testing::Return;
35 35
36 using ::webrtc::test::fec::FrameGenerator; 36 using ::webrtc::test::fec::FrameGenerator;
37 using Packet = ::webrtc::ForwardErrorCorrection::Packet; 37 using Packet = ::webrtc::ForwardErrorCorrection::Packet;
38 using ::webrtc::test::fec::RawRtpPacket; 38 using ::webrtc::test::fec::RawRtpPacket;
39 39
40 class ReceiverFecTest : public ::testing::Test { 40 class ReceiverFecTest : public ::testing::Test {
41 protected: 41 protected:
42 ReceiverFecTest() : receiver_fec_(FecReceiver::Create(&rtp_data_callback_)) {} 42 ReceiverFecTest()
43 : fec_(ForwardErrorCorrection::CreateUlpfec()),
44 receiver_fec_(FecReceiver::Create(&rtp_data_callback_)) {}
43 45
44 void EncodeFec(ForwardErrorCorrection::PacketList* media_packets, 46 void EncodeFec(ForwardErrorCorrection::PacketList* media_packets,
45 std::list<ForwardErrorCorrection::Packet*>* fec_packets, 47 std::list<ForwardErrorCorrection::Packet*>* fec_packets,
46 unsigned int num_fec_packets) { 48 unsigned int num_fec_packets) {
47 uint8_t protection_factor = num_fec_packets * 255 / media_packets->size(); 49 uint8_t protection_factor = num_fec_packets * 255 / media_packets->size();
48 EXPECT_EQ(0, fec_.EncodeFec(*media_packets, protection_factor, 0, false, 50 EXPECT_EQ(0, fec_->EncodeFec(*media_packets, protection_factor, 0, false,
49 kFecMaskBursty, fec_packets)); 51 kFecMaskBursty, fec_packets));
50 ASSERT_EQ(num_fec_packets, fec_packets->size()); 52 ASSERT_EQ(num_fec_packets, fec_packets->size());
51 } 53 }
52 54
53 void GenerateFrame(int num_media_packets, 55 void GenerateFrame(int num_media_packets,
54 int frame_offset, 56 int frame_offset,
55 std::list<RawRtpPacket*>* media_rtp_packets, 57 std::list<RawRtpPacket*>* media_rtp_packets,
56 ForwardErrorCorrection::PacketList* media_packets) { 58 ForwardErrorCorrection::PacketList* media_packets) {
57 generator_.NewFrame(num_media_packets); 59 generator_.NewFrame(num_media_packets);
58 for (int i = 0; i < num_media_packets; ++i) { 60 for (int i = 0; i < num_media_packets; ++i) {
59 std::unique_ptr<RawRtpPacket> next_packet( 61 std::unique_ptr<RawRtpPacket> next_packet(
(...skipping 28 matching lines...) Expand all
88 red_packet->header.header, red_packet->data, 90 red_packet->header.header, red_packet->data,
89 red_packet->length, kFecPayloadType)); 91 red_packet->length, kFecPayloadType));
90 } 92 }
91 93
92 void InjectGarbagePacketLength(size_t fec_garbage_offset); 94 void InjectGarbagePacketLength(size_t fec_garbage_offset);
93 static void SurvivesMaliciousPacket(const uint8_t* data, 95 static void SurvivesMaliciousPacket(const uint8_t* data,
94 size_t length, 96 size_t length,
95 uint8_t ulpfec_payload_type); 97 uint8_t ulpfec_payload_type);
96 98
97 MockRtpData rtp_data_callback_; 99 MockRtpData rtp_data_callback_;
98 ForwardErrorCorrection fec_; 100 std::unique_ptr<ForwardErrorCorrection> fec_;
99 std::unique_ptr<FecReceiver> receiver_fec_; 101 std::unique_ptr<FecReceiver> receiver_fec_;
100 FrameGenerator generator_; 102 FrameGenerator generator_;
101 }; 103 };
102 104
103 TEST_F(ReceiverFecTest, TwoMediaOneFec) { 105 TEST_F(ReceiverFecTest, TwoMediaOneFec) {
104 const unsigned int kNumFecPackets = 1u; 106 const unsigned int kNumFecPackets = 1u;
105 std::list<RawRtpPacket*> media_rtp_packets; 107 std::list<RawRtpPacket*> media_rtp_packets;
106 ForwardErrorCorrection::PacketList media_packets; 108 ForwardErrorCorrection::PacketList media_packets;
107 GenerateFrame(2, 0, &media_rtp_packets, &media_packets); 109 GenerateFrame(2, 0, &media_rtp_packets, &media_packets);
108 std::list<ForwardErrorCorrection::Packet*> fec_packets; 110 std::list<ForwardErrorCorrection::Packet*> fec_packets;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 255
254 TEST_F(ReceiverFecTest, TooManyFrames) { 256 TEST_F(ReceiverFecTest, TooManyFrames) {
255 const unsigned int kNumFecPackets = 1u; 257 const unsigned int kNumFecPackets = 1u;
256 const unsigned int kNumMediaPackets = 49u; 258 const unsigned int kNumMediaPackets = 49u;
257 std::list<RawRtpPacket*> media_rtp_packets; 259 std::list<RawRtpPacket*> media_rtp_packets;
258 ForwardErrorCorrection::PacketList media_packets; 260 ForwardErrorCorrection::PacketList media_packets;
259 for (unsigned int i = 0; i < kNumMediaPackets; ++i) { 261 for (unsigned int i = 0; i < kNumMediaPackets; ++i) {
260 GenerateFrame(1, i, &media_rtp_packets, &media_packets); 262 GenerateFrame(1, i, &media_rtp_packets, &media_packets);
261 } 263 }
262 std::list<ForwardErrorCorrection::Packet*> fec_packets; 264 std::list<ForwardErrorCorrection::Packet*> fec_packets;
263 EXPECT_EQ( 265 EXPECT_EQ(-1, fec_->EncodeFec(media_packets,
264 -1, fec_.EncodeFec(media_packets, kNumFecPackets * 255 / kNumMediaPackets, 266 kNumFecPackets * 255 / kNumMediaPackets, 0,
265 0, false, kFecMaskBursty, &fec_packets)); 267 false, kFecMaskBursty, &fec_packets));
266 } 268 }
267 269
268 TEST_F(ReceiverFecTest, PacketNotDroppedTooEarly) { 270 TEST_F(ReceiverFecTest, PacketNotDroppedTooEarly) {
269 // 1 frame with 2 media packets and one FEC packet. One media packet missing. 271 // 1 frame with 2 media packets and one FEC packet. One media packet missing.
270 // Delay the FEC packet. 272 // Delay the FEC packet.
271 Packet* delayed_fec = NULL; 273 Packet* delayed_fec = NULL;
272 const unsigned int kNumFecPacketsBatch1 = 1u; 274 const unsigned int kNumFecPacketsBatch1 = 1u;
273 const unsigned int kNumMediaPacketsBatch1 = 2u; 275 const unsigned int kNumMediaPacketsBatch1 = 2u;
274 std::list<RawRtpPacket*> media_rtp_packets_batch1; 276 std::list<RawRtpPacket*> media_rtp_packets_batch1;
275 ForwardErrorCorrection::PacketList media_packets_batch1; 277 ForwardErrorCorrection::PacketList media_packets_batch1;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 0x27, 508 0x27,
507 0xc4, 509 0xc4,
508 0x2a, 510 0x2a,
509 0x21, 511 0x21,
510 0x2a, 512 0x2a,
511 0x28}; 513 0x28};
512 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); 514 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100);
513 } 515 }
514 516
515 } // namespace webrtc 517 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc ('k') | webrtc/modules/rtp_rtcp/source/forward_error_correction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698