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

Side by Side Diff: webrtc/modules/pacing/paced_sender_unittest.cc

Issue 2005313003: Propagate probing cluster id to SendTimeHistory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Test probe_cluster_id in PacketRouterTest. 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
« no previous file with comments | « webrtc/modules/pacing/paced_sender.cc ('k') | webrtc/modules/pacing/packet_router.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 14 matching lines...) Expand all
25 static const int kTargetBitrateBps = 800000; 25 static const int kTargetBitrateBps = 800000;
26 26
27 class MockPacedSenderCallback : public PacedSender::PacketSender { 27 class MockPacedSenderCallback : public PacedSender::PacketSender {
28 public: 28 public:
29 MOCK_METHOD5(TimeToSendPacket, 29 MOCK_METHOD5(TimeToSendPacket,
30 bool(uint32_t ssrc, 30 bool(uint32_t ssrc,
31 uint16_t sequence_number, 31 uint16_t sequence_number,
32 int64_t capture_time_ms, 32 int64_t capture_time_ms,
33 bool retransmission, 33 bool retransmission,
34 int probe_cluster_id)); 34 int probe_cluster_id));
35 MOCK_METHOD1(TimeToSendPadding, 35 MOCK_METHOD2(TimeToSendPadding, size_t(size_t bytes, int probe_cluster_id));
36 size_t(size_t bytes));
37 }; 36 };
38 37
39 class PacedSenderPadding : public PacedSender::PacketSender { 38 class PacedSenderPadding : public PacedSender::PacketSender {
40 public: 39 public:
41 PacedSenderPadding() : padding_sent_(0) {} 40 PacedSenderPadding() : padding_sent_(0) {}
42 41
43 bool TimeToSendPacket(uint32_t ssrc, 42 bool TimeToSendPacket(uint32_t ssrc,
44 uint16_t sequence_number, 43 uint16_t sequence_number,
45 int64_t capture_time_ms, 44 int64_t capture_time_ms,
46 bool retransmission, 45 bool retransmission,
47 int probe_cluster_id) override { 46 int probe_cluster_id) override {
48 return true; 47 return true;
49 } 48 }
50 49
51 size_t TimeToSendPadding(size_t bytes) override { 50 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) override {
52 const size_t kPaddingPacketSize = 224; 51 const size_t kPaddingPacketSize = 224;
53 size_t num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize; 52 size_t num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize;
54 padding_sent_ += kPaddingPacketSize * num_packets; 53 padding_sent_ += kPaddingPacketSize * num_packets;
55 return kPaddingPacketSize * num_packets; 54 return kPaddingPacketSize * num_packets;
56 } 55 }
57 56
58 size_t padding_sent() { return padding_sent_; } 57 size_t padding_sent() { return padding_sent_; }
59 58
60 private: 59 private:
61 size_t padding_sent_; 60 size_t padding_sent_;
62 }; 61 };
63 62
64 class PacedSenderProbing : public PacedSender::PacketSender { 63 class PacedSenderProbing : public PacedSender::PacketSender {
65 public: 64 public:
66 PacedSenderProbing(const std::list<int>& expected_deltas, Clock* clock) 65 PacedSenderProbing(const std::list<int>& expected_deltas, Clock* clock)
67 : prev_packet_time_ms_(-1), 66 : prev_packet_time_ms_(-1),
68 expected_deltas_(expected_deltas), 67 expected_deltas_(expected_deltas),
69 packets_sent_(0), 68 packets_sent_(0),
70 clock_(clock) {} 69 clock_(clock) {}
71 70
72 bool TimeToSendPacket(uint32_t ssrc, 71 bool TimeToSendPacket(uint32_t ssrc,
73 uint16_t sequence_number, 72 uint16_t sequence_number,
74 int64_t capture_time_ms, 73 int64_t capture_time_ms,
75 bool retransmission, 74 bool retransmission,
76 int probe_cluster_id) override { 75 int probe_cluster_id) override {
77 ExpectAndCountPacket(); 76 ExpectAndCountPacket();
78 return true; 77 return true;
79 } 78 }
80 79
81 size_t TimeToSendPadding(size_t bytes) override { 80 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) override {
82 ExpectAndCountPacket(); 81 ExpectAndCountPacket();
83 return bytes; 82 return bytes;
84 } 83 }
85 84
86 void ExpectAndCountPacket() { 85 void ExpectAndCountPacket() {
87 ++packets_sent_; 86 ++packets_sent_;
88 EXPECT_FALSE(expected_deltas_.empty()); 87 EXPECT_FALSE(expected_deltas_.empty());
89 if (expected_deltas_.empty()) 88 if (expected_deltas_.empty())
90 return; 89 return;
91 int64_t now_ms = clock_->TimeInMilliseconds(); 90 int64_t now_ms = clock_->TimeInMilliseconds();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 clock_.TimeInMilliseconds(), 250, false); 151 clock_.TimeInMilliseconds(), 250, false);
153 } 152 }
154 153
155 int64_t queued_packet_timestamp = clock_.TimeInMilliseconds(); 154 int64_t queued_packet_timestamp = clock_.TimeInMilliseconds();
156 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 155 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
157 sequence_number, queued_packet_timestamp, 250, 156 sequence_number, queued_packet_timestamp, 250,
158 false); 157 false);
159 EXPECT_EQ(packets_to_send + 1, send_bucket_->QueueSizePackets()); 158 EXPECT_EQ(packets_to_send + 1, send_bucket_->QueueSizePackets());
160 send_bucket_->Process(); 159 send_bucket_->Process();
161 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 160 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
162 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 161 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
163 clock_.AdvanceTimeMilliseconds(4); 162 clock_.AdvanceTimeMilliseconds(4);
164 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess()); 163 EXPECT_EQ(1, send_bucket_->TimeUntilNextProcess());
165 clock_.AdvanceTimeMilliseconds(1); 164 clock_.AdvanceTimeMilliseconds(1);
166 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 165 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
167 EXPECT_EQ(1u, send_bucket_->QueueSizePackets()); 166 EXPECT_EQ(1u, send_bucket_->QueueSizePackets());
168 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number++, 167 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, sequence_number++,
169 queued_packet_timestamp, false, _)) 168 queued_packet_timestamp, false, _))
170 .Times(1) 169 .Times(1)
171 .WillRepeatedly(Return(true)); 170 .WillRepeatedly(Return(true));
172 send_bucket_->Process(); 171 send_bucket_->Process();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 for (size_t j = 0; j < packets_to_send_per_interval * 10; ++j) { 203 for (size_t j = 0; j < packets_to_send_per_interval * 10; ++j) {
205 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 204 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
206 sequence_number++, clock_.TimeInMilliseconds(), 205 sequence_number++, clock_.TimeInMilliseconds(),
207 250, false); 206 250, false);
208 } 207 }
209 EXPECT_EQ(packets_to_send_per_interval + packets_to_send_per_interval * 10, 208 EXPECT_EQ(packets_to_send_per_interval + packets_to_send_per_interval * 10,
210 send_bucket_->QueueSizePackets()); 209 send_bucket_->QueueSizePackets());
211 send_bucket_->Process(); 210 send_bucket_->Process();
212 EXPECT_EQ(packets_to_send_per_interval * 10, 211 EXPECT_EQ(packets_to_send_per_interval * 10,
213 send_bucket_->QueueSizePackets()); 212 send_bucket_->QueueSizePackets());
214 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 213 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
215 for (int k = 0; k < 10; ++k) { 214 for (int k = 0; k < 10; ++k) {
216 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 215 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
217 clock_.AdvanceTimeMilliseconds(5); 216 clock_.AdvanceTimeMilliseconds(5);
218 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, _, false, _)) 217 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, _, false, _))
219 .Times(packets_to_send_per_interval) 218 .Times(packets_to_send_per_interval)
220 .WillRepeatedly(Return(true)); 219 .WillRepeatedly(Return(true));
221 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 220 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
222 send_bucket_->Process(); 221 send_bucket_->Process();
223 } 222 }
224 EXPECT_EQ(0u, send_bucket_->QueueSizePackets()); 223 EXPECT_EQ(0u, send_bucket_->QueueSizePackets());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 256
258 for (size_t j = 0; j < packets_to_send_per_interval * 10; ++j) { 257 for (size_t j = 0; j < packets_to_send_per_interval * 10; ++j) {
259 // Send in duplicate packets. 258 // Send in duplicate packets.
260 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 259 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
261 sequence_number, clock_.TimeInMilliseconds(), 260 sequence_number, clock_.TimeInMilliseconds(),
262 250, false); 261 250, false);
263 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 262 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
264 sequence_number++, clock_.TimeInMilliseconds(), 263 sequence_number++, clock_.TimeInMilliseconds(),
265 250, false); 264 250, false);
266 } 265 }
267 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 266 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
268 send_bucket_->Process(); 267 send_bucket_->Process();
269 for (int k = 0; k < 10; ++k) { 268 for (int k = 0; k < 10; ++k) {
270 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 269 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
271 clock_.AdvanceTimeMilliseconds(5); 270 clock_.AdvanceTimeMilliseconds(5);
272 271
273 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { 272 for (size_t i = 0; i < packets_to_send_per_interval; ++i) {
274 EXPECT_CALL(callback_, 273 EXPECT_CALL(callback_,
275 TimeToSendPacket(ssrc, queued_sequence_number++, _, false, _)) 274 TimeToSendPacket(ssrc, queued_sequence_number++, _, false, _))
276 .Times(1) 275 .Times(1)
277 .WillRepeatedly(Return(true)); 276 .WillRepeatedly(Return(true));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // Due to the multiplicative factor we can send 5 packets during a send 327 // Due to the multiplicative factor we can send 5 packets during a send
329 // interval. (network capacity * multiplier / (8 bits per byte * 328 // interval. (network capacity * multiplier / (8 bits per byte *
330 // (packet size * #send intervals per second) 329 // (packet size * #send intervals per second)
331 const size_t packets_to_send_per_interval = 330 const size_t packets_to_send_per_interval =
332 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / (8 * 250 * 200); 331 kTargetBitrateBps * PacedSender::kDefaultPaceMultiplier / (8 * 250 * 200);
333 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { 332 for (size_t i = 0; i < packets_to_send_per_interval; ++i) {
334 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, 333 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++,
335 clock_.TimeInMilliseconds(), 250, false); 334 clock_.TimeInMilliseconds(), 250, false);
336 } 335 }
337 // No padding is expected since we have sent too much already. 336 // No padding is expected since we have sent too much already.
338 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 337 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
339 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 338 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
340 send_bucket_->Process(); 339 send_bucket_->Process();
341 EXPECT_EQ(0u, send_bucket_->QueueSizePackets()); 340 EXPECT_EQ(0u, send_bucket_->QueueSizePackets());
342 341
343 // 5 milliseconds later should not send padding since we filled the buffers 342 // 5 milliseconds later should not send padding since we filled the buffers
344 // initially. 343 // initially.
345 EXPECT_CALL(callback_, TimeToSendPadding(250)).Times(0); 344 EXPECT_CALL(callback_, TimeToSendPadding(250, _)).Times(0);
346 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 345 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
347 clock_.AdvanceTimeMilliseconds(5); 346 clock_.AdvanceTimeMilliseconds(5);
348 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 347 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
349 send_bucket_->Process(); 348 send_bucket_->Process();
350 349
351 // 5 milliseconds later we have enough budget to send some padding. 350 // 5 milliseconds later we have enough budget to send some padding.
352 EXPECT_CALL(callback_, TimeToSendPadding(250)).Times(1). 351 EXPECT_CALL(callback_, TimeToSendPadding(250, _))
353 WillOnce(Return(250)); 352 .Times(1)
353 .WillOnce(Return(250));
354 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 354 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
355 clock_.AdvanceTimeMilliseconds(5); 355 clock_.AdvanceTimeMilliseconds(5);
356 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 356 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
357 send_bucket_->Process(); 357 send_bucket_->Process();
358 } 358 }
359 359
360 TEST_F(PacedSenderTest, VerifyPaddingUpToBitrate) { 360 TEST_F(PacedSenderTest, VerifyPaddingUpToBitrate) {
361 uint32_t ssrc = 12345; 361 uint32_t ssrc = 12345;
362 uint16_t sequence_number = 1234; 362 uint16_t sequence_number = 1234;
363 int64_t capture_time_ms = 56789; 363 int64_t capture_time_ms = 56789;
364 const int kTimeStep = 5; 364 const int kTimeStep = 5;
365 const int64_t kBitrateWindow = 100; 365 const int64_t kBitrateWindow = 100;
366 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps); 366 send_bucket_->SetEstimatedBitrate(kTargetBitrateBps);
367 send_bucket_->SetAllocatedSendBitrate(kTargetBitrateBps, kTargetBitrateBps); 367 send_bucket_->SetAllocatedSendBitrate(kTargetBitrateBps, kTargetBitrateBps);
368 368
369 int64_t start_time = clock_.TimeInMilliseconds(); 369 int64_t start_time = clock_.TimeInMilliseconds();
370 while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) { 370 while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) {
371 SendAndExpectPacket(PacedSender::kNormalPriority, 371 SendAndExpectPacket(PacedSender::kNormalPriority,
372 ssrc, 372 ssrc,
373 sequence_number++, 373 sequence_number++,
374 capture_time_ms, 374 capture_time_ms,
375 250, 375 250,
376 false); 376 false);
377 EXPECT_CALL(callback_, TimeToSendPadding(250)).Times(1). 377 EXPECT_CALL(callback_, TimeToSendPadding(250, _))
378 WillOnce(Return(250)); 378 .Times(1)
379 .WillOnce(Return(250));
379 send_bucket_->Process(); 380 send_bucket_->Process();
380 clock_.AdvanceTimeMilliseconds(kTimeStep); 381 clock_.AdvanceTimeMilliseconds(kTimeStep);
381 } 382 }
382 } 383 }
383 384
384 TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) { 385 TEST_F(PacedSenderTest, VerifyAverageBitrateVaryingMediaPayload) {
385 uint32_t ssrc = 12345; 386 uint32_t ssrc = 12345;
386 uint16_t sequence_number = 1234; 387 uint16_t sequence_number = 1234;
387 int64_t capture_time_ms = 56789; 388 int64_t capture_time_ms = 56789;
388 const int kTimeStep = 5; 389 const int kTimeStep = 5;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 250, false); 437 250, false);
437 438
438 for (size_t i = 0; i < packets_to_send_per_interval; ++i) { 439 for (size_t i = 0; i < packets_to_send_per_interval; ++i) {
439 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 440 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
440 sequence_number++, capture_time_ms, 250, false); 441 sequence_number++, capture_time_ms, 250, false);
441 } 442 }
442 send_bucket_->InsertPacket(PacedSender::kHighPriority, ssrc, 443 send_bucket_->InsertPacket(PacedSender::kHighPriority, ssrc,
443 sequence_number++, capture_time_ms, 250, false); 444 sequence_number++, capture_time_ms, 250, false);
444 445
445 // Expect all high and normal priority to be sent out first. 446 // Expect all high and normal priority to be sent out first.
446 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 447 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
447 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, capture_time_ms, false, _)) 448 EXPECT_CALL(callback_, TimeToSendPacket(ssrc, _, capture_time_ms, false, _))
448 .Times(packets_to_send_per_interval + 1) 449 .Times(packets_to_send_per_interval + 1)
449 .WillRepeatedly(Return(true)); 450 .WillRepeatedly(Return(true));
450 451
451 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); 452 EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess());
452 clock_.AdvanceTimeMilliseconds(5); 453 clock_.AdvanceTimeMilliseconds(5);
453 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 454 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
454 send_bucket_->Process(); 455 send_bucket_->Process();
455 EXPECT_EQ(1u, send_bucket_->QueueSizePackets()); 456 EXPECT_EQ(1u, send_bucket_->QueueSizePackets());
456 457
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 539
539 // Expect everything to be queued. 540 // Expect everything to be queued.
540 send_bucket_->InsertPacket(PacedSender::kLowPriority, ssrc_low_priority, 541 send_bucket_->InsertPacket(PacedSender::kLowPriority, ssrc_low_priority,
541 sequence_number++, second_capture_time_ms, 250, 542 sequence_number++, second_capture_time_ms, 250,
542 false); 543 false);
543 544
544 EXPECT_EQ(clock_.TimeInMilliseconds() - capture_time_ms, 545 EXPECT_EQ(clock_.TimeInMilliseconds() - capture_time_ms,
545 send_bucket_->QueueInMs()); 546 send_bucket_->QueueInMs());
546 547
547 // Expect no packet to come out while paused. 548 // Expect no packet to come out while paused.
548 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 549 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
549 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, _)).Times(0); 550 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, _)).Times(0);
550 551
551 for (int i = 0; i < 10; ++i) { 552 for (int i = 0; i < 10; ++i) {
552 clock_.AdvanceTimeMilliseconds(5); 553 clock_.AdvanceTimeMilliseconds(5);
553 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); 554 EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess());
554 send_bucket_->Process(); 555 send_bucket_->Process();
555 } 556 }
556 // Expect high prio packets to come out first followed by all packets in the 557 // Expect high prio packets to come out first followed by all packets in the
557 // way they were added. 558 // way they were added.
558 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false, _)) 559 EXPECT_CALL(callback_, TimeToSendPacket(_, _, capture_time_ms, false, _))
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 814
814 // Add 30kbit padding. When increasing budget, media budget will increase from 815 // Add 30kbit padding. When increasing budget, media budget will increase from
815 // negative (overuse) while padding budget will increase from 0. 816 // negative (overuse) while padding budget will increase from 0.
816 clock_.AdvanceTimeMilliseconds(5); 817 clock_.AdvanceTimeMilliseconds(5);
817 send_bucket_->SetAllocatedSendBitrate(60000, 30000); 818 send_bucket_->SetAllocatedSendBitrate(60000, 30000);
818 819
819 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++, 820 SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++,
820 clock_.TimeInMilliseconds(), kPacketSize, false); 821 clock_.TimeInMilliseconds(), kPacketSize, false);
821 EXPECT_LT(5u, send_bucket_->ExpectedQueueTimeMs()); 822 EXPECT_LT(5u, send_bucket_->ExpectedQueueTimeMs());
822 // Don't send padding if queue is non-empty, even if padding budget > 0. 823 // Don't send padding if queue is non-empty, even if padding budget > 0.
823 EXPECT_CALL(callback_, TimeToSendPadding(_)).Times(0); 824 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(0);
824 send_bucket_->Process(); 825 send_bucket_->Process();
825 } 826 }
826 827
827 TEST_F(PacedSenderTest, AverageQueueTime) { 828 TEST_F(PacedSenderTest, AverageQueueTime) {
828 uint32_t ssrc = 12346; 829 uint32_t ssrc = 12346;
829 uint16_t sequence_number = 1234; 830 uint16_t sequence_number = 1234;
830 const size_t kPacketSize = 1200; 831 const size_t kPacketSize = 1200;
831 const int kBitrateBps = 10 * kPacketSize * 8; // 10 packets per second. 832 const int kBitrateBps = 10 * kPacketSize * 8; // 10 packets per second.
832 833
833 send_bucket_->SetEstimatedBitrate(kBitrateBps); 834 send_bucket_->SetEstimatedBitrate(kBitrateBps);
(...skipping 28 matching lines...) Expand all
862 .Times(1) 863 .Times(1)
863 .WillRepeatedly(Return(true)); 864 .WillRepeatedly(Return(true));
864 for (int i = 0; i < 3; ++i) { 865 for (int i = 0; i < 3; ++i) {
865 clock_.AdvanceTimeMilliseconds(30); // Max delta. 866 clock_.AdvanceTimeMilliseconds(30); // Max delta.
866 send_bucket_->Process(); 867 send_bucket_->Process();
867 } 868 }
868 869
869 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs()); 870 EXPECT_EQ(0, send_bucket_->AverageQueueTimeMs());
870 } 871 }
871 872
872 TEST_F(PacedSenderTest, ProbeClusterId) { 873 TEST_F(PacedSenderTest, DISABLED_ProbeClusterId) {
873 uint32_t ssrc = 12346; 874 uint32_t ssrc = 12346;
874 uint16_t sequence_number = 1234; 875 uint16_t sequence_number = 1234;
875 const size_t kPacketSize = 1200; 876 const size_t kPacketSize = 1200;
876 877
877 send_bucket_->SetProbingEnabled(true); 878 send_bucket_->SetProbingEnabled(true);
878 for (int i = 0; i < 11; ++i) { 879 for (int i = 0; i < 11; ++i) {
879 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc, 880 send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
880 sequence_number + i, clock_.TimeInMilliseconds(), 881 sequence_number + i, clock_.TimeInMilliseconds(),
881 kPacketSize, false); 882 kPacketSize, false);
882 } 883 }
883 884
884 // First probing cluster. 885 // First probing cluster.
885 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, 0)) 886 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, 0))
886 .Times(6) 887 .Times(6)
887 .WillRepeatedly(Return(true)); 888 .WillRepeatedly(Return(true));
888 for (int i = 0; i < 6; ++i) 889 for (int i = 0; i < 6; ++i)
889 send_bucket_->Process(); 890 send_bucket_->Process();
890 891
891 // Second probing cluster. 892 // Second probing cluster.
892 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, 1)) 893 EXPECT_CALL(callback_, TimeToSendPacket(_, _, _, _, 1))
893 .Times(5) 894 .Times(5)
894 .WillRepeatedly(Return(true)); 895 .WillRepeatedly(Return(true));
895 for (int i = 0; i < 5; ++i) 896 for (int i = 0; i < 5; ++i)
896 send_bucket_->Process(); 897 send_bucket_->Process();
897 898
898 // No more probing packets. 899 // No more probing packets.
899 EXPECT_CALL(callback_, TimeToSendPadding(_)) 900 EXPECT_CALL(callback_, TimeToSendPadding(_, _)).Times(1);
900 .Times(1);
901 send_bucket_->Process(); 901 send_bucket_->Process();
902 } 902 }
903 903
904 } // namespace test 904 } // namespace test
905 } // namespace webrtc 905 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/pacing/paced_sender.cc ('k') | webrtc/modules/pacing/packet_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698