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...) 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 producer_.SetFecParameters(¶ms, 0); | 84 producer_.SetFecParameters(¶ms); |
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 producer_.AddRtpPacketAndGenerateFec(packet, p.payload_size, p.header_size); | 93 producer_.AddRtpPacketAndGenerateFec(packet, p.payload_size, p.header_size); |
94 size_t num_fec_packets = producer_.NumAvailableFecPackets(); | 94 size_t num_fec_packets = producer_.NumAvailableFecPackets(); |
95 if (num_fec_packets > 0) { | 95 if (num_fec_packets > 0) { |
96 std::vector<std::unique_ptr<RedPacket>> fec_packets = | 96 std::vector<std::unique_ptr<RedPacket>> fec_packets = |
97 producer_.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType, 100, | 97 producer_.GetUlpfecPacketsAsRed(kRedPayloadType, kFecPayloadType, 100, |
98 p.header_size); | 98 p.header_size); |
99 EXPECT_EQ(num_fec_packets, fec_packets.size()); | 99 EXPECT_EQ(num_fec_packets, fec_packets.size()); |
100 } | 100 } |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 TEST_F(ProducerFecTest, OneFrameFec) { | 104 TEST_F(ProducerFecTest, OneFrameFec) { |
105 // The number of media packets (|kNumPackets|), number of frames (one for | 105 // The number of media packets (|kNumPackets|), number of frames (one for |
106 // this test), and the protection factor (|params->fec_rate|) are set to make | 106 // this test), and the protection factor (|params->fec_rate|) are set to make |
107 // sure the conditions for generating FEC are satisfied. This means: | 107 // sure the conditions for generating FEC are satisfied. This means: |
108 // (1) protection factor is high enough so that actual overhead over 1 frame | 108 // (1) protection factor is high enough so that actual overhead over 1 frame |
109 // of packets is within |kMaxExcessOverhead|, and (2) the total number of | 109 // of packets is within |kMaxExcessOverhead|, and (2) the total number of |
110 // media packets for 1 frame is at least |minimum_media_packets_fec_|. | 110 // media packets for 1 frame is at least |minimum_media_packets_fec_|. |
111 constexpr size_t kNumPackets = 4; | 111 constexpr size_t kNumPackets = 4; |
112 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 112 FecProtectionParams params = {15, 3, kFecMaskRandom}; |
113 packet_generator_.NewFrame(kNumPackets); | 113 packet_generator_.NewFrame(kNumPackets); |
114 producer_.SetFecParameters(¶ms, 0); // Expecting one FEC packet. | 114 producer_.SetFecParameters(¶ms); // Expecting one FEC packet. |
115 uint32_t last_timestamp = 0; | 115 uint32_t last_timestamp = 0; |
116 for (size_t i = 0; i < kNumPackets; ++i) { | 116 for (size_t i = 0; i < kNumPackets; ++i) { |
117 std::unique_ptr<AugmentedPacket> packet = | 117 std::unique_ptr<AugmentedPacket> packet = |
118 packet_generator_.NextPacket(i, 10); | 118 packet_generator_.NextPacket(i, 10); |
119 EXPECT_EQ(0, producer_.AddRtpPacketAndGenerateFec( | 119 EXPECT_EQ(0, producer_.AddRtpPacketAndGenerateFec( |
120 packet->data, packet->length, kRtpHeaderSize)); | 120 packet->data, packet->length, kRtpHeaderSize)); |
121 last_timestamp = packet->header.header.timestamp; | 121 last_timestamp = packet->header.header.timestamp; |
122 } | 122 } |
123 EXPECT_TRUE(producer_.FecAvailable()); | 123 EXPECT_TRUE(producer_.FecAvailable()); |
124 uint16_t seq_num = packet_generator_.NextPacketSeqNum(); | 124 uint16_t seq_num = packet_generator_.NextPacketSeqNum(); |
(...skipping 11 matching lines...) Loading... |
136 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to | 136 // (|kNumFrames|), and the protection factor (|params->fec_rate|) are set to |
137 // make sure the conditions for generating FEC are satisfied. This means: | 137 // make sure the conditions for generating FEC are satisfied. This means: |
138 // (1) protection factor is high enough so that actual overhead over | 138 // (1) protection factor is high enough so that actual overhead over |
139 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of | 139 // |kNumFrames| is within |kMaxExcessOverhead|, and (2) the total number of |
140 // media packets for |kNumFrames| frames is at least | 140 // media packets for |kNumFrames| frames is at least |
141 // |minimum_media_packets_fec_|. | 141 // |minimum_media_packets_fec_|. |
142 constexpr size_t kNumPackets = 2; | 142 constexpr size_t kNumPackets = 2; |
143 constexpr size_t kNumFrames = 2; | 143 constexpr size_t kNumFrames = 2; |
144 | 144 |
145 FecProtectionParams params = {15, 3, kFecMaskRandom}; | 145 FecProtectionParams params = {15, 3, kFecMaskRandom}; |
146 producer_.SetFecParameters(¶ms, 0); // Expecting one FEC packet. | 146 producer_.SetFecParameters(¶ms); // Expecting one FEC packet. |
147 uint32_t last_timestamp = 0; | 147 uint32_t last_timestamp = 0; |
148 for (size_t i = 0; i < kNumFrames; ++i) { | 148 for (size_t i = 0; i < kNumFrames; ++i) { |
149 packet_generator_.NewFrame(kNumPackets); | 149 packet_generator_.NewFrame(kNumPackets); |
150 for (size_t j = 0; j < kNumPackets; ++j) { | 150 for (size_t j = 0; j < kNumPackets; ++j) { |
151 std::unique_ptr<AugmentedPacket> packet = | 151 std::unique_ptr<AugmentedPacket> packet = |
152 packet_generator_.NextPacket(i * kNumPackets + j, 10); | 152 packet_generator_.NextPacket(i * kNumPackets + j, 10); |
153 EXPECT_EQ(0, producer_.AddRtpPacketAndGenerateFec( | 153 EXPECT_EQ(0, producer_.AddRtpPacketAndGenerateFec( |
154 packet->data, packet->length, kRtpHeaderSize)); | 154 packet->data, packet->length, kRtpHeaderSize)); |
155 last_timestamp = packet->header.header.timestamp; | 155 last_timestamp = packet->header.header.timestamp; |
156 } | 156 } |
(...skipping 37 matching lines...) Loading... |
194 ProducerFec::BuildRedPacket(packet->data, packet->length - kRtpHeaderSize, | 194 ProducerFec::BuildRedPacket(packet->data, packet->length - kRtpHeaderSize, |
195 kRtpHeaderSize, kRedPayloadType); | 195 kRtpHeaderSize, kRedPayloadType); |
196 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length()); | 196 EXPECT_EQ(packet->length + kRedForFecHeaderLength, red_packet->length()); |
197 VerifyHeader(packet->header.header.sequenceNumber, | 197 VerifyHeader(packet->header.header.sequenceNumber, |
198 packet->header.header.timestamp, kRedPayloadType, | 198 packet->header.header.timestamp, kRedPayloadType, |
199 packet->header.header.payloadType, red_packet.get(), | 199 packet->header.header.payloadType, red_packet.get(), |
200 true); // Marker bit set. | 200 true); // Marker bit set. |
201 } | 201 } |
202 | 202 |
203 } // namespace webrtc | 203 } // namespace webrtc |
OLD | NEW |