Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/flexfec_receiver_unittest.cc

Issue 2553863003: Parse FlexFEC RTP headers in Call and add integration with BWE. (Closed)
Patch Set: Work in progress. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "webrtc/base/basictypes.h" 14 #include "webrtc/base/basictypes.h"
15 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
15 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" 16 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h"
16 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" 17 #include "webrtc/modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h"
17 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h" 18 #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h"
18 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" 19 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
19 #include "webrtc/test/gmock.h" 23 #include "webrtc/test/gmock.h"
20 #include "webrtc/test/gtest.h" 24 #include "webrtc/test/gtest.h"
21 25
22 namespace webrtc { 26 namespace webrtc {
23 27
24 namespace { 28 namespace {
25 29
26 using ::testing::_; 30 using ::testing::_;
27 using ::testing::Args; 31 using ::testing::Args;
28 using ::testing::ElementsAreArray; 32 using ::testing::ElementsAreArray;
29 using ::testing::Return; 33 using ::testing::Return;
34 using ::testing::SaveArg;
30 35
31 using test::fec::FlexfecPacketGenerator; 36 using test::fec::FlexfecPacketGenerator;
32 using Packet = ForwardErrorCorrection::Packet; 37 using Packet = ForwardErrorCorrection::Packet;
33 using PacketList = ForwardErrorCorrection::PacketList; 38 using PacketList = ForwardErrorCorrection::PacketList;
34 39
35 constexpr size_t kPayloadLength = 500; 40 constexpr size_t kPayloadLength = 500;
36 constexpr uint32_t kFlexfecSsrc = 42984; 41 constexpr uint32_t kFlexfecSsrc = 42984;
37 constexpr uint32_t kMediaSsrc = 8353; 42 constexpr uint32_t kMediaSsrc = 8353;
38 43
44 template <typename T>
45 RtpPacketReceived ParsePacket(const std::unique_ptr<T>& packet) {
46 RtpPacketReceived parsed_packet(nullptr);
47 parsed_packet.Parse(packet->data, packet->length);
48 return parsed_packet;
49 }
50
39 } // namespace 51 } // namespace
40 52
41 class FlexfecReceiverTest : public ::testing::Test { 53 class FlexfecReceiverTest : public ::testing::Test {
42 protected: 54 protected:
43 FlexfecReceiverTest() 55 FlexfecReceiverTest()
44 : receiver_(kFlexfecSsrc, kMediaSsrc, &recovered_packet_receiver_), 56 : receiver_(kFlexfecSsrc,
57 kMediaSsrc,
58 &recovered_packet_receiver_,
59 &remote_bitrate_estimator_),
45 erasure_code_(ForwardErrorCorrection::CreateFlexfec()), 60 erasure_code_(ForwardErrorCorrection::CreateFlexfec()),
46 packet_generator_(kMediaSsrc, kFlexfecSsrc) {} 61 packet_generator_(kMediaSsrc, kFlexfecSsrc) {}
47 62
48 // Generates |num_media_packets| corresponding to a single frame. 63 // Generates |num_media_packets| corresponding to a single frame.
49 void PacketizeFrame(size_t num_media_packets, 64 void PacketizeFrame(size_t num_media_packets,
50 size_t frame_offset, 65 size_t frame_offset,
51 PacketList* media_packets); 66 PacketList* media_packets);
52 67
53 // Generates |num_fec_packets| FEC packets, given |media_packets|. 68 // Generates |num_fec_packets| FEC packets, given |media_packets|.
54 std::list<Packet*> EncodeFec(const PacketList& media_packets, 69 std::list<Packet*> EncodeFec(const PacketList& media_packets,
55 size_t num_fec_packets); 70 size_t num_fec_packets);
56 71
57 FlexfecReceiver receiver_; 72 FlexfecReceiver receiver_;
58 std::unique_ptr<ForwardErrorCorrection> erasure_code_; 73 std::unique_ptr<ForwardErrorCorrection> erasure_code_;
59 74
60 FlexfecPacketGenerator packet_generator_; 75 FlexfecPacketGenerator packet_generator_;
61 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver_; 76 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver_;
77 MockRemoteBitrateEstimator remote_bitrate_estimator_;
62 }; 78 };
63 79
64 void FlexfecReceiverTest::PacketizeFrame(size_t num_media_packets, 80 void FlexfecReceiverTest::PacketizeFrame(size_t num_media_packets,
65 size_t frame_offset, 81 size_t frame_offset,
66 PacketList* media_packets) { 82 PacketList* media_packets) {
67 packet_generator_.NewFrame(num_media_packets); 83 packet_generator_.NewFrame(num_media_packets);
68 for (size_t i = 0; i < num_media_packets; ++i) { 84 for (size_t i = 0; i < num_media_packets; ++i) {
69 std::unique_ptr<Packet> next_packet( 85 std::unique_ptr<Packet> next_packet(
70 packet_generator_.NextPacket(frame_offset + i, kPayloadLength)); 86 packet_generator_.NextPacket(frame_offset + i, kPayloadLength));
71 media_packets->push_back(std::move(next_packet)); 87 media_packets->push_back(std::move(next_packet));
(...skipping 14 matching lines...) Expand all
86 kUseUnequalProtection, kFecMaskType, &fec_packets)); 102 kUseUnequalProtection, kFecMaskType, &fec_packets));
87 EXPECT_EQ(num_fec_packets, fec_packets.size()); 103 EXPECT_EQ(num_fec_packets, fec_packets.size());
88 return fec_packets; 104 return fec_packets;
89 } 105 }
90 106
91 TEST_F(FlexfecReceiverTest, ReceivesMediaPacket) { 107 TEST_F(FlexfecReceiverTest, ReceivesMediaPacket) {
92 packet_generator_.NewFrame(1); 108 packet_generator_.NewFrame(1);
93 std::unique_ptr<Packet> media_packet( 109 std::unique_ptr<Packet> media_packet(
94 packet_generator_.NextPacket(0, kPayloadLength)); 110 packet_generator_.NextPacket(0, kPayloadLength));
95 111
96 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 112 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
97 media_packet->length));
98 } 113 }
99 114
100 TEST_F(FlexfecReceiverTest, FailsOnTruncatedMediaPacket) { 115 TEST_F(FlexfecReceiverTest, FailsOnTruncatedMediaPacket) {
101 const size_t kNoPayload = 0; 116 const size_t kNoPayload = 0;
102 117
103 packet_generator_.NewFrame(1); 118 packet_generator_.NewFrame(1);
104 std::unique_ptr<Packet> media_packet( 119 std::unique_ptr<Packet> media_packet(
105 packet_generator_.NextPacket(0, kNoPayload)); 120 packet_generator_.NextPacket(0, kNoPayload));
106 // Simulate truncated media packet. 121 // Simulate truncated media packet.
107 media_packet->length = kRtpHeaderSize - 1; 122 media_packet->length = kRtpHeaderSize - 1;
108 123
109 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 124 EXPECT_FALSE(
110 media_packet->length)); 125 receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
111 } 126 }
112 127
113 TEST_F(FlexfecReceiverTest, ReceivesMediaAndFecPackets) { 128 TEST_F(FlexfecReceiverTest, ReceivesMediaAndFecPackets) {
114 const size_t kNumMediaPackets = 1; 129 const size_t kNumMediaPackets = 1;
115 const size_t kNumFecPackets = 1; 130 const size_t kNumFecPackets = 1;
116 131
117 PacketList media_packets; 132 PacketList media_packets;
118 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 133 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
119 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 134 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
120 auto media_packet = media_packets.front().get(); 135 const auto& media_packet = media_packets.front();
121 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front()); 136 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front());
122 137
123 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 138 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
124 media_packet->length)); 139 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(fec_packet)));
125 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(fec_packet->data,
126 fec_packet->length));
127 } 140 }
128 141
129 TEST_F(FlexfecReceiverTest, FailsOnTruncatedFecPacket) { 142 TEST_F(FlexfecReceiverTest, FailsOnTruncatedFecPacket) {
130 const size_t kNumMediaPackets = 1; 143 const size_t kNumMediaPackets = 1;
131 const size_t kNumFecPackets = 1; 144 const size_t kNumFecPackets = 1;
132 145
133 PacketList media_packets; 146 PacketList media_packets;
134 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 147 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
135 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 148 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
136 auto media_packet = media_packets.front().get(); 149 const auto& media_packet = media_packets.front();
137 // Simulate truncated FlexFEC payload. 150 // Simulate truncated FlexFEC payload.
138 fec_packets.front()->length = 1; 151 fec_packets.front()->length = 1;
139 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front()); 152 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front());
140 153
141 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 154 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
142 media_packet->length)); 155 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(ParsePacket(fec_packet)));
143 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(fec_packet->data,
144 fec_packet->length));
145 } 156 }
146 157
147 TEST_F(FlexfecReceiverTest, FailsOnUnknownMediaSsrc) { 158 TEST_F(FlexfecReceiverTest, FailsOnUnknownMediaSsrc) {
148 const size_t kNumMediaPackets = 1; 159 const size_t kNumMediaPackets = 1;
149 160
150 PacketList media_packets; 161 PacketList media_packets;
151 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 162 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
152 auto media_packet = media_packets.front().get(); 163 auto& media_packet = media_packets.front();
153 // Corrupt the SSRC. 164 // Corrupt the SSRC.
154 media_packet->data[8] = 0; 165 media_packet->data[8] = 0;
155 media_packet->data[9] = 1; 166 media_packet->data[9] = 1;
156 media_packet->data[10] = 2; 167 media_packet->data[10] = 2;
157 media_packet->data[11] = 3; 168 media_packet->data[11] = 3;
158 169
159 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 170 EXPECT_FALSE(
160 media_packet->length)); 171 receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
161 } 172 }
162 173
163 TEST_F(FlexfecReceiverTest, FailsOnUnknownFecSsrc) { 174 TEST_F(FlexfecReceiverTest, FailsOnUnknownFecSsrc) {
164 const size_t kNumMediaPackets = 1; 175 const size_t kNumMediaPackets = 1;
165 const size_t kNumFecPackets = 1; 176 const size_t kNumFecPackets = 1;
166 177
167 PacketList media_packets; 178 PacketList media_packets;
168 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 179 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
169 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 180 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
170 auto media_packet = media_packets.front().get(); 181 const auto& media_packet = media_packets.front();
171 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front()); 182 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front());
172 // Corrupt the SSRC. 183 // Corrupt the SSRC.
173 fec_packet->data[8] = 4; 184 fec_packet->data[8] = 4;
174 fec_packet->data[9] = 5; 185 fec_packet->data[9] = 5;
175 fec_packet->data[10] = 6; 186 fec_packet->data[10] = 6;
176 fec_packet->data[11] = 7; 187 fec_packet->data[11] = 7;
177 188
178 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 189 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
179 media_packet->length)); 190 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(ParsePacket(fec_packet)));
180 EXPECT_FALSE(receiver_.AddAndProcessReceivedPacket(fec_packet->data,
181 fec_packet->length));
182 } 191 }
183 192
184 TEST_F(FlexfecReceiverTest, ReceivesMultiplePackets) { 193 TEST_F(FlexfecReceiverTest, ReceivesMultiplePackets) {
185 const size_t kNumMediaPackets = 2; 194 const size_t kNumMediaPackets = 2;
186 const size_t kNumFecPackets = 1; 195 const size_t kNumFecPackets = 1;
187 196
188 PacketList media_packets; 197 PacketList media_packets;
189 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 198 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
190 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 199 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
191 200
192 // Receive all media packets. 201 // Receive all media packets.
193 for (const auto& media_packet : media_packets) { 202 for (const auto& media_packet : media_packets) {
194 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(media_packet->data, 203 EXPECT_TRUE(
195 media_packet->length)); 204 receiver_.AddAndProcessReceivedPacket(ParsePacket(media_packet)));
196 } 205 }
197 206
198 // Receive FEC packet. 207 // Receive FEC packet.
199 auto fec_packet = fec_packets.front(); 208 auto fec_packet = fec_packets.front();
200 std::unique_ptr<Packet> packet_with_rtp_header = 209 std::unique_ptr<Packet> packet_with_rtp_header =
201 packet_generator_.BuildFlexfecPacket(*fec_packet); 210 packet_generator_.BuildFlexfecPacket(*fec_packet);
202 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 211 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
203 packet_with_rtp_header->data, packet_with_rtp_header->length)); 212 ParsePacket(packet_with_rtp_header)));
204 } 213 }
205 214
206 TEST_F(FlexfecReceiverTest, RecoversFromSingleMediaLoss) { 215 TEST_F(FlexfecReceiverTest, RecoversFromSingleMediaLoss) {
207 const size_t kNumMediaPackets = 2; 216 const size_t kNumMediaPackets = 2;
208 const size_t kNumFecPackets = 1; 217 const size_t kNumFecPackets = 1;
209 218
210 PacketList media_packets; 219 PacketList media_packets;
211 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 220 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
212 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 221 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
213 222
214 // Receive first media packet but drop second. 223 // Receive first media packet but drop second.
215 auto media_it = media_packets.begin(); 224 auto media_it = media_packets.begin();
216 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 225 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
217 (*media_it)->length));
218 226
219 // Receive FEC packet and ensure recovery of lost media packet. 227 // Receive FEC packet and ensure recovery of lost media packet.
220 auto fec_it = fec_packets.begin(); 228 auto fec_it = fec_packets.begin();
221 std::unique_ptr<Packet> packet_with_rtp_header = 229 std::unique_ptr<Packet> packet_with_rtp_header =
222 packet_generator_.BuildFlexfecPacket(**fec_it); 230 packet_generator_.BuildFlexfecPacket(**fec_it);
223 media_it++; 231 media_it++;
224 EXPECT_CALL(recovered_packet_receiver_, 232 EXPECT_CALL(recovered_packet_receiver_,
225 OnRecoveredPacket(_, (*media_it)->length)) 233 OnRecoveredPacket(_, (*media_it)->length))
226 .With( 234 .With(
227 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 235 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
228 .WillOnce(Return(true)); 236 .WillOnce(Return(true));
229 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 237 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
230 packet_with_rtp_header->data, packet_with_rtp_header->length)); 238 ParsePacket(packet_with_rtp_header)));
231 } 239 }
232 240
233 TEST_F(FlexfecReceiverTest, RecoversFromDoubleMediaLoss) { 241 TEST_F(FlexfecReceiverTest, RecoversFromDoubleMediaLoss) {
234 const size_t kNumMediaPackets = 2; 242 const size_t kNumMediaPackets = 2;
235 const size_t kNumFecPackets = 2; 243 const size_t kNumFecPackets = 2;
236 244
237 PacketList media_packets; 245 PacketList media_packets;
238 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 246 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
239 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 247 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
240 248
241 // Drop both media packets. 249 // Drop both media packets.
242 250
243 // Receive first FEC packet and recover first lost media packet. 251 // Receive first FEC packet and recover first lost media packet.
244 auto fec_it = fec_packets.begin(); 252 auto fec_it = fec_packets.begin();
245 std::unique_ptr<Packet> packet_with_rtp_header = 253 std::unique_ptr<Packet> packet_with_rtp_header =
246 packet_generator_.BuildFlexfecPacket(**fec_it); 254 packet_generator_.BuildFlexfecPacket(**fec_it);
247 auto media_it = media_packets.begin(); 255 auto media_it = media_packets.begin();
248 EXPECT_CALL(recovered_packet_receiver_, 256 EXPECT_CALL(recovered_packet_receiver_,
249 OnRecoveredPacket(_, (*media_it)->length)) 257 OnRecoveredPacket(_, (*media_it)->length))
250 .With( 258 .With(
251 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 259 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
252 .WillOnce(Return(true)); 260 .WillOnce(Return(true));
253 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 261 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
254 packet_with_rtp_header->data, packet_with_rtp_header->length)); 262 ParsePacket(packet_with_rtp_header)));
255 263
256 // Receive second FEC packet and recover second lost media packet. 264 // Receive second FEC packet and recover second lost media packet.
257 fec_it++; 265 fec_it++;
258 packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); 266 packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it);
259 media_it++; 267 media_it++;
260 EXPECT_CALL(recovered_packet_receiver_, 268 EXPECT_CALL(recovered_packet_receiver_,
261 OnRecoveredPacket(_, (*media_it)->length)) 269 OnRecoveredPacket(_, (*media_it)->length))
262 .With( 270 .With(
263 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 271 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
264 .WillOnce(Return(true)); 272 .WillOnce(Return(true));
265 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 273 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
266 packet_with_rtp_header->data, packet_with_rtp_header->length)); 274 ParsePacket(packet_with_rtp_header)));
267 } 275 }
268 276
269 TEST_F(FlexfecReceiverTest, DoesNotRecoverFromMediaAndFecLoss) { 277 TEST_F(FlexfecReceiverTest, DoesNotRecoverFromMediaAndFecLoss) {
270 const size_t kNumMediaPackets = 2; 278 const size_t kNumMediaPackets = 2;
271 const size_t kNumFecPackets = 1; 279 const size_t kNumFecPackets = 1;
272 280
273 PacketList media_packets; 281 PacketList media_packets;
274 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 282 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
275 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 283 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
276 284
277 // Receive first media packet. 285 // Receive first media packet.
278 auto media_it = media_packets.begin(); 286 auto media_it = media_packets.begin();
279 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 287 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
280 (*media_it)->length));
281 288
282 // Drop second media packet and FEC packet. Do not expect call back. 289 // Drop second media packet and FEC packet. Do not expect call back.
283 } 290 }
284 291
285 TEST_F(FlexfecReceiverTest, DoesNotCallbackTwice) { 292 TEST_F(FlexfecReceiverTest, DoesNotCallbackTwice) {
286 const size_t kNumMediaPackets = 2; 293 const size_t kNumMediaPackets = 2;
287 const size_t kNumFecPackets = 1; 294 const size_t kNumFecPackets = 1;
288 295
289 PacketList media_packets; 296 PacketList media_packets;
290 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 297 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
291 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 298 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
292 299
293 // Receive first media packet but drop second. 300 // Receive first media packet but drop second.
294 auto media_it = media_packets.begin(); 301 auto media_it = media_packets.begin();
295 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 302 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
296 (*media_it)->length));
297 303
298 // Receive FEC packet and ensure recovery of lost media packet. 304 // Receive FEC packet and ensure recovery of lost media packet.
299 auto fec_it = fec_packets.begin(); 305 auto fec_it = fec_packets.begin();
300 std::unique_ptr<Packet> packet_with_rtp_header = 306 std::unique_ptr<Packet> packet_with_rtp_header =
301 packet_generator_.BuildFlexfecPacket(**fec_it); 307 packet_generator_.BuildFlexfecPacket(**fec_it);
302 media_it++; 308 media_it++;
303 EXPECT_CALL(recovered_packet_receiver_, 309 EXPECT_CALL(recovered_packet_receiver_,
304 OnRecoveredPacket(_, (*media_it)->length)) 310 OnRecoveredPacket(_, (*media_it)->length))
305 .With( 311 .With(
306 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 312 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
307 .WillOnce(Return(true)); 313 .WillOnce(Return(true));
308 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 314 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
309 packet_with_rtp_header->data, packet_with_rtp_header->length)); 315 ParsePacket(packet_with_rtp_header)));
310 316
311 // Receive FEC packet again. 317 // Receive FEC packet again.
312 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 318 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
313 packet_with_rtp_header->data, packet_with_rtp_header->length)); 319 ParsePacket(packet_with_rtp_header)));
314 320
315 // Do not call back again. 321 // Do not call back again.
316 } 322 }
317 323
318 // Here we are implicitly assuming packet masks that are suitable for 324 // Here we are implicitly assuming packet masks that are suitable for
319 // this type of 50% correlated loss. If we are changing our precomputed 325 // this type of 50% correlated loss. If we are changing our precomputed
320 // packet masks, this test might need to be updated. 326 // packet masks, this test might need to be updated.
321 TEST_F(FlexfecReceiverTest, RecoversFrom50PercentLoss) { 327 TEST_F(FlexfecReceiverTest, RecoversFrom50PercentLoss) {
322 const size_t kNumFecPackets = 5; 328 const size_t kNumFecPackets = 5;
323 const size_t kNumFrames = 2 * kNumFecPackets; 329 const size_t kNumFrames = 2 * kNumFecPackets;
324 const size_t kNumMediaPacketsPerFrame = 1; 330 const size_t kNumMediaPacketsPerFrame = 1;
325 331
326 PacketList media_packets; 332 PacketList media_packets;
327 for (size_t i = 0; i < kNumFrames; ++i) { 333 for (size_t i = 0; i < kNumFrames; ++i) {
328 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets); 334 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets);
329 } 335 }
330 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 336 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
331 337
332 // Drop every second media packet. 338 // Drop every second media packet.
333 auto media_it = media_packets.begin(); 339 auto media_it = media_packets.begin();
334 while (media_it != media_packets.end()) { 340 while (media_it != media_packets.end()) {
335 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 341 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
336 (*media_it)->length));
337 ++media_it; 342 ++media_it;
338 if (media_it == media_packets.end()) { 343 if (media_it == media_packets.end()) {
339 break; 344 break;
340 } 345 }
341 ++media_it; 346 ++media_it;
342 } 347 }
343 348
344 // Receive all FEC packets. 349 // Receive all FEC packets.
345 media_it = media_packets.begin(); 350 media_it = media_packets.begin();
346 for (const auto& fec_packet : fec_packets) { 351 for (const auto& fec_packet : fec_packets) {
347 std::unique_ptr<Packet> fec_packet_with_rtp_header = 352 std::unique_ptr<Packet> fec_packet_with_rtp_header =
348 packet_generator_.BuildFlexfecPacket(*fec_packet); 353 packet_generator_.BuildFlexfecPacket(*fec_packet);
349 ++media_it; 354 ++media_it;
350 if (media_it == media_packets.end()) { 355 if (media_it == media_packets.end()) {
351 break; 356 break;
352 } 357 }
353 EXPECT_CALL(recovered_packet_receiver_, 358 EXPECT_CALL(recovered_packet_receiver_,
354 OnRecoveredPacket(_, (*media_it)->length)) 359 OnRecoveredPacket(_, (*media_it)->length))
355 .With(Args<0, 1>( 360 .With(Args<0, 1>(
356 ElementsAreArray((*media_it)->data, (*media_it)->length))) 361 ElementsAreArray((*media_it)->data, (*media_it)->length)))
357 .WillOnce(Return(true)); 362 .WillOnce(Return(true));
358 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 363 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
359 fec_packet_with_rtp_header->data, fec_packet_with_rtp_header->length)); 364 ParsePacket(fec_packet_with_rtp_header)));
360 ++media_it; 365 ++media_it;
361 } 366 }
362 } 367 }
363 368
364 TEST_F(FlexfecReceiverTest, DelayedFecPacketDoesHelp) { 369 TEST_F(FlexfecReceiverTest, DelayedFecPacketDoesHelp) {
365 // These values need to be updated if the underlying erasure code 370 // These values need to be updated if the underlying erasure code
366 // implementation changes. 371 // implementation changes.
367 const size_t kNumFrames = 48; 372 const size_t kNumFrames = 48;
368 const size_t kNumMediaPacketsPerFrame = 1; 373 const size_t kNumMediaPacketsPerFrame = 1;
369 const size_t kNumFecPackets = 1; 374 const size_t kNumFecPackets = 1;
370 375
371 PacketList media_packets; 376 PacketList media_packets;
372 PacketizeFrame(kNumMediaPacketsPerFrame, 0, &media_packets); 377 PacketizeFrame(kNumMediaPacketsPerFrame, 0, &media_packets);
373 PacketizeFrame(kNumMediaPacketsPerFrame, 1, &media_packets); 378 PacketizeFrame(kNumMediaPacketsPerFrame, 1, &media_packets);
374 // Protect two first frames. 379 // Protect two first frames.
375 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 380 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
376 for (size_t i = 2; i < kNumFrames; ++i) { 381 for (size_t i = 2; i < kNumFrames; ++i) {
377 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets); 382 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets);
378 } 383 }
379 384
380 // Drop first media packet and delay FEC packet. 385 // Drop first media packet and delay FEC packet.
381 auto media_it = media_packets.begin(); 386 auto media_it = media_packets.begin();
382 ++media_it; 387 ++media_it;
383 388
384 // Receive all other media packets. 389 // Receive all other media packets.
385 while (media_it != media_packets.end()) { 390 while (media_it != media_packets.end()) {
386 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 391 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
387 (*media_it)->length));
388 ++media_it; 392 ++media_it;
389 } 393 }
390 394
391 // Receive FEC packet and recover first media packet. 395 // Receive FEC packet and recover first media packet.
392 auto fec_it = fec_packets.begin(); 396 auto fec_it = fec_packets.begin();
393 std::unique_ptr<Packet> packet_with_rtp_header = 397 std::unique_ptr<Packet> packet_with_rtp_header =
394 packet_generator_.BuildFlexfecPacket(**fec_it); 398 packet_generator_.BuildFlexfecPacket(**fec_it);
395 media_it = media_packets.begin(); 399 media_it = media_packets.begin();
396 EXPECT_CALL(recovered_packet_receiver_, 400 EXPECT_CALL(recovered_packet_receiver_,
397 OnRecoveredPacket(_, (*media_it)->length)) 401 OnRecoveredPacket(_, (*media_it)->length))
398 .With( 402 .With(
399 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 403 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
400 .WillOnce(Return(true)); 404 .WillOnce(Return(true));
401 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 405 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
402 packet_with_rtp_header->data, packet_with_rtp_header->length)); 406 ParsePacket(packet_with_rtp_header)));
403 } 407 }
404 408
405 TEST_F(FlexfecReceiverTest, TooDelayedFecPacketDoesNotHelp) { 409 TEST_F(FlexfecReceiverTest, TooDelayedFecPacketDoesNotHelp) {
406 // These values need to be updated if the underlying erasure code 410 // These values need to be updated if the underlying erasure code
407 // implementation changes. 411 // implementation changes.
408 const size_t kNumFrames = 49; 412 const size_t kNumFrames = 49;
409 const size_t kNumMediaPacketsPerFrame = 1; 413 const size_t kNumMediaPacketsPerFrame = 1;
410 const size_t kNumFecPackets = 1; 414 const size_t kNumFecPackets = 1;
411 415
412 PacketList media_packets; 416 PacketList media_packets;
413 PacketizeFrame(kNumMediaPacketsPerFrame, 0, &media_packets); 417 PacketizeFrame(kNumMediaPacketsPerFrame, 0, &media_packets);
414 PacketizeFrame(kNumMediaPacketsPerFrame, 1, &media_packets); 418 PacketizeFrame(kNumMediaPacketsPerFrame, 1, &media_packets);
415 // Protect two first frames. 419 // Protect two first frames.
416 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 420 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
417 for (size_t i = 2; i < kNumFrames; ++i) { 421 for (size_t i = 2; i < kNumFrames; ++i) {
418 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets); 422 PacketizeFrame(kNumMediaPacketsPerFrame, i, &media_packets);
419 } 423 }
420 424
421 // Drop first media packet and delay FEC packet. 425 // Drop first media packet and delay FEC packet.
422 auto media_it = media_packets.begin(); 426 auto media_it = media_packets.begin();
423 ++media_it; 427 ++media_it;
424 428
425 // Receive all other media packets. 429 // Receive all other media packets.
426 while (media_it != media_packets.end()) { 430 while (media_it != media_packets.end()) {
427 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 431 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
428 (*media_it)->length));
429 ++media_it; 432 ++media_it;
430 } 433 }
431 434
432 // Receive FEC packet. 435 // Receive FEC packet.
433 auto fec_it = fec_packets.begin(); 436 auto fec_it = fec_packets.begin();
434 std::unique_ptr<Packet> packet_with_rtp_header = 437 std::unique_ptr<Packet> packet_with_rtp_header =
435 packet_generator_.BuildFlexfecPacket(**fec_it); 438 packet_generator_.BuildFlexfecPacket(**fec_it);
436 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 439 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
437 packet_with_rtp_header->data, packet_with_rtp_header->length)); 440 ParsePacket(packet_with_rtp_header)));
438 441
439 // Do not expect a call back. 442 // Do not expect a call back.
440 } 443 }
441 444
442 TEST_F(FlexfecReceiverTest, RecoversWithMediaPacketsOutOfOrder) { 445 TEST_F(FlexfecReceiverTest, RecoversWithMediaPacketsOutOfOrder) {
443 const size_t kNumMediaPackets = 6; 446 const size_t kNumMediaPackets = 6;
444 const size_t kNumFecPackets = 2; 447 const size_t kNumFecPackets = 2;
445 448
446 PacketList media_packets; 449 PacketList media_packets;
447 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 450 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
448 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 451 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
449 452
450 // Lose two media packets, and receive the others out of order. 453 // Lose two media packets, and receive the others out of order.
451 auto media_it = media_packets.begin(); 454 auto media_it = media_packets.begin();
452 auto media_packet0 = media_it++; 455 auto media_packet0 = media_it++;
453 auto media_packet1 = media_it++; 456 auto media_packet1 = media_it++;
454 auto media_packet2 = media_it++; 457 auto media_packet2 = media_it++;
455 auto media_packet3 = media_it++; 458 auto media_packet3 = media_it++;
456 auto media_packet4 = media_it++; 459 auto media_packet4 = media_it++;
457 auto media_packet5 = media_it++; 460 auto media_packet5 = media_it++;
458 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_packet5)->data, 461 EXPECT_TRUE(
459 (*media_packet5)->length)); 462 receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_packet5)));
460 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_packet2)->data, 463 EXPECT_TRUE(
461 (*media_packet2)->length)); 464 receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_packet2)));
462 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_packet3)->data, 465 EXPECT_TRUE(
463 (*media_packet3)->length)); 466 receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_packet3)));
464 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_packet0)->data, 467 EXPECT_TRUE(
465 (*media_packet0)->length)); 468 receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_packet0)));
466 469
467 // Expect to recover lost media packets. 470 // Expect to recover lost media packets.
468 EXPECT_CALL(recovered_packet_receiver_, 471 EXPECT_CALL(recovered_packet_receiver_,
469 OnRecoveredPacket(_, (*media_packet1)->length)) 472 OnRecoveredPacket(_, (*media_packet1)->length))
470 .With(Args<0, 1>( 473 .With(Args<0, 1>(
471 ElementsAreArray((*media_packet1)->data, (*media_packet1)->length))) 474 ElementsAreArray((*media_packet1)->data, (*media_packet1)->length)))
472 .WillOnce(Return(true)); 475 .WillOnce(Return(true));
473 EXPECT_CALL(recovered_packet_receiver_, 476 EXPECT_CALL(recovered_packet_receiver_,
474 OnRecoveredPacket(_, (*media_packet4)->length)) 477 OnRecoveredPacket(_, (*media_packet4)->length))
475 .With(Args<0, 1>( 478 .With(Args<0, 1>(
476 ElementsAreArray((*media_packet4)->data, (*media_packet4)->length))) 479 ElementsAreArray((*media_packet4)->data, (*media_packet4)->length)))
477 .WillOnce(Return(true)); 480 .WillOnce(Return(true));
478 481
479 // Add FEC packets. 482 // Add FEC packets.
480 auto fec_it = fec_packets.begin(); 483 auto fec_it = fec_packets.begin();
481 std::unique_ptr<Packet> packet_with_rtp_header; 484 std::unique_ptr<Packet> packet_with_rtp_header;
482 while (fec_it != fec_packets.end()) { 485 while (fec_it != fec_packets.end()) {
483 packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it); 486 packet_with_rtp_header = packet_generator_.BuildFlexfecPacket(**fec_it);
484 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 487 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
485 packet_with_rtp_header->data, packet_with_rtp_header->length)); 488 ParsePacket(packet_with_rtp_header)));
486 ++fec_it; 489 ++fec_it;
487 } 490 }
488 } 491 }
489 492
493 TEST_F(FlexfecReceiverTest,
494 NotifiesBweOfReceivedFecPacketWithTransportSequenceNumberExtension) {
495 // Set up RTP header extensions.
496 testing::StrictMock<MockRecoveredPacketReceiver> recovered_packet_receiver;
497 testing::StrictMock<MockRemoteBitrateEstimator> remote_bitrate_estimator;
498 FlexfecReceiver receiver(kFlexfecSsrc, kMediaSsrc, &recovered_packet_receiver,
499 &remote_bitrate_estimator);
500 RtpHeaderExtensionMap rtp_header_extension_map;
501 rtp_header_extension_map.Register<TransportSequenceNumber>(
502 TransportSequenceNumber::kId);
danilchap 2016/12/06 15:04:30 sorry for confusing, but it is better not to use T
brandtr 2016/12/12 13:51:08 Done.
503
504 // Generate media and FEC payloads.
505 const size_t kNumMediaPackets = 1;
506 const size_t kNumFecPackets = 1;
507 PacketList media_packets;
508 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
509 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
510
511 // Add transport-wide sequence numbers to packets.
512 ASSERT_EQ(1u, media_packets.size());
513 auto media_packet = media_packets.front().get();
514 RtpPacketReceived media_packet_without_extension;
515 media_packet_without_extension.Parse(media_packet->data,
516 media_packet->length);
517 RtpPacketReceived media_packet_with_extension(&rtp_header_extension_map);
518 media_packet_with_extension.CopyHeaderFrom(media_packet_without_extension);
519 media_packet_with_extension.SetExtension<TransportSequenceNumber>(1);
520 uint8_t* media_payload = media_packet_with_extension.AllocatePayload(
521 media_packet_without_extension.payload_size());
522 memcpy(media_payload, media_packet_with_extension.payload().data(),
523 media_packet_without_extension.payload_size());
524
525 ASSERT_EQ(1u, fec_packets.size());
526 auto fec_packet = packet_generator_.BuildFlexfecPacket(*fec_packets.front());
527 RtpPacketReceived fec_packet_without_extension;
528 fec_packet_without_extension.Parse(fec_packet->data, fec_packet->length);
529 RtpPacketReceived fec_packet_with_extension(&rtp_header_extension_map);
530 fec_packet_with_extension.CopyHeaderFrom(fec_packet_without_extension);
531 fec_packet_with_extension.SetExtension<TransportSequenceNumber>(2);
532 uint8_t* fec_payload = fec_packet_with_extension.AllocatePayload(
533 fec_packet_without_extension.payload_size());
534 memcpy(fec_payload, fec_packet_with_extension.payload().data(),
535 fec_packet_without_extension.payload_size());
536
537 // Expect BWE notification for FEC packet, but not media packet.
538 RTPHeader reported_header;
539 EXPECT_CALL(remote_bitrate_estimator,
540 IncomingPacket(_, fec_packet_with_extension.payload_size(), _))
541 .WillOnce(SaveArg<2>(&reported_header));
542
543 // Add packets to receiver.
544 EXPECT_TRUE(
545 receiver.AddAndProcessReceivedPacket(media_packet_with_extension));
546 EXPECT_TRUE(receiver.AddAndProcessReceivedPacket(fec_packet_with_extension));
547
548 // Ensure that the BWE was notified of the FlexFEC packet.
549 EXPECT_EQ(kFlexfecSsrc, reported_header.ssrc);
550 EXPECT_EQ(2, reported_header.extension.transportSequenceNumber);
551 }
552
490 TEST_F(FlexfecReceiverTest, CalculatesNumberOfPackets) { 553 TEST_F(FlexfecReceiverTest, CalculatesNumberOfPackets) {
491 const size_t kNumMediaPackets = 2; 554 const size_t kNumMediaPackets = 2;
492 const size_t kNumFecPackets = 1; 555 const size_t kNumFecPackets = 1;
493 556
494 PacketList media_packets; 557 PacketList media_packets;
495 PacketizeFrame(kNumMediaPackets, 0, &media_packets); 558 PacketizeFrame(kNumMediaPackets, 0, &media_packets);
496 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets); 559 std::list<Packet*> fec_packets = EncodeFec(media_packets, kNumFecPackets);
497 560
498 // Receive first media packet but drop second. 561 // Receive first media packet but drop second.
499 auto media_it = media_packets.begin(); 562 auto media_it = media_packets.begin();
500 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket((*media_it)->data, 563 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(ParsePacket(*media_it)));
501 (*media_it)->length));
502 564
503 // Receive FEC packet and ensure recovery of lost media packet. 565 // Receive FEC packet and ensure recovery of lost media packet.
504 auto fec_it = fec_packets.begin(); 566 auto fec_it = fec_packets.begin();
505 std::unique_ptr<Packet> packet_with_rtp_header = 567 std::unique_ptr<Packet> packet_with_rtp_header =
506 packet_generator_.BuildFlexfecPacket(**fec_it); 568 packet_generator_.BuildFlexfecPacket(**fec_it);
507 media_it++; 569 media_it++;
508 EXPECT_CALL(recovered_packet_receiver_, 570 EXPECT_CALL(recovered_packet_receiver_,
509 OnRecoveredPacket(_, (*media_it)->length)) 571 OnRecoveredPacket(_, (*media_it)->length))
510 .With( 572 .With(
511 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length))) 573 Args<0, 1>(ElementsAreArray((*media_it)->data, (*media_it)->length)))
512 .WillOnce(Return(true)); 574 .WillOnce(Return(true));
513 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket( 575 EXPECT_TRUE(receiver_.AddAndProcessReceivedPacket(
514 packet_with_rtp_header->data, packet_with_rtp_header->length)); 576 ParsePacket(packet_with_rtp_header)));
515 577
516 // Check stats calculations. 578 // Check stats calculations.
517 FecPacketCounter packet_counter = receiver_.GetPacketCounter(); 579 FecPacketCounter packet_counter = receiver_.GetPacketCounter();
518 EXPECT_EQ(2U, packet_counter.num_packets); 580 EXPECT_EQ(2U, packet_counter.num_packets);
519 EXPECT_EQ(1U, packet_counter.num_fec_packets); 581 EXPECT_EQ(1U, packet_counter.num_fec_packets);
520 EXPECT_EQ(1U, packet_counter.num_recovered_packets); 582 EXPECT_EQ(1U, packet_counter.num_recovered_packets);
521 } 583 }
522 584
523 } // namespace webrtc 585 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698