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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc

Issue 2755553003: Ignore packets sent on old network route when receiving feedback. (Closed)
Patch Set: Comments addressed. Created 3 years, 9 months 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 18 matching lines...) Expand all
29 ~SendTimeHistoryTest() {} 29 ~SendTimeHistoryTest() {}
30 30
31 virtual void SetUp() {} 31 virtual void SetUp() {}
32 32
33 virtual void TearDown() {} 33 virtual void TearDown() {}
34 34
35 void AddPacketWithSendTime(uint16_t sequence_number, 35 void AddPacketWithSendTime(uint16_t sequence_number,
36 size_t length, 36 size_t length,
37 int64_t send_time_ms, 37 int64_t send_time_ms,
38 const PacedPacketInfo& pacing_info) { 38 const PacedPacketInfo& pacing_info) {
39 history_.AddAndRemoveOld(sequence_number, length, pacing_info); 39 PacketFeedback packet(clock_.TimeInMilliseconds(), sequence_number, length,
40 0, 0, pacing_info);
41 history_.AddAndRemoveOld(packet);
40 history_.OnSentPacket(sequence_number, send_time_ms); 42 history_.OnSentPacket(sequence_number, send_time_ms);
41 } 43 }
42 44
43 webrtc::SimulatedClock clock_; 45 webrtc::SimulatedClock clock_;
44 SendTimeHistory history_; 46 SendTimeHistory history_;
45 }; 47 };
46 48
49 TEST_F(SendTimeHistoryTest, SaveAndRestoreNetworkId) {
50 const PacedPacketInfo kPacingInfo(0, 5, 1200);
51 uint16_t sequence_number = 0;
52 int64_t now_ms = clock_.TimeInMilliseconds();
53 for (int i = 1; i < 5; ++i) {
54 PacketFeedback packet(now_ms, sequence_number++, 1000, i, i - 1,
55 kPacingInfo);
56 history_.AddAndRemoveOld(packet);
57 history_.OnSentPacket(sequence_number, now_ms);
58 PacketFeedback restored(now_ms, sequence_number);
59 EXPECT_TRUE(history_.GetFeedback(&restored, sequence_number));
60 EXPECT_EQ(packet.local_net_id, restored.local_net_id);
61 EXPECT_EQ(packet.remote_net_id, restored.remote_net_id);
62 }
63 }
64
47 TEST_F(SendTimeHistoryTest, AddRemoveOne) { 65 TEST_F(SendTimeHistoryTest, AddRemoveOne) {
48 const uint16_t kSeqNo = 10; 66 const uint16_t kSeqNo = 10;
49 // TODO(philipel): Fix PacedPacketInfo constructor? 67 // TODO(philipel): Fix PacedPacketInfo constructor?
50 const PacedPacketInfo kPacingInfo(0, 5, 1200); 68 const PacedPacketInfo kPacingInfo(0, 5, 1200);
51 const PacketFeedback kSentPacket(0, 1, kSeqNo, 1, kPacingInfo); 69 const PacketFeedback kSentPacket(0, 1, kSeqNo, 1, kPacingInfo);
52 AddPacketWithSendTime(kSeqNo, 1, 1, kPacingInfo); 70 AddPacketWithSendTime(kSeqNo, 1, 1, kPacingInfo);
53 71
54 PacketFeedback received_packet(0, 0, kSeqNo, 0, kPacingInfo); 72 PacketFeedback received_packet(0, 0, kSeqNo, 0, kPacingInfo);
55 EXPECT_TRUE(history_.GetFeedback(&received_packet, false)); 73 EXPECT_TRUE(history_.GetFeedback(&received_packet, false));
56 EXPECT_EQ(kSentPacket, received_packet); 74 EXPECT_EQ(kSentPacket, received_packet);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 const PacedPacketInfo kPacingInfo(1, 2, 200); 108 const PacedPacketInfo kPacingInfo(1, 2, 200);
91 for (size_t i = 0; i < num_items; ++i) { 109 for (size_t i = 0; i < num_items; ++i) {
92 sent_packets.push_back(PacketFeedback(0, static_cast<int64_t>(i), 110 sent_packets.push_back(PacketFeedback(0, static_cast<int64_t>(i),
93 static_cast<uint16_t>(i), kPacketSize, 111 static_cast<uint16_t>(i), kPacketSize,
94 kPacingInfo)); 112 kPacingInfo));
95 received_packets.push_back(PacketFeedback( 113 received_packets.push_back(PacketFeedback(
96 static_cast<int64_t>(i) + kTransmissionTime, 0, 114 static_cast<int64_t>(i) + kTransmissionTime, 0,
97 static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo())); 115 static_cast<uint16_t>(i), kPacketSize, PacedPacketInfo()));
98 } 116 }
99 for (size_t i = 0; i < num_items; ++i) { 117 for (size_t i = 0; i < num_items; ++i) {
100 history_.AddAndRemoveOld(sent_packets[i].sequence_number, 118 PacketFeedback packet = sent_packets[i];
101 sent_packets[i].payload_size, 119 packet.arrival_time_ms = -1;
102 PacedPacketInfo(1, 2, 200)); 120 packet.send_time_ms = -1;
121 history_.AddAndRemoveOld(packet);
103 } 122 }
104 for (size_t i = 0; i < num_items; ++i) 123 for (size_t i = 0; i < num_items; ++i)
105 history_.OnSentPacket(sent_packets[i].sequence_number, 124 history_.OnSentPacket(sent_packets[i].sequence_number,
106 sent_packets[i].send_time_ms); 125 sent_packets[i].send_time_ms);
107 std::random_shuffle(received_packets.begin(), received_packets.end()); 126 std::random_shuffle(received_packets.begin(), received_packets.end());
108 for (size_t i = 0; i < num_items; ++i) { 127 for (size_t i = 0; i < num_items; ++i) {
109 PacketFeedback packet = received_packets[i]; 128 PacketFeedback packet = received_packets[i];
110 EXPECT_TRUE(history_.GetFeedback(&packet, false)); 129 EXPECT_TRUE(history_.GetFeedback(&packet, false));
111 PacketFeedback sent_packet = sent_packets[packet.sequence_number]; 130 PacketFeedback sent_packet = sent_packets[packet.sequence_number];
112 sent_packet.arrival_time_ms = packet.arrival_time_ms; 131 sent_packet.arrival_time_ms = packet.arrival_time_ms;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 packets[2].send_time_ms, packets[2].pacing_info); 224 packets[2].send_time_ms, packets[2].pacing_info);
206 225
207 PacketFeedback packet2(0, 0, packets[1].sequence_number, 0, kPacingInfo1); 226 PacketFeedback packet2(0, 0, packets[1].sequence_number, 0, kPacingInfo1);
208 EXPECT_TRUE(history_.GetFeedback(&packet2, true)); 227 EXPECT_TRUE(history_.GetFeedback(&packet2, true));
209 EXPECT_EQ(packets[1], packet2); 228 EXPECT_EQ(packets[1], packet2);
210 229
211 PacketFeedback packet3(0, 0, packets[2].sequence_number, 0, kPacingInfo2); 230 PacketFeedback packet3(0, 0, packets[2].sequence_number, 0, kPacingInfo2);
212 EXPECT_TRUE(history_.GetFeedback(&packet3, true)); 231 EXPECT_TRUE(history_.GetFeedback(&packet3, true));
213 EXPECT_EQ(packets[2], packet3); 232 EXPECT_EQ(packets[2], packet3);
214 } 233 }
215
216 TEST_F(SendTimeHistoryTest, Clear) {
217 const uint16_t kSeqNo = 1;
218 const int64_t kTimestamp = 2;
219 const PacedPacketInfo kPacingInfo(0, 5, 1200);
220
221 PacketFeedback packets[] = {{0, kTimestamp, kSeqNo, 0, kPacingInfo},
222 {0, kTimestamp + 1, kSeqNo + 1, 0, kPacingInfo}};
223
224 AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size,
225 packets[0].send_time_ms, kPacingInfo);
226 AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size,
227 packets[1].send_time_ms, kPacingInfo);
228 PacketFeedback info(0, 0, packets[0].sequence_number, 0, kPacingInfo);
229 EXPECT_TRUE(history_.GetFeedback(&info, true));
230 EXPECT_EQ(packets[0], info);
231
232 history_.Clear();
233
234 PacketFeedback info2(0, 0, packets[1].sequence_number, 0, kPacingInfo);
235 EXPECT_FALSE(history_.GetFeedback(&info2, true));
236 }
237
238 } // namespace test 234 } // namespace test
239 } // namespace webrtc 235 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698