| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/call/rampup_tests.h" |
| 12 |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
| 13 #include "webrtc/base/common.h" | |
| 14 #include "webrtc/base/event.h" | |
| 15 #include "webrtc/base/platform_thread.h" | 15 #include "webrtc/base/platform_thread.h" |
| 16 #include "webrtc/modules/pacing/packet_router.h" | |
| 17 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | |
| 18 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | |
| 19 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | |
| 20 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | |
| 21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
| 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | |
| 26 #include "webrtc/test/testsupport/perf_test.h" | 16 #include "webrtc/test/testsupport/perf_test.h" |
| 27 #include "webrtc/video/rampup_tests.h" | |
| 28 | 17 |
| 29 namespace webrtc { | 18 namespace webrtc { |
| 30 namespace { | 19 namespace { |
| 31 | 20 |
| 32 static const int64_t kPollIntervalMs = 20; | 21 static const int64_t kPollIntervalMs = 20; |
| 33 | 22 |
| 34 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, | 23 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { |
| 35 uint32_t ssrc_offset) { | |
| 36 std::vector<uint32_t> ssrcs; | 24 std::vector<uint32_t> ssrcs; |
| 37 for (size_t i = 0; i != num_streams; ++i) | 25 for (size_t i = 0; i != num_streams; ++i) |
| 38 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); | 26 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); |
| 39 return ssrcs; | 27 return ssrcs; |
| 40 } | 28 } |
| 41 } // namespace | 29 } // namespace |
| 42 | 30 |
| 43 RampUpTester::RampUpTester(size_t num_streams, | 31 RampUpTester::RampUpTester(size_t num_video_streams, |
| 32 size_t num_audio_streams, |
| 44 unsigned int start_bitrate_bps, | 33 unsigned int start_bitrate_bps, |
| 45 const std::string& extension_type, | 34 const std::string& extension_type, |
| 46 bool rtx, | 35 bool rtx, |
| 47 bool red) | 36 bool red) |
| 48 : EndToEndTest(test::CallTest::kLongTimeoutMs), | 37 : EndToEndTest(test::CallTest::kLongTimeoutMs), |
| 49 event_(false, false), | 38 event_(false, false), |
| 50 clock_(Clock::GetRealTimeClock()), | 39 clock_(Clock::GetRealTimeClock()), |
| 51 num_streams_(num_streams), | 40 num_video_streams_(num_video_streams), |
| 41 num_audio_streams_(num_audio_streams), |
| 52 rtx_(rtx), | 42 rtx_(rtx), |
| 53 red_(red), | 43 red_(red), |
| 54 send_stream_(nullptr), | 44 send_stream_(nullptr), |
| 55 start_bitrate_bps_(start_bitrate_bps), | 45 start_bitrate_bps_(start_bitrate_bps), |
| 56 start_bitrate_verified_(false), | 46 start_bitrate_verified_(false), |
| 57 expected_bitrate_bps_(0), | 47 expected_bitrate_bps_(0), |
| 58 test_start_ms_(-1), | 48 test_start_ms_(-1), |
| 59 ramp_up_finished_ms_(-1), | 49 ramp_up_finished_ms_(-1), |
| 60 extension_type_(extension_type), | 50 extension_type_(extension_type), |
| 61 ssrcs_(GenerateSsrcs(num_streams, 100)), | 51 video_ssrcs_(GenerateSsrcs(num_video_streams_, 100)), |
| 62 rtx_ssrcs_(GenerateSsrcs(num_streams, 200)), | 52 video_rtx_ssrcs_(GenerateSsrcs(num_video_streams_, 200)), |
| 53 audio_ssrcs_(GenerateSsrcs(num_audio_streams_, 300)), |
| 63 poller_thread_(&BitrateStatsPollingThread, | 54 poller_thread_(&BitrateStatsPollingThread, |
| 64 this, | 55 this, |
| 65 "BitrateStatsPollingThread"), | 56 "BitrateStatsPollingThread"), |
| 66 sender_call_(nullptr) { | 57 sender_call_(nullptr) { |
| 67 if (rtx_) { | 58 if (rtx_) { |
| 68 for (size_t i = 0; i < ssrcs_.size(); ++i) | 59 for (size_t i = 0; i < video_ssrcs_.size(); ++i) |
| 69 rtx_ssrc_map_[rtx_ssrcs_[i]] = ssrcs_[i]; | 60 rtx_ssrc_map_[video_rtx_ssrcs_[i]] = video_ssrcs_[i]; |
| 70 } | 61 } |
| 71 } | 62 } |
| 72 | 63 |
| 73 RampUpTester::~RampUpTester() { | 64 RampUpTester::~RampUpTester() { |
| 74 event_.Set(); | 65 event_.Set(); |
| 75 } | 66 } |
| 76 | 67 |
| 77 Call::Config RampUpTester::GetSenderCallConfig() { | 68 Call::Config RampUpTester::GetSenderCallConfig() { |
| 78 Call::Config call_config; | 69 Call::Config call_config; |
| 79 if (start_bitrate_bps_ != 0) { | 70 if (start_bitrate_bps_ != 0) { |
| 80 call_config.bitrate_config.start_bitrate_bps = start_bitrate_bps_; | 71 call_config.bitrate_config.start_bitrate_bps = start_bitrate_bps_; |
| 81 } | 72 } |
| 82 call_config.bitrate_config.min_bitrate_bps = 10000; | 73 call_config.bitrate_config.min_bitrate_bps = 10000; |
| 83 return call_config; | 74 return call_config; |
| 84 } | 75 } |
| 85 | 76 |
| 86 void RampUpTester::OnStreamsCreated( | 77 void RampUpTester::OnVideoStreamsCreated( |
| 87 VideoSendStream* send_stream, | 78 VideoSendStream* send_stream, |
| 88 const std::vector<VideoReceiveStream*>& receive_streams) { | 79 const std::vector<VideoReceiveStream*>& receive_streams) { |
| 89 send_stream_ = send_stream; | 80 send_stream_ = send_stream; |
| 90 } | 81 } |
| 91 | 82 |
| 92 void RampUpTester::OnTransportsCreated( | 83 void RampUpTester::OnTransportsCreated( |
| 93 test::PacketTransport* send_transport, | 84 test::PacketTransport* send_transport, |
| 94 test::PacketTransport* receive_transport) { | 85 test::PacketTransport* receive_transport) { |
| 95 send_transport_ = send_transport; | 86 send_transport_ = send_transport; |
| 96 send_transport_->SetConfig(forward_transport_config_); | 87 send_transport_->SetConfig(forward_transport_config_); |
| 97 } | 88 } |
| 98 | 89 |
| 99 size_t RampUpTester::GetNumStreams() const { | 90 void RampUpTester::ModifyVideoConfigs( |
| 100 return num_streams_; | |
| 101 } | |
| 102 | |
| 103 void RampUpTester::ModifyConfigs( | |
| 104 VideoSendStream::Config* send_config, | 91 VideoSendStream::Config* send_config, |
| 105 std::vector<VideoReceiveStream::Config>* receive_configs, | 92 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 106 VideoEncoderConfig* encoder_config) { | 93 VideoEncoderConfig* encoder_config) { |
| 107 send_config->suspend_below_min_bitrate = true; | 94 send_config->suspend_below_min_bitrate = true; |
| 108 | 95 |
| 109 if (num_streams_ == 1) { | 96 if (num_video_streams_ == 1) { |
| 110 encoder_config->streams[0].target_bitrate_bps = | 97 encoder_config->streams[0].target_bitrate_bps = |
| 111 encoder_config->streams[0].max_bitrate_bps = 2000000; | 98 encoder_config->streams[0].max_bitrate_bps = 2000000; |
| 112 // For single stream rampup until 1mbps | 99 // For single stream rampup until 1mbps |
| 113 expected_bitrate_bps_ = kSingleStreamTargetBps; | 100 expected_bitrate_bps_ = kSingleStreamTargetBps; |
| 114 } else { | 101 } else { |
| 115 // For multi stream rampup until all streams are being sent. That means | 102 // For multi stream rampup until all streams are being sent. That means |
| 116 // enough birate to send all the target streams plus the min bitrate of | 103 // enough birate to send all the target streams plus the min bitrate of |
| 117 // the last one. | 104 // the last one. |
| 118 expected_bitrate_bps_ = encoder_config->streams.back().min_bitrate_bps; | 105 expected_bitrate_bps_ = encoder_config->streams.back().min_bitrate_bps; |
| 119 for (size_t i = 0; i < encoder_config->streams.size() - 1; ++i) { | 106 for (size_t i = 0; i < encoder_config->streams.size() - 1; ++i) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 send_config->rtp.extensions.push_back(RtpExtension( | 123 send_config->rtp.extensions.push_back(RtpExtension( |
| 137 extension_type_.c_str(), kTransportSequenceNumberExtensionId)); | 124 extension_type_.c_str(), kTransportSequenceNumberExtensionId)); |
| 138 } else { | 125 } else { |
| 139 remb = true; | 126 remb = true; |
| 140 transport_cc = false; | 127 transport_cc = false; |
| 141 send_config->rtp.extensions.push_back(RtpExtension( | 128 send_config->rtp.extensions.push_back(RtpExtension( |
| 142 extension_type_.c_str(), kTransmissionTimeOffsetExtensionId)); | 129 extension_type_.c_str(), kTransmissionTimeOffsetExtensionId)); |
| 143 } | 130 } |
| 144 | 131 |
| 145 send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs; | 132 send_config->rtp.nack.rtp_history_ms = test::CallTest::kNackRtpHistoryMs; |
| 146 send_config->rtp.ssrcs = ssrcs_; | 133 send_config->rtp.ssrcs = video_ssrcs_; |
| 147 if (rtx_) { | 134 if (rtx_) { |
| 148 send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType; | 135 send_config->rtp.rtx.payload_type = test::CallTest::kSendRtxPayloadType; |
| 149 send_config->rtp.rtx.ssrcs = rtx_ssrcs_; | 136 send_config->rtp.rtx.ssrcs = video_rtx_ssrcs_; |
| 150 } | 137 } |
| 151 if (red_) { | 138 if (red_) { |
| 152 send_config->rtp.fec.ulpfec_payload_type = | 139 send_config->rtp.fec.ulpfec_payload_type = |
| 153 test::CallTest::kUlpfecPayloadType; | 140 test::CallTest::kUlpfecPayloadType; |
| 154 send_config->rtp.fec.red_payload_type = test::CallTest::kRedPayloadType; | 141 send_config->rtp.fec.red_payload_type = test::CallTest::kRedPayloadType; |
| 155 } | 142 } |
| 156 | 143 |
| 157 size_t i = 0; | 144 size_t i = 0; |
| 158 for (VideoReceiveStream::Config& recv_config : *receive_configs) { | 145 for (VideoReceiveStream::Config& recv_config : *receive_configs) { |
| 159 recv_config.rtp.remb = remb; | 146 recv_config.rtp.remb = remb; |
| 160 recv_config.rtp.transport_cc = transport_cc; | 147 recv_config.rtp.transport_cc = transport_cc; |
| 161 recv_config.rtp.extensions = send_config->rtp.extensions; | 148 recv_config.rtp.extensions = send_config->rtp.extensions; |
| 162 | 149 |
| 163 recv_config.rtp.remote_ssrc = ssrcs_[i]; | 150 recv_config.rtp.remote_ssrc = video_ssrcs_[i]; |
| 164 recv_config.rtp.nack.rtp_history_ms = send_config->rtp.nack.rtp_history_ms; | 151 recv_config.rtp.nack.rtp_history_ms = send_config->rtp.nack.rtp_history_ms; |
| 165 | 152 |
| 166 if (red_) { | 153 if (red_) { |
| 167 recv_config.rtp.fec.red_payload_type = | 154 recv_config.rtp.fec.red_payload_type = |
| 168 send_config->rtp.fec.red_payload_type; | 155 send_config->rtp.fec.red_payload_type; |
| 169 recv_config.rtp.fec.ulpfec_payload_type = | 156 recv_config.rtp.fec.ulpfec_payload_type = |
| 170 send_config->rtp.fec.ulpfec_payload_type; | 157 send_config->rtp.fec.ulpfec_payload_type; |
| 171 } | 158 } |
| 172 | 159 |
| 173 if (rtx_) { | 160 if (rtx_) { |
| 174 recv_config.rtp.rtx[send_config->encoder_settings.payload_type].ssrc = | 161 recv_config.rtp.rtx[send_config->encoder_settings.payload_type].ssrc = |
| 175 rtx_ssrcs_[i]; | 162 video_rtx_ssrcs_[i]; |
| 176 recv_config.rtp.rtx[send_config->encoder_settings.payload_type] | 163 recv_config.rtp.rtx[send_config->encoder_settings.payload_type] |
| 177 .payload_type = send_config->rtp.rtx.payload_type; | 164 .payload_type = send_config->rtp.rtx.payload_type; |
| 178 } | 165 } |
| 179 ++i; | 166 ++i; |
| 180 } | 167 } |
| 181 } | 168 } |
| 182 | 169 |
| 183 void RampUpTester::OnCallsCreated(Call* sender_call, Call* receiver_call) { | 170 void RampUpTester::OnCallsCreated(Call* sender_call, Call* receiver_call) { |
| 184 sender_call_ = sender_call; | 171 sender_call_ = sender_call; |
| 185 } | 172 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 209 } | 196 } |
| 210 | 197 |
| 211 return !event_.Wait(kPollIntervalMs); | 198 return !event_.Wait(kPollIntervalMs); |
| 212 } | 199 } |
| 213 | 200 |
| 214 void RampUpTester::ReportResult(const std::string& measurement, | 201 void RampUpTester::ReportResult(const std::string& measurement, |
| 215 size_t value, | 202 size_t value, |
| 216 const std::string& units) const { | 203 const std::string& units) const { |
| 217 webrtc::test::PrintResult( | 204 webrtc::test::PrintResult( |
| 218 measurement, "", | 205 measurement, "", |
| 219 ::testing::UnitTest::GetInstance()->current_test_info()->name(), | 206 ::testing::UnitTest::GetInstance()->current_test_info()->name(), value, |
| 220 value, units, false); | 207 units, false); |
| 221 } | 208 } |
| 222 | 209 |
| 223 void RampUpTester::AccumulateStats(const VideoSendStream::StreamStats& stream, | 210 void RampUpTester::AccumulateStats(const VideoSendStream::StreamStats& stream, |
| 224 size_t* total_packets_sent, | 211 size_t* total_packets_sent, |
| 225 size_t* total_sent, | 212 size_t* total_sent, |
| 226 size_t* padding_sent, | 213 size_t* padding_sent, |
| 227 size_t* media_sent) const { | 214 size_t* media_sent) const { |
| 228 *total_packets_sent += stream.rtp_stats.transmitted.packets + | 215 *total_packets_sent += stream.rtp_stats.transmitted.packets + |
| 229 stream.rtp_stats.retransmitted.packets + | 216 stream.rtp_stats.retransmitted.packets + |
| 230 stream.rtp_stats.fec.packets; | 217 stream.rtp_stats.fec.packets; |
| 231 *total_sent += stream.rtp_stats.transmitted.TotalBytes() + | 218 *total_sent += stream.rtp_stats.transmitted.TotalBytes() + |
| 232 stream.rtp_stats.retransmitted.TotalBytes() + | 219 stream.rtp_stats.retransmitted.TotalBytes() + |
| 233 stream.rtp_stats.fec.TotalBytes(); | 220 stream.rtp_stats.fec.TotalBytes(); |
| 234 *padding_sent += stream.rtp_stats.transmitted.padding_bytes + | 221 *padding_sent += stream.rtp_stats.transmitted.padding_bytes + |
| 235 stream.rtp_stats.retransmitted.padding_bytes + | 222 stream.rtp_stats.retransmitted.padding_bytes + |
| 236 stream.rtp_stats.fec.padding_bytes; | 223 stream.rtp_stats.fec.padding_bytes; |
| 237 *media_sent += stream.rtp_stats.MediaPayloadBytes(); | 224 *media_sent += stream.rtp_stats.MediaPayloadBytes(); |
| 238 } | 225 } |
| 239 | 226 |
| 240 void RampUpTester::TriggerTestDone() { | 227 void RampUpTester::TriggerTestDone() { |
| 241 RTC_DCHECK_GE(test_start_ms_, 0); | 228 RTC_DCHECK_GE(test_start_ms_, 0); |
| 242 | 229 |
| 243 VideoSendStream::Stats send_stats = send_stream_->GetStats(); | 230 VideoSendStream::Stats send_stats = send_stream_->GetStats(); |
| 244 | 231 |
| 245 size_t total_packets_sent = 0; | 232 size_t total_packets_sent = 0; |
| 246 size_t total_sent = 0; | 233 size_t total_sent = 0; |
| 247 size_t padding_sent = 0; | 234 size_t padding_sent = 0; |
| 248 size_t media_sent = 0; | 235 size_t media_sent = 0; |
| 249 for (uint32_t ssrc : ssrcs_) { | 236 for (uint32_t ssrc : video_ssrcs_) { |
| 250 AccumulateStats(send_stats.substreams[ssrc], &total_packets_sent, | 237 AccumulateStats(send_stats.substreams[ssrc], &total_packets_sent, |
| 251 &total_sent, &padding_sent, &media_sent); | 238 &total_sent, &padding_sent, &media_sent); |
| 252 } | 239 } |
| 253 | 240 |
| 254 size_t rtx_total_packets_sent = 0; | 241 size_t rtx_total_packets_sent = 0; |
| 255 size_t rtx_total_sent = 0; | 242 size_t rtx_total_sent = 0; |
| 256 size_t rtx_padding_sent = 0; | 243 size_t rtx_padding_sent = 0; |
| 257 size_t rtx_media_sent = 0; | 244 size_t rtx_media_sent = 0; |
| 258 for (uint32_t rtx_ssrc : rtx_ssrcs_) { | 245 for (uint32_t rtx_ssrc : video_rtx_ssrcs_) { |
| 259 AccumulateStats(send_stats.substreams[rtx_ssrc], &rtx_total_packets_sent, | 246 AccumulateStats(send_stats.substreams[rtx_ssrc], &rtx_total_packets_sent, |
| 260 &rtx_total_sent, &rtx_padding_sent, &rtx_media_sent); | 247 &rtx_total_sent, &rtx_padding_sent, &rtx_media_sent); |
| 261 } | 248 } |
| 262 | 249 |
| 263 ReportResult("ramp-up-total-packets-sent", total_packets_sent, "packets"); | 250 ReportResult("ramp-up-total-packets-sent", total_packets_sent, "packets"); |
| 264 ReportResult("ramp-up-total-sent", total_sent, "bytes"); | 251 ReportResult("ramp-up-total-sent", total_sent, "bytes"); |
| 265 ReportResult("ramp-up-media-sent", media_sent, "bytes"); | 252 ReportResult("ramp-up-media-sent", media_sent, "bytes"); |
| 266 ReportResult("ramp-up-padding-sent", padding_sent, "bytes"); | 253 ReportResult("ramp-up-padding-sent", padding_sent, "bytes"); |
| 267 ReportResult("ramp-up-rtx-total-packets-sent", rtx_total_packets_sent, | 254 ReportResult("ramp-up-rtx-total-packets-sent", rtx_total_packets_sent, |
| 268 "packets"); | 255 "packets"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 281 EXPECT_TRUE(Wait()) << "Timed out while waiting for ramp-up to complete."; | 268 EXPECT_TRUE(Wait()) << "Timed out while waiting for ramp-up to complete."; |
| 282 TriggerTestDone(); | 269 TriggerTestDone(); |
| 283 poller_thread_.Stop(); | 270 poller_thread_.Stop(); |
| 284 } | 271 } |
| 285 | 272 |
| 286 RampUpDownUpTester::RampUpDownUpTester(size_t num_streams, | 273 RampUpDownUpTester::RampUpDownUpTester(size_t num_streams, |
| 287 unsigned int start_bitrate_bps, | 274 unsigned int start_bitrate_bps, |
| 288 const std::string& extension_type, | 275 const std::string& extension_type, |
| 289 bool rtx, | 276 bool rtx, |
| 290 bool red) | 277 bool red) |
| 291 : RampUpTester(num_streams, start_bitrate_bps, extension_type, rtx, red), | 278 : RampUpTester(num_streams, 0, start_bitrate_bps, extension_type, rtx, red), |
| 292 test_state_(kFirstRampup), | 279 test_state_(kFirstRampup), |
| 293 state_start_ms_(clock_->TimeInMilliseconds()), | 280 state_start_ms_(clock_->TimeInMilliseconds()), |
| 294 interval_start_ms_(clock_->TimeInMilliseconds()), | 281 interval_start_ms_(clock_->TimeInMilliseconds()), |
| 295 sent_bytes_(0) { | 282 sent_bytes_(0) { |
| 296 forward_transport_config_.link_capacity_kbps = | 283 forward_transport_config_.link_capacity_kbps = kHighBandwidthLimitBps / 1000; |
| 297 kHighBandwidthLimitBps / 1000; | |
| 298 } | 284 } |
| 299 | 285 |
| 300 RampUpDownUpTester::~RampUpDownUpTester() {} | 286 RampUpDownUpTester::~RampUpDownUpTester() {} |
| 301 | 287 |
| 302 bool RampUpDownUpTester::PollStats() { | 288 bool RampUpDownUpTester::PollStats() { |
| 303 if (send_stream_) { | 289 if (send_stream_) { |
| 304 webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); | 290 webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); |
| 305 int transmit_bitrate_bps = 0; | 291 int transmit_bitrate_bps = 0; |
| 306 for (auto it : stats.substreams) { | 292 for (auto it : stats.substreams) { |
| 307 transmit_bitrate_bps += it.second.total_bitrate_bps; | 293 transmit_bitrate_bps += it.second.total_bitrate_bps; |
| 308 } | 294 } |
| 309 | 295 |
| 310 EvolveTestState(transmit_bitrate_bps, stats.suspended); | 296 EvolveTestState(transmit_bitrate_bps, stats.suspended); |
| 311 } | 297 } |
| 312 | 298 |
| 313 return !event_.Wait(kPollIntervalMs); | 299 return !event_.Wait(kPollIntervalMs); |
| 314 } | 300 } |
| 315 | 301 |
| 316 Call::Config RampUpDownUpTester::GetReceiverCallConfig() { | 302 Call::Config RampUpDownUpTester::GetReceiverCallConfig() { |
| 317 Call::Config config; | 303 Call::Config config; |
| 318 config.bitrate_config.min_bitrate_bps = 10000; | 304 config.bitrate_config.min_bitrate_bps = 10000; |
| 319 return config; | 305 return config; |
| 320 } | 306 } |
| 321 | 307 |
| 322 std::string RampUpDownUpTester::GetModifierString() const { | 308 std::string RampUpDownUpTester::GetModifierString() const { |
| 323 std::string str("_"); | 309 std::string str("_"); |
| 324 std::ostringstream s; | 310 if (num_video_streams_ > 0) { |
| 325 s << num_streams_; | 311 std::ostringstream s; |
| 326 str += s.str(); | 312 s << num_video_streams_; |
| 327 str += "stream"; | 313 str += s.str(); |
| 328 str += (num_streams_ > 1 ? "s" : ""); | 314 str += "stream"; |
| 329 str += "_"; | 315 str += (num_video_streams_ > 1 ? "s" : ""); |
| 316 str += "_"; |
| 317 } |
| 318 if (num_audio_streams_ > 0) { |
| 319 std::ostringstream s; |
| 320 s << num_audio_streams_; |
| 321 str += s.str(); |
| 322 str += "stream"; |
| 323 str += (num_audio_streams_ > 1 ? "s" : ""); |
| 324 str += "_"; |
| 325 } |
| 330 str += (rtx_ ? "" : "no"); | 326 str += (rtx_ ? "" : "no"); |
| 331 str += "rtx"; | 327 str += "rtx"; |
| 332 return str; | 328 return str; |
| 333 } | 329 } |
| 334 | 330 |
| 335 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { | 331 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { |
| 336 int64_t now = clock_->TimeInMilliseconds(); | 332 int64_t now = clock_->TimeInMilliseconds(); |
| 337 switch (test_state_) { | 333 switch (test_state_) { |
| 338 case kFirstRampup: { | 334 case kFirstRampup: { |
| 339 EXPECT_FALSE(suspended); | 335 EXPECT_FALSE(suspended); |
| 340 if (bitrate_bps > kExpectedHighBitrateBps) { | 336 if (bitrate_bps > kExpectedHighBitrateBps) { |
| 341 // The first ramp-up has reached the target bitrate. Change the | 337 // The first ramp-up has reached the target bitrate. Change the |
| 342 // channel limit, and move to the next test state. | 338 // channel limit, and move to the next test state. |
| 343 forward_transport_config_.link_capacity_kbps = | 339 forward_transport_config_.link_capacity_kbps = |
| 344 kLowBandwidthLimitBps / 1000; | 340 kLowBandwidthLimitBps / 1000; |
| 345 send_transport_->SetConfig(forward_transport_config_); | 341 send_transport_->SetConfig(forward_transport_config_); |
| 346 test_state_ = kLowRate; | 342 test_state_ = kLowRate; |
| 347 webrtc::test::PrintResult("ramp_up_down_up", | 343 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 348 GetModifierString(), | 344 "first_rampup", now - state_start_ms_, "ms", |
| 349 "first_rampup", | |
| 350 now - state_start_ms_, | |
| 351 "ms", | |
| 352 false); | 345 false); |
| 353 state_start_ms_ = now; | 346 state_start_ms_ = now; |
| 354 interval_start_ms_ = now; | 347 interval_start_ms_ = now; |
| 355 sent_bytes_ = 0; | 348 sent_bytes_ = 0; |
| 356 } | 349 } |
| 357 break; | 350 break; |
| 358 } | 351 } |
| 359 case kLowRate: { | 352 case kLowRate: { |
| 360 if (bitrate_bps < kExpectedLowBitrateBps && suspended) { | 353 if (bitrate_bps < kExpectedLowBitrateBps && suspended) { |
| 361 // The ramp-down was successful. Change the channel limit back to a | 354 // The ramp-down was successful. Change the channel limit back to a |
| 362 // high value, and move to the next test state. | 355 // high value, and move to the next test state. |
| 363 forward_transport_config_.link_capacity_kbps = | 356 forward_transport_config_.link_capacity_kbps = |
| 364 kHighBandwidthLimitBps / 1000; | 357 kHighBandwidthLimitBps / 1000; |
| 365 send_transport_->SetConfig(forward_transport_config_); | 358 send_transport_->SetConfig(forward_transport_config_); |
| 366 test_state_ = kSecondRampup; | 359 test_state_ = kSecondRampup; |
| 367 webrtc::test::PrintResult("ramp_up_down_up", | 360 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 368 GetModifierString(), | 361 "rampdown", now - state_start_ms_, "ms", |
| 369 "rampdown", | |
| 370 now - state_start_ms_, | |
| 371 "ms", | |
| 372 false); | 362 false); |
| 373 state_start_ms_ = now; | 363 state_start_ms_ = now; |
| 374 interval_start_ms_ = now; | 364 interval_start_ms_ = now; |
| 375 sent_bytes_ = 0; | 365 sent_bytes_ = 0; |
| 376 } | 366 } |
| 377 break; | 367 break; |
| 378 } | 368 } |
| 379 case kSecondRampup: { | 369 case kSecondRampup: { |
| 380 if (bitrate_bps > kExpectedHighBitrateBps && !suspended) { | 370 if (bitrate_bps > kExpectedHighBitrateBps && !suspended) { |
| 381 webrtc::test::PrintResult("ramp_up_down_up", | 371 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 382 GetModifierString(), | 372 "second_rampup", now - state_start_ms_, "ms", |
| 383 "second_rampup", | |
| 384 now - state_start_ms_, | |
| 385 "ms", | |
| 386 false); | 373 false); |
| 387 observation_complete_.Set(); | 374 observation_complete_.Set(); |
| 388 } | 375 } |
| 389 break; | 376 break; |
| 390 } | 377 } |
| 391 } | 378 } |
| 392 } | 379 } |
| 393 | 380 |
| 394 class RampUpTest : public test::CallTest { | 381 class RampUpTest : public test::CallTest { |
| 395 public: | 382 public: |
| 396 RampUpTest() {} | 383 RampUpTest() {} |
| 397 | 384 |
| 398 virtual ~RampUpTest() { | 385 virtual ~RampUpTest() { |
| 399 EXPECT_EQ(nullptr, send_stream_); | 386 EXPECT_EQ(nullptr, video_send_stream_); |
| 400 EXPECT_TRUE(receive_streams_.empty()); | 387 EXPECT_TRUE(video_receive_streams_.empty()); |
| 401 } | 388 } |
| 402 }; | 389 }; |
| 403 | 390 |
| 404 TEST_F(RampUpTest, SingleStream) { | 391 TEST_F(RampUpTest, SingleStream) { |
| 405 RampUpTester test(1, 0, RtpExtension::kTOffset, false, false); | 392 RampUpTester test(1, 0, 0, RtpExtension::kTOffset, false, false); |
| 406 RunBaseTest(&test, FakeNetworkPipe::Config()); | 393 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 407 } | 394 } |
| 408 | 395 |
| 409 TEST_F(RampUpTest, Simulcast) { | 396 TEST_F(RampUpTest, Simulcast) { |
| 410 RampUpTester test(3, 0, RtpExtension::kTOffset, false, false); | 397 RampUpTester test(3, 0, 0, RtpExtension::kTOffset, false, false); |
| 411 RunBaseTest(&test, FakeNetworkPipe::Config()); | 398 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 412 } | 399 } |
| 413 | 400 |
| 414 TEST_F(RampUpTest, SimulcastWithRtx) { | 401 TEST_F(RampUpTest, SimulcastWithRtx) { |
| 415 RampUpTester test(3, 0, RtpExtension::kTOffset, true, false); | 402 RampUpTester test(3, 0, 0, RtpExtension::kTOffset, true, false); |
| 416 RunBaseTest(&test, FakeNetworkPipe::Config()); | 403 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 417 } | 404 } |
| 418 | 405 |
| 419 TEST_F(RampUpTest, SimulcastByRedWithRtx) { | 406 TEST_F(RampUpTest, SimulcastByRedWithRtx) { |
| 420 RampUpTester test(3, 0, RtpExtension::kTOffset, true, true); | 407 RampUpTester test(3, 0, 0, RtpExtension::kTOffset, true, true); |
| 421 RunBaseTest(&test, FakeNetworkPipe::Config()); | 408 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 422 } | 409 } |
| 423 | 410 |
| 424 TEST_F(RampUpTest, SingleStreamWithHighStartBitrate) { | 411 TEST_F(RampUpTest, SingleStreamWithHighStartBitrate) { |
| 425 RampUpTester test(1, 0.9 * kSingleStreamTargetBps, RtpExtension::kTOffset, | 412 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, RtpExtension::kTOffset, |
| 426 false, false); | 413 false, false); |
| 427 RunBaseTest(&test, FakeNetworkPipe::Config()); | 414 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 428 } | 415 } |
| 429 | 416 |
| 430 TEST_F(RampUpTest, UpDownUpOneStream) { | 417 TEST_F(RampUpTest, UpDownUpOneStream) { |
| 431 RampUpDownUpTester test(1, 60000, RtpExtension::kAbsSendTime, false, false); | 418 RampUpDownUpTester test(1, 60000, RtpExtension::kAbsSendTime, false, false); |
| 432 RunBaseTest(&test, FakeNetworkPipe::Config()); | 419 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 433 } | 420 } |
| 434 | 421 |
| 435 TEST_F(RampUpTest, UpDownUpThreeStreams) { | 422 TEST_F(RampUpTest, UpDownUpThreeStreams) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 451 RampUpDownUpTester test(1, 60000, RtpExtension::kAbsSendTime, true, true); | 438 RampUpDownUpTester test(1, 60000, RtpExtension::kAbsSendTime, true, true); |
| 452 RunBaseTest(&test, FakeNetworkPipe::Config()); | 439 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 453 } | 440 } |
| 454 | 441 |
| 455 TEST_F(RampUpTest, UpDownUpThreeStreamsByRedRtx) { | 442 TEST_F(RampUpTest, UpDownUpThreeStreamsByRedRtx) { |
| 456 RampUpDownUpTester test(3, 60000, RtpExtension::kAbsSendTime, true, true); | 443 RampUpDownUpTester test(3, 60000, RtpExtension::kAbsSendTime, true, true); |
| 457 RunBaseTest(&test, FakeNetworkPipe::Config()); | 444 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 458 } | 445 } |
| 459 | 446 |
| 460 TEST_F(RampUpTest, AbsSendTimeSingleStream) { | 447 TEST_F(RampUpTest, AbsSendTimeSingleStream) { |
| 461 RampUpTester test(1, 0, RtpExtension::kAbsSendTime, false, false); | 448 RampUpTester test(1, 0, 0, RtpExtension::kAbsSendTime, false, false); |
| 462 RunBaseTest(&test, FakeNetworkPipe::Config()); | 449 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 463 } | 450 } |
| 464 | 451 |
| 465 TEST_F(RampUpTest, AbsSendTimeSimulcast) { | 452 TEST_F(RampUpTest, AbsSendTimeSimulcast) { |
| 466 RampUpTester test(3, 0, RtpExtension::kAbsSendTime, false, false); | 453 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTime, false, false); |
| 467 RunBaseTest(&test, FakeNetworkPipe::Config()); | 454 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 468 } | 455 } |
| 469 | 456 |
| 470 TEST_F(RampUpTest, AbsSendTimeSimulcastWithRtx) { | 457 TEST_F(RampUpTest, AbsSendTimeSimulcastWithRtx) { |
| 471 RampUpTester test(3, 0, RtpExtension::kAbsSendTime, true, false); | 458 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTime, true, false); |
| 472 RunBaseTest(&test, FakeNetworkPipe::Config()); | 459 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 473 } | 460 } |
| 474 | 461 |
| 475 TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) { | 462 TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) { |
| 476 RampUpTester test(3, 0, RtpExtension::kAbsSendTime, true, true); | 463 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTime, true, true); |
| 477 RunBaseTest(&test, FakeNetworkPipe::Config()); | 464 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 478 } | 465 } |
| 479 | 466 |
| 480 TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) { | 467 TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) { |
| 481 RampUpTester test(1, 0.9 * kSingleStreamTargetBps, RtpExtension::kAbsSendTime, | 468 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, |
| 482 false, false); | 469 RtpExtension::kAbsSendTime, false, false); |
| 483 RunBaseTest(&test, FakeNetworkPipe::Config()); | 470 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 484 } | 471 } |
| 485 | 472 |
| 486 TEST_F(RampUpTest, TransportSequenceNumberSingleStream) { | 473 TEST_F(RampUpTest, TransportSequenceNumberSingleStream) { |
| 487 RampUpTester test(1, 0, RtpExtension::kTransportSequenceNumber, false, false); | 474 RampUpTester test(1, 0, 0, RtpExtension::kTransportSequenceNumber, false, |
| 475 false); |
| 488 RunBaseTest(&test, FakeNetworkPipe::Config()); | 476 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 489 } | 477 } |
| 490 | 478 |
| 491 TEST_F(RampUpTest, TransportSequenceNumberSimulcast) { | 479 TEST_F(RampUpTest, TransportSequenceNumberSimulcast) { |
| 492 RampUpTester test(3, 0, RtpExtension::kTransportSequenceNumber, false, false); | 480 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumber, false, |
| 481 false); |
| 493 RunBaseTest(&test, FakeNetworkPipe::Config()); | 482 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 494 } | 483 } |
| 495 | 484 |
| 496 TEST_F(RampUpTest, TransportSequenceNumberSimulcastWithRtx) { | 485 TEST_F(RampUpTest, TransportSequenceNumberSimulcastWithRtx) { |
| 497 RampUpTester test(3, 0, RtpExtension::kTransportSequenceNumber, true, false); | 486 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumber, true, |
| 487 false); |
| 498 RunBaseTest(&test, FakeNetworkPipe::Config()); | 488 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 499 } | 489 } |
| 500 | 490 |
| 501 TEST_F(RampUpTest, TransportSequenceNumberSimulcastByRedWithRtx) { | 491 TEST_F(RampUpTest, TransportSequenceNumberSimulcastByRedWithRtx) { |
| 502 RampUpTester test(3, 0, RtpExtension::kTransportSequenceNumber, true, true); | 492 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumber, true, |
| 493 true); |
| 503 RunBaseTest(&test, FakeNetworkPipe::Config()); | 494 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 504 } | 495 } |
| 505 | 496 |
| 506 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { | 497 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { |
| 507 RampUpTester test(1, 0.9 * kSingleStreamTargetBps, | 498 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, |
| 508 RtpExtension::kTransportSequenceNumber, false, false); | 499 RtpExtension::kTransportSequenceNumber, false, false); |
| 509 RunBaseTest(&test, FakeNetworkPipe::Config()); | 500 RunBaseTest(&test, FakeNetworkPipe::Config()); |
| 510 } | 501 } |
| 511 } // namespace webrtc | 502 } // namespace webrtc |
| OLD | NEW |