blob: d6271d3ccbde805824ab863c31bc5d43d6c42b96 [file] [log] [blame]
pbos@webrtc.org744fbc72013-09-10 09:26:25 +00001/*
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.org744fbc72013-09-10 09:26:25 +000010
stefanff483612015-12-21 03:14:00 -080011#include "webrtc/call/rampup_tests.h"
12
pbos@webrtc.org744fbc72013-09-10 09:26:25 +000013#include "testing/gtest/include/gtest/gtest.h"
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +000014#include "webrtc/base/checks.h"
pbos12411ef2015-11-23 14:47:56 -080015#include "webrtc/base/platform_thread.h"
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +000016#include "webrtc/test/testsupport/perf_test.h"
pbos@webrtc.org744fbc72013-09-10 09:26:25 +000017
18namespace webrtc {
pbos@webrtc.org29023282013-09-11 10:14:56 +000019namespace {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +000020
Stefan Holmer723dff12015-10-05 14:59:41 +020021static const int64_t kPollIntervalMs = 20;
pbos@webrtc.org29023282013-09-11 10:14:56 +000022
stefanff483612015-12-21 03:14:00 -080023std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +000024 std::vector<uint32_t> ssrcs;
25 for (size_t i = 0; i != num_streams; ++i)
26 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i));
27 return ssrcs;
28}
mflodman@webrtc.orgeb16b812014-06-16 08:57:39 +000029} // namespace
henrik.lundin@webrtc.org845862f2014-03-06 07:19:28 +000030
stefanff483612015-12-21 03:14:00 -080031RampUpTester::RampUpTester(size_t num_video_streams,
32 size_t num_audio_streams,
stefan4fbd1452015-09-28 03:57:14 -070033 unsigned int start_bitrate_bps,
34 const std::string& extension_type,
35 bool rtx,
36 bool red)
37 : EndToEndTest(test::CallTest::kLongTimeoutMs),
38 event_(false, false),
39 clock_(Clock::GetRealTimeClock()),
stefanff483612015-12-21 03:14:00 -080040 num_video_streams_(num_video_streams),
41 num_audio_streams_(num_audio_streams),
stefan4fbd1452015-09-28 03:57:14 -070042 rtx_(rtx),
43 red_(red),
44 send_stream_(nullptr),
45 start_bitrate_bps_(start_bitrate_bps),
46 start_bitrate_verified_(false),
stefan@webrtc.org3d7da882014-07-08 13:59:46 +000047 expected_bitrate_bps_(0),
Erik Språngf3a7c9d2015-10-05 14:03:22 +020048 test_start_ms_(-1),
stefan4fbd1452015-09-28 03:57:14 -070049 ramp_up_finished_ms_(-1),
50 extension_type_(extension_type),
stefanff483612015-12-21 03:14:00 -080051 video_ssrcs_(GenerateSsrcs(num_video_streams_, 100)),
52 video_rtx_ssrcs_(GenerateSsrcs(num_video_streams_, 200)),
53 audio_ssrcs_(GenerateSsrcs(num_audio_streams_, 300)),
Peter Boström8c38e8b2015-11-26 17:45:47 +010054 poller_thread_(&BitrateStatsPollingThread,
55 this,
56 "BitrateStatsPollingThread"),
stefan4fbd1452015-09-28 03:57:14 -070057 sender_call_(nullptr) {
Stefan Holmerff2a6352016-01-14 10:00:21 +010058 EXPECT_LE(num_audio_streams_, 1u);
stefan4fbd1452015-09-28 03:57:14 -070059 if (rtx_) {
stefanff483612015-12-21 03:14:00 -080060 for (size_t i = 0; i < video_ssrcs_.size(); ++i)
61 rtx_ssrc_map_[video_rtx_ssrcs_[i]] = video_ssrcs_[i];
stefan@webrtc.org3d7da882014-07-08 13:59:46 +000062 }
stefan4fbd1452015-09-28 03:57:14 -070063}
64
65RampUpTester::~RampUpTester() {
66 event_.Set();
stefan4fbd1452015-09-28 03:57:14 -070067}
68
69Call::Config RampUpTester::GetSenderCallConfig() {
70 Call::Config call_config;
71 if (start_bitrate_bps_ != 0) {
72 call_config.bitrate_config.start_bitrate_bps = start_bitrate_bps_;
73 }
74 call_config.bitrate_config.min_bitrate_bps = 10000;
75 return call_config;
76}
77
stefanff483612015-12-21 03:14:00 -080078void RampUpTester::OnVideoStreamsCreated(
stefan4fbd1452015-09-28 03:57:14 -070079 VideoSendStream* send_stream,
80 const std::vector<VideoReceiveStream*>& receive_streams) {
81 send_stream_ = send_stream;
82}
83
stefane74eef12016-01-08 06:47:13 -080084test::PacketTransport* RampUpTester::CreateSendTransport(Call* sender_call) {
85 send_transport_ = new test::PacketTransport(sender_call, this,
86 test::PacketTransport::kSender,
87 forward_transport_config_);
88 return send_transport_;
stefanf116bd02015-10-27 08:29:42 -070089}
90
Stefan Holmerd20e6512016-01-12 15:51:22 +010091size_t RampUpTester::GetNumVideoStreams() const {
92 return num_video_streams_;
93}
94
Stefan Holmerff2a6352016-01-14 10:00:21 +010095size_t RampUpTester::GetNumAudioStreams() const {
96 return num_audio_streams_;
97}
98
stefanff483612015-12-21 03:14:00 -080099void RampUpTester::ModifyVideoConfigs(
stefan4fbd1452015-09-28 03:57:14 -0700100 VideoSendStream::Config* send_config,
101 std::vector<VideoReceiveStream::Config>* receive_configs,
102 VideoEncoderConfig* encoder_config) {
103 send_config->suspend_below_min_bitrate = true;
104
stefanff483612015-12-21 03:14:00 -0800105 if (num_video_streams_ == 1) {
stefan4fbd1452015-09-28 03:57:14 -0700106 encoder_config->streams[0].target_bitrate_bps =
107 encoder_config->streams[0].max_bitrate_bps = 2000000;
108 // For single stream rampup until 1mbps
109 expected_bitrate_bps_ = kSingleStreamTargetBps;
110 } else {
111 // For multi stream rampup until all streams are being sent. That means
112 // enough birate to send all the target streams plus the min bitrate of
113 // the last one.
114 expected_bitrate_bps_ = encoder_config->streams.back().min_bitrate_bps;
115 for (size_t i = 0; i < encoder_config->streams.size() - 1; ++i) {
116 expected_bitrate_bps_ += encoder_config->streams[i].target_bitrate_bps;
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000117 }
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000118 }
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000119
stefan4fbd1452015-09-28 03:57:14 -0700120 send_config->rtp.extensions.clear();
121
122 bool remb;
stefan43edf0f2015-11-20 18:05:48 -0800123 bool transport_cc;
isheriff6f8d6862016-05-26 11:24:55 -0700124 if (extension_type_ == RtpExtension::kAbsSendTimeUri) {
stefan4fbd1452015-09-28 03:57:14 -0700125 remb = true;
stefan43edf0f2015-11-20 18:05:48 -0800126 transport_cc = false;
stefan4fbd1452015-09-28 03:57:14 -0700127 send_config->rtp.extensions.push_back(
128 RtpExtension(extension_type_.c_str(), kAbsSendTimeExtensionId));
isheriff6f8d6862016-05-26 11:24:55 -0700129 } else if (extension_type_ == RtpExtension::kTransportSequenceNumberUri) {
stefan4fbd1452015-09-28 03:57:14 -0700130 remb = false;
stefan43edf0f2015-11-20 18:05:48 -0800131 transport_cc = true;
stefan4fbd1452015-09-28 03:57:14 -0700132 send_config->rtp.extensions.push_back(RtpExtension(
133 extension_type_.c_str(), kTransportSequenceNumberExtensionId));
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000134 } else {
stefan4fbd1452015-09-28 03:57:14 -0700135 remb = true;
stefan43edf0f2015-11-20 18:05:48 -0800136 transport_cc = false;
stefan4fbd1452015-09-28 03:57:14 -0700137 send_config->rtp.extensions.push_back(RtpExtension(
138 extension_type_.c_str(), kTransmissionTimeOffsetExtensionId));
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000139 }
stefan4fbd1452015-09-28 03:57:14 -0700140
141 send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs;
stefanff483612015-12-21 03:14:00 -0800142 send_config->rtp.ssrcs = video_ssrcs_;
stefan4fbd1452015-09-28 03:57:14 -0700143 if (rtx_) {
144 send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType;
stefanff483612015-12-21 03:14:00 -0800145 send_config->rtp.rtx.ssrcs = video_rtx_ssrcs_;
stefan4fbd1452015-09-28 03:57:14 -0700146 }
147 if (red_) {
148 send_config->rtp.fec.ulpfec_payload_type =
149 test::CallTest::kUlpfecPayloadType;
150 send_config->rtp.fec.red_payload_type = test::CallTest::kRedPayloadType;
151 }
152
153 size_t i = 0;
154 for (VideoReceiveStream::Config& recv_config : *receive_configs) {
155 recv_config.rtp.remb = remb;
stefan43edf0f2015-11-20 18:05:48 -0800156 recv_config.rtp.transport_cc = transport_cc;
stefan4fbd1452015-09-28 03:57:14 -0700157 recv_config.rtp.extensions = send_config->rtp.extensions;
158
stefanff483612015-12-21 03:14:00 -0800159 recv_config.rtp.remote_ssrc = video_ssrcs_[i];
stefan4fbd1452015-09-28 03:57:14 -0700160 recv_config.rtp.nack.rtp_history_ms = send_config->rtp.nack.rtp_history_ms;
161
162 if (red_) {
163 recv_config.rtp.fec.red_payload_type =
164 send_config->rtp.fec.red_payload_type;
165 recv_config.rtp.fec.ulpfec_payload_type =
166 send_config->rtp.fec.ulpfec_payload_type;
167 }
168
169 if (rtx_) {
170 recv_config.rtp.rtx[send_config->encoder_settings.payload_type].ssrc =
stefanff483612015-12-21 03:14:00 -0800171 video_rtx_ssrcs_[i];
stefan4fbd1452015-09-28 03:57:14 -0700172 recv_config.rtp.rtx[send_config->encoder_settings.payload_type]
173 .payload_type = send_config->rtp.rtx.payload_type;
174 }
175 ++i;
176 }
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000177}
178
Stefan Holmerff2a6352016-01-14 10:00:21 +0100179void RampUpTester::ModifyAudioConfigs(
180 AudioSendStream::Config* send_config,
181 std::vector<AudioReceiveStream::Config>* receive_configs) {
182 if (num_audio_streams_ == 0)
183 return;
184
isheriff6f8d6862016-05-26 11:24:55 -0700185 EXPECT_NE(RtpExtension::kTimestampOffsetUri, extension_type_)
Stefan Holmerff2a6352016-01-14 10:00:21 +0100186 << "Audio BWE not supported with toffset.";
187
188 send_config->rtp.ssrc = audio_ssrcs_[0];
189 send_config->rtp.extensions.clear();
190
191 bool transport_cc = false;
isheriff6f8d6862016-05-26 11:24:55 -0700192 if (extension_type_ == RtpExtension::kAbsSendTimeUri) {
Stefan Holmerff2a6352016-01-14 10:00:21 +0100193 transport_cc = false;
194 send_config->rtp.extensions.push_back(
195 RtpExtension(extension_type_.c_str(), kAbsSendTimeExtensionId));
isheriff6f8d6862016-05-26 11:24:55 -0700196 } else if (extension_type_ == RtpExtension::kTransportSequenceNumberUri) {
Stefan Holmerff2a6352016-01-14 10:00:21 +0100197 transport_cc = true;
198 send_config->rtp.extensions.push_back(RtpExtension(
199 extension_type_.c_str(), kTransportSequenceNumberExtensionId));
200 }
201
202 for (AudioReceiveStream::Config& recv_config : *receive_configs) {
Stefan Holmerff2a6352016-01-14 10:00:21 +0100203 recv_config.rtp.transport_cc = transport_cc;
204 recv_config.rtp.extensions = send_config->rtp.extensions;
205 recv_config.rtp.remote_ssrc = send_config->rtp.ssrc;
206 }
207}
208
stefan4fbd1452015-09-28 03:57:14 -0700209void RampUpTester::OnCallsCreated(Call* sender_call, Call* receiver_call) {
210 sender_call_ = sender_call;
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000211}
212
stefan4fbd1452015-09-28 03:57:14 -0700213bool RampUpTester::BitrateStatsPollingThread(void* obj) {
214 return static_cast<RampUpTester*>(obj)->PollStats();
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000215}
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000216
stefan4fbd1452015-09-28 03:57:14 -0700217bool RampUpTester::PollStats() {
218 if (sender_call_) {
219 Call::Stats stats = sender_call_->GetStats();
220
221 RTC_DCHECK_GT(expected_bitrate_bps_, 0);
222 if (!start_bitrate_verified_ && start_bitrate_bps_ != 0) {
223 // For tests with an explicitly set start bitrate, verify the first
224 // bitrate estimate is close to the start bitrate and lower than the
225 // test target bitrate. This is to verify a call respects the configured
226 // start bitrate, but due to the BWE implementation we can't guarantee the
227 // first estimate really is as high as the start bitrate.
228 EXPECT_GT(stats.send_bandwidth_bps, 0.9 * start_bitrate_bps_);
229 start_bitrate_verified_ = true;
230 }
231 if (stats.send_bandwidth_bps >= expected_bitrate_bps_) {
232 ramp_up_finished_ms_ = clock_->TimeInMilliseconds();
Peter Boström5811a392015-12-10 13:02:50 +0100233 observation_complete_.Set();
stefan4fbd1452015-09-28 03:57:14 -0700234 }
235 }
236
237 return !event_.Wait(kPollIntervalMs);
Erik Språng468e62a2015-07-06 10:50:47 +0200238}
239
stefan4fbd1452015-09-28 03:57:14 -0700240void RampUpTester::ReportResult(const std::string& measurement,
241 size_t value,
242 const std::string& units) const {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000243 webrtc::test::PrintResult(
244 measurement, "",
stefanff483612015-12-21 03:14:00 -0800245 ::testing::UnitTest::GetInstance()->current_test_info()->name(), value,
246 units, false);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000247}
248
stefan092508a2015-09-29 02:26:42 -0700249void RampUpTester::AccumulateStats(const VideoSendStream::StreamStats& stream,
250 size_t* total_packets_sent,
251 size_t* total_sent,
252 size_t* padding_sent,
253 size_t* media_sent) const {
stefan4fbd1452015-09-28 03:57:14 -0700254 *total_packets_sent += stream.rtp_stats.transmitted.packets +
255 stream.rtp_stats.retransmitted.packets +
256 stream.rtp_stats.fec.packets;
257 *total_sent += stream.rtp_stats.transmitted.TotalBytes() +
258 stream.rtp_stats.retransmitted.TotalBytes() +
259 stream.rtp_stats.fec.TotalBytes();
260 *padding_sent += stream.rtp_stats.transmitted.padding_bytes +
261 stream.rtp_stats.retransmitted.padding_bytes +
262 stream.rtp_stats.fec.padding_bytes;
263 *media_sent += stream.rtp_stats.MediaPayloadBytes();
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000264}
265
stefan4fbd1452015-09-28 03:57:14 -0700266void RampUpTester::TriggerTestDone() {
Erik Språngf3a7c9d2015-10-05 14:03:22 +0200267 RTC_DCHECK_GE(test_start_ms_, 0);
268
Stefan Holmerff2a6352016-01-14 10:00:21 +0100269 // TODO(holmer): Add audio send stats here too when those APIs are available.
stefan4fbd1452015-09-28 03:57:14 -0700270 VideoSendStream::Stats send_stats = send_stream_->GetStats();
271
272 size_t total_packets_sent = 0;
273 size_t total_sent = 0;
274 size_t padding_sent = 0;
275 size_t media_sent = 0;
stefanff483612015-12-21 03:14:00 -0800276 for (uint32_t ssrc : video_ssrcs_) {
stefan092508a2015-09-29 02:26:42 -0700277 AccumulateStats(send_stats.substreams[ssrc], &total_packets_sent,
278 &total_sent, &padding_sent, &media_sent);
stefan4fbd1452015-09-28 03:57:14 -0700279 }
280
281 size_t rtx_total_packets_sent = 0;
282 size_t rtx_total_sent = 0;
283 size_t rtx_padding_sent = 0;
284 size_t rtx_media_sent = 0;
stefanff483612015-12-21 03:14:00 -0800285 for (uint32_t rtx_ssrc : video_rtx_ssrcs_) {
stefan092508a2015-09-29 02:26:42 -0700286 AccumulateStats(send_stats.substreams[rtx_ssrc], &rtx_total_packets_sent,
287 &rtx_total_sent, &rtx_padding_sent, &rtx_media_sent);
stefan4fbd1452015-09-28 03:57:14 -0700288 }
289
290 ReportResult("ramp-up-total-packets-sent", total_packets_sent, "packets");
291 ReportResult("ramp-up-total-sent", total_sent, "bytes");
292 ReportResult("ramp-up-media-sent", media_sent, "bytes");
293 ReportResult("ramp-up-padding-sent", padding_sent, "bytes");
294 ReportResult("ramp-up-rtx-total-packets-sent", rtx_total_packets_sent,
295 "packets");
296 ReportResult("ramp-up-rtx-total-sent", rtx_total_sent, "bytes");
297 ReportResult("ramp-up-rtx-media-sent", rtx_media_sent, "bytes");
298 ReportResult("ramp-up-rtx-padding-sent", rtx_padding_sent, "bytes");
299 if (ramp_up_finished_ms_ >= 0) {
300 ReportResult("ramp-up-time", ramp_up_finished_ms_ - test_start_ms_,
301 "milliseconds");
302 }
Stefan Holmerff2a6352016-01-14 10:00:21 +0100303 ReportResult("ramp-up-average-network-latency",
304 send_transport_->GetAverageDelayMs(), "milliseconds");
stefan4fbd1452015-09-28 03:57:14 -0700305}
306
307void RampUpTester::PerformTest() {
Erik Språngf3a7c9d2015-10-05 14:03:22 +0200308 test_start_ms_ = clock_->TimeInMilliseconds();
Peter Boström8c38e8b2015-11-26 17:45:47 +0100309 poller_thread_.Start();
Peter Boström5811a392015-12-10 13:02:50 +0100310 EXPECT_TRUE(Wait()) << "Timed out while waiting for ramp-up to complete.";
stefan4fbd1452015-09-28 03:57:14 -0700311 TriggerTestDone();
Peter Boström8c38e8b2015-11-26 17:45:47 +0100312 poller_thread_.Stop();
stefan4fbd1452015-09-28 03:57:14 -0700313}
314
Stefan Holmerff2a6352016-01-14 10:00:21 +0100315RampUpDownUpTester::RampUpDownUpTester(size_t num_video_streams,
316 size_t num_audio_streams,
stefan4fbd1452015-09-28 03:57:14 -0700317 unsigned int start_bitrate_bps,
318 const std::string& extension_type,
319 bool rtx,
320 bool red)
Stefan Holmerff2a6352016-01-14 10:00:21 +0100321 : RampUpTester(num_video_streams,
322 num_audio_streams,
323 start_bitrate_bps,
324 extension_type,
325 rtx,
326 red),
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000327 test_state_(kFirstRampup),
328 state_start_ms_(clock_->TimeInMilliseconds()),
stefan4fbd1452015-09-28 03:57:14 -0700329 interval_start_ms_(clock_->TimeInMilliseconds()),
330 sent_bytes_(0) {
stefanff483612015-12-21 03:14:00 -0800331 forward_transport_config_.link_capacity_kbps = kHighBandwidthLimitBps / 1000;
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000332}
333
stefan4fbd1452015-09-28 03:57:14 -0700334RampUpDownUpTester::~RampUpDownUpTester() {}
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000335
stefan4fbd1452015-09-28 03:57:14 -0700336bool RampUpDownUpTester::PollStats() {
337 if (send_stream_) {
338 webrtc::VideoSendStream::Stats stats = send_stream_->GetStats();
339 int transmit_bitrate_bps = 0;
340 for (auto it : stats.substreams) {
341 transmit_bitrate_bps += it.second.total_bitrate_bps;
mflodman@webrtc.orgeb16b812014-06-16 08:57:39 +0000342 }
stefan4fbd1452015-09-28 03:57:14 -0700343
344 EvolveTestState(transmit_bitrate_bps, stats.suspended);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000345 }
stefan4fbd1452015-09-28 03:57:14 -0700346
347 return !event_.Wait(kPollIntervalMs);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000348}
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000349
stefan4fbd1452015-09-28 03:57:14 -0700350Call::Config RampUpDownUpTester::GetReceiverCallConfig() {
351 Call::Config config;
352 config.bitrate_config.min_bitrate_bps = 10000;
353 return config;
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000354}
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000355
stefan4fbd1452015-09-28 03:57:14 -0700356std::string RampUpDownUpTester::GetModifierString() const {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000357 std::string str("_");
stefanff483612015-12-21 03:14:00 -0800358 if (num_video_streams_ > 0) {
359 std::ostringstream s;
360 s << num_video_streams_;
361 str += s.str();
362 str += "stream";
363 str += (num_video_streams_ > 1 ? "s" : "");
364 str += "_";
365 }
366 if (num_audio_streams_ > 0) {
367 std::ostringstream s;
368 s << num_audio_streams_;
369 str += s.str();
370 str += "stream";
371 str += (num_audio_streams_ > 1 ? "s" : "");
372 str += "_";
373 }
stefan4fbd1452015-09-28 03:57:14 -0700374 str += (rtx_ ? "" : "no");
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000375 str += "rtx";
376 return str;
377}
andresp@webrtc.orgc1480792014-03-20 03:23:55 +0000378
stefan4fbd1452015-09-28 03:57:14 -0700379void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000380 int64_t now = clock_->TimeInMilliseconds();
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000381 switch (test_state_) {
382 case kFirstRampup: {
stefan4fbd1452015-09-28 03:57:14 -0700383 EXPECT_FALSE(suspended);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000384 if (bitrate_bps > kExpectedHighBitrateBps) {
385 // The first ramp-up has reached the target bitrate. Change the
386 // channel limit, and move to the next test state.
387 forward_transport_config_.link_capacity_kbps =
388 kLowBandwidthLimitBps / 1000;
stefanf116bd02015-10-27 08:29:42 -0700389 send_transport_->SetConfig(forward_transport_config_);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000390 test_state_ = kLowRate;
stefanff483612015-12-21 03:14:00 -0800391 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(),
392 "first_rampup", now - state_start_ms_, "ms",
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000393 false);
394 state_start_ms_ = now;
395 interval_start_ms_ = now;
396 sent_bytes_ = 0;
andresp@webrtc.orgc1480792014-03-20 03:23:55 +0000397 }
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000398 break;
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000399 }
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000400 case kLowRate: {
stefan4fbd1452015-09-28 03:57:14 -0700401 if (bitrate_bps < kExpectedLowBitrateBps && suspended) {
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000402 // The ramp-down was successful. Change the channel limit back to a
403 // high value, and move to the next test state.
404 forward_transport_config_.link_capacity_kbps =
405 kHighBandwidthLimitBps / 1000;
stefanf116bd02015-10-27 08:29:42 -0700406 send_transport_->SetConfig(forward_transport_config_);
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000407 test_state_ = kSecondRampup;
stefanff483612015-12-21 03:14:00 -0800408 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(),
409 "rampdown", now - state_start_ms_, "ms",
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000410 false);
411 state_start_ms_ = now;
412 interval_start_ms_ = now;
413 sent_bytes_ = 0;
414 }
415 break;
416 }
417 case kSecondRampup: {
stefan4fbd1452015-09-28 03:57:14 -0700418 if (bitrate_bps > kExpectedHighBitrateBps && !suspended) {
stefanff483612015-12-21 03:14:00 -0800419 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(),
420 "second_rampup", now - state_start_ms_, "ms",
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000421 false);
Stefan Holmerff2a6352016-01-14 10:00:21 +0100422 ReportResult("ramp-up-down-up-average-network-latency",
423 send_transport_->GetAverageDelayMs(), "milliseconds");
Peter Boström5811a392015-12-10 13:02:50 +0100424 observation_complete_.Set();
stefan@webrtc.org3d7da882014-07-08 13:59:46 +0000425 }
426 break;
427 }
428 }
429}
pbos@webrtc.orgf577ae92014-03-19 08:43:57 +0000430
stefan4fbd1452015-09-28 03:57:14 -0700431class RampUpTest : public test::CallTest {
Erik Språng6b8d3552015-09-24 15:06:57 +0200432 public:
stefan4fbd1452015-09-28 03:57:14 -0700433 RampUpTest() {}
Erik Språng6b8d3552015-09-24 15:06:57 +0200434
stefan4fbd1452015-09-28 03:57:14 -0700435 virtual ~RampUpTest() {
stefanff483612015-12-21 03:14:00 -0800436 EXPECT_EQ(nullptr, video_send_stream_);
437 EXPECT_TRUE(video_receive_streams_.empty());
Erik Språng6b8d3552015-09-24 15:06:57 +0200438 }
Erik Språng6b8d3552015-09-24 15:06:57 +0200439};
440
stefan@webrtc.orgcb254aa2014-06-12 15:12:25 +0000441TEST_F(RampUpTest, SingleStream) {
isheriff6f8d6862016-05-26 11:24:55 -0700442 RampUpTester test(1, 0, 0, RtpExtension::kTimestampOffsetUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800443 RunBaseTest(&test);
andresp@webrtc.orgc1480792014-03-20 03:23:55 +0000444}
pbos@webrtc.org744fbc72013-09-10 09:26:25 +0000445
stefan@webrtc.orgcb254aa2014-06-12 15:12:25 +0000446TEST_F(RampUpTest, Simulcast) {
isheriff6f8d6862016-05-26 11:24:55 -0700447 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800448 RunBaseTest(&test);
andresp@webrtc.orgc1480792014-03-20 03:23:55 +0000449}
450
stefan@webrtc.orgcb254aa2014-06-12 15:12:25 +0000451TEST_F(RampUpTest, SimulcastWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700452 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, true, false);
stefane74eef12016-01-08 06:47:13 -0800453 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800454}
455
456TEST_F(RampUpTest, SimulcastByRedWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700457 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, true, true);
stefane74eef12016-01-08 06:47:13 -0800458 RunBaseTest(&test);
mflodman@webrtc.orgeb16b812014-06-16 08:57:39 +0000459}
460
461TEST_F(RampUpTest, SingleStreamWithHighStartBitrate) {
isheriff6f8d6862016-05-26 11:24:55 -0700462 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps,
463 RtpExtension::kTimestampOffsetUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800464 RunBaseTest(&test);
andresp@webrtc.orgc1480792014-03-20 03:23:55 +0000465}
pbos@webrtc.org744fbc72013-09-10 09:26:25 +0000466
kjellanderf1685c72016-01-08 10:43:41 -0800467// Disabled on Mac due to flakiness, see
468// https://bugs.chromium.org/p/webrtc/issues/detail?id=5407
469#ifndef WEBRTC_MAC
Stefan Holmerff2a6352016-01-14 10:00:21 +0100470
471static const uint32_t kStartBitrateBps = 60000;
472
philipelf4d84412016-02-23 18:56:36 +0100473// Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576
474TEST_F(RampUpTest, DISABLED_UpDownUpOneStream) {
isheriff6f8d6862016-05-26 11:24:55 -0700475 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100476 false, false);
stefane74eef12016-01-08 06:47:13 -0800477 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800478}
henrik.lundin@webrtc.org845862f2014-03-06 07:19:28 +0000479
Shao Changbine62202f2015-04-21 20:24:50 +0800480TEST_F(RampUpTest, UpDownUpThreeStreams) {
isheriff6f8d6862016-05-26 11:24:55 -0700481 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100482 false, false);
stefane74eef12016-01-08 06:47:13 -0800483 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800484}
henrik.lundin@webrtc.org998cb8f2014-03-06 09:12:00 +0000485
philipelf4d84412016-02-23 18:56:36 +0100486// Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576
487TEST_F(RampUpTest, DISABLED_UpDownUpOneStreamRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700488 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100489 true, false);
stefane74eef12016-01-08 06:47:13 -0800490 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800491}
henrik.lundin@webrtc.org998cb8f2014-03-06 09:12:00 +0000492
Shao Changbine62202f2015-04-21 20:24:50 +0800493TEST_F(RampUpTest, UpDownUpThreeStreamsRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700494 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100495 true, false);
stefane74eef12016-01-08 06:47:13 -0800496 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800497}
498
philipelf4d84412016-02-23 18:56:36 +0100499// Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576
500TEST_F(RampUpTest, DISABLED_UpDownUpOneStreamByRedRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700501 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100502 true, true);
stefane74eef12016-01-08 06:47:13 -0800503 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800504}
505
506TEST_F(RampUpTest, UpDownUpThreeStreamsByRedRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700507 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100508 true, true);
stefane74eef12016-01-08 06:47:13 -0800509 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800510}
Stefan Holmerff2a6352016-01-14 10:00:21 +0100511
512TEST_F(RampUpTest, SendSideVideoUpDownUpRtx) {
513 RampUpDownUpTester test(3, 0, kStartBitrateBps,
isheriff6f8d6862016-05-26 11:24:55 -0700514 RtpExtension::kTransportSequenceNumberUri, true,
515 false);
Stefan Holmerff2a6352016-01-14 10:00:21 +0100516 RunBaseTest(&test);
517}
518
519// TODO(holmer): Enable when audio bitrates are included in the bitrate
520// allocation.
521TEST_F(RampUpTest, DISABLED_SendSideAudioVideoUpDownUpRtx) {
522 RampUpDownUpTester test(3, 1, kStartBitrateBps,
isheriff6f8d6862016-05-26 11:24:55 -0700523 RtpExtension::kTransportSequenceNumberUri, true,
524 false);
Stefan Holmerff2a6352016-01-14 10:00:21 +0100525 RunBaseTest(&test);
526}
527
kjellanderf1685c72016-01-08 10:43:41 -0800528#endif
henrik.lundin@webrtc.org845862f2014-03-06 07:19:28 +0000529
pbos@webrtc.org85bd53e2014-12-10 10:36:20 +0000530TEST_F(RampUpTest, AbsSendTimeSingleStream) {
isheriff6f8d6862016-05-26 11:24:55 -0700531 RampUpTester test(1, 0, 0, RtpExtension::kAbsSendTimeUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800532 RunBaseTest(&test);
pbos@webrtc.org85bd53e2014-12-10 10:36:20 +0000533}
534
535TEST_F(RampUpTest, AbsSendTimeSimulcast) {
isheriff6f8d6862016-05-26 11:24:55 -0700536 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800537 RunBaseTest(&test);
pbos@webrtc.org85bd53e2014-12-10 10:36:20 +0000538}
539
540TEST_F(RampUpTest, AbsSendTimeSimulcastWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700541 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, true, false);
stefane74eef12016-01-08 06:47:13 -0800542 RunBaseTest(&test);
Shao Changbine62202f2015-04-21 20:24:50 +0800543}
544
545TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700546 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, true, true);
stefane74eef12016-01-08 06:47:13 -0800547 RunBaseTest(&test);
pbos@webrtc.org85bd53e2014-12-10 10:36:20 +0000548}
549
550TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) {
stefanff483612015-12-21 03:14:00 -0800551 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps,
isheriff6f8d6862016-05-26 11:24:55 -0700552 RtpExtension::kAbsSendTimeUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800553 RunBaseTest(&test);
pbos@webrtc.org85bd53e2014-12-10 10:36:20 +0000554}
Erik Språng6b8d3552015-09-24 15:06:57 +0200555
556TEST_F(RampUpTest, TransportSequenceNumberSingleStream) {
isheriff6f8d6862016-05-26 11:24:55 -0700557 RampUpTester test(1, 0, 0, RtpExtension::kTransportSequenceNumberUri, false,
stefanff483612015-12-21 03:14:00 -0800558 false);
stefane74eef12016-01-08 06:47:13 -0800559 RunBaseTest(&test);
Erik Språng6b8d3552015-09-24 15:06:57 +0200560}
561
562TEST_F(RampUpTest, TransportSequenceNumberSimulcast) {
isheriff6f8d6862016-05-26 11:24:55 -0700563 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, false,
stefanff483612015-12-21 03:14:00 -0800564 false);
stefane74eef12016-01-08 06:47:13 -0800565 RunBaseTest(&test);
Erik Språng6b8d3552015-09-24 15:06:57 +0200566}
567
568TEST_F(RampUpTest, TransportSequenceNumberSimulcastWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700569 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, true,
stefanff483612015-12-21 03:14:00 -0800570 false);
stefane74eef12016-01-08 06:47:13 -0800571 RunBaseTest(&test);
Erik Språng6b8d3552015-09-24 15:06:57 +0200572}
573
Stefan Holmerff2a6352016-01-14 10:00:21 +0100574TEST_F(RampUpTest, AudioVideoTransportSequenceNumberSimulcastWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700575 RampUpTester test(3, 1, 0, RtpExtension::kTransportSequenceNumberUri, true,
Stefan Holmerff2a6352016-01-14 10:00:21 +0100576 false);
577 RunBaseTest(&test);
578}
579
Erik Språng6b8d3552015-09-24 15:06:57 +0200580TEST_F(RampUpTest, TransportSequenceNumberSimulcastByRedWithRtx) {
isheriff6f8d6862016-05-26 11:24:55 -0700581 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, true,
stefanff483612015-12-21 03:14:00 -0800582 true);
stefane74eef12016-01-08 06:47:13 -0800583 RunBaseTest(&test);
Erik Språng6b8d3552015-09-24 15:06:57 +0200584}
585
586TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) {
stefanff483612015-12-21 03:14:00 -0800587 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps,
isheriff6f8d6862016-05-26 11:24:55 -0700588 RtpExtension::kTransportSequenceNumberUri, false, false);
stefane74eef12016-01-08 06:47:13 -0800589 RunBaseTest(&test);
Erik Språng6b8d3552015-09-24 15:06:57 +0200590}
pbos@webrtc.org744fbc72013-09-10 09:26:25 +0000591} // namespace webrtc