| 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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 } | 1515 } |
| 1515 | 1516 |
| 1516 class TransportFeedbackTester : public test::EndToEndTest { | 1517 class TransportFeedbackTester : public test::EndToEndTest { |
| 1517 public: | 1518 public: |
| 1518 explicit TransportFeedbackTester(bool feedback_enabled, | 1519 explicit TransportFeedbackTester(bool feedback_enabled, |
| 1519 size_t num_video_streams, | 1520 size_t num_video_streams, |
| 1520 size_t num_audio_streams) | 1521 size_t num_audio_streams) |
| 1521 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), | 1522 : EndToEndTest(::webrtc::EndToEndTest::kDefaultTimeoutMs), |
| 1522 feedback_enabled_(feedback_enabled), | 1523 feedback_enabled_(feedback_enabled), |
| 1523 num_video_streams_(num_video_streams), | 1524 num_video_streams_(num_video_streams), |
| 1524 num_audio_streams_(num_audio_streams) { | 1525 num_audio_streams_(num_audio_streams), |
| 1526 receiver_call_(nullptr) { |
| 1525 // Only one stream of each supported for now. | 1527 // Only one stream of each supported for now. |
| 1526 EXPECT_LE(num_video_streams, 1u); | 1528 EXPECT_LE(num_video_streams, 1u); |
| 1527 EXPECT_LE(num_audio_streams, 1u); | 1529 EXPECT_LE(num_audio_streams, 1u); |
| 1528 } | 1530 } |
| 1529 | 1531 |
| 1530 protected: | 1532 protected: |
| 1531 Action OnSendRtcp(const uint8_t* data, size_t length) override { | 1533 Action OnSendRtcp(const uint8_t* data, size_t length) override { |
| 1532 EXPECT_FALSE(HasTransportFeedback(data, length)); | 1534 EXPECT_FALSE(HasTransportFeedback(data, length)); |
| 1533 return SEND_PACKET; | 1535 return SEND_PACKET; |
| 1534 } | 1536 } |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2496 public: | 2498 public: |
| 2497 StatsObserver() | 2499 StatsObserver() |
| 2498 : EndToEndTest(kLongTimeoutMs), | 2500 : EndToEndTest(kLongTimeoutMs), |
| 2499 encoder_(Clock::GetRealTimeClock(), 10), | 2501 encoder_(Clock::GetRealTimeClock(), 10), |
| 2500 send_stream_(nullptr), | 2502 send_stream_(nullptr), |
| 2501 expected_send_ssrcs_(), | 2503 expected_send_ssrcs_(), |
| 2502 check_stats_event_(false, false) {} | 2504 check_stats_event_(false, false) {} |
| 2503 | 2505 |
| 2504 private: | 2506 private: |
| 2505 Action OnSendRtp(const uint8_t* packet, size_t length) override { | 2507 Action OnSendRtp(const uint8_t* packet, size_t length) override { |
| 2508 const int kPacketLossFrac = 25; // Drop every 25th packet => 4% loss. |
| 2509 RTPHeader header; |
| 2510 RtpUtility::RtpHeaderParser parser(packet, length); |
| 2511 if (parser.Parse(&header) && |
| 2512 expected_send_ssrcs_.find(header.ssrc) != |
| 2513 expected_send_ssrcs_.end() && |
| 2514 header.sequenceNumber % kPacketLossFrac == 0) { |
| 2515 return DROP_PACKET; |
| 2516 } |
| 2506 check_stats_event_.Set(); | 2517 check_stats_event_.Set(); |
| 2507 return SEND_PACKET; | 2518 return SEND_PACKET; |
| 2508 } | 2519 } |
| 2509 | 2520 |
| 2510 Action OnSendRtcp(const uint8_t* packet, size_t length) override { | 2521 Action OnSendRtcp(const uint8_t* packet, size_t length) override { |
| 2511 check_stats_event_.Set(); | 2522 check_stats_event_.Set(); |
| 2512 return SEND_PACKET; | 2523 return SEND_PACKET; |
| 2513 } | 2524 } |
| 2514 | 2525 |
| 2515 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { | 2526 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 send_stats_filled_["CpuOveruseMetrics"] |= | 2607 send_stats_filled_["CpuOveruseMetrics"] |= |
| 2597 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; | 2608 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; |
| 2598 | 2609 |
| 2599 send_stats_filled_["EncoderImplementationName"] |= | 2610 send_stats_filled_["EncoderImplementationName"] |= |
| 2600 stats.encoder_implementation_name == | 2611 stats.encoder_implementation_name == |
| 2601 test::FakeEncoder::kImplementationName; | 2612 test::FakeEncoder::kImplementationName; |
| 2602 | 2613 |
| 2603 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = | 2614 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = |
| 2604 stats.substreams.begin(); | 2615 stats.substreams.begin(); |
| 2605 it != stats.substreams.end(); ++it) { | 2616 it != stats.substreams.end(); ++it) { |
| 2606 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != | 2617 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end()) |
| 2607 expected_send_ssrcs_.end()); | 2618 continue; // Probably RTX. |
| 2608 | 2619 |
| 2609 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= | 2620 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= |
| 2610 stats.input_frame_rate != 0; | 2621 stats.input_frame_rate != 0; |
| 2611 | 2622 |
| 2612 const VideoSendStream::StreamStats& stream_stats = it->second; | 2623 const VideoSendStream::StreamStats& stream_stats = it->second; |
| 2613 | 2624 |
| 2614 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= | 2625 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= |
| 2615 stream_stats.rtcp_stats.cumulative_lost != 0 || | 2626 stream_stats.rtcp_stats.cumulative_lost != 0 || |
| 2616 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || | 2627 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || |
| 2617 stream_stats.rtcp_stats.fraction_lost != 0; | 2628 stream_stats.rtcp_stats.fraction_lost != 0; |
| 2618 | 2629 |
| 2619 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= | 2630 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= |
| 2620 stream_stats.rtp_stats.fec.packets != 0 || | 2631 stream_stats.rtp_stats.fec.packets != 0 || |
| 2621 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || | 2632 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || |
| 2622 stream_stats.rtp_stats.retransmitted.packets != 0 || | 2633 stream_stats.rtp_stats.retransmitted.packets != 0 || |
| 2623 stream_stats.rtp_stats.transmitted.packets != 0; | 2634 stream_stats.rtp_stats.transmitted.packets != 0; |
| 2624 | 2635 |
| 2625 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", | 2636 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total", |
| 2626 it->first)] |= | 2637 it->first)] |= |
| 2627 stream_stats.total_bitrate_bps != 0; | 2638 stream_stats.total_bitrate_bps != 0; |
| 2628 | 2639 |
| 2640 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit", |
| 2641 it->first)] |= |
| 2642 stream_stats.retransmit_bitrate_bps != 0; |
| 2643 |
| 2629 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= | 2644 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= |
| 2630 stream_stats.frame_counts.delta_frames != 0 || | 2645 stream_stats.frame_counts.delta_frames != 0 || |
| 2631 stream_stats.frame_counts.key_frames != 0; | 2646 stream_stats.frame_counts.key_frames != 0; |
| 2632 | 2647 |
| 2633 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= | 2648 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= |
| 2634 stats.encode_frame_rate != 0; | 2649 stats.encode_frame_rate != 0; |
| 2635 | 2650 |
| 2636 send_stats_filled_[CompoundKey("Delay", it->first)] |= | 2651 send_stats_filled_[CompoundKey("Delay", it->first)] |= |
| 2637 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; | 2652 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; |
| 2638 | 2653 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2649 return AllStatsFilled(send_stats_filled_); | 2664 return AllStatsFilled(send_stats_filled_); |
| 2650 } | 2665 } |
| 2651 | 2666 |
| 2652 std::string CompoundKey(const char* name, uint32_t ssrc) { | 2667 std::string CompoundKey(const char* name, uint32_t ssrc) { |
| 2653 std::ostringstream oss; | 2668 std::ostringstream oss; |
| 2654 oss << name << "_" << ssrc; | 2669 oss << name << "_" << ssrc; |
| 2655 return oss.str(); | 2670 return oss.str(); |
| 2656 } | 2671 } |
| 2657 | 2672 |
| 2658 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { | 2673 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { |
| 2659 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); | 2674 for (auto& it : stats_map) { |
| 2660 it != stats_map.end(); | 2675 if (!it.second) |
| 2661 ++it) { | |
| 2662 if (!it->second) | |
| 2663 return false; | 2676 return false; |
| 2664 } | 2677 } |
| 2665 return true; | 2678 return true; |
| 2666 } | 2679 } |
| 2667 | 2680 |
| 2668 test::PacketTransport* CreateSendTransport(Call* sender_call) override { | 2681 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
| 2669 FakeNetworkPipe::Config network_config; | 2682 FakeNetworkPipe::Config network_config; |
| 2670 network_config.loss_percent = 5; | 2683 network_config.loss_percent = 5; |
| 2671 return new test::PacketTransport( | 2684 return new test::PacketTransport( |
| 2672 sender_call, this, test::PacketTransport::kSender, network_config); | 2685 sender_call, this, test::PacketTransport::kSender, network_config); |
| 2673 } | 2686 } |
| 2674 | 2687 |
| 2675 Call::Config GetSenderCallConfig() override { | 2688 Call::Config GetSenderCallConfig() override { |
| 2676 Call::Config config = EndToEndTest::GetSenderCallConfig(); | 2689 Call::Config config = EndToEndTest::GetSenderCallConfig(); |
| 2677 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; | 2690 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; |
| 2678 return config; | 2691 return config; |
| 2679 } | 2692 } |
| 2680 | 2693 |
| 2681 void ModifyVideoConfigs( | 2694 void ModifyVideoConfigs( |
| 2682 VideoSendStream::Config* send_config, | 2695 VideoSendStream::Config* send_config, |
| 2683 std::vector<VideoReceiveStream::Config>* receive_configs, | 2696 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 2684 VideoEncoderConfig* encoder_config) override { | 2697 VideoEncoderConfig* encoder_config) override { |
| 2698 // Set low rates to avoid waiting for rampup. |
| 2699 for (size_t i = 0; i < encoder_config->streams.size(); ++i) { |
| 2700 encoder_config->streams[i].min_bitrate_bps = 10000; |
| 2701 encoder_config->streams[i].target_bitrate_bps = 15000; |
| 2702 encoder_config->streams[i].max_bitrate_bps = 20000; |
| 2703 } |
| 2685 send_config->pre_encode_callback = this; // Used to inject delay. | 2704 send_config->pre_encode_callback = this; // Used to inject delay. |
| 2686 expected_cname_ = send_config->rtp.c_name = "SomeCName"; | 2705 expected_cname_ = send_config->rtp.c_name = "SomeCName"; |
| 2687 | 2706 |
| 2707 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 2708 send_config->rtp.rtx.payload_type = kSendRtxPayloadType; |
| 2709 |
| 2688 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; | 2710 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; |
| 2689 for (size_t i = 0; i < ssrcs.size(); ++i) { | 2711 for (size_t i = 0; i < ssrcs.size(); ++i) { |
| 2690 expected_send_ssrcs_.insert(ssrcs[i]); | 2712 expected_send_ssrcs_.insert(ssrcs[i]); |
| 2691 expected_receive_ssrcs_.push_back( | 2713 expected_receive_ssrcs_.push_back( |
| 2692 (*receive_configs)[i].rtp.remote_ssrc); | 2714 (*receive_configs)[i].rtp.remote_ssrc); |
| 2693 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; | 2715 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; |
| 2716 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
| 2717 |
| 2718 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc = |
| 2719 kSendRtxSsrcs[i]; |
| 2720 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type = |
| 2721 kSendRtxPayloadType; |
| 2694 } | 2722 } |
| 2723 |
| 2724 for (size_t i = 0; i < kNumSsrcs; ++i) |
| 2725 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]); |
| 2726 |
| 2695 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that | 2727 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that |
| 2696 // are non-zero. | 2728 // are non-zero. |
| 2697 send_config->encoder_settings.encoder = &encoder_; | 2729 send_config->encoder_settings.encoder = &encoder_; |
| 2698 } | 2730 } |
| 2699 | 2731 |
| 2700 size_t GetNumVideoStreams() const override { return kNumSsrcs; } | 2732 size_t GetNumVideoStreams() const override { return kNumSsrcs; } |
| 2701 | 2733 |
| 2702 void OnVideoStreamsCreated( | 2734 void OnVideoStreamsCreated( |
| 2703 VideoSendStream* send_stream, | 2735 VideoSendStream* send_stream, |
| 2704 const std::vector<VideoReceiveStream*>& receive_streams) override { | 2736 const std::vector<VideoReceiveStream*>& receive_streams) override { |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3542 private: | 3574 private: |
| 3543 bool video_observed_; | 3575 bool video_observed_; |
| 3544 bool audio_observed_; | 3576 bool audio_observed_; |
| 3545 SequenceNumberUnwrapper unwrapper_; | 3577 SequenceNumberUnwrapper unwrapper_; |
| 3546 std::set<int64_t> received_packet_ids_; | 3578 std::set<int64_t> received_packet_ids_; |
| 3547 } test; | 3579 } test; |
| 3548 | 3580 |
| 3549 RunBaseTest(&test); | 3581 RunBaseTest(&test); |
| 3550 } | 3582 } |
| 3551 } // namespace webrtc | 3583 } // namespace webrtc |
| OLD | NEW |