| 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 17 matching lines...) Expand all Loading... |
| 28 // #define VERBOSE_OUTPUT | 28 // #define VERBOSE_OUTPUT |
| 29 | 29 |
| 30 namespace webrtc { | 30 namespace webrtc { |
| 31 namespace fec_private_tables { | 31 namespace fec_private_tables { |
| 32 extern const uint8_t** kPacketMaskBurstyTbl[12]; | 32 extern const uint8_t** kPacketMaskBurstyTbl[12]; |
| 33 } | 33 } |
| 34 namespace test { | 34 namespace test { |
| 35 using fec_private_tables::kPacketMaskBurstyTbl; | 35 using fec_private_tables::kPacketMaskBurstyTbl; |
| 36 | 36 |
| 37 void ReceivePackets( | 37 void ReceivePackets( |
| 38 ForwardErrorCorrection::ReceivedPacketList* to_decode_list, | 38 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>>* |
| 39 ForwardErrorCorrection::ReceivedPacketList* received_packet_list, | 39 to_decode_list, |
| 40 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>>* |
| 41 received_packet_list, |
| 40 size_t num_packets_to_decode, | 42 size_t num_packets_to_decode, |
| 41 float reorder_rate, | 43 float reorder_rate, |
| 42 float duplicate_rate, | 44 float duplicate_rate, |
| 43 Random* random) { | 45 Random* random) { |
| 44 RTC_DCHECK(to_decode_list->empty()); | 46 RTC_DCHECK(to_decode_list->empty()); |
| 45 RTC_DCHECK_LE(num_packets_to_decode, received_packet_list->size()); | 47 RTC_DCHECK_LE(num_packets_to_decode, received_packet_list->size()); |
| 46 | 48 |
| 47 for (size_t i = 0; i < num_packets_to_decode; i++) { | 49 for (size_t i = 0; i < num_packets_to_decode; i++) { |
| 48 auto it = received_packet_list->begin(); | 50 auto it = received_packet_list->begin(); |
| 49 // Reorder packets. | 51 // Reorder packets. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Maximum number of media packets allowed for the mask type. | 98 // Maximum number of media packets allowed for the mask type. |
| 97 const uint16_t kMaxMediaPackets[] = { | 99 const uint16_t kMaxMediaPackets[] = { |
| 98 kMaxNumberMediaPackets, | 100 kMaxNumberMediaPackets, |
| 99 sizeof(kPacketMaskBurstyTbl) / sizeof(*kPacketMaskBurstyTbl)}; | 101 sizeof(kPacketMaskBurstyTbl) / sizeof(*kPacketMaskBurstyTbl)}; |
| 100 | 102 |
| 101 ASSERT_EQ(12, kMaxMediaPackets[1]) << "Max media packets for bursty mode not " | 103 ASSERT_EQ(12, kMaxMediaPackets[1]) << "Max media packets for bursty mode not " |
| 102 << "equal to 12."; | 104 << "equal to 12."; |
| 103 | 105 |
| 104 ForwardErrorCorrection::PacketList media_packet_list; | 106 ForwardErrorCorrection::PacketList media_packet_list; |
| 105 std::list<ForwardErrorCorrection::Packet*> fec_packet_list; | 107 std::list<ForwardErrorCorrection::Packet*> fec_packet_list; |
| 106 ForwardErrorCorrection::ReceivedPacketList to_decode_list; | 108 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> |
| 107 ForwardErrorCorrection::ReceivedPacketList received_packet_list; | 109 to_decode_list; |
| 110 std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>> |
| 111 received_packet_list; |
| 108 ForwardErrorCorrection::RecoveredPacketList recovered_packet_list; | 112 ForwardErrorCorrection::RecoveredPacketList recovered_packet_list; |
| 109 std::list<uint8_t*> fec_mask_list; | 113 std::list<uint8_t*> fec_mask_list; |
| 110 | 114 |
| 111 // Running over only two loss rates to limit execution time. | 115 // Running over only two loss rates to limit execution time. |
| 112 const float loss_rate[] = {0.05f, 0.01f}; | 116 const float loss_rate[] = {0.05f, 0.01f}; |
| 113 const uint32_t loss_rate_size = sizeof(loss_rate) / sizeof(*loss_rate); | 117 const uint32_t loss_rate_size = sizeof(loss_rate) / sizeof(*loss_rate); |
| 114 const float reorder_rate = 0.1f; | 118 const float reorder_rate = 0.1f; |
| 115 const float duplicate_rate = 0.1f; | 119 const float duplicate_rate = 0.1f; |
| 116 | 120 |
| 117 uint8_t media_loss_mask[kMaxNumberMediaPackets]; | 121 uint8_t media_loss_mask[kMaxNumberMediaPackets]; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 num_packets_to_decode, reorder_rate, | 400 num_packets_to_decode, reorder_rate, |
| 397 duplicate_rate, &random); | 401 duplicate_rate, &random); |
| 398 | 402 |
| 399 if (fec_packet_received == false) { | 403 if (fec_packet_received == false) { |
| 400 for (const auto& received_packet : to_decode_list) { | 404 for (const auto& received_packet : to_decode_list) { |
| 401 if (received_packet->is_fec) { | 405 if (received_packet->is_fec) { |
| 402 fec_packet_received = true; | 406 fec_packet_received = true; |
| 403 } | 407 } |
| 404 } | 408 } |
| 405 } | 409 } |
| 406 ASSERT_EQ(0, | 410 for (const auto& received_packet : to_decode_list) { |
| 407 fec->DecodeFec(&to_decode_list, &recovered_packet_list)) | 411 fec->DecodeFec(*received_packet, &recovered_packet_list); |
| 408 << "DecodeFec() failed"; | 412 } |
| 409 ASSERT_TRUE(to_decode_list.empty()) | 413 to_decode_list.clear(); |
| 410 << "Received packet list is not empty."; | |
| 411 } | 414 } |
| 412 media_packet_idx = 0; | 415 media_packet_idx = 0; |
| 413 for (const auto& media_packet : media_packet_list) { | 416 for (const auto& media_packet : media_packet_list) { |
| 414 if (media_loss_mask[media_packet_idx] == 1) { | 417 if (media_loss_mask[media_packet_idx] == 1) { |
| 415 // Should have recovered this packet. | 418 // Should have recovered this packet. |
| 416 auto recovered_packet_list_it = recovered_packet_list.cbegin(); | 419 auto recovered_packet_list_it = recovered_packet_list.cbegin(); |
| 417 | 420 |
| 418 ASSERT_FALSE(recovered_packet_list_it == | 421 ASSERT_FALSE(recovered_packet_list_it == |
| 419 recovered_packet_list.end()) | 422 recovered_packet_list.end()) |
| 420 << "Insufficient number of recovered packets."; | 423 << "Insufficient number of recovered packets."; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 TEST(FecTest, UlpfecTest) { | 469 TEST(FecTest, UlpfecTest) { |
| 467 RunTest(false); | 470 RunTest(false); |
| 468 } | 471 } |
| 469 | 472 |
| 470 TEST(FecTest, FlexfecTest) { | 473 TEST(FecTest, FlexfecTest) { |
| 471 RunTest(true); | 474 RunTest(true); |
| 472 } | 475 } |
| 473 | 476 |
| 474 } // namespace test | 477 } // namespace test |
| 475 } // namespace webrtc | 478 } // namespace webrtc |
| OLD | NEW |