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 30 matching lines...) Expand all Loading... |
41 class NullRecoveredPacketReceiver : public RecoveredPacketReceiver { | 41 class NullRecoveredPacketReceiver : public RecoveredPacketReceiver { |
42 public: | 42 public: |
43 void OnRecoveredPacket(const uint8_t* packet, size_t length) override {} | 43 void OnRecoveredPacket(const uint8_t* packet, size_t length) override {} |
44 }; | 44 }; |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 class UlpfecReceiverTest : public ::testing::Test { | 48 class UlpfecReceiverTest : public ::testing::Test { |
49 protected: | 49 protected: |
50 UlpfecReceiverTest() | 50 UlpfecReceiverTest() |
51 : fec_(ForwardErrorCorrection::CreateUlpfec()), | 51 : fec_(ForwardErrorCorrection::CreateUlpfec(kMediaSsrc)), |
52 receiver_fec_(UlpfecReceiver::Create(&recovered_packet_receiver_)), | 52 receiver_fec_( |
| 53 UlpfecReceiver::Create(kMediaSsrc, &recovered_packet_receiver_)), |
53 packet_generator_(kMediaSsrc) {} | 54 packet_generator_(kMediaSsrc) {} |
54 | 55 |
55 // Generates |num_fec_packets| FEC packets, given |media_packets|. | 56 // Generates |num_fec_packets| FEC packets, given |media_packets|. |
56 void EncodeFec(const ForwardErrorCorrection::PacketList& media_packets, | 57 void EncodeFec(const ForwardErrorCorrection::PacketList& media_packets, |
57 size_t num_fec_packets, | 58 size_t num_fec_packets, |
58 std::list<ForwardErrorCorrection::Packet*>* fec_packets); | 59 std::list<ForwardErrorCorrection::Packet*>* fec_packets); |
59 | 60 |
60 // Generates |num_media_packets| corresponding to a single frame. | 61 // Generates |num_media_packets| corresponding to a single frame. |
61 void PacketizeFrame(size_t num_media_packets, | 62 void PacketizeFrame(size_t num_media_packets, |
62 size_t frame_offset, | 63 size_t frame_offset, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 173 |
173 void UlpfecReceiverTest::SurvivesMaliciousPacket(const uint8_t* data, | 174 void UlpfecReceiverTest::SurvivesMaliciousPacket(const uint8_t* data, |
174 size_t length, | 175 size_t length, |
175 uint8_t ulpfec_payload_type) { | 176 uint8_t ulpfec_payload_type) { |
176 RTPHeader header; | 177 RTPHeader header; |
177 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); | 178 std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); |
178 ASSERT_TRUE(parser->Parse(data, length, &header)); | 179 ASSERT_TRUE(parser->Parse(data, length, &header)); |
179 | 180 |
180 NullRecoveredPacketReceiver null_callback; | 181 NullRecoveredPacketReceiver null_callback; |
181 std::unique_ptr<UlpfecReceiver> receiver_fec( | 182 std::unique_ptr<UlpfecReceiver> receiver_fec( |
182 UlpfecReceiver::Create(&null_callback)); | 183 UlpfecReceiver::Create(kMediaSsrc, &null_callback)); |
183 | 184 |
184 receiver_fec->AddReceivedRedPacket(header, data, length, ulpfec_payload_type); | 185 receiver_fec->AddReceivedRedPacket(header, data, length, ulpfec_payload_type); |
185 } | 186 } |
186 | 187 |
187 TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { | 188 TEST_F(UlpfecReceiverTest, TwoMediaOneFec) { |
188 constexpr size_t kNumFecPackets = 1u; | 189 constexpr size_t kNumFecPackets = 1u; |
189 std::list<AugmentedPacket*> augmented_media_packets; | 190 std::list<AugmentedPacket*> augmented_media_packets; |
190 ForwardErrorCorrection::PacketList media_packets; | 191 ForwardErrorCorrection::PacketList media_packets; |
191 PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); | 192 PacketizeFrame(2, 0, &augmented_media_packets, &media_packets); |
192 std::list<ForwardErrorCorrection::Packet*> fec_packets; | 193 std::list<ForwardErrorCorrection::Packet*> fec_packets; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 476 |
476 TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) { | 477 TEST_F(UlpfecReceiverTest, TruncatedPacketWithoutDataPastFirstBlock) { |
477 const uint8_t kPacket[] = { | 478 const uint8_t kPacket[] = { |
478 0x82, 0x38, 0x92, 0x38, 0x92, 0x38, 0xde, 0x2a, 0x11, 0xc8, 0xa3, 0xc4, | 479 0x82, 0x38, 0x92, 0x38, 0x92, 0x38, 0xde, 0x2a, 0x11, 0xc8, 0xa3, 0xc4, |
479 0x82, 0x38, 0x2a, 0x21, 0x2a, 0x28, 0x92, 0x38, 0x92, 0x00, 0x00, 0x0a, | 480 0x82, 0x38, 0x2a, 0x21, 0x2a, 0x28, 0x92, 0x38, 0x92, 0x00, 0x00, 0x0a, |
480 0x3a, 0xc8, 0xa3, 0x3a, 0x27, 0xc4, 0x2a, 0x21, 0x2a, 0x28}; | 481 0x3a, 0xc8, 0xa3, 0x3a, 0x27, 0xc4, 0x2a, 0x21, 0x2a, 0x28}; |
481 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); | 482 SurvivesMaliciousPacket(kPacket, sizeof(kPacket), 100); |
482 } | 483 } |
483 | 484 |
484 } // namespace webrtc | 485 } // namespace webrtc |
OLD | NEW |