| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 ssrc); | 270 ssrc); |
| 271 // Generate random values for payload | 271 // Generate random values for payload |
| 272 for (size_t j = 12; j < media_packet->length; ++j) { | 272 for (size_t j = 12; j < media_packet->length; ++j) { |
| 273 media_packet->data[j] = random.Rand<uint8_t>(); | 273 media_packet->data[j] = random.Rand<uint8_t>(); |
| 274 } | 274 } |
| 275 media_packet_list.push_back(std::move(media_packet)); | 275 media_packet_list.push_back(std::move(media_packet)); |
| 276 seq_num++; | 276 seq_num++; |
| 277 } | 277 } |
| 278 media_packet_list.back()->data[1] |= 0x80; | 278 media_packet_list.back()->data[1] |= 0x80; |
| 279 | 279 |
| 280 ASSERT_EQ(0, fec.GenerateFec(media_packet_list, protection_factor, | 280 ASSERT_EQ(0, fec.EncodeFec(media_packet_list, protection_factor, |
| 281 num_imp_packets, kUseUnequalProtection, | 281 num_imp_packets, kUseUnequalProtection, |
| 282 fec_mask_type, &fec_packet_list)) | 282 fec_mask_type, &fec_packet_list)) |
| 283 << "GenerateFec() failed"; | 283 << "EncodeFec() failed"; |
| 284 | 284 |
| 285 ASSERT_EQ(num_fec_packets, fec_packet_list.size()) | 285 ASSERT_EQ(num_fec_packets, fec_packet_list.size()) |
| 286 << "We requested " << num_fec_packets << " FEC packets, but " | 286 << "We requested " << num_fec_packets << " FEC packets, but " |
| 287 << "GenerateFec() produced " << fec_packet_list.size(); | 287 << "EncodeFec() produced " << fec_packet_list.size(); |
| 288 | 288 |
| 289 memset(media_loss_mask, 0, sizeof(media_loss_mask)); | 289 memset(media_loss_mask, 0, sizeof(media_loss_mask)); |
| 290 uint32_t media_packet_idx = 0; | 290 uint32_t media_packet_idx = 0; |
| 291 for (const auto& media_packet : media_packet_list) { | 291 for (const auto& media_packet : media_packet_list) { |
| 292 // We want a value between 0 and 1. | 292 // We want a value between 0 and 1. |
| 293 const float loss_random_variable = random.Rand<float>(); | 293 const float loss_random_variable = random.Rand<float>(); |
| 294 | 294 |
| 295 if (loss_random_variable >= loss_rate[loss_rate_idx]) { | 295 if (loss_random_variable >= loss_rate[loss_rate_idx]) { |
| 296 media_loss_mask[media_packet_idx] = 1; | 296 media_loss_mask[media_packet_idx] = 1; |
| 297 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> | 297 std::unique_ptr<ForwardErrorCorrection::ReceivedPacket> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 num_packets_to_decode, reorder_rate, | 385 num_packets_to_decode, reorder_rate, |
| 386 duplicate_rate, &random); | 386 duplicate_rate, &random); |
| 387 | 387 |
| 388 if (fec_packet_received == false) { | 388 if (fec_packet_received == false) { |
| 389 for (const auto& received_packet : to_decode_list) { | 389 for (const auto& received_packet : to_decode_list) { |
| 390 if (received_packet->is_fec) { | 390 if (received_packet->is_fec) { |
| 391 fec_packet_received = true; | 391 fec_packet_received = true; |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 ASSERT_EQ(0, fec.DecodeFec(&to_decode_list, | 395 ASSERT_EQ(0, |
| 396 &recovered_packet_list)) | 396 fec.DecodeFec(&to_decode_list, &recovered_packet_list)) |
| 397 << "DecodeFec() failed"; | 397 << "DecodeFec() failed"; |
| 398 ASSERT_TRUE(to_decode_list.empty()) | 398 ASSERT_TRUE(to_decode_list.empty()) |
| 399 << "Received packet list is not empty."; | 399 << "Received packet list is not empty."; |
| 400 } | 400 } |
| 401 media_packet_idx = 0; | 401 media_packet_idx = 0; |
| 402 for (const auto& media_packet : media_packet_list) { | 402 for (const auto& media_packet : media_packet_list) { |
| 403 if (media_loss_mask[media_packet_idx] == 1) { | 403 if (media_loss_mask[media_packet_idx] == 1) { |
| 404 // Should have recovered this packet. | 404 // Should have recovered this packet. |
| 405 auto recovered_packet_list_it = recovered_packet_list.cbegin(); | 405 auto recovered_packet_list_it = recovered_packet_list.cbegin(); |
| 406 | 406 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } // loop over mask types | 447 } // loop over mask types |
| 448 | 448 |
| 449 // Have DecodeFec clear the recovered packet list. | 449 // Have DecodeFec clear the recovered packet list. |
| 450 fec.ResetState(&recovered_packet_list); | 450 fec.ResetState(&recovered_packet_list); |
| 451 ASSERT_TRUE(recovered_packet_list.empty()) | 451 ASSERT_TRUE(recovered_packet_list.empty()) |
| 452 << "Recovered packet list is not empty"; | 452 << "Recovered packet list is not empty"; |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace test | 455 } // namespace test |
| 456 } // namespace webrtc | 456 } // namespace webrtc |
| OLD | NEW |