OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ASSERT_TRUE(IsSequenceNumberSorted(packets)); | 325 ASSERT_TRUE(IsSequenceNumberSorted(packets)); |
326 for (PacketsConstIt it = packets.begin(); it != packets.end(); ++it) { | 326 for (PacketsConstIt it = packets.begin(); it != packets.end(); ++it) { |
327 EXPECT_LE(now_ms_ * 1000, (*it)->send_time_us()); | 327 EXPECT_LE(now_ms_ * 1000, (*it)->send_time_us()); |
328 } | 328 } |
329 EXPECT_EQ(out_packets, packets.size()); | 329 EXPECT_EQ(out_packets, packets.size()); |
330 accumulated_packets_.splice(accumulated_packets_.end(), packets); | 330 accumulated_packets_.splice(accumulated_packets_.end(), packets); |
331 now_ms_ += run_for_ms; | 331 now_ms_ += run_for_ms; |
332 } | 332 } |
333 | 333 |
334 void TestDelayFilter(int64_t delay_ms) { | 334 void TestDelayFilter(int64_t delay_ms) { |
335 filter_.SetDelayMs(delay_ms); | 335 filter_.SetOneWayDelayMs(delay_ms); |
336 TestDelayFilter(1, 0, 0); // No input should yield no output | 336 TestDelayFilter(1, 0, 0); // No input should yield no output |
337 | 337 |
338 // Single packet | 338 // Single packet |
339 TestDelayFilter(0, 1, 1); | 339 TestDelayFilter(0, 1, 1); |
340 TestDelayFilter(delay_ms, 0, 0); | 340 TestDelayFilter(delay_ms, 0, 0); |
341 | 341 |
342 for (int i = 0; i < delay_ms; ++i) { | 342 for (int i = 0; i < delay_ms; ++i) { |
343 filter_.SetDelayMs(i); | 343 filter_.SetOneWayDelayMs(i); |
344 TestDelayFilter(1, 10, 10); | 344 TestDelayFilter(1, 10, 10); |
345 } | 345 } |
346 TestDelayFilter(0, 0, 0); | 346 TestDelayFilter(0, 0, 0); |
347 TestDelayFilter(delay_ms, 0, 0); | 347 TestDelayFilter(delay_ms, 0, 0); |
348 | 348 |
349 // Wait a little longer - should still see no output | 349 // Wait a little longer - should still see no output |
350 TestDelayFilter(delay_ms, 0, 0); | 350 TestDelayFilter(delay_ms, 0, 0); |
351 | 351 |
352 for (int i = 1; i < delay_ms + 1; ++i) { | 352 for (int i = 1; i < delay_ms + 1; ++i) { |
353 filter_.SetDelayMs(i); | 353 filter_.SetOneWayDelayMs(i); |
354 TestDelayFilter(1, 5, 5); | 354 TestDelayFilter(1, 5, 5); |
355 } | 355 } |
356 TestDelayFilter(0, 0, 0); | 356 TestDelayFilter(0, 0, 0); |
357 filter_.SetDelayMs(2 * delay_ms); | 357 filter_.SetOneWayDelayMs(2 * delay_ms); |
358 TestDelayFilter(1, 0, 0); | 358 TestDelayFilter(1, 0, 0); |
359 TestDelayFilter(delay_ms, 13, 13); | 359 TestDelayFilter(delay_ms, 13, 13); |
360 TestDelayFilter(delay_ms, 0, 0); | 360 TestDelayFilter(delay_ms, 0, 0); |
361 | 361 |
362 // Wait a little longer - should still see no output | 362 // Wait a little longer - should still see no output |
363 TestDelayFilter(delay_ms, 0, 0); | 363 TestDelayFilter(delay_ms, 0, 0); |
364 | 364 |
365 for (int i = 0; i < 2 * delay_ms; ++i) { | 365 for (int i = 0; i < 2 * delay_ms; ++i) { |
366 filter_.SetDelayMs(2 * delay_ms - i - 1); | 366 filter_.SetOneWayDelayMs(2 * delay_ms - i - 1); |
367 TestDelayFilter(1, 5, 5); | 367 TestDelayFilter(1, 5, 5); |
368 } | 368 } |
369 TestDelayFilter(0, 0, 0); | 369 TestDelayFilter(0, 0, 0); |
370 filter_.SetDelayMs(0); | 370 filter_.SetOneWayDelayMs(0); |
371 TestDelayFilter(0, 7, 7); | 371 TestDelayFilter(0, 7, 7); |
372 | 372 |
373 ASSERT_TRUE(IsTimeSorted(accumulated_packets_)); | 373 ASSERT_TRUE(IsTimeSorted(accumulated_packets_)); |
374 ASSERT_TRUE(IsSequenceNumberSorted(accumulated_packets_)); | 374 ASSERT_TRUE(IsSequenceNumberSorted(accumulated_packets_)); |
375 } | 375 } |
376 | 376 |
377 DelayFilter filter_; | 377 DelayFilter filter_; |
378 Packets accumulated_packets_; | 378 Packets accumulated_packets_; |
379 | 379 |
380 private: | 380 private: |
381 int64_t now_ms_; | 381 int64_t now_ms_; |
382 uint32_t sequence_number_; | 382 uint32_t sequence_number_; |
383 | 383 |
384 DISALLOW_COPY_AND_ASSIGN(BweTestFramework_DelayFilterTest); | 384 DISALLOW_COPY_AND_ASSIGN(BweTestFramework_DelayFilterTest); |
385 }; | 385 }; |
386 | 386 |
387 TEST_F(BweTestFramework_DelayFilterTest, Delay0) { | 387 TEST_F(BweTestFramework_DelayFilterTest, Delay0) { |
388 TestDelayFilter(1, 0, 0); // No input should yield no output | 388 TestDelayFilter(1, 0, 0); // No input should yield no output |
389 TestDelayFilter(1, 10, 10); // Expect no delay (delay time is zero) | 389 TestDelayFilter(1, 10, 10); // Expect no delay (delay time is zero) |
390 TestDelayFilter(1, 0, 0); // Check no packets are still in buffer | 390 TestDelayFilter(1, 0, 0); // Check no packets are still in buffer |
391 filter_.SetDelayMs(0); | 391 filter_.SetOneWayDelayMs(0); |
392 TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero) | 392 TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero) |
393 TestDelayFilter(1, 0, 0); // Check no packets are still in buffer | 393 TestDelayFilter(1, 0, 0); // Check no packets are still in buffer |
394 } | 394 } |
395 | 395 |
396 TEST_F(BweTestFramework_DelayFilterTest, Delay1) { | 396 TEST_F(BweTestFramework_DelayFilterTest, Delay1) { |
397 TestDelayFilter(1); | 397 TestDelayFilter(1); |
398 } | 398 } |
399 | 399 |
400 TEST_F(BweTestFramework_DelayFilterTest, Delay2) { | 400 TEST_F(BweTestFramework_DelayFilterTest, Delay2) { |
401 TestDelayFilter(2); | 401 TestDelayFilter(2); |
402 } | 402 } |
403 | 403 |
404 TEST_F(BweTestFramework_DelayFilterTest, Delay20) { | 404 TEST_F(BweTestFramework_DelayFilterTest, Delay20) { |
405 TestDelayFilter(20); | 405 TestDelayFilter(20); |
406 } | 406 } |
407 | 407 |
408 TEST_F(BweTestFramework_DelayFilterTest, Delay100) { | 408 TEST_F(BweTestFramework_DelayFilterTest, Delay100) { |
409 TestDelayFilter(100); | 409 TestDelayFilter(100); |
410 } | 410 } |
411 | 411 |
412 TEST_F(BweTestFramework_DelayFilterTest, JumpToZeroDelay) { | 412 TEST_F(BweTestFramework_DelayFilterTest, JumpToZeroDelay) { |
413 DelayFilter delay(NULL, 0); | 413 DelayFilter delay(NULL, 0); |
414 Packets acc; | 414 Packets acc; |
415 Packets packets; | 415 Packets packets; |
416 | 416 |
417 // Delay a bunch of packets, accumulate them to the 'acc' list. | 417 // Delay a bunch of packets, accumulate them to the 'acc' list. |
418 delay.SetDelayMs(100.0f); | 418 delay.SetOneWayDelayMs(100.0f); |
419 for (uint32_t i = 0; i < 10; ++i) { | 419 for (uint32_t i = 0; i < 10; ++i) { |
420 packets.push_back(new MediaPacket(i * 100, i)); | 420 packets.push_back(new MediaPacket(i * 100, i)); |
421 } | 421 } |
422 delay.RunFor(1000, &packets); | 422 delay.RunFor(1000, &packets); |
423 acc.splice(acc.end(), packets); | 423 acc.splice(acc.end(), packets); |
424 ASSERT_TRUE(IsTimeSorted(acc)); | 424 ASSERT_TRUE(IsTimeSorted(acc)); |
425 ASSERT_TRUE(IsSequenceNumberSorted(acc)); | 425 ASSERT_TRUE(IsSequenceNumberSorted(acc)); |
426 | 426 |
427 // Drop delay to zero, send a few more packets through the delay, append them | 427 // Drop delay to zero, send a few more packets through the delay, append them |
428 // to the 'acc' list and verify that it is all sorted. | 428 // to the 'acc' list and verify that it is all sorted. |
429 delay.SetDelayMs(0.0f); | 429 delay.SetOneWayDelayMs(0.0f); |
430 for (uint32_t i = 10; i < 50; ++i) { | 430 for (uint32_t i = 10; i < 50; ++i) { |
431 packets.push_back(new MediaPacket(i * 100, i)); | 431 packets.push_back(new MediaPacket(i * 100, i)); |
432 } | 432 } |
433 delay.RunFor(1000, &packets); | 433 delay.RunFor(1000, &packets); |
434 acc.splice(acc.end(), packets); | 434 acc.splice(acc.end(), packets); |
435 ASSERT_TRUE(IsTimeSorted(acc)); | 435 ASSERT_TRUE(IsTimeSorted(acc)); |
436 ASSERT_TRUE(IsSequenceNumberSorted(acc)); | 436 ASSERT_TRUE(IsSequenceNumberSorted(acc)); |
437 | 437 |
438 for (auto* packet : acc) | 438 for (auto* packet : acc) |
439 delete packet; | 439 delete packet; |
440 } | 440 } |
441 | 441 |
442 TEST_F(BweTestFramework_DelayFilterTest, IncreasingDelay) { | 442 TEST_F(BweTestFramework_DelayFilterTest, IncreasingDelay) { |
443 // Gradually increase delay. | 443 // Gradually increase delay. |
444 for (int i = 1; i < 50; i += 4) { | 444 for (int i = 1; i < 50; i += 4) { |
445 TestDelayFilter(i); | 445 TestDelayFilter(i); |
446 } | 446 } |
447 // Reach a steady state. | 447 // Reach a steady state. |
448 filter_.SetDelayMs(100); | 448 filter_.SetOneWayDelayMs(100); |
449 TestDelayFilter(1, 20, 20); | 449 TestDelayFilter(1, 20, 20); |
450 TestDelayFilter(2, 0, 0); | 450 TestDelayFilter(2, 0, 0); |
451 TestDelayFilter(99, 20, 20); | 451 TestDelayFilter(99, 20, 20); |
452 // Drop delay back down to zero. | 452 // Drop delay back down to zero. |
453 filter_.SetDelayMs(0); | 453 filter_.SetOneWayDelayMs(0); |
454 TestDelayFilter(1, 100, 100); | 454 TestDelayFilter(1, 100, 100); |
455 TestDelayFilter(23010, 0, 0); | 455 TestDelayFilter(23010, 0, 0); |
456 ASSERT_TRUE(IsTimeSorted(accumulated_packets_)); | 456 ASSERT_TRUE(IsTimeSorted(accumulated_packets_)); |
457 ASSERT_TRUE(IsSequenceNumberSorted(accumulated_packets_)); | 457 ASSERT_TRUE(IsSequenceNumberSorted(accumulated_packets_)); |
458 } | 458 } |
459 | 459 |
460 static void TestJitterFilter(int64_t stddev_jitter_ms) { | 460 static void TestJitterFilter(int64_t stddev_jitter_ms) { |
461 JitterFilter filter(NULL, 0); | 461 JitterFilter filter(NULL, 0); |
462 filter.SetJitter(stddev_jitter_ms); | 462 filter.SetJitter(stddev_jitter_ms); |
463 | 463 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 size_t bytes_transmitted = 0; | 636 size_t bytes_transmitted = 0; |
637 while (!output_packets_.empty()) { | 637 while (!output_packets_.empty()) { |
638 const Packet* packet = output_packets_.front(); | 638 const Packet* packet = output_packets_.front(); |
639 if (packet->send_time_us() > now_ms_ * 1000) { | 639 if (packet->send_time_us() > now_ms_ * 1000) { |
640 break; | 640 break; |
641 } | 641 } |
642 bytes_transmitted += packet->payload_size(); | 642 bytes_transmitted += packet->payload_size(); |
643 delete output_packets_.front(); | 643 delete output_packets_.front(); |
644 output_packets_.pop_front(); | 644 output_packets_.pop_front(); |
645 } | 645 } |
646 EXPECT_EQ(expected_kbit_transmitted, (bytes_transmitted * 8) / 1000); | 646 EXPECT_EQ(expected_kbit_transmitted, (bytes_transmitted * 8 + 500) / 1000); |
647 } | 647 } |
648 | 648 |
649 void CheckMaxDelay(int64_t max_delay_ms) { | 649 void CheckMaxDelay(int64_t max_delay_ms) { |
650 for (const auto* packet : output_packets_) { | 650 for (const auto* packet : output_packets_) { |
651 const MediaPacket* media_packet = static_cast<const MediaPacket*>(packet); | 651 const MediaPacket* media_packet = static_cast<const MediaPacket*>(packet); |
652 int64_t delay_us = media_packet->send_time_us() - | 652 int64_t delay_us = media_packet->send_time_us() - |
653 send_times_us_[media_packet->header().sequenceNumber]; | 653 send_times_us_[media_packet->header().sequenceNumber]; |
654 EXPECT_GE(max_delay_ms * 1000, delay_us); | 654 EXPECT_GE(max_delay_ms * 1000, delay_us); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 private: | 658 private: |
659 int64_t now_ms_; | 659 int64_t now_ms_; |
660 uint16_t sequence_number_; | 660 uint16_t sequence_number_; |
661 Packets output_packets_; | 661 Packets output_packets_; |
662 std::vector<int64_t> send_times_us_; | 662 std::vector<int64_t> send_times_us_; |
663 | 663 |
664 DISALLOW_COPY_AND_ASSIGN(BweTestFramework_ChokeFilterTest); | 664 DISALLOW_COPY_AND_ASSIGN(BweTestFramework_ChokeFilterTest); |
665 }; | 665 }; |
666 | 666 |
667 TEST_F(BweTestFramework_ChokeFilterTest, NoQueue) { | 667 TEST_F(BweTestFramework_ChokeFilterTest, NoQueue) { |
668 const int kCapacityKbps = 10; | 668 const int kCapacityKbps = 10; |
669 const size_t kPacketSizeBytes = 125; | 669 const size_t kPacketSizeBytes = 125; |
670 const int64_t kExpectedSendTimeUs = | 670 const int64_t kExpectedSendTimeUs = |
671 (kPacketSizeBytes * 8 * 1000 + kCapacityKbps / 2) / kCapacityKbps; | 671 (kPacketSizeBytes * 8 * 1000 + kCapacityKbps / 2) / kCapacityKbps; |
672 uint16_t sequence_number = 0; | 672 uint16_t sequence_number = 0; |
673 int64_t send_time_us = 0; | 673 int64_t send_time_us = 0; |
674 ChokeFilter filter(NULL, 0); | 674 ChokeFilter filter(NULL, 0); |
675 filter.SetCapacity(10); | 675 filter.set_capacity_kbps(10); |
676 Packets packets; | 676 Packets packets; |
677 RTPHeader header; | 677 RTPHeader header; |
678 for (int i = 0; i < 2; ++i) { | 678 for (int i = 0; i < 2; ++i) { |
679 header.sequenceNumber = sequence_number++; | 679 header.sequenceNumber = sequence_number++; |
680 // Payload is 1000 bits. | 680 // Payload is 1000 bits. |
681 packets.push_back( | 681 packets.push_back( |
682 new MediaPacket(0, send_time_us, kPacketSizeBytes, header)); | 682 new MediaPacket(0, send_time_us, kPacketSizeBytes, header)); |
683 // Packets are sent far enough a part plus an extra millisecond so that they | 683 // Packets are sent far enough a part plus an extra millisecond so that they |
684 // will never be in the choke queue at the same time. | 684 // will never be in the choke queue at the same time. |
685 send_time_us += kExpectedSendTimeUs + 1000; | 685 send_time_us += kExpectedSendTimeUs + 1000; |
686 } | 686 } |
687 ASSERT_TRUE(IsTimeSorted(packets)); | 687 ASSERT_TRUE(IsTimeSorted(packets)); |
688 filter.RunFor(2 * kExpectedSendTimeUs + 1000, &packets); | 688 filter.RunFor(2 * kExpectedSendTimeUs + 1000, &packets); |
689 EXPECT_EQ(kExpectedSendTimeUs, packets.front()->send_time_us()); | 689 EXPECT_EQ(kExpectedSendTimeUs, packets.front()->send_time_us()); |
690 delete packets.front(); | 690 delete packets.front(); |
691 packets.pop_front(); | 691 packets.pop_front(); |
692 EXPECT_EQ(2 * kExpectedSendTimeUs + 1000, packets.front()->send_time_us()); | 692 EXPECT_EQ(2 * kExpectedSendTimeUs + 1000, packets.front()->send_time_us()); |
693 delete packets.front(); | 693 delete packets.front(); |
694 packets.pop_front(); | 694 packets.pop_front(); |
695 } | 695 } |
696 | 696 |
697 TEST_F(BweTestFramework_ChokeFilterTest, Short) { | 697 TEST_F(BweTestFramework_ChokeFilterTest, Short) { |
698 // 100ms, 100 packets, 10 kbps choke -> 1 kbit of data should have propagated. | 698 // 100ms, 100 packets, 10 kbps choke -> 1 kbit of data should have propagated. |
699 // That is actually just a single packet, since each packet has 1000 bits of | 699 // That is actually just a single packet, since each packet has 1000 bits of |
700 // payload. | 700 // payload. |
701 ChokeFilter filter(NULL, 0); | 701 ChokeFilter filter(NULL, 0); |
702 filter.SetCapacity(10); | 702 filter.set_capacity_kbps(10); |
703 TestChoke(&filter, 100, 100, 1); | 703 TestChoke(&filter, 100, 100, 1); |
704 } | 704 } |
705 | 705 |
706 TEST_F(BweTestFramework_ChokeFilterTest, Medium) { | 706 TEST_F(BweTestFramework_ChokeFilterTest, Medium) { |
707 // 100ms, 10 packets, 10 kbps choke -> 1 packet through, or 1 kbit. | 707 // 100ms, 10 packets, 10 kbps choke -> 1 packet through, or 1 kbit. |
708 ChokeFilter filter(NULL, 0); | 708 ChokeFilter filter(NULL, 0); |
709 filter.SetCapacity(10); | 709 filter.set_capacity_kbps(10); |
710 TestChoke(&filter, 100, 10, 1); | 710 TestChoke(&filter, 100, 10, 1); |
711 // 200ms, no new packets -> another packet through. | 711 // 200ms, no new packets -> another packet through. |
712 TestChoke(&filter, 100, 0, 1); | 712 TestChoke(&filter, 100, 0, 1); |
713 // 1000ms, no new packets -> 8 more packets. | 713 // 1000ms, no new packets -> 8 more packets. |
714 TestChoke(&filter, 800, 0, 8); | 714 TestChoke(&filter, 800, 0, 8); |
715 // 2000ms, no new packets -> queue is empty so no output. | 715 // 2000ms, no new packets -> queue is empty so no output. |
716 TestChoke(&filter, 1000, 0, 0); | 716 TestChoke(&filter, 1000, 0, 0); |
717 } | 717 } |
718 | 718 |
719 TEST_F(BweTestFramework_ChokeFilterTest, Long) { | 719 TEST_F(BweTestFramework_ChokeFilterTest, Long) { |
720 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. | 720 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. |
721 ChokeFilter filter(NULL, 0); | 721 ChokeFilter filter(NULL, 0); |
722 filter.SetCapacity(10); | 722 filter.set_capacity_kbps(10); |
723 TestChoke(&filter, 100, 100, 1); | 723 TestChoke(&filter, 100, 100, 1); |
724 // 200ms, no input, another packet through. | 724 // 200ms, no input, another packet through. |
725 TestChoke(&filter, 100, 0, 1); | 725 TestChoke(&filter, 100, 0, 1); |
726 // 1000ms, no input, 8 packets through. | 726 // 1000ms, no input, 8 packets through. |
727 TestChoke(&filter, 800, 0, 8); | 727 TestChoke(&filter, 800, 0, 8); |
728 // 10000ms, no input, raise choke to 100 kbps. Remaining 90 packets in queue | 728 // 10000ms, no input, raise choke to 100 kbps. Remaining 90 packets in queue |
729 // should be propagated, for a total of 90 kbps. | 729 // should be propagated, for a total of 90 kbps. |
730 filter.SetCapacity(100); | 730 filter.set_capacity_kbps(100); |
731 TestChoke(&filter, 9000, 0, 90); | 731 TestChoke(&filter, 9000, 0, 90); |
732 // 10100ms, 20 more packets -> 10 packets or 10 kbit through. | 732 // 10100ms, 20 more packets -> 10 packets or 10 kbit through. |
733 TestChoke(&filter, 100, 20, 10); | 733 TestChoke(&filter, 100, 20, 10); |
734 // 10300ms, 10 more packets -> 20 packets out. | 734 // 10300ms, 10 more packets -> 20 packets out. |
735 TestChoke(&filter, 200, 10, 20); | 735 TestChoke(&filter, 200, 10, 20); |
736 // 11300ms, no input, queue should be empty. | 736 // 11300ms, no input, queue should be empty. |
737 filter.SetCapacity(10); | 737 filter.set_capacity_kbps(10); |
738 TestChoke(&filter, 1000, 0, 0); | 738 TestChoke(&filter, 1000, 0, 0); |
739 } | 739 } |
740 | 740 |
741 TEST_F(BweTestFramework_ChokeFilterTest, MaxDelay) { | 741 TEST_F(BweTestFramework_ChokeFilterTest, MaxDelay) { |
742 // 10 kbps choke, 500 ms delay cap | 742 // 10 kbps choke, 500 ms delay cap |
743 ChokeFilter filter(NULL, 0); | 743 ChokeFilter filter(NULL, 0); |
744 filter.SetCapacity(10); | 744 filter.set_capacity_kbps(10); |
745 filter.SetMaxDelay(500); | 745 filter.set_max_delay_ms(500); |
746 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. | 746 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. |
747 TestChoke(&filter, 100, 100, 1); | 747 TestChoke(&filter, 100, 100, 1); |
748 CheckMaxDelay(500); | 748 CheckMaxDelay(500); |
749 // 500ms, no input, 4 more packets through. | 749 // 500ms, no input, 4 more packets through. |
750 TestChoke(&filter, 400, 0, 4); | 750 TestChoke(&filter, 400, 0, 4); |
751 // 10000ms, no input, remaining packets should have been dropped. | 751 // 10000ms, no input, remaining packets should have been dropped. |
752 TestChoke(&filter, 9500, 0, 0); | 752 TestChoke(&filter, 9500, 0, 0); |
753 | 753 |
754 // 100 ms delay cap | 754 // 100 ms delay cap |
755 filter.SetMaxDelay(100); | 755 filter.set_max_delay_ms(100); |
756 // 10100ms, 50 more packets -> 1 packets or 1 kbit through. | 756 // 10100ms, 50 more packets -> 1 packets or 1 kbit through. |
757 TestChoke(&filter, 100, 50, 1); | 757 TestChoke(&filter, 100, 50, 1); |
758 CheckMaxDelay(100); | 758 CheckMaxDelay(100); |
759 // 20000ms, no input, remaining packets in queue should have been dropped. | 759 // 20000ms, no input, remaining packets in queue should have been dropped. |
760 TestChoke(&filter, 9900, 0, 0); | 760 TestChoke(&filter, 9900, 0, 0); |
761 | 761 |
762 // Reset delay cap (0 is no cap) and verify no packets are dropped. | 762 // Reset delay cap (0 is no cap) and verify no packets are dropped. |
763 filter.SetCapacity(10); | 763 filter.set_capacity_kbps(10); |
764 filter.SetMaxDelay(0); | 764 filter.set_max_delay_ms(0); |
765 TestChoke(&filter, 100, 100, 1); | 765 TestChoke(&filter, 100, 100, 1); |
766 TestChoke(&filter, 9900, 0, 99); | 766 TestChoke(&filter, 9900, 0, 99); |
767 } | 767 } |
768 | 768 |
769 TEST_F(BweTestFramework_ChokeFilterTest, ShortTrace) { | 769 TEST_F(BweTestFramework_ChokeFilterTest, ShortTrace) { |
770 // According to the input file 6 packets should be transmitted within | 770 // According to the input file 6 packets should be transmitted within |
771 // 100 milliseconds. | 771 // 100 milliseconds. |
772 TraceBasedDeliveryFilter filter(NULL, 0); | 772 TraceBasedDeliveryFilter filter(NULL, 0); |
773 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 773 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
774 TestChoke(&filter, 100, 100, 6); | 774 TestChoke(&filter, 100, 100, 6); |
775 } | 775 } |
776 | 776 |
777 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceTwoWraps) { | 777 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceTwoWraps) { |
778 // According to the input file 19 packets should be transmitted within | 778 // According to the input file 19 packets should be transmitted within |
779 // 280 milliseconds (at the wrapping point two packets are sent back to back). | 779 // 280 milliseconds (at the wrapping point two packets are sent back to back). |
780 TraceBasedDeliveryFilter filter(NULL, 0); | 780 TraceBasedDeliveryFilter filter(NULL, 0); |
781 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 781 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
782 TestChoke(&filter, 280, 100, 19); | 782 TestChoke(&filter, 280, 100, 19); |
783 } | 783 } |
784 | 784 |
785 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceMaxDelay) { | 785 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceMaxDelay) { |
786 TraceBasedDeliveryFilter filter(NULL, 0); | 786 TraceBasedDeliveryFilter filter(NULL, 0); |
787 filter.SetMaxDelay(25); | 787 filter.set_max_delay_ms(25); |
788 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 788 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
789 // Uses all slots up to 110 ms. Several packets are being dropped. | 789 // Uses all slots up to 110 ms. Several packets are being dropped. |
790 TestChoke(&filter, 110, 20, 9); | 790 TestChoke(&filter, 110, 20, 9); |
791 CheckMaxDelay(25); | 791 CheckMaxDelay(25); |
792 // Simulate enough time for the next slot (at 135 ms) to be used. This makes | 792 // Simulate enough time for the next slot (at 135 ms) to be used. This makes |
793 // sure that a slot isn't missed between runs. | 793 // sure that a slot isn't missed between runs. |
794 TestChoke(&filter, 25, 1, 1); | 794 TestChoke(&filter, 25, 1, 1); |
795 } | 795 } |
796 | 796 |
797 void TestVideoSender(VideoSender* sender, | 797 void TestVideoSender(VideoSender* sender, |
798 int64_t run_for_ms, | 798 int64_t run_for_ms, |
799 uint32_t expected_packets, | 799 uint32_t expected_packets, |
800 uint32_t expected_payload_size, | 800 uint32_t expected_payload_size, |
801 size_t expected_total_payload_size) { | 801 size_t expected_total_payload_size) { |
802 assert(sender); | 802 assert(sender); |
803 Packets packets; | 803 Packets packets; |
804 sender->RunFor(run_for_ms, &packets); | 804 sender->RunFor(run_for_ms, &packets); |
805 ASSERT_TRUE(IsTimeSorted(packets)); | 805 ASSERT_TRUE(IsTimeSorted(packets)); |
806 ASSERT_TRUE(IsSequenceNumberSorted(packets)); | 806 ASSERT_TRUE(IsSequenceNumberSorted(packets)); |
807 EXPECT_EQ(expected_packets, packets.size()); | 807 EXPECT_EQ(expected_packets, packets.size()); |
| 808 |
808 int64_t send_time_us = -1; | 809 int64_t send_time_us = -1; |
809 size_t total_payload_size = 0; | 810 size_t total_payload_size = 0; |
810 uint32_t absolute_send_time = 0; | 811 uint32_t absolute_send_time = 0; |
811 uint32_t absolute_send_time_wraps = 0; | 812 uint32_t absolute_send_time_wraps = 0; |
812 uint32_t rtp_timestamp = 0; | 813 uint32_t rtp_timestamp = 0; |
813 uint32_t rtp_timestamp_wraps = 0; | 814 uint32_t rtp_timestamp_wraps = 0; |
| 815 |
814 for (const auto* packet : packets) { | 816 for (const auto* packet : packets) { |
815 const MediaPacket* media_packet = static_cast<const MediaPacket*>(packet); | 817 const MediaPacket* media_packet = static_cast<const MediaPacket*>(packet); |
816 EXPECT_LE(send_time_us, media_packet->send_time_us()); | 818 EXPECT_LE(send_time_us, media_packet->send_time_us()); |
817 send_time_us = media_packet->send_time_us(); | 819 send_time_us = media_packet->send_time_us(); |
818 if (sender->source()->max_payload_size_bytes() != | 820 if (sender->source()->max_payload_size_bytes() != |
819 media_packet->payload_size()) { | 821 media_packet->payload_size()) { |
820 EXPECT_EQ(expected_payload_size, media_packet->payload_size()); | 822 EXPECT_EQ(expected_payload_size, media_packet->payload_size()); |
821 } | 823 } |
822 total_payload_size += media_packet->payload_size(); | 824 total_payload_size += media_packet->payload_size(); |
823 if (absolute_send_time > | 825 if (absolute_send_time > |
824 media_packet->header().extension.absoluteSendTime) { | 826 media_packet->header().extension.absoluteSendTime) { |
825 absolute_send_time_wraps++; | 827 absolute_send_time_wraps++; |
826 } | 828 } |
827 absolute_send_time = media_packet->header().extension.absoluteSendTime; | 829 absolute_send_time = media_packet->header().extension.absoluteSendTime; |
828 if (rtp_timestamp > media_packet->header().timestamp) { | 830 if (rtp_timestamp > media_packet->header().timestamp) { |
829 rtp_timestamp_wraps++; | 831 rtp_timestamp_wraps++; |
830 } | 832 } |
831 rtp_timestamp = media_packet->header().timestamp; | 833 rtp_timestamp = media_packet->header().timestamp; |
832 } | 834 } |
| 835 |
833 EXPECT_EQ(expected_total_payload_size, total_payload_size); | 836 EXPECT_EQ(expected_total_payload_size, total_payload_size); |
834 EXPECT_GE(1u, absolute_send_time_wraps); | 837 EXPECT_GE(1u, absolute_send_time_wraps); |
835 EXPECT_GE(1u, rtp_timestamp_wraps); | 838 EXPECT_GE(1u, rtp_timestamp_wraps); |
836 | 839 |
837 for (auto* packet : packets) | 840 for (auto* packet : packets) |
838 delete packet; | 841 delete packet; |
839 } | 842 } |
840 | 843 |
| 844 // Random {-1, 0, +1} ms was added to frame timestamps. |
| 845 |
841 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s) { | 846 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s) { |
842 // 1 fps, 80 kbps | 847 // 1 fps, 80 kbps |
843 VideoSource source(0, 1.0f, 80, 0x1234, 0); | 848 VideoSource source(0, 1.0f, 80, 0x1234, 0); |
844 VideoSender sender(NULL, &source, kNullEstimator); | 849 VideoSender sender(NULL, &source, kNullEstimator); |
845 EXPECT_EQ(80000u, source.bits_per_second()); | 850 EXPECT_EQ(80000u, source.bits_per_second()); |
846 // We're at 1 fps, so all packets should be generated on first call, giving 10 | 851 // We're at 1 fps, so all packets should be generated on first call, giving 10 |
847 // packets of each 1000 bytes, total 10000 bytes. | 852 // packets of each 1000 bytes, total 10000 bytes. |
848 TestVideoSender(&sender, 1, 9, 400, 10000); | 853 TestVideoSender(&sender, 1, 9, 400, 10000); |
849 // 999ms, should see no output here. | 854 // 998ms, should see no output here. |
850 TestVideoSender(&sender, 998, 0, 0, 0); | 855 TestVideoSender(&sender, 997, 0, 0, 0); |
851 // 1999ms, should get data for one more frame. | 856 // 1001ms, should get data for one more frame. |
852 TestVideoSender(&sender, 1000, 9, 400, 10000); | 857 TestVideoSender(&sender, 3, 9, 400, 10000); |
853 // 2000ms, one more frame. | 858 // 1998ms, should see no output here. |
854 TestVideoSender(&sender, 1, 9, 400, 10000); | 859 TestVideoSender(&sender, 997, 0, 0, 0); |
855 // 2999ms, should see nothing. | 860 // 2001ms, one more frame. |
856 TestVideoSender(&sender, 999, 0, 0, 0); | 861 TestVideoSender(&sender, 3, 9, 400, 10000); |
| 862 // 2998ms, should see nothing. |
| 863 TestVideoSender(&sender, 997, 0, 0, 0); |
857 } | 864 } |
858 | 865 |
859 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s_Offset) { | 866 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s_Offset) { |
860 // 1 fps, 80 kbps, offset 0.5 of a frame period, ==0.5s in this case. | 867 // 1 fps, 80 kbps, offset 0.5 of a frame period, ==0.5s in this case. |
861 VideoSource source(0, 1.0f, 80, 0x1234, 500); | 868 VideoSource source(0, 1.0f, 80, 0x1234, 500); |
862 VideoSender sender(NULL, &source, kNullEstimator); | 869 VideoSender sender(NULL, &source, kNullEstimator); |
863 EXPECT_EQ(80000u, source.bits_per_second()); | 870 EXPECT_EQ(80000u, source.bits_per_second()); |
864 // 499ms, no output. | 871 // 498ms, no output. |
865 TestVideoSender(&sender, 499, 0, 0, 0); | 872 TestVideoSender(&sender, 498, 0, 0, 0); |
866 // 500ms, first frame (this is the offset we set), 10 packets of 1000 bytes. | 873 // 501ms, first frame (this is the offset we set), 10 packets of 1000 bytes. |
867 TestVideoSender(&sender, 1, 9, 400, 10000); | 874 TestVideoSender(&sender, 3, 9, 400, 10000); |
868 // 1499ms, nothing. | 875 // 1498ms, nothing. |
869 TestVideoSender(&sender, 999, 0, 0, 0); | 876 TestVideoSender(&sender, 997, 0, 0, 0); |
870 // 1999ms, second frame. | 877 // 1501ms, second frame. |
871 TestVideoSender(&sender, 500, 9, 400, 10000); | 878 TestVideoSender(&sender, 3, 9, 400, 10000); |
872 // 2499ms, nothing. | 879 // 2498ms, nothing. |
873 TestVideoSender(&sender, 500, 0, 0, 0); | 880 TestVideoSender(&sender, 997, 0, 0, 0); |
874 // 2500ms, third frame. | 881 // 2501ms, third frame. |
875 TestVideoSender(&sender, 1, 9, 400, 10000); | 882 TestVideoSender(&sender, 3, 9, 400, 10000); |
876 // 3499ms, nothing. | 883 // 3498ms, nothing. |
877 TestVideoSender(&sender, 999, 0, 0, 0); | 884 TestVideoSender(&sender, 997, 0, 0, 0); |
878 } | 885 } |
879 | 886 |
880 TEST(BweTestFramework_VideoSenderTest, Fps50Kpbs80_11s) { | 887 TEST(BweTestFramework_VideoSenderTest, Fps50Kpbs80_11s) { |
881 // 50 fps, 80 kbps. | 888 // 50 fps, 80 kbps. |
882 VideoSource source(0, 50.0f, 80, 0x1234, 0); | 889 VideoSource source(0, 50.0f, 80, 0x1234, 0); |
883 VideoSender sender(NULL, &source, kNullEstimator); | 890 VideoSender sender(NULL, &source, kNullEstimator); |
884 EXPECT_EQ(80000u, source.bits_per_second()); | 891 EXPECT_EQ(80000u, source.bits_per_second()); |
885 // 9998ms, should see 500 frames, 200 byte payloads, total 100000 bytes. | 892 // 9981, should see 500 frames, 200 byte payloads, total 100000 bytes. |
886 TestVideoSender(&sender, 9998, 500, 200, 100000); | 893 TestVideoSender(&sender, 9981, 500, 200, 100000); |
887 // 9999ms, nothing. | 894 // 9998ms, nothing. |
888 TestVideoSender(&sender, 1, 0, 0, 0); | 895 TestVideoSender(&sender, 17, 0, 0, 0); |
889 // 10000ms, 501st frame as a single packet. | 896 // 10001ms, 501st frame as a single packet. |
890 TestVideoSender(&sender, 1, 1, 200, 200); | 897 TestVideoSender(&sender, 3, 1, 200, 200); |
891 // 10998ms, 49 more frames. | 898 // 10981ms, 49 more frames. |
892 TestVideoSender(&sender, 998, 49, 200, 9800); | 899 TestVideoSender(&sender, 981, 49, 200, 9800); |
893 // 10999ms, nothing. | 900 // 10998ms, nothing. |
894 TestVideoSender(&sender, 1, 0, 0, 0); | 901 TestVideoSender(&sender, 17, 0, 0, 0); |
895 } | 902 } |
896 | 903 |
897 TEST(BweTestFramework_VideoSenderTest, Fps10Kpbs120_1s) { | 904 TEST(BweTestFramework_VideoSenderTest, Fps20Kpbs120_1s) { |
898 // 20 fps, 120 kbps. | 905 // 20 fps, 120 kbps. |
899 VideoSource source(0, 20.0f, 120, 0x1234, 0); | 906 VideoSource source(0, 20.0f, 120, 0x1234, 0); |
900 VideoSender sender(NULL, &source, kNullEstimator); | 907 VideoSender sender(NULL, &source, kNullEstimator); |
901 EXPECT_EQ(120000u, source.bits_per_second()); | 908 EXPECT_EQ(120000u, source.bits_per_second()); |
902 // 498ms, 10 frames with 750 byte payloads, total 7500 bytes. | 909 // 451ms, 10 frames with 750 byte payloads, total 7500 bytes. |
903 TestVideoSender(&sender, 498, 10, 750, 7500); | 910 TestVideoSender(&sender, 451, 10, 750, 7500); |
904 // 499ms, nothing. | 911 // 498ms, nothing. |
905 TestVideoSender(&sender, 1, 0, 0, 0); | 912 TestVideoSender(&sender, 47, 0, 0, 0); |
906 // 500ms, one more frame. | 913 // 501ms, one more frame. |
907 TestVideoSender(&sender, 1, 1, 750, 750); | 914 TestVideoSender(&sender, 3, 1, 750, 750); |
908 // 998ms, 9 more frames. | 915 // 951ms, 9 more frames. |
909 TestVideoSender(&sender, 498, 9, 750, 6750); | 916 TestVideoSender(&sender, 450, 9, 750, 6750); |
910 // 999ms, nothing. | 917 // 998ms, nothing. |
911 TestVideoSender(&sender, 1, 0, 0, 0); | 918 TestVideoSender(&sender, 47, 0, 0, 0); |
912 } | 919 } |
913 | 920 |
914 TEST(BweTestFramework_VideoSenderTest, Fps30Kbps800_20s) { | 921 TEST(BweTestFramework_VideoSenderTest, Fps25Kbps820_20s) { |
915 // 20 fps, 820 kbps. | 922 // 25 fps, 820 kbps. |
916 VideoSource source(0, 25.0f, 820, 0x1234, 0); | 923 VideoSource source(0, 25.0f, 820, 0x1234, 0); |
917 VideoSender sender(NULL, &source, kNullEstimator); | 924 VideoSender sender(NULL, &source, kNullEstimator); |
918 EXPECT_EQ(820000u, source.bits_per_second()); | 925 EXPECT_EQ(820000u, source.bits_per_second()); |
919 // 9998ms, 250 frames. 820 kbps = 102500 bytes/s, so total should be 1025000. | 926 // 9961ms, 250 frames. 820 kbps = 102500 bytes/s, so total should be 1025000. |
920 // Each frame is 102500/25=4100 bytes, or 5 packets (4 @1000 bytes, 1 @100), | 927 // Each frame is 102500/25=4100 bytes, or 5 packets (4 @1000 bytes, 1 @100), |
921 // so packet count should be 5*250=1250 and last packet of each frame has | 928 // so packet count should be 5*250=1250 and last packet of each frame has |
922 // 100 bytes of payload. | 929 // 100 bytes of payload. |
923 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 930 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
924 // 9999ms, nothing. | 931 // 9998ms, nothing. |
925 TestVideoSender(&sender, 1, 0, 0, 0); | 932 TestVideoSender(&sender, 37, 0, 0, 0); |
926 // 19998ms, 250 more frames. | 933 // 19961ms, 250 more frames. |
927 TestVideoSender(&sender, 9999, 1000, 500, 1025000); | 934 TestVideoSender(&sender, 9963, 1000, 500, 1025000); |
928 // 19999ms, nothing. | 935 // 19998ms, nothing. |
929 TestVideoSender(&sender, 1, 0, 0, 0); | 936 TestVideoSender(&sender, 37, 0, 0, 0); |
930 // 20038ms, one more frame, as described above (25fps == 40ms/frame). | 937 // 20001ms, one more frame, as described above (25fps == 40ms/frame). |
931 TestVideoSender(&sender, 39, 4, 500, 4100); | 938 TestVideoSender(&sender, 3, 4, 500, 4100); |
932 // 20039ms, nothing. | 939 // 20038ms, nothing. |
933 TestVideoSender(&sender, 1, 0, 0, 0); | 940 TestVideoSender(&sender, 37, 0, 0, 0); |
934 } | 941 } |
935 | 942 |
936 TEST(BweTestFramework_VideoSenderTest, TestAppendInOrder) { | 943 TEST(BweTestFramework_VideoSenderTest, TestAppendInOrder) { |
937 // 1 fps, 80 kbps, 250ms offset. | 944 // 1 fps, 80 kbps, 250ms offset. |
938 VideoSource source1(0, 1.0f, 80, 0x1234, 250); | 945 VideoSource source1(0, 1.0f, 80, 0x1234, 250); |
939 VideoSender sender1(NULL, &source1, kNullEstimator); | 946 VideoSender sender1(NULL, &source1, kNullEstimator); |
940 EXPECT_EQ(80000u, source1.bits_per_second()); | 947 EXPECT_EQ(80000u, source1.bits_per_second()); |
941 Packets packets; | 948 Packets packets; |
942 // Generate some packets, verify they are sorted. | 949 // Generate some packets, verify they are sorted. |
943 sender1.RunFor(999, &packets); | 950 sender1.RunFor(999, &packets); |
(...skipping 22 matching lines...) Expand all Loading... |
966 | 973 |
967 for (auto* packet : packets) | 974 for (auto* packet : packets) |
968 delete packet; | 975 delete packet; |
969 } | 976 } |
970 | 977 |
971 TEST(BweTestFramework_VideoSenderTest, FeedbackIneffective) { | 978 TEST(BweTestFramework_VideoSenderTest, FeedbackIneffective) { |
972 VideoSource source(0, 25.0f, 820, 0x1234, 0); | 979 VideoSource source(0, 25.0f, 820, 0x1234, 0); |
973 VideoSender sender(NULL, &source, kNullEstimator); | 980 VideoSender sender(NULL, &source, kNullEstimator); |
974 | 981 |
975 EXPECT_EQ(820000u, source.bits_per_second()); | 982 EXPECT_EQ(820000u, source.bits_per_second()); |
976 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 983 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
977 | 984 |
978 // Make sure feedback has no effect on a regular video sender. | 985 // Make sure feedback has no effect on a regular video sender. |
979 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); | 986 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); |
980 Packets packets; | 987 Packets packets; |
981 packets.push_back(feedback); | 988 packets.push_back(feedback); |
982 sender.RunFor(0, &packets); | 989 sender.RunFor(0, &packets); |
983 EXPECT_EQ(820000u, source.bits_per_second()); | 990 EXPECT_EQ(820000u, source.bits_per_second()); |
984 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 991 TestVideoSender(&sender, 10000, 1000, 500, 1025000); |
985 } | 992 } |
986 | 993 |
987 TEST(BweTestFramework_AdaptiveVideoSenderTest, FeedbackChangesBitrate) { | 994 TEST(BweTestFramework_AdaptiveVideoSenderTest, FeedbackChangesBitrate) { |
988 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); | 995 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); |
989 VideoSender sender(NULL, &source, kRembEstimator); | 996 VideoSender sender(NULL, &source, kRembEstimator); |
990 EXPECT_EQ(820000u, source.bits_per_second()); | 997 EXPECT_EQ(820000u, source.bits_per_second()); |
991 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 998 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
992 | 999 |
993 // Make sure we can reduce the bitrate. | 1000 // Make sure we can reduce the bitrate. |
994 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); | 1001 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); |
995 Packets packets; | 1002 Packets packets; |
996 packets.push_back(feedback); | 1003 packets.push_back(feedback); |
997 sender.RunFor(0, &packets); | 1004 sender.RunFor(0, &packets); |
998 EXPECT_EQ(512000u, source.bits_per_second()); | 1005 EXPECT_EQ(512000u, source.bits_per_second()); |
999 TestVideoSender(&sender, 9998, 750, 160, 640000); | 1006 TestVideoSender(&sender, 10000, 750, 160, 640000); |
1000 | 1007 |
1001 // Increase the bitrate to the initial bitrate and verify that the output is | 1008 // Increase the bitrate to the initial bitrate and verify that the output is |
1002 // the same. | 1009 // the same. |
1003 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); | 1010 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); |
1004 packets.push_back(feedback); | 1011 packets.push_back(feedback); |
1005 sender.RunFor(10000, &packets); | 1012 sender.RunFor(10000, &packets); |
1006 EXPECT_EQ(820000u, source.bits_per_second()); | 1013 EXPECT_EQ(820000u, source.bits_per_second()); |
1007 | 1014 |
1008 for (auto* packet : packets) | 1015 for (auto* packet : packets) |
1009 delete packet; | 1016 delete packet; |
1010 } | 1017 } |
1011 | 1018 |
1012 TEST(BweTestFramework_AdaptiveVideoSenderTest, Paced_FeedbackChangesBitrate) { | 1019 TEST(BweTestFramework_AdaptiveVideoSenderTest, Paced_FeedbackChangesBitrate) { |
1013 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); | 1020 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); |
1014 PacedVideoSender sender(NULL, &source, kRembEstimator); | 1021 PacedVideoSender sender(NULL, &source, kRembEstimator); |
1015 EXPECT_EQ(820000u, source.bits_per_second()); | 1022 EXPECT_EQ(820000u, source.bits_per_second()); |
1016 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 1023 TestVideoSender(&sender, 9998, 1000, 500, 1025000); |
1017 | 1024 |
1018 // Make sure we can reduce the bitrate. | 1025 // Make sure we can reduce the bitrate. |
1019 RembFeedback* feedback = new RembFeedback(0, 1, 0, 512000, RTCPReportBlock()); | 1026 RembFeedback* feedback = new RembFeedback(0, 1, 0, 512000, RTCPReportBlock()); |
1020 Packets packets; | 1027 Packets packets; |
1021 packets.push_back(feedback); | 1028 packets.push_back(feedback); |
1022 sender.RunFor(10000, &packets); | 1029 sender.RunFor(10000, &packets); |
1023 ASSERT_EQ(512000u, source.bits_per_second()); | 1030 ASSERT_EQ(512000u, source.bits_per_second()); |
1024 TestVideoSender(&sender, 9998, 750, 160, 640000); | 1031 TestVideoSender(&sender, 10000, 750, 160, 640000); |
1025 | 1032 |
1026 // Increase the bitrate to the initial bitrate and verify that the output is | 1033 // Increase the bitrate to the initial bitrate and verify that the output is |
1027 // the same. | 1034 // the same. |
1028 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); | 1035 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); |
1029 packets.push_back(feedback); | 1036 packets.push_back(feedback); |
1030 sender.RunFor(10000, &packets); | 1037 sender.RunFor(10000, &packets); |
1031 EXPECT_EQ(820000u, source.bits_per_second()); | 1038 EXPECT_EQ(820000u, source.bits_per_second()); |
1032 | 1039 |
1033 for (auto* packet : packets) | 1040 for (auto* packet : packets) |
1034 delete packet; | 1041 delete packet; |
1035 } | 1042 } |
1036 } // namespace bwe | 1043 } // namespace bwe |
1037 } // namespace testing | 1044 } // namespace testing |
1038 } // namespace webrtc | 1045 } // namespace webrtc |
OLD | NEW |