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

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

Issue 3012243002: Change ForwardErrorCorrection class to accept one received packet at a time. (Closed)
Patch Set: Fix compilation errors, including tests. Created 3 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 kFecMaskBursty, &this->generated_fec_packets_)); 231 kFecMaskBursty, &this->generated_fec_packets_));
231 232
232 // Expect 1 FEC packet. 233 // Expect 1 FEC packet.
233 EXPECT_EQ(1u, this->generated_fec_packets_.size()); 234 EXPECT_EQ(1u, this->generated_fec_packets_.size());
234 235
235 // No packets lost. 236 // No packets lost.
236 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 237 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
237 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 238 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
238 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 239 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
239 240
240 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 241 for (const auto& received_packet : this->received_packets_) {
241 &this->recovered_packets_)); 242 this->fec_.DecodeFec(*received_packet,
243 &this->recovered_packets_);
244 }
242 245
243 // No packets lost, expect complete recovery. 246 // No packets lost, expect complete recovery.
244 EXPECT_TRUE(this->IsRecoveryComplete()); 247 EXPECT_TRUE(this->IsRecoveryComplete());
245 } 248 }
246 249
247 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { 250 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) {
248 constexpr int kNumImportantPackets = 0; 251 constexpr int kNumImportantPackets = 0;
249 constexpr bool kUseUnequalProtection = false; 252 constexpr bool kUseUnequalProtection = false;
250 constexpr int kNumMediaPackets = 4; 253 constexpr int kNumMediaPackets = 4;
251 constexpr uint8_t kProtectionFactor = 60; 254 constexpr uint8_t kProtectionFactor = 60;
252 255
253 this->media_packets_ = 256 this->media_packets_ =
254 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); 257 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets);
255 258
256 EXPECT_EQ( 259 EXPECT_EQ(
257 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, 260 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor,
258 kNumImportantPackets, kUseUnequalProtection, 261 kNumImportantPackets, kUseUnequalProtection,
259 kFecMaskBursty, &this->generated_fec_packets_)); 262 kFecMaskBursty, &this->generated_fec_packets_));
260 263
261 // Expect 1 FEC packet. 264 // Expect 1 FEC packet.
262 EXPECT_EQ(1u, this->generated_fec_packets_.size()); 265 EXPECT_EQ(1u, this->generated_fec_packets_.size());
263 266
264 // 1 media packet lost 267 // 1 media packet lost
265 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 268 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
266 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 269 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
267 this->media_loss_mask_[3] = 1; 270 this->media_loss_mask_[3] = 1;
268 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 271 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
269 272
270 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 273 for (const auto& received_packet : this->received_packets_) {
271 &this->recovered_packets_)); 274 this->fec_.DecodeFec(*received_packet,
275 &this->recovered_packets_);
276 }
272 277
273 // One packet lost, one FEC packet, expect complete recovery. 278 // One packet lost, one FEC packet, expect complete recovery.
274 EXPECT_TRUE(this->IsRecoveryComplete()); 279 EXPECT_TRUE(this->IsRecoveryComplete());
275 this->recovered_packets_.clear(); 280 this->recovered_packets_.clear();
276 281
277 // 2 media packets lost. 282 // 2 media packets lost.
278 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 283 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
279 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 284 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
280 this->media_loss_mask_[1] = 1; 285 this->media_loss_mask_[1] = 1;
281 this->media_loss_mask_[3] = 1; 286 this->media_loss_mask_[3] = 1;
282 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 287 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
283 288
284 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 289 for (const auto& received_packet : this->received_packets_) {
285 &this->recovered_packets_)); 290 this->fec_.DecodeFec(*received_packet,
291 &this->recovered_packets_);
292 }
286 293
287 // 2 packets lost, one FEC packet, cannot get complete recovery. 294 // 2 packets lost, one FEC packet, cannot get complete recovery.
288 EXPECT_FALSE(this->IsRecoveryComplete()); 295 EXPECT_FALSE(this->IsRecoveryComplete());
289 } 296 }
290 297
291 // Verify that we don't use an old FEC packet for FEC decoding. 298 // Verify that we don't use an old FEC packet for FEC decoding.
292 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) { 299 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) {
293 constexpr int kNumImportantPackets = 0; 300 constexpr int kNumImportantPackets = 0;
294 constexpr bool kUseUnequalProtection = false; 301 constexpr bool kUseUnequalProtection = false;
295 constexpr uint8_t kProtectionFactor = 20; 302 constexpr uint8_t kProtectionFactor = 20;
(...skipping 27 matching lines...) Expand all
323 330
324 // Expect 3 media packets for this frame. 331 // Expect 3 media packets for this frame.
325 EXPECT_EQ(3u, this->media_packets_.size()); 332 EXPECT_EQ(3u, this->media_packets_.size());
326 333
327 // Second media packet lost (seq#0). 334 // Second media packet lost (seq#0).
328 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 335 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
329 this->media_loss_mask_[1] = 1; 336 this->media_loss_mask_[1] = 1;
330 // Add packets #65535, and #1 to received list. 337 // Add packets #65535, and #1 to received list.
331 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); 338 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
332 339
333 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 340 for (const auto& received_packet : this->received_packets_) {
334 &this->recovered_packets_)); 341 this->fec_.DecodeFec(*received_packet,
342 &this->recovered_packets_);
343 }
335 344
336 // Expect that no decoding is done to get missing packet (seq#0) of second 345 // 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 346 // 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). 347 // recovered packets is 2, and not equal to number of media packets (=3).
339 EXPECT_EQ(2u, this->recovered_packets_.size()); 348 EXPECT_EQ(2u, this->recovered_packets_.size());
340 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); 349 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size());
341 } 350 }
342 351
343 // Verify we can still recover frame if sequence number wrap occurs within 352 // 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. 353 // the frame and FEC packet following wrap is received after media packets.
(...skipping 18 matching lines...) Expand all
363 372
364 // Lose one media packet (seq# 65535). 373 // Lose one media packet (seq# 65535).
365 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 374 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
366 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 375 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
367 this->media_loss_mask_[1] = 1; 376 this->media_loss_mask_[1] = 1;
368 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); 377 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
369 // Add FEC packet to received list following the media packets. 378 // Add FEC packet to received list following the media packets.
370 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, 379 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
371 true); 380 true);
372 381
373 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 382 for (const auto& received_packet : this->received_packets_) {
374 &this->recovered_packets_)); 383 this->fec_.DecodeFec(*received_packet,
384 &this->recovered_packets_);
385 }
375 386
376 // Expect 3 media packets in recovered list, and complete recovery. 387 // Expect 3 media packets in recovered list, and complete recovery.
377 // Wrap-around won't remove FEC packet, as it follows the wrap. 388 // Wrap-around won't remove FEC packet, as it follows the wrap.
378 EXPECT_EQ(3u, this->recovered_packets_.size()); 389 EXPECT_EQ(3u, this->recovered_packets_.size());
379 EXPECT_TRUE(this->IsRecoveryComplete()); 390 EXPECT_TRUE(this->IsRecoveryComplete());
380 } 391 }
381 392
382 // Sequence number wrap occurs within the ULPFEC packets for the frame. 393 // 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. 394 // 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
(...skipping 23 matching lines...) Expand all
408 419
409 // Lose the last two media packets (seq# 65533, 65534). 420 // Lose the last two media packets (seq# 65533, 65534).
410 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 421 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
411 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 422 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
412 this->media_loss_mask_[1] = 1; 423 this->media_loss_mask_[1] = 1;
413 this->media_loss_mask_[2] = 1; 424 this->media_loss_mask_[2] = 1;
414 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); 425 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
415 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, 426 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
416 true); 427 true);
417 428
418 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 429 for (const auto& received_packet : this->received_packets_) {
419 &this->recovered_packets_)); 430 this->fec_.DecodeFec(*received_packet,
431 &this->recovered_packets_);
432 }
420 433
421 // The two FEC packets are received and should allow for complete recovery, 434 // 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 435 // 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 436 // one media packet is recoverable. So expect 2 media packets on recovered
424 // list and no complete recovery. 437 // list and no complete recovery.
425 EXPECT_EQ(2u, this->recovered_packets_.size()); 438 EXPECT_EQ(2u, this->recovered_packets_.size());
426 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); 439 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size());
427 EXPECT_FALSE(this->IsRecoveryComplete()); 440 EXPECT_FALSE(this->IsRecoveryComplete());
428 } 441 }
429 442
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 474
462 // Lose the last two media packets (seq# 65533, 65534). 475 // Lose the last two media packets (seq# 65533, 65534).
463 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 476 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
464 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 477 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
465 this->media_loss_mask_[1] = 1; 478 this->media_loss_mask_[1] = 1;
466 this->media_loss_mask_[2] = 1; 479 this->media_loss_mask_[2] = 1;
467 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); 480 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
468 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, 481 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
469 true); 482 true);
470 483
471 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 484 for (const auto& received_packet : this->received_packets_) {
472 &this->recovered_packets_)); 485 this->fec_.DecodeFec(*received_packet,
486 &this->recovered_packets_);
487 }
473 488
474 // The two FEC packets are received and should allow for complete recovery, 489 // 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 490 // 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 491 // one media packet is recoverable. So expect 2 media packets on recovered
477 // list and no complete recovery. 492 // list and no complete recovery.
478 EXPECT_EQ(2u, this->recovered_packets_.size()); 493 EXPECT_EQ(2u, this->recovered_packets_.size());
479 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size()); 494 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_.size());
480 EXPECT_FALSE(this->IsRecoveryComplete()); 495 EXPECT_FALSE(this->IsRecoveryComplete());
481 } 496 }
482 497
(...skipping 22 matching lines...) Expand all
505 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 520 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
506 this->media_loss_mask_[1] = 1; 521 this->media_loss_mask_[1] = 1;
507 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 522 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
508 523
509 // Reorder received media packets. 524 // Reorder received media packets.
510 auto it0 = this->received_packets_.begin(); 525 auto it0 = this->received_packets_.begin();
511 auto it1 = this->received_packets_.begin(); 526 auto it1 = this->received_packets_.begin();
512 it1++; 527 it1++;
513 std::swap(*it0, *it1); 528 std::swap(*it0, *it1);
514 529
515 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 530 for (const auto& received_packet : this->received_packets_) {
516 &this->recovered_packets_)); 531 this->fec_.DecodeFec(*received_packet,
532 &this->recovered_packets_);
533 }
517 534
518 // Expect 3 media packets in recovered list, and complete recovery. 535 // Expect 3 media packets in recovered list, and complete recovery.
519 EXPECT_EQ(3u, this->recovered_packets_.size()); 536 EXPECT_EQ(3u, this->recovered_packets_.size());
520 EXPECT_TRUE(this->IsRecoveryComplete()); 537 EXPECT_TRUE(this->IsRecoveryComplete());
521 } 538 }
522 539
523 // Verify we can still recover frame if FEC is received before media packets. 540 // Verify we can still recover frame if FEC is received before media packets.
524 TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) { 541 TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) {
525 constexpr int kNumImportantPackets = 0; 542 constexpr int kNumImportantPackets = 0;
526 constexpr bool kUseUnequalProtection = false; 543 constexpr bool kUseUnequalProtection = false;
(...skipping 16 matching lines...) Expand all
543 // Lose one media packet (seq# 1). 560 // Lose one media packet (seq# 1).
544 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 561 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
545 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 562 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
546 this->media_loss_mask_[1] = 1; 563 this->media_loss_mask_[1] = 1;
547 // Add FEC packet to received list before the media packets. 564 // Add FEC packet to received list before the media packets.
548 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, 565 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
549 true); 566 true);
550 // Add media packets to received list. 567 // Add media packets to received list.
551 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false); 568 this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
552 569
553 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 570 for (const auto& received_packet : this->received_packets_) {
554 &this->recovered_packets_)); 571 this->fec_.DecodeFec(*received_packet,
572 &this->recovered_packets_);
573 }
555 574
556 // Expect 3 media packets in recovered list, and complete recovery. 575 // Expect 3 media packets in recovered list, and complete recovery.
557 EXPECT_EQ(3u, this->recovered_packets_.size()); 576 EXPECT_EQ(3u, this->recovered_packets_.size());
558 EXPECT_TRUE(this->IsRecoveryComplete()); 577 EXPECT_TRUE(this->IsRecoveryComplete());
559 } 578 }
560 579
561 // Test 50% protection with random mask type: Two cases are considered: 580 // 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% 581 // a 50% non-consecutive loss which can be fully recovered, and a 50%
563 // consecutive loss which cannot be fully recovered. 582 // consecutive loss which cannot be fully recovered.
564 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { 583 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) {
(...skipping 25 matching lines...) Expand all
590 609
591 // 4 packets lost: 3 media packets (0, 2, 3), and one FEC packet (0) lost. 610 // 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_)); 611 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
593 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 612 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
594 this->fec_loss_mask_[0] = 1; 613 this->fec_loss_mask_[0] = 1;
595 this->media_loss_mask_[0] = 1; 614 this->media_loss_mask_[0] = 1;
596 this->media_loss_mask_[2] = 1; 615 this->media_loss_mask_[2] = 1;
597 this->media_loss_mask_[3] = 1; 616 this->media_loss_mask_[3] = 1;
598 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 617 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
599 618
600 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 619 for (const auto& received_packet : this->received_packets_) {
601 &this->recovered_packets_)); 620 this->fec_.DecodeFec(*received_packet,
621 &this->recovered_packets_);
622 }
602 623
603 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. 624 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery.
604 EXPECT_TRUE(this->IsRecoveryComplete()); 625 EXPECT_TRUE(this->IsRecoveryComplete());
605 this->recovered_packets_.clear(); 626 this->recovered_packets_.clear();
606 627
607 // 4 consecutive packets lost: media packets 0, 1, 2, 3. 628 // 4 consecutive packets lost: media packets 0, 1, 2, 3.
608 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 629 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
609 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 630 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
610 this->media_loss_mask_[0] = 1; 631 this->media_loss_mask_[0] = 1;
611 this->media_loss_mask_[1] = 1; 632 this->media_loss_mask_[1] = 1;
612 this->media_loss_mask_[2] = 1; 633 this->media_loss_mask_[2] = 1;
613 this->media_loss_mask_[3] = 1; 634 this->media_loss_mask_[3] = 1;
614 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 635 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
615 636
616 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 637 for (const auto& received_packet : this->received_packets_) {
617 &this->recovered_packets_)); 638 this->fec_.DecodeFec(*received_packet,
639 &this->recovered_packets_);
640 }
618 641
619 // Cannot get complete recovery for this loss configuration with random mask. 642 // Cannot get complete recovery for this loss configuration with random mask.
620 EXPECT_FALSE(this->IsRecoveryComplete()); 643 EXPECT_FALSE(this->IsRecoveryComplete());
621 } 644 }
622 645
623 // Test 50% protection with bursty type: Three cases are considered: 646 // Test 50% protection with bursty type: Three cases are considered:
624 // two 50% consecutive losses which can be fully recovered, and one 647 // two 50% consecutive losses which can be fully recovered, and one
625 // non-consecutive which cannot be fully recovered. 648 // non-consecutive which cannot be fully recovered.
626 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { 649 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) {
627 constexpr int kNumImportantPackets = 0; 650 constexpr int kNumImportantPackets = 0;
(...skipping 24 matching lines...) Expand all
652 675
653 // 4 consecutive packets lost: media packets 0,1,2,3. 676 // 4 consecutive packets lost: media packets 0,1,2,3.
654 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 677 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
655 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 678 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
656 this->media_loss_mask_[0] = 1; 679 this->media_loss_mask_[0] = 1;
657 this->media_loss_mask_[1] = 1; 680 this->media_loss_mask_[1] = 1;
658 this->media_loss_mask_[2] = 1; 681 this->media_loss_mask_[2] = 1;
659 this->media_loss_mask_[3] = 1; 682 this->media_loss_mask_[3] = 1;
660 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 683 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
661 684
662 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 685 for (const auto& received_packet : this->received_packets_) {
663 &this->recovered_packets_)); 686 this->fec_.DecodeFec(*received_packet,
687 &this->recovered_packets_);
688 }
664 689
665 // Expect complete recovery for consecutive packet loss <= 50%. 690 // Expect complete recovery for consecutive packet loss <= 50%.
666 EXPECT_TRUE(this->IsRecoveryComplete()); 691 EXPECT_TRUE(this->IsRecoveryComplete());
667 this->recovered_packets_.clear(); 692 this->recovered_packets_.clear();
668 693
669 // 4 consecutive packets lost: media packets 1,2, 3, and FEC packet 0. 694 // 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_)); 695 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
671 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 696 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
672 this->fec_loss_mask_[0] = 1; 697 this->fec_loss_mask_[0] = 1;
673 this->media_loss_mask_[1] = 1; 698 this->media_loss_mask_[1] = 1;
674 this->media_loss_mask_[2] = 1; 699 this->media_loss_mask_[2] = 1;
675 this->media_loss_mask_[3] = 1; 700 this->media_loss_mask_[3] = 1;
676 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 701 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
677 702
678 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 703 for (const auto& received_packet : this->received_packets_) {
679 &this->recovered_packets_)); 704 this->fec_.DecodeFec(*received_packet,
705 &this->recovered_packets_);
706 }
680 707
681 // Expect complete recovery for consecutive packet loss <= 50%. 708 // Expect complete recovery for consecutive packet loss <= 50%.
682 EXPECT_TRUE(this->IsRecoveryComplete()); 709 EXPECT_TRUE(this->IsRecoveryComplete());
683 this->recovered_packets_.clear(); 710 this->recovered_packets_.clear();
684 711
685 // 4 packets lost (non-consecutive loss): media packets 0, 3, and FEC# 0, 3. 712 // 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_)); 713 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
687 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 714 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
688 this->fec_loss_mask_[0] = 1; 715 this->fec_loss_mask_[0] = 1;
689 this->fec_loss_mask_[3] = 1; 716 this->fec_loss_mask_[3] = 1;
690 this->media_loss_mask_[0] = 1; 717 this->media_loss_mask_[0] = 1;
691 this->media_loss_mask_[3] = 1; 718 this->media_loss_mask_[3] = 1;
692 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 719 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
693 720
694 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 721 for (const auto& received_packet : this->received_packets_) {
695 &this->recovered_packets_)); 722 this->fec_.DecodeFec(*received_packet,
723 &this->recovered_packets_);
724 }
696 725
697 // Cannot get complete recovery for this loss configuration. 726 // Cannot get complete recovery for this loss configuration.
698 EXPECT_FALSE(this->IsRecoveryComplete()); 727 EXPECT_FALSE(this->IsRecoveryComplete());
699 } 728 }
700 729
701 TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) { 730 TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) {
702 constexpr int kNumImportantPackets = 2; 731 constexpr int kNumImportantPackets = 2;
703 constexpr bool kUseUnequalProtection = true; 732 constexpr bool kUseUnequalProtection = true;
704 constexpr int kNumMediaPackets = 4; 733 constexpr int kNumMediaPackets = 4;
705 constexpr uint8_t kProtectionFactor = 60; 734 constexpr uint8_t kProtectionFactor = 60;
706 735
707 this->media_packets_ = 736 this->media_packets_ =
708 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); 737 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets);
709 738
710 EXPECT_EQ( 739 EXPECT_EQ(
711 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, 740 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor,
712 kNumImportantPackets, kUseUnequalProtection, 741 kNumImportantPackets, kUseUnequalProtection,
713 kFecMaskBursty, &this->generated_fec_packets_)); 742 kFecMaskBursty, &this->generated_fec_packets_));
714 743
715 // Expect 1 FEC packet. 744 // Expect 1 FEC packet.
716 EXPECT_EQ(1u, this->generated_fec_packets_.size()); 745 EXPECT_EQ(1u, this->generated_fec_packets_.size());
717 746
718 // No packets lost. 747 // No packets lost.
719 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 748 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
720 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 749 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
721 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 750 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
722 751
723 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 752 for (const auto& received_packet : this->received_packets_) {
724 &this->recovered_packets_)); 753 this->fec_.DecodeFec(*received_packet,
754 &this->recovered_packets_);
755 }
725 756
726 // No packets lost, expect complete recovery. 757 // No packets lost, expect complete recovery.
727 EXPECT_TRUE(this->IsRecoveryComplete()); 758 EXPECT_TRUE(this->IsRecoveryComplete());
728 } 759 }
729 760
730 TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { 761 TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) {
731 constexpr int kNumImportantPackets = 2; 762 constexpr int kNumImportantPackets = 2;
732 constexpr bool kUseUnequalProtection = true; 763 constexpr bool kUseUnequalProtection = true;
733 constexpr int kNumMediaPackets = 4; 764 constexpr int kNumMediaPackets = 4;
734 constexpr uint8_t kProtectionFactor = 60; 765 constexpr uint8_t kProtectionFactor = 60;
735 766
736 this->media_packets_ = 767 this->media_packets_ =
737 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); 768 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets);
738 769
739 EXPECT_EQ( 770 EXPECT_EQ(
740 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor, 771 0, this->fec_.EncodeFec(this->media_packets_, kProtectionFactor,
741 kNumImportantPackets, kUseUnequalProtection, 772 kNumImportantPackets, kUseUnequalProtection,
742 kFecMaskBursty, &this->generated_fec_packets_)); 773 kFecMaskBursty, &this->generated_fec_packets_));
743 774
744 // Expect 1 FEC packet. 775 // Expect 1 FEC packet.
745 EXPECT_EQ(1u, this->generated_fec_packets_.size()); 776 EXPECT_EQ(1u, this->generated_fec_packets_.size());
746 777
747 // 1 media packet lost. 778 // 1 media packet lost.
748 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 779 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
749 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 780 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
750 this->media_loss_mask_[3] = 1; 781 this->media_loss_mask_[3] = 1;
751 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 782 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
752 783
753 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 784 for (const auto& received_packet : this->received_packets_) {
754 &this->recovered_packets_)); 785 this->fec_.DecodeFec(*received_packet,
786 &this->recovered_packets_);
787 }
755 788
756 // One packet lost, one FEC packet, expect complete recovery. 789 // One packet lost, one FEC packet, expect complete recovery.
757 EXPECT_TRUE(this->IsRecoveryComplete()); 790 EXPECT_TRUE(this->IsRecoveryComplete());
758 this->recovered_packets_.clear(); 791 this->recovered_packets_.clear();
759 792
760 // 2 media packets lost. 793 // 2 media packets lost.
761 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 794 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
762 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 795 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
763 this->media_loss_mask_[1] = 1; 796 this->media_loss_mask_[1] = 1;
764 this->media_loss_mask_[3] = 1; 797 this->media_loss_mask_[3] = 1;
765 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 798 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
766 799
767 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 800 for (const auto& received_packet : this->received_packets_) {
768 &this->recovered_packets_)); 801 this->fec_.DecodeFec(*received_packet,
802 &this->recovered_packets_);
803 }
769 804
770 // 2 packets lost, one FEC packet, cannot get complete recovery. 805 // 2 packets lost, one FEC packet, cannot get complete recovery.
771 EXPECT_FALSE(this->IsRecoveryComplete()); 806 EXPECT_FALSE(this->IsRecoveryComplete());
772 } 807 }
773 808
774 // Test 50% protection with random mask type for UEP on. 809 // Test 50% protection with random mask type for UEP on.
775 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { 810 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) {
776 constexpr int kNumImportantPackets = 1; 811 constexpr int kNumImportantPackets = 1;
777 constexpr bool kUseUnequalProtection = true; 812 constexpr bool kUseUnequalProtection = true;
778 constexpr int kNumMediaPackets = 4; 813 constexpr int kNumMediaPackets = 4;
(...skipping 22 matching lines...) Expand all
801 836
802 // 4 packets lost: 3 media packets and FEC packet#1 lost. 837 // 4 packets lost: 3 media packets and FEC packet#1 lost.
803 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 838 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
804 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 839 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
805 this->fec_loss_mask_[1] = 1; 840 this->fec_loss_mask_[1] = 1;
806 this->media_loss_mask_[0] = 1; 841 this->media_loss_mask_[0] = 1;
807 this->media_loss_mask_[2] = 1; 842 this->media_loss_mask_[2] = 1;
808 this->media_loss_mask_[3] = 1; 843 this->media_loss_mask_[3] = 1;
809 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 844 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
810 845
811 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 846 for (const auto& received_packet : this->received_packets_) {
812 &this->recovered_packets_)); 847 this->fec_.DecodeFec(*received_packet,
848 &this->recovered_packets_);
849 }
813 850
814 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. 851 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery.
815 EXPECT_TRUE(this->IsRecoveryComplete()); 852 EXPECT_TRUE(this->IsRecoveryComplete());
816 this->recovered_packets_.clear(); 853 this->recovered_packets_.clear();
817 854
818 // 5 packets lost: 4 media packets and one FEC packet#2 lost. 855 // 5 packets lost: 4 media packets and one FEC packet#2 lost.
819 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 856 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
820 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 857 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
821 this->fec_loss_mask_[2] = 1; 858 this->fec_loss_mask_[2] = 1;
822 this->media_loss_mask_[0] = 1; 859 this->media_loss_mask_[0] = 1;
823 this->media_loss_mask_[1] = 1; 860 this->media_loss_mask_[1] = 1;
824 this->media_loss_mask_[2] = 1; 861 this->media_loss_mask_[2] = 1;
825 this->media_loss_mask_[3] = 1; 862 this->media_loss_mask_[3] = 1;
826 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 863 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
827 864
828 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 865 for (const auto& received_packet : this->received_packets_) {
829 &this->recovered_packets_)); 866 this->fec_.DecodeFec(*received_packet,
867 &this->recovered_packets_);
868 }
830 869
831 // Cannot get complete recovery for this loss configuration. 870 // Cannot get complete recovery for this loss configuration.
832 EXPECT_FALSE(this->IsRecoveryComplete()); 871 EXPECT_FALSE(this->IsRecoveryComplete());
833 } 872 }
834 873
835 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { 874 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) {
836 constexpr int kNumImportantPackets = 0; 875 constexpr int kNumImportantPackets = 0;
837 constexpr bool kUseUnequalProtection = false; 876 constexpr bool kUseUnequalProtection = false;
838 constexpr int kNumMediaPackets = 5; 877 constexpr int kNumMediaPackets = 5;
839 constexpr uint8_t kProtectionFactor = 60; 878 constexpr uint8_t kProtectionFactor = 60;
(...skipping 13 matching lines...) Expand all
853 892
854 // Expect 1 FEC packet. 893 // Expect 1 FEC packet.
855 EXPECT_EQ(1u, this->generated_fec_packets_.size()); 894 EXPECT_EQ(1u, this->generated_fec_packets_.size());
856 895
857 // 1 protected media packet lost 896 // 1 protected media packet lost
858 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 897 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
859 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 898 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
860 this->media_loss_mask_[2] = 1; 899 this->media_loss_mask_[2] = 1;
861 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 900 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
862 901
863 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 902 for (const auto& received_packet : this->received_packets_) {
864 &this->recovered_packets_)); 903 this->fec_.DecodeFec(*received_packet,
904 &this->recovered_packets_);
905 }
865 906
866 // One packet lost, one FEC packet, expect complete recovery. 907 // One packet lost, one FEC packet, expect complete recovery.
867 EXPECT_TRUE(this->IsRecoveryComplete()); 908 EXPECT_TRUE(this->IsRecoveryComplete());
868 this->recovered_packets_.clear(); 909 this->recovered_packets_.clear();
869 910
870 // Unprotected packet lost. 911 // Unprotected packet lost.
871 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 912 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
872 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 913 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
873 this->media_loss_mask_[1] = 1; 914 this->media_loss_mask_[1] = 1;
874 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 915 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
875 916
876 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 917 for (const auto& received_packet : this->received_packets_) {
877 &this->recovered_packets_)); 918 this->fec_.DecodeFec(*received_packet,
919 &this->recovered_packets_);
920 }
878 921
879 // Unprotected packet lost. Recovery not possible. 922 // Unprotected packet lost. Recovery not possible.
880 EXPECT_FALSE(this->IsRecoveryComplete()); 923 EXPECT_FALSE(this->IsRecoveryComplete());
881 this->recovered_packets_.clear(); 924 this->recovered_packets_.clear();
882 925
883 // 2 media packets lost. 926 // 2 media packets lost.
884 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 927 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
885 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 928 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
886 this->media_loss_mask_[0] = 1; 929 this->media_loss_mask_[0] = 1;
887 this->media_loss_mask_[2] = 1; 930 this->media_loss_mask_[2] = 1;
888 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 931 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
889 932
890 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 933 for (const auto& received_packet : this->received_packets_) {
891 &this->recovered_packets_)); 934 this->fec_.DecodeFec(*received_packet,
935 &this->recovered_packets_);
936 }
892 937
893 // 2 protected packets lost, one FEC packet, cannot get complete recovery. 938 // 2 protected packets lost, one FEC packet, cannot get complete recovery.
894 EXPECT_FALSE(this->IsRecoveryComplete()); 939 EXPECT_FALSE(this->IsRecoveryComplete());
895 } 940 }
896 941
897 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { 942 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) {
898 constexpr int kNumImportantPackets = 0; 943 constexpr int kNumImportantPackets = 0;
899 constexpr bool kUseUnequalProtection = false; 944 constexpr bool kUseUnequalProtection = false;
900 constexpr int kNumMediaPackets = 21; 945 constexpr int kNumMediaPackets = 21;
901 uint8_t kProtectionFactor = 127; 946 uint8_t kProtectionFactor = 127;
(...skipping 16 matching lines...) Expand all
918 963
919 // Expect 5 FEC packet. 964 // Expect 5 FEC packet.
920 EXPECT_EQ(5u, this->generated_fec_packets_.size()); 965 EXPECT_EQ(5u, this->generated_fec_packets_.size());
921 966
922 // Last protected media packet lost 967 // Last protected media packet lost
923 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 968 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
924 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 969 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
925 this->media_loss_mask_[kNumMediaPackets - 1] = 1; 970 this->media_loss_mask_[kNumMediaPackets - 1] = 1;
926 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 971 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
927 972
928 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 973 for (const auto& received_packet : this->received_packets_) {
929 &this->recovered_packets_)); 974 this->fec_.DecodeFec(*received_packet,
975 &this->recovered_packets_);
976 }
930 977
931 // One packet lost, one FEC packet, expect complete recovery. 978 // One packet lost, one FEC packet, expect complete recovery.
932 EXPECT_TRUE(this->IsRecoveryComplete()); 979 EXPECT_TRUE(this->IsRecoveryComplete());
933 this->recovered_packets_.clear(); 980 this->recovered_packets_.clear();
934 981
935 // Last unprotected packet lost. 982 // Last unprotected packet lost.
936 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 983 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
937 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 984 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
938 this->media_loss_mask_[kNumMediaPackets - 2] = 1; 985 this->media_loss_mask_[kNumMediaPackets - 2] = 1;
939 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 986 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
940 987
941 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 988 for (const auto& received_packet : this->received_packets_) {
942 &this->recovered_packets_)); 989 this->fec_.DecodeFec(*received_packet,
990 &this->recovered_packets_);
991 }
943 992
944 // Unprotected packet lost. Recovery not possible. 993 // Unprotected packet lost. Recovery not possible.
945 EXPECT_FALSE(this->IsRecoveryComplete()); 994 EXPECT_FALSE(this->IsRecoveryComplete());
946 this->recovered_packets_.clear(); 995 this->recovered_packets_.clear();
947 996
948 // 6 media packets lost. 997 // 6 media packets lost.
949 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 998 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
950 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 999 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
951 this->media_loss_mask_[kNumMediaPackets - 11] = 1; 1000 this->media_loss_mask_[kNumMediaPackets - 11] = 1;
952 this->media_loss_mask_[kNumMediaPackets - 9] = 1; 1001 this->media_loss_mask_[kNumMediaPackets - 9] = 1;
953 this->media_loss_mask_[kNumMediaPackets - 7] = 1; 1002 this->media_loss_mask_[kNumMediaPackets - 7] = 1;
954 this->media_loss_mask_[kNumMediaPackets - 5] = 1; 1003 this->media_loss_mask_[kNumMediaPackets - 5] = 1;
955 this->media_loss_mask_[kNumMediaPackets - 3] = 1; 1004 this->media_loss_mask_[kNumMediaPackets - 3] = 1;
956 this->media_loss_mask_[kNumMediaPackets - 1] = 1; 1005 this->media_loss_mask_[kNumMediaPackets - 1] = 1;
957 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 1006 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
958 1007
959 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 1008 for (const auto& received_packet : this->received_packets_) {
960 &this->recovered_packets_)); 1009 this->fec_.DecodeFec(*received_packet,
1010 &this->recovered_packets_);
1011 }
961 1012
962 // 5 protected packets lost, one FEC packet, cannot get complete recovery. 1013 // 5 protected packets lost, one FEC packet, cannot get complete recovery.
963 EXPECT_FALSE(this->IsRecoveryComplete()); 1014 EXPECT_FALSE(this->IsRecoveryComplete());
964 } 1015 }
965 1016
966 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { 1017 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) {
967 constexpr int kNumImportantPackets = 0; 1018 constexpr int kNumImportantPackets = 0;
968 constexpr bool kUseUnequalProtection = false; 1019 constexpr bool kUseUnequalProtection = false;
969 constexpr int kNumMediaPackets = 21; 1020 constexpr int kNumMediaPackets = 21;
970 uint8_t kProtectionFactor = 127; 1021 uint8_t kProtectionFactor = 127;
(...skipping 16 matching lines...) Expand all
987 1038
988 // Expect 5 FEC packet. 1039 // Expect 5 FEC packet.
989 EXPECT_EQ(5u, this->generated_fec_packets_.size()); 1040 EXPECT_EQ(5u, this->generated_fec_packets_.size());
990 1041
991 // Last protected media packet lost 1042 // Last protected media packet lost
992 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 1043 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
993 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 1044 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
994 this->media_loss_mask_[kNumMediaPackets - 1] = 1; 1045 this->media_loss_mask_[kNumMediaPackets - 1] = 1;
995 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 1046 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
996 1047
997 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 1048 for (const auto& received_packet : this->received_packets_) {
998 &this->recovered_packets_)); 1049 this->fec_.DecodeFec(*received_packet,
1050 &this->recovered_packets_);
1051 }
999 1052
1000 // One packet lost, one FEC packet, expect complete recovery. 1053 // One packet lost, one FEC packet, expect complete recovery.
1001 EXPECT_TRUE(this->IsRecoveryComplete()); 1054 EXPECT_TRUE(this->IsRecoveryComplete());
1002 this->recovered_packets_.clear(); 1055 this->recovered_packets_.clear();
1003 1056
1004 // Last unprotected packet lost. 1057 // Last unprotected packet lost.
1005 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 1058 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
1006 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 1059 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
1007 this->media_loss_mask_[kNumMediaPackets - 2] = 1; 1060 this->media_loss_mask_[kNumMediaPackets - 2] = 1;
1008 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 1061 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
1009 1062
1010 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 1063 for (const auto& received_packet : this->received_packets_) {
1011 &this->recovered_packets_)); 1064 this->fec_.DecodeFec(*received_packet,
1065 &this->recovered_packets_);
1066 }
1012 1067
1013 // Unprotected packet lost. Recovery not possible. 1068 // Unprotected packet lost. Recovery not possible.
1014 EXPECT_FALSE(this->IsRecoveryComplete()); 1069 EXPECT_FALSE(this->IsRecoveryComplete());
1015 this->recovered_packets_.clear(); 1070 this->recovered_packets_.clear();
1016 1071
1017 // 6 media packets lost. 1072 // 6 media packets lost.
1018 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); 1073 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_));
1019 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); 1074 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
1020 this->media_loss_mask_[kNumMediaPackets - 11] = 1; 1075 this->media_loss_mask_[kNumMediaPackets - 11] = 1;
1021 this->media_loss_mask_[kNumMediaPackets - 9] = 1; 1076 this->media_loss_mask_[kNumMediaPackets - 9] = 1;
1022 this->media_loss_mask_[kNumMediaPackets - 7] = 1; 1077 this->media_loss_mask_[kNumMediaPackets - 7] = 1;
1023 this->media_loss_mask_[kNumMediaPackets - 5] = 1; 1078 this->media_loss_mask_[kNumMediaPackets - 5] = 1;
1024 this->media_loss_mask_[kNumMediaPackets - 3] = 1; 1079 this->media_loss_mask_[kNumMediaPackets - 3] = 1;
1025 this->media_loss_mask_[kNumMediaPackets - 1] = 1; 1080 this->media_loss_mask_[kNumMediaPackets - 1] = 1;
1026 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); 1081 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
1027 1082
1028 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, 1083 for (const auto& received_packet : this->received_packets_) {
1029 &this->recovered_packets_)); 1084 this->fec_.DecodeFec(*received_packet,
1085 &this->recovered_packets_);
1086 }
1030 1087
1031 // 5 protected packets lost, one FEC packet, cannot get complete recovery. 1088 // 5 protected packets lost, one FEC packet, cannot get complete recovery.
1032 EXPECT_FALSE(this->IsRecoveryComplete()); 1089 EXPECT_FALSE(this->IsRecoveryComplete());
1033 } 1090 }
1034 1091
1035 } // namespace webrtc 1092 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698