Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: webrtc/video/end_to_end_tests.cc

Issue 2061423003: Refactor NACK bitrate allocation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 // Drop every 25th packet => 4% loss.
2528 static const int kPacketLossFrac = 25;
2529 RTPHeader header;
2530 RtpUtility::RtpHeaderParser parser(packet, length);
2531 if (parser.Parse(&header) &&
2532 expected_send_ssrcs_.find(header.ssrc) !=
2533 expected_send_ssrcs_.end() &&
2534 header.sequenceNumber % kPacketLossFrac == 0) {
2535 return DROP_PACKET;
2536 }
2525 check_stats_event_.Set(); 2537 check_stats_event_.Set();
2526 return SEND_PACKET; 2538 return SEND_PACKET;
2527 } 2539 }
2528 2540
2529 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 2541 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
2530 check_stats_event_.Set(); 2542 check_stats_event_.Set();
2531 return SEND_PACKET; 2543 return SEND_PACKET;
2532 } 2544 }
2533 2545
2534 Action OnReceiveRtp(const uint8_t* packet, size_t length) override { 2546 Action OnReceiveRtp(const uint8_t* packet, size_t length) override {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 send_stats_filled_["CpuOveruseMetrics"] |= 2627 send_stats_filled_["CpuOveruseMetrics"] |=
2616 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0; 2628 stats.avg_encode_time_ms != 0 && stats.encode_usage_percent != 0;
2617 2629
2618 send_stats_filled_["EncoderImplementationName"] |= 2630 send_stats_filled_["EncoderImplementationName"] |=
2619 stats.encoder_implementation_name == 2631 stats.encoder_implementation_name ==
2620 test::FakeEncoder::kImplementationName; 2632 test::FakeEncoder::kImplementationName;
2621 2633
2622 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = 2634 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it =
2623 stats.substreams.begin(); 2635 stats.substreams.begin();
2624 it != stats.substreams.end(); ++it) { 2636 it != stats.substreams.end(); ++it) {
2625 EXPECT_TRUE(expected_send_ssrcs_.find(it->first) != 2637 if (expected_send_ssrcs_.find(it->first) == expected_send_ssrcs_.end())
2626 expected_send_ssrcs_.end()); 2638 continue; // Probably RTX.
2627 2639
2628 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |= 2640 send_stats_filled_[CompoundKey("CapturedFrameRate", it->first)] |=
2629 stats.input_frame_rate != 0; 2641 stats.input_frame_rate != 0;
2630 2642
2631 const VideoSendStream::StreamStats& stream_stats = it->second; 2643 const VideoSendStream::StreamStats& stream_stats = it->second;
2632 2644
2633 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |= 2645 send_stats_filled_[CompoundKey("StatisticsUpdated", it->first)] |=
2634 stream_stats.rtcp_stats.cumulative_lost != 0 || 2646 stream_stats.rtcp_stats.cumulative_lost != 0 ||
2635 stream_stats.rtcp_stats.extended_max_sequence_number != 0 || 2647 stream_stats.rtcp_stats.extended_max_sequence_number != 0 ||
2636 stream_stats.rtcp_stats.fraction_lost != 0; 2648 stream_stats.rtcp_stats.fraction_lost != 0;
2637 2649
2638 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |= 2650 send_stats_filled_[CompoundKey("DataCountersUpdated", it->first)] |=
2639 stream_stats.rtp_stats.fec.packets != 0 || 2651 stream_stats.rtp_stats.fec.packets != 0 ||
2640 stream_stats.rtp_stats.transmitted.padding_bytes != 0 || 2652 stream_stats.rtp_stats.transmitted.padding_bytes != 0 ||
2641 stream_stats.rtp_stats.retransmitted.packets != 0 || 2653 stream_stats.rtp_stats.retransmitted.packets != 0 ||
2642 stream_stats.rtp_stats.transmitted.packets != 0; 2654 stream_stats.rtp_stats.transmitted.packets != 0;
2643 2655
2644 send_stats_filled_[CompoundKey("BitrateStatisticsObserver", 2656 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Total",
2645 it->first)] |= 2657 it->first)] |=
2646 stream_stats.total_bitrate_bps != 0; 2658 stream_stats.total_bitrate_bps != 0;
2647 2659
2660 send_stats_filled_[CompoundKey("BitrateStatisticsObserver.Retransmit",
2661 it->first)] |=
2662 stream_stats.retransmit_bitrate_bps != 0;
2663
2648 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |= 2664 send_stats_filled_[CompoundKey("FrameCountObserver", it->first)] |=
2649 stream_stats.frame_counts.delta_frames != 0 || 2665 stream_stats.frame_counts.delta_frames != 0 ||
2650 stream_stats.frame_counts.key_frames != 0; 2666 stream_stats.frame_counts.key_frames != 0;
2651 2667
2652 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |= 2668 send_stats_filled_[CompoundKey("OutgoingRate", it->first)] |=
2653 stats.encode_frame_rate != 0; 2669 stats.encode_frame_rate != 0;
2654 2670
2655 send_stats_filled_[CompoundKey("Delay", it->first)] |= 2671 send_stats_filled_[CompoundKey("Delay", it->first)] |=
2656 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0; 2672 stream_stats.avg_delay_ms != 0 || stream_stats.max_delay_ms != 0;
2657 2673
(...skipping 10 matching lines...) Expand all
2668 return AllStatsFilled(send_stats_filled_); 2684 return AllStatsFilled(send_stats_filled_);
2669 } 2685 }
2670 2686
2671 std::string CompoundKey(const char* name, uint32_t ssrc) { 2687 std::string CompoundKey(const char* name, uint32_t ssrc) {
2672 std::ostringstream oss; 2688 std::ostringstream oss;
2673 oss << name << "_" << ssrc; 2689 oss << name << "_" << ssrc;
2674 return oss.str(); 2690 return oss.str();
2675 } 2691 }
2676 2692
2677 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) { 2693 bool AllStatsFilled(const std::map<std::string, bool>& stats_map) {
2678 for (std::map<std::string, bool>::const_iterator it = stats_map.begin(); 2694 for (const auto& stat : stats_map) {
2679 it != stats_map.end(); 2695 if (!stat.second)
2680 ++it) {
2681 if (!it->second)
2682 return false; 2696 return false;
2683 } 2697 }
2684 return true; 2698 return true;
2685 } 2699 }
2686 2700
2687 test::PacketTransport* CreateSendTransport(Call* sender_call) override { 2701 test::PacketTransport* CreateSendTransport(Call* sender_call) override {
2688 FakeNetworkPipe::Config network_config; 2702 FakeNetworkPipe::Config network_config;
2689 network_config.loss_percent = 5; 2703 network_config.loss_percent = 5;
2690 return new test::PacketTransport( 2704 return new test::PacketTransport(
2691 sender_call, this, test::PacketTransport::kSender, network_config); 2705 sender_call, this, test::PacketTransport::kSender, network_config);
2692 } 2706 }
2693 2707
2694 Call::Config GetSenderCallConfig() override { 2708 Call::Config GetSenderCallConfig() override {
2695 Call::Config config = EndToEndTest::GetSenderCallConfig(); 2709 Call::Config config = EndToEndTest::GetSenderCallConfig();
2696 config.bitrate_config.start_bitrate_bps = kStartBitrateBps; 2710 config.bitrate_config.start_bitrate_bps = kStartBitrateBps;
2697 return config; 2711 return config;
2698 } 2712 }
2699 2713
2700 void ModifyVideoConfigs( 2714 void ModifyVideoConfigs(
2701 VideoSendStream::Config* send_config, 2715 VideoSendStream::Config* send_config,
2702 std::vector<VideoReceiveStream::Config>* receive_configs, 2716 std::vector<VideoReceiveStream::Config>* receive_configs,
2703 VideoEncoderConfig* encoder_config) override { 2717 VideoEncoderConfig* encoder_config) override {
2718 // Set low rates to avoid waiting for rampup.
2719 for (size_t i = 0; i < encoder_config->streams.size(); ++i) {
2720 encoder_config->streams[i].min_bitrate_bps = 10000;
2721 encoder_config->streams[i].target_bitrate_bps = 15000;
2722 encoder_config->streams[i].max_bitrate_bps = 20000;
2723 }
2704 send_config->pre_encode_callback = this; // Used to inject delay. 2724 send_config->pre_encode_callback = this; // Used to inject delay.
2705 expected_cname_ = send_config->rtp.c_name = "SomeCName"; 2725 expected_cname_ = send_config->rtp.c_name = "SomeCName";
2706 2726
2727 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2728 send_config->rtp.rtx.payload_type = kSendRtxPayloadType;
2729
2707 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs; 2730 const std::vector<uint32_t>& ssrcs = send_config->rtp.ssrcs;
2708 for (size_t i = 0; i < ssrcs.size(); ++i) { 2731 for (size_t i = 0; i < ssrcs.size(); ++i) {
2709 expected_send_ssrcs_.insert(ssrcs[i]); 2732 expected_send_ssrcs_.insert(ssrcs[i]);
2710 expected_receive_ssrcs_.push_back( 2733 expected_receive_ssrcs_.push_back(
2711 (*receive_configs)[i].rtp.remote_ssrc); 2734 (*receive_configs)[i].rtp.remote_ssrc);
2712 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs; 2735 (*receive_configs)[i].render_delay_ms = kExpectedRenderDelayMs;
2713 (*receive_configs)[i].renderer = &receive_stream_renderer_; 2736 (*receive_configs)[i].renderer = &receive_stream_renderer_;
2737 (*receive_configs)[i].rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
2738
2739 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].ssrc =
2740 kSendRtxSsrcs[i];
2741 (*receive_configs)[i].rtp.rtx[kFakeVideoSendPayloadType].payload_type =
2742 kSendRtxPayloadType;
2714 } 2743 }
2744
2745 for (size_t i = 0; i < kNumSsrcs; ++i)
2746 send_config->rtp.rtx.ssrcs.push_back(kSendRtxSsrcs[i]);
2747
2715 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that 2748 // Use a delayed encoder to make sure we see CpuOveruseMetrics stats that
2716 // are non-zero. 2749 // are non-zero.
2717 send_config->encoder_settings.encoder = &encoder_; 2750 send_config->encoder_settings.encoder = &encoder_;
2718 } 2751 }
2719 2752
2720 size_t GetNumVideoStreams() const override { return kNumSsrcs; } 2753 size_t GetNumVideoStreams() const override { return kNumSsrcs; }
2721 2754
2722 void OnVideoStreamsCreated( 2755 void OnVideoStreamsCreated(
2723 VideoSendStream* send_stream, 2756 VideoSendStream* send_stream,
2724 const std::vector<VideoReceiveStream*>& receive_streams) override { 2757 const std::vector<VideoReceiveStream*>& receive_streams) override {
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 private: 3591 private:
3559 bool video_observed_; 3592 bool video_observed_;
3560 bool audio_observed_; 3593 bool audio_observed_;
3561 SequenceNumberUnwrapper unwrapper_; 3594 SequenceNumberUnwrapper unwrapper_;
3562 std::set<int64_t> received_packet_ids_; 3595 std::set<int64_t> received_packet_ids_;
3563 } test; 3596 } test;
3564 3597
3565 RunBaseTest(&test); 3598 RunBaseTest(&test);
3566 } 3599 }
3567 } // namespace webrtc 3600 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698