OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 EXPECT_EQ(0, | 194 EXPECT_EQ(0, |
195 fec_->DecodeFec(&received_packet_list_, &recovered_packet_list_)); | 195 fec_->DecodeFec(&received_packet_list_, &recovered_packet_list_)); |
196 | 196 |
197 // Expect that no decoding is done to get missing packet (seq#0) of second | 197 // Expect that no decoding is done to get missing packet (seq#0) of second |
198 // frame, using old FEC packet (seq#2) from first (old) frame. So number of | 198 // frame, using old FEC packet (seq#2) from first (old) frame. So number of |
199 // recovered packets is 2, and not equal to number of media packets (=3). | 199 // recovered packets is 2, and not equal to number of media packets (=3). |
200 EXPECT_EQ(2, static_cast<int>(recovered_packet_list_.size())); | 200 EXPECT_EQ(2, static_cast<int>(recovered_packet_list_.size())); |
201 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); | 201 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); |
202 } | 202 } |
203 | 203 |
204 // Verify we can still recovery frame if sequence number wrap occurs within | 204 // Verify we can still recover frame if sequence number wrap occurs within |
205 // the frame and FEC packet following wrap is received after media packets. | 205 // the frame and FEC packet following wrap is received after media packets. |
206 TEST_F(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) { | 206 TEST_F(RtpFecTest, FecRecoveryWithSeqNumGapOneFrameRecovery) { |
207 const int kNumImportantPackets = 0; | 207 const int kNumImportantPackets = 0; |
208 const bool kUseUnequalProtection = false; | 208 const bool kUseUnequalProtection = false; |
209 uint8_t kProtectionFactor = 20; | 209 uint8_t kProtectionFactor = 20; |
210 | 210 |
211 // One frame, with sequence number wrap in media packets. | 211 // One frame, with sequence number wrap in media packets. |
212 // -----Frame 1---- | 212 // -----Frame 1---- |
213 // #65534(media) #65535(media) #0(media) #1(FEC). | 213 // #65534(media) #65535(media) #0(media) #1(FEC). |
214 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 65534); | 214 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 65534); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 | 274 |
275 // The two FEC packets are received and should allow for complete recovery, | 275 // The two FEC packets are received and should allow for complete recovery, |
276 // but because of the wrap the second FEC packet will be discarded, and only | 276 // but because of the wrap the second FEC packet will be discarded, and only |
277 // one media packet is recoverable. So exepct 2 media packets on recovered | 277 // one media packet is recoverable. So exepct 2 media packets on recovered |
278 // list and no complete recovery. | 278 // list and no complete recovery. |
279 EXPECT_EQ(2, static_cast<int>(recovered_packet_list_.size())); | 279 EXPECT_EQ(2, static_cast<int>(recovered_packet_list_.size())); |
280 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); | 280 EXPECT_TRUE(recovered_packet_list_.size() != media_packet_list_.size()); |
281 EXPECT_FALSE(IsRecoveryComplete()); | 281 EXPECT_FALSE(IsRecoveryComplete()); |
282 } | 282 } |
283 | 283 |
284 // Verify we can still recovery frame if FEC is received before media packets. | 284 // Verify we can still recover frame if media packets are reordered. |
285 TEST_F(RtpFecTest, FecRecoveryWithMediaReordering) { | |
286 const int kNumImportantPackets = 0; | |
danilchap
2016/07/01 18:55:08
might want change to constexpr, but may leave as c
brandtr
2016/07/04 13:56:07
Done.
| |
287 const bool kUseUnequalProtection = false; | |
288 uint8_t kProtectionFactor = 20; | |
danilchap
2016/07/01 18:55:08
const
brandtr
2016/07/04 13:56:07
Done.
| |
289 | |
290 // One frame: 3 media packets, 1 FEC packet. | |
291 // -----Frame 1---- | |
292 // #0(media) #1(media) #2(media) #3(FEC). | |
293 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 0); | |
294 | |
295 EXPECT_EQ(0, fec_->GenerateFec(media_packet_list_, kProtectionFactor, | |
296 kNumImportantPackets, kUseUnequalProtection, | |
297 webrtc::kFecMaskBursty, &fec_packet_list_)); | |
298 | |
299 // Expect 1 FEC packet. | |
300 EXPECT_EQ(1, static_cast<int>(fec_packet_list_.size())); | |
danilchap
2016/07/01 18:55:08
EXPECT_EQ(1u, fec_packet_list_.size()); is cleaner
brandtr
2016/07/04 13:56:07
Done.
| |
301 | |
302 // Lose one media packet (seq# 1). | |
303 memset(media_loss_mask_, 0, sizeof(media_loss_mask_)); | |
304 memset(fec_loss_mask_, 0, sizeof(fec_loss_mask_)); | |
305 media_loss_mask_[1] = 1; | |
306 NetworkReceivedPackets(); | |
307 | |
308 // Reorder received media packets. | |
309 auto it0 = received_packet_list_.begin(); | |
310 auto it2 = received_packet_list_.begin(); it2++; | |
danilchap
2016/07/01 18:55:08
do not keep two commands on one line
brandtr
2016/07/04 13:56:07
Done.
| |
311 std::swap(*it0, *it2); | |
312 | |
313 EXPECT_EQ(0, | |
314 fec_->DecodeFec(&received_packet_list_, &recovered_packet_list_)); | |
315 | |
316 // Expect 3 media packets in recovered list, and complete recovery. | |
317 EXPECT_EQ(3, static_cast<int>(recovered_packet_list_.size())); | |
danilchap
2016/07/01 18:55:08
EXPECT_EQ(3u, ...)
brandtr
2016/07/04 13:56:07
Done.
| |
318 EXPECT_TRUE(IsRecoveryComplete()); | |
319 } | |
320 | |
321 // Verify we can still recover frame if FEC is received before media packets. | |
285 TEST_F(RtpFecTest, FecRecoveryWithFecOutOfOrder) { | 322 TEST_F(RtpFecTest, FecRecoveryWithFecOutOfOrder) { |
286 const int kNumImportantPackets = 0; | 323 const int kNumImportantPackets = 0; |
287 const bool kUseUnequalProtection = false; | 324 const bool kUseUnequalProtection = false; |
288 uint8_t kProtectionFactor = 20; | 325 uint8_t kProtectionFactor = 20; |
289 | 326 |
290 // One frame: 3 media packets, 1 FEC packet. | 327 // One frame: 3 media packets, 1 FEC packet. |
291 // -----Frame 1---- | 328 // -----Frame 1---- |
292 // #0(media) #1(media) #2(media) #3(FEC). | 329 // #0(media) #1(media) #2(media) #3(FEC). |
293 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 0); | 330 fec_seq_num_ = ConstructMediaPacketsSeqNum(3, 0); |
294 | 331 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 PacketList* dst, int N) { | 951 PacketList* dst, int N) { |
915 RTC_DCHECK_GT(N, 0); | 952 RTC_DCHECK_GT(N, 0); |
916 int i = 0; | 953 int i = 0; |
917 for (auto& packet : src) { | 954 for (auto& packet : src) { |
918 if (i % N == 0) { | 955 if (i % N == 0) { |
919 dst->emplace_back(new ForwardErrorCorrection::Packet(*packet)); | 956 dst->emplace_back(new ForwardErrorCorrection::Packet(*packet)); |
920 } | 957 } |
921 ++i; | 958 ++i; |
922 } | 959 } |
923 } | 960 } |
OLD | NEW |