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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, Short) { | 667 TEST_F(BweTestFramework_ChokeFilterTest, Short) { |
668 // 100ms, 100 packets, 10 kbps choke -> 1 kbit of data should have propagated. | 668 // 100ms, 100 packets, 10 kbps choke -> 1 kbit of data should have propagated. |
669 // That is actually just a single packet, since each packet has 1000 bits of | 669 // That is actually just a single packet, since each packet has 1000 bits of |
670 // payload. | 670 // payload. |
671 ChokeFilter filter(NULL, 0); | 671 ChokeFilter filter(NULL, 0); |
672 filter.SetCapacity(10); | 672 filter.set_capacity_kbps(10); |
673 TestChoke(&filter, 100, 100, 1); | 673 TestChoke(&filter, 100, 100, 1); |
674 } | 674 } |
675 | 675 |
676 TEST_F(BweTestFramework_ChokeFilterTest, Medium) { | 676 TEST_F(BweTestFramework_ChokeFilterTest, Medium) { |
677 // 100ms, 10 packets, 10 kbps choke -> 1 packet through, or 1 kbit. | 677 // 100ms, 10 packets, 10 kbps choke -> 1 packet through, or 1 kbit. |
678 ChokeFilter filter(NULL, 0); | 678 ChokeFilter filter(NULL, 0); |
679 filter.SetCapacity(10); | 679 filter.set_capacity_kbps(10); |
680 TestChoke(&filter, 100, 10, 1); | 680 TestChoke(&filter, 100, 10, 1); |
681 // 200ms, no new packets -> another packet through. | 681 // 200ms, no new packets -> another packet through. |
682 TestChoke(&filter, 100, 0, 1); | 682 TestChoke(&filter, 100, 0, 1); |
683 // 1000ms, no new packets -> 8 more packets. | 683 // 1000ms, no new packets -> 8 more packets. |
684 TestChoke(&filter, 800, 0, 8); | 684 TestChoke(&filter, 800, 0, 8); |
685 // 2000ms, no new packets -> queue is empty so no output. | 685 // 2000ms, no new packets -> queue is empty so no output. |
686 TestChoke(&filter, 1000, 0, 0); | 686 TestChoke(&filter, 1000, 0, 0); |
687 } | 687 } |
688 | 688 |
689 TEST_F(BweTestFramework_ChokeFilterTest, Long) { | 689 TEST_F(BweTestFramework_ChokeFilterTest, Long) { |
690 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. | 690 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. |
691 ChokeFilter filter(NULL, 0); | 691 ChokeFilter filter(NULL, 0); |
692 filter.SetCapacity(10); | 692 filter.set_capacity_kbps(10); |
693 TestChoke(&filter, 100, 100, 1); | 693 TestChoke(&filter, 100, 100, 1); |
694 // 200ms, no input, another packet through. | 694 // 200ms, no input, another packet through. |
695 TestChoke(&filter, 100, 0, 1); | 695 TestChoke(&filter, 100, 0, 1); |
696 // 1000ms, no input, 8 packets through. | 696 // 1000ms, no input, 8 packets through. |
697 TestChoke(&filter, 800, 0, 8); | 697 TestChoke(&filter, 800, 0, 8); |
698 // 10000ms, no input, raise choke to 100 kbps. Remaining 90 packets in queue | 698 // 10000ms, no input, raise choke to 100 kbps. Remaining 90 packets in queue |
699 // should be propagated, for a total of 90 kbps. | 699 // should be propagated, for a total of 90 kbps. |
700 filter.SetCapacity(100); | 700 filter.set_capacity_kbps(100); |
701 TestChoke(&filter, 9000, 0, 90); | 701 TestChoke(&filter, 9000, 0, 90); |
702 // 10100ms, 20 more packets -> 10 packets or 10 kbit through. | 702 // 10100ms, 20 more packets -> 10 packets or 10 kbit through. |
703 TestChoke(&filter, 100, 20, 10); | 703 TestChoke(&filter, 100, 20, 10); |
704 // 10300ms, 10 more packets -> 20 packets out. | 704 // 10300ms, 10 more packets -> 20 packets out. |
705 TestChoke(&filter, 200, 10, 20); | 705 TestChoke(&filter, 200, 10, 20); |
706 // 11300ms, no input, queue should be empty. | 706 // 11300ms, no input, queue should be empty. |
707 filter.SetCapacity(10); | 707 filter.set_capacity_kbps(10); |
708 TestChoke(&filter, 1000, 0, 0); | 708 TestChoke(&filter, 1000, 0, 0); |
709 } | 709 } |
710 | 710 |
711 TEST_F(BweTestFramework_ChokeFilterTest, MaxDelay) { | 711 TEST_F(BweTestFramework_ChokeFilterTest, MaxDelay) { |
712 // 10 kbps choke, 500 ms delay cap | 712 // 10 kbps choke, 500 ms delay cap |
713 ChokeFilter filter(NULL, 0); | 713 ChokeFilter filter(NULL, 0); |
714 filter.SetCapacity(10); | 714 filter.set_capacity_kbps(10); |
715 filter.SetMaxDelay(500); | 715 filter.set_max_delay_ms(500); |
716 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. | 716 // 100ms, 100 packets in queue, 10 kbps choke -> 1 packet through, or 1 kbit. |
717 TestChoke(&filter, 100, 100, 1); | 717 TestChoke(&filter, 100, 100, 1); |
718 CheckMaxDelay(500); | 718 CheckMaxDelay(500); |
719 // 500ms, no input, 4 more packets through. | 719 // 500ms, no input, 4 more packets through. |
720 TestChoke(&filter, 400, 0, 4); | 720 TestChoke(&filter, 400, 0, 4); |
721 // 10000ms, no input, remaining packets should have been dropped. | 721 // 10000ms, no input, remaining packets should have been dropped. |
722 TestChoke(&filter, 9500, 0, 0); | 722 TestChoke(&filter, 9500, 0, 0); |
723 | 723 |
724 // 100 ms delay cap | 724 // 100 ms delay cap |
725 filter.SetMaxDelay(100); | 725 filter.set_max_delay_ms(100); |
726 // 10100ms, 50 more packets -> 2 packets or 2 kbit through. | 726 // 10100ms, 50 more packets -> 2 packets or 2 kbit through. |
727 TestChoke(&filter, 100, 50, 2); | 727 TestChoke(&filter, 100, 50, 2); |
728 CheckMaxDelay(100); | 728 CheckMaxDelay(100); |
729 // 20000ms, no input, remaining packets in queue should have been dropped. | 729 // 20000ms, no input, remaining packets in queue should have been dropped. |
730 TestChoke(&filter, 9900, 0, 0); | 730 TestChoke(&filter, 9900, 0, 0); |
731 | 731 |
732 // Reset delay cap (0 is no cap) and verify no packets are dropped. | 732 // Reset delay cap (0 is no cap) and verify no packets are dropped. |
733 filter.SetCapacity(10); | 733 filter.set_capacity_kbps(10); |
734 filter.SetMaxDelay(0); | 734 filter.set_max_delay_ms(0); |
735 TestChoke(&filter, 100, 100, 2); | 735 TestChoke(&filter, 100, 100, 2); |
736 TestChoke(&filter, 9900, 0, 98); | 736 TestChoke(&filter, 9900, 0, 98); |
737 } | 737 } |
738 | 738 |
739 TEST_F(BweTestFramework_ChokeFilterTest, ShortTrace) { | 739 TEST_F(BweTestFramework_ChokeFilterTest, ShortTrace) { |
740 // According to the input file 6 packets should be transmitted within | 740 // According to the input file 6 packets should be transmitted within |
741 // 100 milliseconds. | 741 // 100 milliseconds. |
742 TraceBasedDeliveryFilter filter(NULL, 0); | 742 TraceBasedDeliveryFilter filter(NULL, 0); |
743 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 743 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
744 TestChoke(&filter, 100, 100, 6); | 744 TestChoke(&filter, 100, 100, 6); |
745 } | 745 } |
746 | 746 |
747 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceTwoWraps) { | 747 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceTwoWraps) { |
748 // According to the input file 19 packets should be transmitted within | 748 // According to the input file 19 packets should be transmitted within |
749 // 280 milliseconds (at the wrapping point two packets are sent back to back). | 749 // 280 milliseconds (at the wrapping point two packets are sent back to back). |
750 TraceBasedDeliveryFilter filter(NULL, 0); | 750 TraceBasedDeliveryFilter filter(NULL, 0); |
751 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 751 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
752 TestChoke(&filter, 280, 100, 19); | 752 TestChoke(&filter, 280, 100, 19); |
753 } | 753 } |
754 | 754 |
755 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceMaxDelay) { | 755 TEST_F(BweTestFramework_ChokeFilterTest, ShortTraceMaxDelay) { |
756 TraceBasedDeliveryFilter filter(NULL, 0); | 756 TraceBasedDeliveryFilter filter(NULL, 0); |
757 filter.SetMaxDelay(25); | 757 filter.set_max_delay_ms(25); |
758 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); | 758 ASSERT_TRUE(filter.Init(test::ResourcePath("synthetic-trace", "rx"))); |
759 // Uses all slots up to 110 ms. Several packets are being dropped. | 759 // Uses all slots up to 110 ms. Several packets are being dropped. |
760 TestChoke(&filter, 110, 20, 9); | 760 TestChoke(&filter, 110, 20, 9); |
761 CheckMaxDelay(25); | 761 CheckMaxDelay(25); |
762 // Simulate enough time for the next slot (at 135 ms) to be used. This makes | 762 // Simulate enough time for the next slot (at 135 ms) to be used. This makes |
763 // sure that a slot isn't missed between runs. | 763 // sure that a slot isn't missed between runs. |
764 TestChoke(&filter, 25, 1, 1); | 764 TestChoke(&filter, 25, 1, 1); |
765 } | 765 } |
766 | 766 |
767 void TestVideoSender(VideoSender* sender, | 767 void TestVideoSender(VideoSender* sender, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 rtp_timestamp = media_packet->header().timestamp; | 801 rtp_timestamp = media_packet->header().timestamp; |
802 } | 802 } |
803 EXPECT_EQ(expected_total_payload_size, total_payload_size); | 803 EXPECT_EQ(expected_total_payload_size, total_payload_size); |
804 EXPECT_GE(1u, absolute_send_time_wraps); | 804 EXPECT_GE(1u, absolute_send_time_wraps); |
805 EXPECT_GE(1u, rtp_timestamp_wraps); | 805 EXPECT_GE(1u, rtp_timestamp_wraps); |
806 | 806 |
807 for (auto* packet : packets) | 807 for (auto* packet : packets) |
808 delete packet; | 808 delete packet; |
809 } | 809 } |
810 | 810 |
| 811 // Random {-1, 0, +1} ms was added to frame timestamps. |
| 812 |
811 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s) { | 813 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s) { |
812 // 1 fps, 80 kbps | 814 // 1 fps, 80 kbps |
813 VideoSource source(0, 1.0f, 80, 0x1234, 0); | 815 VideoSource source(0, 1.0f, 80, 0x1234, 0); |
814 VideoSender sender(NULL, &source, kNullEstimator); | 816 VideoSender sender(NULL, &source, kNullEstimator); |
815 EXPECT_EQ(80000u, source.bits_per_second()); | 817 EXPECT_EQ(80000u, source.bits_per_second()); |
816 // We're at 1 fps, so all packets should be generated on first call, giving 10 | 818 // We're at 1 fps, so all packets should be generated on first call, giving 10 |
817 // packets of each 1000 bytes, total 10000 bytes. | 819 // packets of each 1000 bytes, total 10000 bytes. |
818 TestVideoSender(&sender, 1, 9, 400, 10000); | 820 TestVideoSender(&sender, 1, 9, 400, 10000); |
819 // 999ms, should see no output here. | 821 // 998ms, should see no output here. |
820 TestVideoSender(&sender, 998, 0, 0, 0); | 822 TestVideoSender(&sender, 997, 0, 0, 0); |
821 // 1999ms, should get data for one more frame. | 823 // 1001ms, should get data for one more frame. |
822 TestVideoSender(&sender, 1000, 9, 400, 10000); | 824 TestVideoSender(&sender, 3, 9, 400, 10000); |
823 // 2000ms, one more frame. | 825 // 1998ms, should see no output here. |
824 TestVideoSender(&sender, 1, 9, 400, 10000); | 826 TestVideoSender(&sender, 997, 0, 0, 0); |
825 // 2999ms, should see nothing. | 827 // 2001ms, one more frame. |
826 TestVideoSender(&sender, 999, 0, 0, 0); | 828 TestVideoSender(&sender, 3, 9, 400, 10000); |
| 829 // 2998ms, should see nothing. |
| 830 TestVideoSender(&sender, 997, 0, 0, 0); |
827 } | 831 } |
828 | 832 |
829 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s_Offset) { | 833 TEST(BweTestFramework_VideoSenderTest, Fps1Kbps80_1s_Offset) { |
830 // 1 fps, 80 kbps, offset 0.5 of a frame period, ==0.5s in this case. | 834 // 1 fps, 80 kbps, offset 0.5 of a frame period, ==0.5s in this case. |
831 VideoSource source(0, 1.0f, 80, 0x1234, 500); | 835 VideoSource source(0, 1.0f, 80, 0x1234, 500); |
832 VideoSender sender(NULL, &source, kNullEstimator); | 836 VideoSender sender(NULL, &source, kNullEstimator); |
833 EXPECT_EQ(80000u, source.bits_per_second()); | 837 EXPECT_EQ(80000u, source.bits_per_second()); |
834 // 499ms, no output. | 838 // 498ms, no output. |
835 TestVideoSender(&sender, 499, 0, 0, 0); | 839 TestVideoSender(&sender, 498, 0, 0, 0); |
836 // 500ms, first frame (this is the offset we set), 10 packets of 1000 bytes. | 840 // 501ms, first frame (this is the offset we set), 10 packets of 1000 bytes. |
837 TestVideoSender(&sender, 1, 9, 400, 10000); | 841 TestVideoSender(&sender, 3, 9, 400, 10000); |
838 // 1499ms, nothing. | 842 // 1498ms, nothing. |
839 TestVideoSender(&sender, 999, 0, 0, 0); | 843 TestVideoSender(&sender, 997, 0, 0, 0); |
840 // 1999ms, second frame. | 844 // 1501ms, second frame. |
841 TestVideoSender(&sender, 500, 9, 400, 10000); | 845 TestVideoSender(&sender, 3, 9, 400, 10000); |
842 // 2499ms, nothing. | 846 // 2498ms, nothing. |
843 TestVideoSender(&sender, 500, 0, 0, 0); | 847 TestVideoSender(&sender, 997, 0, 0, 0); |
844 // 2500ms, third frame. | 848 // 2501ms, third frame. |
845 TestVideoSender(&sender, 1, 9, 400, 10000); | 849 TestVideoSender(&sender, 3, 9, 400, 10000); |
846 // 3499ms, nothing. | 850 // 3498ms, nothing. |
847 TestVideoSender(&sender, 999, 0, 0, 0); | 851 TestVideoSender(&sender, 997, 0, 0, 0); |
848 } | 852 } |
849 | 853 |
850 TEST(BweTestFramework_VideoSenderTest, Fps50Kpbs80_11s) { | 854 TEST(BweTestFramework_VideoSenderTest, Fps50Kpbs80_11s) { |
851 // 50 fps, 80 kbps. | 855 // 50 fps, 80 kbps. |
852 VideoSource source(0, 50.0f, 80, 0x1234, 0); | 856 VideoSource source(0, 50.0f, 80, 0x1234, 0); |
853 VideoSender sender(NULL, &source, kNullEstimator); | 857 VideoSender sender(NULL, &source, kNullEstimator); |
854 EXPECT_EQ(80000u, source.bits_per_second()); | 858 EXPECT_EQ(80000u, source.bits_per_second()); |
855 // 9998ms, should see 500 frames, 200 byte payloads, total 100000 bytes. | 859 // 9981, should see 500 frames, 200 byte payloads, total 100000 bytes. |
856 TestVideoSender(&sender, 9998, 500, 200, 100000); | 860 TestVideoSender(&sender, 9981, 500, 200, 100000); |
857 // 9999ms, nothing. | 861 // 9998ms, nothing. |
858 TestVideoSender(&sender, 1, 0, 0, 0); | 862 TestVideoSender(&sender, 17, 0, 0, 0); |
859 // 10000ms, 501st frame as a single packet. | 863 // 10001ms, 501st frame as a single packet. |
860 TestVideoSender(&sender, 1, 1, 200, 200); | 864 TestVideoSender(&sender, 3, 1, 200, 200); |
861 // 10998ms, 49 more frames. | 865 // 10981ms, 49 more frames. |
862 TestVideoSender(&sender, 998, 49, 200, 9800); | 866 TestVideoSender(&sender, 981, 49, 200, 9800); |
863 // 10999ms, nothing. | 867 // 10998ms, nothing. |
864 TestVideoSender(&sender, 1, 0, 0, 0); | 868 TestVideoSender(&sender, 17, 0, 0, 0); |
865 } | 869 } |
866 | 870 |
867 TEST(BweTestFramework_VideoSenderTest, Fps10Kpbs120_1s) { | 871 TEST(BweTestFramework_VideoSenderTest, Fps20Kpbs120_1s) { |
868 // 20 fps, 120 kbps. | 872 // 20 fps, 120 kbps. |
869 VideoSource source(0, 20.0f, 120, 0x1234, 0); | 873 VideoSource source(0, 20.0f, 120, 0x1234, 0); |
870 VideoSender sender(NULL, &source, kNullEstimator); | 874 VideoSender sender(NULL, &source, kNullEstimator); |
871 EXPECT_EQ(120000u, source.bits_per_second()); | 875 EXPECT_EQ(120000u, source.bits_per_second()); |
872 // 498ms, 10 frames with 750 byte payloads, total 7500 bytes. | 876 // 451ms, 10 frames with 750 byte payloads, total 7500 bytes. |
873 TestVideoSender(&sender, 498, 10, 750, 7500); | 877 TestVideoSender(&sender, 451, 10, 750, 7500); |
874 // 499ms, nothing. | 878 // 498ms, nothing. |
875 TestVideoSender(&sender, 1, 0, 0, 0); | 879 TestVideoSender(&sender, 47, 0, 0, 0); |
876 // 500ms, one more frame. | 880 // 501ms, one more frame. |
877 TestVideoSender(&sender, 1, 1, 750, 750); | 881 TestVideoSender(&sender, 3, 1, 750, 750); |
878 // 998ms, 9 more frames. | 882 // 951ms, 9 more frames. |
879 TestVideoSender(&sender, 498, 9, 750, 6750); | 883 TestVideoSender(&sender, 450, 9, 750, 6750); |
880 // 999ms, nothing. | 884 // 998ms, nothing. |
881 TestVideoSender(&sender, 1, 0, 0, 0); | 885 TestVideoSender(&sender, 47, 0, 0, 0); |
882 } | 886 } |
883 | 887 |
884 TEST(BweTestFramework_VideoSenderTest, Fps30Kbps800_20s) { | 888 TEST(BweTestFramework_VideoSenderTest, Fps25Kbps820_20s) { |
885 // 20 fps, 820 kbps. | 889 // 25 fps, 820 kbps. |
886 VideoSource source(0, 25.0f, 820, 0x1234, 0); | 890 VideoSource source(0, 25.0f, 820, 0x1234, 0); |
887 VideoSender sender(NULL, &source, kNullEstimator); | 891 VideoSender sender(NULL, &source, kNullEstimator); |
888 EXPECT_EQ(820000u, source.bits_per_second()); | 892 EXPECT_EQ(820000u, source.bits_per_second()); |
889 // 9998ms, 250 frames. 820 kbps = 102500 bytes/s, so total should be 1025000. | 893 // 9961ms, 250 frames. 820 kbps = 102500 bytes/s, so total should be 1025000. |
890 // Each frame is 102500/25=4100 bytes, or 5 packets (4 @1000 bytes, 1 @100), | 894 // Each frame is 102500/25=4100 bytes, or 5 packets (4 @1000 bytes, 1 @100), |
891 // so packet count should be 5*250=1250 and last packet of each frame has | 895 // so packet count should be 5*250=1250 and last packet of each frame has |
892 // 100 bytes of payload. | 896 // 100 bytes of payload. |
893 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 897 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
894 // 9999ms, nothing. | 898 // 9998ms, nothing. |
895 TestVideoSender(&sender, 1, 0, 0, 0); | 899 TestVideoSender(&sender, 37, 0, 0, 0); |
896 // 19998ms, 250 more frames. | 900 // 19961ms, 250 more frames. |
897 TestVideoSender(&sender, 9999, 1000, 500, 1025000); | 901 TestVideoSender(&sender, 9963, 1000, 500, 1025000); |
898 // 19999ms, nothing. | 902 // 19998ms, nothing. |
899 TestVideoSender(&sender, 1, 0, 0, 0); | 903 TestVideoSender(&sender, 37, 0, 0, 0); |
900 // 20038ms, one more frame, as described above (25fps == 40ms/frame). | 904 // 20001ms, one more frame, as described above (25fps == 40ms/frame). |
901 TestVideoSender(&sender, 39, 4, 500, 4100); | 905 TestVideoSender(&sender, 3, 4, 500, 4100); |
902 // 20039ms, nothing. | 906 // 20038ms, nothing. |
903 TestVideoSender(&sender, 1, 0, 0, 0); | 907 TestVideoSender(&sender, 37, 0, 0, 0); |
904 } | 908 } |
905 | 909 |
906 TEST(BweTestFramework_VideoSenderTest, TestAppendInOrder) { | 910 TEST(BweTestFramework_VideoSenderTest, TestAppendInOrder) { |
907 // 1 fps, 80 kbps, 250ms offset. | 911 // 1 fps, 80 kbps, 250ms offset. |
908 VideoSource source1(0, 1.0f, 80, 0x1234, 250); | 912 VideoSource source1(0, 1.0f, 80, 0x1234, 250); |
909 VideoSender sender1(NULL, &source1, kNullEstimator); | 913 VideoSender sender1(NULL, &source1, kNullEstimator); |
910 EXPECT_EQ(80000u, source1.bits_per_second()); | 914 EXPECT_EQ(80000u, source1.bits_per_second()); |
911 Packets packets; | 915 Packets packets; |
912 // Generate some packets, verify they are sorted. | 916 // Generate some packets, verify they are sorted. |
913 sender1.RunFor(999, &packets); | 917 sender1.RunFor(999, &packets); |
(...skipping 22 matching lines...) Expand all Loading... |
936 | 940 |
937 for (auto* packet : packets) | 941 for (auto* packet : packets) |
938 delete packet; | 942 delete packet; |
939 } | 943 } |
940 | 944 |
941 TEST(BweTestFramework_VideoSenderTest, FeedbackIneffective) { | 945 TEST(BweTestFramework_VideoSenderTest, FeedbackIneffective) { |
942 VideoSource source(0, 25.0f, 820, 0x1234, 0); | 946 VideoSource source(0, 25.0f, 820, 0x1234, 0); |
943 VideoSender sender(NULL, &source, kNullEstimator); | 947 VideoSender sender(NULL, &source, kNullEstimator); |
944 | 948 |
945 EXPECT_EQ(820000u, source.bits_per_second()); | 949 EXPECT_EQ(820000u, source.bits_per_second()); |
946 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 950 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
947 | 951 |
948 // Make sure feedback has no effect on a regular video sender. | 952 // Make sure feedback has no effect on a regular video sender. |
949 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); | 953 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); |
950 Packets packets; | 954 Packets packets; |
951 packets.push_back(feedback); | 955 packets.push_back(feedback); |
952 sender.RunFor(0, &packets); | 956 sender.RunFor(0, &packets); |
953 EXPECT_EQ(820000u, source.bits_per_second()); | 957 EXPECT_EQ(820000u, source.bits_per_second()); |
954 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 958 TestVideoSender(&sender, 10000, 1000, 500, 1025000); |
955 } | 959 } |
956 | 960 |
957 TEST(BweTestFramework_AdaptiveVideoSenderTest, FeedbackChangesBitrate) { | 961 TEST(BweTestFramework_AdaptiveVideoSenderTest, FeedbackChangesBitrate) { |
958 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); | 962 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); |
959 VideoSender sender(NULL, &source, kRembEstimator); | 963 VideoSender sender(NULL, &source, kRembEstimator); |
960 EXPECT_EQ(820000u, source.bits_per_second()); | 964 EXPECT_EQ(820000u, source.bits_per_second()); |
961 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 965 TestVideoSender(&sender, 9961, 1000, 500, 1025000); |
962 | 966 |
963 // Make sure we can reduce the bitrate. | 967 // Make sure we can reduce the bitrate. |
964 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); | 968 RembFeedback* feedback = new RembFeedback(0, 0, 0, 512000, RTCPReportBlock()); |
965 Packets packets; | 969 Packets packets; |
966 packets.push_back(feedback); | 970 packets.push_back(feedback); |
967 sender.RunFor(0, &packets); | 971 sender.RunFor(0, &packets); |
968 EXPECT_EQ(512000u, source.bits_per_second()); | 972 EXPECT_EQ(512000u, source.bits_per_second()); |
969 TestVideoSender(&sender, 9998, 750, 160, 640000); | 973 TestVideoSender(&sender, 10000, 750, 160, 640000); |
970 | 974 |
971 // Increase the bitrate to the initial bitrate and verify that the output is | 975 // Increase the bitrate to the initial bitrate and verify that the output is |
972 // the same. | 976 // the same. |
973 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); | 977 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); |
974 packets.push_back(feedback); | 978 packets.push_back(feedback); |
975 sender.RunFor(10000, &packets); | 979 sender.RunFor(10000, &packets); |
976 EXPECT_EQ(820000u, source.bits_per_second()); | 980 EXPECT_EQ(820000u, source.bits_per_second()); |
977 | 981 |
978 for (auto* packet : packets) | 982 for (auto* packet : packets) |
979 delete packet; | 983 delete packet; |
980 } | 984 } |
981 | 985 |
982 TEST(BweTestFramework_AdaptiveVideoSenderTest, Paced_FeedbackChangesBitrate) { | 986 TEST(BweTestFramework_AdaptiveVideoSenderTest, Paced_FeedbackChangesBitrate) { |
983 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); | 987 AdaptiveVideoSource source(0, 25.0f, 820, 0x1234, 0); |
984 PacedVideoSender sender(NULL, &source, kRembEstimator); | 988 PacedVideoSender sender(NULL, &source, kRembEstimator); |
985 EXPECT_EQ(820000u, source.bits_per_second()); | 989 EXPECT_EQ(820000u, source.bits_per_second()); |
986 TestVideoSender(&sender, 9998, 1000, 500, 1025000); | 990 TestVideoSender(&sender, 9998, 1000, 500, 1025000); |
987 | 991 |
988 // Make sure we can reduce the bitrate. | 992 // Make sure we can reduce the bitrate. |
989 RembFeedback* feedback = new RembFeedback(0, 1, 0, 512000, RTCPReportBlock()); | 993 RembFeedback* feedback = new RembFeedback(0, 1, 0, 512000, RTCPReportBlock()); |
990 Packets packets; | 994 Packets packets; |
991 packets.push_back(feedback); | 995 packets.push_back(feedback); |
992 sender.RunFor(10000, &packets); | 996 sender.RunFor(10000, &packets); |
993 ASSERT_EQ(512000u, source.bits_per_second()); | 997 ASSERT_EQ(512000u, source.bits_per_second()); |
994 TestVideoSender(&sender, 9998, 750, 160, 640000); | 998 TestVideoSender(&sender, 10000, 750, 160, 640000); |
995 | 999 |
996 // Increase the bitrate to the initial bitrate and verify that the output is | 1000 // Increase the bitrate to the initial bitrate and verify that the output is |
997 // the same. | 1001 // the same. |
998 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); | 1002 feedback = new RembFeedback(0, 0, 0, 820000, RTCPReportBlock()); |
999 packets.push_back(feedback); | 1003 packets.push_back(feedback); |
1000 sender.RunFor(10000, &packets); | 1004 sender.RunFor(10000, &packets); |
1001 EXPECT_EQ(820000u, source.bits_per_second()); | 1005 EXPECT_EQ(820000u, source.bits_per_second()); |
1002 | 1006 |
1003 for (auto* packet : packets) | 1007 for (auto* packet : packets) |
1004 delete packet; | 1008 delete packet; |
1005 } | 1009 } |
1006 } // namespace bwe | 1010 } // namespace bwe |
1007 } // namespace testing | 1011 } // namespace testing |
1008 } // namespace webrtc | 1012 } // namespace webrtc |
OLD | NEW |