Chromium Code Reviews

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

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix android CE Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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> 10 #include <algorithm>
(...skipping 2586 matching lines...)
2597 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "InputFramesPerSecond")); 2597 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "InputFramesPerSecond"));
2598 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "SentFramesPerSecond")); 2598 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "SentFramesPerSecond"));
2599 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); 2599 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond"));
2600 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); 2600 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond"));
2601 2601
2602 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); 2602 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs"));
2603 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); 2603 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs"));
2604 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); 2604 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs"));
2605 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); 2605 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs"));
2606 2606
2607 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayInMs")); 2607 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EndToEndDelayInMs"));
2608 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EndToEndDelayMaxInMs"));
2608 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); 2609 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond"));
2609 2610
2610 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EncodeTimeInMs")); 2611 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EncodeTimeInMs"));
2611 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); 2612 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs"));
2612 2613
2613 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "NumberOfPauseEvents")); 2614 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "NumberOfPauseEvents"));
2614 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "PausedTimeInPercent")); 2615 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "PausedTimeInPercent"));
2615 2616
2616 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "BitrateSentInKbps")); 2617 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "BitrateSentInKbps"));
2617 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateReceivedInKbps")); 2618 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateReceivedInKbps"));
(...skipping 19 matching lines...)
2637 2638
2638 int num_red_samples = use_red ? 1 : 0; 2639 int num_red_samples = use_red ? 1 : 0;
2639 EXPECT_EQ(num_red_samples, 2640 EXPECT_EQ(num_red_samples,
2640 metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps")); 2641 metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps"));
2641 EXPECT_EQ(num_red_samples, 2642 EXPECT_EQ(num_red_samples,
2642 metrics::NumSamples("WebRTC.Video.FecBitrateReceivedInKbps")); 2643 metrics::NumSamples("WebRTC.Video.FecBitrateReceivedInKbps"));
2643 EXPECT_EQ(num_red_samples, 2644 EXPECT_EQ(num_red_samples,
2644 metrics::NumSamples("WebRTC.Video.ReceivedFecPacketsInPercent")); 2645 metrics::NumSamples("WebRTC.Video.ReceivedFecPacketsInPercent"));
2645 } 2646 }
2646 2647
2648 TEST_F(EndToEndTest, ContentTypeSwitches) {
2649 class StatsObserver : public test::BaseTest,
2650 public rtc::VideoSinkInterface<VideoFrame> {
2651 public:
2652 StatsObserver() : BaseTest(kLongTimeoutMs), num_frames_received_(0) {}
2653
2654 bool ShouldCreateReceivers() const override { return true; }
2655
2656 void OnFrame(const VideoFrame& video_frame) override {
2657 // The RTT is needed to estimate |ntp_time_ms| which is used by
2658 // end-to-end delay stats. Therefore, start counting received frames once
2659 // |ntp_time_ms| is valid.
2660 if (video_frame.ntp_time_ms() > 0 &&
2661 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() >=
2662 video_frame.ntp_time_ms()) {
2663 rtc::CritScope lock(&crit_);
2664 ++num_frames_received_;
2665 }
2666 }
2667
2668 Action OnSendRtp(const uint8_t* packet, size_t length) override {
2669 if (MinNumberOfFramesReceived())
2670 observation_complete_.Set();
2671 return SEND_PACKET;
2672 }
2673
2674 bool MinNumberOfFramesReceived() const {
2675 const int kMinRequiredHistogramSamples = 200;
2676 rtc::CritScope lock(&crit_);
2677 return num_frames_received_ > kMinRequiredHistogramSamples;
2678 }
2679
2680 // May be called several times.
2681 void PerformTest() override {
2682 EXPECT_TRUE(Wait()) << "Timed out waiting for enough packets.";
2683 // Reset frame counter so next PerformTest() call will do something.
2684 {
2685 rtc::CritScope lock(&crit_);
2686 num_frames_received_ = 0;
2687 }
2688 }
2689
2690 rtc::CriticalSection crit_;
2691 int num_frames_received_ GUARDED_BY(&crit_);
2692 } test;
2693
2694 metrics::Reset();
2695
2696 Call::Config send_config(test.GetSenderCallConfig());
2697 CreateSenderCall(send_config);
2698 Call::Config recv_config(test.GetReceiverCallConfig());
2699 CreateReceiverCall(recv_config);
2700 receive_transport_.reset(test.CreateReceiveTransport());
2701 send_transport_.reset(test.CreateSendTransport(sender_call_.get()));
2702 send_transport_->SetReceiver(receiver_call_->Receiver());
2703 receive_transport_->SetReceiver(sender_call_->Receiver());
2704 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
2705 CreateSendConfig(1, 0, 0, send_transport_.get());
2706 CreateMatchingReceiveConfigs(receive_transport_.get());
2707
2708 // Modify send and receive configs.
2709 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2710 video_receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2711 video_receive_configs_[0].renderer = &test;
2712 // RTT needed for RemoteNtpTimeEstimator for the receive stream.
2713 video_receive_configs_[0].rtp.rtcp_xr.receiver_reference_time_report = true;
2714 // Start with realtime video.
2715 video_encoder_config_.content_type =
2716 VideoEncoderConfig::ContentType::kRealtimeVideo;
2717 // Second encoder config for the second part of the test uses screenshare
2718 VideoEncoderConfig encoder_config_with_screenshare_ =
2719 video_encoder_config_.Copy();
2720 encoder_config_with_screenshare_.content_type =
2721 VideoEncoderConfig::ContentType::kScreen;
2722
2723 CreateVideoStreams();
2724 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth,
2725 kDefaultHeight);
2726 Start();
2727
2728 test.PerformTest();
2729
2730 // Replace old send stream.
2731 sender_call_->DestroyVideoSendStream(video_send_stream_);
2732 video_send_stream_ = sender_call_->CreateVideoSendStream(
2733 video_send_config_.Copy(), encoder_config_with_screenshare_.Copy());
2734 video_send_stream_->SetSource(
2735 frame_generator_capturer_.get(),
2736 VideoSendStream::DegradationPreference::kBalanced);
2737 video_send_stream_->Start();
2738
2739 // Continue to run test but now with screenshare.
2740 test.PerformTest();
2741
2742 send_transport_->StopSending();
2743 receive_transport_->StopSending();
2744 Stop();
2745 DestroyStreams();
2746 DestroyCalls();
2747 // Delete the call for Call stats to be reported.
2748 sender_call_.reset();
2749 receiver_call_.reset();
2750
2751 // Verify that stats have been updated for both screenshare and video.
2752 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayInMs"));
2753 EXPECT_EQ(1,
2754 metrics::NumSamples("WebRTC.Video.Screenshare.EndToEndDelayInMs"));
2755 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayMaxInMs"));
2756 EXPECT_EQ(
2757 1, metrics::NumSamples("WebRTC.Video.Screenshare.EndToEndDelayMaxInMs"));
2758 }
2759
2647 TEST_F(EndToEndTest, VerifyHistogramStatsWithRtx) { 2760 TEST_F(EndToEndTest, VerifyHistogramStatsWithRtx) {
2648 const bool kEnabledRtx = true; 2761 const bool kEnabledRtx = true;
2649 const bool kEnabledRed = false; 2762 const bool kEnabledRed = false;
2650 const bool kScreenshare = false; 2763 const bool kScreenshare = false;
2651 VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); 2764 VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare);
2652 } 2765 }
2653 2766
2654 TEST_F(EndToEndTest, VerifyHistogramStatsWithRed) { 2767 TEST_F(EndToEndTest, VerifyHistogramStatsWithRed) {
2655 const bool kEnabledRtx = false; 2768 const bool kEnabledRtx = false;
2656 const bool kEnabledRed = true; 2769 const bool kEnabledRed = true;
(...skipping 1647 matching lines...)
4304 std::unique_ptr<VideoEncoder> encoder_; 4417 std::unique_ptr<VideoEncoder> encoder_;
4305 std::unique_ptr<VideoDecoder> decoder_; 4418 std::unique_ptr<VideoDecoder> decoder_;
4306 rtc::CriticalSection crit_; 4419 rtc::CriticalSection crit_;
4307 int recorded_frames_ GUARDED_BY(crit_); 4420 int recorded_frames_ GUARDED_BY(crit_);
4308 } test(this); 4421 } test(this);
4309 4422
4310 RunBaseTest(&test); 4423 RunBaseTest(&test);
4311 } 4424 }
4312 4425
4313 } // namespace webrtc 4426 } // namespace webrtc
OLDNEW

Powered by Google App Engine