pbos@webrtc.org | 744fbc7 | 2013-09-10 09:26:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
pbos@webrtc.org | 744fbc7 | 2013-09-10 09:26:25 +0000 | [diff] [blame] | 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "call/rampup_tests.h" |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 12 | |
Steve Anton | 40d5533 | 2019-01-07 10:21:47 -0800 | [diff] [blame] | 13 | #include "absl/memory/memory.h" |
Artem Titov | 4e199e9 | 2018-08-20 13:30:39 +0200 | [diff] [blame] | 14 | #include "call/fake_network_pipe.h" |
Sebastian Jansson | f5e767d | 2018-10-15 13:24:31 +0200 | [diff] [blame] | 15 | #include "logging/rtc_event_log/output/rtc_event_log_output_file.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "rtc_base/checks.h" |
Sebastian Jansson | f5e767d | 2018-10-15 13:24:31 +0200 | [diff] [blame] | 17 | #include "rtc_base/flags.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "rtc_base/logging.h" |
| 19 | #include "rtc_base/platform_thread.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "rtc_base/string_encode.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "test/encoder_settings.h" |
Per Kjellander | 914351d | 2019-02-15 10:54:55 +0100 | [diff] [blame] | 22 | #include "test/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "test/gtest.h" |
| 24 | #include "test/testsupport/perf_test.h" |
pbos@webrtc.org | 744fbc7 | 2013-09-10 09:26:25 +0000 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
pbos@webrtc.org | 2902328 | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 27 | namespace { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 28 | |
Stefan Holmer | 723dff1 | 2015-10-05 14:59:41 +0200 | [diff] [blame] | 29 | static const int64_t kPollIntervalMs = 20; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 30 | static const int kExpectedHighVideoBitrateBps = 80000; |
stefan | db752f9 | 2016-12-05 08:23:40 -0800 | [diff] [blame] | 31 | static const int kExpectedHighAudioBitrateBps = 30000; |
| 32 | static const int kLowBandwidthLimitBps = 20000; |
Sebastian Jansson | 12fb170 | 2018-02-23 11:34:18 +0100 | [diff] [blame] | 33 | // Set target detected bitrate to slightly larger than the target bitrate to |
| 34 | // avoid flakiness. |
| 35 | static const int kLowBitrateMarginBps = 2000; |
pbos@webrtc.org | 2902328 | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 36 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 37 | std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 38 | std::vector<uint32_t> ssrcs; |
| 39 | for (size_t i = 0; i != num_streams; ++i) |
| 40 | ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); |
| 41 | return ssrcs; |
| 42 | } |
mflodman@webrtc.org | eb16b81 | 2014-06-16 08:57:39 +0000 | [diff] [blame] | 43 | } // namespace |
henrik.lundin@webrtc.org | 845862f | 2014-03-06 07:19:28 +0000 | [diff] [blame] | 44 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 45 | WEBRTC_DEFINE_string(ramp_dump_name, |
| 46 | "", |
| 47 | "Filename for dumped received RTP stream."); |
Sebastian Jansson | f5e767d | 2018-10-15 13:24:31 +0200 | [diff] [blame] | 48 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 49 | RampUpTester::RampUpTester(size_t num_video_streams, |
| 50 | size_t num_audio_streams, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 51 | size_t num_flexfec_streams, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 52 | unsigned int start_bitrate_bps, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 53 | int64_t min_run_time_ms, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 54 | const std::string& extension_type, |
| 55 | bool rtx, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 56 | bool red, |
| 57 | bool report_perf_stats) |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 58 | : EndToEndTest(test::CallTest::kLongTimeoutMs), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 59 | clock_(Clock::GetRealTimeClock()), |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 60 | num_video_streams_(num_video_streams), |
| 61 | num_audio_streams_(num_audio_streams), |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 62 | num_flexfec_streams_(num_flexfec_streams), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 63 | rtx_(rtx), |
| 64 | red_(red), |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 65 | report_perf_stats_(report_perf_stats), |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 66 | sender_call_(nullptr), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 67 | send_stream_(nullptr), |
sprang | 4847ae6 | 2017-06-27 07:06:52 -0700 | [diff] [blame] | 68 | send_transport_(nullptr), |
Artem Titov | 631cafa | 2018-08-21 21:01:00 +0200 | [diff] [blame] | 69 | send_simulated_network_(nullptr), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 70 | start_bitrate_bps_(start_bitrate_bps), |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 71 | min_run_time_ms_(min_run_time_ms), |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 72 | expected_bitrate_bps_(0), |
Erik Språng | f3a7c9d | 2015-10-05 14:03:22 +0200 | [diff] [blame] | 73 | test_start_ms_(-1), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 74 | ramp_up_finished_ms_(-1), |
| 75 | extension_type_(extension_type), |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 76 | video_ssrcs_(GenerateSsrcs(num_video_streams_, 100)), |
| 77 | video_rtx_ssrcs_(GenerateSsrcs(num_video_streams_, 200)), |
| 78 | audio_ssrcs_(GenerateSsrcs(num_audio_streams_, 300)), |
Peter Boström | 8c38e8b | 2015-11-26 17:45:47 +0100 | [diff] [blame] | 79 | poller_thread_(&BitrateStatsPollingThread, |
| 80 | this, |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 81 | "BitrateStatsPollingThread") { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 82 | if (red_) |
| 83 | EXPECT_EQ(0u, num_flexfec_streams_); |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 84 | EXPECT_LE(num_audio_streams_, 1u); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 85 | } |
| 86 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 87 | RampUpTester::~RampUpTester() {} |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 88 | |
Niels Möller | de8e6e6 | 2018-11-13 15:10:33 +0100 | [diff] [blame] | 89 | void RampUpTester::ModifySenderBitrateConfig( |
| 90 | BitrateConstraints* bitrate_config) { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 91 | if (start_bitrate_bps_ != 0) { |
Niels Möller | de8e6e6 | 2018-11-13 15:10:33 +0100 | [diff] [blame] | 92 | bitrate_config->start_bitrate_bps = start_bitrate_bps_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 93 | } |
Niels Möller | de8e6e6 | 2018-11-13 15:10:33 +0100 | [diff] [blame] | 94 | bitrate_config->min_bitrate_bps = 10000; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 95 | } |
| 96 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 97 | void RampUpTester::OnVideoStreamsCreated( |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 98 | VideoSendStream* send_stream, |
| 99 | const std::vector<VideoReceiveStream*>& receive_streams) { |
| 100 | send_stream_ = send_stream; |
| 101 | } |
| 102 | |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 103 | test::PacketTransport* RampUpTester::CreateSendTransport( |
| 104 | test::SingleThreadedTaskQueueForTesting* task_queue, |
| 105 | Call* sender_call) { |
Artem Titov | 631cafa | 2018-08-21 21:01:00 +0200 | [diff] [blame] | 106 | auto network = absl::make_unique<SimulatedNetwork>(forward_transport_config_); |
| 107 | send_simulated_network_ = network.get(); |
minyue | 20c84cc | 2017-04-10 16:57:57 -0700 | [diff] [blame] | 108 | send_transport_ = new test::PacketTransport( |
eladalon | 413ee9a | 2017-08-22 04:02:52 -0700 | [diff] [blame] | 109 | task_queue, sender_call, this, test::PacketTransport::kSender, |
Artem Titov | 4e199e9 | 2018-08-20 13:30:39 +0200 | [diff] [blame] | 110 | test::CallTest::payload_type_map_, |
Artem Titov | 631cafa | 2018-08-21 21:01:00 +0200 | [diff] [blame] | 111 | absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(), |
| 112 | std::move(network))); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 113 | return send_transport_; |
stefan | f116bd0 | 2015-10-27 08:29:42 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Stefan Holmer | d20e651 | 2016-01-12 15:51:22 +0100 | [diff] [blame] | 116 | size_t RampUpTester::GetNumVideoStreams() const { |
| 117 | return num_video_streams_; |
| 118 | } |
| 119 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 120 | size_t RampUpTester::GetNumAudioStreams() const { |
| 121 | return num_audio_streams_; |
| 122 | } |
| 123 | |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 124 | size_t RampUpTester::GetNumFlexfecStreams() const { |
| 125 | return num_flexfec_streams_; |
| 126 | } |
| 127 | |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 128 | class RampUpTester::VideoStreamFactory |
| 129 | : public VideoEncoderConfig::VideoStreamFactoryInterface { |
| 130 | public: |
| 131 | VideoStreamFactory() {} |
| 132 | |
| 133 | private: |
| 134 | std::vector<VideoStream> CreateEncoderStreams( |
| 135 | int width, |
| 136 | int height, |
| 137 | const VideoEncoderConfig& encoder_config) override { |
| 138 | std::vector<VideoStream> streams = |
| 139 | test::CreateVideoStreams(width, height, encoder_config); |
| 140 | if (encoder_config.number_of_streams == 1) { |
| 141 | streams[0].target_bitrate_bps = streams[0].max_bitrate_bps = 2000000; |
| 142 | } |
| 143 | return streams; |
| 144 | } |
| 145 | }; |
| 146 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 147 | void RampUpTester::ModifyVideoConfigs( |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 148 | VideoSendStream::Config* send_config, |
| 149 | std::vector<VideoReceiveStream::Config>* receive_configs, |
| 150 | VideoEncoderConfig* encoder_config) { |
| 151 | send_config->suspend_below_min_bitrate = true; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 152 | encoder_config->number_of_streams = num_video_streams_; |
| 153 | encoder_config->max_bitrate_bps = 2000000; |
| 154 | encoder_config->video_stream_factory = |
| 155 | new rtc::RefCountedObject<RampUpTester::VideoStreamFactory>(); |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 156 | if (num_video_streams_ == 1) { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 157 | // For single stream rampup until 1mbps |
| 158 | expected_bitrate_bps_ = kSingleStreamTargetBps; |
| 159 | } else { |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 14:12:27 +0200 | [diff] [blame] | 160 | // To ensure simulcast rate allocation. |
| 161 | send_config->rtp.payload_name = "VP8"; |
| 162 | encoder_config->codec_type = kVideoCodecVP8; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 163 | std::vector<VideoStream> streams = test::CreateVideoStreams( |
| 164 | test::CallTest::kDefaultWidth, test::CallTest::kDefaultHeight, |
| 165 | *encoder_config); |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 14:12:27 +0200 | [diff] [blame] | 166 | // For multi stream rampup until all streams are being sent. That means |
| 167 | // enough bitrate to send all the target streams plus the min bitrate of |
| 168 | // the last one. |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 169 | expected_bitrate_bps_ = streams.back().min_bitrate_bps; |
| 170 | for (size_t i = 0; i < streams.size() - 1; ++i) { |
| 171 | expected_bitrate_bps_ += streams[i].target_bitrate_bps; |
stefan@webrtc.org | 7e9315b | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 172 | } |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 173 | } |
stefan@webrtc.org | 7e9315b | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 174 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 175 | send_config->rtp.extensions.clear(); |
| 176 | |
| 177 | bool remb; |
stefan | 43edf0f | 2015-11-20 18:05:48 -0800 | [diff] [blame] | 178 | bool transport_cc; |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 179 | if (extension_type_ == RtpExtension::kAbsSendTimeUri) { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 180 | remb = true; |
stefan | 43edf0f | 2015-11-20 18:05:48 -0800 | [diff] [blame] | 181 | transport_cc = false; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 182 | send_config->rtp.extensions.push_back( |
| 183 | RtpExtension(extension_type_.c_str(), kAbsSendTimeExtensionId)); |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 184 | } else if (extension_type_ == RtpExtension::kTransportSequenceNumberUri) { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 185 | remb = false; |
stefan | 43edf0f | 2015-11-20 18:05:48 -0800 | [diff] [blame] | 186 | transport_cc = true; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 187 | send_config->rtp.extensions.push_back(RtpExtension( |
| 188 | extension_type_.c_str(), kTransportSequenceNumberExtensionId)); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 189 | } else { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 190 | remb = true; |
stefan | 43edf0f | 2015-11-20 18:05:48 -0800 | [diff] [blame] | 191 | transport_cc = false; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 192 | send_config->rtp.extensions.push_back(RtpExtension( |
| 193 | extension_type_.c_str(), kTransmissionTimeOffsetExtensionId)); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 194 | } |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 195 | |
| 196 | send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 197 | send_config->rtp.ssrcs = video_ssrcs_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 198 | if (rtx_) { |
| 199 | send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 200 | send_config->rtp.rtx.ssrcs = video_rtx_ssrcs_; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 201 | } |
| 202 | if (red_) { |
brandtr | b5f2c3f | 2016-10-04 23:28:39 -0700 | [diff] [blame] | 203 | send_config->rtp.ulpfec.ulpfec_payload_type = |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 204 | test::CallTest::kUlpfecPayloadType; |
brandtr | b5f2c3f | 2016-10-04 23:28:39 -0700 | [diff] [blame] | 205 | send_config->rtp.ulpfec.red_payload_type = test::CallTest::kRedPayloadType; |
brandtr | fbfb536 | 2016-11-17 04:18:37 -0800 | [diff] [blame] | 206 | if (rtx_) { |
| 207 | send_config->rtp.ulpfec.red_rtx_payload_type = |
| 208 | test::CallTest::kRtxRedPayloadType; |
| 209 | } |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | size_t i = 0; |
| 213 | for (VideoReceiveStream::Config& recv_config : *receive_configs) { |
| 214 | recv_config.rtp.remb = remb; |
stefan | 43edf0f | 2015-11-20 18:05:48 -0800 | [diff] [blame] | 215 | recv_config.rtp.transport_cc = transport_cc; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 216 | recv_config.rtp.extensions = send_config->rtp.extensions; |
Ilya Nikolaevskiy | b0588e6 | 2018-08-27 14:12:27 +0200 | [diff] [blame] | 217 | recv_config.decoders.reserve(1); |
| 218 | recv_config.decoders[0].payload_type = send_config->rtp.payload_type; |
Niels Möller | cb7e1d2 | 2018-09-11 15:56:04 +0200 | [diff] [blame] | 219 | recv_config.decoders[0].video_format = |
| 220 | SdpVideoFormat(send_config->rtp.payload_name); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 221 | |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 222 | recv_config.rtp.remote_ssrc = video_ssrcs_[i]; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 223 | recv_config.rtp.nack.rtp_history_ms = send_config->rtp.nack.rtp_history_ms; |
| 224 | |
| 225 | if (red_) { |
nisse | 3b3622f | 2017-09-26 02:49:21 -0700 | [diff] [blame] | 226 | recv_config.rtp.red_payload_type = |
brandtr | b5f2c3f | 2016-10-04 23:28:39 -0700 | [diff] [blame] | 227 | send_config->rtp.ulpfec.red_payload_type; |
nisse | 3b3622f | 2017-09-26 02:49:21 -0700 | [diff] [blame] | 228 | recv_config.rtp.ulpfec_payload_type = |
brandtr | b5f2c3f | 2016-10-04 23:28:39 -0700 | [diff] [blame] | 229 | send_config->rtp.ulpfec.ulpfec_payload_type; |
brandtr | fbfb536 | 2016-11-17 04:18:37 -0800 | [diff] [blame] | 230 | if (rtx_) { |
nisse | ca5706d | 2017-09-11 02:32:16 -0700 | [diff] [blame] | 231 | recv_config.rtp.rtx_associated_payload_types |
| 232 | [send_config->rtp.ulpfec.red_rtx_payload_type] = |
| 233 | send_config->rtp.ulpfec.red_payload_type; |
brandtr | fbfb536 | 2016-11-17 04:18:37 -0800 | [diff] [blame] | 234 | } |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | if (rtx_) { |
brandtr | 1474212 | 2017-01-27 04:53:07 -0800 | [diff] [blame] | 238 | recv_config.rtp.rtx_ssrc = video_rtx_ssrcs_[i]; |
| 239 | recv_config.rtp |
nisse | 26e3abb | 2017-08-25 04:44:25 -0700 | [diff] [blame] | 240 | .rtx_associated_payload_types[send_config->rtp.rtx.payload_type] = |
Niels Möller | 259a497 | 2018-04-05 15:36:51 +0200 | [diff] [blame] | 241 | send_config->rtp.payload_type; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 242 | } |
| 243 | ++i; |
| 244 | } |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 245 | |
| 246 | RTC_DCHECK_LE(num_flexfec_streams_, 1); |
| 247 | if (num_flexfec_streams_ == 1) { |
| 248 | send_config->rtp.flexfec.payload_type = test::CallTest::kFlexfecPayloadType; |
| 249 | send_config->rtp.flexfec.ssrc = test::CallTest::kFlexfecSendSsrc; |
| 250 | send_config->rtp.flexfec.protected_media_ssrcs = {video_ssrcs_[0]}; |
| 251 | } |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 254 | void RampUpTester::ModifyAudioConfigs( |
| 255 | AudioSendStream::Config* send_config, |
| 256 | std::vector<AudioReceiveStream::Config>* receive_configs) { |
| 257 | if (num_audio_streams_ == 0) |
| 258 | return; |
| 259 | |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 260 | EXPECT_NE(RtpExtension::kTimestampOffsetUri, extension_type_) |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 261 | << "Audio BWE not supported with toffset."; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 262 | EXPECT_NE(RtpExtension::kAbsSendTimeUri, extension_type_) |
| 263 | << "Audio BWE not supported with abs-send-time."; |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 264 | |
| 265 | send_config->rtp.ssrc = audio_ssrcs_[0]; |
| 266 | send_config->rtp.extensions.clear(); |
| 267 | |
minyue | 10cbb46 | 2016-11-07 09:29:22 -0800 | [diff] [blame] | 268 | send_config->min_bitrate_bps = 6000; |
| 269 | send_config->max_bitrate_bps = 60000; |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 270 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 271 | bool transport_cc = false; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 272 | if (extension_type_ == RtpExtension::kTransportSequenceNumberUri) { |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 273 | transport_cc = true; |
| 274 | send_config->rtp.extensions.push_back(RtpExtension( |
| 275 | extension_type_.c_str(), kTransportSequenceNumberExtensionId)); |
| 276 | } |
| 277 | |
| 278 | for (AudioReceiveStream::Config& recv_config : *receive_configs) { |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 279 | recv_config.rtp.transport_cc = transport_cc; |
| 280 | recv_config.rtp.extensions = send_config->rtp.extensions; |
| 281 | recv_config.rtp.remote_ssrc = send_config->rtp.ssrc; |
| 282 | } |
| 283 | } |
| 284 | |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 285 | void RampUpTester::ModifyFlexfecConfigs( |
| 286 | std::vector<FlexfecReceiveStream::Config>* receive_configs) { |
| 287 | if (num_flexfec_streams_ == 0) |
| 288 | return; |
| 289 | RTC_DCHECK_EQ(1, num_flexfec_streams_); |
| 290 | (*receive_configs)[0].payload_type = test::CallTest::kFlexfecPayloadType; |
| 291 | (*receive_configs)[0].remote_ssrc = test::CallTest::kFlexfecSendSsrc; |
| 292 | (*receive_configs)[0].protected_media_ssrcs = {video_ssrcs_[0]}; |
| 293 | (*receive_configs)[0].local_ssrc = video_ssrcs_[0]; |
| 294 | if (extension_type_ == RtpExtension::kAbsSendTimeUri) { |
| 295 | (*receive_configs)[0].transport_cc = false; |
| 296 | (*receive_configs)[0].rtp_header_extensions.push_back( |
| 297 | RtpExtension(extension_type_.c_str(), kAbsSendTimeExtensionId)); |
| 298 | } else if (extension_type_ == RtpExtension::kTransportSequenceNumberUri) { |
| 299 | (*receive_configs)[0].transport_cc = true; |
| 300 | (*receive_configs)[0].rtp_header_extensions.push_back(RtpExtension( |
| 301 | extension_type_.c_str(), kTransportSequenceNumberExtensionId)); |
| 302 | } |
| 303 | } |
| 304 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 305 | void RampUpTester::OnCallsCreated(Call* sender_call, Call* receiver_call) { |
| 306 | sender_call_ = sender_call; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 307 | } |
| 308 | |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 309 | void RampUpTester::BitrateStatsPollingThread(void* obj) { |
| 310 | static_cast<RampUpTester*>(obj)->PollStats(); |
pbos@webrtc.org | 32452b2 | 2014-10-22 12:15:24 +0000 | [diff] [blame] | 311 | } |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 312 | |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 313 | void RampUpTester::PollStats() { |
| 314 | do { |
| 315 | if (sender_call_) { |
| 316 | Call::Stats stats = sender_call_->GetStats(); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 317 | |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 318 | EXPECT_GE(expected_bitrate_bps_, 0); |
| 319 | if (stats.send_bandwidth_bps >= expected_bitrate_bps_ && |
| 320 | (min_run_time_ms_ == -1 || |
| 321 | clock_->TimeInMilliseconds() - test_start_ms_ >= min_run_time_ms_)) { |
| 322 | ramp_up_finished_ms_ = clock_->TimeInMilliseconds(); |
| 323 | observation_complete_.Set(); |
| 324 | } |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 325 | } |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 326 | } while (!stop_event_.Wait(kPollIntervalMs)); |
Erik Språng | 468e62a | 2015-07-06 10:50:47 +0200 | [diff] [blame] | 327 | } |
| 328 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 329 | void RampUpTester::ReportResult(const std::string& measurement, |
| 330 | size_t value, |
| 331 | const std::string& units) const { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 332 | webrtc::test::PrintResult( |
| 333 | measurement, "", |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 334 | ::testing::UnitTest::GetInstance()->current_test_info()->name(), value, |
| 335 | units, false); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 336 | } |
| 337 | |
stefan | 092508a | 2015-09-29 02:26:42 -0700 | [diff] [blame] | 338 | void RampUpTester::AccumulateStats(const VideoSendStream::StreamStats& stream, |
| 339 | size_t* total_packets_sent, |
| 340 | size_t* total_sent, |
| 341 | size_t* padding_sent, |
| 342 | size_t* media_sent) const { |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 343 | *total_packets_sent += stream.rtp_stats.transmitted.packets + |
| 344 | stream.rtp_stats.retransmitted.packets + |
| 345 | stream.rtp_stats.fec.packets; |
| 346 | *total_sent += stream.rtp_stats.transmitted.TotalBytes() + |
| 347 | stream.rtp_stats.retransmitted.TotalBytes() + |
| 348 | stream.rtp_stats.fec.TotalBytes(); |
| 349 | *padding_sent += stream.rtp_stats.transmitted.padding_bytes + |
| 350 | stream.rtp_stats.retransmitted.padding_bytes + |
| 351 | stream.rtp_stats.fec.padding_bytes; |
| 352 | *media_sent += stream.rtp_stats.MediaPayloadBytes(); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 353 | } |
| 354 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 355 | void RampUpTester::TriggerTestDone() { |
Erik Språng | f3a7c9d | 2015-10-05 14:03:22 +0200 | [diff] [blame] | 356 | RTC_DCHECK_GE(test_start_ms_, 0); |
| 357 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 358 | // TODO(holmer): Add audio send stats here too when those APIs are available. |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 359 | if (!send_stream_) |
| 360 | return; |
| 361 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 362 | VideoSendStream::Stats send_stats = send_stream_->GetStats(); |
| 363 | |
| 364 | size_t total_packets_sent = 0; |
| 365 | size_t total_sent = 0; |
| 366 | size_t padding_sent = 0; |
| 367 | size_t media_sent = 0; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 368 | for (uint32_t ssrc : video_ssrcs_) { |
stefan | 092508a | 2015-09-29 02:26:42 -0700 | [diff] [blame] | 369 | AccumulateStats(send_stats.substreams[ssrc], &total_packets_sent, |
| 370 | &total_sent, &padding_sent, &media_sent); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | size_t rtx_total_packets_sent = 0; |
| 374 | size_t rtx_total_sent = 0; |
| 375 | size_t rtx_padding_sent = 0; |
| 376 | size_t rtx_media_sent = 0; |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 377 | for (uint32_t rtx_ssrc : video_rtx_ssrcs_) { |
stefan | 092508a | 2015-09-29 02:26:42 -0700 | [diff] [blame] | 378 | AccumulateStats(send_stats.substreams[rtx_ssrc], &rtx_total_packets_sent, |
| 379 | &rtx_total_sent, &rtx_padding_sent, &rtx_media_sent); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 380 | } |
| 381 | |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 382 | if (report_perf_stats_) { |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 383 | ReportResult("ramp-up-media-sent", media_sent, "bytes"); |
| 384 | ReportResult("ramp-up-padding-sent", padding_sent, "bytes"); |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 385 | ReportResult("ramp-up-rtx-media-sent", rtx_media_sent, "bytes"); |
| 386 | ReportResult("ramp-up-rtx-padding-sent", rtx_padding_sent, "bytes"); |
| 387 | if (ramp_up_finished_ms_ >= 0) { |
| 388 | ReportResult("ramp-up-time", ramp_up_finished_ms_ - test_start_ms_, |
| 389 | "milliseconds"); |
| 390 | } |
| 391 | ReportResult("ramp-up-average-network-latency", |
| 392 | send_transport_->GetAverageDelayMs(), "milliseconds"); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 393 | } |
| 394 | } |
| 395 | |
| 396 | void RampUpTester::PerformTest() { |
Erik Språng | f3a7c9d | 2015-10-05 14:03:22 +0200 | [diff] [blame] | 397 | test_start_ms_ = clock_->TimeInMilliseconds(); |
Peter Boström | 8c38e8b | 2015-11-26 17:45:47 +0100 | [diff] [blame] | 398 | poller_thread_.Start(); |
Peter Boström | 5811a39 | 2015-12-10 13:02:50 +0100 | [diff] [blame] | 399 | EXPECT_TRUE(Wait()) << "Timed out while waiting for ramp-up to complete."; |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 400 | TriggerTestDone(); |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 401 | stop_event_.Set(); |
Peter Boström | 8c38e8b | 2015-11-26 17:45:47 +0100 | [diff] [blame] | 402 | poller_thread_.Stop(); |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 405 | RampUpDownUpTester::RampUpDownUpTester(size_t num_video_streams, |
| 406 | size_t num_audio_streams, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 407 | size_t num_flexfec_streams, |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 408 | unsigned int start_bitrate_bps, |
| 409 | const std::string& extension_type, |
| 410 | bool rtx, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 411 | bool red, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 412 | const std::vector<int>& loss_rates, |
| 413 | bool report_perf_stats) |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 414 | : RampUpTester(num_video_streams, |
| 415 | num_audio_streams, |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 416 | num_flexfec_streams, |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 417 | start_bitrate_bps, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 418 | 0, |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 419 | extension_type, |
| 420 | rtx, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 421 | red, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 422 | report_perf_stats), |
stefan | 76d9c9c | 2017-04-01 06:51:09 -0700 | [diff] [blame] | 423 | link_rates_({4 * GetExpectedHighBitrate() / (3 * 1000), |
| 424 | kLowBandwidthLimitBps / 1000, |
| 425 | 4 * GetExpectedHighBitrate() / (3 * 1000), 0}), |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 426 | test_state_(kFirstRampup), |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 427 | next_state_(kTransitionToNextState), |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 428 | state_start_ms_(clock_->TimeInMilliseconds()), |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 429 | interval_start_ms_(clock_->TimeInMilliseconds()), |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 430 | sent_bytes_(0), |
| 431 | loss_rates_(loss_rates) { |
| 432 | forward_transport_config_.link_capacity_kbps = link_rates_[test_state_]; |
| 433 | forward_transport_config_.queue_delay_ms = 100; |
| 434 | forward_transport_config_.loss_percent = loss_rates_[test_state_]; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 435 | } |
| 436 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 437 | RampUpDownUpTester::~RampUpDownUpTester() {} |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 438 | |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 439 | void RampUpDownUpTester::PollStats() { |
| 440 | do { |
Alex Narest | 78609d5 | 2017-10-20 10:37:47 +0200 | [diff] [blame] | 441 | int transmit_bitrate_bps = 0; |
| 442 | bool suspended = false; |
| 443 | if (num_video_streams_ > 0) { |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 444 | webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); |
Mirko Bonadei | 739baf0 | 2019-01-27 17:29:42 +0100 | [diff] [blame] | 445 | for (const auto& it : stats.substreams) { |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 446 | transmit_bitrate_bps += it.second.total_bitrate_bps; |
| 447 | } |
Alex Narest | 78609d5 | 2017-10-20 10:37:47 +0200 | [diff] [blame] | 448 | suspended = stats.suspended; |
| 449 | } |
| 450 | if (num_audio_streams_ > 0 && sender_call_ != nullptr) { |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 451 | // An audio send stream doesn't have bitrate stats, so the call send BW is |
| 452 | // currently used instead. |
Alex Narest | 78609d5 | 2017-10-20 10:37:47 +0200 | [diff] [blame] | 453 | transmit_bitrate_bps = sender_call_->GetStats().send_bandwidth_bps; |
mflodman@webrtc.org | eb16b81 | 2014-06-16 08:57:39 +0000 | [diff] [blame] | 454 | } |
Alex Narest | 78609d5 | 2017-10-20 10:37:47 +0200 | [diff] [blame] | 455 | EvolveTestState(transmit_bitrate_bps, suspended); |
tommi | 0f8b403 | 2017-02-22 11:22:05 -0800 | [diff] [blame] | 456 | } while (!stop_event_.Wait(kPollIntervalMs)); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 457 | } |
stefan@webrtc.org | 7e9315b | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 458 | |
Niels Möller | de8e6e6 | 2018-11-13 15:10:33 +0100 | [diff] [blame] | 459 | void RampUpDownUpTester::ModifyReceiverBitrateConfig( |
| 460 | BitrateConstraints* bitrate_config) { |
| 461 | bitrate_config->min_bitrate_bps = 10000; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 462 | } |
stefan@webrtc.org | 7e9315b | 2013-12-04 10:24:26 +0000 | [diff] [blame] | 463 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 464 | std::string RampUpDownUpTester::GetModifierString() const { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 465 | std::string str("_"); |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 466 | if (num_video_streams_ > 0) { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 467 | str += rtc::ToString(num_video_streams_); |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 468 | str += "stream"; |
| 469 | str += (num_video_streams_ > 1 ? "s" : ""); |
| 470 | str += "_"; |
| 471 | } |
| 472 | if (num_audio_streams_ > 0) { |
Jonas Olsson | 0a713b6 | 2018-04-04 15:49:32 +0200 | [diff] [blame] | 473 | str += rtc::ToString(num_audio_streams_); |
stefan | ff48361 | 2015-12-21 03:14:00 -0800 | [diff] [blame] | 474 | str += "stream"; |
| 475 | str += (num_audio_streams_ > 1 ? "s" : ""); |
| 476 | str += "_"; |
| 477 | } |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 478 | str += (rtx_ ? "" : "no"); |
Edward Lemur | dd3987f | 2018-01-04 19:44:54 +0100 | [diff] [blame] | 479 | str += "rtx_"; |
| 480 | str += (red_ ? "" : "no"); |
| 481 | str += "red"; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 482 | return str; |
| 483 | } |
andresp@webrtc.org | c148079 | 2014-03-20 03:23:55 +0000 | [diff] [blame] | 484 | |
stefan | db752f9 | 2016-12-05 08:23:40 -0800 | [diff] [blame] | 485 | int RampUpDownUpTester::GetExpectedHighBitrate() const { |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 486 | int expected_bitrate_bps = 0; |
| 487 | if (num_audio_streams_ > 0) |
| 488 | expected_bitrate_bps += kExpectedHighAudioBitrateBps; |
| 489 | if (num_video_streams_ > 0) |
| 490 | expected_bitrate_bps += kExpectedHighVideoBitrateBps; |
| 491 | return expected_bitrate_bps; |
| 492 | } |
| 493 | |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 494 | size_t RampUpDownUpTester::GetFecBytes() const { |
| 495 | size_t flex_fec_bytes = 0; |
| 496 | if (num_flexfec_streams_ > 0) { |
| 497 | webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); |
| 498 | for (const auto& kv : stats.substreams) |
| 499 | flex_fec_bytes += kv.second.rtp_stats.fec.TotalBytes(); |
| 500 | } |
| 501 | return flex_fec_bytes; |
| 502 | } |
| 503 | |
| 504 | bool RampUpDownUpTester::ExpectingFec() const { |
| 505 | return num_flexfec_streams_ > 0 && forward_transport_config_.loss_percent > 0; |
| 506 | } |
| 507 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 508 | void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 509 | int64_t now = clock_->TimeInMilliseconds(); |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 510 | switch (test_state_) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 511 | case kFirstRampup: |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 512 | EXPECT_FALSE(suspended); |
stefan | db752f9 | 2016-12-05 08:23:40 -0800 | [diff] [blame] | 513 | if (bitrate_bps >= GetExpectedHighBitrate()) { |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 514 | if (report_perf_stats_) { |
| 515 | webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 516 | "first_rampup", now - state_start_ms_, "ms", |
| 517 | false); |
| 518 | } |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 519 | // Apply loss during the transition between states if FEC is enabled. |
| 520 | forward_transport_config_.loss_percent = loss_rates_[test_state_]; |
| 521 | test_state_ = kTransitionToNextState; |
| 522 | next_state_ = kLowRate; |
andresp@webrtc.org | c148079 | 2014-03-20 03:23:55 +0000 | [diff] [blame] | 523 | } |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 524 | break; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 525 | case kLowRate: { |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 526 | // Audio streams are never suspended. |
| 527 | bool check_suspend_state = num_video_streams_ > 0; |
Sebastian Jansson | 12fb170 | 2018-02-23 11:34:18 +0100 | [diff] [blame] | 528 | if (bitrate_bps < kLowBandwidthLimitBps + kLowBitrateMarginBps && |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 529 | suspended == check_suspend_state) { |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 530 | if (report_perf_stats_) { |
| 531 | webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 532 | "rampdown", now - state_start_ms_, "ms", |
| 533 | false); |
| 534 | } |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 535 | // Apply loss during the transition between states if FEC is enabled. |
| 536 | forward_transport_config_.loss_percent = loss_rates_[test_state_]; |
| 537 | test_state_ = kTransitionToNextState; |
| 538 | next_state_ = kSecondRampup; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 539 | } |
| 540 | break; |
| 541 | } |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 542 | case kSecondRampup: |
stefan | db752f9 | 2016-12-05 08:23:40 -0800 | [diff] [blame] | 543 | if (bitrate_bps >= GetExpectedHighBitrate() && !suspended) { |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 544 | if (report_perf_stats_) { |
| 545 | webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 546 | "second_rampup", now - state_start_ms_, |
| 547 | "ms", false); |
| 548 | ReportResult("ramp-up-down-up-average-network-latency", |
| 549 | send_transport_->GetAverageDelayMs(), "milliseconds"); |
| 550 | } |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 551 | // Apply loss during the transition between states if FEC is enabled. |
| 552 | forward_transport_config_.loss_percent = loss_rates_[test_state_]; |
| 553 | test_state_ = kTransitionToNextState; |
| 554 | next_state_ = kTestEnd; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 555 | } |
| 556 | break; |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 557 | case kTestEnd: |
| 558 | observation_complete_.Set(); |
| 559 | break; |
| 560 | case kTransitionToNextState: |
| 561 | if (!ExpectingFec() || GetFecBytes() > 0) { |
| 562 | test_state_ = next_state_; |
| 563 | forward_transport_config_.link_capacity_kbps = link_rates_[test_state_]; |
| 564 | // No loss while ramping up and down as it may affect the BWE |
| 565 | // negatively, making the test flaky. |
| 566 | forward_transport_config_.loss_percent = 0; |
| 567 | state_start_ms_ = now; |
| 568 | interval_start_ms_ = now; |
| 569 | sent_bytes_ = 0; |
Artem Titov | 631cafa | 2018-08-21 21:01:00 +0200 | [diff] [blame] | 570 | send_simulated_network_->SetConfig(forward_transport_config_); |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 571 | } |
| 572 | break; |
stefan@webrtc.org | 3d7da88 | 2014-07-08 13:59:46 +0000 | [diff] [blame] | 573 | } |
| 574 | } |
pbos@webrtc.org | f577ae9 | 2014-03-19 08:43:57 +0000 | [diff] [blame] | 575 | |
stefan | 4fbd145 | 2015-09-28 03:57:14 -0700 | [diff] [blame] | 576 | class RampUpTest : public test::CallTest { |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 577 | public: |
Sebastian Jansson | f5e767d | 2018-10-15 13:24:31 +0200 | [diff] [blame] | 578 | RampUpTest() { |
| 579 | std::string dump_name(FLAG_ramp_dump_name); |
| 580 | if (!dump_name.empty()) { |
| 581 | send_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); |
| 582 | recv_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); |
| 583 | bool event_log_started = |
| 584 | send_event_log_->StartLogging( |
| 585 | absl::make_unique<RtcEventLogOutputFile>( |
| 586 | dump_name + ".send.rtc.dat", RtcEventLog::kUnlimitedOutput), |
| 587 | RtcEventLog::kImmediateOutput) && |
| 588 | recv_event_log_->StartLogging( |
| 589 | absl::make_unique<RtcEventLogOutputFile>( |
| 590 | dump_name + ".recv.rtc.dat", RtcEventLog::kUnlimitedOutput), |
| 591 | RtcEventLog::kImmediateOutput); |
| 592 | RTC_DCHECK(event_log_started); |
| 593 | } |
| 594 | } |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 595 | }; |
| 596 | |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 597 | static const uint32_t kStartBitrateBps = 60000; |
| 598 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 599 | TEST_F(RampUpTest, UpDownUpAbsSendTimeSimulcastRedRtx) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 600 | std::vector<int> loss_rates = {0, 0, 0, 0}; |
| 601 | RampUpDownUpTester test(3, 0, 0, kStartBitrateBps, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 602 | RtpExtension::kAbsSendTimeUri, true, true, loss_rates, |
| 603 | true); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 604 | RunBaseTest(&test); |
Shao Changbin | e62202f | 2015-04-21 20:24:50 +0800 | [diff] [blame] | 605 | } |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 606 | |
Taylor Brandstetter | ba6b503 | 2018-02-16 09:59:56 -0800 | [diff] [blame] | 607 | // TODO(bugs.webrtc.org/8878) |
| 608 | #if defined(WEBRTC_MAC) |
| 609 | #define MAYBE_UpDownUpTransportSequenceNumberRtx \ |
| 610 | DISABLED_UpDownUpTransportSequenceNumberRtx |
| 611 | #else |
| 612 | #define MAYBE_UpDownUpTransportSequenceNumberRtx \ |
| 613 | UpDownUpTransportSequenceNumberRtx |
| 614 | #endif |
| 615 | TEST_F(RampUpTest, MAYBE_UpDownUpTransportSequenceNumberRtx) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 616 | std::vector<int> loss_rates = {0, 0, 0, 0}; |
| 617 | RampUpDownUpTester test(3, 0, 0, kStartBitrateBps, |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 618 | RtpExtension::kTransportSequenceNumberUri, true, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 619 | false, loss_rates, true); |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 620 | RunBaseTest(&test); |
| 621 | } |
| 622 | |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 623 | // TODO(holmer): Tests which don't report perf stats should be moved to a |
| 624 | // different executable since they per definition are not perf tests. |
Taylor Brandstetter | 05d9822 | 2017-10-10 12:12:53 -0700 | [diff] [blame] | 625 | // This test is disabled because it crashes on Linux, and is flaky on other |
| 626 | // platforms. See: crbug.com/webrtc/7919 |
| 627 | TEST_F(RampUpTest, DISABLED_UpDownUpTransportSequenceNumberPacketLoss) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 628 | std::vector<int> loss_rates = {20, 0, 0, 0}; |
| 629 | RampUpDownUpTester test(1, 0, 1, kStartBitrateBps, |
| 630 | RtpExtension::kTransportSequenceNumberUri, true, |
stefan | 45b5fe5 | 2017-03-09 06:27:02 -0800 | [diff] [blame] | 631 | false, loss_rates, false); |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 632 | RunBaseTest(&test); |
| 633 | } |
| 634 | |
Taylor Brandstetter | ab86e7f | 2018-02-12 15:16:02 -0800 | [diff] [blame] | 635 | // TODO(bugs.webrtc.org/8878) |
| 636 | #if defined(WEBRTC_MAC) |
| 637 | #define MAYBE_UpDownUpAudioVideoTransportSequenceNumberRtx \ |
| 638 | DISABLED_UpDownUpAudioVideoTransportSequenceNumberRtx |
| 639 | #else |
| 640 | #define MAYBE_UpDownUpAudioVideoTransportSequenceNumberRtx \ |
| 641 | UpDownUpAudioVideoTransportSequenceNumberRtx |
| 642 | #endif |
| 643 | TEST_F(RampUpTest, MAYBE_UpDownUpAudioVideoTransportSequenceNumberRtx) { |
Per Kjellander | 914351d | 2019-02-15 10:54:55 +0100 | [diff] [blame] | 644 | test::ScopedFieldTrials field_trials("WebRTC-Audio-SendSideBwe/Enabled/"); |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 645 | std::vector<int> loss_rates = {0, 0, 0, 0}; |
| 646 | RampUpDownUpTester test(3, 1, 0, kStartBitrateBps, |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 647 | RtpExtension::kTransportSequenceNumberUri, true, |
stefan | ff2ebf5 | 2017-03-13 01:27:03 -0700 | [diff] [blame] | 648 | false, loss_rates, false); |
Stefan Holmer | ff2a635 | 2016-01-14 10:00:21 +0100 | [diff] [blame] | 649 | RunBaseTest(&test); |
| 650 | } |
| 651 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 652 | TEST_F(RampUpTest, UpDownUpAudioTransportSequenceNumberRtx) { |
Per Kjellander | 914351d | 2019-02-15 10:54:55 +0100 | [diff] [blame] | 653 | test::ScopedFieldTrials field_trials("WebRTC-Audio-SendSideBwe/Enabled/"); |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 654 | std::vector<int> loss_rates = {0, 0, 0, 0}; |
| 655 | RampUpDownUpTester test(0, 1, 0, kStartBitrateBps, |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 656 | RtpExtension::kTransportSequenceNumberUri, true, |
stefan | ff2ebf5 | 2017-03-13 01:27:03 -0700 | [diff] [blame] | 657 | false, loss_rates, false); |
mflodman | 86cc6ff | 2016-07-26 04:44:06 -0700 | [diff] [blame] | 658 | RunBaseTest(&test); |
| 659 | } |
| 660 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 661 | TEST_F(RampUpTest, TOffsetSimulcastRedRtx) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 662 | RampUpTester test(3, 0, 0, 0, 0, RtpExtension::kTimestampOffsetUri, true, |
| 663 | true, true); |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 664 | RunBaseTest(&test); |
| 665 | } |
| 666 | |
| 667 | TEST_F(RampUpTest, AbsSendTime) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 668 | RampUpTester test(1, 0, 0, 0, 0, RtpExtension::kAbsSendTimeUri, false, false, |
stefan | ff2ebf5 | 2017-03-13 01:27:03 -0700 | [diff] [blame] | 669 | false); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 670 | RunBaseTest(&test); |
pbos@webrtc.org | 85bd53e | 2014-12-10 10:36:20 +0000 | [diff] [blame] | 671 | } |
| 672 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 673 | TEST_F(RampUpTest, AbsSendTimeSimulcastRedRtx) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 674 | RampUpTester test(3, 0, 0, 0, 0, RtpExtension::kAbsSendTimeUri, true, true, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 675 | true); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 676 | RunBaseTest(&test); |
pbos@webrtc.org | 85bd53e | 2014-12-10 10:36:20 +0000 | [diff] [blame] | 677 | } |
| 678 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 679 | TEST_F(RampUpTest, TransportSequenceNumber) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 680 | RampUpTester test(1, 0, 0, 0, 0, RtpExtension::kTransportSequenceNumberUri, |
stefan | ff2ebf5 | 2017-03-13 01:27:03 -0700 | [diff] [blame] | 681 | false, false, false); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 682 | RunBaseTest(&test); |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | TEST_F(RampUpTest, TransportSequenceNumberSimulcast) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 686 | RampUpTester test(3, 0, 0, 0, 0, RtpExtension::kTransportSequenceNumberUri, |
stefan | ff2ebf5 | 2017-03-13 01:27:03 -0700 | [diff] [blame] | 687 | false, false, false); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 688 | RunBaseTest(&test); |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 689 | } |
| 690 | |
stefan | 38d8b3c | 2017-01-09 04:19:24 -0800 | [diff] [blame] | 691 | TEST_F(RampUpTest, TransportSequenceNumberSimulcastRedRtx) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 692 | RampUpTester test(3, 0, 0, 0, 0, RtpExtension::kTransportSequenceNumberUri, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 693 | true, true, true); |
| 694 | RunBaseTest(&test); |
| 695 | } |
| 696 | |
Niels Möller | cd2e105 | 2018-11-08 10:23:13 +0100 | [diff] [blame] | 697 | TEST_F(RampUpTest, AudioTransportSequenceNumber) { |
philipel | 5ef2bc1 | 2017-02-21 07:28:31 -0800 | [diff] [blame] | 698 | RampUpTester test(0, 1, 0, 300000, 10000, |
stefan | 5a2c506 | 2017-01-27 06:43:18 -0800 | [diff] [blame] | 699 | RtpExtension::kTransportSequenceNumberUri, false, false, |
| 700 | false); |
stefan | e74eef1 | 2016-01-08 06:47:13 -0800 | [diff] [blame] | 701 | RunBaseTest(&test); |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 702 | } |
pbos@webrtc.org | 744fbc7 | 2013-09-10 09:26:25 +0000 | [diff] [blame] | 703 | } // namespace webrtc |