OLD | NEW |
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // equal. However, the difference must be the same for all x. | 86 // equal. However, the difference must be the same for all x. |
87 int64_t arrival_time_delta = | 87 int64_t arrival_time_delta = |
88 truth[0].arrival_time_ms - input[0].arrival_time_ms; | 88 truth[0].arrival_time_ms - input[0].arrival_time_ms; |
89 for (size_t i = 0; i < len; ++i) { | 89 for (size_t i = 0; i < len; ++i) { |
90 EXPECT_EQ(truth[i].arrival_time_ms, | 90 EXPECT_EQ(truth[i].arrival_time_ms, |
91 input[i].arrival_time_ms + arrival_time_delta); | 91 input[i].arrival_time_ms + arrival_time_delta); |
92 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); | 92 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); |
93 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); | 93 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); |
94 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); | 94 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); |
95 EXPECT_EQ(truth[i].was_paced, input[i].was_paced); | 95 EXPECT_EQ(truth[i].was_paced, input[i].was_paced); |
| 96 EXPECT_EQ(truth[i].probe_cluster_id, input[i].probe_cluster_id); |
96 } | 97 } |
97 } | 98 } |
98 | 99 |
99 // Utility method, to reset arrival_time_ms before adding send time. | 100 // Utility method, to reset arrival_time_ms before adding send time. |
100 void OnSentPacket(PacketInfo info) { | 101 void OnSentPacket(PacketInfo info) { |
101 info.arrival_time_ms = 0; | 102 info.arrival_time_ms = 0; |
102 adapter_->AddPacket(info.sequence_number, info.payload_size, | 103 adapter_->AddPacket(info.sequence_number, info.payload_size, info.was_paced, |
103 info.was_paced); | 104 info.probe_cluster_id); |
104 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); | 105 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); |
105 } | 106 } |
106 | 107 |
107 SimulatedClock clock_; | 108 SimulatedClock clock_; |
108 MockRemoteBitrateEstimator* bitrate_estimator_; | 109 MockRemoteBitrateEstimator* bitrate_estimator_; |
109 MockBitrateControllerAdapter bitrate_controller_; | 110 MockBitrateControllerAdapter bitrate_controller_; |
110 std::unique_ptr<TransportFeedbackAdapter> adapter_; | 111 std::unique_ptr<TransportFeedbackAdapter> adapter_; |
111 | 112 |
112 uint32_t receiver_estimated_bitrate_; | 113 uint32_t receiver_estimated_bitrate_; |
113 }; | 114 }; |
114 | 115 |
115 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { | 116 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { |
116 std::vector<PacketInfo> packets; | 117 std::vector<PacketInfo> packets; |
117 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); | 118 packets.push_back(PacketInfo(100, 200, 0, 1500, true, 0)); |
118 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 119 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 0)); |
119 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); | 120 packets.push_back(PacketInfo(120, 220, 2, 1500, true, 0)); |
120 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); | 121 packets.push_back(PacketInfo(130, 230, 3, 1500, true, 1)); |
121 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); | 122 packets.push_back(PacketInfo(140, 240, 4, 1500, true, 1)); |
122 | 123 |
123 for (const PacketInfo& packet : packets) | 124 for (const PacketInfo& packet : packets) |
124 OnSentPacket(packet); | 125 OnSentPacket(packet); |
125 | 126 |
126 rtcp::TransportFeedback feedback; | 127 rtcp::TransportFeedback feedback; |
127 feedback.WithBase(packets[0].sequence_number, | 128 feedback.WithBase(packets[0].sequence_number, |
128 packets[0].arrival_time_ms * 1000); | 129 packets[0].arrival_time_ms * 1000); |
129 | 130 |
130 for (const PacketInfo& packet : packets) { | 131 for (const PacketInfo& packet : packets) { |
131 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, | 132 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, |
132 packet.arrival_time_ms * 1000)); | 133 packet.arrival_time_ms * 1000)); |
133 } | 134 } |
134 | 135 |
135 feedback.Build(); | 136 feedback.Build(); |
136 | 137 |
137 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_)) | 138 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_)) |
138 .Times(1) | 139 .Times(1) |
139 .WillOnce(Invoke( | 140 .WillOnce(Invoke( |
140 [packets, this](const std::vector<PacketInfo>& feedback_vector) { | 141 [packets, this](const std::vector<PacketInfo>& feedback_vector) { |
141 ComparePacketVectors(packets, feedback_vector); | 142 ComparePacketVectors(packets, feedback_vector); |
142 })); | 143 })); |
143 adapter_->OnTransportFeedback(feedback); | 144 adapter_->OnTransportFeedback(feedback); |
144 } | 145 } |
145 | 146 |
146 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { | 147 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { |
147 std::vector<PacketInfo> packets; | 148 std::vector<PacketInfo> packets; |
148 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); | 149 packets.push_back(PacketInfo(100, 200, 0, 1500, true, 1)); |
149 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 150 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 2)); |
150 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); | 151 packets.push_back(PacketInfo(120, 220, 2, 1500, true, 3)); |
151 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); | 152 packets.push_back(PacketInfo(130, 230, 3, 1500, true, 4)); |
152 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); | 153 packets.push_back(PacketInfo(140, 240, 4, 1500, true, 5)); |
153 | 154 |
154 const uint16_t kSendSideDropBefore = 1; | 155 const uint16_t kSendSideDropBefore = 1; |
155 const uint16_t kReceiveSideDropAfter = 3; | 156 const uint16_t kReceiveSideDropAfter = 3; |
156 | 157 |
157 for (const PacketInfo& packet : packets) { | 158 for (const PacketInfo& packet : packets) { |
158 if (packet.sequence_number >= kSendSideDropBefore) | 159 if (packet.sequence_number >= kSendSideDropBefore) |
159 OnSentPacket(packet); | 160 OnSentPacket(packet); |
160 } | 161 } |
161 | 162 |
162 rtcp::TransportFeedback feedback; | 163 rtcp::TransportFeedback feedback; |
(...skipping 20 matching lines...) Expand all Loading... |
183 ComparePacketVectors(expected_packets, feedback_vector); | 184 ComparePacketVectors(expected_packets, feedback_vector); |
184 })); | 185 })); |
185 adapter_->OnTransportFeedback(feedback); | 186 adapter_->OnTransportFeedback(feedback); |
186 } | 187 } |
187 | 188 |
188 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { | 189 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { |
189 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * | 190 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * |
190 static_cast<int64_t>(1 << 8) * | 191 static_cast<int64_t>(1 << 8) * |
191 static_cast<int64_t>((1 << 23) - 1) / 1000; | 192 static_cast<int64_t>((1 << 23) - 1) / 1000; |
192 std::vector<PacketInfo> packets; | 193 std::vector<PacketInfo> packets; |
193 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, true)); | 194 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, true, |
194 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, true)); | 195 PacketInfo::kNotAProbe)); |
195 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true)); | 196 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, true, |
| 197 PacketInfo::kNotAProbe)); |
| 198 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true, |
| 199 PacketInfo::kNotAProbe)); |
196 | 200 |
197 for (const PacketInfo& packet : packets) | 201 for (const PacketInfo& packet : packets) |
198 OnSentPacket(packet); | 202 OnSentPacket(packet); |
199 | 203 |
200 for (size_t i = 0; i < packets.size(); ++i) { | 204 for (size_t i = 0; i < packets.size(); ++i) { |
201 std::unique_ptr<rtcp::TransportFeedback> feedback( | 205 std::unique_ptr<rtcp::TransportFeedback> feedback( |
202 new rtcp::TransportFeedback()); | 206 new rtcp::TransportFeedback()); |
203 feedback->WithBase(packets[i].sequence_number, | 207 feedback->WithBase(packets[i].sequence_number, |
204 packets[i].arrival_time_ms * 1000); | 208 packets[i].arrival_time_ms * 1000); |
205 | 209 |
(...skipping 12 matching lines...) Expand all Loading... |
218 .WillOnce(Invoke([expected_packets, this]( | 222 .WillOnce(Invoke([expected_packets, this]( |
219 const std::vector<PacketInfo>& feedback_vector) { | 223 const std::vector<PacketInfo>& feedback_vector) { |
220 ComparePacketVectors(expected_packets, feedback_vector); | 224 ComparePacketVectors(expected_packets, feedback_vector); |
221 })); | 225 })); |
222 adapter_->OnTransportFeedback(*feedback.get()); | 226 adapter_->OnTransportFeedback(*feedback.get()); |
223 } | 227 } |
224 } | 228 } |
225 | 229 |
226 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { | 230 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { |
227 std::vector<PacketInfo> packets; | 231 std::vector<PacketInfo> packets; |
228 packets.push_back(PacketInfo(120, 200, 0, 1500, true)); | 232 packets.push_back(PacketInfo(120, 200, 0, 1500, true, 0)); |
229 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 233 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 0)); |
230 packets.push_back(PacketInfo(100, 220, 2, 1500, true)); | 234 packets.push_back(PacketInfo(100, 220, 2, 1500, true, 0)); |
231 std::vector<PacketInfo> expected_packets; | 235 std::vector<PacketInfo> expected_packets; |
232 expected_packets.push_back(packets[2]); | 236 expected_packets.push_back(packets[2]); |
233 expected_packets.push_back(packets[1]); | 237 expected_packets.push_back(packets[1]); |
234 expected_packets.push_back(packets[0]); | 238 expected_packets.push_back(packets[0]); |
235 | 239 |
236 for (const PacketInfo& packet : packets) | 240 for (const PacketInfo& packet : packets) |
237 OnSentPacket(packet); | 241 OnSentPacket(packet); |
238 | 242 |
239 rtcp::TransportFeedback feedback; | 243 rtcp::TransportFeedback feedback; |
240 feedback.WithBase(packets[0].sequence_number, | 244 feedback.WithBase(packets[0].sequence_number, |
(...skipping 19 matching lines...) Expand all Loading... |
260 std::vector<PacketInfo> sent_packets; | 264 std::vector<PacketInfo> sent_packets; |
261 const int64_t kSmallDeltaUs = | 265 const int64_t kSmallDeltaUs = |
262 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1); | 266 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1); |
263 const int64_t kLargePositiveDeltaUs = | 267 const int64_t kLargePositiveDeltaUs = |
264 rtcp::TransportFeedback::kDeltaScaleFactor * | 268 rtcp::TransportFeedback::kDeltaScaleFactor * |
265 std::numeric_limits<int16_t>::max(); | 269 std::numeric_limits<int16_t>::max(); |
266 const int64_t kLargeNegativeDeltaUs = | 270 const int64_t kLargeNegativeDeltaUs = |
267 rtcp::TransportFeedback::kDeltaScaleFactor * | 271 rtcp::TransportFeedback::kDeltaScaleFactor * |
268 std::numeric_limits<int16_t>::min(); | 272 std::numeric_limits<int16_t>::min(); |
269 | 273 |
270 PacketInfo info(100, 200, 0, 1500, true); | 274 PacketInfo info(100, 200, 0, 1500, true, PacketInfo::kNotAProbe); |
271 sent_packets.push_back(info); | 275 sent_packets.push_back(info); |
272 | 276 |
273 info.send_time_ms += kSmallDeltaUs / 1000; | 277 info.send_time_ms += kSmallDeltaUs / 1000; |
274 info.arrival_time_ms += kSmallDeltaUs / 1000; | 278 info.arrival_time_ms += kSmallDeltaUs / 1000; |
275 ++info.sequence_number; | 279 ++info.sequence_number; |
276 sent_packets.push_back(info); | 280 sent_packets.push_back(info); |
277 | 281 |
278 info.send_time_ms += kLargePositiveDeltaUs / 1000; | 282 info.send_time_ms += kLargePositiveDeltaUs / 1000; |
279 info.arrival_time_ms += kLargePositiveDeltaUs / 1000; | 283 info.arrival_time_ms += kLargePositiveDeltaUs / 1000; |
280 ++info.sequence_number; | 284 ++info.sequence_number; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 })); | 355 })); |
352 adapter_->OnTransportFeedback(*feedback.get()); | 356 adapter_->OnTransportFeedback(*feedback.get()); |
353 | 357 |
354 expected_packets.push_back(info); | 358 expected_packets.push_back(info); |
355 | 359 |
356 ComparePacketVectors(expected_packets, received_feedback); | 360 ComparePacketVectors(expected_packets, received_feedback); |
357 } | 361 } |
358 | 362 |
359 } // namespace test | 363 } // namespace test |
360 } // namespace webrtc | 364 } // namespace webrtc |
OLD | NEW |