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