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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
index 99f16699f37d225884408d900341332bb229a70c..2210de0253625585d59f05ff6652f0476deccaa0 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
@@ -86,7 +86,8 @@ class RtpFecTest : public ::testing::Test {
ForwardErrorCorrection::PacketList media_packets_;
std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_;
- ForwardErrorCorrection::ReceivedPacketList received_packets_;
+ std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>>
+ received_packets_;
ForwardErrorCorrection::RecoveredPacketList recovered_packets_;
int media_loss_mask_[kUlpfecMaxMediaPackets];
@@ -237,8 +238,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNoLoss) {
memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// No packets lost, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -267,8 +270,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// One packet lost, one FEC packet, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -281,8 +286,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// 2 packets lost, one FEC packet, cannot get complete recovery.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -330,8 +337,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) {
// Add packets #65535, and #1 to received list.
this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect that no decoding is done to get missing packet (seq#0) of second
// frame, using old FEC packet (seq#2) from first (old) frame. So number of
@@ -370,8 +379,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) {
this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
true);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect 3 media packets in recovered list, and complete recovery.
// Wrap-around won't remove FEC packet, as it follows the wrap.
@@ -415,8 +426,10 @@ TEST_F(RtpFecTestUlpfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) {
this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
true);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// The two FEC packets are received and should allow for complete recovery,
// but because of the wrap the first FEC packet will be discarded, and only
@@ -468,8 +481,10 @@ TEST_F(RtpFecTestFlexfecOnly, FecRecoveryWithSeqNumGapOneFrameNoRecovery) {
this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_,
true);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// The two FEC packets are received and should allow for complete recovery,
// but because of the wrap the first FEC packet will be discarded, and only
@@ -512,8 +527,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithMediaOutOfOrder) {
it1++;
std::swap(*it0, *it1);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect 3 media packets in recovered list, and complete recovery.
EXPECT_EQ(3u, this->recovered_packets_.size());
@@ -550,8 +567,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) {
// Add media packets to received list.
this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect 3 media packets in recovered list, and complete recovery.
EXPECT_EQ(3u, this->recovered_packets_.size());
@@ -597,8 +616,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// With media packet#1 and FEC packets #1, #2, #3, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -613,8 +634,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Cannot get complete recovery for this loss configuration with random mask.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -659,8 +682,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect complete recovery for consecutive packet loss <= 50%.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -675,8 +700,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Expect complete recovery for consecutive packet loss <= 50%.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -691,8 +718,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Cannot get complete recovery for this loss configuration.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -720,8 +749,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) {
memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_));
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// No packets lost, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -750,8 +781,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// One packet lost, one FEC packet, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -764,8 +797,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// 2 packets lost, one FEC packet, cannot get complete recovery.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -808,8 +843,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// With media packet#3 and FEC packets #0, #1, #3, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -825,8 +862,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) {
this->media_loss_mask_[3] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Cannot get complete recovery for this loss configuration.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -860,8 +899,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) {
this->media_loss_mask_[2] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// One packet lost, one FEC packet, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -873,8 +914,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) {
this->media_loss_mask_[1] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Unprotected packet lost. Recovery not possible.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -887,8 +930,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) {
this->media_loss_mask_[2] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// 2 protected packets lost, one FEC packet, cannot get complete recovery.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -925,8 +970,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) {
this->media_loss_mask_[kNumMediaPackets - 1] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// One packet lost, one FEC packet, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -938,8 +985,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) {
this->media_loss_mask_[kNumMediaPackets - 2] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Unprotected packet lost. Recovery not possible.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -956,8 +1005,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) {
this->media_loss_mask_[kNumMediaPackets - 1] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// 5 protected packets lost, one FEC packet, cannot get complete recovery.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -994,8 +1045,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) {
this->media_loss_mask_[kNumMediaPackets - 1] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// One packet lost, one FEC packet, expect complete recovery.
EXPECT_TRUE(this->IsRecoveryComplete());
@@ -1007,8 +1060,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) {
this->media_loss_mask_[kNumMediaPackets - 2] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// Unprotected packet lost. Recovery not possible.
EXPECT_FALSE(this->IsRecoveryComplete());
@@ -1025,8 +1080,10 @@ TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) {
this->media_loss_mask_[kNumMediaPackets - 1] = 1;
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
- EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_,
- &this->recovered_packets_));
+ for (const auto& received_packet : this->received_packets_) {
+ this->fec_.DecodeFec(*received_packet,
+ &this->recovered_packets_);
+ }
// 5 protected packets lost, one FEC packet, cannot get complete recovery.
EXPECT_FALSE(this->IsRecoveryComplete());

Powered by Google App Engine
This is Rietveld 408576698