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 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 EXPECT_EQ( | 2020 EXPECT_EQ( |
2021 1, metrics::NumSamples("WebRTC.Video.UniqueNackRequestsSentInPercent")); | 2021 1, metrics::NumSamples("WebRTC.Video.UniqueNackRequestsSentInPercent")); |
2022 EXPECT_EQ(1, metrics::NumSamples( | 2022 EXPECT_EQ(1, metrics::NumSamples( |
2023 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); | 2023 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); |
2024 EXPECT_GT(metrics::MinSample("WebRTC.Video.NackPacketsSentPerMinute"), 0); | 2024 EXPECT_GT(metrics::MinSample("WebRTC.Video.NackPacketsSentPerMinute"), 0); |
2025 } | 2025 } |
2026 | 2026 |
2027 void EndToEndTest::VerifyHistogramStats(bool use_rtx, | 2027 void EndToEndTest::VerifyHistogramStats(bool use_rtx, |
2028 bool use_red, | 2028 bool use_red, |
2029 bool screenshare) { | 2029 bool screenshare) { |
2030 class StatsObserver : public test::EndToEndTest { | 2030 class StatsObserver : public test::EndToEndTest, |
| 2031 public rtc::VideoSinkInterface<VideoFrame> { |
2031 public: | 2032 public: |
2032 StatsObserver(bool use_rtx, bool use_red, bool screenshare) | 2033 StatsObserver(bool use_rtx, bool use_red, bool screenshare) |
2033 : EndToEndTest(kLongTimeoutMs), | 2034 : EndToEndTest(kLongTimeoutMs), |
2034 use_rtx_(use_rtx), | 2035 use_rtx_(use_rtx), |
2035 use_red_(use_red), | 2036 use_red_(use_red), |
2036 screenshare_(screenshare), | 2037 screenshare_(screenshare), |
2037 // This test uses NACK, so to send FEC we can't use a fake encoder. | 2038 // This test uses NACK, so to send FEC we can't use a fake encoder. |
2038 vp8_encoder_( | 2039 vp8_encoder_( |
2039 use_red ? VideoEncoder::Create(VideoEncoder::EncoderType::kVp8) | 2040 use_red ? VideoEncoder::Create(VideoEncoder::EncoderType::kVp8) |
2040 : nullptr), | 2041 : nullptr), |
2041 sender_call_(nullptr), | 2042 sender_call_(nullptr), |
2042 receiver_call_(nullptr), | 2043 receiver_call_(nullptr), |
2043 start_runtime_ms_(-1) {} | 2044 start_runtime_ms_(-1) {} |
2044 | 2045 |
2045 private: | 2046 private: |
| 2047 void OnFrame(const VideoFrame& video_frame) override {} |
| 2048 |
2046 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 2049 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
2047 if (MinMetricRunTimePassed()) | 2050 if (MinMetricRunTimePassed()) |
2048 observation_complete_.Set(); | 2051 observation_complete_.Set(); |
2049 | 2052 |
2050 return SEND_PACKET; | 2053 return SEND_PACKET; |
2051 } | 2054 } |
2052 | 2055 |
2053 bool MinMetricRunTimePassed() { | 2056 bool MinMetricRunTimePassed() { |
2054 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 2057 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
2055 if (start_runtime_ms_ == -1) { | 2058 if (start_runtime_ms_ == -1) { |
2056 start_runtime_ms_ = now; | 2059 start_runtime_ms_ = now; |
2057 return false; | 2060 return false; |
2058 } | 2061 } |
2059 int64_t elapsed_sec = (now - start_runtime_ms_) / 1000; | 2062 int64_t elapsed_sec = (now - start_runtime_ms_) / 1000; |
2060 return elapsed_sec > metrics::kMinRunTimeInSeconds * 2; | 2063 return elapsed_sec > metrics::kMinRunTimeInSeconds * 2; |
2061 } | 2064 } |
2062 | 2065 |
2063 void ModifyVideoConfigs( | 2066 void ModifyVideoConfigs( |
2064 VideoSendStream::Config* send_config, | 2067 VideoSendStream::Config* send_config, |
2065 std::vector<VideoReceiveStream::Config>* receive_configs, | 2068 std::vector<VideoReceiveStream::Config>* receive_configs, |
2066 VideoEncoderConfig* encoder_config) override { | 2069 VideoEncoderConfig* encoder_config) override { |
2067 // NACK | 2070 // NACK |
2068 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 2071 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
2069 (*receive_configs)[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 2072 (*receive_configs)[0].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 2073 (*receive_configs)[0].renderer = this; |
2070 // FEC | 2074 // FEC |
2071 if (use_red_) { | 2075 if (use_red_) { |
2072 send_config->rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 2076 send_config->rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
2073 send_config->rtp.fec.red_payload_type = kRedPayloadType; | 2077 send_config->rtp.fec.red_payload_type = kRedPayloadType; |
2074 send_config->encoder_settings.encoder = vp8_encoder_.get(); | 2078 send_config->encoder_settings.encoder = vp8_encoder_.get(); |
2075 send_config->encoder_settings.payload_name = "VP8"; | 2079 send_config->encoder_settings.payload_name = "VP8"; |
2076 (*receive_configs)[0].decoders[0].payload_name = "VP8"; | 2080 (*receive_configs)[0].decoders[0].payload_name = "VP8"; |
2077 (*receive_configs)[0].rtp.fec.red_payload_type = kRedPayloadType; | 2081 (*receive_configs)[0].rtp.fec.red_payload_type = kRedPayloadType; |
2078 (*receive_configs)[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 2082 (*receive_configs)[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
2079 } | 2083 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 VideoSendStream* send_stream_; | 2487 VideoSendStream* send_stream_; |
2484 uint32_t bitrate_kbps_ GUARDED_BY(crit_); | 2488 uint32_t bitrate_kbps_ GUARDED_BY(crit_); |
2485 } test; | 2489 } test; |
2486 | 2490 |
2487 RunBaseTest(&test); | 2491 RunBaseTest(&test); |
2488 } | 2492 } |
2489 | 2493 |
2490 TEST_F(EndToEndTest, GetStats) { | 2494 TEST_F(EndToEndTest, GetStats) { |
2491 static const int kStartBitrateBps = 3000000; | 2495 static const int kStartBitrateBps = 3000000; |
2492 static const int kExpectedRenderDelayMs = 20; | 2496 static const int kExpectedRenderDelayMs = 20; |
| 2497 |
| 2498 class ReceiveStreamRenderer : public rtc::VideoSinkInterface<VideoFrame> { |
| 2499 public: |
| 2500 ReceiveStreamRenderer() {} |
| 2501 |
| 2502 private: |
| 2503 void OnFrame(const VideoFrame& video_frame) override {} |
| 2504 }; |
| 2505 |
2493 class StatsObserver : public test::EndToEndTest, | 2506 class StatsObserver : public test::EndToEndTest, |
2494 public rtc::VideoSinkInterface<VideoFrame> { | 2507 public rtc::VideoSinkInterface<VideoFrame> { |
2495 public: | 2508 public: |
2496 StatsObserver() | 2509 StatsObserver() |
2497 : EndToEndTest(kLongTimeoutMs), | 2510 : EndToEndTest(kLongTimeoutMs), |
2498 encoder_(Clock::GetRealTimeClock(), 10), | 2511 encoder_(Clock::GetRealTimeClock(), 10), |
2499 send_stream_(nullptr), | 2512 send_stream_(nullptr), |
2500 expected_send_ssrcs_(), | 2513 expected_send_ssrcs_(), |
2501 check_stats_event_(false, false) {} | 2514 check_stats_event_(false, false) {} |
2502 | 2515 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2683 VideoEncoderConfig* encoder_config) override { | 2696 VideoEncoderConfig* encoder_config) override { |
2684 send_config->pre_encode_callback = this; // Used to inject delay. | 2697 send_config->pre_encode_callback = this; // Used to inject delay. |
2685 expected_cname_ = send_config->rtp.c_name = "SomeCName"; | 2698 expected_cname_ = send_config->rtp.c_name = "SomeCName"; |
2686 | 2699 |
2687 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; | 2700 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; |
2688 for (size_t i = 0; i < ssrcs.size(); ++i) { | 2701 for (size_t i = 0; i < ssrcs.size(); ++i) { |
2689 expected_send_ssrcs_.insert(ssrcs[i]); | 2702 expected_send_ssrcs_.insert(ssrcs[i]); |
2690 expected_receive_ssrcs_.push_back( | 2703 expected_receive_ssrcs_.push_back( |
2691 (*receive_configs)[i].rtp.remote_ssrc); | 2704 (*receive_configs)[i].rtp.remote_ssrc); |
2692 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; | 2705 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; |
| 2706 (*receive_configs)[i].renderer = &receive_stream_renderer_; |
2693 } | 2707 } |
2694 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that | 2708 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that |
2695 // are non-zero. | 2709 // are non-zero. |
2696 send_config->encoder_settings.encoder = &encoder_; | 2710 send_config->encoder_settings.encoder = &encoder_; |
2697 } | 2711 } |
2698 | 2712 |
2699 size_t GetNumVideoStreams() const override { return kNumSsrcs; } | 2713 size_t GetNumVideoStreams() const override { return kNumSsrcs; } |
2700 | 2714 |
2701 void OnVideoStreamsCreated( | 2715 void OnVideoStreamsCreated( |
2702 VideoSendStream* send_stream, | 2716 VideoSendStream* send_stream, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 std::map<std::string, bool> receive_stats_filled_; | 2766 std::map<std::string, bool> receive_stats_filled_; |
2753 | 2767 |
2754 VideoSendStream* send_stream_; | 2768 VideoSendStream* send_stream_; |
2755 std::map<std::string, bool> send_stats_filled_; | 2769 std::map<std::string, bool> send_stats_filled_; |
2756 | 2770 |
2757 std::vector<uint32_t> expected_receive_ssrcs_; | 2771 std::vector<uint32_t> expected_receive_ssrcs_; |
2758 std::set<uint32_t> expected_send_ssrcs_; | 2772 std::set<uint32_t> expected_send_ssrcs_; |
2759 std::string expected_cname_; | 2773 std::string expected_cname_; |
2760 | 2774 |
2761 rtc::Event check_stats_event_; | 2775 rtc::Event check_stats_event_; |
| 2776 ReceiveStreamRenderer receive_stream_renderer_; |
2762 } test; | 2777 } test; |
2763 | 2778 |
2764 RunBaseTest(&test); | 2779 RunBaseTest(&test); |
2765 } | 2780 } |
2766 | 2781 |
2767 TEST_F(EndToEndTest, ReceiverReferenceTimeReportEnabled) { | 2782 TEST_F(EndToEndTest, ReceiverReferenceTimeReportEnabled) { |
2768 TestXrReceiverReferenceTimeReport(true); | 2783 TestXrReceiverReferenceTimeReport(true); |
2769 } | 2784 } |
2770 | 2785 |
2771 TEST_F(EndToEndTest, ReceiverReferenceTimeReportDisabled) { | 2786 TEST_F(EndToEndTest, ReceiverReferenceTimeReportDisabled) { |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3541 private: | 3556 private: |
3542 bool video_observed_; | 3557 bool video_observed_; |
3543 bool audio_observed_; | 3558 bool audio_observed_; |
3544 SequenceNumberUnwrapper unwrapper_; | 3559 SequenceNumberUnwrapper unwrapper_; |
3545 std::set<int64_t> received_packet_ids_; | 3560 std::set<int64_t> received_packet_ids_; |
3546 } test; | 3561 } test; |
3547 | 3562 |
3548 RunBaseTest(&test); | 3563 RunBaseTest(&test); |
3549 } | 3564 } |
3550 } // namespace webrtc | 3565 } // namespace webrtc |
OLD | NEW |