Chromium Code Reviews| 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 | 569 |
| 570 uint32_t local_ssrc_; | 570 uint32_t local_ssrc_; |
| 571 uint32_t remote_ssrc_; | 571 uint32_t remote_ssrc_; |
| 572 Transport* receive_transport_; | 572 Transport* receive_transport_; |
| 573 rtc::Optional<uint16_t> sequence_number_to_retransmit_; | 573 rtc::Optional<uint16_t> sequence_number_to_retransmit_; |
| 574 } test; | 574 } test; |
| 575 | 575 |
| 576 RunBaseTest(&test); | 576 RunBaseTest(&test); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // Disabled due to flakyness, see | 579 TEST_F(EndToEndTest, ReceivesUlpfec) { |
| 580 // https://bugs.chromium.org/p/webrtc/issues/detail?id=7047. | |
| 581 TEST_F(EndToEndTest, DISABLED_ReceivesUlpfec) { | |
| 582 class UlpfecRenderObserver : public test::EndToEndTest, | 580 class UlpfecRenderObserver : public test::EndToEndTest, |
| 583 public rtc::VideoSinkInterface<VideoFrame> { | 581 public rtc::VideoSinkInterface<VideoFrame> { |
| 584 public: | 582 public: |
| 585 UlpfecRenderObserver() | 583 UlpfecRenderObserver() |
| 586 : EndToEndTest(kDefaultTimeoutMs), | 584 : EndToEndTest(kDefaultTimeoutMs), |
| 585 encoder_(VP8Encoder::Create()), | |
| 587 random_(0xcafef00d1), | 586 random_(0xcafef00d1), |
| 588 num_packets_sent_(0) {} | 587 num_packets_sent_(0) {} |
| 589 | 588 |
| 590 private: | 589 private: |
| 591 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 590 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 592 rtc::CritScope lock(&crit_); | 591 rtc::CritScope lock(&crit_); |
| 593 RTPHeader header; | 592 RTPHeader header; |
| 594 EXPECT_TRUE(parser_->Parse(packet, length, &header)); | 593 EXPECT_TRUE(parser_->Parse(packet, length, &header)); |
| 595 | 594 |
| 596 EXPECT_TRUE(header.payloadType == kFakeVideoSendPayloadType || | 595 EXPECT_TRUE(header.payloadType == kVideoSendPayloadType || |
| 597 header.payloadType == kRedPayloadType) | 596 header.payloadType == kRedPayloadType) |
| 598 << "Unknown payload type received."; | 597 << "Unknown payload type received."; |
| 599 EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc) << "Unknown SSRC received."; | 598 EXPECT_EQ(kVideoSendSsrcs[0], header.ssrc) << "Unknown SSRC received."; |
| 600 | 599 |
| 601 // Parse RED header. | 600 // Parse RED header. |
| 602 int encapsulated_payload_type = -1; | 601 int encapsulated_payload_type = -1; |
| 603 if (header.payloadType == kRedPayloadType) { | 602 if (header.payloadType == kRedPayloadType) { |
| 604 encapsulated_payload_type = | 603 encapsulated_payload_type = |
| 605 static_cast<int>(packet[header.headerLength]); | 604 static_cast<int>(packet[header.headerLength]); |
| 606 | 605 |
| 607 EXPECT_TRUE(encapsulated_payload_type == kFakeVideoSendPayloadType || | 606 EXPECT_TRUE(encapsulated_payload_type == kVideoSendPayloadType || |
| 608 encapsulated_payload_type == kUlpfecPayloadType) | 607 encapsulated_payload_type == kUlpfecPayloadType) |
| 609 << "Unknown encapsulated payload type received."; | 608 << "Unknown encapsulated payload type received."; |
| 610 } | 609 } |
| 611 | 610 |
| 612 // To reduce test flakiness, always let ULPFEC packets through. | 611 // To minimize test flakiness, always let ULPFEC packets through. |
| 613 if (encapsulated_payload_type == kUlpfecPayloadType) { | 612 if (encapsulated_payload_type == kUlpfecPayloadType) { |
| 614 return SEND_PACKET; | 613 return SEND_PACKET; |
| 615 } | 614 } |
| 616 | 615 |
| 617 // Simulate 5% video packet loss after rampup period. Record the | 616 // Simulate 5% video packet loss after rampup period. Record the |
| 618 // corresponding timestamps that were dropped. | 617 // corresponding timestamps that were dropped. |
| 619 if (num_packets_sent_++ > 100 && random_.Rand(1, 100) <= 5) { | 618 if (num_packets_sent_++ > 100 && random_.Rand(1, 100) <= 5) { |
| 620 if (encapsulated_payload_type == kFakeVideoSendPayloadType) { | 619 if (encapsulated_payload_type == kVideoSendPayloadType) { |
| 621 dropped_sequence_numbers_.insert(header.sequenceNumber); | 620 dropped_sequence_numbers_.insert(header.sequenceNumber); |
| 622 dropped_timestamps_.insert(header.timestamp); | 621 dropped_timestamps_.insert(header.timestamp); |
| 623 } | 622 } |
| 624 | |
| 625 return DROP_PACKET; | 623 return DROP_PACKET; |
| 626 } | 624 } |
| 627 | 625 |
| 628 return SEND_PACKET; | 626 return SEND_PACKET; |
| 629 } | 627 } |
| 630 | 628 |
| 631 void OnFrame(const VideoFrame& video_frame) override { | 629 void OnFrame(const VideoFrame& video_frame) override { |
| 632 rtc::CritScope lock(&crit_); | 630 rtc::CritScope lock(&crit_); |
| 633 // Rendering frame with timestamp of packet that was dropped -> FEC | 631 // Rendering frame with timestamp of packet that was dropped -> FEC |
| 634 // protection worked. | 632 // protection worked. |
| 635 auto it = dropped_timestamps_.find(video_frame.timestamp()); | 633 auto it = dropped_timestamps_.find(video_frame.timestamp()); |
| 636 if (it != dropped_timestamps_.end()) { | 634 if (it != dropped_timestamps_.end()) { |
| 637 observation_complete_.Set(); | 635 observation_complete_.Set(); |
| 638 } | 636 } |
| 639 } | 637 } |
| 640 | 638 |
| 641 void ModifyVideoConfigs( | 639 void ModifyVideoConfigs( |
| 642 VideoSendStream::Config* send_config, | 640 VideoSendStream::Config* send_config, |
| 643 std::vector<VideoReceiveStream::Config>* receive_configs, | 641 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 644 VideoEncoderConfig* encoder_config) override { | 642 VideoEncoderConfig* encoder_config) override { |
| 645 send_config->rtp.extensions.push_back( | 643 // Use VP8 instead of FAKE, since the latter does not have PictureID |
| 646 RtpExtension(RtpExtension::kTransportSequenceNumberUri, | 644 // in the packetization headers. |
|
philipel
2017/03/20 12:09:07
I can't see why picture id matters in the case of
brandtr_google
2017/03/20 12:12:09
I believe it has something to do with key frame re
brandtr_google
2017/03/20 12:14:14
I guess the main point is that switching to VP8 se
| |
| 647 test::kTransportSequenceNumberExtensionId)); | 645 send_config->encoder_settings.encoder = encoder_.get(); |
| 646 send_config->encoder_settings.payload_name = "VP8"; | |
| 647 send_config->encoder_settings.payload_type = kVideoSendPayloadType; | |
| 648 VideoReceiveStream::Decoder decoder = | |
| 649 test::CreateMatchingDecoder(send_config->encoder_settings); | |
| 650 decoder_.reset(decoder.decoder); | |
| 651 (*receive_configs)[0].decoders.clear(); | |
| 652 (*receive_configs)[0].decoders.push_back(decoder); | |
| 653 | |
| 654 // Enable ULPFEC over RED. | |
| 648 send_config->rtp.ulpfec.red_payload_type = kRedPayloadType; | 655 send_config->rtp.ulpfec.red_payload_type = kRedPayloadType; |
| 649 send_config->rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; | 656 send_config->rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; |
| 650 | |
| 651 (*receive_configs)[0].rtp.transport_cc = true; | |
| 652 (*receive_configs)[0].rtp.ulpfec.red_payload_type = kRedPayloadType; | 657 (*receive_configs)[0].rtp.ulpfec.red_payload_type = kRedPayloadType; |
| 653 (*receive_configs)[0].rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; | 658 (*receive_configs)[0].rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType; |
| 659 | |
| 654 (*receive_configs)[0].renderer = this; | 660 (*receive_configs)[0].renderer = this; |
| 655 } | 661 } |
| 656 | 662 |
| 657 void PerformTest() override { | 663 void PerformTest() override { |
| 658 EXPECT_TRUE(Wait()) | 664 EXPECT_TRUE(Wait()) |
| 659 << "Timed out waiting for dropped frames to be rendered."; | 665 << "Timed out waiting for dropped frames to be rendered."; |
| 660 } | 666 } |
| 661 | 667 |
| 662 rtc::CriticalSection crit_; | 668 rtc::CriticalSection crit_; |
| 669 std::unique_ptr<VideoEncoder> encoder_; | |
| 670 std::unique_ptr<VideoDecoder> decoder_; | |
| 663 std::set<uint32_t> dropped_sequence_numbers_ GUARDED_BY(crit_); | 671 std::set<uint32_t> dropped_sequence_numbers_ GUARDED_BY(crit_); |
| 664 // Several packets can have the same timestamp. | 672 // Several packets can have the same timestamp. |
| 665 std::multiset<uint32_t> dropped_timestamps_ GUARDED_BY(crit_); | 673 std::multiset<uint32_t> dropped_timestamps_ GUARDED_BY(crit_); |
| 666 Random random_; | 674 Random random_; |
| 667 int num_packets_sent_; | 675 int num_packets_sent_ GUARDED_BY(crit_); |
| 668 } test; | 676 } test; |
| 669 | 677 |
| 670 RunBaseTest(&test); | 678 RunBaseTest(&test); |
| 671 } | 679 } |
| 672 | 680 |
| 673 class FlexfecRenderObserver : public test::EndToEndTest, | 681 class FlexfecRenderObserver : public test::EndToEndTest, |
| 674 public rtc::VideoSinkInterface<VideoFrame> { | 682 public rtc::VideoSinkInterface<VideoFrame> { |
| 675 public: | 683 public: |
| 676 static constexpr uint32_t kVideoLocalSsrc = 123; | 684 static constexpr uint32_t kVideoLocalSsrc = 123; |
| 677 static constexpr uint32_t kFlexfecLocalSsrc = 456; | 685 static constexpr uint32_t kFlexfecLocalSsrc = 456; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 if (!expect_flexfec_rtcp_ || received_flexfec_rtcp_) { | 794 if (!expect_flexfec_rtcp_ || received_flexfec_rtcp_) { |
| 787 observation_complete_.Set(); | 795 observation_complete_.Set(); |
| 788 } | 796 } |
| 789 } | 797 } |
| 790 } | 798 } |
| 791 | 799 |
| 792 void ModifyVideoConfigs( | 800 void ModifyVideoConfigs( |
| 793 VideoSendStream::Config* send_config, | 801 VideoSendStream::Config* send_config, |
| 794 std::vector<VideoReceiveStream::Config>* receive_configs, | 802 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 795 VideoEncoderConfig* encoder_config) override { | 803 VideoEncoderConfig* encoder_config) override { |
| 796 send_config->rtp.extensions.push_back( | |
| 797 RtpExtension(RtpExtension::kTransportSequenceNumberUri, | |
| 798 test::kTransportSequenceNumberExtensionId)); | |
| 799 | |
| 800 (*receive_configs)[0].rtp.local_ssrc = kVideoLocalSsrc; | 804 (*receive_configs)[0].rtp.local_ssrc = kVideoLocalSsrc; |
| 801 (*receive_configs)[0].rtp.transport_cc = true; | |
| 802 (*receive_configs)[0].renderer = this; | 805 (*receive_configs)[0].renderer = this; |
| 803 | 806 |
| 804 if (enable_nack_) { | 807 if (enable_nack_) { |
| 805 send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs; | 808 send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs; |
| 806 send_config->rtp.ulpfec.red_rtx_payload_type = | 809 send_config->rtp.ulpfec.red_rtx_payload_type = |
| 807 test::CallTest::kRtxRedPayloadType; | 810 test::CallTest::kRtxRedPayloadType; |
| 808 send_config->rtp.rtx.ssrcs.push_back(test::CallTest::kSendRtxSsrcs[0]); | 811 send_config->rtp.rtx.ssrcs.push_back(test::CallTest::kSendRtxSsrcs[0]); |
| 809 send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType; | 812 send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType; |
| 810 | 813 |
| 811 (*receive_configs)[0].rtp.nack.rtp_history_ms = | 814 (*receive_configs)[0].rtp.nack.rtp_history_ms = |
| (...skipping 3368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4180 std::unique_ptr<VideoEncoder> encoder_; | 4183 std::unique_ptr<VideoEncoder> encoder_; |
| 4181 std::unique_ptr<VideoDecoder> decoder_; | 4184 std::unique_ptr<VideoDecoder> decoder_; |
| 4182 rtc::CriticalSection crit_; | 4185 rtc::CriticalSection crit_; |
| 4183 int recorded_frames_ GUARDED_BY(crit_); | 4186 int recorded_frames_ GUARDED_BY(crit_); |
| 4184 } test(this); | 4187 } test(this); |
| 4185 | 4188 |
| 4186 RunBaseTest(&test); | 4189 RunBaseTest(&test); |
| 4187 } | 4190 } |
| 4188 | 4191 |
| 4189 } // namespace webrtc | 4192 } // namespace webrtc |
| OLD | NEW |