| 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 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "InputFramesPerSecond")); | 2636 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "InputFramesPerSecond")); |
| 2637 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "SentFramesPerSecond")); | 2637 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "SentFramesPerSecond")); |
| 2638 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); | 2638 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); |
| 2639 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); | 2639 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); |
| 2640 | 2640 |
| 2641 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); | 2641 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); |
| 2642 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); | 2642 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); |
| 2643 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); | 2643 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); |
| 2644 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); | 2644 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); |
| 2645 | 2645 |
| 2646 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EndToEndDelayInMs")); | 2646 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayInMs")); |
| 2647 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EndToEndDelayMaxInMs")); | |
| 2648 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); | 2647 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); |
| 2649 | 2648 |
| 2650 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EncodeTimeInMs")); | 2649 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "EncodeTimeInMs")); |
| 2651 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); | 2650 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); |
| 2652 | 2651 |
| 2653 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "NumberOfPauseEvents")); | 2652 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "NumberOfPauseEvents")); |
| 2654 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "PausedTimeInPercent")); | 2653 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "PausedTimeInPercent")); |
| 2655 | 2654 |
| 2656 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "BitrateSentInKbps")); | 2655 EXPECT_EQ(1, metrics::NumSamples(video_prefix + "BitrateSentInKbps")); |
| 2657 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateReceivedInKbps")); | 2656 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateReceivedInKbps")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2677 | 2676 |
| 2678 int num_red_samples = use_red ? 1 : 0; | 2677 int num_red_samples = use_red ? 1 : 0; |
| 2679 EXPECT_EQ(num_red_samples, | 2678 EXPECT_EQ(num_red_samples, |
| 2680 metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps")); | 2679 metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps")); |
| 2681 EXPECT_EQ(num_red_samples, | 2680 EXPECT_EQ(num_red_samples, |
| 2682 metrics::NumSamples("WebRTC.Video.FecBitrateReceivedInKbps")); | 2681 metrics::NumSamples("WebRTC.Video.FecBitrateReceivedInKbps")); |
| 2683 EXPECT_EQ(num_red_samples, | 2682 EXPECT_EQ(num_red_samples, |
| 2684 metrics::NumSamples("WebRTC.Video.ReceivedFecPacketsInPercent")); | 2683 metrics::NumSamples("WebRTC.Video.ReceivedFecPacketsInPercent")); |
| 2685 } | 2684 } |
| 2686 | 2685 |
| 2687 TEST_F(EndToEndTest, ContentTypeSwitches) { | |
| 2688 class StatsObserver : public test::BaseTest, | |
| 2689 public rtc::VideoSinkInterface<VideoFrame> { | |
| 2690 public: | |
| 2691 StatsObserver() : BaseTest(kLongTimeoutMs), num_frames_received_(0) {} | |
| 2692 | |
| 2693 bool ShouldCreateReceivers() const override { return true; } | |
| 2694 | |
| 2695 void OnFrame(const VideoFrame& video_frame) override { | |
| 2696 // The RTT is needed to estimate |ntp_time_ms| which is used by | |
| 2697 // end-to-end delay stats. Therefore, start counting received frames once | |
| 2698 // |ntp_time_ms| is valid. | |
| 2699 if (video_frame.ntp_time_ms() > 0 && | |
| 2700 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() >= | |
| 2701 video_frame.ntp_time_ms()) { | |
| 2702 rtc::CritScope lock(&crit_); | |
| 2703 ++num_frames_received_; | |
| 2704 } | |
| 2705 } | |
| 2706 | |
| 2707 Action OnSendRtp(const uint8_t* packet, size_t length) override { | |
| 2708 if (MinNumberOfFramesReceived()) | |
| 2709 observation_complete_.Set(); | |
| 2710 return SEND_PACKET; | |
| 2711 } | |
| 2712 | |
| 2713 bool MinNumberOfFramesReceived() const { | |
| 2714 const int kMinRequiredHistogramSamples = 200; | |
| 2715 rtc::CritScope lock(&crit_); | |
| 2716 return num_frames_received_ > kMinRequiredHistogramSamples; | |
| 2717 } | |
| 2718 | |
| 2719 // May be called several times. | |
| 2720 void PerformTest() override { | |
| 2721 EXPECT_TRUE(Wait()) << "Timed out waiting for enough packets."; | |
| 2722 // Reset frame counter so next PerformTest() call will do something. | |
| 2723 { | |
| 2724 rtc::CritScope lock(&crit_); | |
| 2725 num_frames_received_ = 0; | |
| 2726 } | |
| 2727 } | |
| 2728 | |
| 2729 rtc::CriticalSection crit_; | |
| 2730 int num_frames_received_ GUARDED_BY(&crit_); | |
| 2731 } test; | |
| 2732 | |
| 2733 metrics::Reset(); | |
| 2734 | |
| 2735 Call::Config send_config(test.GetSenderCallConfig()); | |
| 2736 CreateSenderCall(send_config); | |
| 2737 Call::Config recv_config(test.GetReceiverCallConfig()); | |
| 2738 CreateReceiverCall(recv_config); | |
| 2739 receive_transport_.reset(test.CreateReceiveTransport()); | |
| 2740 send_transport_.reset(test.CreateSendTransport(sender_call_.get())); | |
| 2741 send_transport_->SetReceiver(receiver_call_->Receiver()); | |
| 2742 receive_transport_->SetReceiver(sender_call_->Receiver()); | |
| 2743 receiver_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); | |
| 2744 CreateSendConfig(1, 0, 0, send_transport_.get()); | |
| 2745 CreateMatchingReceiveConfigs(receive_transport_.get()); | |
| 2746 | |
| 2747 // Modify send and receive configs. | |
| 2748 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
| 2749 video_receive_configs_[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
| 2750 video_receive_configs_[0].renderer = &test; | |
| 2751 // RTT needed for RemoteNtpTimeEstimator for the receive stream. | |
| 2752 video_receive_configs_[0].rtp.rtcp_xr.receiver_reference_time_report = true; | |
| 2753 // Start with realtime video. | |
| 2754 video_encoder_config_.content_type = | |
| 2755 VideoEncoderConfig::ContentType::kRealtimeVideo; | |
| 2756 // Second encoder config for the second part of the test uses screenshare | |
| 2757 VideoEncoderConfig encoder_config_with_screenshare_ = | |
| 2758 video_encoder_config_.Copy(); | |
| 2759 encoder_config_with_screenshare_.content_type = | |
| 2760 VideoEncoderConfig::ContentType::kScreen; | |
| 2761 | |
| 2762 CreateVideoStreams(); | |
| 2763 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, | |
| 2764 kDefaultHeight); | |
| 2765 Start(); | |
| 2766 | |
| 2767 test.PerformTest(); | |
| 2768 | |
| 2769 // Replace old send stream. | |
| 2770 sender_call_->DestroyVideoSendStream(video_send_stream_); | |
| 2771 video_send_stream_ = sender_call_->CreateVideoSendStream( | |
| 2772 video_send_config_.Copy(), encoder_config_with_screenshare_.Copy()); | |
| 2773 video_send_stream_->SetSource( | |
| 2774 frame_generator_capturer_.get(), | |
| 2775 VideoSendStream::DegradationPreference::kBalanced); | |
| 2776 video_send_stream_->Start(); | |
| 2777 | |
| 2778 // Continue to run test but now with screenshare. | |
| 2779 test.PerformTest(); | |
| 2780 | |
| 2781 send_transport_->StopSending(); | |
| 2782 receive_transport_->StopSending(); | |
| 2783 Stop(); | |
| 2784 DestroyStreams(); | |
| 2785 DestroyCalls(); | |
| 2786 // Delete the call for Call stats to be reported. | |
| 2787 sender_call_.reset(); | |
| 2788 receiver_call_.reset(); | |
| 2789 | |
| 2790 // Verify that stats have been updated for both screenshare and video. | |
| 2791 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayInMs")); | |
| 2792 EXPECT_EQ(1, | |
| 2793 metrics::NumSamples("WebRTC.Video.Screenshare.EndToEndDelayInMs")); | |
| 2794 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.EndToEndDelayMaxInMs")); | |
| 2795 EXPECT_EQ( | |
| 2796 1, metrics::NumSamples("WebRTC.Video.Screenshare.EndToEndDelayMaxInMs")); | |
| 2797 } | |
| 2798 | |
| 2799 TEST_F(EndToEndTest, VerifyHistogramStatsWithRtx) { | 2686 TEST_F(EndToEndTest, VerifyHistogramStatsWithRtx) { |
| 2800 const bool kEnabledRtx = true; | 2687 const bool kEnabledRtx = true; |
| 2801 const bool kEnabledRed = false; | 2688 const bool kEnabledRed = false; |
| 2802 const bool kScreenshare = false; | 2689 const bool kScreenshare = false; |
| 2803 VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); | 2690 VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); |
| 2804 } | 2691 } |
| 2805 | 2692 |
| 2806 TEST_F(EndToEndTest, VerifyHistogramStatsWithRed) { | 2693 TEST_F(EndToEndTest, VerifyHistogramStatsWithRed) { |
| 2807 const bool kEnabledRtx = false; | 2694 const bool kEnabledRtx = false; |
| 2808 const bool kEnabledRed = true; | 2695 const bool kEnabledRed = true; |
| (...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4456 std::unique_ptr<VideoEncoder> encoder_; | 4343 std::unique_ptr<VideoEncoder> encoder_; |
| 4457 std::unique_ptr<VideoDecoder> decoder_; | 4344 std::unique_ptr<VideoDecoder> decoder_; |
| 4458 rtc::CriticalSection crit_; | 4345 rtc::CriticalSection crit_; |
| 4459 int recorded_frames_ GUARDED_BY(crit_); | 4346 int recorded_frames_ GUARDED_BY(crit_); |
| 4460 } test(this); | 4347 } test(this); |
| 4461 | 4348 |
| 4462 RunBaseTest(&test); | 4349 RunBaseTest(&test); |
| 4463 } | 4350 } |
| 4464 | 4351 |
| 4465 } // namespace webrtc | 4352 } // namespace webrtc |
| OLD | NEW |