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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 EXPECT_EQ(truth[i].arrival_time_ms, | 96 EXPECT_EQ(truth[i].arrival_time_ms, |
97 input[i].arrival_time_ms + arrival_time_delta); | 97 input[i].arrival_time_ms + arrival_time_delta); |
98 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); | 98 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); |
99 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); | 99 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); |
100 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); | 100 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); |
101 EXPECT_EQ(truth[i].was_paced, input[i].was_paced); | 101 EXPECT_EQ(truth[i].was_paced, input[i].was_paced); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 // Utility method, to reset arrival_time_ms before adding send time. | 105 // Utility method, to reset arrival_time_ms before adding send time. |
106 void OnPacketSent(PacketInfo info) { | 106 void OnSentPacket(PacketInfo info) { |
107 info.arrival_time_ms = 0; | 107 info.arrival_time_ms = 0; |
108 adapter_->OnPacketSent(info); | 108 adapter_->OnSentPacket(info); |
109 } | 109 } |
110 | 110 |
111 SimulatedClock clock_; | 111 SimulatedClock clock_; |
112 MockProcessThread process_thread_; | 112 MockProcessThread process_thread_; |
113 MockRemoteBitrateEstimator* bitrate_estimator_; | 113 MockRemoteBitrateEstimator* bitrate_estimator_; |
114 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_; | 114 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_; |
115 | 115 |
116 uint32_t receiver_estimated_bitrate_; | 116 uint32_t receiver_estimated_bitrate_; |
117 }; | 117 }; |
118 | 118 |
119 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { | 119 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { |
120 std::vector<PacketInfo> packets; | 120 std::vector<PacketInfo> packets; |
121 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); | 121 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); |
122 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 122 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); |
123 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); | 123 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); |
124 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); | 124 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); |
125 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); | 125 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); |
126 | 126 |
127 for (const PacketInfo& packet : packets) | 127 for (const PacketInfo& packet : packets) |
128 OnPacketSent(packet); | 128 OnSentPacket(packet); |
129 | 129 |
130 rtcp::TransportFeedback feedback; | 130 rtcp::TransportFeedback feedback; |
131 feedback.WithBase(packets[0].sequence_number, | 131 feedback.WithBase(packets[0].sequence_number, |
132 packets[0].arrival_time_ms * 1000); | 132 packets[0].arrival_time_ms * 1000); |
133 | 133 |
134 for (const PacketInfo& packet : packets) { | 134 for (const PacketInfo& packet : packets) { |
135 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, | 135 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, |
136 packet.arrival_time_ms * 1000)); | 136 packet.arrival_time_ms * 1000)); |
137 } | 137 } |
138 | 138 |
(...skipping 14 matching lines...) Expand all Loading... |
153 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); | 153 packets.push_back(PacketInfo(110, 210, 1, 1500, true)); |
154 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); | 154 packets.push_back(PacketInfo(120, 220, 2, 1500, true)); |
155 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); | 155 packets.push_back(PacketInfo(130, 230, 3, 1500, true)); |
156 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); | 156 packets.push_back(PacketInfo(140, 240, 4, 1500, true)); |
157 | 157 |
158 const uint16_t kSendSideDropBefore = 1; | 158 const uint16_t kSendSideDropBefore = 1; |
159 const uint16_t kReceiveSideDropAfter = 3; | 159 const uint16_t kReceiveSideDropAfter = 3; |
160 | 160 |
161 for (const PacketInfo& packet : packets) { | 161 for (const PacketInfo& packet : packets) { |
162 if (packet.sequence_number >= kSendSideDropBefore) | 162 if (packet.sequence_number >= kSendSideDropBefore) |
163 OnPacketSent(packet); | 163 OnSentPacket(packet); |
164 } | 164 } |
165 | 165 |
166 rtcp::TransportFeedback feedback; | 166 rtcp::TransportFeedback feedback; |
167 feedback.WithBase(packets[0].sequence_number, | 167 feedback.WithBase(packets[0].sequence_number, |
168 packets[0].arrival_time_ms * 1000); | 168 packets[0].arrival_time_ms * 1000); |
169 | 169 |
170 for (const PacketInfo& packet : packets) { | 170 for (const PacketInfo& packet : packets) { |
171 if (packet.sequence_number <= kReceiveSideDropAfter) { | 171 if (packet.sequence_number <= kReceiveSideDropAfter) { |
172 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, | 172 EXPECT_TRUE(feedback.WithReceivedPacket(packet.sequence_number, |
173 packet.arrival_time_ms * 1000)); | 173 packet.arrival_time_ms * 1000)); |
(...skipping 18 matching lines...) Expand all Loading... |
192 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { | 192 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { |
193 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * | 193 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * |
194 static_cast<int64_t>(1 << 8) * | 194 static_cast<int64_t>(1 << 8) * |
195 static_cast<int64_t>((1 << 23) - 1) / 1000; | 195 static_cast<int64_t>((1 << 23) - 1) / 1000; |
196 std::vector<PacketInfo> packets; | 196 std::vector<PacketInfo> packets; |
197 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, true)); | 197 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, true)); |
198 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, true)); | 198 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, true)); |
199 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true)); | 199 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true)); |
200 | 200 |
201 for (const PacketInfo& packet : packets) | 201 for (const PacketInfo& packet : packets) |
202 OnPacketSent(packet); | 202 OnSentPacket(packet); |
203 | 203 |
204 for (size_t i = 0; i < packets.size(); ++i) { | 204 for (size_t i = 0; i < packets.size(); ++i) { |
205 rtc::scoped_ptr<rtcp::TransportFeedback> feedback( | 205 rtc::scoped_ptr<rtcp::TransportFeedback> feedback( |
206 new rtcp::TransportFeedback()); | 206 new rtcp::TransportFeedback()); |
207 feedback->WithBase(packets[i].sequence_number, | 207 feedback->WithBase(packets[i].sequence_number, |
208 packets[i].arrival_time_ms * 1000); | 208 packets[i].arrival_time_ms * 1000); |
209 | 209 |
210 EXPECT_TRUE(feedback->WithReceivedPacket( | 210 EXPECT_TRUE(feedback->WithReceivedPacket( |
211 packets[i].sequence_number, packets[i].arrival_time_ms * 1000)); | 211 packets[i].sequence_number, packets[i].arrival_time_ms * 1000)); |
212 | 212 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ++info.sequence_number; | 256 ++info.sequence_number; |
257 sent_packets.push_back(info); | 257 sent_packets.push_back(info); |
258 | 258 |
259 // Too large, delta - will need two feedback messages. | 259 // Too large, delta - will need two feedback messages. |
260 info.send_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; | 260 info.send_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; |
261 info.arrival_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; | 261 info.arrival_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; |
262 ++info.sequence_number; | 262 ++info.sequence_number; |
263 | 263 |
264 // Packets will be added to send history. | 264 // Packets will be added to send history. |
265 for (const PacketInfo& packet : sent_packets) | 265 for (const PacketInfo& packet : sent_packets) |
266 OnPacketSent(packet); | 266 OnSentPacket(packet); |
267 OnPacketSent(info); | 267 OnSentPacket(info); |
268 | 268 |
269 // Create expected feedback and send into adapter. | 269 // Create expected feedback and send into adapter. |
270 rtc::scoped_ptr<rtcp::TransportFeedback> feedback( | 270 rtc::scoped_ptr<rtcp::TransportFeedback> feedback( |
271 new rtcp::TransportFeedback()); | 271 new rtcp::TransportFeedback()); |
272 feedback->WithBase(sent_packets[0].sequence_number, | 272 feedback->WithBase(sent_packets[0].sequence_number, |
273 sent_packets[0].arrival_time_ms * 1000); | 273 sent_packets[0].arrival_time_ms * 1000); |
274 | 274 |
275 for (const PacketInfo& packet : sent_packets) { | 275 for (const PacketInfo& packet : sent_packets) { |
276 EXPECT_TRUE(feedback->WithReceivedPacket(packet.sequence_number, | 276 EXPECT_TRUE(feedback->WithReceivedPacket(packet.sequence_number, |
277 packet.arrival_time_ms * 1000)); | 277 packet.arrival_time_ms * 1000)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 })); | 314 })); |
315 adapter_->OnTransportFeedback(*feedback.get()); | 315 adapter_->OnTransportFeedback(*feedback.get()); |
316 | 316 |
317 sent_packets.push_back(info); | 317 sent_packets.push_back(info); |
318 | 318 |
319 ComparePacketVectors(sent_packets, received_feedback); | 319 ComparePacketVectors(sent_packets, received_feedback); |
320 } | 320 } |
321 | 321 |
322 } // namespace test | 322 } // namespace test |
323 } // namespace webrtc | 323 } // namespace webrtc |
OLD | NEW |