Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2503523003: Add VideoSendStreamTest for FlexFEC. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 uint32_t kHalf24BitsSpace = 0xFFFFFF / 2;
584 if (header.extension.absoluteSendTime <= kHalf24BitsSpace &&
585 prev_header_.extension.absoluteSendTime > kHalf24BitsSpace) {
586 // 24 bits wrap.
587 EXPECT_GT(prev_header_.extension.absoluteSendTime,
588 header.extension.absoluteSendTime);
589 } else {
590 EXPECT_GE(header.extension.absoluteSendTime,
591 prev_header_.extension.absoluteSendTime);
592 }
593 EXPECT_TRUE(header.extension.hasTransportSequenceNumber);
594 uint16_t seq_num_diff = header.extension.transportSequenceNumber -
595 prev_header_.extension.transportSequenceNumber;
596 EXPECT_EQ(1, seq_num_diff);
stefan-webrtc 2016/11/15 12:29:53 Do you think it's necessary to verify that the ext
brandtr 2016/11/15 13:05:39 It's enough to just check that they are set. Also
597 }
598
599 if (send_count_ > 100 && sent_media_ && sent_flexfec_) {
600 observation_complete_.Set();
601 }
602
603 prev_header_ = header;
604
605 return SEND_PACKET;
606 }
607
608 test::PacketTransport* CreateSendTransport(Call* sender_call) override {
609 // At low RTT (< kLowRttNackMs) -> NACK only, no FEC.
610 // Therefore we need some network delay.
611 const int kNetworkDelayMs = 100;
612 FakeNetworkPipe::Config config;
613 config.loss_percent = 50;
614 config.queue_delay_ms = kNetworkDelayMs;
615 return new test::PacketTransport(sender_call, this,
616 test::PacketTransport::kSender, config);
617 }
618
619 void ModifyVideoConfigs(
620 VideoSendStream::Config* send_config,
621 std::vector<VideoReceiveStream::Config>* receive_configs,
622 VideoEncoderConfig* encoder_config) override {
623 transport_adapter_.reset(
624 new internal::TransportAdapter(send_config->send_transport));
625 transport_adapter_->Enable();
626 if (use_nack_) {
627 send_config->rtp.nack.rtp_history_ms =
628 (*receive_configs)[0].rtp.nack.rtp_history_ms =
629 VideoSendStreamTest::kNackRtpHistoryMs;
630 }
631 send_config->encoder_settings.encoder = encoder_.get();
632 send_config->encoder_settings.payload_name = payload_name_;
633 if (header_extensions_enabled_) {
634 send_config->rtp.extensions.push_back(RtpExtension(
635 RtpExtension::kAbsSendTimeUri, test::kAbsSendTimeExtensionId));
636 send_config->rtp.extensions.push_back(
637 RtpExtension(RtpExtension::kTransportSequenceNumberUri,
638 test::kTransportSequenceNumberExtensionId));
639 }
640 }
641
642 void PerformTest() override {
643 EXPECT_TRUE(Wait())
644 << "Timed out waiting for FlexFEC and/or media packets.";
645 }
646
647 std::unique_ptr<internal::TransportAdapter> transport_adapter_;
648 std::unique_ptr<VideoEncoder> encoder_;
649 const std::string payload_name_;
650 const bool use_nack_;
651 int send_count_;
652 bool sent_media_;
653 bool sent_flexfec_;
654 bool header_extensions_enabled_;
655 RTPHeader prev_header_;
656 };
657
658 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsVp8) {
659 FlexfecObserver test(true, false, "VP8");
660 RunBaseTest(&test);
661 }
662
663 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsVp8) {
664 FlexfecObserver test(false, false, "VP8");
665 RunBaseTest(&test);
666 }
667
668 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackVp8) {
669 FlexfecObserver test(true, true, "VP8");
670 RunBaseTest(&test);
671 }
672
673 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackVp8) {
674 FlexfecObserver test(false, true, "VP8");
675 RunBaseTest(&test);
676 }
677
678 #if !defined(RTC_DISABLE_VP9)
679 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsVp9) {
680 FlexfecObserver test(true, false, "VP9");
681 RunBaseTest(&test);
682 }
683
684 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsVp9) {
685 FlexfecObserver test(false, false, "VP9");
686 RunBaseTest(&test);
687 }
688
689 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackVp9) {
690 FlexfecObserver test(true, true, "VP9");
691 RunBaseTest(&test);
692 }
693
694 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackVp9) {
695 FlexfecObserver test(false, true, "VP9");
696 RunBaseTest(&test);
697 }
698 #endif // defined(RTC_DISABLE_VP9)
699
700 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsH264) {
701 FlexfecObserver test(true, false, "H264");
702 RunBaseTest(&test);
703 }
704
705 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsH264) {
706 FlexfecObserver test(false, false, "H264");
707 RunBaseTest(&test);
708 }
709
710 TEST_F(VideoSendStreamTest, SupportsFlexfecWithRtpExtensionsAndNackH264) {
711 FlexfecObserver test(true, true, "H264");
712 RunBaseTest(&test);
713 }
714
715 TEST_F(VideoSendStreamTest, SupportsFlexfecWithoutRtpExtensionsAndNackH264) {
716 FlexfecObserver test(false, true, "H264");
717 RunBaseTest(&test);
718 }
719
538 void VideoSendStreamTest::TestNackRetransmission( 720 void VideoSendStreamTest::TestNackRetransmission(
539 uint32_t retransmit_ssrc, 721 uint32_t retransmit_ssrc,
540 uint8_t retransmit_payload_type) { 722 uint8_t retransmit_payload_type) {
541 class NackObserver : public test::SendTest { 723 class NackObserver : public test::SendTest {
542 public: 724 public:
543 explicit NackObserver(uint32_t retransmit_ssrc, 725 explicit NackObserver(uint32_t retransmit_ssrc,
544 uint8_t retransmit_payload_type) 726 uint8_t retransmit_payload_type)
545 : SendTest(kDefaultTimeoutMs), 727 : SendTest(kDefaultTimeoutMs),
546 send_count_(0), 728 send_count_(0),
547 retransmit_ssrc_(retransmit_ssrc), 729 retransmit_ssrc_(retransmit_ssrc),
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2987 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { 3169 RequestSourceRotateIfVideoOrientationExtensionNotSupported) {
2988 TestRequestSourceRotateVideo(false); 3170 TestRequestSourceRotateVideo(false);
2989 } 3171 }
2990 3172
2991 TEST_F(VideoSendStreamTest, 3173 TEST_F(VideoSendStreamTest,
2992 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { 3174 DoNotRequestsRotationIfVideoOrientationExtensionSupported) {
2993 TestRequestSourceRotateVideo(true); 3175 TestRequestSourceRotateVideo(true);
2994 } 3176 }
2995 3177
2996 } // namespace webrtc 3178 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698