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

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

Issue 2086633002: Revert of Remove audio/video distinction for probe packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
95 EXPECT_EQ(truth[i].probe_cluster_id, input[i].probe_cluster_id); 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.probe_cluster_id); 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, 0)); 118 packets.push_back(PacketInfo(100, 200, 0, 1500, true, 0));
118 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 119 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 0));
119 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); 120 packets.push_back(PacketInfo(120, 220, 2, 1500, true, 0));
120 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); 121 packets.push_back(PacketInfo(130, 230, 3, 1500, true, 1));
121 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); 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, 1)); 149 packets.push_back(PacketInfo(100, 200, 0, 1500, true, 1));
149 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); 150 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 2));
150 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); 151 packets.push_back(PacketInfo(120, 220, 2, 1500, true, 3));
151 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); 152 packets.push_back(PacketInfo(130, 230, 3, 1500, true, 4));
152 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); 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
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, 194 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, true,
194 PacketInfo::kNotAProbe)); 195 PacketInfo::kNotAProbe));
195 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, 196 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, true,
196 PacketInfo::kNotAProbe)); 197 PacketInfo::kNotAProbe));
197 packets.push_back( 198 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true,
198 PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, PacketInfo::kNotAProbe)); 199 PacketInfo::kNotAProbe));
199 200
200 for (const PacketInfo& packet : packets) 201 for (const PacketInfo& packet : packets)
201 OnSentPacket(packet); 202 OnSentPacket(packet);
202 203
203 for (size_t i = 0; i < packets.size(); ++i) { 204 for (size_t i = 0; i < packets.size(); ++i) {
204 std::unique_ptr<rtcp::TransportFeedback> feedback( 205 std::unique_ptr<rtcp::TransportFeedback> feedback(
205 new rtcp::TransportFeedback()); 206 new rtcp::TransportFeedback());
206 feedback->WithBase(packets[i].sequence_number, 207 feedback->WithBase(packets[i].sequence_number,
207 packets[i].arrival_time_ms * 1000); 208 packets[i].arrival_time_ms * 1000);
208 209
(...skipping 12 matching lines...) Expand all
221 .WillOnce(Invoke([expected_packets, this]( 222 .WillOnce(Invoke([expected_packets, this](
222 const std::vector<PacketInfo>& feedback_vector) { 223 const std::vector<PacketInfo>& feedback_vector) {
223 ComparePacketVectors(expected_packets, feedback_vector); 224 ComparePacketVectors(expected_packets, feedback_vector);
224 })); 225 }));
225 adapter_->OnTransportFeedback(*feedback.get()); 226 adapter_->OnTransportFeedback(*feedback.get());
226 } 227 }
227 } 228 }
228 229
229 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { 230 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) {
230 std::vector<PacketInfo> packets; 231 std::vector<PacketInfo> packets;
231 packets.push_back(PacketInfo(120, 200, 0, 1500, 0)); 232 packets.push_back(PacketInfo(120, 200, 0, 1500, true, 0));
232 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 233 packets.push_back(PacketInfo(110, 210, 1, 1500, true, 0));
233 packets.push_back(PacketInfo(100, 220, 2, 1500, 0)); 234 packets.push_back(PacketInfo(100, 220, 2, 1500, true, 0));
234 std::vector<PacketInfo> expected_packets; 235 std::vector<PacketInfo> expected_packets;
235 expected_packets.push_back(packets[2]); 236 expected_packets.push_back(packets[2]);
236 expected_packets.push_back(packets[1]); 237 expected_packets.push_back(packets[1]);
237 expected_packets.push_back(packets[0]); 238 expected_packets.push_back(packets[0]);
238 239
239 for (const PacketInfo& packet : packets) 240 for (const PacketInfo& packet : packets)
240 OnSentPacket(packet); 241 OnSentPacket(packet);
241 242
242 rtcp::TransportFeedback feedback; 243 rtcp::TransportFeedback feedback;
243 feedback.WithBase(packets[0].sequence_number, 244 feedback.WithBase(packets[0].sequence_number,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 })); 355 }));
355 adapter_->OnTransportFeedback(*feedback.get()); 356 adapter_->OnTransportFeedback(*feedback.get());
356 357
357 expected_packets.push_back(info); 358 expected_packets.push_back(info);
358 359
359 ComparePacketVectors(expected_packets, received_feedback); 360 ComparePacketVectors(expected_packets, received_feedback);
360 } 361 }
361 362
362 } // namespace test 363 } // namespace test
363 } // namespace webrtc 364 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698