| OLD | NEW |
| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { | 182 TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { |
| 183 constexpr size_t kNumFecPackets = 1u; | 183 constexpr size_t kNumFecPackets = 1u; |
| 184 std::list<AugmentedPacket*> augmented_media_packets; | 184 std::list<AugmentedPacket*> augmented_media_packets; |
| 185 ForwardErrorCorrection::PacketList media_packets; | 185 ForwardErrorCorrection::PacketList media_packets; |
| 186 PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); | 186 PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); |
| 187 std::list<ForwardErrorCorrection::Packet*> fec_packets; | 187 std::list<ForwardErrorCorrection::Packet*> fec_packets; |
| 188 EncodeFec(media_packets, kNumFecPackets, &fec_packets); | 188 EncodeFec(media_packets, kNumFecPackets, &fec_packets); |
| 189 | 189 |
| 190 FecPacketCounter counter = receiver_fec_->GetPacketCounter(); |
| 191 EXPECT_EQ(0u, counter.num_packets); |
| 192 EXPECT_EQ(-1, counter.first_packet_time_ms); |
| 193 |
| 190 // Recovery | 194 // Recovery |
| 191 auto it = augmented_media_packets.begin(); | 195 auto it = augmented_media_packets.begin(); |
| 192 BuildAndAddRedMediaPacket(*it); | 196 BuildAndAddRedMediaPacket(*it); |
| 193 VerifyReconstructedMediaPacket(**it, 1); | 197 VerifyReconstructedMediaPacket(**it, 1); |
| 194 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); | 198 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); |
| 199 counter = receiver_fec_->GetPacketCounter(); |
| 200 EXPECT_EQ(1u, counter.num_packets); |
| 201 EXPECT_EQ(0u, counter.num_fec_packets); |
| 202 EXPECT_EQ(0u, counter.num_recovered_packets); |
| 203 const int64_t first_packet_time_ms = counter.first_packet_time_ms; |
| 204 EXPECT_NE(-1, first_packet_time_ms); |
| 205 |
| 195 // Drop one media packet. | 206 // Drop one media packet. |
| 196 auto fec_it = fec_packets.begin(); | 207 auto fec_it = fec_packets.begin(); |
| 197 BuildAndAddRedFecPacket(*fec_it); | 208 BuildAndAddRedFecPacket(*fec_it); |
| 198 ++it; | 209 ++it; |
| 199 VerifyReconstructedMediaPacket(**it, 1); | 210 VerifyReconstructedMediaPacket(**it, 1); |
| 200 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); | 211 EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec()); |
| 201 | 212 |
| 202 FecPacketCounter counter = receiver_fec_->GetPacketCounter(); | 213 counter = receiver_fec_->GetPacketCounter(); |
| 203 EXPECT_EQ(2u, counter.num_packets); | 214 EXPECT_EQ(2u, counter.num_packets); |
| 204 EXPECT_EQ(1u, counter.num_fec_packets); | 215 EXPECT_EQ(1u, counter.num_fec_packets); |
| 205 EXPECT_EQ(1u, counter.num_recovered_packets); | 216 EXPECT_EQ(1u, counter.num_recovered_packets); |
| 217 EXPECT_EQ(first_packet_time_ms, counter.first_packet_time_ms); |
| 206 } | 218 } |
| 207 | 219 |
| 208 TEST_F(UlpfecReceiverTest, InjectGarbageFecHeaderLengthRecovery) { | 220 TEST_F(UlpfecReceiverTest, InjectGarbageFecHeaderLengthRecovery) { |
| 209 // Byte offset 8 is the 'length recovery' field of the FEC header. | 221 // Byte offset 8 is the 'length recovery' field of the FEC header. |
| 210 InjectGarbagePacketLength(8); | 222 InjectGarbagePacketLength(8); |
| 211 } | 223 } |
| 212 | 224 |
| 213 TEST_F(UlpfecReceiverTest, InjectGarbageFecLevelHeaderProtectionLength) { | 225 TEST_F(UlpfecReceiverTest, InjectGarbageFecLevelHeaderProtectionLength) { |
| 214 // Byte offset 10 is the 'protection length' field in the first FEC level | 226 // Byte offset 10 is the 'protection length' field in the first FEC level |
| 215 // header. | 227 // header. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 476 |
| 465 TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) { | 477 TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) { |
| 466 const uint8_t kPacket[] = { | 478 const uint8_t kPacket[] = { |
| 467 0x82, 0x38, 0x92, 0x38, 0x92, 0x38, 0xde, 0x2a, 0x11, 0xc8, 0xa3, 0xc4, | 479 0x82, 0x38, 0x92, 0x38, 0x92, 0x38, 0xde, 0x2a, 0x11, 0xc8, 0xa3, 0xc4, |
| 468 0x82, 0x38, 0x2a, 0x21, 0x2a, 0x28, 0x92, 0x38, 0x92, 0x00, 0x00, 0x0a, | 480 0x82, 0x38, 0x2a, 0x21, 0x2a, 0x28, 0x92, 0x38, 0x92, 0x00, 0x00, 0x0a, |
| 469 0x3a, 0xc8, 0xa3, 0x3a, 0x27, 0xc4, 0x2a, 0x21, 0x2a, 0x28}; | 481 0x3a, 0xc8, 0xa3, 0x3a, 0x27, 0xc4, 0x2a, 0x21, 0x2a, 0x28}; |
| 470 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); | 482 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); |
| 471 } | 483 } |
| 472 | 484 |
| 473 } // namespace webrtc | 485 } // namespace webrtc |
| OLD | NEW |