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 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <list> | 12 #include <list> |
13 #include <memory> | |
13 | 14 |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/base/random.h" | 16 #include "webrtc/base/random.h" |
16 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
18 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" | |
19 #include "webrtc/modules/rtp_rtcp/source/flexfec_header_reader_writer.h" | |
17 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" | 20 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
21 #include "webrtc/modules/rtp_rtcp/source/ulpfec_header_reader_writer.h" | |
18 | 22 |
19 using webrtc::ForwardErrorCorrection; | 23 namespace webrtc { |
20 | 24 |
21 // Minimum RTP header size in bytes. | 25 namespace { |
22 constexpr uint8_t kRtpHeaderSize = 12; | 26 // Transport header size in bytes. Assume UDP/IPv4 as a reasonable minimum. |
27 constexpr size_t kTransportOverhead = 28; | |
28 } // namespace | |
23 | 29 |
24 // Transport header size in bytes. Assume UDP/IPv4 as a reasonable minimum. | 30 // Subclass ForwardErrorCorrection to use gTest typed tests. |
25 constexpr uint8_t kTransportOverhead = 28; | 31 class UlpfecForwardErrorCorrection : public ForwardErrorCorrection { |
32 public: | |
33 UlpfecForwardErrorCorrection() | |
34 : ForwardErrorCorrection(ForwardErrorCorrection::CreateUlpfec()) {} | |
35 }; | |
26 | 36 |
27 // Maximum number of media packets used in the FEC (RFC 5109). | 37 class FlexfecForwardErrorCorrection : public ForwardErrorCorrection { |
28 constexpr uint8_t kMaxNumberMediaPackets = | 38 public: |
29 ForwardErrorCorrection::kMaxMediaPackets; | 39 FlexfecForwardErrorCorrection() |
40 : ForwardErrorCorrection(ForwardErrorCorrection::CreateFlexfec()) {} | |
41 }; | |
30 | 42 |
31 using PacketList = ForwardErrorCorrection::PacketList; | 43 template <typename S> |
danilchap
2016/08/22 13:00:41
Can you have more descriptional name for this type
brandtr
2016/08/23 08:19:11
Done, see https://codereview.webrtc.org/2267393002
| |
32 using ReceivedPacketList = ForwardErrorCorrection::ReceivedPacketList; | |
33 using RecoveredPacketList = ForwardErrorCorrection::RecoveredPacketList; | |
34 | |
35 class RtpFecTest : public ::testing::Test { | 44 class RtpFecTest : public ::testing::Test { |
36 protected: | 45 protected: |
37 RtpFecTest() | 46 RtpFecTest() |
38 : random_(0xfec133700742), | 47 : random_(0xabcdef123456), |
39 ssrc_(random_.Rand<uint32_t>()), | 48 media_packet_generator_( |
40 fec_seq_num_(0) {} | 49 kRtpHeaderSize, // minimum packet size |
41 | 50 IP_PACKET_SIZE |
42 // Construct the media packet list, up to |num_media_packets| packets. | 51 - kRtpHeaderSize |
43 // Returns the next sequence number after the last media packet. | 52 - kTransportOverhead |
44 // (this will be the sequence of the first FEC packet) | 53 - fec_.MaxPacketOverhead(), // maximum packet size |
45 int ConstructMediaPacketsSeqNum(int num_media_packets, int start_seq_num); | 54 &random_) {} |
46 int ConstructMediaPackets(int num_media_packets); | |
47 | 55 |
48 // Deep copies |src| to |dst|, but only keeps every Nth packet. | 56 // Deep copies |src| to |dst|, but only keeps every Nth packet. |
49 void DeepCopyEveryNthPacket(const PacketList& src, int n, PacketList* dst); | 57 static void DeepCopyEveryNthPacket( |
58 const ForwardErrorCorrection::PacketList& src, | |
59 int n, | |
60 ForwardErrorCorrection::PacketList* dst); | |
50 | 61 |
51 // Construct |received_packet_list_|: a subset of the media and FEC packets. | 62 // Construct |received_packets_|: a subset of the media and FEC packets. |
52 // | 63 // |
53 // Media packet "i" is lost if media_loss_mask_[i] = 1, received if | 64 // Media packet "i" is lost if media_loss_mask_[i] = 1, received if |
54 // media_loss_mask_[i] = 0. | 65 // media_loss_mask_[i] = 0. |
55 // FEC packet "i" is lost if fec_loss_mask_[i] = 1, received if | 66 // FEC packet "i" is lost if fec_loss_mask_[i] = 1, received if |
56 // fec_loss_mask_[i] = 0. | 67 // fec_loss_mask_[i] = 0. |
57 void NetworkReceivedPackets(int* media_loss_mask, int* fec_loss_mask); | 68 void NetworkReceivedPackets(int* media_loss_mask, int* fec_loss_mask); |
58 | 69 |
59 // Add packet from |packet_list| to list of received packets, using the | 70 // Add packet from |packet_list| to list of received packets, using the |
60 // |loss_mask|. | 71 // |loss_mask|. |
61 // The |packet_list| may be a media packet list (is_fec = false), or a | 72 // The |packet_list| may be a media packet list (is_fec = false), or a |
62 // FEC packet list (is_fec = true). | 73 // FEC packet list (is_fec = true). |
63 template <typename T> | 74 template <typename T> |
64 void ReceivedPackets(const T& packet_list, int* loss_mask, bool is_fec); | 75 void ReceivedPackets(const T& packet_list, int* loss_mask, bool is_fec); |
65 | 76 |
66 // Check for complete recovery after FEC decoding. | 77 // Check for complete recovery after FEC decoding. |
67 bool IsRecoveryComplete(); | 78 bool IsRecoveryComplete(); |
68 | 79 |
69 // Delete the media and FEC packets. | 80 S fec_; |
70 void TearDown(); | |
71 | 81 |
72 webrtc::Random random_; | 82 Random random_; |
73 ForwardErrorCorrection fec_; | 83 test::fec::MediaPacketGenerator media_packet_generator_; |
74 int ssrc_; | |
75 uint16_t fec_seq_num_; | |
76 | 84 |
77 PacketList media_packet_list_; | 85 ForwardErrorCorrection::PacketList* media_packets_; |
78 std::list<ForwardErrorCorrection::Packet*> fec_packet_list_; | 86 std::list<ForwardErrorCorrection::Packet*> generated_fec_packets_; |
79 ReceivedPacketList received_packet_list_; | 87 ForwardErrorCorrection::ReceivedPacketList received_packets_; |
80 RecoveredPacketList recovered_packet_list_; | 88 ForwardErrorCorrection::RecoveredPacketList recovered_packets_; |
81 | 89 |
82 int media_loss_mask_[kMaxNumberMediaPackets]; | 90 int media_loss_mask_[kUlpfecMaxMediaPackets]; |
83 int fec_loss_mask_[kMaxNumberMediaPackets]; | 91 int fec_loss_mask_[kUlpfecMaxMediaPackets]; |
84 }; | 92 }; |
85 | 93 |
86 TEST_F(RtpFecTest, FecRecoveryNoLoss) { | 94 // Define gTest typed test to loop over both ULPFEC and FlexFEC. |
95 // Since the tests now are parameterized, we need to access | |
96 // member variables using |this|, thereby enforcing runtime | |
97 // resolution. | |
98 typedef ::testing::Types<UlpfecForwardErrorCorrection, | |
99 FlexfecForwardErrorCorrection> | |
100 FecTypes; | |
101 TYPED_TEST_CASE(RtpFecTest, FecTypes); | |
102 | |
103 TYPED_TEST(RtpFecTest, FecRecoveryNoLoss) { | |
87 constexpr int kNumImportantPackets = 0; | 104 constexpr int kNumImportantPackets = 0; |
88 constexpr bool kUseUnequalProtection = false; | 105 constexpr bool kUseUnequalProtection = false; |
89 constexpr int kNumMediaPackets = 4; | 106 constexpr int kNumMediaPackets = 4; |
90 constexpr uint8_t kProtectionFactor = 60; | 107 constexpr uint8_t kProtectionFactor = 60; |
91 | 108 |
92 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 109 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
110 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
93 | 111 |
94 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 112 EXPECT_EQ( |
95 kNumImportantPackets, kUseUnequalProtection, | 113 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
96 webrtc::kFecMaskBursty, &fec_packet_list_)); | 114 kNumImportantPackets, kUseUnequalProtection, |
115 kFecMaskBursty, &this->generated_fec_packets_)); | |
97 | 116 |
98 // Expect 1 FEC packet. | 117 // Expect 1 FEC packet. |
99 EXPECT_EQ(1u, fec_packet_list_.size()); | 118 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
100 | 119 |
101 // No packets lost. | 120 // No packets lost. |
102 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 121 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
103 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 122 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
104 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 123 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
105 | 124 |
106 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 125 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
126 &this->recovered_packets_)); | |
107 | 127 |
108 // No packets lost, expect complete recovery. | 128 // No packets lost, expect complete recovery. |
109 EXPECT_TRUE(IsRecoveryComplete()); | 129 EXPECT_TRUE(this->IsRecoveryComplete()); |
110 } | 130 } |
111 | 131 |
112 TEST_F(RtpFecTest, FecRecoveryWithLoss) { | 132 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss) { |
113 constexpr int kNumImportantPackets = 0; | 133 constexpr int kNumImportantPackets = 0; |
114 constexpr bool kUseUnequalProtection = false; | 134 constexpr bool kUseUnequalProtection = false; |
115 constexpr int kNumMediaPackets = 4; | 135 constexpr int kNumMediaPackets = 4; |
116 constexpr uint8_t kProtectionFactor = 60; | 136 constexpr uint8_t kProtectionFactor = 60; |
117 | 137 |
118 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 138 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
139 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
119 | 140 |
120 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 141 EXPECT_EQ( |
121 kNumImportantPackets, kUseUnequalProtection, | 142 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
122 webrtc::kFecMaskBursty, &fec_packet_list_)); | 143 kNumImportantPackets, kUseUnequalProtection, |
144 kFecMaskBursty, &this->generated_fec_packets_)); | |
123 | 145 |
124 // Expect 1 FEC packet. | 146 // Expect 1 FEC packet. |
125 EXPECT_EQ(1u, fec_packet_list_.size()); | 147 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
126 | 148 |
127 // 1 media packet lost | 149 // 1 media packet lost |
128 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 150 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
129 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 151 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
130 media_loss_mask_[3] = 1; | 152 this->media_loss_mask_[3] = 1; |
131 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 153 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
132 | 154 |
133 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 155 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
156 &this->recovered_packets_)); | |
134 | 157 |
135 // One packet lost, one FEC packet, expect complete recovery. | 158 // One packet lost, one FEC packet, expect complete recovery. |
136 EXPECT_TRUE(IsRecoveryComplete()); | 159 EXPECT_TRUE(this->IsRecoveryComplete()); |
137 recovered_packet_list_.clear(); | 160 this->recovered_packets_.clear(); |
138 | 161 |
139 // 2 media packets lost. | 162 // 2 media packets lost. |
140 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 163 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
141 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 164 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
142 media_loss_mask_[1] = 1; | 165 this->media_loss_mask_[1] = 1; |
143 media_loss_mask_[3] = 1; | 166 this->media_loss_mask_[3] = 1; |
144 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 167 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
145 | 168 |
146 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 169 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
170 &this->recovered_packets_)); | |
147 | 171 |
148 // 2 packets lost, one FEC packet, cannot get complete recovery. | 172 // 2 packets lost, one FEC packet, cannot get complete recovery. |
149 EXPECT_FALSE(IsRecoveryComplete()); | 173 EXPECT_FALSE(this->IsRecoveryComplete()); |
150 } | 174 } |
151 | 175 |
152 // Verify that we don't use an old FEC packet for FEC decoding. | 176 // Verify that we don't use an old FEC packet for FEC decoding. |
153 TEST_F(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) { | 177 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapTwoFrames) { |
154 constexpr int kNumImportantPackets = 0; | 178 constexpr int kNumImportantPackets = 0; |
155 constexpr bool kUseUnequalProtection = false; | 179 constexpr bool kUseUnequalProtection = false; |
156 constexpr uint8_t kProtectionFactor = 20; | 180 constexpr uint8_t kProtectionFactor = 20; |
157 | 181 |
158 // Two frames: first frame (old) with two media packets and 1 FEC packet. | 182 // Two frames: first frame (old) with two media packets and 1 FEC packet. |
159 // Second frame (new) with 3 media packets, and no FEC packets. | 183 // Second frame (new) with 3 media packets, and no FEC packets. |
160 // ---Frame 1---- ----Frame 2------ | 184 // ---Frame 1---- ----Frame 2------ |
161 // #0(media) #1(media) #2(FEC) #65535(media) #0(media) #1(media). | 185 // #0(media) #1(media) #2(FEC) #65535(media) #0(media) #1(media). |
162 // If we lose either packet 0 or 1 of second frame, FEC decoding should not | 186 // If we lose either packet 0 or 1 of second frame, FEC decoding should not |
163 // try to decode using "old" FEC packet #2. | 187 // try to decode using "old" FEC packet #2. |
164 | 188 |
165 // Construct media packets for first frame, starting at sequence number 0. | 189 // Construct media packets for first frame, starting at sequence number 0. |
166 fec_seq_num_ = ConstructMediaPacketsSeqNum(2, 0); | 190 this->media_packet_generator_.ConstructMediaPacketsSeqNum(2, 0); |
191 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
167 | 192 |
168 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 193 EXPECT_EQ( |
169 kNumImportantPackets, kUseUnequalProtection, | 194 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
170 webrtc::kFecMaskBursty, &fec_packet_list_)); | 195 kNumImportantPackets, kUseUnequalProtection, |
196 kFecMaskBursty, &this->generated_fec_packets_)); | |
171 // Expect 1 FEC packet. | 197 // Expect 1 FEC packet. |
172 EXPECT_EQ(1u, fec_packet_list_.size()); | 198 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
173 // Add FEC packet (seq#2) of this first frame to received list (i.e., assume | 199 // Add FEC packet (seq#2) of this first frame to received list (i.e., assume |
174 // the two media packet were lost). | 200 // the two media packet were lost). |
175 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 201 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
176 ReceivedPackets(fec_packet_list_, fec_loss_mask_, true); | 202 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
203 true); | |
177 | 204 |
178 // Construct media packets for second frame, with sequence number wrap. | 205 // Construct media packets for second frame, with sequence number wrap. |
179 media_packet_list_.clear(); | 206 this->media_packets_->clear(); |
180 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 65535); | 207 this->media_packet_generator_.ConstructMediaPacketsSeqNum(3, 65535); |
208 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
181 | 209 |
182 // Expect 3 media packets for this frame. | 210 // Expect 3 media packets for this frame. |
183 EXPECT_EQ(3u, media_packet_list_.size()); | 211 EXPECT_EQ(3u, this->media_packets_->size()); |
184 | 212 |
185 // Second media packet lost (seq#0). | 213 // Second media packet lost (seq#0). |
186 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 214 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
187 media_loss_mask_[1] = 1; | 215 this->media_loss_mask_[1] = 1; |
188 // Add packets #65535, and #1 to received list. | 216 // Add packets #65535, and #1 to received list. |
189 ReceivedPackets(media_packet_list_, media_loss_mask_, false); | 217 this->ReceivedPackets(*this->media_packets_, this->media_loss_mask_, false); |
190 | 218 |
191 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 219 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
220 &this->recovered_packets_)); | |
192 | 221 |
193 // Expect that no decoding is done to get missing packet (seq#0) of second | 222 // Expect that no decoding is done to get missing packet (seq#0) of second |
194 // frame, using old FEC packet (seq#2) from first (old) frame. So number of | 223 // frame, using old FEC packet (seq#2) from first (old) frame. So number of |
195 // recovered packets is 2, and not equal to number of media packets (=3). | 224 // recovered packets is 2, and not equal to number of media packets (=3). |
196 EXPECT_EQ(2u, recovered_packet_list_.size()); | 225 EXPECT_EQ(2u, this->recovered_packets_.size()); |
197 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); | 226 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_->size()); |
198 } | 227 } |
199 | 228 |
200 // Verify we can still recover frame if sequence number wrap occurs within | 229 // Verify we can still recover frame if sequence number wrap occurs within |
201 // the frame and FEC packet following wrap is received after media packets. | 230 // the frame and FEC packet following wrap is received after media packets. |
202 TEST_F(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) { | 231 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) { |
203 constexpr int kNumImportantPackets = 0; | 232 constexpr int kNumImportantPackets = 0; |
204 constexpr bool kUseUnequalProtection = false; | 233 constexpr bool kUseUnequalProtection = false; |
205 constexpr uint8_t kProtectionFactor = 20; | 234 constexpr uint8_t kProtectionFactor = 20; |
206 | 235 |
207 // One frame, with sequence number wrap in media packets. | 236 // One frame, with sequence number wrap in media packets. |
208 // -----Frame 1---- | 237 // -----Frame 1---- |
209 // #65534(media) #65535(media) #0(media) #1(FEC). | 238 // #65534(media) #65535(media) #0(media) #1(FEC). |
210 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 65534); | 239 this->media_packet_generator_.ConstructMediaPacketsSeqNum(3, 65534); |
240 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
211 | 241 |
212 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 242 EXPECT_EQ( |
213 kNumImportantPackets, kUseUnequalProtection, | 243 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
214 webrtc::kFecMaskBursty, &fec_packet_list_)); | 244 kNumImportantPackets, kUseUnequalProtection, |
245 kFecMaskBursty, &this->generated_fec_packets_)); | |
215 | 246 |
216 // Expect 1 FEC packet. | 247 // Expect 1 FEC packet. |
217 EXPECT_EQ(1u, fec_packet_list_.size()); | 248 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
218 | 249 |
219 // Lose one media packet (seq# 65535). | 250 // Lose one media packet (seq# 65535). |
220 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 251 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
221 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 252 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
222 media_loss_mask_[1] = 1; | 253 this->media_loss_mask_[1] = 1; |
223 ReceivedPackets(media_packet_list_, media_loss_mask_, false); | 254 this->ReceivedPackets(*this->media_packets_, this->media_loss_mask_, false); |
224 // Add FEC packet to received list following the media packets. | 255 // Add FEC packet to received list following the media packets. |
225 ReceivedPackets(fec_packet_list_, fec_loss_mask_, true); | 256 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
257 true); | |
226 | 258 |
227 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 259 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
260 &this->recovered_packets_)); | |
228 | 261 |
229 // Expect 3 media packets in recovered list, and complete recovery. | 262 // Expect 3 media packets in recovered list, and complete recovery. |
230 // Wrap-around won't remove FEC packet, as it follows the wrap. | 263 // Wrap-around won't remove FEC packet, as it follows the wrap. |
231 EXPECT_EQ(3u, recovered_packet_list_.size()); | 264 EXPECT_EQ(3u, this->recovered_packets_.size()); |
232 EXPECT_TRUE(IsRecoveryComplete()); | 265 EXPECT_TRUE(this->IsRecoveryComplete()); |
233 } | 266 } |
234 | 267 |
235 // Sequence number wrap occurs within the FEC packets for the frame. | 268 // Sequence number wrap occurs within the FEC packets for the frame. |
236 // In this case we will discard FEC packet and full recovery is not expected. | 269 // In this case we will discard FEC packet and full recovery is not expected. |
237 // Same problem will occur if wrap is within media packets but FEC packet is | 270 // Same problem will occur if wrap is within media packets but FEC packet is |
238 // received before the media packets. This may be improved if timing information | 271 // received before the media packets. This may be improved if timing information |
239 // is used to detect old FEC packets. | 272 // is used to detect old FEC packets. |
240 // TODO(marpan): Update test if wrap-around handling changes in FEC decoding. | 273 // TODO(marpan): Update test if wrap-around handling changes in FEC decoding. |
241 TEST_F(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { | 274 TYPED_TEST(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameNoRecovery) { |
242 constexpr int kNumImportantPackets = 0; | 275 constexpr int kNumImportantPackets = 0; |
243 constexpr bool kUseUnequalProtection = false; | 276 constexpr bool kUseUnequalProtection = false; |
244 constexpr uint8_t kProtectionFactor = 200; | 277 constexpr uint8_t kProtectionFactor = 200; |
245 | 278 |
246 // 1 frame: 3 media packets and 2 FEC packets. | 279 // 1 frame: 3 media packets and 2 FEC packets. |
247 // Sequence number wrap in FEC packets. | 280 // Sequence number wrap in FEC packets. |
248 // -----Frame 1---- | 281 // -----Frame 1---- |
249 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). | 282 // #65532(media) #65533(media) #65534(media) #65535(FEC) #0(FEC). |
250 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 65532); | 283 this->media_packet_generator_.ConstructMediaPacketsSeqNum(3, 65532); |
284 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
251 | 285 |
252 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 286 EXPECT_EQ( |
253 kNumImportantPackets, kUseUnequalProtection, | 287 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
254 webrtc::kFecMaskBursty, &fec_packet_list_)); | 288 kNumImportantPackets, kUseUnequalProtection, |
289 kFecMaskBursty, &this->generated_fec_packets_)); | |
255 | 290 |
256 // Expect 2 FEC packets. | 291 // Expect 2 FEC packets. |
257 EXPECT_EQ(2u, fec_packet_list_.size()); | 292 EXPECT_EQ(2u, this->generated_fec_packets_.size()); |
258 | 293 |
259 // Lose the last two media packets (seq# 65533, 65534). | 294 // Lose the last two media packets (seq# 65533, 65534). |
260 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 295 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
261 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 296 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
262 media_loss_mask_[1] = 1; | 297 this->media_loss_mask_[1] = 1; |
263 media_loss_mask_[2] = 1; | 298 this->media_loss_mask_[2] = 1; |
264 ReceivedPackets(media_packet_list_, media_loss_mask_, false); | 299 this->ReceivedPackets(*this->media_packets_, this->media_loss_mask_, false); |
265 ReceivedPackets(fec_packet_list_, fec_loss_mask_, true); | 300 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
301 true); | |
266 | 302 |
267 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 303 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
304 &this->recovered_packets_)); | |
268 | 305 |
269 // The two FEC packets are received and should allow for complete recovery, | 306 // The two FEC packets are received and should allow for complete recovery, |
270 // but because of the wrap the second FEC packet will be discarded, and only | 307 // but because of the wrap the second FEC packet will be discarded, and only |
271 // one media packet is recoverable. So exepct 2 media packets on recovered | 308 // one media packet is recoverable. So exepct 2 media packets on recovered |
272 // list and no complete recovery. | 309 // list and no complete recovery. |
273 EXPECT_EQ(2u, recovered_packet_list_.size()); | 310 EXPECT_EQ(2u, this->recovered_packets_.size()); |
274 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); | 311 EXPECT_TRUE(this->recovered_packets_.size() != this->media_packets_->size()); |
275 EXPECT_FALSE(IsRecoveryComplete()); | 312 EXPECT_FALSE(this->IsRecoveryComplete()); |
276 } | 313 } |
277 | 314 |
278 // Verify we can still recover frame if media packets are reordered. | 315 // Verify we can still recover frame if media packets are reordered. |
279 TEST_F(RtpFecTest, FecRecoveryWithMediaOutOfOrder) { | 316 TYPED_TEST(RtpFecTest, FecRecoveryWithMediaOutOfOrder) { |
280 constexpr int kNumImportantPackets = 0; | 317 constexpr int kNumImportantPackets = 0; |
281 constexpr bool kUseUnequalProtection = false; | 318 constexpr bool kUseUnequalProtection = false; |
282 constexpr uint8_t kProtectionFactor = 20; | 319 constexpr uint8_t kProtectionFactor = 20; |
283 | 320 |
284 // One frame: 3 media packets, 1 FEC packet. | 321 // One frame: 3 media packets, 1 FEC packet. |
285 // -----Frame 1---- | 322 // -----Frame 1---- |
286 // #0(media) #1(media) #2(media) #3(FEC). | 323 // #0(media) #1(media) #2(media) #3(FEC). |
287 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 0); | 324 this->media_packet_generator_.ConstructMediaPacketsSeqNum(3, 0); |
325 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
288 | 326 |
289 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 327 EXPECT_EQ( |
290 kNumImportantPackets, kUseUnequalProtection, | 328 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
291 webrtc::kFecMaskBursty, &fec_packet_list_)); | 329 kNumImportantPackets, kUseUnequalProtection, |
330 kFecMaskBursty, &this->generated_fec_packets_)); | |
292 | 331 |
293 // Expect 1 FEC packet. | 332 // Expect 1 FEC packet. |
294 EXPECT_EQ(1u, fec_packet_list_.size()); | 333 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
295 | 334 |
296 // Lose one media packet (seq# 1). | 335 // Lose one media packet (seq# 1). |
297 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 336 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
298 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 337 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
299 media_loss_mask_[1] = 1; | 338 this->media_loss_mask_[1] = 1; |
300 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 339 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
301 | 340 |
302 // Reorder received media packets. | 341 // Reorder received media packets. |
303 auto it0 = received_packet_list_.begin(); | 342 auto it0 = this->received_packets_.begin(); |
304 auto it2 = received_packet_list_.begin(); | 343 auto it2 = this->received_packets_.begin(); |
305 it2++; | 344 it2++; |
306 std::swap(*it0, *it2); | 345 std::swap(*it0, *it2); |
307 | 346 |
308 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 347 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
348 &this->recovered_packets_)); | |
309 | 349 |
310 // Expect 3 media packets in recovered list, and complete recovery. | 350 // Expect 3 media packets in recovered list, and complete recovery. |
311 EXPECT_EQ(3u, recovered_packet_list_.size()); | 351 EXPECT_EQ(3u, this->recovered_packets_.size()); |
312 EXPECT_TRUE(IsRecoveryComplete()); | 352 EXPECT_TRUE(this->IsRecoveryComplete()); |
313 } | 353 } |
314 | 354 |
315 // Verify we can still recover frame if FEC is received before media packets. | 355 // Verify we can still recover frame if FEC is received before media packets. |
316 TEST_F(RtpFecTest, FecRecoveryWithFecOutOfOrder) { | 356 TYPED_TEST(RtpFecTest, FecRecoveryWithFecOutOfOrder) { |
317 constexpr int kNumImportantPackets = 0; | 357 constexpr int kNumImportantPackets = 0; |
318 constexpr bool kUseUnequalProtection = false; | 358 constexpr bool kUseUnequalProtection = false; |
319 constexpr uint8_t kProtectionFactor = 20; | 359 constexpr uint8_t kProtectionFactor = 20; |
320 | 360 |
321 // One frame: 3 media packets, 1 FEC packet. | 361 // One frame: 3 media packets, 1 FEC packet. |
322 // -----Frame 1---- | 362 // -----Frame 1---- |
323 // #0(media) #1(media) #2(media) #3(FEC). | 363 // #0(media) #1(media) #2(media) #3(FEC). |
324 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 0); | 364 this->media_packet_generator_.ConstructMediaPacketsSeqNum(3, 0); |
365 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
325 | 366 |
326 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 367 EXPECT_EQ( |
327 kNumImportantPackets, kUseUnequalProtection, | 368 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
328 webrtc::kFecMaskBursty, &fec_packet_list_)); | 369 kNumImportantPackets, kUseUnequalProtection, |
370 kFecMaskBursty, &this->generated_fec_packets_)); | |
329 | 371 |
330 // Expect 1 FEC packet. | 372 // Expect 1 FEC packet. |
331 EXPECT_EQ(1u, fec_packet_list_.size()); | 373 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
332 | 374 |
333 // Lose one media packet (seq# 1). | 375 // Lose one media packet (seq# 1). |
334 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 376 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
335 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 377 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
336 media_loss_mask_[1] = 1; | 378 this->media_loss_mask_[1] = 1; |
337 // Add FEC packet to received list before the media packets. | 379 // Add FEC packet to received list before the media packets. |
338 ReceivedPackets(fec_packet_list_, fec_loss_mask_, true); | 380 this->ReceivedPackets(this->generated_fec_packets_, this->fec_loss_mask_, |
381 true); | |
339 // Add media packets to received list. | 382 // Add media packets to received list. |
340 ReceivedPackets(media_packet_list_, media_loss_mask_, false); | 383 this->ReceivedPackets(*this->media_packets_, this->media_loss_mask_, false); |
341 | 384 |
342 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 385 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
386 &this->recovered_packets_)); | |
343 | 387 |
344 // Expect 3 media packets in recovered list, and complete recovery. | 388 // Expect 3 media packets in recovered list, and complete recovery. |
345 EXPECT_EQ(3u, recovered_packet_list_.size()); | 389 EXPECT_EQ(3u, this->recovered_packets_.size()); |
346 EXPECT_TRUE(IsRecoveryComplete()); | 390 EXPECT_TRUE(this->IsRecoveryComplete()); |
347 } | 391 } |
348 | 392 |
349 // Test 50% protection with random mask type: Two cases are considered: | 393 // Test 50% protection with random mask type: Two cases are considered: |
350 // a 50% non-consecutive loss which can be fully recovered, and a 50% | 394 // a 50% non-consecutive loss which can be fully recovered, and a 50% |
351 // consecutive loss which cannot be fully recovered. | 395 // consecutive loss which cannot be fully recovered. |
352 TEST_F(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { | 396 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percRandomMask) { |
353 constexpr int kNumImportantPackets = 0; | 397 constexpr int kNumImportantPackets = 0; |
354 constexpr bool kUseUnequalProtection = false; | 398 constexpr bool kUseUnequalProtection = false; |
355 constexpr int kNumMediaPackets = 4; | 399 constexpr int kNumMediaPackets = 4; |
356 constexpr uint8_t kProtectionFactor = 255; | 400 constexpr uint8_t kProtectionFactor = 255; |
357 | 401 |
358 // Packet Mask for (4,4,0) code, from random mask table. | 402 // Packet Mask for (4,4,0) code, from random mask table. |
359 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 0) | 403 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 0) |
360 | 404 |
361 // media#0 media#1 media#2 media#3 | 405 // media#0 media#1 media#2 media#3 |
362 // fec#0: 1 1 0 0 | 406 // fec#0: 1 1 0 0 |
363 // fec#1: 1 0 1 0 | 407 // fec#1: 1 0 1 0 |
364 // fec#2: 0 0 1 1 | 408 // fec#2: 0 0 1 1 |
365 // fec#3: 0 1 0 1 | 409 // fec#3: 0 1 0 1 |
366 // | 410 // |
367 | 411 |
368 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 412 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
413 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
369 | 414 |
370 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 415 EXPECT_EQ( |
371 kNumImportantPackets, kUseUnequalProtection, | 416 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
372 webrtc::kFecMaskRandom, &fec_packet_list_)); | 417 kNumImportantPackets, kUseUnequalProtection, |
418 kFecMaskRandom, &this->generated_fec_packets_)); | |
373 | 419 |
374 // Expect 4 FEC packets. | 420 // Expect 4 FEC packets. |
375 EXPECT_EQ(4u, fec_packet_list_.size()); | 421 EXPECT_EQ(4u, this->generated_fec_packets_.size()); |
376 | 422 |
377 // 4 packets lost: 3 media packets (0, 2, 3), and one FEC packet (0) lost. | 423 // 4 packets lost: 3 media packets (0, 2, 3), and one FEC packet (0) lost. |
378 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 424 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
379 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 425 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
380 fec_loss_mask_[0] = 1; | 426 this->fec_loss_mask_[0] = 1; |
381 media_loss_mask_[0] = 1; | 427 this->media_loss_mask_[0] = 1; |
382 media_loss_mask_[2] = 1; | 428 this->media_loss_mask_[2] = 1; |
383 media_loss_mask_[3] = 1; | 429 this->media_loss_mask_[3] = 1; |
384 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 430 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
385 | 431 |
386 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 432 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
433 &this->recovered_packets_)); | |
387 | 434 |
388 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. | 435 // With media packet#1 and FEC packets #1, #2, #3, expect complete recovery. |
389 EXPECT_TRUE(IsRecoveryComplete()); | 436 EXPECT_TRUE(this->IsRecoveryComplete()); |
390 recovered_packet_list_.clear(); | 437 this->recovered_packets_.clear(); |
391 | 438 |
392 // 4 consecutive packets lost: media packets 0, 1, 2, 3. | 439 // 4 consecutive packets lost: media packets 0, 1, 2, 3. |
393 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 440 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
394 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 441 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
395 media_loss_mask_[0] = 1; | 442 this->media_loss_mask_[0] = 1; |
396 media_loss_mask_[1] = 1; | 443 this->media_loss_mask_[1] = 1; |
397 media_loss_mask_[2] = 1; | 444 this->media_loss_mask_[2] = 1; |
398 media_loss_mask_[3] = 1; | 445 this->media_loss_mask_[3] = 1; |
399 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 446 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
400 | 447 |
401 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 448 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
449 &this->recovered_packets_)); | |
402 | 450 |
403 // Cannot get complete recovery for this loss configuration with random mask. | 451 // Cannot get complete recovery for this loss configuration with random mask. |
404 EXPECT_FALSE(IsRecoveryComplete()); | 452 EXPECT_FALSE(this->IsRecoveryComplete()); |
405 } | 453 } |
406 | 454 |
407 // Test 50% protection with bursty type: Three cases are considered: | 455 // Test 50% protection with bursty type: Three cases are considered: |
408 // two 50% consecutive losses which can be fully recovered, and one | 456 // two 50% consecutive losses which can be fully recovered, and one |
409 // non-consecutive which cannot be fully recovered. | 457 // non-consecutive which cannot be fully recovered. |
410 TEST_F(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { | 458 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percBurstyMask) { |
411 constexpr int kNumImportantPackets = 0; | 459 constexpr int kNumImportantPackets = 0; |
412 constexpr bool kUseUnequalProtection = false; | 460 constexpr bool kUseUnequalProtection = false; |
413 constexpr int kNumMediaPackets = 4; | 461 constexpr int kNumMediaPackets = 4; |
414 constexpr uint8_t kProtectionFactor = 255; | 462 constexpr uint8_t kProtectionFactor = 255; |
415 | 463 |
416 // Packet Mask for (4,4,0) code, from bursty mask table. | 464 // Packet Mask for (4,4,0) code, from bursty mask table. |
417 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 0) | 465 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 0) |
418 | 466 |
419 // media#0 media#1 media#2 media#3 | 467 // media#0 media#1 media#2 media#3 |
420 // fec#0: 1 0 0 0 | 468 // fec#0: 1 0 0 0 |
421 // fec#1: 1 1 0 0 | 469 // fec#1: 1 1 0 0 |
422 // fec#2: 0 1 1 0 | 470 // fec#2: 0 1 1 0 |
423 // fec#3: 0 0 1 1 | 471 // fec#3: 0 0 1 1 |
424 // | 472 // |
425 | 473 |
426 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 474 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
475 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
427 | 476 |
428 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 477 EXPECT_EQ( |
429 kNumImportantPackets, kUseUnequalProtection, | 478 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
430 webrtc::kFecMaskBursty, &fec_packet_list_)); | 479 kNumImportantPackets, kUseUnequalProtection, |
480 kFecMaskBursty, &this->generated_fec_packets_)); | |
431 | 481 |
432 // Expect 4 FEC packets. | 482 // Expect 4 FEC packets. |
433 EXPECT_EQ(4u, fec_packet_list_.size()); | 483 EXPECT_EQ(4u, this->generated_fec_packets_.size()); |
434 | 484 |
435 // 4 consecutive packets lost: media packets 0,1,2,3. | 485 // 4 consecutive packets lost: media packets 0,1,2,3. |
436 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 486 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
437 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 487 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
438 media_loss_mask_[0] = 1; | 488 this->media_loss_mask_[0] = 1; |
439 media_loss_mask_[1] = 1; | 489 this->media_loss_mask_[1] = 1; |
440 media_loss_mask_[2] = 1; | 490 this->media_loss_mask_[2] = 1; |
441 media_loss_mask_[3] = 1; | 491 this->media_loss_mask_[3] = 1; |
442 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 492 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
443 | 493 |
444 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 494 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
495 &this->recovered_packets_)); | |
445 | 496 |
446 // Expect complete recovery for consecutive packet loss <= 50%. | 497 // Expect complete recovery for consecutive packet loss <= 50%. |
447 EXPECT_TRUE(IsRecoveryComplete()); | 498 EXPECT_TRUE(this->IsRecoveryComplete()); |
448 recovered_packet_list_.clear(); | 499 this->recovered_packets_.clear(); |
449 | 500 |
450 // 4 consecutive packets lost: media packets 1,2, 3, and FEC packet 0. | 501 // 4 consecutive packets lost: media packets 1,2, 3, and FEC packet 0. |
451 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 502 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
452 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 503 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
453 fec_loss_mask_[0] = 1; | 504 this->fec_loss_mask_[0] = 1; |
454 media_loss_mask_[1] = 1; | 505 this->media_loss_mask_[1] = 1; |
455 media_loss_mask_[2] = 1; | 506 this->media_loss_mask_[2] = 1; |
456 media_loss_mask_[3] = 1; | 507 this->media_loss_mask_[3] = 1; |
457 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 508 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
458 | 509 |
459 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 510 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
511 &this->recovered_packets_)); | |
460 | 512 |
461 // Expect complete recovery for consecutive packet loss <= 50%. | 513 // Expect complete recovery for consecutive packet loss <= 50%. |
462 EXPECT_TRUE(IsRecoveryComplete()); | 514 EXPECT_TRUE(this->IsRecoveryComplete()); |
463 recovered_packet_list_.clear(); | 515 this->recovered_packets_.clear(); |
464 | 516 |
465 // 4 packets lost (non-consecutive loss): media packets 0, 3, and FEC# 0, 3. | 517 // 4 packets lost (non-consecutive loss): media packets 0, 3, and FEC# 0, 3. |
466 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 518 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
467 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 519 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
468 fec_loss_mask_[0] = 1; | 520 this->fec_loss_mask_[0] = 1; |
469 fec_loss_mask_[3] = 1; | 521 this->fec_loss_mask_[3] = 1; |
470 media_loss_mask_[0] = 1; | 522 this->media_loss_mask_[0] = 1; |
471 media_loss_mask_[3] = 1; | 523 this->media_loss_mask_[3] = 1; |
472 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 524 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
473 | 525 |
474 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 526 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
527 &this->recovered_packets_)); | |
475 | 528 |
476 // Cannot get complete recovery for this loss configuration. | 529 // Cannot get complete recovery for this loss configuration. |
477 EXPECT_FALSE(IsRecoveryComplete()); | 530 EXPECT_FALSE(this->IsRecoveryComplete()); |
478 } | 531 } |
479 | 532 |
480 TEST_F(RtpFecTest, FecRecoveryNoLossUep) { | 533 TYPED_TEST(RtpFecTest, FecRecoveryNoLossUep) { |
481 constexpr int kNumImportantPackets = 2; | 534 constexpr int kNumImportantPackets = 2; |
482 constexpr bool kUseUnequalProtection = true; | 535 constexpr bool kUseUnequalProtection = true; |
483 constexpr int kNumMediaPackets = 4; | 536 constexpr int kNumMediaPackets = 4; |
484 constexpr uint8_t kProtectionFactor = 60; | 537 constexpr uint8_t kProtectionFactor = 60; |
485 | 538 |
486 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 539 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
540 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
487 | 541 |
488 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 542 EXPECT_EQ( |
489 kNumImportantPackets, kUseUnequalProtection, | 543 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
490 webrtc::kFecMaskBursty, &fec_packet_list_)); | 544 kNumImportantPackets, kUseUnequalProtection, |
545 kFecMaskBursty, &this->generated_fec_packets_)); | |
491 | 546 |
492 // Expect 1 FEC packet. | 547 // Expect 1 FEC packet. |
493 EXPECT_EQ(1u, fec_packet_list_.size()); | 548 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
494 | 549 |
495 // No packets lost. | 550 // No packets lost. |
496 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 551 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
497 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 552 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
498 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 553 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
499 | 554 |
500 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 555 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
556 &this->recovered_packets_)); | |
501 | 557 |
502 // No packets lost, expect complete recovery. | 558 // No packets lost, expect complete recovery. |
503 EXPECT_TRUE(IsRecoveryComplete()); | 559 EXPECT_TRUE(this->IsRecoveryComplete()); |
504 } | 560 } |
505 | 561 |
506 TEST_F(RtpFecTest, FecRecoveryWithLossUep) { | 562 TYPED_TEST(RtpFecTest, FecRecoveryWithLossUep) { |
507 constexpr int kNumImportantPackets = 2; | 563 constexpr int kNumImportantPackets = 2; |
508 constexpr bool kUseUnequalProtection = true; | 564 constexpr bool kUseUnequalProtection = true; |
509 constexpr int kNumMediaPackets = 4; | 565 constexpr int kNumMediaPackets = 4; |
510 constexpr uint8_t kProtectionFactor = 60; | 566 constexpr uint8_t kProtectionFactor = 60; |
511 | 567 |
512 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 568 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
569 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
513 | 570 |
514 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 571 EXPECT_EQ( |
515 kNumImportantPackets, kUseUnequalProtection, | 572 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
516 webrtc::kFecMaskBursty, &fec_packet_list_)); | 573 kNumImportantPackets, kUseUnequalProtection, |
574 kFecMaskBursty, &this->generated_fec_packets_)); | |
517 | 575 |
518 // Expect 1 FEC packet. | 576 // Expect 1 FEC packet. |
519 EXPECT_EQ(1u, fec_packet_list_.size()); | 577 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
520 | 578 |
521 // 1 media packet lost. | 579 // 1 media packet lost. |
522 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 580 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
523 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 581 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
524 media_loss_mask_[3] = 1; | 582 this->media_loss_mask_[3] = 1; |
525 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 583 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
526 | 584 |
527 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 585 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
586 &this->recovered_packets_)); | |
528 | 587 |
529 // One packet lost, one FEC packet, expect complete recovery. | 588 // One packet lost, one FEC packet, expect complete recovery. |
530 EXPECT_TRUE(IsRecoveryComplete()); | 589 EXPECT_TRUE(this->IsRecoveryComplete()); |
531 recovered_packet_list_.clear(); | 590 this->recovered_packets_.clear(); |
532 | 591 |
533 // 2 media packets lost. | 592 // 2 media packets lost. |
534 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 593 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
535 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 594 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
536 media_loss_mask_[1] = 1; | 595 this->media_loss_mask_[1] = 1; |
537 media_loss_mask_[3] = 1; | 596 this->media_loss_mask_[3] = 1; |
538 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 597 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
539 | 598 |
540 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 599 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
600 &this->recovered_packets_)); | |
541 | 601 |
542 // 2 packets lost, one FEC packet, cannot get complete recovery. | 602 // 2 packets lost, one FEC packet, cannot get complete recovery. |
543 EXPECT_FALSE(IsRecoveryComplete()); | 603 EXPECT_FALSE(this->IsRecoveryComplete()); |
544 } | 604 } |
545 | 605 |
546 // Test 50% protection with random mask type for UEP on. | 606 // Test 50% protection with random mask type for UEP on. |
547 TEST_F(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { | 607 TYPED_TEST(RtpFecTest, FecRecoveryWithLoss50percUepRandomMask) { |
548 constexpr int kNumImportantPackets = 1; | 608 constexpr int kNumImportantPackets = 1; |
549 constexpr bool kUseUnequalProtection = true; | 609 constexpr bool kUseUnequalProtection = true; |
550 constexpr int kNumMediaPackets = 4; | 610 constexpr int kNumMediaPackets = 4; |
551 constexpr uint8_t kProtectionFactor = 255; | 611 constexpr uint8_t kProtectionFactor = 255; |
552 | 612 |
553 // Packet Mask for (4,4,1) code, from random mask table. | 613 // Packet Mask for (4,4,1) code, from random mask table. |
554 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 1) | 614 // (kNumMediaPackets = 4; num_fec_packets = 4, kNumImportantPackets = 1) |
555 | 615 |
556 // media#0 media#1 media#2 media#3 | 616 // media#0 media#1 media#2 media#3 |
557 // fec#0: 1 0 0 0 | 617 // fec#0: 1 0 0 0 |
558 // fec#1: 1 1 0 0 | 618 // fec#1: 1 1 0 0 |
559 // fec#2: 1 0 1 1 | 619 // fec#2: 1 0 1 1 |
560 // fec#3: 0 1 1 0 | 620 // fec#3: 0 1 1 0 |
561 // | 621 // |
562 | 622 |
563 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 623 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
564 | 624 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); |
565 EXPECT_EQ(0, fec_.GenerateFec(media_packet_list_, kProtectionFactor, | 625 |
566 kNumImportantPackets, kUseUnequalProtection, | 626 EXPECT_EQ( |
567 webrtc::kFecMaskRandom, &fec_packet_list_)); | 627 0, this->fec_.EncodeFec(*this->media_packets_, kProtectionFactor, |
628 kNumImportantPackets, kUseUnequalProtection, | |
629 kFecMaskRandom, &this->generated_fec_packets_)); | |
568 | 630 |
569 // Expect 4 FEC packets. | 631 // Expect 4 FEC packets. |
570 EXPECT_EQ(4u, fec_packet_list_.size()); | 632 EXPECT_EQ(4u, this->generated_fec_packets_.size()); |
571 | 633 |
572 // 4 packets lost: 3 media packets and FEC packet#1 lost. | 634 // 4 packets lost: 3 media packets and FEC packet#1 lost. |
573 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 635 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
574 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 636 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
575 fec_loss_mask_[1] = 1; | 637 this->fec_loss_mask_[1] = 1; |
576 media_loss_mask_[0] = 1; | 638 this->media_loss_mask_[0] = 1; |
577 media_loss_mask_[2] = 1; | 639 this->media_loss_mask_[2] = 1; |
578 media_loss_mask_[3] = 1; | 640 this->media_loss_mask_[3] = 1; |
579 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 641 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
580 | 642 |
581 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 643 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
644 &this->recovered_packets_)); | |
582 | 645 |
583 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. | 646 // With media packet#3 and FEC packets #0, #1, #3, expect complete recovery. |
584 EXPECT_TRUE(IsRecoveryComplete()); | 647 EXPECT_TRUE(this->IsRecoveryComplete()); |
585 recovered_packet_list_.clear(); | 648 this->recovered_packets_.clear(); |
586 | 649 |
587 // 5 packets lost: 4 media packets and one FEC packet#2 lost. | 650 // 5 packets lost: 4 media packets and one FEC packet#2 lost. |
588 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 651 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
589 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 652 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
590 fec_loss_mask_[2] = 1; | 653 this->fec_loss_mask_[2] = 1; |
591 media_loss_mask_[0] = 1; | 654 this->media_loss_mask_[0] = 1; |
592 media_loss_mask_[1] = 1; | 655 this->media_loss_mask_[1] = 1; |
593 media_loss_mask_[2] = 1; | 656 this->media_loss_mask_[2] = 1; |
594 media_loss_mask_[3] = 1; | 657 this->media_loss_mask_[3] = 1; |
595 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 658 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
596 | 659 |
597 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 660 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
661 &this->recovered_packets_)); | |
598 | 662 |
599 // Cannot get complete recovery for this loss configuration. | 663 // Cannot get complete recovery for this loss configuration. |
600 EXPECT_FALSE(IsRecoveryComplete()); | 664 EXPECT_FALSE(this->IsRecoveryComplete()); |
601 } | 665 } |
602 | 666 |
603 TEST_F(RtpFecTest, FecRecoveryNonConsecutivePackets) { | 667 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePackets) { |
604 constexpr int kNumImportantPackets = 0; | 668 constexpr int kNumImportantPackets = 0; |
605 constexpr bool kUseUnequalProtection = false; | 669 constexpr bool kUseUnequalProtection = false; |
606 constexpr int kNumMediaPackets = 5; | 670 constexpr int kNumMediaPackets = 5; |
607 constexpr uint8_t kProtectionFactor = 60; | 671 constexpr uint8_t kProtectionFactor = 60; |
608 | 672 |
609 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 673 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
674 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
610 | 675 |
611 // Create a new temporary packet list for generating FEC packets. | 676 // Create a new temporary packet list for generating FEC packets. |
612 // This list should have every other packet removed. | 677 // This list should have every other packet removed. |
613 PacketList protected_media_packets; | 678 ForwardErrorCorrection::PacketList protected_media_packets; |
614 DeepCopyEveryNthPacket(media_packet_list_, 2, &protected_media_packets); | 679 TestFixture::DeepCopyEveryNthPacket(*this->media_packets_, 2, |
615 | 680 &protected_media_packets); |
616 EXPECT_EQ(0, fec_.GenerateFec(protected_media_packets, kProtectionFactor, | 681 |
617 kNumImportantPackets, kUseUnequalProtection, | 682 EXPECT_EQ( |
618 webrtc::kFecMaskBursty, &fec_packet_list_)); | 683 0, this->fec_.EncodeFec(protected_media_packets, kProtectionFactor, |
684 kNumImportantPackets, kUseUnequalProtection, | |
685 kFecMaskBursty, &this->generated_fec_packets_)); | |
619 | 686 |
620 // Expect 1 FEC packet. | 687 // Expect 1 FEC packet. |
621 EXPECT_EQ(1u, fec_packet_list_.size()); | 688 EXPECT_EQ(1u, this->generated_fec_packets_.size()); |
622 | 689 |
623 // 1 protected media packet lost | 690 // 1 protected media packet lost |
624 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 691 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
625 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 692 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
626 media_loss_mask_[2] = 1; | 693 this->media_loss_mask_[2] = 1; |
627 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 694 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
628 | 695 |
629 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 696 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
697 &this->recovered_packets_)); | |
630 | 698 |
631 // One packet lost, one FEC packet, expect complete recovery. | 699 // One packet lost, one FEC packet, expect complete recovery. |
632 EXPECT_TRUE(IsRecoveryComplete()); | 700 EXPECT_TRUE(this->IsRecoveryComplete()); |
633 recovered_packet_list_.clear(); | 701 this->recovered_packets_.clear(); |
634 | 702 |
635 // Unprotected packet lost. | 703 // Unprotected packet lost. |
636 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 704 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
637 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 705 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
638 media_loss_mask_[1] = 1; | 706 this->media_loss_mask_[1] = 1; |
639 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 707 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
640 | 708 |
641 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 709 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
710 &this->recovered_packets_)); | |
642 | 711 |
643 // Unprotected packet lost. Recovery not possible. | 712 // Unprotected packet lost. Recovery not possible. |
644 EXPECT_FALSE(IsRecoveryComplete()); | 713 EXPECT_FALSE(this->IsRecoveryComplete()); |
645 recovered_packet_list_.clear(); | 714 this->recovered_packets_.clear(); |
646 | 715 |
647 // 2 media packets lost. | 716 // 2 media packets lost. |
648 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 717 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
649 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 718 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
650 media_loss_mask_[0] = 1; | 719 this->media_loss_mask_[0] = 1; |
651 media_loss_mask_[2] = 1; | 720 this->media_loss_mask_[2] = 1; |
652 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 721 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
653 | 722 |
654 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 723 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
724 &this->recovered_packets_)); | |
655 | 725 |
656 // 2 protected packets lost, one FEC packet, cannot get complete recovery. | 726 // 2 protected packets lost, one FEC packet, cannot get complete recovery. |
657 EXPECT_FALSE(IsRecoveryComplete()); | 727 EXPECT_FALSE(this->IsRecoveryComplete()); |
658 } | 728 } |
659 | 729 |
660 TEST_F(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { | 730 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsExtension) { |
661 constexpr int kNumImportantPackets = 0; | 731 constexpr int kNumImportantPackets = 0; |
662 constexpr bool kUseUnequalProtection = false; | 732 constexpr bool kUseUnequalProtection = false; |
663 constexpr int kNumMediaPackets = 21; | 733 constexpr int kNumMediaPackets = 21; |
664 uint8_t kProtectionFactor = 127; | 734 uint8_t kProtectionFactor = 127; |
665 | 735 |
666 fec_seq_num_ = ConstructMediaPackets(kNumMediaPackets); | 736 this->media_packet_generator_.ConstructMediaPackets(kNumMediaPackets); |
737 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
667 | 738 |
668 // Create a new temporary packet list for generating FEC packets. | 739 // Create a new temporary packet list for generating FEC packets. |
669 // This list should have every other packet removed. | 740 // This list should have every other packet removed. |
670 PacketList protected_media_packets; | 741 ForwardErrorCorrection::PacketList protected_media_packets; |
671 DeepCopyEveryNthPacket(media_packet_list_, 2, &protected_media_packets); | 742 TestFixture::DeepCopyEveryNthPacket(*this->media_packets_, 2, |
743 &protected_media_packets); | |
672 | 744 |
673 // Zero column insertion will have to extend the size of the packet | 745 // Zero column insertion will have to extend the size of the packet |
674 // mask since the number of actual packets are 21, while the number | 746 // mask since the number of actual packets are 21, while the number |
675 // of protected packets are 11. | 747 // of protected packets are 11. |
676 EXPECT_EQ(0, fec_.GenerateFec(protected_media_packets, kProtectionFactor, | 748 EXPECT_EQ( |
677 kNumImportantPackets, kUseUnequalProtection, | 749 0, this->fec_.EncodeFec(protected_media_packets, kProtectionFactor, |
678 webrtc::kFecMaskBursty, &fec_packet_list_)); | 750 kNumImportantPackets, kUseUnequalProtection, |
751 kFecMaskBursty, &this->generated_fec_packets_)); | |
679 | 752 |
680 // Expect 5 FEC packet. | 753 // Expect 5 FEC packet. |
681 EXPECT_EQ(5u, fec_packet_list_.size()); | 754 EXPECT_EQ(5u, this->generated_fec_packets_.size()); |
682 | 755 |
683 // Last protected media packet lost | 756 // Last protected media packet lost |
684 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 757 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
685 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 758 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
686 media_loss_mask_[kNumMediaPackets - 1] = 1; | 759 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
687 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 760 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
688 | 761 |
689 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 762 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
763 &this->recovered_packets_)); | |
690 | 764 |
691 // One packet lost, one FEC packet, expect complete recovery. | 765 // One packet lost, one FEC packet, expect complete recovery. |
692 EXPECT_TRUE(IsRecoveryComplete()); | 766 EXPECT_TRUE(this->IsRecoveryComplete()); |
693 recovered_packet_list_.clear(); | 767 this->recovered_packets_.clear(); |
694 | 768 |
695 // Last unprotected packet lost. | 769 // Last unprotected packet lost. |
696 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 770 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
697 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 771 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
698 media_loss_mask_[kNumMediaPackets - 2] = 1; | 772 this->media_loss_mask_[kNumMediaPackets - 2] = 1; |
699 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 773 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
700 | 774 |
701 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 775 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
776 &this->recovered_packets_)); | |
702 | 777 |
703 // Unprotected packet lost. Recovery not possible. | 778 // Unprotected packet lost. Recovery not possible. |
704 EXPECT_FALSE(IsRecoveryComplete()); | 779 EXPECT_FALSE(this->IsRecoveryComplete()); |
705 recovered_packet_list_.clear(); | 780 this->recovered_packets_.clear(); |
706 | 781 |
707 // 6 media packets lost. | 782 // 6 media packets lost. |
708 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 783 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
709 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 784 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
710 media_loss_mask_[kNumMediaPackets - 11] = 1; | 785 this->media_loss_mask_[kNumMediaPackets - 11] = 1; |
711 media_loss_mask_[kNumMediaPackets - 9] = 1; | 786 this->media_loss_mask_[kNumMediaPackets - 9] = 1; |
712 media_loss_mask_[kNumMediaPackets - 7] = 1; | 787 this->media_loss_mask_[kNumMediaPackets - 7] = 1; |
713 media_loss_mask_[kNumMediaPackets - 5] = 1; | 788 this->media_loss_mask_[kNumMediaPackets - 5] = 1; |
714 media_loss_mask_[kNumMediaPackets - 3] = 1; | 789 this->media_loss_mask_[kNumMediaPackets - 3] = 1; |
715 media_loss_mask_[kNumMediaPackets - 1] = 1; | 790 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
716 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 791 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
717 | 792 |
718 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 793 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
794 &this->recovered_packets_)); | |
719 | 795 |
720 // 5 protected packets lost, one FEC packet, cannot get complete recovery. | 796 // 5 protected packets lost, one FEC packet, cannot get complete recovery. |
721 EXPECT_FALSE(IsRecoveryComplete()); | 797 EXPECT_FALSE(this->IsRecoveryComplete()); |
722 } | 798 } |
723 | 799 |
724 TEST_F(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { | 800 TYPED_TEST(RtpFecTest, FecRecoveryNonConsecutivePacketsWrap) { |
725 constexpr int kNumImportantPackets = 0; | 801 constexpr int kNumImportantPackets = 0; |
726 constexpr bool kUseUnequalProtection = false; | 802 constexpr bool kUseUnequalProtection = false; |
727 constexpr int kNumMediaPackets = 21; | 803 constexpr int kNumMediaPackets = 21; |
728 uint8_t kProtectionFactor = 127; | 804 uint8_t kProtectionFactor = 127; |
729 | 805 |
730 fec_seq_num_ = ConstructMediaPacketsSeqNum(kNumMediaPackets, 0xFFFF - 5); | 806 this->media_packet_generator_.ConstructMediaPacketsSeqNum(kNumMediaPackets, |
807 0xFFFF - 5); | |
808 this->media_packets_ = this->media_packet_generator_.GetMediaPackets(); | |
731 | 809 |
732 // Create a new temporary packet list for generating FEC packets. | 810 // Create a new temporary packet list for generating FEC packets. |
733 // This list should have every other packet removed. | 811 // This list should have every other packet removed. |
734 PacketList protected_media_packets; | 812 ForwardErrorCorrection::PacketList protected_media_packets; |
735 DeepCopyEveryNthPacket(media_packet_list_, 2, &protected_media_packets); | 813 TestFixture::DeepCopyEveryNthPacket(*this->media_packets_, 2, |
814 &protected_media_packets); | |
736 | 815 |
737 // Zero column insertion will have to extend the size of the packet | 816 // Zero column insertion will have to extend the size of the packet |
738 // mask since the number of actual packets are 21, while the number | 817 // mask since the number of actual packets are 21, while the number |
739 // of protected packets are 11. | 818 // of protected packets are 11. |
740 EXPECT_EQ(0, fec_.GenerateFec(protected_media_packets, kProtectionFactor, | 819 EXPECT_EQ( |
741 kNumImportantPackets, kUseUnequalProtection, | 820 0, this->fec_.EncodeFec(protected_media_packets, kProtectionFactor, |
742 webrtc::kFecMaskBursty, &fec_packet_list_)); | 821 kNumImportantPackets, kUseUnequalProtection, |
822 kFecMaskBursty, &this->generated_fec_packets_)); | |
743 | 823 |
744 // Expect 5 FEC packet. | 824 // Expect 5 FEC packet. |
745 EXPECT_EQ(5u, fec_packet_list_.size()); | 825 EXPECT_EQ(5u, this->generated_fec_packets_.size()); |
746 | 826 |
747 // Last protected media packet lost | 827 // Last protected media packet lost |
748 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 828 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
749 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 829 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
750 media_loss_mask_[kNumMediaPackets - 1] = 1; | 830 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
751 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 831 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
752 | 832 |
753 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 833 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
834 &this->recovered_packets_)); | |
754 | 835 |
755 // One packet lost, one FEC packet, expect complete recovery. | 836 // One packet lost, one FEC packet, expect complete recovery. |
756 EXPECT_TRUE(IsRecoveryComplete()); | 837 EXPECT_TRUE(this->IsRecoveryComplete()); |
757 recovered_packet_list_.clear(); | 838 this->recovered_packets_.clear(); |
758 | 839 |
759 // Last unprotected packet lost. | 840 // Last unprotected packet lost. |
760 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 841 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
761 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 842 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
762 media_loss_mask_[kNumMediaPackets - 2] = 1; | 843 this->media_loss_mask_[kNumMediaPackets - 2] = 1; |
763 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 844 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
764 | 845 |
765 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 846 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
847 &this->recovered_packets_)); | |
766 | 848 |
767 // Unprotected packet lost. Recovery not possible. | 849 // Unprotected packet lost. Recovery not possible. |
768 EXPECT_FALSE(IsRecoveryComplete()); | 850 EXPECT_FALSE(this->IsRecoveryComplete()); |
769 recovered_packet_list_.clear(); | 851 this->recovered_packets_.clear(); |
770 | 852 |
771 // 6 media packets lost. | 853 // 6 media packets lost. |
772 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | 854 memset(this->media_loss_mask_, 0, sizeof(this->media_loss_mask_)); |
773 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | 855 memset(this->fec_loss_mask_, 0, sizeof(this->fec_loss_mask_)); |
774 media_loss_mask_[kNumMediaPackets - 11] = 1; | 856 this->media_loss_mask_[kNumMediaPackets - 11] = 1; |
775 media_loss_mask_[kNumMediaPackets - 9] = 1; | 857 this->media_loss_mask_[kNumMediaPackets - 9] = 1; |
776 media_loss_mask_[kNumMediaPackets - 7] = 1; | 858 this->media_loss_mask_[kNumMediaPackets - 7] = 1; |
777 media_loss_mask_[kNumMediaPackets - 5] = 1; | 859 this->media_loss_mask_[kNumMediaPackets - 5] = 1; |
778 media_loss_mask_[kNumMediaPackets - 3] = 1; | 860 this->media_loss_mask_[kNumMediaPackets - 3] = 1; |
779 media_loss_mask_[kNumMediaPackets - 1] = 1; | 861 this->media_loss_mask_[kNumMediaPackets - 1] = 1; |
780 NetworkReceivedPackets(media_loss_mask_, fec_loss_mask_); | 862 this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_); |
781 | 863 |
782 EXPECT_EQ(0, fec_.DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 864 EXPECT_EQ(0, this->fec_.DecodeFec(&this->received_packets_, |
865 &this->recovered_packets_)); | |
783 | 866 |
784 // 5 protected packets lost, one FEC packet, cannot get complete recovery. | 867 // 5 protected packets lost, one FEC packet, cannot get complete recovery. |
785 EXPECT_FALSE(IsRecoveryComplete()); | 868 EXPECT_FALSE(this->IsRecoveryComplete()); |
786 } | 869 } |
787 | 870 |
788 void RtpFecTest::TearDown() { | 871 template <typename S> |
789 fec_.ResetState(&recovered_packet_list_); | 872 bool RtpFecTest<S>::IsRecoveryComplete() { |
790 recovered_packet_list_.clear(); | |
791 media_packet_list_.clear(); | |
792 EXPECT_TRUE(media_packet_list_.empty()); | |
793 } | |
794 | |
795 bool RtpFecTest::IsRecoveryComplete() { | |
796 // We must have equally many recovered packets as original packets. | 873 // We must have equally many recovered packets as original packets. |
797 if (recovered_packet_list_.size() != media_packet_list_.size()) { | 874 if (recovered_packets_.size() != media_packets_->size()) { |
798 return false; | 875 return false; |
799 } | 876 } |
800 | 877 |
801 // All recovered packets must be identical to the corresponding | 878 // All recovered packets must be identical to the corresponding |
802 // original packets. | 879 // original packets. |
803 using PacketPtr = std::unique_ptr<ForwardErrorCorrection::Packet>; | 880 using PacketPtr = std::unique_ptr<ForwardErrorCorrection::Packet>; |
804 using RecoveredPacketPtr = | 881 using RecoveredPacketPtr = |
805 std::unique_ptr<ForwardErrorCorrection::RecoveredPacket>; | 882 std::unique_ptr<ForwardErrorCorrection::RecoveredPacket>; |
806 auto cmp = [](const PacketPtr& media_packet, | 883 auto cmp = [](const PacketPtr& media_packet, |
807 const RecoveredPacketPtr& recovered_packet) { | 884 const RecoveredPacketPtr& recovered_packet) { |
808 if (media_packet->length != recovered_packet->pkt->length) { | 885 if (media_packet->length != recovered_packet->pkt->length) { |
809 return false; | 886 return false; |
810 } | 887 } |
811 if (memcmp(media_packet->data, | 888 if (memcmp(media_packet->data, |
812 recovered_packet->pkt->data, | 889 recovered_packet->pkt->data, |
813 media_packet->length) != 0) { | 890 media_packet->length) != 0) { |
814 return false; | 891 return false; |
815 } | 892 } |
816 return true; | 893 return true; |
817 }; | 894 }; |
818 return std::equal(media_packet_list_.cbegin(), media_packet_list_.cend(), | 895 return std::equal(media_packets_->cbegin(), media_packets_->cend(), |
819 recovered_packet_list_.cbegin(), cmp); | 896 recovered_packets_.cbegin(), cmp); |
820 } | 897 } |
821 | 898 |
822 void RtpFecTest::NetworkReceivedPackets(int* media_loss_mask, | 899 template <typename S> |
823 int* fec_loss_mask) { | 900 void RtpFecTest<S>::NetworkReceivedPackets(int* media_loss_mask, |
901 int* fec_loss_mask) { | |
824 constexpr bool kFecPacket = true; | 902 constexpr bool kFecPacket = true; |
825 ReceivedPackets(media_packet_list_, media_loss_mask, !kFecPacket); | 903 ReceivedPackets(*media_packets_, media_loss_mask, !kFecPacket); |
826 ReceivedPackets(fec_packet_list_, fec_loss_mask, kFecPacket); | 904 ReceivedPackets(generated_fec_packets_, fec_loss_mask, kFecPacket); |
827 } | 905 } |
828 | 906 |
907 template <typename S> | |
829 template <typename T> | 908 template <typename T> |
danilchap
2016/08/22 13:00:41
template <typename S, typename T>
brandtr
2016/08/23 08:19:11
That's what I though first too, but it doesn't com
| |
830 void RtpFecTest::ReceivedPackets(const T& packet_list, int* loss_mask, | 909 void RtpFecTest<S>::ReceivedPackets(const T& packet_list, |
831 bool is_fec) { | 910 int* loss_mask, |
832 int seq_num = fec_seq_num_; | 911 bool is_fec) { |
912 uint16_t fec_seq_num = media_packet_generator_.GetFecSeqNum(); | |
913 uint32_t ssrc = media_packet_generator_.GetSsrc(); | |
833 int packet_idx = 0; | 914 int packet_idx = 0; |
834 | 915 |
835 for (const auto& packet : packet_list) { | 916 for (const auto& packet : packet_list) { |
836 if (loss_mask[packet_idx] == 0) { | 917 if (loss_mask[packet_idx] == 0) { |
837 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( | 918 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> received_packet( |
838 new ForwardErrorCorrection::ReceivedPacket()); | 919 new ForwardErrorCorrection::ReceivedPacket()); |
839 received_packet->pkt = new ForwardErrorCorrection::Packet(); | 920 received_packet->pkt = new ForwardErrorCorrection::Packet(); |
840 received_packet->pkt->length = packet->length; | 921 received_packet->pkt->length = packet->length; |
841 memcpy(received_packet->pkt->data, packet->data, packet->length); | 922 memcpy(received_packet->pkt->data, packet->data, packet->length); |
842 received_packet->is_fec = is_fec; | 923 received_packet->is_fec = is_fec; |
843 if (!is_fec) { | 924 if (!is_fec) { |
844 // For media packets, the sequence number and marker bit is | 925 // For media packets, the sequence number and marker bit is |
845 // obtained from RTP header. These were set in ConstructMediaPackets(). | 926 // obtained from RTP header. These were set in ConstructMediaPackets(). |
846 received_packet->seq_num = | 927 received_packet->seq_num = |
847 webrtc::ByteReader<uint16_t>::ReadBigEndian(&packet->data[2]); | 928 ByteReader<uint16_t>::ReadBigEndian(&packet->data[2]); |
848 } else { | 929 } else { |
849 // The sequence number, marker bit, and ssrc number are defined in the | 930 // The sequence number, marker bit, and ssrc number are defined in the |
850 // RTP header of the FEC packet, which is not constructed in this test. | 931 // RTP header of the FEC packet, which is not constructed in this test. |
851 // So we set these values below based on the values generated in | 932 // So we set these values below based on the values generated in |
852 // ConstructMediaPackets(). | 933 // ConstructMediaPackets(). |
853 received_packet->seq_num = seq_num; | 934 received_packet->seq_num = fec_seq_num; |
854 // The ssrc value for FEC packets is set to the one used for the | 935 // The ssrc value for FEC packets is set to the one used for the |
855 // media packets in ConstructMediaPackets(). | 936 // media packets in ConstructMediaPackets(). |
856 received_packet->ssrc = ssrc_; | 937 received_packet->ssrc = ssrc; |
857 } | 938 } |
858 received_packet_list_.push_back(std::move(received_packet)); | 939 received_packets_.push_back(std::move(received_packet)); |
859 } | 940 } |
860 packet_idx++; | 941 packet_idx++; |
861 // Sequence number of FEC packets are defined as increment by 1 from | 942 // Sequence number of FEC packets are defined as increment by 1 from |
862 // last media packet in frame. | 943 // last media packet in frame. |
863 if (is_fec) seq_num++; | 944 if (is_fec) |
945 fec_seq_num++; | |
864 } | 946 } |
865 } | 947 } |
866 | 948 |
867 int RtpFecTest::ConstructMediaPacketsSeqNum(int num_media_packets, | 949 template <typename S> |
868 int start_seq_num) { | 950 void RtpFecTest<S>::DeepCopyEveryNthPacket( |
869 RTC_DCHECK_GT(num_media_packets, 0); | 951 const ForwardErrorCorrection::PacketList& src, |
870 int sequence_number = start_seq_num; | 952 int n, |
871 int time_stamp = random_.Rand<int>(); | 953 ForwardErrorCorrection::PacketList* dst) { |
872 | |
873 for (int i = 0; i < num_media_packets; ++i) { | |
874 std::unique_ptr<ForwardErrorCorrection::Packet> media_packet( | |
875 new ForwardErrorCorrection::Packet()); | |
876 constexpr uint32_t kMinPacketSize = kRtpHeaderSize; | |
877 const uint32_t kMaxPacketSize = IP_PACKET_SIZE - kRtpHeaderSize - | |
878 kTransportOverhead - | |
879 ForwardErrorCorrection::PacketOverhead(); | |
880 media_packet->length = random_.Rand(kMinPacketSize, kMaxPacketSize); | |
881 | |
882 // Generate random values for the first 2 bytes | |
883 media_packet->data[0] = random_.Rand<uint8_t>(); | |
884 media_packet->data[1] = random_.Rand<uint8_t>(); | |
885 | |
886 // The first two bits are assumed to be 10 by the FEC encoder. | |
887 // In fact the FEC decoder will set the two first bits to 10 regardless of | |
888 // what they actually were. Set the first two bits to 10 so that a memcmp | |
889 // can be performed for the whole restored packet. | |
890 media_packet->data[0] |= 0x80; | |
891 media_packet->data[0] &= 0xbf; | |
892 | |
893 // FEC is applied to a whole frame. | |
894 // A frame is signaled by multiple packets without the marker bit set | |
895 // followed by the last packet of the frame for which the marker bit is set. | |
896 // Only push one (fake) frame to the FEC. | |
897 media_packet->data[1] &= 0x7f; | |
898 | |
899 webrtc::ByteWriter<uint16_t>::WriteBigEndian(&media_packet->data[2], | |
900 sequence_number); | |
901 webrtc::ByteWriter<uint32_t>::WriteBigEndian(&media_packet->data[4], | |
902 time_stamp); | |
903 webrtc::ByteWriter<uint32_t>::WriteBigEndian(&media_packet->data[8], ssrc_); | |
904 | |
905 // Generate random values for payload. | |
906 for (size_t j = 12; j < media_packet->length; ++j) { | |
907 media_packet->data[j] = random_.Rand<uint8_t>(); | |
908 } | |
909 sequence_number++; | |
910 media_packet_list_.push_back(std::move(media_packet)); | |
911 } | |
912 // Last packet, set marker bit. | |
913 ForwardErrorCorrection::Packet* media_packet = | |
914 media_packet_list_.back().get(); | |
915 RTC_DCHECK(media_packet); | |
916 media_packet->data[1] |= 0x80; | |
917 return sequence_number; | |
918 } | |
919 | |
920 int RtpFecTest::ConstructMediaPackets(int num_media_packets) { | |
921 return ConstructMediaPacketsSeqNum(num_media_packets, random_.Rand<int>()); | |
922 } | |
923 | |
924 void RtpFecTest::DeepCopyEveryNthPacket(const PacketList& src, int n, | |
925 PacketList* dst) { | |
926 RTC_DCHECK_GT(n, 0); | 954 RTC_DCHECK_GT(n, 0); |
927 int i = 0; | 955 int i = 0; |
928 for (const auto& packet : src) { | 956 for (const auto& packet : src) { |
929 if (i % n == 0) { | 957 if (i % n == 0) { |
930 dst->emplace_back(new ForwardErrorCorrection::Packet(*packet)); | 958 dst->emplace_back(new ForwardErrorCorrection::Packet(*packet)); |
931 } | 959 } |
932 ++i; | 960 ++i; |
933 } | 961 } |
934 } | 962 } |
963 | |
964 } // namespace webrtc | |
OLD | NEW |