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 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 RunBaseTest(&test); | 528 RunBaseTest(&test); |
529 } | 529 } |
530 | 530 |
531 #if !defined(RTC_DISABLE_VP9) | 531 #if !defined(RTC_DISABLE_VP9) |
532 TEST_F(VideoSendStreamTest, DoesUtilizeUlpfecForVp9WithNackEnabled) { | 532 TEST_F(VideoSendStreamTest, DoesUtilizeUlpfecForVp9WithNackEnabled) { |
533 UlpfecObserver test(false, true, true, true, "VP9"); | 533 UlpfecObserver test(false, true, true, true, "VP9"); |
534 RunBaseTest(&test); | 534 RunBaseTest(&test); |
535 } | 535 } |
536 #endif // !defined(RTC_DISABLE_VP9) | 536 #endif // !defined(RTC_DISABLE_VP9) |
537 | 537 |
| 538 // TODO(brandtr): Move these FlexFEC tests when we have created |
| 539 // FlexfecSendStream. |
| 540 class FlexfecObserver : public test::EndToEndTest { |
| 541 public: |
| 542 FlexfecObserver(bool header_extensions_enabled, |
| 543 bool use_nack, |
| 544 const std::string& codec) |
| 545 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), |
| 546 payload_name_(codec), |
| 547 use_nack_(use_nack), |
| 548 send_count_(0), |
| 549 sent_media_(false), |
| 550 sent_flexfec_(false), |
| 551 header_extensions_enabled_(header_extensions_enabled) { |
| 552 if (codec == "H264") { |
| 553 encoder_.reset(new test::FakeH264Encoder(Clock::GetRealTimeClock())); |
| 554 } else if (codec == "VP8") { |
| 555 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)); |
| 556 } else if (codec == "VP9") { |
| 557 encoder_.reset(VideoEncoder::Create(VideoEncoder::EncoderType::kVp9)); |
| 558 } else { |
| 559 RTC_NOTREACHED(); |
| 560 } |
| 561 } |
| 562 |
| 563 size_t GetNumFlexfecStreams() const override { return 1; } |
| 564 |
| 565 private: |
| 566 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 567 RTPHeader header; |
| 568 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 569 |
| 570 ++send_count_; |
| 571 if (header.payloadType == VideoSendStreamTest::kFlexfecPayloadType) { |
| 572 EXPECT_EQ(VideoSendStreamTest::kFlexfecSendSsrc, header.ssrc); |
| 573 sent_flexfec_ = true; |
| 574 } else { |
| 575 EXPECT_EQ(VideoSendStreamTest::kFakeVideoSendPayloadType, |
| 576 header.payloadType); |
| 577 EXPECT_EQ(VideoSendStreamTest::kVideoSendSsrcs[0], header.ssrc); |
| 578 sent_media_ = true; |
| 579 } |
| 580 |
| 581 if (header_extensions_enabled_) { |
| 582 EXPECT_TRUE(header.extension.hasAbsoluteSendTime); |
| 583 EXPECT_TRUE(header.extension.hasTransmissionTimeOffset); |
| 584 EXPECT_TRUE(header.extension.hasTransportSequenceNumber); |
| 585 } |
| 586 |
| 587 if (send_count_ > 100 && sent_media_ && sent_flexfec_) { |
| 588 observation_complete_.Set(); |
| 589 } |
| 590 |
| 591 return SEND_PACKET; |
| 592 } |
| 593 |
| 594 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
| 595 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC. |
| 596 // Therefore we need some network delay. |
| 597 const int kNetworkDelayMs = 100; |
| 598 FakeNetworkPipe::Config config; |
| 599 config.loss_percent = 50; |
| 600 config.queue_delay_ms = kNetworkDelayMs; |
| 601 return new test::PacketTransport(sender_call, this, |
| 602 test::PacketTransport::kSender, config); |
| 603 } |
| 604 |
| 605 void ModifyVideoConfigs( |
| 606 VideoSendStream::Config* send_config, |
| 607 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 608 VideoEncoderConfig* encoder_config) override { |
| 609 transport_adapter_.reset( |
| 610 new internal::TransportAdapter(send_config->send_transport)); |
| 611 transport_adapter_->Enable(); |
| 612 if (use_nack_) { |
| 613 send_config->rtp.nack.rtp_history_ms = |
| 614 (*receive_configs)[0].rtp.nack.rtp_history_ms = |
| 615 VideoSendStreamTest::kNackRtpHistoryMs; |
| 616 } |
| 617 send_config->encoder_settings.encoder = encoder_.get(); |
| 618 send_config->encoder_settings.payload_name = payload_name_; |
| 619 if (header_extensions_enabled_) { |
| 620 send_config->rtp.extensions.push_back(RtpExtension( |
| 621 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId)); |
| 622 send_config->rtp.extensions.push_back(RtpExtension( |
| 623 RtpExtension::kTimestampOffsetUri, test::kTOffsetExtensionId)); |
| 624 send_config->rtp.extensions.push_back( |
| 625 RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
| 626 test::kTransportSequenceNumberExtensionId)); |
| 627 } |
| 628 } |
| 629 |
| 630 void PerformTest() override { |
| 631 EXPECT_TRUE(Wait()) |
| 632 << "Timed out waiting for FlexFEC and/or media packets."; |
| 633 } |
| 634 |
| 635 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
| 636 std::unique_ptr<VideoEncoder> encoder_; |
| 637 const std::string payload_name_; |
| 638 const bool use_nack_; |
| 639 int send_count_; |
| 640 bool sent_media_; |
| 641 bool sent_flexfec_; |
| 642 bool header_extensions_enabled_; |
| 643 }; |
| 644 |
| 645 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsVp8) { |
| 646 FlexfecObserver test(true, false, "VP8"); |
| 647 RunBaseTest(&test); |
| 648 } |
| 649 |
| 650 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsVp8) { |
| 651 FlexfecObserver test(false, false, "VP8"); |
| 652 RunBaseTest(&test); |
| 653 } |
| 654 |
| 655 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackVp8) { |
| 656 FlexfecObserver test(true, true, "VP8"); |
| 657 RunBaseTest(&test); |
| 658 } |
| 659 |
| 660 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackVp8) { |
| 661 FlexfecObserver test(false, true, "VP8"); |
| 662 RunBaseTest(&test); |
| 663 } |
| 664 |
| 665 #if !defined(RTC_DISABLE_VP9) |
| 666 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsVp9) { |
| 667 FlexfecObserver test(true, false, "VP9"); |
| 668 RunBaseTest(&test); |
| 669 } |
| 670 |
| 671 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsVp9) { |
| 672 FlexfecObserver test(false, false, "VP9"); |
| 673 RunBaseTest(&test); |
| 674 } |
| 675 |
| 676 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackVp9) { |
| 677 FlexfecObserver test(true, true, "VP9"); |
| 678 RunBaseTest(&test); |
| 679 } |
| 680 |
| 681 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackVp9) { |
| 682 FlexfecObserver test(false, true, "VP9"); |
| 683 RunBaseTest(&test); |
| 684 } |
| 685 #endif // defined(RTC_DISABLE_VP9) |
| 686 |
| 687 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsH264) { |
| 688 FlexfecObserver test(true, false, "H264"); |
| 689 RunBaseTest(&test); |
| 690 } |
| 691 |
| 692 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsH264) { |
| 693 FlexfecObserver test(false, false, "H264"); |
| 694 RunBaseTest(&test); |
| 695 } |
| 696 |
| 697 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackH264) { |
| 698 FlexfecObserver test(true, true, "H264"); |
| 699 RunBaseTest(&test); |
| 700 } |
| 701 |
| 702 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackH264) { |
| 703 FlexfecObserver test(false, true, "H264"); |
| 704 RunBaseTest(&test); |
| 705 } |
| 706 |
538 void VideoSendStreamTest::TestNackRetransmission( | 707 void VideoSendStreamTest::TestNackRetransmission( |
539 uint32_t retransmit_ssrc, | 708 uint32_t retransmit_ssrc, |
540 uint8_t retransmit_payload_type) { | 709 uint8_t retransmit_payload_type) { |
541 class NackObserver : public test::SendTest { | 710 class NackObserver : public test::SendTest { |
542 public: | 711 public: |
543 explicit NackObserver(uint32_t retransmit_ssrc, | 712 explicit NackObserver(uint32_t retransmit_ssrc, |
544 uint8_t retransmit_payload_type) | 713 uint8_t retransmit_payload_type) |
545 : SendTest(kDefaultTimeoutMs), | 714 : SendTest(kDefaultTimeoutMs), |
546 send_count_(0), | 715 send_count_(0), |
547 retransmit_ssrc_(retransmit_ssrc), | 716 retransmit_ssrc_(retransmit_ssrc), |
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2987 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { | 3156 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { |
2988 TestRequestSourceRotateVideo(false); | 3157 TestRequestSourceRotateVideo(false); |
2989 } | 3158 } |
2990 | 3159 |
2991 TEST_F(VideoSendStreamTest, | 3160 TEST_F(VideoSendStreamTest, |
2992 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { | 3161 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { |
2993 TestRequestSourceRotateVideo(true); | 3162 TestRequestSourceRotateVideo(true); |
2994 } | 3163 } |
2995 | 3164 |
2996 } // namespace webrtc | 3165 } // namespace webrtc |
OLD | NEW |