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> | 10 #include <algorithm> |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 } | 659 } |
660 | 660 |
661 rtc::CriticalSection crit_; | 661 rtc::CriticalSection crit_; |
662 std::set<uint32_t> protected_sequence_numbers_ GUARDED_BY(crit_); | 662 std::set<uint32_t> protected_sequence_numbers_ GUARDED_BY(crit_); |
663 std::set<uint32_t> protected_timestamps_ GUARDED_BY(crit_); | 663 std::set<uint32_t> protected_timestamps_ GUARDED_BY(crit_); |
664 } test; | 664 } test; |
665 | 665 |
666 RunBaseTest(&test); | 666 RunBaseTest(&test); |
667 } | 667 } |
668 | 668 |
669 TEST_F(EndToEndTest, CanReceiveFlexfec) { | |
670 class FlexfecRenderObserver : public test::EndToEndTest, | |
671 public rtc::VideoSinkInterface<VideoFrame> { | |
672 public: | |
673 FlexfecRenderObserver() | |
674 : EndToEndTest(kDefaultTimeoutMs), state_(kFirstPacket) {} | |
675 | |
676 size_t GetNumFlexfecStreams() const override { return 1; } | |
677 | |
678 private: | |
679 Action OnSendRtp(const uint8_t* packet, size_t length) override { | |
680 rtc::CritScope lock(&crit_); | |
681 RTPHeader header; | |
682 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | |
683 | |
684 uint8_t payload_type = header.payloadType; | |
685 if (payload_type != kFakeVideoSendPayloadType) { | |
686 EXPECT_EQ(kFlexfecPayloadType, payload_type); | |
687 } | |
688 | |
689 auto seq_num_it = protected_sequence_numbers_.find(header.sequenceNumber); | |
690 if (seq_num_it != protected_sequence_numbers_.end()) { | |
691 // Retransmitted packet, should not count. | |
692 protected_sequence_numbers_.erase(seq_num_it); | |
693 auto ts_it = protected_timestamps_.find(header.timestamp); | |
694 EXPECT_NE(ts_it, protected_timestamps_.end()); | |
695 protected_timestamps_.erase(ts_it); | |
696 return SEND_PACKET; | |
697 } | |
698 | |
699 switch (state_) { | |
700 case kFirstPacket: | |
701 state_ = kDropEveryOtherPacketUntilFlexfec; | |
702 break; | |
703 case kDropEveryOtherPacketUntilFlexfec: | |
704 if (payload_type == kFlexfecPayloadType) { | |
705 state_ = kDropNextMediaPacket; | |
706 return SEND_PACKET; | |
707 } | |
708 if (header.sequenceNumber % 2 == 0) | |
709 return DROP_PACKET; | |
710 break; | |
711 case kDropNextMediaPacket: | |
712 if (payload_type == kFakeVideoSendPayloadType) { | |
713 protected_sequence_numbers_.insert(header.sequenceNumber); | |
714 protected_timestamps_.insert(header.timestamp); | |
715 state_ = kDropEveryOtherPacketUntilFlexfec; | |
716 return DROP_PACKET; | |
717 } | |
718 break; | |
719 } | |
720 | |
721 return SEND_PACKET; | |
722 } | |
723 | |
724 void OnFrame(const VideoFrame& video_frame) override { | |
725 rtc::CritScope lock(&crit_); | |
726 // Rendering frame with timestamp of packet that was dropped -> FEC | |
727 // protection worked. | |
728 auto it = protected_timestamps_.find(video_frame.timestamp()); | |
729 if (it != protected_timestamps_.end()) | |
730 observation_complete_.Set(); | |
731 } | |
732 | |
733 enum { | |
734 kFirstPacket, | |
735 kDropEveryOtherPacketUntilFlexfec, | |
736 kDropNextMediaPacket, | |
737 } state_; | |
738 | |
739 void ModifyVideoConfigs( | |
740 VideoSendStream::Config* send_config, | |
741 std::vector<VideoReceiveStream::Config>* receive_configs, | |
742 VideoEncoderConfig* encoder_config) override { | |
743 (*receive_configs)[0].renderer = this; | |
744 } | |
745 | |
746 void PerformTest() override { | |
747 EXPECT_TRUE(Wait()) | |
748 << "Timed out waiting for dropped frames frames to be rendered."; | |
nisse-webrtc
2016/11/16 07:45:27
Repeated word.
brandtr
2016/11/16 07:48:41
Fixed.
| |
749 } | |
750 | |
751 rtc::CriticalSection crit_; | |
752 std::set<uint32_t> protected_sequence_numbers_ GUARDED_BY(crit_); | |
753 std::set<uint32_t> protected_timestamps_ GUARDED_BY(crit_); | |
754 } test; | |
755 | |
756 RunBaseTest(&test); | |
757 } | |
758 | |
669 TEST_F(EndToEndTest, ReceivedUlpfecPacketsNotNacked) { | 759 TEST_F(EndToEndTest, ReceivedUlpfecPacketsNotNacked) { |
670 class UlpfecNackObserver : public test::EndToEndTest { | 760 class UlpfecNackObserver : public test::EndToEndTest { |
671 public: | 761 public: |
672 UlpfecNackObserver() | 762 UlpfecNackObserver() |
673 : EndToEndTest(kDefaultTimeoutMs), | 763 : EndToEndTest(kDefaultTimeoutMs), |
674 state_(kFirstPacket), | 764 state_(kFirstPacket), |
675 ulpfec_sequence_number_(0), | 765 ulpfec_sequence_number_(0), |
676 has_last_sequence_number_(false), | 766 has_last_sequence_number_(false), |
677 last_sequence_number_(0), | 767 last_sequence_number_(0), |
678 encoder_(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)), | 768 encoder_(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)), |
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3702 | 3792 |
3703 void VerifyEmptyUlpfecConfig(const UlpfecConfig& config) { | 3793 void VerifyEmptyUlpfecConfig(const UlpfecConfig& config) { |
3704 EXPECT_EQ(-1, config.ulpfec_payload_type) | 3794 EXPECT_EQ(-1, config.ulpfec_payload_type) |
3705 << "Enabling ULPFEC requires rtpmap: ulpfec negotiation."; | 3795 << "Enabling ULPFEC requires rtpmap: ulpfec negotiation."; |
3706 EXPECT_EQ(-1, config.red_payload_type) | 3796 EXPECT_EQ(-1, config.red_payload_type) |
3707 << "Enabling ULPFEC requires rtpmap: red negotiation."; | 3797 << "Enabling ULPFEC requires rtpmap: red negotiation."; |
3708 EXPECT_EQ(-1, config.red_rtx_payload_type) | 3798 EXPECT_EQ(-1, config.red_rtx_payload_type) |
3709 << "Enabling RTX in ULPFEC requires rtpmap: rtx negotiation."; | 3799 << "Enabling RTX in ULPFEC requires rtpmap: rtx negotiation."; |
3710 } | 3800 } |
3711 | 3801 |
3802 void VerifyEmptyFlexfecConfig(const FlexfecConfig& config) { | |
3803 EXPECT_EQ(-1, config.flexfec_payload_type) | |
3804 << "Enabling FlexFEC requires rtpmap: flexfec negotiation."; | |
3805 EXPECT_TRUE(config.protected_media_ssrcs.empty()) | |
3806 << "Enabling FlexFEC requires ssrc-group: FEC-FR negotiation."; | |
3807 } | |
3808 | |
3712 TEST_F(EndToEndTest, VerifyDefaultSendConfigParameters) { | 3809 TEST_F(EndToEndTest, VerifyDefaultSendConfigParameters) { |
3713 VideoSendStream::Config default_send_config(nullptr); | 3810 VideoSendStream::Config default_send_config(nullptr); |
3714 EXPECT_EQ(0, default_send_config.rtp.nack.rtp_history_ms) | 3811 EXPECT_EQ(0, default_send_config.rtp.nack.rtp_history_ms) |
3715 << "Enabling NACK require rtcp-fb: nack negotiation."; | 3812 << "Enabling NACK require rtcp-fb: nack negotiation."; |
3716 EXPECT_TRUE(default_send_config.rtp.rtx.ssrcs.empty()) | 3813 EXPECT_TRUE(default_send_config.rtp.rtx.ssrcs.empty()) |
3717 << "Enabling RTX requires rtpmap: rtx negotiation."; | 3814 << "Enabling RTX requires rtpmap: rtx negotiation."; |
3718 EXPECT_TRUE(default_send_config.rtp.extensions.empty()) | 3815 EXPECT_TRUE(default_send_config.rtp.extensions.empty()) |
3719 << "Enabling RTP extensions require negotiation."; | 3816 << "Enabling RTP extensions require negotiation."; |
3720 | 3817 |
3721 VerifyEmptyNackConfig(default_send_config.rtp.nack); | 3818 VerifyEmptyNackConfig(default_send_config.rtp.nack); |
3722 VerifyEmptyUlpfecConfig(default_send_config.rtp.ulpfec); | 3819 VerifyEmptyUlpfecConfig(default_send_config.rtp.ulpfec); |
3820 VerifyEmptyFlexfecConfig(default_send_config.rtp.flexfec); | |
3723 } | 3821 } |
3724 | 3822 |
3725 TEST_F(EndToEndTest, VerifyDefaultReceiveConfigParameters) { | 3823 TEST_F(EndToEndTest, VerifyDefaultVideoReceiveConfigParameters) { |
3726 VideoReceiveStream::Config default_receive_config(nullptr); | 3824 VideoReceiveStream::Config default_receive_config(nullptr); |
3727 EXPECT_EQ(RtcpMode::kCompound, default_receive_config.rtp.rtcp_mode) | 3825 EXPECT_EQ(RtcpMode::kCompound, default_receive_config.rtp.rtcp_mode) |
3728 << "Reduced-size RTCP require rtcp-rsize to be negotiated."; | 3826 << "Reduced-size RTCP require rtcp-rsize to be negotiated."; |
3729 EXPECT_FALSE(default_receive_config.rtp.remb) | 3827 EXPECT_FALSE(default_receive_config.rtp.remb) |
3730 << "REMB require rtcp-fb: goog-remb to be negotiated."; | 3828 << "REMB require rtcp-fb: goog-remb to be negotiated."; |
3731 EXPECT_FALSE( | 3829 EXPECT_FALSE( |
3732 default_receive_config.rtp.rtcp_xr.receiver_reference_time_report) | 3830 default_receive_config.rtp.rtcp_xr.receiver_reference_time_report) |
3733 << "RTCP XR settings require rtcp-xr to be negotiated."; | 3831 << "RTCP XR settings require rtcp-xr to be negotiated."; |
3734 EXPECT_TRUE(default_receive_config.rtp.rtx.empty()) | 3832 EXPECT_TRUE(default_receive_config.rtp.rtx.empty()) |
3735 << "Enabling RTX requires rtpmap: rtx negotiation."; | 3833 << "Enabling RTX requires rtpmap: rtx negotiation."; |
3736 EXPECT_TRUE(default_receive_config.rtp.extensions.empty()) | 3834 EXPECT_TRUE(default_receive_config.rtp.extensions.empty()) |
3737 << "Enabling RTP extensions require negotiation."; | 3835 << "Enabling RTP extensions require negotiation."; |
3738 | 3836 |
3739 VerifyEmptyNackConfig(default_receive_config.rtp.nack); | 3837 VerifyEmptyNackConfig(default_receive_config.rtp.nack); |
3740 VerifyEmptyUlpfecConfig(default_receive_config.rtp.ulpfec); | 3838 VerifyEmptyUlpfecConfig(default_receive_config.rtp.ulpfec); |
3741 } | 3839 } |
3742 | 3840 |
3841 TEST_F(EndToEndTest, VerifyDefaultFlexfecReceiveConfigParameters) { | |
3842 FlexfecReceiveStream::Config default_receive_config; | |
3843 VerifyEmptyFlexfecConfig(default_receive_config); | |
3844 } | |
3845 | |
3743 TEST_F(EndToEndTest, TransportSeqNumOnAudioAndVideo) { | 3846 TEST_F(EndToEndTest, TransportSeqNumOnAudioAndVideo) { |
3744 static const int kExtensionId = 8; | 3847 static const int kExtensionId = 8; |
3745 class TransportSequenceNumberTest : public test::EndToEndTest { | 3848 class TransportSequenceNumberTest : public test::EndToEndTest { |
3746 public: | 3849 public: |
3747 TransportSequenceNumberTest() | 3850 TransportSequenceNumberTest() |
3748 : EndToEndTest(kDefaultTimeoutMs), | 3851 : EndToEndTest(kDefaultTimeoutMs), |
3749 video_observed_(false), | 3852 video_observed_(false), |
3750 audio_observed_(false) { | 3853 audio_observed_(false) { |
3751 parser_->RegisterRtpHeaderExtension(kRtpExtensionTransportSequenceNumber, | 3854 parser_->RegisterRtpHeaderExtension(kRtpExtensionTransportSequenceNumber, |
3752 kExtensionId); | 3855 kExtensionId); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3907 std::unique_ptr<VideoEncoder> encoder_; | 4010 std::unique_ptr<VideoEncoder> encoder_; |
3908 std::unique_ptr<VideoDecoder> decoder_; | 4011 std::unique_ptr<VideoDecoder> decoder_; |
3909 rtc::CriticalSection crit_; | 4012 rtc::CriticalSection crit_; |
3910 int recorded_frames_ GUARDED_BY(crit_); | 4013 int recorded_frames_ GUARDED_BY(crit_); |
3911 } test(this); | 4014 } test(this); |
3912 | 4015 |
3913 RunBaseTest(&test); | 4016 RunBaseTest(&test); |
3914 } | 4017 } |
3915 | 4018 |
3916 } // namespace webrtc | 4019 } // namespace webrtc |
OLD | NEW |