| 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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 bool has_last_sequence_number_; | 695 bool has_last_sequence_number_; |
| 696 uint16_t last_sequence_number_; | 696 uint16_t last_sequence_number_; |
| 697 } test; | 697 } test; |
| 698 | 698 |
| 699 RunBaseTest(&test); | 699 RunBaseTest(&test); |
| 700 } | 700 } |
| 701 | 701 |
| 702 // This test drops second RTP packet with a marker bit set, makes sure it's | 702 // This test drops second RTP packet with a marker bit set, makes sure it's |
| 703 // retransmitted and renders. Retransmission SSRCs are also checked. | 703 // retransmitted and renders. Retransmission SSRCs are also checked. |
| 704 void EndToEndTest::DecodesRetransmittedFrame(bool enable_rtx, bool enable_red) { | 704 void EndToEndTest::DecodesRetransmittedFrame(bool enable_rtx, bool enable_red) { |
| 705 // Must be set high enough to allow the bitrate probing to finish. | 705 static const int kDroppedFrameNumber = 10; |
| 706 static const int kMinProbePackets = 100; | |
| 707 static const int kDroppedFrameNumber = kMinProbePackets + 1; | |
| 708 class RetransmissionObserver : public test::EndToEndTest, | 706 class RetransmissionObserver : public test::EndToEndTest, |
| 709 public I420FrameCallback { | 707 public I420FrameCallback { |
| 710 public: | 708 public: |
| 711 RetransmissionObserver(bool enable_rtx, bool enable_red) | 709 RetransmissionObserver(bool enable_rtx, bool enable_red) |
| 712 : EndToEndTest(kDefaultTimeoutMs), | 710 : EndToEndTest(kDefaultTimeoutMs), |
| 713 payload_type_(GetPayloadType(false, enable_red)), | 711 payload_type_(GetPayloadType(false, enable_red)), |
| 714 retransmission_ssrc_(enable_rtx ? kSendRtxSsrcs[0] | 712 retransmission_ssrc_(enable_rtx ? kSendRtxSsrcs[0] |
| 715 : kVideoSendSsrcs[0]), | 713 : kVideoSendSsrcs[0]), |
| 716 retransmission_payload_type_(GetPayloadType(enable_rtx, enable_red)), | 714 retransmission_payload_type_(GetPayloadType(enable_rtx, enable_red)), |
| 717 encoder_(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)), | 715 encoder_(VideoEncoder::Create(VideoEncoder::EncoderType::kVp8)), |
| 718 marker_bits_observed_(0), | 716 marker_bits_observed_(0), |
| 719 num_packets_observed_(0), | |
| 720 retransmitted_timestamp_(0), | 717 retransmitted_timestamp_(0), |
| 721 frame_retransmitted_(false) {} | 718 frame_retransmitted_(false) {} |
| 722 | 719 |
| 723 private: | 720 private: |
| 724 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 721 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 725 rtc::CritScope lock(&crit_); | 722 rtc::CritScope lock(&crit_); |
| 726 RTPHeader header; | 723 RTPHeader header; |
| 727 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | 724 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 728 | 725 |
| 729 // We accept some padding or RTX packets in the beginning to enable | 726 // Ignore padding-only packets over RTX. |
| 730 // bitrate probing. | 727 if (header.payloadType != payload_type_) { |
| 731 if (num_packets_observed_++ < kMinProbePackets && | 728 EXPECT_EQ(retransmission_ssrc_, header.ssrc); |
| 732 header.payloadType != payload_type_) { | 729 if (length == header.headerLength + header.paddingLength) |
| 733 EXPECT_TRUE(retransmission_payload_type_ == header.payloadType || | 730 return SEND_PACKET; |
| 734 length == header.headerLength + header.paddingLength); | |
| 735 return SEND_PACKET; | |
| 736 } | 731 } |
| 732 |
| 737 if (header.timestamp == retransmitted_timestamp_) { | 733 if (header.timestamp == retransmitted_timestamp_) { |
| 738 EXPECT_EQ(retransmission_ssrc_, header.ssrc); | 734 EXPECT_EQ(retransmission_ssrc_, header.ssrc); |
| 739 EXPECT_EQ(retransmission_payload_type_, header.payloadType); | 735 EXPECT_EQ(retransmission_payload_type_, header.payloadType); |
| 740 frame_retransmitted_ = true; | 736 frame_retransmitted_ = true; |
| 741 return SEND_PACKET; | 737 return SEND_PACKET; |
| 742 } | 738 } |
| 743 | 739 |
| 744 EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc) | 740 EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc) |
| 745 << "Payload type " << static_cast<int>(header.payloadType) | 741 << "Payload type " << static_cast<int>(header.payloadType) |
| 746 << " not expected."; | 742 << " not expected."; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 return kFakeVideoSendPayloadType; | 812 return kFakeVideoSendPayloadType; |
| 817 } | 813 } |
| 818 | 814 |
| 819 rtc::CriticalSection crit_; | 815 rtc::CriticalSection crit_; |
| 820 const int payload_type_; | 816 const int payload_type_; |
| 821 const uint32_t retransmission_ssrc_; | 817 const uint32_t retransmission_ssrc_; |
| 822 const int retransmission_payload_type_; | 818 const int retransmission_payload_type_; |
| 823 rtc::scoped_ptr<VideoEncoder> encoder_; | 819 rtc::scoped_ptr<VideoEncoder> encoder_; |
| 824 const std::string payload_name_; | 820 const std::string payload_name_; |
| 825 int marker_bits_observed_; | 821 int marker_bits_observed_; |
| 826 int num_packets_observed_; | |
| 827 uint32_t retransmitted_timestamp_ GUARDED_BY(&crit_); | 822 uint32_t retransmitted_timestamp_ GUARDED_BY(&crit_); |
| 828 bool frame_retransmitted_; | 823 bool frame_retransmitted_; |
| 829 } test(enable_rtx, enable_red); | 824 } test(enable_rtx, enable_red); |
| 830 | 825 |
| 831 RunBaseTest(&test); | 826 RunBaseTest(&test); |
| 832 } | 827 } |
| 833 | 828 |
| 834 TEST_F(EndToEndTest, DecodesRetransmittedFrame) { | 829 TEST_F(EndToEndTest, DecodesRetransmittedFrame) { |
| 835 DecodesRetransmittedFrame(false, false); | 830 DecodesRetransmittedFrame(false, false); |
| 836 } | 831 } |
| (...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 private: | 3532 private: |
| 3538 bool video_observed_; | 3533 bool video_observed_; |
| 3539 bool audio_observed_; | 3534 bool audio_observed_; |
| 3540 SequenceNumberUnwrapper unwrapper_; | 3535 SequenceNumberUnwrapper unwrapper_; |
| 3541 std::set<int64_t> received_packet_ids_; | 3536 std::set<int64_t> received_packet_ids_; |
| 3542 } test; | 3537 } test; |
| 3543 | 3538 |
| 3544 RunBaseTest(&test); | 3539 RunBaseTest(&test); |
| 3545 } | 3540 } |
| 3546 } // namespace webrtc | 3541 } // namespace webrtc |
| OLD | NEW |