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