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> |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 #include <memory> | 13 #include <memory> |
14 #include <sstream> | 14 #include <sstream> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/event.h" | 21 #include "webrtc/base/event.h" |
22 #include "webrtc/call.h" | 22 #include "webrtc/call.h" |
23 #include "webrtc/call/transport_adapter.h" | 23 #include "webrtc/call/transport_adapter.h" |
24 #include "webrtc/common_video/include/frame_callback.h" | 24 #include "webrtc/common_video/include/frame_callback.h" |
25 #include "webrtc/modules/include/module_common_types.h" | 25 #include "webrtc/modules/include/module_common_types.h" |
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | |
30 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 31 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
33 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 32 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
34 #include "webrtc/system_wrappers/include/metrics.h" | 33 #include "webrtc/system_wrappers/include/metrics.h" |
35 #include "webrtc/system_wrappers/include/metrics_default.h" | 34 #include "webrtc/system_wrappers/include/metrics_default.h" |
36 #include "webrtc/system_wrappers/include/sleep.h" | 35 #include "webrtc/system_wrappers/include/sleep.h" |
37 #include "webrtc/test/call_test.h" | 36 #include "webrtc/test/call_test.h" |
38 #include "webrtc/test/direct_transport.h" | 37 #include "webrtc/test/direct_transport.h" |
39 #include "webrtc/test/encoder_settings.h" | 38 #include "webrtc/test/encoder_settings.h" |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 } | 1520 } |
1522 | 1521 |
1523 class TransportFeedbackTester : public test::EndToEndTest { | 1522 class TransportFeedbackTester : public test::EndToEndTest { |
1524 public: | 1523 public: |
1525 explicit TransportFeedbackTester(bool feedback_enabled, | 1524 explicit TransportFeedbackTester(bool feedback_enabled, |
1526 size_t num_video_streams, | 1525 size_t num_video_streams, |
1527 size_t num_audio_streams) | 1526 size_t num_audio_streams) |
1528 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), | 1527 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), |
1529 feedback_enabled_(feedback_enabled), | 1528 feedback_enabled_(feedback_enabled), |
1530 num_video_streams_(num_video_streams), | 1529 num_video_streams_(num_video_streams), |
1531 num_audio_streams_(num_audio_streams), | 1530 num_audio_streams_(num_audio_streams) { |
1532 receiver_call_(nullptr) { | |
1533 // Only one stream of each supported for now. | 1531 // Only one stream of each supported for now. |
1534 EXPECT_LE(num_video_streams, 1u); | 1532 EXPECT_LE(num_video_streams, 1u); |
1535 EXPECT_LE(num_audio_streams, 1u); | 1533 EXPECT_LE(num_audio_streams, 1u); |
1536 } | 1534 } |
1537 | 1535 |
1538 protected: | 1536 protected: |
1539 Action OnSendRtcp(const uint8_t* data, size_t length) override { | 1537 Action OnSendRtcp(const uint8_t* data, size_t length) override { |
1540 EXPECT_FALSE(HasTransportFeedback(data, length)); | 1538 EXPECT_FALSE(HasTransportFeedback(data, length)); |
1541 return SEND_PACKET; | 1539 return SEND_PACKET; |
1542 } | 1540 } |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 public: | 2532 public: |
2535 StatsObserver() | 2533 StatsObserver() |
2536 : EndToEndTest(kLongTimeoutMs), | 2534 : EndToEndTest(kLongTimeoutMs), |
2537 encoder_(Clock::GetRealTimeClock(), 10), | 2535 encoder_(Clock::GetRealTimeClock(), 10), |
2538 send_stream_(nullptr), | 2536 send_stream_(nullptr), |
2539 expected_send_ssrcs_(), | 2537 expected_send_ssrcs_(), |
2540 check_stats_event_(false, false) {} | 2538 check_stats_event_(false, false) {} |
2541 | 2539 |
2542 private: | 2540 private: |
2543 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 2541 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
2544 // Drop every 25th packet => 4% loss. | |
2545 static const int kPacketLossFrac = 25; | |
2546 RTPHeader header; | |
2547 RtpUtility::RtpHeaderParser parser(packet, length); | |
2548 if (parser.Parse(&header) && | |
2549 expected_send_ssrcs_.find(header.ssrc) != | |
2550 expected_send_ssrcs_.end() && | |
2551 header.sequenceNumber % kPacketLossFrac == 0) { | |
2552 return DROP_PACKET; | |
2553 } | |
2554 check_stats_event_.Set(); | 2542 check_stats_event_.Set(); |
2555 return SEND_PACKET; | 2543 return SEND_PACKET; |
2556 } | 2544 } |
2557 | 2545 |
2558 Action OnSendRtcp(const uint8_t* packet, size_t length) override { | 2546 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
2559 check_stats_event_.Set(); | 2547 check_stats_event_.Set(); |
2560 return SEND_PACKET; | 2548 return SEND_PACKET; |
2561 } | 2549 } |
2562 | 2550 |
2563 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { | 2551 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 send_stats_filled_["CpuOveruseMetrics"] |= | 2632 send_stats_filled_["CpuOveruseMetrics"] |= |
2645 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; | 2633 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; |
2646 | 2634 |
2647 send_stats_filled_["EncoderImplementationName"] |= | 2635 send_stats_filled_["EncoderImplementationName"] |= |
2648 stats.encoder_implementation_name == | 2636 stats.encoder_implementation_name == |
2649 test::FakeEncoder::kImplementationName; | 2637 test::FakeEncoder::kImplementationName; |
2650 | 2638 |
2651 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = | 2639 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = |
2652 stats.substreams.begin(); | 2640 stats.substreams.begin(); |
2653 it != stats.substreams.end(); ++it) { | 2641 it != stats.substreams.end(); ++it) { |
2654 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end()) | 2642 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != |
2655 continue; // Probably RTX. | 2643 expected_send_ssrcs_.end()); |
2656 | 2644 |
2657 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= | 2645 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= |
2658 stats.input_frame_rate != 0; | 2646 stats.input_frame_rate != 0; |
2659 | 2647 |
2660 const VideoSendStream::StreamStats& stream_stats = it->second; | 2648 const VideoSendStream::StreamStats& stream_stats = it->second; |
2661 | 2649 |
2662 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= | 2650 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= |
2663 stream_stats.rtcp_stats.cumulative_lost != 0 || | 2651 stream_stats.rtcp_stats.cumulative_lost != 0 || |
2664 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || | 2652 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || |
2665 stream_stats.rtcp_stats.fraction_lost != 0; | 2653 stream_stats.rtcp_stats.fraction_lost != 0; |
2666 | 2654 |
2667 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= | 2655 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= |
2668 stream_stats.rtp_stats.fec.packets != 0 || | 2656 stream_stats.rtp_stats.fec.packets != 0 || |
2669 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || | 2657 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || |
2670 stream_stats.rtp_stats.retransmitted.packets != 0 || | 2658 stream_stats.rtp_stats.retransmitted.packets != 0 || |
2671 stream_stats.rtp_stats.transmitted.packets != 0; | 2659 stream_stats.rtp_stats.transmitted.packets != 0; |
2672 | 2660 |
2673 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total", | 2661 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", |
2674 it->first)] |= | 2662 it->first)] |= |
2675 stream_stats.total_bitrate_bps != 0; | 2663 stream_stats.total_bitrate_bps != 0; |
2676 | 2664 |
2677 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit", | |
2678 it->first)] |= | |
2679 stream_stats.retransmit_bitrate_bps != 0; | |
2680 | |
2681 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= | 2665 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= |
2682 stream_stats.frame_counts.delta_frames != 0 || | 2666 stream_stats.frame_counts.delta_frames != 0 || |
2683 stream_stats.frame_counts.key_frames != 0; | 2667 stream_stats.frame_counts.key_frames != 0; |
2684 | 2668 |
2685 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= | 2669 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= |
2686 stats.encode_frame_rate != 0; | 2670 stats.encode_frame_rate != 0; |
2687 | 2671 |
2688 send_stats_filled_[CompoundKey("Delay", it->first)] |= | 2672 send_stats_filled_[CompoundKey("Delay", it->first)] |= |
2689 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; | 2673 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; |
2690 | 2674 |
(...skipping 10 matching lines...) Expand all Loading... |
2701 return AllStatsFilled(send_stats_filled_); | 2685 return AllStatsFilled(send_stats_filled_); |
2702 } | 2686 } |
2703 | 2687 |
2704 std::string CompoundKey(const char* name, uint32_t ssrc) { | 2688 std::string CompoundKey(const char* name, uint32_t ssrc) { |
2705 std::ostringstream oss; | 2689 std::ostringstream oss; |
2706 oss << name << "_" << ssrc; | 2690 oss << name << "_" << ssrc; |
2707 return oss.str(); | 2691 return oss.str(); |
2708 } | 2692 } |
2709 | 2693 |
2710 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { | 2694 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { |
2711 for (const auto& stat : stats_map) { | 2695 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); |
2712 if (!stat.second) | 2696 it != stats_map.end(); |
| 2697 ++it) { |
| 2698 if (!it->second) |
2713 return false; | 2699 return false; |
2714 } | 2700 } |
2715 return true; | 2701 return true; |
2716 } | 2702 } |
2717 | 2703 |
2718 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 2704 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
2719 FakeNetworkPipe::Config network_config; | 2705 FakeNetworkPipe::Config network_config; |
2720 network_config.loss_percent = 5; | 2706 network_config.loss_percent = 5; |
2721 return new test::PacketTransport( | 2707 return new test::PacketTransport( |
2722 sender_call, this, test::PacketTransport::kSender, network_config); | 2708 sender_call, this, test::PacketTransport::kSender, network_config); |
2723 } | 2709 } |
2724 | 2710 |
2725 Call::Config GetSenderCallConfig() override { | 2711 Call::Config GetSenderCallConfig() override { |
2726 Call::Config config = EndToEndTest::GetSenderCallConfig(); | 2712 Call::Config config = EndToEndTest::GetSenderCallConfig(); |
2727 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; | 2713 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; |
2728 return config; | 2714 return config; |
2729 } | 2715 } |
2730 | 2716 |
2731 void ModifyVideoConfigs( | 2717 void ModifyVideoConfigs( |
2732 VideoSendStream::Config* send_config, | 2718 VideoSendStream::Config* send_config, |
2733 std::vector<VideoReceiveStream::Config>* receive_configs, | 2719 std::vector<VideoReceiveStream::Config>* receive_configs, |
2734 VideoEncoderConfig* encoder_config) override { | 2720 VideoEncoderConfig* encoder_config) override { |
2735 // Set low rates to avoid waiting for rampup. | |
2736 for (size_t i = 0; i < encoder_config->streams.size(); ++i) { | |
2737 encoder_config->streams[i].min_bitrate_bps = 10000; | |
2738 encoder_config->streams[i].target_bitrate_bps = 15000; | |
2739 encoder_config->streams[i].max_bitrate_bps = 20000; | |
2740 } | |
2741 send_config->pre_encode_callback = this; // Used to inject delay. | 2721 send_config->pre_encode_callback = this; // Used to inject delay. |
2742 expected_cname_ = send_config->rtp.c_name = "SomeCName"; | 2722 expected_cname_ = send_config->rtp.c_name = "SomeCName"; |
2743 | 2723 |
2744 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
2745 send_config->rtp.rtx.payload_type = kSendRtxPayloadType; | |
2746 | |
2747 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; | 2724 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; |
2748 for (size_t i = 0; i < ssrcs.size(); ++i) { | 2725 for (size_t i = 0; i < ssrcs.size(); ++i) { |
2749 expected_send_ssrcs_.insert(ssrcs[i]); | 2726 expected_send_ssrcs_.insert(ssrcs[i]); |
2750 expected_receive_ssrcs_.push_back( | 2727 expected_receive_ssrcs_.push_back( |
2751 (*receive_configs)[i].rtp.remote_ssrc); | 2728 (*receive_configs)[i].rtp.remote_ssrc); |
2752 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; | 2729 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; |
2753 (*receive_configs)[i].renderer = &receive_stream_renderer_; | 2730 (*receive_configs)[i].renderer = &receive_stream_renderer_; |
2754 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
2755 | |
2756 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc = | |
2757 kSendRtxSsrcs[i]; | |
2758 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type = | |
2759 kSendRtxPayloadType; | |
2760 } | 2731 } |
2761 | |
2762 for (size_t i = 0; i < kNumSsrcs; ++i) | |
2763 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); | |
2764 | |
2765 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that | 2732 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that |
2766 // are non-zero. | 2733 // are non-zero. |
2767 send_config->encoder_settings.encoder = &encoder_; | 2734 send_config->encoder_settings.encoder = &encoder_; |
2768 } | 2735 } |
2769 | 2736 |
2770 size_t GetNumVideoStreams() const override { return kNumSsrcs; } | 2737 size_t GetNumVideoStreams() const override { return kNumSsrcs; } |
2771 | 2738 |
2772 void OnVideoStreamsCreated( | 2739 void OnVideoStreamsCreated( |
2773 VideoSendStream* send_stream, | 2740 VideoSendStream* send_stream, |
2774 const std::vector<VideoReceiveStream*>& receive_streams) override { | 2741 const std::vector<VideoReceiveStream*>& receive_streams) override { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3608 private: | 3575 private: |
3609 bool video_observed_; | 3576 bool video_observed_; |
3610 bool audio_observed_; | 3577 bool audio_observed_; |
3611 SequenceNumberUnwrapper unwrapper_; | 3578 SequenceNumberUnwrapper unwrapper_; |
3612 std::set<int64_t> received_packet_ids_; | 3579 std::set<int64_t> received_packet_ids_; |
3613 } test; | 3580 } test; |
3614 | 3581 |
3615 RunBaseTest(&test); | 3582 RunBaseTest(&test); |
3616 } | 3583 } |
3617 } // namespace webrtc | 3584 } // namespace webrtc |
OLD | NEW |