| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 protected_packets.push_back({14, 1, 43, 0}); | 74 protected_packets.push_back({14, 1, 43, 0}); |
| 75 protected_packets.push_back({19, 0, 48, 0}); | 75 protected_packets.push_back({19, 0, 48, 0}); |
| 76 protected_packets.push_back({19, 0, 50, 0}); | 76 protected_packets.push_back({19, 0, 50, 0}); |
| 77 protected_packets.push_back({14, 3, 51, 0}); | 77 protected_packets.push_back({14, 3, 51, 0}); |
| 78 protected_packets.push_back({13, 8, 52, 0}); | 78 protected_packets.push_back({13, 8, 52, 0}); |
| 79 protected_packets.push_back({19, 2, 53, 0}); | 79 protected_packets.push_back({19, 2, 53, 0}); |
| 80 protected_packets.push_back({12, 3, 54, 0}); | 80 protected_packets.push_back({12, 3, 54, 0}); |
| 81 protected_packets.push_back({21, 0, 55, 0}); | 81 protected_packets.push_back({21, 0, 55, 0}); |
| 82 protected_packets.push_back({13, 3, 57, 1}); | 82 protected_packets.push_back({13, 3, 57, 1}); |
| 83 FecProtectionParams params = {117, 3, kFecMaskBursty}; | 83 FecProtectionParams params = {117, 3, kFecMaskBursty}; |
| 84 ulpfec_generator_.SetFecParameters(¶ms); | 84 ulpfec_generator_.SetFecParameters(params); |
| 85 uint8_t packet[28] = {0}; | 85 uint8_t packet[28] = {0}; |
| 86 for (Packet p : protected_packets) { | 86 for (Packet p : protected_packets) { |
| 87 if (p.marker_bit) { | 87 if (p.marker_bit) { |
| 88 packet[1] |= 0x80; | 88 packet[1] |= 0x80; |
| 89 } else { | 89 } else { |
| 90 packet[1] &= ~0x80; | 90 packet[1] &= ~0x80; |
| 91 } | 91 } |
| 92 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], p.seq_num); | 92 ByteWriter<uint16_t>::WriteBigEndian(&packet[2], p.seq_num); |
| 93 ulpfec_generator_.AddRtpPacketAndGenerateFec(packet, p.payload_size, | 93 ulpfec_generator_.AddRtpPacketAndGenerateFec(packet, p.payload_size, |
| 94 p.header_size); | 94 p.header_size); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 105 TEST_F(UlpfecGeneratorTest, OneFrameFec) { | 105 TEST_F(UlpfecGeneratorTest, OneFrameFec) { |
| 106 // The number of media packets (|kNumPackets|), number of frames (one for | 106 // The number of media packets (|kNumPackets|), number of frames (one for |
| 107 // this test), and the protection factor (|params->fec_rate|) are set to make | 107 // this test), and the protection factor (|params->fec_rate|) are set to make |
| 108 // sure the conditions for generating FEC are satisfied. This means: | 108 // sure the conditions for generating FEC are satisfied. This means: |
| 109 // (1) protection factor is high enough so that actual overhead over 1 frame | 109 // (1) protection factor is high enough so that actual overhead over 1 frame |
| 110 // of packets is within |kMaxExcessOverhead|, and (2) the total number of | 110 // of packets is within |kMaxExcessOverhead|, and (2) the total number of |
| 111 // media packets for 1 frame is at least |minimum_media_packets_fec_|. | 111 // media packets for 1 frame is at least |minimum_media_packets_fec_|. |
| 112 constexpr size_t kNumPackets = 4; | 112 constexpr size_t kNumPackets = 4; |
| 113 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 113 FecProtectionParams params = {15, 3, kFecMaskRandom}; |
| 114 packet_generator_.NewFrame(kNumPackets); | 114 packet_generator_.NewFrame(kNumPackets); |
| 115 ulpfec_generator_.SetFecParameters(¶ms); // Expecting one FEC packet. | 115 ulpfec_generator_.SetFecParameters(params); // Expecting one FEC packet. |
| 116 uint32_t last_timestamp = 0; | 116 uint32_t last_timestamp = 0; |
| 117 for (size_t i = 0; i < kNumPackets; ++i) { | 117 for (size_t i = 0; i < kNumPackets; ++i) { |
| 118 std::unique_ptr<AugmentedPacket> packet = | 118 std::unique_ptr<AugmentedPacket> packet = |
| 119 packet_generator_.NextPacket(i, 10); | 119 packet_generator_.NextPacket(i, 10); |
| 120 EXPECT_EQ(0, ulpfec_generator_.AddRtpPacketAndGenerateFec( | 120 EXPECT_EQ(0, ulpfec_generator_.AddRtpPacketAndGenerateFec( |
| 121 packet->data, packet->length, kRtpHeaderSize)); | 121 packet->data, packet->length, kRtpHeaderSize)); |
| 122 last_timestamp = packet->header.header.timestamp; | 122 last_timestamp = packet->header.header.timestamp; |
| 123 } | 123 } |
| 124 EXPECT_TRUE(ulpfec_generator_.FecAvailable()); | 124 EXPECT_TRUE(ulpfec_generator_.FecAvailable()); |
| 125 uint16_t seq_num = packet_generator_.NextPacketSeqNum(); | 125 uint16_t seq_num = packet_generator_.NextPacketSeqNum(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to | 137 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to |
| 138 // make sure the conditions for generating FEC are satisfied. This means: | 138 // make sure the conditions for generating FEC are satisfied. This means: |
| 139 // (1) protection factor is high enough so that actual overhead over | 139 // (1) protection factor is high enough so that actual overhead over |
| 140 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of | 140 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of |
| 141 // media packets for |kNumFrames| frames is at least | 141 // media packets for |kNumFrames| frames is at least |
| 142 // |minimum_media_packets_fec_|. | 142 // |minimum_media_packets_fec_|. |
| 143 constexpr size_t kNumPackets = 2; | 143 constexpr size_t kNumPackets = 2; |
| 144 constexpr size_t kNumFrames = 2; | 144 constexpr size_t kNumFrames = 2; |
| 145 | 145 |
| 146 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 146 FecProtectionParams params = {15, 3, kFecMaskRandom}; |
| 147 ulpfec_generator_.SetFecParameters(¶ms); // Expecting one FEC packet. | 147 ulpfec_generator_.SetFecParameters(params); // Expecting one FEC packet. |
| 148 uint32_t last_timestamp = 0; | 148 uint32_t last_timestamp = 0; |
| 149 for (size_t i = 0; i < kNumFrames; ++i) { | 149 for (size_t i = 0; i < kNumFrames; ++i) { |
| 150 packet_generator_.NewFrame(kNumPackets); | 150 packet_generator_.NewFrame(kNumPackets); |
| 151 for (size_t j = 0; j < kNumPackets; ++j) { | 151 for (size_t j = 0; j < kNumPackets; ++j) { |
| 152 std::unique_ptr<AugmentedPacket> packet = | 152 std::unique_ptr<AugmentedPacket> packet = |
| 153 packet_generator_.NextPacket(i * kNumPackets + j, 10); | 153 packet_generator_.NextPacket(i * kNumPackets + j, 10); |
| 154 EXPECT_EQ(0, ulpfec_generator_.AddRtpPacketAndGenerateFec( | 154 EXPECT_EQ(0, ulpfec_generator_.AddRtpPacketAndGenerateFec( |
| 155 packet->data, packet->length, kRtpHeaderSize)); | 155 packet->data, packet->length, kRtpHeaderSize)); |
| 156 last_timestamp = packet->header.header.timestamp; | 156 last_timestamp = packet->header.header.timestamp; |
| 157 } | 157 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 packet->data, packet->length - kRtpHeaderSize, kRtpHeaderSize, | 195 packet->data, packet->length - kRtpHeaderSize, kRtpHeaderSize, |
| 196 kRedPayloadType); | 196 kRedPayloadType); |
| 197 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length()); | 197 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length()); |
| 198 VerifyHeader(packet->header.header.sequenceNumber, | 198 VerifyHeader(packet->header.header.sequenceNumber, |
| 199 packet->header.header.timestamp, kRedPayloadType, | 199 packet->header.header.timestamp, kRedPayloadType, |
| 200 packet->header.header.payloadType, red_packet.get(), | 200 packet->header.header.payloadType, red_packet.get(), |
| 201 true); // Marker bit set. | 201 true); // Marker bit set. |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace webrtc | 204 } // namespace webrtc |
| OLD | NEW |