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" | |
29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 30 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 31 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
31 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
32 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 33 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
33 #include "webrtc/system_wrappers/include/metrics.h" | 34 #include "webrtc/system_wrappers/include/metrics.h" |
34 #include "webrtc/system_wrappers/include/metrics_default.h" | 35 #include "webrtc/system_wrappers/include/metrics_default.h" |
35 #include "webrtc/system_wrappers/include/sleep.h" | 36 #include "webrtc/system_wrappers/include/sleep.h" |
36 #include "webrtc/test/call_test.h" | 37 #include "webrtc/test/call_test.h" |
37 #include "webrtc/test/direct_transport.h" | 38 #include "webrtc/test/direct_transport.h" |
38 #include "webrtc/test/encoder_settings.h" | 39 #include "webrtc/test/encoder_settings.h" |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 } | 1521 } |
1521 | 1522 |
1522 class TransportFeedbackTester : public test::EndToEndTest { | 1523 class TransportFeedbackTester : public test::EndToEndTest { |
1523 public: | 1524 public: |
1524 explicit TransportFeedbackTester(bool feedback_enabled, | 1525 explicit TransportFeedbackTester(bool feedback_enabled, |
1525 size_t num_video_streams, | 1526 size_t num_video_streams, |
1526 size_t num_audio_streams) | 1527 size_t num_audio_streams) |
1527 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), | 1528 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), |
1528 feedback_enabled_(feedback_enabled), | 1529 feedback_enabled_(feedback_enabled), |
1529 num_video_streams_(num_video_streams), | 1530 num_video_streams_(num_video_streams), |
1530 num_audio_streams_(num_audio_streams) { | 1531 num_audio_streams_(num_audio_streams), |
1532 receiver_call_(nullptr) { | |
1531 // Only one stream of each supported for now. | 1533 // Only one stream of each supported for now. |
1532 EXPECT_LE(num_video_streams, 1u); | 1534 EXPECT_LE(num_video_streams, 1u); |
1533 EXPECT_LE(num_audio_streams, 1u); | 1535 EXPECT_LE(num_audio_streams, 1u); |
1534 } | 1536 } |
1535 | 1537 |
1536 protected: | 1538 protected: |
1537 Action OnSendRtcp(const uint8_t* data, size_t length) override { | 1539 Action OnSendRtcp(const uint8_t* data, size_t length) override { |
1538 EXPECT_FALSE(HasTransportFeedback(data, length)); | 1540 EXPECT_FALSE(HasTransportFeedback(data, length)); |
1539 return SEND_PACKET; | 1541 return SEND_PACKET; |
1540 } | 1542 } |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2515 public: | 2517 public: |
2516 StatsObserver() | 2518 StatsObserver() |
2517 : EndToEndTest(kLongTimeoutMs), | 2519 : EndToEndTest(kLongTimeoutMs), |
2518 encoder_(Clock::GetRealTimeClock(), 10), | 2520 encoder_(Clock::GetRealTimeClock(), 10), |
2519 send_stream_(nullptr), | 2521 send_stream_(nullptr), |
2520 expected_send_ssrcs_(), | 2522 expected_send_ssrcs_(), |
2521 check_stats_event_(false, false) {} | 2523 check_stats_event_(false, false) {} |
2522 | 2524 |
2523 private: | 2525 private: |
2524 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 2526 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
2527 const int kPacketLossFrac = 25; // Drop every 25th packet => 4% loss. | |
tommi
2016/07/07 12:48:47
should be packet_loss_frac or static const int kPa
sprang_webrtc
2016/07/07 13:46:51
Done.
| |
2528 RTPHeader header; | |
2529 RtpUtility::RtpHeaderParser parser(packet, length); | |
2530 if (parser.Parse(&header) && | |
2531 expected_send_ssrcs_.find(header.ssrc) != | |
2532 expected_send_ssrcs_.end() && | |
2533 header.sequenceNumber % kPacketLossFrac == 0) { | |
2534 return DROP_PACKET; | |
2535 } | |
2525 check_stats_event_.Set(); | 2536 check_stats_event_.Set(); |
2526 return SEND_PACKET; | 2537 return SEND_PACKET; |
2527 } | 2538 } |
2528 | 2539 |
2529 Action OnSendRtcp(const uint8_t* packet, size_t length) override { | 2540 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
2530 check_stats_event_.Set(); | 2541 check_stats_event_.Set(); |
2531 return SEND_PACKET; | 2542 return SEND_PACKET; |
2532 } | 2543 } |
2533 | 2544 |
2534 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { | 2545 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2615 send_stats_filled_["CpuOveruseMetrics"] |= | 2626 send_stats_filled_["CpuOveruseMetrics"] |= |
2616 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; | 2627 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; |
2617 | 2628 |
2618 send_stats_filled_["EncoderImplementationName"] |= | 2629 send_stats_filled_["EncoderImplementationName"] |= |
2619 stats.encoder_implementation_name == | 2630 stats.encoder_implementation_name == |
2620 test::FakeEncoder::kImplementationName; | 2631 test::FakeEncoder::kImplementationName; |
2621 | 2632 |
2622 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = | 2633 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = |
2623 stats.substreams.begin(); | 2634 stats.substreams.begin(); |
2624 it != stats.substreams.end(); ++it) { | 2635 it != stats.substreams.end(); ++it) { |
2625 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != | 2636 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end()) |
2626 expected_send_ssrcs_.end()); | 2637 continue; // Probably RTX. |
2627 | 2638 |
2628 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= | 2639 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= |
2629 stats.input_frame_rate != 0; | 2640 stats.input_frame_rate != 0; |
2630 | 2641 |
2631 const VideoSendStream::StreamStats& stream_stats = it->second; | 2642 const VideoSendStream::StreamStats& stream_stats = it->second; |
2632 | 2643 |
2633 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= | 2644 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= |
2634 stream_stats.rtcp_stats.cumulative_lost != 0 || | 2645 stream_stats.rtcp_stats.cumulative_lost != 0 || |
2635 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || | 2646 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || |
2636 stream_stats.rtcp_stats.fraction_lost != 0; | 2647 stream_stats.rtcp_stats.fraction_lost != 0; |
2637 | 2648 |
2638 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= | 2649 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= |
2639 stream_stats.rtp_stats.fec.packets != 0 || | 2650 stream_stats.rtp_stats.fec.packets != 0 || |
2640 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || | 2651 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || |
2641 stream_stats.rtp_stats.retransmitted.packets != 0 || | 2652 stream_stats.rtp_stats.retransmitted.packets != 0 || |
2642 stream_stats.rtp_stats.transmitted.packets != 0; | 2653 stream_stats.rtp_stats.transmitted.packets != 0; |
2643 | 2654 |
2644 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", | 2655 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total", |
2645 it->first)] |= | 2656 it->first)] |= |
2646 stream_stats.total_bitrate_bps != 0; | 2657 stream_stats.total_bitrate_bps != 0; |
2647 | 2658 |
2659 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit", | |
2660 it->first)] |= | |
2661 stream_stats.retransmit_bitrate_bps != 0; | |
2662 | |
2648 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= | 2663 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= |
2649 stream_stats.frame_counts.delta_frames != 0 || | 2664 stream_stats.frame_counts.delta_frames != 0 || |
2650 stream_stats.frame_counts.key_frames != 0; | 2665 stream_stats.frame_counts.key_frames != 0; |
2651 | 2666 |
2652 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= | 2667 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= |
2653 stats.encode_frame_rate != 0; | 2668 stats.encode_frame_rate != 0; |
2654 | 2669 |
2655 send_stats_filled_[CompoundKey("Delay", it->first)] |= | 2670 send_stats_filled_[CompoundKey("Delay", it->first)] |= |
2656 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; | 2671 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; |
2657 | 2672 |
(...skipping 10 matching lines...) Expand all Loading... | |
2668 return AllStatsFilled(send_stats_filled_); | 2683 return AllStatsFilled(send_stats_filled_); |
2669 } | 2684 } |
2670 | 2685 |
2671 std::string CompoundKey(const char* name, uint32_t ssrc) { | 2686 std::string CompoundKey(const char* name, uint32_t ssrc) { |
2672 std::ostringstream oss; | 2687 std::ostringstream oss; |
2673 oss << name << "_" << ssrc; | 2688 oss << name << "_" << ssrc; |
2674 return oss.str(); | 2689 return oss.str(); |
2675 } | 2690 } |
2676 | 2691 |
2677 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { | 2692 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { |
2678 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); | 2693 for (const auto& stat : stats_map) { |
2679 it != stats_map.end(); | 2694 if (!stat.second) |
2680 ++it) { | |
2681 if (!it->second) | |
2682 return false; | 2695 return false; |
2683 } | 2696 } |
2684 return true; | 2697 return true; |
2685 } | 2698 } |
2686 | 2699 |
2687 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 2700 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
2688 FakeNetworkPipe::Config network_config; | 2701 FakeNetworkPipe::Config network_config; |
2689 network_config.loss_percent = 5; | 2702 network_config.loss_percent = 5; |
2690 return new test::PacketTransport( | 2703 return new test::PacketTransport( |
2691 sender_call, this, test::PacketTransport::kSender, network_config); | 2704 sender_call, this, test::PacketTransport::kSender, network_config); |
2692 } | 2705 } |
2693 | 2706 |
2694 Call::Config GetSenderCallConfig() override { | 2707 Call::Config GetSenderCallConfig() override { |
2695 Call::Config config = EndToEndTest::GetSenderCallConfig(); | 2708 Call::Config config = EndToEndTest::GetSenderCallConfig(); |
2696 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; | 2709 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; |
2697 return config; | 2710 return config; |
2698 } | 2711 } |
2699 | 2712 |
2700 void ModifyVideoConfigs( | 2713 void ModifyVideoConfigs( |
2701 VideoSendStream::Config* send_config, | 2714 VideoSendStream::Config* send_config, |
2702 std::vector<VideoReceiveStream::Config>* receive_configs, | 2715 std::vector<VideoReceiveStream::Config>* receive_configs, |
2703 VideoEncoderConfig* encoder_config) override { | 2716 VideoEncoderConfig* encoder_config) override { |
2717 // Set low rates to avoid waiting for rampup. | |
2718 for (size_t i = 0; i < encoder_config->streams.size(); ++i) { | |
2719 encoder_config->streams[i].min_bitrate_bps = 10000; | |
2720 encoder_config->streams[i].target_bitrate_bps = 15000; | |
2721 encoder_config->streams[i].max_bitrate_bps = 20000; | |
2722 } | |
2704 send_config->pre_encode_callback = this; // Used to inject delay. | 2723 send_config->pre_encode_callback = this; // Used to inject delay. |
2705 expected_cname_ = send_config->rtp.c_name = "SomeCName"; | 2724 expected_cname_ = send_config->rtp.c_name = "SomeCName"; |
2706 | 2725 |
2726 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
2727 send_config->rtp.rtx.payload_type = kSendRtxPayloadType; | |
2728 | |
2707 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; | 2729 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; |
2708 for (size_t i = 0; i < ssrcs.size(); ++i) { | 2730 for (size_t i = 0; i < ssrcs.size(); ++i) { |
2709 expected_send_ssrcs_.insert(ssrcs[i]); | 2731 expected_send_ssrcs_.insert(ssrcs[i]); |
2710 expected_receive_ssrcs_.push_back( | 2732 expected_receive_ssrcs_.push_back( |
2711 (*receive_configs)[i].rtp.remote_ssrc); | 2733 (*receive_configs)[i].rtp.remote_ssrc); |
2712 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; | 2734 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; |
2713 (*receive_configs)[i].renderer = &receive_stream_renderer_; | 2735 (*receive_configs)[i].renderer = &receive_stream_renderer_; |
2736 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | |
2737 | |
2738 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc = | |
2739 kSendRtxSsrcs[i]; | |
2740 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type = | |
2741 kSendRtxPayloadType; | |
2714 } | 2742 } |
2743 | |
2744 for (size_t i = 0; i < kNumSsrcs; ++i) | |
2745 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); | |
2746 | |
2715 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that | 2747 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that |
2716 // are non-zero. | 2748 // are non-zero. |
2717 send_config->encoder_settings.encoder = &encoder_; | 2749 send_config->encoder_settings.encoder = &encoder_; |
2718 } | 2750 } |
2719 | 2751 |
2720 size_t GetNumVideoStreams() const override { return kNumSsrcs; } | 2752 size_t GetNumVideoStreams() const override { return kNumSsrcs; } |
2721 | 2753 |
2722 void OnVideoStreamsCreated( | 2754 void OnVideoStreamsCreated( |
2723 VideoSendStream* send_stream, | 2755 VideoSendStream* send_stream, |
2724 const std::vector<VideoReceiveStream*>& receive_streams) override { | 2756 const std::vector<VideoReceiveStream*>& receive_streams) override { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3558 private: | 3590 private: |
3559 bool video_observed_; | 3591 bool video_observed_; |
3560 bool audio_observed_; | 3592 bool audio_observed_; |
3561 SequenceNumberUnwrapper unwrapper_; | 3593 SequenceNumberUnwrapper unwrapper_; |
3562 std::set<int64_t> received_packet_ids_; | 3594 std::set<int64_t> received_packet_ids_; |
3563 } test; | 3595 } test; |
3564 | 3596 |
3565 RunBaseTest(&test); | 3597 RunBaseTest(&test); |
3566 } | 3598 } |
3567 } // namespace webrtc | 3599 } // namespace webrtc |
OLD | NEW |