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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Check for complete recovery after FEC decoding. | 79 // Check for complete recovery after FEC decoding. |
80 bool IsRecoveryComplete(); | 80 bool IsRecoveryComplete(); |
81 | 81 |
82 ForwardErrorCorrectionType fec_; | 82 ForwardErrorCorrectionType fec_; |
83 | 83 |
84 Random random_; | 84 Random random_; |
85 test::fec::MediaPacketGenerator media_packet_generator_; | 85 test::fec::MediaPacketGenerator media_packet_generator_; |
86 | 86 |
87 ForwardErrorCorrection::PacketList media_packets_; | 87 ForwardErrorCorrection::PacketList media_packets_; |
88 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; | 88 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; |
89 ForwardErrorCorrection::ReceivedPacketList received_packets_; | 89 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> |
| 90 received_packets_; |
90 ForwardErrorCorrection::RecoveredPacketList recovered_packets_; | 91 ForwardErrorCorrection::RecoveredPacketList recovered_packets_; |
91 | 92 |
92 int media_loss_mask_[kUlpfecMaxMediaPackets]; | 93 int media_loss_mask_[kUlpfecMaxMediaPackets]; |
93 int fec_loss_mask_[kUlpfecMaxMediaPackets]; | 94 int fec_loss_mask_[kUlpfecMaxMediaPackets]; |
94 }; | 95 }; |
95 | 96 |
96 template <typename ForwardErrorCorrectionType> | 97 template <typename ForwardErrorCorrectionType> |
97 void RtpFecTest<ForwardErrorCorrectionType>::NetworkReceivedPackets( | 98 void RtpFecTest<ForwardErrorCorrectionType>::NetworkReceivedPackets( |
98 int* media_loss_mask, | 99 int* media_loss_mask, |
99 int* fec_loss_mask) { | 100 int* fec_loss_mask) { |
100 constexpr bool kFecPacket = true; | 101 constexpr bool kFecPacket = true; |
| 102 this->received_packets_.clear(); |
101 ReceivedPackets(media_packets_, media_loss_mask, !kFecPacket); | 103 ReceivedPackets(media_packets_, media_loss_mask, !kFecPacket); |
102 ReceivedPackets(generated_fec_packets_, fec_loss_mask, kFecPacket); | 104 ReceivedPackets(generated_fec_packets_, fec_loss_mask, kFecPacket); |
103 } | 105 } |
104 | 106 |
105 template <typename ForwardErrorCorrectionType> | 107 template <typename ForwardErrorCorrectionType> |
106 template <typename PacketListType> | 108 template <typename PacketListType> |
107 void RtpFecTest<ForwardErrorCorrectionType>::ReceivedPackets( | 109 void RtpFecTest<ForwardErrorCorrectionType>::ReceivedPackets( |
108 const PacketListType& packet_list, | 110 const PacketListType& packet_list, |
109 int* loss_mask, | 111 int* loss_mask, |
110 bool is_fec) { | 112 bool is_fec) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 kFecMaskBursty, &this->generated_fec_packets_)); | 232 kFecMaskBursty, &this->generated_fec_packets_)); |
231 | 233 |
232 // Expect 1 FEC packet. | 234 // Expect 1 FEC packet. |
233 EXPECT_EQ(1u, this->generated_fec_packets_.size()); | 235 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
234 | 236 |
235 // No packets lost. | 237 // No packets lost. |
236 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 238 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
237 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 239 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
238 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 240 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
239 | 241 |
240 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 242 for (const auto& received_packet : this->received_packets_) { |
241 &this->recovered_packets_)); | 243 this->fec_.DecodeFec(*received_packet, |
| 244 &this->recovered_packets_); |
| 245 } |
242 | 246 |
243 // No packets lost, expect complete recovery. | 247 // No packets lost, expect complete recovery. |
244 EXPECT_TRUE(this->IsRecoveryComplete()); | 248 EXPECT_TRUE(this->IsRecoveryComplete()); |
245 } | 249 } |
246 | 250 |
247 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { | 251 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { |
248 constexpr int kNumImportantPackets = 0; | 252 constexpr int kNumImportantPackets = 0; |
249 constexpr bool kUseUnequalProtection = false; | 253 constexpr bool kUseUnequalProtection = false; |
250 constexpr int kNumMediaPackets = 4; | 254 constexpr int kNumMediaPackets = 4; |
251 constexpr uint8_t kProtectionFactor = 60; | 255 constexpr uint8_t kProtectionFactor = 60; |
252 | 256 |
253 this->media_packets_ = | 257 this->media_packets_ = |
254 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); | 258 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
255 | 259 |
256 EXPECT_EQ( | 260 EXPECT_EQ( |
257 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, | 261 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, |
258 kNumImportantPackets, kUseUnequalProtection, | 262 kNumImportantPackets, kUseUnequalProtection, |
259 kFecMaskBursty, &this->generated_fec_packets_)); | 263 kFecMaskBursty, &this->generated_fec_packets_)); |
260 | 264 |
261 // Expect 1 FEC packet. | 265 // Expect 1 FEC packet. |
262 EXPECT_EQ(1u, this->generated_fec_packets_.size()); | 266 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
263 | 267 |
264 // 1 media packet lost | 268 // 1 media packet lost |
265 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 269 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
266 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 270 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
267 this->media_loss_mask_[3] = 1; | 271 this->media_loss_mask_[3] = 1; |
268 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 272 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
269 | 273 |
270 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 274 for (const auto& received_packet : this->received_packets_) { |
271 &this->recovered_packets_)); | 275 this->fec_.DecodeFec(*received_packet, |
| 276 &this->recovered_packets_); |
| 277 } |
272 | 278 |
273 // One packet lost, one FEC packet, expect complete recovery. | 279 // One packet lost, one FEC packet, expect complete recovery. |
274 EXPECT_TRUE(this->IsRecoveryComplete()); | 280 EXPECT_TRUE(this->IsRecoveryComplete()); |
275 this->recovered_packets_.clear(); | 281 this->recovered_packets_.clear(); |
276 | 282 |
277 // 2 media packets lost. | 283 // 2 media packets lost. |
278 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 284 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
279 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 285 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
280 this->media_loss_mask_[1] = 1; | 286 this->media_loss_mask_[1] = 1; |
281 this->media_loss_mask_[3] = 1; | 287 this->media_loss_mask_[3] = 1; |
282 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 288 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
283 | 289 |
284 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 290 for (const auto& received_packet : this->received_packets_) { |
285 &this->recovered_packets_)); | 291 this->fec_.DecodeFec(*received_packet, |
| 292 &this->recovered_packets_); |
| 293 } |
286 | 294 |
287 // 2 packets lost, one FEC packet, cannot get complete recovery. | 295 // 2 packets lost, one FEC packet, cannot get complete recovery. |
288 EXPECT_FALSE(this->IsRecoveryComplete()); | 296 EXPECT_FALSE(this->IsRecoveryComplete()); |
289 } | 297 } |
290 | 298 |
291 // Verify that we don't use an old FEC packet for FEC decoding. | 299 // Verify that we don't use an old FEC packet for FEC decoding. |
292 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) { | 300 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) { |
293 constexpr int kNumImportantPackets = 0; | 301 constexpr int kNumImportantPackets = 0; |
294 constexpr bool kUseUnequalProtection = false; | 302 constexpr bool kUseUnequalProtection = false; |
295 constexpr uint8_t kProtectionFactor = 20; | 303 constexpr uint8_t kProtectionFactor = 20; |
(...skipping 27 matching lines...) Expand all Loading... |
323 | 331 |
324 // Expect 3 media packets for this frame. | 332 // Expect 3 media packets for this frame. |
325 EXPECT_EQ(3u, this->media_packets_.size()); | 333 EXPECT_EQ(3u, this->media_packets_.size()); |
326 | 334 |
327 // Second media packet lost (seq#0). | 335 // Second media packet lost (seq#0). |
328 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 336 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
329 this->media_loss_mask_[1] = 1; | 337 this->media_loss_mask_[1] = 1; |
330 // Add packets #65535, and #1 to received list. | 338 // Add packets #65535, and #1 to received list. |
331 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); | 339 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); |
332 | 340 |
333 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 341 for (const auto& received_packet : this->received_packets_) { |
334 &this->recovered_packets_)); | 342 this->fec_.DecodeFec(*received_packet, |
| 343 &this->recovered_packets_); |
| 344 } |
335 | 345 |
336 // Expect that no decoding is done to get missing packet (seq#0) of second | 346 // Expect that no decoding is done to get missing packet (seq#0) of second |
337 // frame, using old FEC packet (seq#2) from first (old) frame. So number of | 347 // frame, using old FEC packet (seq#2) from first (old) frame. So number of |
338 // recovered packets is 2, and not equal to number of media packets (=3). | 348 // recovered packets is 2, and not equal to number of media packets (=3). |
339 EXPECT_EQ(2u, this->recovered_packets_.size()); | 349 EXPECT_EQ(2u, this->recovered_packets_.size()); |
340 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); | 350 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); |
341 } | 351 } |
342 | 352 |
343 // Verify we can still recover frame if sequence number wrap occurs within | 353 // Verify we can still recover frame if sequence number wrap occurs within |
344 // the frame and FEC packet following wrap is received after media packets. | 354 // the frame and FEC packet following wrap is received after media packets. |
(...skipping 18 matching lines...) Expand all Loading... |
363 | 373 |
364 // Lose one media packet (seq# 65535). | 374 // Lose one media packet (seq# 65535). |
365 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 375 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
366 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 376 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
367 this->media_loss_mask_[1] = 1; | 377 this->media_loss_mask_[1] = 1; |
368 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); | 378 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); |
369 // Add FEC packet to received list following the media packets. | 379 // Add FEC packet to received list following the media packets. |
370 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, | 380 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
371 true); | 381 true); |
372 | 382 |
373 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 383 for (const auto& received_packet : this->received_packets_) { |
374 &this->recovered_packets_)); | 384 this->fec_.DecodeFec(*received_packet, |
| 385 &this->recovered_packets_); |
| 386 } |
375 | 387 |
376 // Expect 3 media packets in recovered list, and complete recovery. | 388 // Expect 3 media packets in recovered list, and complete recovery. |
377 // Wrap-around won't remove FEC packet, as it follows the wrap. | 389 // Wrap-around won't remove FEC packet, as it follows the wrap. |
378 EXPECT_EQ(3u, this->recovered_packets_.size()); | 390 EXPECT_EQ(3u, this->recovered_packets_.size()); |
379 EXPECT_TRUE(this->IsRecoveryComplete()); | 391 EXPECT_TRUE(this->IsRecoveryComplete()); |
380 } | 392 } |
381 | 393 |
382 // Sequence number wrap occurs within the ULPFEC packets for the frame. | 394 // Sequence number wrap occurs within the ULPFEC packets for the frame. |
383 // In this case we will discard ULPFEC packet and full recovery is not expected. | |
384 // Same problem will occur if wrap is within media packets but ULPFEC packet is | 395 // Same problem will occur if wrap is within media packets but ULPFEC packet is |
385 // received before the media packets. This may be improved if timing information | 396 // received before the media packets. This may be improved if timing information |
386 // is used to detect old ULPFEC packets. | 397 // is used to detect old ULPFEC packets. |
387 // TODO(marpan): Update test if wrap-around handling changes in FEC decoding. | 398 |
| 399 // TODO(nisse): There's some logic to discard ULPFEC packets at wrap-around, |
| 400 // however, that is not actually exercised by this test: When the first FEC |
| 401 // packet is processed, it results in full recovery of one media packet and the |
| 402 // FEC packet is forgotten. And then the wraparound isn't noticed when the next |
| 403 // FEC packet is received. We should fix wraparound handling, which currently |
| 404 // appears broken, and then figure out how to test it properly. |
388 using RtpFecTestUlpfecOnly = RtpFecTest<UlpfecForwardErrorCorrection>; | 405 using RtpFecTestUlpfecOnly = RtpFecTest<UlpfecForwardErrorCorrection>; |
389 TEST_F(RtpFecTestUlpfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { | 406 TEST_F(RtpFecTestUlpfecOnly, FecRecoveryWithSeqNumGapOneFrameRecovery) { |
390 constexpr int kNumImportantPackets = 0; | 407 constexpr int kNumImportantPackets = 0; |
391 constexpr bool kUseUnequalProtection = false; | 408 constexpr bool kUseUnequalProtection = false; |
392 constexpr uint8_t kProtectionFactor = 200; | 409 constexpr uint8_t kProtectionFactor = 200; |
393 | 410 |
394 // 1 frame: 3 media packets and 2 FEC packets. | 411 // 1 frame: 3 media packets and 2 FEC packets. |
395 // Sequence number wrap in FEC packets. | 412 // Sequence number wrap in FEC packets. |
396 // -----Frame 1---- | 413 // -----Frame 1---- |
397 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). | 414 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). |
398 this->media_packets_ = | 415 this->media_packets_ = |
399 this->media_packet_generator_.ConstructMediaPackets(3, 65532); | 416 this->media_packet_generator_.ConstructMediaPackets(3, 65532); |
400 | 417 |
401 EXPECT_EQ( | 418 EXPECT_EQ( |
402 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, | 419 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, |
403 kNumImportantPackets, kUseUnequalProtection, | 420 kNumImportantPackets, kUseUnequalProtection, |
404 kFecMaskBursty, &this->generated_fec_packets_)); | 421 kFecMaskBursty, &this->generated_fec_packets_)); |
405 | 422 |
406 // Expect 2 FEC packets. | 423 // Expect 2 FEC packets. |
407 EXPECT_EQ(2u, this->generated_fec_packets_.size()); | 424 EXPECT_EQ(2u, this->generated_fec_packets_.size()); |
408 | 425 |
409 // Lose the last two media packets (seq# 65533, 65534). | 426 // Lose the last two media packets (seq# 65533, 65534). |
410 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 427 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
411 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 428 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
412 this->media_loss_mask_[1] = 1; | 429 this->media_loss_mask_[1] = 1; |
413 this->media_loss_mask_[2] = 1; | 430 this->media_loss_mask_[2] = 1; |
414 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); | 431 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); |
415 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, | 432 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
416 true); | 433 true); |
417 | 434 |
418 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 435 for (const auto& received_packet : this->received_packets_) { |
419 &this->recovered_packets_)); | 436 this->fec_.DecodeFec(*received_packet, |
| 437 &this->recovered_packets_); |
| 438 } |
420 | 439 |
421 // The two FEC packets are received and should allow for complete recovery, | 440 // The two FEC packets are received and should allow for complete recovery, |
422 // but because of the wrap the first FEC packet will be discarded, and only | 441 // but because of the wrap the first FEC packet will be discarded, and only |
423 // one media packet is recoverable. So expect 2 media packets on recovered | 442 // one media packet is recoverable. So expect 2 media packets on recovered |
424 // list and no complete recovery. | 443 // list and no complete recovery. |
425 EXPECT_EQ(2u, this->recovered_packets_.size()); | 444 EXPECT_EQ(3u, this->recovered_packets_.size()); |
426 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); | 445 EXPECT_EQ(this->recovered_packets_.size(), this->media_packets_.size()); |
427 EXPECT_FALSE(this->IsRecoveryComplete()); | 446 EXPECT_TRUE(this->IsRecoveryComplete()); |
428 } | 447 } |
429 | 448 |
430 // TODO(brandtr): This test mimics the one above, ensuring that the recovery | 449 // TODO(brandtr): This test mimics the one above, ensuring that the recovery |
431 // strategy of FlexFEC matches the recovery strategy of ULPFEC. Since FlexFEC | 450 // strategy of FlexFEC matches the recovery strategy of ULPFEC. Since FlexFEC |
432 // does not share the sequence number space with the media, however, having a | 451 // does not share the sequence number space with the media, however, having a |
433 // matching recovery strategy may be suboptimal. Study this further. | 452 // matching recovery strategy may be suboptimal. Study this further. |
| 453 // TODO(nisse): In this test, recovery based on the first FEC packet fails with |
| 454 // the log message "The recovered packet had a length larger than a typical IP |
| 455 // packet, and is thus dropped." This is probably not intended, and needs |
| 456 // investigation. |
434 using RtpFecTestFlexfecOnly = RtpFecTest<FlexfecForwardErrorCorrection>; | 457 using RtpFecTestFlexfecOnly = RtpFecTest<FlexfecForwardErrorCorrection>; |
435 TEST_F(RtpFecTestFlexfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { | 458 TEST_F(RtpFecTestFlexfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { |
436 constexpr int kNumImportantPackets = 0; | 459 constexpr int kNumImportantPackets = 0; |
437 constexpr bool kUseUnequalProtection = false; | 460 constexpr bool kUseUnequalProtection = false; |
438 constexpr uint8_t kProtectionFactor = 200; | 461 constexpr uint8_t kProtectionFactor = 200; |
439 | 462 |
440 // 1 frame: 3 media packets and 2 FEC packets. | 463 // 1 frame: 3 media packets and 2 FEC packets. |
441 // Sequence number wrap in FEC packets. | 464 // Sequence number wrap in FEC packets. |
442 // -----Frame 1---- | 465 // -----Frame 1---- |
443 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). | 466 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). |
(...skipping 17 matching lines...) Expand all Loading... |
461 | 484 |
462 // Lose the last two media packets (seq# 65533, 65534). | 485 // Lose the last two media packets (seq# 65533, 65534). |
463 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 486 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
464 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 487 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
465 this->media_loss_mask_[1] = 1; | 488 this->media_loss_mask_[1] = 1; |
466 this->media_loss_mask_[2] = 1; | 489 this->media_loss_mask_[2] = 1; |
467 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); | 490 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); |
468 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, | 491 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
469 true); | 492 true); |
470 | 493 |
471 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 494 for (const auto& received_packet : this->received_packets_) { |
472 &this->recovered_packets_)); | 495 this->fec_.DecodeFec(*received_packet, |
| 496 &this->recovered_packets_); |
| 497 } |
473 | 498 |
474 // The two FEC packets are received and should allow for complete recovery, | 499 // The two FEC packets are received and should allow for complete recovery, |
475 // but because of the wrap the first FEC packet will be discarded, and only | 500 // but because of the wrap the first FEC packet will be discarded, and only |
476 // one media packet is recoverable. So expect 2 media packets on recovered | 501 // one media packet is recoverable. So expect 2 media packets on recovered |
477 // list and no complete recovery. | 502 // list and no complete recovery. |
478 EXPECT_EQ(2u, this->recovered_packets_.size()); | 503 EXPECT_EQ(2u, this->recovered_packets_.size()); |
479 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); | 504 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); |
480 EXPECT_FALSE(this->IsRecoveryComplete()); | 505 EXPECT_FALSE(this->IsRecoveryComplete()); |
481 } | 506 } |
482 | 507 |
(...skipping 22 matching lines...) Expand all Loading... |
505 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 530 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
506 this->media_loss_mask_[1] = 1; | 531 this->media_loss_mask_[1] = 1; |
507 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 532 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
508 | 533 |
509 // Reorder received media packets. | 534 // Reorder received media packets. |
510 auto it0 = this->received_packets_.begin(); | 535 auto it0 = this->received_packets_.begin(); |
511 auto it1 = this->received_packets_.begin(); | 536 auto it1 = this->received_packets_.begin(); |
512 it1++; | 537 it1++; |
513 std::swap(*it0, *it1); | 538 std::swap(*it0, *it1); |
514 | 539 |
515 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 540 for (const auto& received_packet : this->received_packets_) { |
516 &this->recovered_packets_)); | 541 this->fec_.DecodeFec(*received_packet, |
| 542 &this->recovered_packets_); |
| 543 } |
517 | 544 |
518 // Expect 3 media packets in recovered list, and complete recovery. | 545 // Expect 3 media packets in recovered list, and complete recovery. |
519 EXPECT_EQ(3u, this->recovered_packets_.size()); | 546 EXPECT_EQ(3u, this->recovered_packets_.size()); |
520 EXPECT_TRUE(this->IsRecoveryComplete()); | 547 EXPECT_TRUE(this->IsRecoveryComplete()); |
521 } | 548 } |
522 | 549 |
523 // Verify we can still recover frame if FEC is received before media packets. | 550 // Verify we can still recover frame if FEC is received before media packets. |
524 TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) { | 551 TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) { |
525 constexpr int kNumImportantPackets = 0; | 552 constexpr int kNumImportantPackets = 0; |
526 constexpr bool kUseUnequalProtection = false; | 553 constexpr bool kUseUnequalProtection = false; |
(...skipping 16 matching lines...) Expand all Loading... |
543 // Lose one media packet (seq# 1). | 570 // Lose one media packet (seq# 1). |
544 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 571 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
545 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 572 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
546 this->media_loss_mask_[1] = 1; | 573 this->media_loss_mask_[1] = 1; |
547 // Add FEC packet to received list before the media packets. | 574 // Add FEC packet to received list before the media packets. |
548 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, | 575 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
549 true); | 576 true); |
550 // Add media packets to received list. | 577 // Add media packets to received list. |
551 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); | 578 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); |
552 | 579 |
553 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 580 for (const auto& received_packet : this->received_packets_) { |
554 &this->recovered_packets_)); | 581 this->fec_.DecodeFec(*received_packet, |
| 582 &this->recovered_packets_); |
| 583 } |
555 | 584 |
556 // Expect 3 media packets in recovered list, and complete recovery. | 585 // Expect 3 media packets in recovered list, and complete recovery. |
557 EXPECT_EQ(3u, this->recovered_packets_.size()); | 586 EXPECT_EQ(3u, this->recovered_packets_.size()); |
558 EXPECT_TRUE(this->IsRecoveryComplete()); | 587 EXPECT_TRUE(this->IsRecoveryComplete()); |
559 } | 588 } |
560 | 589 |
561 // Test 50% protection with random mask type: Two cases are considered: | 590 // Test 50% protection with random mask type: Two cases are considered: |
562 // a 50% non-consecutive loss which can be fully recovered, and a 50% | 591 // a 50% non-consecutive loss which can be fully recovered, and a 50% |
563 // consecutive loss which cannot be fully recovered. | 592 // consecutive loss which cannot be fully recovered. |
564 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { | 593 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { |
(...skipping 25 matching lines...) Expand all Loading... |
590 | 619 |
591 // 4 packets lost: 3 media packets (0, 2, 3), and one FEC packet (0) lost. | 620 // 4 packets lost: 3 media packets (0, 2, 3), and one FEC packet (0) lost. |
592 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 621 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
593 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 622 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
594 this->fec_loss_mask_[0] = 1; | 623 this->fec_loss_mask_[0] = 1; |
595 this->media_loss_mask_[0] = 1; | 624 this->media_loss_mask_[0] = 1; |
596 this->media_loss_mask_[2] = 1; | 625 this->media_loss_mask_[2] = 1; |
597 this->media_loss_mask_[3] = 1; | 626 this->media_loss_mask_[3] = 1; |
598 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 627 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
599 | 628 |
600 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 629 for (const auto& received_packet : this->received_packets_) { |
601 &this->recovered_packets_)); | 630 this->fec_.DecodeFec(*received_packet, |
| 631 &this->recovered_packets_); |
| 632 } |
602 | 633 |
603 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. | 634 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. |
604 EXPECT_TRUE(this->IsRecoveryComplete()); | 635 EXPECT_TRUE(this->IsRecoveryComplete()); |
605 this->recovered_packets_.clear(); | 636 this->recovered_packets_.clear(); |
606 | 637 |
607 // 4 consecutive packets lost: media packets 0, 1, 2, 3. | 638 // 4 consecutive packets lost: media packets 0, 1, 2, 3. |
608 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 639 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
609 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 640 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
610 this->media_loss_mask_[0] = 1; | 641 this->media_loss_mask_[0] = 1; |
611 this->media_loss_mask_[1] = 1; | 642 this->media_loss_mask_[1] = 1; |
612 this->media_loss_mask_[2] = 1; | 643 this->media_loss_mask_[2] = 1; |
613 this->media_loss_mask_[3] = 1; | 644 this->media_loss_mask_[3] = 1; |
614 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 645 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
615 | 646 |
616 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 647 for (const auto& received_packet : this->received_packets_) { |
617 &this->recovered_packets_)); | 648 this->fec_.DecodeFec(*received_packet, |
| 649 &this->recovered_packets_); |
| 650 } |
618 | 651 |
619 // Cannot get complete recovery for this loss configuration with random mask. | 652 // Cannot get complete recovery for this loss configuration with random mask. |
620 EXPECT_FALSE(this->IsRecoveryComplete()); | 653 EXPECT_FALSE(this->IsRecoveryComplete()); |
621 } | 654 } |
622 | 655 |
623 // Test 50% protection with bursty type: Three cases are considered: | 656 // Test 50% protection with bursty type: Three cases are considered: |
624 // two 50% consecutive losses which can be fully recovered, and one | 657 // two 50% consecutive losses which can be fully recovered, and one |
625 // non-consecutive which cannot be fully recovered. | 658 // non-consecutive which cannot be fully recovered. |
626 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { | 659 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { |
627 constexpr int kNumImportantPackets = 0; | 660 constexpr int kNumImportantPackets = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
652 | 685 |
653 // 4 consecutive packets lost: media packets 0,1,2,3. | 686 // 4 consecutive packets lost: media packets 0,1,2,3. |
654 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 687 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
655 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 688 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
656 this->media_loss_mask_[0] = 1; | 689 this->media_loss_mask_[0] = 1; |
657 this->media_loss_mask_[1] = 1; | 690 this->media_loss_mask_[1] = 1; |
658 this->media_loss_mask_[2] = 1; | 691 this->media_loss_mask_[2] = 1; |
659 this->media_loss_mask_[3] = 1; | 692 this->media_loss_mask_[3] = 1; |
660 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 693 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
661 | 694 |
662 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 695 for (const auto& received_packet : this->received_packets_) { |
663 &this->recovered_packets_)); | 696 this->fec_.DecodeFec(*received_packet, |
| 697 &this->recovered_packets_); |
| 698 } |
664 | 699 |
665 // Expect complete recovery for consecutive packet loss <= 50%. | 700 // Expect complete recovery for consecutive packet loss <= 50%. |
666 EXPECT_TRUE(this->IsRecoveryComplete()); | 701 EXPECT_TRUE(this->IsRecoveryComplete()); |
667 this->recovered_packets_.clear(); | 702 this->recovered_packets_.clear(); |
668 | 703 |
669 // 4 consecutive packets lost: media packets 1,2, 3, and FEC packet 0. | 704 // 4 consecutive packets lost: media packets 1,2, 3, and FEC packet 0. |
670 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 705 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
671 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 706 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
672 this->fec_loss_mask_[0] = 1; | 707 this->fec_loss_mask_[0] = 1; |
673 this->media_loss_mask_[1] = 1; | 708 this->media_loss_mask_[1] = 1; |
674 this->media_loss_mask_[2] = 1; | 709 this->media_loss_mask_[2] = 1; |
675 this->media_loss_mask_[3] = 1; | 710 this->media_loss_mask_[3] = 1; |
676 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 711 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
677 | 712 |
678 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 713 for (const auto& received_packet : this->received_packets_) { |
679 &this->recovered_packets_)); | 714 this->fec_.DecodeFec(*received_packet, |
| 715 &this->recovered_packets_); |
| 716 } |
680 | 717 |
681 // Expect complete recovery for consecutive packet loss <= 50%. | 718 // Expect complete recovery for consecutive packet loss <= 50%. |
682 EXPECT_TRUE(this->IsRecoveryComplete()); | 719 EXPECT_TRUE(this->IsRecoveryComplete()); |
683 this->recovered_packets_.clear(); | 720 this->recovered_packets_.clear(); |
684 | 721 |
685 // 4 packets lost (non-consecutive loss): media packets 0, 3, and FEC# 0, 3. | 722 // 4 packets lost (non-consecutive loss): media packets 0, 3, and FEC# 0, 3. |
686 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 723 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
687 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 724 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
688 this->fec_loss_mask_[0] = 1; | 725 this->fec_loss_mask_[0] = 1; |
689 this->fec_loss_mask_[3] = 1; | 726 this->fec_loss_mask_[3] = 1; |
690 this->media_loss_mask_[0] = 1; | 727 this->media_loss_mask_[0] = 1; |
691 this->media_loss_mask_[3] = 1; | 728 this->media_loss_mask_[3] = 1; |
692 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 729 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
693 | 730 |
694 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 731 for (const auto& received_packet : this->received_packets_) { |
695 &this->recovered_packets_)); | 732 this->fec_.DecodeFec(*received_packet, |
| 733 &this->recovered_packets_); |
| 734 } |
696 | 735 |
697 // Cannot get complete recovery for this loss configuration. | 736 // Cannot get complete recovery for this loss configuration. |
698 EXPECT_FALSE(this->IsRecoveryComplete()); | 737 EXPECT_FALSE(this->IsRecoveryComplete()); |
699 } | 738 } |
700 | 739 |
701 TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) { | 740 TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) { |
702 constexpr int kNumImportantPackets = 2; | 741 constexpr int kNumImportantPackets = 2; |
703 constexpr bool kUseUnequalProtection = true; | 742 constexpr bool kUseUnequalProtection = true; |
704 constexpr int kNumMediaPackets = 4; | 743 constexpr int kNumMediaPackets = 4; |
705 constexpr uint8_t kProtectionFactor = 60; | 744 constexpr uint8_t kProtectionFactor = 60; |
706 | 745 |
707 this->media_packets_ = | 746 this->media_packets_ = |
708 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); | 747 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
709 | 748 |
710 EXPECT_EQ( | 749 EXPECT_EQ( |
711 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, | 750 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, |
712 kNumImportantPackets, kUseUnequalProtection, | 751 kNumImportantPackets, kUseUnequalProtection, |
713 kFecMaskBursty, &this->generated_fec_packets_)); | 752 kFecMaskBursty, &this->generated_fec_packets_)); |
714 | 753 |
715 // Expect 1 FEC packet. | 754 // Expect 1 FEC packet. |
716 EXPECT_EQ(1u, this->generated_fec_packets_.size()); | 755 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
717 | 756 |
718 // No packets lost. | 757 // No packets lost. |
719 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 758 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
720 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 759 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
721 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 760 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
722 | 761 |
723 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 762 for (const auto& received_packet : this->received_packets_) { |
724 &this->recovered_packets_)); | 763 this->fec_.DecodeFec(*received_packet, |
| 764 &this->recovered_packets_); |
| 765 } |
725 | 766 |
726 // No packets lost, expect complete recovery. | 767 // No packets lost, expect complete recovery. |
727 EXPECT_TRUE(this->IsRecoveryComplete()); | 768 EXPECT_TRUE(this->IsRecoveryComplete()); |
728 } | 769 } |
729 | 770 |
730 TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { | 771 TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { |
731 constexpr int kNumImportantPackets = 2; | 772 constexpr int kNumImportantPackets = 2; |
732 constexpr bool kUseUnequalProtection = true; | 773 constexpr bool kUseUnequalProtection = true; |
733 constexpr int kNumMediaPackets = 4; | 774 constexpr int kNumMediaPackets = 4; |
734 constexpr uint8_t kProtectionFactor = 60; | 775 constexpr uint8_t kProtectionFactor = 60; |
735 | 776 |
736 this->media_packets_ = | 777 this->media_packets_ = |
737 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); | 778 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
738 | 779 |
739 EXPECT_EQ( | 780 EXPECT_EQ( |
740 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, | 781 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, |
741 kNumImportantPackets, kUseUnequalProtection, | 782 kNumImportantPackets, kUseUnequalProtection, |
742 kFecMaskBursty, &this->generated_fec_packets_)); | 783 kFecMaskBursty, &this->generated_fec_packets_)); |
743 | 784 |
744 // Expect 1 FEC packet. | 785 // Expect 1 FEC packet. |
745 EXPECT_EQ(1u, this->generated_fec_packets_.size()); | 786 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
746 | 787 |
747 // 1 media packet lost. | 788 // 1 media packet lost. |
748 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 789 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
749 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 790 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
750 this->media_loss_mask_[3] = 1; | 791 this->media_loss_mask_[3] = 1; |
751 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 792 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
752 | 793 |
753 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 794 for (const auto& received_packet : this->received_packets_) { |
754 &this->recovered_packets_)); | 795 this->fec_.DecodeFec(*received_packet, |
| 796 &this->recovered_packets_); |
| 797 } |
755 | 798 |
756 // One packet lost, one FEC packet, expect complete recovery. | 799 // One packet lost, one FEC packet, expect complete recovery. |
757 EXPECT_TRUE(this->IsRecoveryComplete()); | 800 EXPECT_TRUE(this->IsRecoveryComplete()); |
758 this->recovered_packets_.clear(); | 801 this->recovered_packets_.clear(); |
759 | 802 |
760 // 2 media packets lost. | 803 // 2 media packets lost. |
761 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 804 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
762 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 805 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
763 this->media_loss_mask_[1] = 1; | 806 this->media_loss_mask_[1] = 1; |
764 this->media_loss_mask_[3] = 1; | 807 this->media_loss_mask_[3] = 1; |
765 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 808 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
766 | 809 |
767 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 810 for (const auto& received_packet : this->received_packets_) { |
768 &this->recovered_packets_)); | 811 this->fec_.DecodeFec(*received_packet, |
| 812 &this->recovered_packets_); |
| 813 } |
769 | 814 |
770 // 2 packets lost, one FEC packet, cannot get complete recovery. | 815 // 2 packets lost, one FEC packet, cannot get complete recovery. |
771 EXPECT_FALSE(this->IsRecoveryComplete()); | 816 EXPECT_FALSE(this->IsRecoveryComplete()); |
772 } | 817 } |
773 | 818 |
774 // Test 50% protection with random mask type for UEP on. | 819 // Test 50% protection with random mask type for UEP on. |
775 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { | 820 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { |
776 constexpr int kNumImportantPackets = 1; | 821 constexpr int kNumImportantPackets = 1; |
777 constexpr bool kUseUnequalProtection = true; | 822 constexpr bool kUseUnequalProtection = true; |
778 constexpr int kNumMediaPackets = 4; | 823 constexpr int kNumMediaPackets = 4; |
(...skipping 22 matching lines...) Expand all Loading... |
801 | 846 |
802 // 4 packets lost: 3 media packets and FEC packet#1 lost. | 847 // 4 packets lost: 3 media packets and FEC packet#1 lost. |
803 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 848 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
804 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 849 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
805 this->fec_loss_mask_[1] = 1; | 850 this->fec_loss_mask_[1] = 1; |
806 this->media_loss_mask_[0] = 1; | 851 this->media_loss_mask_[0] = 1; |
807 this->media_loss_mask_[2] = 1; | 852 this->media_loss_mask_[2] = 1; |
808 this->media_loss_mask_[3] = 1; | 853 this->media_loss_mask_[3] = 1; |
809 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 854 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
810 | 855 |
811 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 856 for (const auto& received_packet : this->received_packets_) { |
812 &this->recovered_packets_)); | 857 this->fec_.DecodeFec(*received_packet, |
| 858 &this->recovered_packets_); |
| 859 } |
813 | 860 |
814 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. | 861 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. |
815 EXPECT_TRUE(this->IsRecoveryComplete()); | 862 EXPECT_TRUE(this->IsRecoveryComplete()); |
816 this->recovered_packets_.clear(); | 863 this->recovered_packets_.clear(); |
817 | 864 |
818 // 5 packets lost: 4 media packets and one FEC packet#2 lost. | 865 // 5 packets lost: 4 media packets and one FEC packet#2 lost. |
819 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 866 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
820 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 867 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
821 this->fec_loss_mask_[2] = 1; | 868 this->fec_loss_mask_[2] = 1; |
822 this->media_loss_mask_[0] = 1; | 869 this->media_loss_mask_[0] = 1; |
823 this->media_loss_mask_[1] = 1; | 870 this->media_loss_mask_[1] = 1; |
824 this->media_loss_mask_[2] = 1; | 871 this->media_loss_mask_[2] = 1; |
825 this->media_loss_mask_[3] = 1; | 872 this->media_loss_mask_[3] = 1; |
826 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 873 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
827 | 874 |
828 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 875 for (const auto& received_packet : this->received_packets_) { |
829 &this->recovered_packets_)); | 876 this->fec_.DecodeFec(*received_packet, |
| 877 &this->recovered_packets_); |
| 878 } |
830 | 879 |
831 // Cannot get complete recovery for this loss configuration. | 880 // Cannot get complete recovery for this loss configuration. |
832 EXPECT_FALSE(this->IsRecoveryComplete()); | 881 EXPECT_FALSE(this->IsRecoveryComplete()); |
833 } | 882 } |
834 | 883 |
835 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { | 884 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { |
836 constexpr int kNumImportantPackets = 0; | 885 constexpr int kNumImportantPackets = 0; |
837 constexpr bool kUseUnequalProtection = false; | 886 constexpr bool kUseUnequalProtection = false; |
838 constexpr int kNumMediaPackets = 5; | 887 constexpr int kNumMediaPackets = 5; |
839 constexpr uint8_t kProtectionFactor = 60; | 888 constexpr uint8_t kProtectionFactor = 60; |
(...skipping 13 matching lines...) Expand all Loading... |
853 | 902 |
854 // Expect 1 FEC packet. | 903 // Expect 1 FEC packet. |
855 EXPECT_EQ(1u, this->generated_fec_packets_.size()); | 904 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
856 | 905 |
857 // 1 protected media packet lost | 906 // 1 protected media packet lost |
858 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 907 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
859 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 908 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
860 this->media_loss_mask_[2] = 1; | 909 this->media_loss_mask_[2] = 1; |
861 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 910 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
862 | 911 |
863 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 912 for (const auto& received_packet : this->received_packets_) { |
864 &this->recovered_packets_)); | 913 this->fec_.DecodeFec(*received_packet, |
| 914 &this->recovered_packets_); |
| 915 } |
865 | 916 |
866 // One packet lost, one FEC packet, expect complete recovery. | 917 // One packet lost, one FEC packet, expect complete recovery. |
867 EXPECT_TRUE(this->IsRecoveryComplete()); | 918 EXPECT_TRUE(this->IsRecoveryComplete()); |
868 this->recovered_packets_.clear(); | 919 this->recovered_packets_.clear(); |
869 | 920 |
870 // Unprotected packet lost. | 921 // Unprotected packet lost. |
871 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 922 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
872 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 923 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
873 this->media_loss_mask_[1] = 1; | 924 this->media_loss_mask_[1] = 1; |
874 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 925 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
875 | 926 |
876 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 927 for (const auto& received_packet : this->received_packets_) { |
877 &this->recovered_packets_)); | 928 this->fec_.DecodeFec(*received_packet, |
| 929 &this->recovered_packets_); |
| 930 } |
878 | 931 |
879 // Unprotected packet lost. Recovery not possible. | 932 // Unprotected packet lost. Recovery not possible. |
880 EXPECT_FALSE(this->IsRecoveryComplete()); | 933 EXPECT_FALSE(this->IsRecoveryComplete()); |
881 this->recovered_packets_.clear(); | 934 this->recovered_packets_.clear(); |
882 | 935 |
883 // 2 media packets lost. | 936 // 2 media packets lost. |
884 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 937 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
885 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 938 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
886 this->media_loss_mask_[0] = 1; | 939 this->media_loss_mask_[0] = 1; |
887 this->media_loss_mask_[2] = 1; | 940 this->media_loss_mask_[2] = 1; |
888 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 941 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
889 | 942 |
890 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 943 for (const auto& received_packet : this->received_packets_) { |
891 &this->recovered_packets_)); | 944 this->fec_.DecodeFec(*received_packet, |
| 945 &this->recovered_packets_); |
| 946 } |
892 | 947 |
893 // 2 protected packets lost, one FEC packet, cannot get complete recovery. | 948 // 2 protected packets lost, one FEC packet, cannot get complete recovery. |
894 EXPECT_FALSE(this->IsRecoveryComplete()); | 949 EXPECT_FALSE(this->IsRecoveryComplete()); |
895 } | 950 } |
896 | 951 |
897 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { | 952 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { |
898 constexpr int kNumImportantPackets = 0; | 953 constexpr int kNumImportantPackets = 0; |
899 constexpr bool kUseUnequalProtection = false; | 954 constexpr bool kUseUnequalProtection = false; |
900 constexpr int kNumMediaPackets = 21; | 955 constexpr int kNumMediaPackets = 21; |
901 uint8_t kProtectionFactor = 127; | 956 uint8_t kProtectionFactor = 127; |
(...skipping 16 matching lines...) Expand all Loading... |
918 | 973 |
919 // Expect 5 FEC packet. | 974 // Expect 5 FEC packet. |
920 EXPECT_EQ(5u, this->generated_fec_packets_.size()); | 975 EXPECT_EQ(5u, this->generated_fec_packets_.size()); |
921 | 976 |
922 // Last protected media packet lost | 977 // Last protected media packet lost |
923 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 978 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
924 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 979 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
925 this->media_loss_mask_[kNumMediaPackets - 1] = 1; | 980 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
926 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 981 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
927 | 982 |
928 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 983 for (const auto& received_packet : this->received_packets_) { |
929 &this->recovered_packets_)); | 984 this->fec_.DecodeFec(*received_packet, |
| 985 &this->recovered_packets_); |
| 986 } |
930 | 987 |
931 // One packet lost, one FEC packet, expect complete recovery. | 988 // One packet lost, one FEC packet, expect complete recovery. |
932 EXPECT_TRUE(this->IsRecoveryComplete()); | 989 EXPECT_TRUE(this->IsRecoveryComplete()); |
933 this->recovered_packets_.clear(); | 990 this->recovered_packets_.clear(); |
934 | 991 |
935 // Last unprotected packet lost. | 992 // Last unprotected packet lost. |
936 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 993 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
937 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 994 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
938 this->media_loss_mask_[kNumMediaPackets - 2] = 1; | 995 this->media_loss_mask_[kNumMediaPackets - 2] = 1; |
939 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 996 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
940 | 997 |
941 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 998 for (const auto& received_packet : this->received_packets_) { |
942 &this->recovered_packets_)); | 999 this->fec_.DecodeFec(*received_packet, |
| 1000 &this->recovered_packets_); |
| 1001 } |
943 | 1002 |
944 // Unprotected packet lost. Recovery not possible. | 1003 // Unprotected packet lost. Recovery not possible. |
945 EXPECT_FALSE(this->IsRecoveryComplete()); | 1004 EXPECT_FALSE(this->IsRecoveryComplete()); |
946 this->recovered_packets_.clear(); | 1005 this->recovered_packets_.clear(); |
947 | 1006 |
948 // 6 media packets lost. | 1007 // 6 media packets lost. |
949 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 1008 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
950 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 1009 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
951 this->media_loss_mask_[kNumMediaPackets - 11] = 1; | 1010 this->media_loss_mask_[kNumMediaPackets - 11] = 1; |
952 this->media_loss_mask_[kNumMediaPackets - 9] = 1; | 1011 this->media_loss_mask_[kNumMediaPackets - 9] = 1; |
953 this->media_loss_mask_[kNumMediaPackets - 7] = 1; | 1012 this->media_loss_mask_[kNumMediaPackets - 7] = 1; |
954 this->media_loss_mask_[kNumMediaPackets - 5] = 1; | 1013 this->media_loss_mask_[kNumMediaPackets - 5] = 1; |
955 this->media_loss_mask_[kNumMediaPackets - 3] = 1; | 1014 this->media_loss_mask_[kNumMediaPackets - 3] = 1; |
956 this->media_loss_mask_[kNumMediaPackets - 1] = 1; | 1015 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
957 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 1016 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
958 | 1017 |
959 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 1018 for (const auto& received_packet : this->received_packets_) { |
960 &this->recovered_packets_)); | 1019 this->fec_.DecodeFec(*received_packet, |
| 1020 &this->recovered_packets_); |
| 1021 } |
961 | 1022 |
962 // 5 protected packets lost, one FEC packet, cannot get complete recovery. | 1023 // 5 protected packets lost, one FEC packet, cannot get complete recovery. |
963 EXPECT_FALSE(this->IsRecoveryComplete()); | 1024 EXPECT_FALSE(this->IsRecoveryComplete()); |
964 } | 1025 } |
965 | 1026 |
966 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { | 1027 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { |
967 constexpr int kNumImportantPackets = 0; | 1028 constexpr int kNumImportantPackets = 0; |
968 constexpr bool kUseUnequalProtection = false; | 1029 constexpr bool kUseUnequalProtection = false; |
969 constexpr int kNumMediaPackets = 21; | 1030 constexpr int kNumMediaPackets = 21; |
970 uint8_t kProtectionFactor = 127; | 1031 uint8_t kProtectionFactor = 127; |
(...skipping 16 matching lines...) Expand all Loading... |
987 | 1048 |
988 // Expect 5 FEC packet. | 1049 // Expect 5 FEC packet. |
989 EXPECT_EQ(5u, this->generated_fec_packets_.size()); | 1050 EXPECT_EQ(5u, this->generated_fec_packets_.size()); |
990 | 1051 |
991 // Last protected media packet lost | 1052 // Last protected media packet lost |
992 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 1053 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
993 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 1054 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
994 this->media_loss_mask_[kNumMediaPackets - 1] = 1; | 1055 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
995 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 1056 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
996 | 1057 |
997 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 1058 for (const auto& received_packet : this->received_packets_) { |
998 &this->recovered_packets_)); | 1059 this->fec_.DecodeFec(*received_packet, |
| 1060 &this->recovered_packets_); |
| 1061 } |
999 | 1062 |
1000 // One packet lost, one FEC packet, expect complete recovery. | 1063 // One packet lost, one FEC packet, expect complete recovery. |
1001 EXPECT_TRUE(this->IsRecoveryComplete()); | 1064 EXPECT_TRUE(this->IsRecoveryComplete()); |
1002 this->recovered_packets_.clear(); | 1065 this->recovered_packets_.clear(); |
1003 | 1066 |
1004 // Last unprotected packet lost. | 1067 // Last unprotected packet lost. |
1005 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 1068 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
1006 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 1069 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
1007 this->media_loss_mask_[kNumMediaPackets - 2] = 1; | 1070 this->media_loss_mask_[kNumMediaPackets - 2] = 1; |
1008 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 1071 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
1009 | 1072 |
1010 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 1073 for (const auto& received_packet : this->received_packets_) { |
1011 &this->recovered_packets_)); | 1074 this->fec_.DecodeFec(*received_packet, |
| 1075 &this->recovered_packets_); |
| 1076 } |
1012 | 1077 |
1013 // Unprotected packet lost. Recovery not possible. | 1078 // Unprotected packet lost. Recovery not possible. |
1014 EXPECT_FALSE(this->IsRecoveryComplete()); | 1079 EXPECT_FALSE(this->IsRecoveryComplete()); |
1015 this->recovered_packets_.clear(); | 1080 this->recovered_packets_.clear(); |
1016 | 1081 |
1017 // 6 media packets lost. | 1082 // 6 media packets lost. |
1018 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); | 1083 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
1019 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); | 1084 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
1020 this->media_loss_mask_[kNumMediaPackets - 11] = 1; | 1085 this->media_loss_mask_[kNumMediaPackets - 11] = 1; |
1021 this->media_loss_mask_[kNumMediaPackets - 9] = 1; | 1086 this->media_loss_mask_[kNumMediaPackets - 9] = 1; |
1022 this->media_loss_mask_[kNumMediaPackets - 7] = 1; | 1087 this->media_loss_mask_[kNumMediaPackets - 7] = 1; |
1023 this->media_loss_mask_[kNumMediaPackets - 5] = 1; | 1088 this->media_loss_mask_[kNumMediaPackets - 5] = 1; |
1024 this->media_loss_mask_[kNumMediaPackets - 3] = 1; | 1089 this->media_loss_mask_[kNumMediaPackets - 3] = 1; |
1025 this->media_loss_mask_[kNumMediaPackets - 1] = 1; | 1090 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
1026 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); | 1091 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
1027 | 1092 |
1028 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, | 1093 for (const auto& received_packet : this->received_packets_) { |
1029 &this->recovered_packets_)); | 1094 this->fec_.DecodeFec(*received_packet, |
| 1095 &this->recovered_packets_); |
| 1096 } |
1030 | 1097 |
1031 // 5 protected packets lost, one FEC packet, cannot get complete recovery. | 1098 // 5 protected packets lost, one FEC packet, cannot get complete recovery. |
1032 EXPECT_FALSE(this->IsRecoveryComplete()); | 1099 EXPECT_FALSE(this->IsRecoveryComplete()); |
1033 } | 1100 } |
1034 | 1101 |
1035 } // namespace webrtc | 1102 } // namespace webrtc |
OLD | NEW |