blob: 46913b83a6022ff893f50f6a3284a82f746374cc [file] [log] [blame]
pbos@webrtc.org1d096902013-12-13 12:48:05 +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 */
asaperssonf8cdd182016-03-15 01:00:47 -070010
pbos@webrtc.org1d096902013-12-13 12:48:05 +000011#include <algorithm>
asaperssonf8cdd182016-03-15 01:00:47 -070012#include <limits>
kwibergb25345e2016-03-12 06:10:44 -080013#include <memory>
pbos@webrtc.org1d096902013-12-13 12:48:05 +000014#include <string>
15
Karl Wiberg918f50c2018-07-05 11:40:33 +020016#include "absl/memory/memory.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "api/audio_codecs/builtin_audio_encoder_factory.h"
Artem Titov46c4e602018-08-17 14:26:54 +020018#include "api/test/simulated_network.h"
Jiawei Ouc2ebe212018-11-08 10:02:56 -080019#include "api/video/builtin_video_bitrate_allocator_factory.h"
Erik Språngef75ebe2018-05-15 15:18:36 +020020#include "api/video/video_bitrate_allocation.h"
Elad Alon370f93a2019-06-11 14:57:57 +020021#include "api/video_codecs/video_encoder.h"
Niels Möller0a8f4352018-05-18 11:37:23 +020022#include "api/video_codecs/video_encoder_config.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "call/call.h"
Artem Titov4e199e92018-08-20 13:30:39 +020024#include "call/fake_network_pipe.h"
25#include "call/simulated_network.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "logging/rtc_event_log/rtc_event_log.h"
27#include "modules/audio_coding/include/audio_coding_module.h"
Artem Titov3faa8322018-03-07 14:44:00 +010028#include "modules/audio_device/include/test_audio_device.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020029#include "modules/audio_mixer/audio_mixer_impl.h"
30#include "modules/rtp_rtcp/include/rtp_header_parser.h"
Mirko Bonadeie95b57c2019-07-12 14:55:42 +000031#include "rtc_base/bitrate_allocation_strategy.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020032#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020033#include "rtc_base/thread_annotations.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020034#include "system_wrappers/include/metrics.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020035#include "test/call_test.h"
36#include "test/direct_transport.h"
37#include "test/drifting_clock.h"
38#include "test/encoder_settings.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020039#include "test/fake_encoder.h"
40#include "test/field_trial.h"
41#include "test/frame_generator.h"
42#include "test/frame_generator_capturer.h"
43#include "test/gtest.h"
Niels Möllerae4237e2018-10-05 11:28:38 +020044#include "test/null_transport.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020045#include "test/rtp_rtcp_observer.h"
46#include "test/single_threaded_task_queue.h"
Steve Anton10542f22019-01-11 09:11:00 -080047#include "test/testsupport/file_utils.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020048#include "test/testsupport/perf_test.h"
Niels Möllercbcbc222018-09-28 09:07:24 +020049#include "test/video_encoder_proxy_factory.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020050#include "video/transport_adapter.h"
pbos@webrtc.org1d096902013-12-13 12:48:05 +000051
danilchap9c6a0c72016-02-10 10:54:47 -080052using webrtc::test::DriftingClock;
danilchap9c6a0c72016-02-10 10:54:47 -080053
pbos@webrtc.org1d096902013-12-13 12:48:05 +000054namespace webrtc {
Elad Alond8d32482019-02-18 23:45:57 +010055namespace {
56enum : int { // The first valid value is 1.
57 kTransportSequenceNumberExtensionId = 1,
58};
59} // namespace
pbos@webrtc.org1d096902013-12-13 12:48:05 +000060
pbos@webrtc.org994d0b72014-06-27 08:47:52 +000061class CallPerfTest : public test::CallTest {
Elad Alond8d32482019-02-18 23:45:57 +010062 public:
63 CallPerfTest() {
64 RegisterRtpExtension(RtpExtension(RtpExtension::kTransportSequenceNumberUri,
65 kTransportSequenceNumberExtensionId));
66 }
67
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +000068 protected:
Yves Gerey665174f2018-06-19 15:03:05 +020069 enum class FecMode { kOn, kOff };
70 enum class CreateOrder { kAudioFirst, kVideoFirst };
Danil Chapovalovcde5d6b2016-02-15 11:14:58 +010071 void TestAudioVideoSync(FecMode fec,
72 CreateOrder create_first,
danilchap9c6a0c72016-02-10 10:54:47 -080073 float video_ntp_speed,
74 float video_rtp_speed,
Edward Lemur947f3fe2017-12-28 15:50:33 +010075 float audio_rtp_speed,
76 const std::string& test_label);
stefan@webrtc.org01581da2014-09-04 06:48:14 +000077
pbos@webrtc.org3349ae02014-03-13 12:52:27 +000078 void TestMinTransmitBitrate(bool pad_to_min_bitrate);
79
Artem Titov75e36472018-10-08 12:28:56 +020080 void TestCaptureNtpTime(const BuiltInNetworkBehaviorConfig& net_config,
wu@webrtc.orgcd701192014-04-24 22:10:24 +000081 int threshold_ms,
82 int start_time_ms,
83 int run_time_ms);
Mirko Bonadeie95b57c2019-07-12 14:55:42 +000084 void TestMinAudioVideoBitrate(bool use_bitrate_allocation_strategy,
85 int test_bitrate_from,
Alex Narestd0e196b2017-11-22 17:22:35 +010086 int test_bitrate_to,
87 int test_bitrate_step,
88 int min_bwe,
89 int start_bwe,
90 int max_bwe);
pbos@webrtc.org1d096902013-12-13 12:48:05 +000091};
92
asaperssonf8cdd182016-03-15 01:00:47 -070093class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver,
nisse7ade7b32016-03-23 04:48:10 -070094 public rtc::VideoSinkInterface<VideoFrame> {
pbos@webrtc.org1d096902013-12-13 12:48:05 +000095 static const int kInSyncThresholdMs = 50;
96 static const int kStartupTimeMs = 2000;
97 static const int kMinRunTimeMs = 30000;
98
99 public:
Edward Lemur947f3fe2017-12-28 15:50:33 +0100100 explicit VideoRtcpAndSyncObserver(Clock* clock, const std::string& test_label)
asaperssonf8cdd182016-03-15 01:00:47 -0700101 : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs),
102 clock_(clock),
Edward Lemur947f3fe2017-12-28 15:50:33 +0100103 test_label_(test_label),
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000104 creation_time_ms_(clock_->TimeInMilliseconds()),
asaperssonf8cdd182016-03-15 01:00:47 -0700105 first_time_in_sync_(-1),
106 receive_stream_(nullptr) {}
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000107
nisseeb83a1a2016-03-21 01:27:56 -0700108 void OnFrame(const VideoFrame& video_frame) override {
asaperssonf8cdd182016-03-15 01:00:47 -0700109 VideoReceiveStream::Stats stats;
110 {
111 rtc::CritScope lock(&crit_);
112 if (receive_stream_)
113 stats = receive_stream_->GetStats();
114 }
115 if (stats.sync_offset_ms == std::numeric_limits<int>::max())
116 return;
117
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000118 int64_t now_ms = clock_->TimeInMilliseconds();
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000119 int64_t time_since_creation = now_ms - creation_time_ms_;
120 // During the first couple of seconds audio and video can falsely be
121 // estimated as being synchronized. We don't want to trigger on those.
122 if (time_since_creation < kStartupTimeMs)
123 return;
asaperssonf8cdd182016-03-15 01:00:47 -0700124 if (std::abs(stats.sync_offset_ms) < kInSyncThresholdMs) {
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000125 if (first_time_in_sync_ == -1) {
126 first_time_in_sync_ = now_ms;
Edward Lemur947f3fe2017-12-28 15:50:33 +0100127 webrtc::test::PrintResult("sync_convergence_time", test_label_,
128 "synchronization", time_since_creation, "ms",
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000129 false);
130 }
131 if (time_since_creation > kMinRunTimeMs)
Peter Boström5811a392015-12-10 13:02:50 +0100132 observation_complete_.Set();
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000133 }
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200134 if (first_time_in_sync_ != -1)
135 sync_offset_ms_list_.push_back(stats.sync_offset_ms);
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000136 }
137
asaperssonf8cdd182016-03-15 01:00:47 -0700138 void set_receive_stream(VideoReceiveStream* receive_stream) {
139 rtc::CritScope lock(&crit_);
140 receive_stream_ = receive_stream;
141 }
142
danilchap46b89b92016-06-03 09:27:37 -0700143 void PrintResults() {
Edward Lemur947f3fe2017-12-28 15:50:33 +0100144 test::PrintResultList("stream_offset", test_label_, "synchronization",
Edward Lemur2f061682017-11-24 13:40:01 +0100145 sync_offset_ms_list_, "ms", false);
danilchap46b89b92016-06-03 09:27:37 -0700146 }
147
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000148 private:
pbos@webrtc.orgde1429e2014-04-28 13:00:21 +0000149 Clock* const clock_;
Edward Lemur947f3fe2017-12-28 15:50:33 +0100150 std::string test_label_;
stefanf116bd02015-10-27 08:29:42 -0700151 const int64_t creation_time_ms_;
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000152 int64_t first_time_in_sync_;
asaperssonf8cdd182016-03-15 01:00:47 -0700153 rtc::CriticalSection crit_;
danilchapa37de392017-09-09 04:17:22 -0700154 VideoReceiveStream* receive_stream_ RTC_GUARDED_BY(crit_);
Edward Lemur2f061682017-11-24 13:40:01 +0100155 std::vector<double> sync_offset_ms_list_;
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000156};
157
Danil Chapovalovcde5d6b2016-02-15 11:14:58 +0100158void CallPerfTest::TestAudioVideoSync(FecMode fec,
159 CreateOrder create_first,
danilchap9c6a0c72016-02-10 10:54:47 -0800160 float video_ntp_speed,
161 float video_rtp_speed,
Edward Lemur947f3fe2017-12-28 15:50:33 +0100162 float audio_rtp_speed,
163 const std::string& test_label) {
pbos8fc7fa72015-07-15 08:02:58 -0700164 const char* kSyncGroup = "av_sync";
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100165 const uint32_t kAudioSendSsrc = 1234;
166 const uint32_t kAudioRecvSsrc = 5678;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000167
Artem Titov75e36472018-10-08 12:28:56 +0200168 BuiltInNetworkBehaviorConfig audio_net_config;
mflodman3d7db262016-04-29 00:57:13 -0700169 audio_net_config.queue_delay_ms = 500;
170 audio_net_config.loss_percent = 5;
minyue20c84cc2017-04-10 16:57:57 -0700171
Edward Lemur947f3fe2017-12-28 15:50:33 +0100172 VideoRtcpAndSyncObserver observer(Clock::GetRealTimeClock(), test_label);
eladalon413ee9a2017-08-22 04:02:52 -0700173
minyue20c84cc2017-04-10 16:57:57 -0700174 std::map<uint8_t, MediaType> audio_pt_map;
175 std::map<uint8_t, MediaType> video_pt_map;
minyue20c84cc2017-04-10 16:57:57 -0700176
eladalon413ee9a2017-08-22 04:02:52 -0700177 std::unique_ptr<test::PacketTransport> audio_send_transport;
178 std::unique_ptr<test::PacketTransport> video_send_transport;
179 std::unique_ptr<test::PacketTransport> receive_transport;
Niels Möllerae4237e2018-10-05 11:28:38 +0200180 test::NullTransport rtcp_send_transport;
mflodman3d7db262016-04-29 00:57:13 -0700181
eladalon413ee9a2017-08-22 04:02:52 -0700182 AudioSendStream* audio_send_stream;
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100183 AudioReceiveStream* audio_receive_stream;
eladalon413ee9a2017-08-22 04:02:52 -0700184 std::unique_ptr<DriftingClock> drifting_clock;
pbos8fc7fa72015-07-15 08:02:58 -0700185
eladalon413ee9a2017-08-22 04:02:52 -0700186 task_queue_.SendTask([&]() {
187 metrics::Reset();
Artem Titov3faa8322018-03-07 14:44:00 +0100188 rtc::scoped_refptr<TestAudioDeviceModule> fake_audio_device =
Danil Chapovalov08fa9532019-06-12 11:49:17 +0000189 TestAudioDeviceModule::Create(
190 task_queue_factory_.get(),
Artem Titov3faa8322018-03-07 14:44:00 +0100191 TestAudioDeviceModule::CreatePulsedNoiseCapturer(256, 48000),
192 TestAudioDeviceModule::CreateDiscardRenderer(48000),
193 audio_rtp_speed);
Fredrik Solenbergd3195342017-11-21 20:33:05 +0100194 EXPECT_EQ(0, fake_audio_device->Init());
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000195
eladalon413ee9a2017-08-22 04:02:52 -0700196 AudioState::Config send_audio_state_config;
eladalon413ee9a2017-08-22 04:02:52 -0700197 send_audio_state_config.audio_mixer = AudioMixerImpl::Create();
Ivo Creusen62337e52018-01-09 14:17:33 +0100198 send_audio_state_config.audio_processing =
199 AudioProcessingBuilder().Create();
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100200 send_audio_state_config.audio_device_module = fake_audio_device;
Sebastian Jansson8e6602f2018-07-13 10:43:20 +0200201 Call::Config sender_config(send_event_log_.get());
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000202
Fredrik Solenbergd3195342017-11-21 20:33:05 +0100203 auto audio_state = AudioState::Create(send_audio_state_config);
204 fake_audio_device->RegisterAudioCallback(audio_state->audio_transport());
205 sender_config.audio_state = audio_state;
Sebastian Jansson8e6602f2018-07-13 10:43:20 +0200206 Call::Config receiver_config(recv_event_log_.get());
Fredrik Solenbergd3195342017-11-21 20:33:05 +0100207 receiver_config.audio_state = audio_state;
eladalon413ee9a2017-08-22 04:02:52 -0700208 CreateCalls(sender_config, receiver_config);
209
210 std::copy_if(std::begin(payload_type_map_), std::end(payload_type_map_),
211 std::inserter(audio_pt_map, audio_pt_map.end()),
212 [](const std::pair<const uint8_t, MediaType>& pair) {
213 return pair.second == MediaType::AUDIO;
214 });
215 std::copy_if(std::begin(payload_type_map_), std::end(payload_type_map_),
216 std::inserter(video_pt_map, video_pt_map.end()),
217 [](const std::pair<const uint8_t, MediaType>& pair) {
218 return pair.second == MediaType::VIDEO;
219 });
220
Karl Wiberg918f50c2018-07-05 11:40:33 +0200221 audio_send_transport = absl::make_unique<test::PacketTransport>(
eladalon413ee9a2017-08-22 04:02:52 -0700222 &task_queue_, sender_call_.get(), &observer,
Artem Titov4e199e92018-08-20 13:30:39 +0200223 test::PacketTransport::kSender, audio_pt_map,
224 absl::make_unique<FakeNetworkPipe>(
225 Clock::GetRealTimeClock(),
226 absl::make_unique<SimulatedNetwork>(audio_net_config)));
eladalon413ee9a2017-08-22 04:02:52 -0700227 audio_send_transport->SetReceiver(receiver_call_->Receiver());
228
Karl Wiberg918f50c2018-07-05 11:40:33 +0200229 video_send_transport = absl::make_unique<test::PacketTransport>(
eladalon413ee9a2017-08-22 04:02:52 -0700230 &task_queue_, sender_call_.get(), &observer,
231 test::PacketTransport::kSender, video_pt_map,
Artem Titov4e199e92018-08-20 13:30:39 +0200232 absl::make_unique<FakeNetworkPipe>(
233 Clock::GetRealTimeClock(), absl::make_unique<SimulatedNetwork>(
Artem Titov75e36472018-10-08 12:28:56 +0200234 BuiltInNetworkBehaviorConfig())));
eladalon413ee9a2017-08-22 04:02:52 -0700235 video_send_transport->SetReceiver(receiver_call_->Receiver());
236
Karl Wiberg918f50c2018-07-05 11:40:33 +0200237 receive_transport = absl::make_unique<test::PacketTransport>(
eladalon413ee9a2017-08-22 04:02:52 -0700238 &task_queue_, receiver_call_.get(), &observer,
239 test::PacketTransport::kReceiver, payload_type_map_,
Artem Titov4e199e92018-08-20 13:30:39 +0200240 absl::make_unique<FakeNetworkPipe>(
241 Clock::GetRealTimeClock(), absl::make_unique<SimulatedNetwork>(
Artem Titov75e36472018-10-08 12:28:56 +0200242 BuiltInNetworkBehaviorConfig())));
eladalon413ee9a2017-08-22 04:02:52 -0700243 receive_transport->SetReceiver(sender_call_->Receiver());
244
245 CreateSendConfig(1, 0, 0, video_send_transport.get());
246 CreateMatchingReceiveConfigs(receive_transport.get());
247
Niels Möller7d76a312018-10-26 12:57:07 +0200248 AudioSendStream::Config audio_send_config(audio_send_transport.get(),
Anton Sukhanov4f08faa2019-05-21 11:12:57 -0700249 MediaTransportConfig());
eladalon413ee9a2017-08-22 04:02:52 -0700250 audio_send_config.rtp.ssrc = kAudioSendSsrc;
Oskar Sundbomfedc00c2017-11-16 10:55:08 +0100251 audio_send_config.send_codec_spec = AudioSendStream::Config::SendCodecSpec(
252 kAudioSendPayloadType, {"ISAC", 16000, 1});
eladalon413ee9a2017-08-22 04:02:52 -0700253 audio_send_config.encoder_factory = CreateBuiltinAudioEncoderFactory();
254 audio_send_stream = sender_call_->CreateAudioSendStream(audio_send_config);
255
Sebastian Janssonf33905d2018-07-13 09:49:00 +0200256 GetVideoSendConfig()->rtp.nack.rtp_history_ms = kNackRtpHistoryMs;
eladalon413ee9a2017-08-22 04:02:52 -0700257 if (fec == FecMode::kOn) {
Sebastian Janssonf33905d2018-07-13 09:49:00 +0200258 GetVideoSendConfig()->rtp.ulpfec.red_payload_type = kRedPayloadType;
259 GetVideoSendConfig()->rtp.ulpfec.ulpfec_payload_type = kUlpfecPayloadType;
nisse3b3622f2017-09-26 02:49:21 -0700260 video_receive_configs_[0].rtp.red_payload_type = kRedPayloadType;
261 video_receive_configs_[0].rtp.ulpfec_payload_type = kUlpfecPayloadType;
eladalon413ee9a2017-08-22 04:02:52 -0700262 }
263 video_receive_configs_[0].rtp.nack.rtp_history_ms = 1000;
264 video_receive_configs_[0].renderer = &observer;
265 video_receive_configs_[0].sync_group = kSyncGroup;
266
267 AudioReceiveStream::Config audio_recv_config;
268 audio_recv_config.rtp.remote_ssrc = kAudioSendSsrc;
269 audio_recv_config.rtp.local_ssrc = kAudioRecvSsrc;
Niels Möllerae4237e2018-10-05 11:28:38 +0200270 audio_recv_config.rtcp_send_transport = &rtcp_send_transport;
eladalon413ee9a2017-08-22 04:02:52 -0700271 audio_recv_config.sync_group = kSyncGroup;
Niels Möller2784a032018-03-28 14:16:04 +0200272 audio_recv_config.decoder_factory = audio_decoder_factory_;
eladalon413ee9a2017-08-22 04:02:52 -0700273 audio_recv_config.decoder_map = {
274 {kAudioSendPayloadType, {"ISAC", 16000, 1}}};
275
276 if (create_first == CreateOrder::kAudioFirst) {
277 audio_receive_stream =
278 receiver_call_->CreateAudioReceiveStream(audio_recv_config);
279 CreateVideoStreams();
280 } else {
281 CreateVideoStreams();
282 audio_receive_stream =
283 receiver_call_->CreateAudioReceiveStream(audio_recv_config);
284 }
285 EXPECT_EQ(1u, video_receive_streams_.size());
286 observer.set_receive_stream(video_receive_streams_[0]);
Karl Wiberg918f50c2018-07-05 11:40:33 +0200287 drifting_clock = absl::make_unique<DriftingClock>(clock_, video_ntp_speed);
eladalon413ee9a2017-08-22 04:02:52 -0700288 CreateFrameGeneratorCapturerWithDrift(drifting_clock.get(), video_rtp_speed,
289 kDefaultFramerate, kDefaultWidth,
290 kDefaultHeight);
291
292 Start();
293
294 audio_send_stream->Start();
295 audio_receive_stream->Start();
296 });
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000297
Peter Boström5811a392015-12-10 13:02:50 +0100298 EXPECT_TRUE(observer.Wait())
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000299 << "Timed out while waiting for audio and video to be synchronized.";
300
eladalon413ee9a2017-08-22 04:02:52 -0700301 task_queue_.SendTask([&]() {
302 audio_send_stream->Stop();
303 audio_receive_stream->Stop();
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000304
eladalon413ee9a2017-08-22 04:02:52 -0700305 Stop();
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000306
eladalon413ee9a2017-08-22 04:02:52 -0700307 DestroyStreams();
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100308
eladalon413ee9a2017-08-22 04:02:52 -0700309 video_send_transport.reset();
310 audio_send_transport.reset();
311 receive_transport.reset();
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100312
eladalon413ee9a2017-08-22 04:02:52 -0700313 sender_call_->DestroyAudioSendStream(audio_send_stream);
314 receiver_call_->DestroyAudioReceiveStream(audio_receive_stream);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000315
eladalon413ee9a2017-08-22 04:02:52 -0700316 DestroyCalls();
eladalon413ee9a2017-08-22 04:02:52 -0700317 });
asaperssonf8cdd182016-03-15 01:00:47 -0700318
danilchap46b89b92016-06-03 09:27:37 -0700319 observer.PrintResults();
ilnik5328b9e2017-02-21 05:20:28 -0800320
321 // In quick test synchronization may not be achieved in time.
sprange5d3a3e2017-03-01 06:20:56 -0800322 if (!field_trial::IsEnabled("WebRTC-QuickPerfTest")) {
Artem Titarenkoded1e4f2019-03-15 11:36:39 +0100323// TODO(bugs.webrtc.org/10417): Reenable this for iOS
324#if !defined(WEBRTC_IOS)
ilnik5328b9e2017-02-21 05:20:28 -0800325 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs"));
Artem Titarenkoded1e4f2019-03-15 11:36:39 +0100326#endif
ilnik5328b9e2017-02-21 05:20:28 -0800327 }
pbos@webrtc.org1d096902013-12-13 12:48:05 +0000328}
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000329
Niels Möller9a750612018-08-09 11:04:32 +0200330TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithoutClockDrift) {
331 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
332 DriftingClock::kNoDrift, DriftingClock::kNoDrift,
333 DriftingClock::kNoDrift, "_video_no_drift");
334}
335
danilchapac287ee2016-02-29 12:17:04 -0800336TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) {
Danil Chapovalovcde5d6b2016-02-15 11:14:58 +0100337 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
338 DriftingClock::PercentsFaster(10.0f),
Edward Lemur947f3fe2017-12-28 15:50:33 +0100339 DriftingClock::kNoDrift, DriftingClock::kNoDrift,
340 "_video_ntp_drift");
danilchap9c6a0c72016-02-10 10:54:47 -0800341}
342
danilchap9c6a0c72016-02-10 10:54:47 -0800343TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) {
Danil Chapovalovcde5d6b2016-02-15 11:14:58 +0100344 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst,
345 DriftingClock::kNoDrift,
danilchap9c6a0c72016-02-10 10:54:47 -0800346 DriftingClock::PercentsSlower(30.0f),
Edward Lemur947f3fe2017-12-28 15:50:33 +0100347 DriftingClock::PercentsFaster(30.0f), "_audio_faster");
danilchap9c6a0c72016-02-10 10:54:47 -0800348}
349
350TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) {
Danil Chapovalovcde5d6b2016-02-15 11:14:58 +0100351 TestAudioVideoSync(FecMode::kOn, CreateOrder::kVideoFirst,
352 DriftingClock::kNoDrift,
danilchap9c6a0c72016-02-10 10:54:47 -0800353 DriftingClock::PercentsFaster(30.0f),
Edward Lemur947f3fe2017-12-28 15:50:33 +0100354 DriftingClock::PercentsSlower(30.0f), "_video_faster");
stefan@webrtc.org01581da2014-09-04 06:48:14 +0000355}
356
Artem Titov46c4e602018-08-17 14:26:54 +0200357void CallPerfTest::TestCaptureNtpTime(
Artem Titov75e36472018-10-08 12:28:56 +0200358 const BuiltInNetworkBehaviorConfig& net_config,
Artem Titov46c4e602018-08-17 14:26:54 +0200359 int threshold_ms,
360 int start_time_ms,
361 int run_time_ms) {
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000362 class CaptureNtpTimeObserver : public test::EndToEndTest,
nisse7ade7b32016-03-23 04:48:10 -0700363 public rtc::VideoSinkInterface<VideoFrame> {
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000364 public:
Artem Titov75e36472018-10-08 12:28:56 +0200365 CaptureNtpTimeObserver(const BuiltInNetworkBehaviorConfig& net_config,
stefane74eef12016-01-08 06:47:13 -0800366 int threshold_ms,
367 int start_time_ms,
368 int run_time_ms)
stefanf116bd02015-10-27 08:29:42 -0700369 : EndToEndTest(kLongTimeoutMs),
stefane74eef12016-01-08 06:47:13 -0800370 net_config_(net_config),
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000371 clock_(Clock::GetRealTimeClock()),
372 threshold_ms_(threshold_ms),
373 start_time_ms_(start_time_ms),
374 run_time_ms_(run_time_ms),
375 creation_time_ms_(clock_->TimeInMilliseconds()),
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000376 capturer_(nullptr),
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000377 rtp_start_timestamp_set_(false),
378 rtp_start_timestamp_(0) {}
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000379
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000380 private:
eladalon413ee9a2017-08-22 04:02:52 -0700381 test::PacketTransport* CreateSendTransport(
382 test::SingleThreadedTaskQueueForTesting* task_queue,
383 Call* sender_call) override {
Artem Titov4e199e92018-08-20 13:30:39 +0200384 return new test::PacketTransport(
385 task_queue, sender_call, this, test::PacketTransport::kSender,
386 payload_type_map_,
387 absl::make_unique<FakeNetworkPipe>(
388 Clock::GetRealTimeClock(),
389 absl::make_unique<SimulatedNetwork>(net_config_)));
stefane74eef12016-01-08 06:47:13 -0800390 }
391
eladalon413ee9a2017-08-22 04:02:52 -0700392 test::PacketTransport* CreateReceiveTransport(
393 test::SingleThreadedTaskQueueForTesting* task_queue) override {
Artem Titov4e199e92018-08-20 13:30:39 +0200394 return new test::PacketTransport(
395 task_queue, nullptr, this, test::PacketTransport::kReceiver,
396 payload_type_map_,
397 absl::make_unique<FakeNetworkPipe>(
398 Clock::GetRealTimeClock(),
399 absl::make_unique<SimulatedNetwork>(net_config_)));
Stefan Holmerea8c0f62016-01-13 08:58:38 +0100400 }
401
nisseeb83a1a2016-03-21 01:27:56 -0700402 void OnFrame(const VideoFrame& video_frame) override {
stefanf116bd02015-10-27 08:29:42 -0700403 rtc::CritScope lock(&crit_);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000404 if (video_frame.ntp_time_ms() <= 0) {
405 // Haven't got enough RTCP SR in order to calculate the capture ntp
406 // time.
407 return;
408 }
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000409
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000410 int64_t now_ms = clock_->TimeInMilliseconds();
411 int64_t time_since_creation = now_ms - creation_time_ms_;
412 if (time_since_creation < start_time_ms_) {
413 // Wait for |start_time_ms_| before start measuring.
414 return;
415 }
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000416
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000417 if (time_since_creation > run_time_ms_) {
Peter Boström5811a392015-12-10 13:02:50 +0100418 observation_complete_.Set();
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000419 }
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000420
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000421 FrameCaptureTimeList::iterator iter =
422 capture_time_list_.find(video_frame.timestamp());
423 EXPECT_TRUE(iter != capture_time_list_.end());
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000424
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000425 // The real capture time has been wrapped to uint32_t before converted
426 // to rtp timestamp in the sender side. So here we convert the estimated
427 // capture time to a uint32_t 90k timestamp also for comparing.
428 uint32_t estimated_capture_timestamp =
429 90 * static_cast<uint32_t>(video_frame.ntp_time_ms());
430 uint32_t real_capture_timestamp = iter->second;
431 int time_offset_ms = real_capture_timestamp - estimated_capture_timestamp;
432 time_offset_ms = time_offset_ms / 90;
danilchap46b89b92016-06-03 09:27:37 -0700433 time_offset_ms_list_.push_back(time_offset_ms);
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000434
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000435 EXPECT_TRUE(std::abs(time_offset_ms) < threshold_ms_);
436 }
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000437
nisseef8b61e2016-04-29 06:09:15 -0700438 Action OnSendRtp(const uint8_t* packet, size_t length) override {
stefanf116bd02015-10-27 08:29:42 -0700439 rtc::CritScope lock(&crit_);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000440 RTPHeader header;
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000441 EXPECT_TRUE(parser_->Parse(packet, length, &header));
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000442
443 if (!rtp_start_timestamp_set_) {
444 // Calculate the rtp timestamp offset in order to calculate the real
445 // capture time.
446 uint32_t first_capture_timestamp =
447 90 * static_cast<uint32_t>(capturer_->first_frame_capture_time());
448 rtp_start_timestamp_ = header.timestamp - first_capture_timestamp;
449 rtp_start_timestamp_set_ = true;
450 }
451
452 uint32_t capture_timestamp = header.timestamp - rtp_start_timestamp_;
453 capture_time_list_.insert(
454 capture_time_list_.end(),
455 std::make_pair(header.timestamp, capture_timestamp));
456 return SEND_PACKET;
457 }
458
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000459 void OnFrameGeneratorCapturerCreated(
460 test::FrameGeneratorCapturer* frame_generator_capturer) override {
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000461 capturer_ = frame_generator_capturer;
462 }
463
stefanff483612015-12-21 03:14:00 -0800464 void ModifyVideoConfigs(
465 VideoSendStream::Config* send_config,
466 std::vector<VideoReceiveStream::Config>* receive_configs,
467 VideoEncoderConfig* encoder_config) override {
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000468 (*receive_configs)[0].renderer = this;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000469 // Enable the receiver side rtt calculation.
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000470 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000471 }
472
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000473 void PerformTest() override {
Peter Boström5811a392015-12-10 13:02:50 +0100474 EXPECT_TRUE(Wait()) << "Timed out while waiting for "
475 "estimated capture NTP time to be "
476 "within bounds.";
danilchap46b89b92016-06-03 09:27:37 -0700477 test::PrintResultList("capture_ntp_time", "", "real - estimated",
Edward Lemur2f061682017-11-24 13:40:01 +0100478 time_offset_ms_list_, "ms", true);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000479 }
480
stefanf116bd02015-10-27 08:29:42 -0700481 rtc::CriticalSection crit_;
Artem Titov75e36472018-10-08 12:28:56 +0200482 const BuiltInNetworkBehaviorConfig net_config_;
stefanf116bd02015-10-27 08:29:42 -0700483 Clock* const clock_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000484 int threshold_ms_;
485 int start_time_ms_;
486 int run_time_ms_;
487 int64_t creation_time_ms_;
488 test::FrameGeneratorCapturer* capturer_;
489 bool rtp_start_timestamp_set_;
490 uint32_t rtp_start_timestamp_;
491 typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList;
danilchapa37de392017-09-09 04:17:22 -0700492 FrameCaptureTimeList capture_time_list_ RTC_GUARDED_BY(&crit_);
Edward Lemur2f061682017-11-24 13:40:01 +0100493 std::vector<double> time_offset_ms_list_;
stefane74eef12016-01-08 06:47:13 -0800494 } test(net_config, threshold_ms, start_time_ms, run_time_ms);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000495
stefane74eef12016-01-08 06:47:13 -0800496 RunBaseTest(&test);
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000497}
498
Alex Loikoaf228ee2018-11-22 11:53:18 +0100499// Flaky tests, disabled on Mac and Windows due to webrtc:8291.
500#if !(defined(WEBRTC_MAC) || defined(WEBRTC_WIN))
wu@webrtc.org9aa7d8d2014-05-29 05:03:52 +0000501TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) {
Artem Titov75e36472018-10-08 12:28:56 +0200502 BuiltInNetworkBehaviorConfig net_config;
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000503 net_config.queue_delay_ms = 100;
504 // TODO(wu): lower the threshold as the calculation/estimatation becomes more
505 // accurate.
wu@webrtc.org9aa7d8d2014-05-29 05:03:52 +0000506 const int kThresholdMs = 100;
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000507 const int kStartTimeMs = 10000;
508 const int kRunTimeMs = 20000;
509 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs);
510}
511
wu@webrtc.org0224c202014-05-05 17:42:43 +0000512TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkJitter) {
Artem Titov75e36472018-10-08 12:28:56 +0200513 BuiltInNetworkBehaviorConfig net_config;
wu@webrtc.org0224c202014-05-05 17:42:43 +0000514 net_config.queue_delay_ms = 100;
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000515 net_config.delay_standard_deviation_ms = 10;
516 // TODO(wu): lower the threshold as the calculation/estimatation becomes more
517 // accurate.
wu@webrtc.org0224c202014-05-05 17:42:43 +0000518 const int kThresholdMs = 100;
wu@webrtc.orgcd701192014-04-24 22:10:24 +0000519 const int kStartTimeMs = 10000;
520 const int kRunTimeMs = 20000;
521 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs);
522}
Alex Loiko5aea38c2017-09-27 13:10:28 +0200523#endif
kthelgasonfa5fdce2017-02-27 00:15:31 -0800524
perkj803d97f2016-11-01 11:45:46 -0700525TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
sprangc5d62e22017-04-02 23:53:04 -0700526 // Minimal normal usage at the start, then 30s overuse to allow filter to
527 // settle, and then 80s underuse to allow plenty of time for rampup again.
528 test::ScopedFieldTrials fake_overuse_settings(
529 "WebRTC-ForceSimulatedOveruseIntervalMs/1-30000-80000/");
530
perkj803d97f2016-11-01 11:45:46 -0700531 class LoadObserver : public test::SendTest,
532 public test::FrameGeneratorCapturer::SinkWantsObserver {
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000533 public:
Åsa Persson8c1bf952018-09-13 10:42:19 +0200534 LoadObserver() : SendTest(kLongTimeoutMs), test_phase_(TestPhase::kInit) {}
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000535
perkj803d97f2016-11-01 11:45:46 -0700536 void OnFrameGeneratorCapturerCreated(
537 test::FrameGeneratorCapturer* frame_generator_capturer) override {
538 frame_generator_capturer->SetSinkWantsObserver(this);
kthelgasonfa5fdce2017-02-27 00:15:31 -0800539 // Set a high initial resolution to be sure that we can scale down.
540 frame_generator_capturer->ChangeResolution(1920, 1080);
perkj803d97f2016-11-01 11:45:46 -0700541 }
542
543 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
544 // is called.
sprangc5d62e22017-04-02 23:53:04 -0700545 // TODO(sprang): Add integration test for maintain-framerate mode?
perkj803d97f2016-11-01 11:45:46 -0700546 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
547 const rtc::VideoSinkWants& wants) override {
Åsa Persson8c1bf952018-09-13 10:42:19 +0200548 // At kStart expect CPU overuse. Then expect CPU underuse when the encoder
perkj803d97f2016-11-01 11:45:46 -0700549 // delay has been decreased.
sprangc5d62e22017-04-02 23:53:04 -0700550 switch (test_phase_) {
Åsa Persson8c1bf952018-09-13 10:42:19 +0200551 case TestPhase::kInit:
552 // Max framerate should be set initially.
553 if (wants.max_framerate_fps != std::numeric_limits<int>::max() &&
554 wants.max_pixel_count == std::numeric_limits<int>::max()) {
555 test_phase_ = TestPhase::kStart;
556 } else {
557 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
558 << wants.max_pixel_count << ", target res = "
559 << wants.target_pixel_count.value_or(-1)
560 << ", max fps = " << wants.max_framerate_fps;
561 }
562 break;
sprangc5d62e22017-04-02 23:53:04 -0700563 case TestPhase::kStart:
564 if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
mflodmancc3d4422017-08-03 08:27:51 -0700565 // On adapting down, VideoStreamEncoder::VideoSourceProxy will set
566 // only the max pixel count, leaving the target unset.
sprangc5d62e22017-04-02 23:53:04 -0700567 test_phase_ = TestPhase::kAdaptedDown;
568 } else {
569 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
570 << wants.max_pixel_count << ", target res = "
571 << wants.target_pixel_count.value_or(-1)
572 << ", max fps = " << wants.max_framerate_fps;
573 }
574 break;
575 case TestPhase::kAdaptedDown:
576 // On adapting up, the adaptation counter will again be at zero, and
577 // so all constraints will be reset.
578 if (wants.max_pixel_count == std::numeric_limits<int>::max() &&
579 !wants.target_pixel_count) {
580 test_phase_ = TestPhase::kAdaptedUp;
581 observation_complete_.Set();
582 } else {
583 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
584 << wants.max_pixel_count << ", target res = "
585 << wants.target_pixel_count.value_or(-1)
586 << ", max fps = " << wants.max_framerate_fps;
587 }
588 break;
589 case TestPhase::kAdaptedUp:
590 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
591 << wants.max_pixel_count << ", target res = "
592 << wants.target_pixel_count.value_or(-1)
593 << ", max fps = " << wants.max_framerate_fps;
perkj803d97f2016-11-01 11:45:46 -0700594 }
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000595 }
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000596
stefanff483612015-12-21 03:14:00 -0800597 void ModifyVideoConfigs(
598 VideoSendStream::Config* send_config,
599 std::vector<VideoReceiveStream::Config>* receive_configs,
Yves Gerey665174f2018-06-19 15:03:05 +0200600 VideoEncoderConfig* encoder_config) override {}
asapersson@webrtc.org049e4ec2014-11-20 10:19:46 +0000601
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000602 void PerformTest() override {
Peter Boström5811a392015-12-10 13:02:50 +0100603 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000604 }
asapersson@webrtc.org049e4ec2014-11-20 10:19:46 +0000605
Åsa Persson8c1bf952018-09-13 10:42:19 +0200606 enum class TestPhase {
607 kInit,
608 kStart,
609 kAdaptedDown,
610 kAdaptedUp
611 } test_phase_;
perkj803d97f2016-11-01 11:45:46 -0700612 } test;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000613
stefane74eef12016-01-08 06:47:13 -0800614 RunBaseTest(&test);
asapersson@webrtc.orgbdc5ed22014-01-31 10:05:07 +0000615}
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000616
617void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
618 static const int kMaxEncodeBitrateKbps = 30;
pbos@webrtc.org709e2972014-03-19 10:59:52 +0000619 static const int kMinTransmitBitrateBps = 150000;
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000620 static const int kMinAcceptableTransmitBitrate = 130;
621 static const int kMaxAcceptableTransmitBitrate = 170;
622 static const int kNumBitrateObservationsInRange = 100;
sprang867fb522015-08-03 04:38:41 -0700623 static const int kAcceptableBitrateErrorMargin = 15; // +- 7
stefanf116bd02015-10-27 08:29:42 -0700624 class BitrateObserver : public test::EndToEndTest {
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000625 public:
626 explicit BitrateObserver(bool using_min_transmit_bitrate)
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000627 : EndToEndTest(kLongTimeoutMs),
pbos@webrtc.org2b4ce3a2015-03-23 13:12:24 +0000628 send_stream_(nullptr),
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200629 converged_(false),
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000630 pad_to_min_bitrate_(using_min_transmit_bitrate),
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200631 min_acceptable_bitrate_(using_min_transmit_bitrate
632 ? kMinAcceptableTransmitBitrate
633 : (kMaxEncodeBitrateKbps -
634 kAcceptableBitrateErrorMargin / 2)),
635 max_acceptable_bitrate_(using_min_transmit_bitrate
636 ? kMaxAcceptableTransmitBitrate
637 : (kMaxEncodeBitrateKbps +
638 kAcceptableBitrateErrorMargin / 2)),
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000639 num_bitrate_observations_in_range_(0) {}
640
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000641 private:
stefanf116bd02015-10-27 08:29:42 -0700642 // TODO(holmer): Run this with a timer instead of once per packet.
643 Action OnSendRtp(const uint8_t* packet, size_t length) override {
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000644 VideoSendStream::Stats stats = send_stream_->GetStats();
Benjamin Wright41f9f2c2019-03-13 18:03:29 -0700645 if (!stats.substreams.empty()) {
kwibergaf476c72016-11-28 15:21:39 -0800646 RTC_DCHECK_EQ(1, stats.substreams.size());
stefan@webrtc.org0bae1fa2014-11-05 14:05:29 +0000647 int bitrate_kbps =
648 stats.substreams.begin()->second.total_bitrate_bps / 1000;
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200649 if (bitrate_kbps > min_acceptable_bitrate_ &&
650 bitrate_kbps < max_acceptable_bitrate_) {
651 converged_ = true;
652 ++num_bitrate_observations_in_range_;
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000653 if (num_bitrate_observations_in_range_ ==
654 kNumBitrateObservationsInRange)
Peter Boström5811a392015-12-10 13:02:50 +0100655 observation_complete_.Set();
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000656 }
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200657 if (converged_)
658 bitrate_kbps_list_.push_back(bitrate_kbps);
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000659 }
stefanf116bd02015-10-27 08:29:42 -0700660 return SEND_PACKET;
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000661 }
662
stefanff483612015-12-21 03:14:00 -0800663 void OnVideoStreamsCreated(
pbos@webrtc.orgbe9d2a42014-06-30 13:19:09 +0000664 VideoSendStream* send_stream,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000665 const std::vector<VideoReceiveStream*>& receive_streams) override {
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000666 send_stream_ = send_stream;
667 }
668
stefanff483612015-12-21 03:14:00 -0800669 void ModifyVideoConfigs(
670 VideoSendStream::Config* send_config,
671 std::vector<VideoReceiveStream::Config>* receive_configs,
672 VideoEncoderConfig* encoder_config) override {
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000673 if (pad_to_min_bitrate_) {
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000674 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000675 } else {
henrikg91d6ede2015-09-17 00:24:34 -0700676 RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000677 }
678 }
679
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000680 void PerformTest() override {
Peter Boström5811a392015-12-10 13:02:50 +0100681 EXPECT_TRUE(Wait()) << "Timeout while waiting for send-bitrate stats.";
danilchap46b89b92016-06-03 09:27:37 -0700682 test::PrintResultList(
683 "bitrate_stats_",
684 (pad_to_min_bitrate_ ? "min_transmit_bitrate"
685 : "without_min_transmit_bitrate"),
Edward Lemur2f061682017-11-24 13:40:01 +0100686 "bitrate_kbps", bitrate_kbps_list_, "kbps", false);
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000687 }
688
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000689 VideoSendStream* send_stream_;
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200690 bool converged_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000691 const bool pad_to_min_bitrate_;
Danil Chapovalov371b43b2016-06-16 09:58:44 +0200692 const int min_acceptable_bitrate_;
693 const int max_acceptable_bitrate_;
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000694 int num_bitrate_observations_in_range_;
Edward Lemur2f061682017-11-24 13:40:01 +0100695 std::vector<double> bitrate_kbps_list_;
pbos@webrtc.org994d0b72014-06-27 08:47:52 +0000696 } test(pad_to_min_bitrate);
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000697
Niels Möller4db138e2018-04-19 09:04:13 +0200698 fake_encoder_max_bitrate_ = kMaxEncodeBitrateKbps;
stefane74eef12016-01-08 06:47:13 -0800699 RunBaseTest(&test);
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000700}
701
Yves Gerey665174f2018-06-19 15:03:05 +0200702TEST_F(CallPerfTest, PadsToMinTransmitBitrate) {
703 TestMinTransmitBitrate(true);
704}
pbos@webrtc.org3349ae02014-03-13 12:52:27 +0000705
706TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) {
707 TestMinTransmitBitrate(false);
708}
709
Taylor Brandstetter85904f42018-02-16 10:11:49 -0800710// TODO(bugs.webrtc.org/8878)
711#if defined(WEBRTC_MAC)
712#define MAYBE_KeepsHighBitrateWhenReconfiguringSender \
713 DISABLED_KeepsHighBitrateWhenReconfiguringSender
714#else
715#define MAYBE_KeepsHighBitrateWhenReconfiguringSender \
716 KeepsHighBitrateWhenReconfiguringSender
717#endif
718TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) {
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000719 static const uint32_t kInitialBitrateKbps = 400;
720 static const uint32_t kReconfigureThresholdKbps = 600;
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000721
perkjfa10b552016-10-02 23:45:26 -0700722 class VideoStreamFactory
723 : public VideoEncoderConfig::VideoStreamFactoryInterface {
724 public:
725 VideoStreamFactory() {}
726
727 private:
728 std::vector<VideoStream> CreateEncoderStreams(
729 int width,
730 int height,
731 const VideoEncoderConfig& encoder_config) override {
732 std::vector<VideoStream> streams =
733 test::CreateVideoStreams(width, height, encoder_config);
734 streams[0].min_bitrate_bps = 50000;
735 streams[0].target_bitrate_bps = streams[0].max_bitrate_bps = 2000000;
736 return streams;
737 }
738 };
739
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000740 class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder {
741 public:
742 BitrateObserver()
743 : EndToEndTest(kDefaultTimeoutMs),
744 FakeEncoder(Clock::GetRealTimeClock()),
sprang867fb522015-08-03 04:38:41 -0700745 encoder_inits_(0),
Erik Språng08127a92016-11-16 16:41:30 +0100746 last_set_bitrate_kbps_(0),
747 send_stream_(nullptr),
Niels Möller4db138e2018-04-19 09:04:13 +0200748 frame_generator_(nullptr),
Jiawei Ouc2ebe212018-11-08 10:02:56 -0800749 encoder_factory_(this),
750 bitrate_allocator_factory_(
751 CreateBuiltinVideoBitrateAllocatorFactory()) {}
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000752
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000753 int32_t InitEncode(const VideoCodec* config,
Elad Alon370f93a2019-06-11 14:57:57 +0200754 const VideoEncoder::Settings& settings) override {
perkjfa10b552016-10-02 23:45:26 -0700755 ++encoder_inits_;
756 if (encoder_inits_ == 1) {
emircan05a55b52016-10-28 14:06:29 -0700757 // First time initialization. Frame size is known.
Per21d45d22016-10-30 21:37:57 +0100758 // |expected_bitrate| is affected by bandwidth estimation before the
759 // first frame arrives to the encoder.
Erik Språng08127a92016-11-16 16:41:30 +0100760 uint32_t expected_bitrate = last_set_bitrate_kbps_ > 0
761 ? last_set_bitrate_kbps_
762 : kInitialBitrateKbps;
Per21d45d22016-10-30 21:37:57 +0100763 EXPECT_EQ(expected_bitrate, config->startBitrate)
764 << "Encoder not initialized at expected bitrate.";
perkjfa10b552016-10-02 23:45:26 -0700765 EXPECT_EQ(kDefaultWidth, config->width);
766 EXPECT_EQ(kDefaultHeight, config->height);
Per21d45d22016-10-30 21:37:57 +0100767 } else if (encoder_inits_ == 2) {
perkjfa10b552016-10-02 23:45:26 -0700768 EXPECT_EQ(2 * kDefaultWidth, config->width);
769 EXPECT_EQ(2 * kDefaultHeight, config->height);
Erik Språng08127a92016-11-16 16:41:30 +0100770 EXPECT_GE(last_set_bitrate_kbps_, kReconfigureThresholdKbps);
philipel0676f222018-04-17 16:12:21 +0200771 EXPECT_GT(config->startBitrate, kReconfigureThresholdKbps)
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000772 << "Encoder reconfigured with bitrate too far away from last set.";
Peter Boström5811a392015-12-10 13:02:50 +0100773 observation_complete_.Set();
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000774 }
Elad Alon370f93a2019-06-11 14:57:57 +0200775 return FakeEncoder::InitEncode(config, settings);
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000776 }
777
Erik Språng16cb8f52019-04-12 13:59:09 +0200778 void SetRates(const RateControlParameters& parameters) override {
779 last_set_bitrate_kbps_ = parameters.bitrate.get_sum_kbps();
Per21d45d22016-10-30 21:37:57 +0100780 if (encoder_inits_ == 1 &&
Erik Språng16cb8f52019-04-12 13:59:09 +0200781 parameters.bitrate.get_sum_kbps() > kReconfigureThresholdKbps) {
Peter Boström5811a392015-12-10 13:02:50 +0100782 time_to_reconfigure_.Set();
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000783 }
Erik Språng16cb8f52019-04-12 13:59:09 +0200784 FakeEncoder::SetRates(parameters);
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000785 }
786
Niels Möllerde8e6e62018-11-13 15:10:33 +0100787 void ModifySenderBitrateConfig(
788 BitrateConstraints* bitrate_config) override {
789 bitrate_config->start_bitrate_bps = kInitialBitrateKbps * 1000;
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000790 }
791
stefanff483612015-12-21 03:14:00 -0800792 void ModifyVideoConfigs(
793 VideoSendStream::Config* send_config,
794 std::vector<VideoReceiveStream::Config>* receive_configs,
795 VideoEncoderConfig* encoder_config) override {
Niels Möller4db138e2018-04-19 09:04:13 +0200796 send_config->encoder_settings.encoder_factory = &encoder_factory_;
Jiawei Ouc2ebe212018-11-08 10:02:56 -0800797 send_config->encoder_settings.bitrate_allocator_factory =
798 bitrate_allocator_factory_.get();
Per21d45d22016-10-30 21:37:57 +0100799 encoder_config->max_bitrate_bps = 2 * kReconfigureThresholdKbps * 1000;
perkjfa10b552016-10-02 23:45:26 -0700800 encoder_config->video_stream_factory =
801 new rtc::RefCountedObject<VideoStreamFactory>();
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000802
perkj26091b12016-09-01 01:17:40 -0700803 encoder_config_ = encoder_config->Copy();
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000804 }
805
stefanff483612015-12-21 03:14:00 -0800806 void OnVideoStreamsCreated(
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000807 VideoSendStream* send_stream,
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000808 const std::vector<VideoReceiveStream*>& receive_streams) override {
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000809 send_stream_ = send_stream;
810 }
811
perkjfa10b552016-10-02 23:45:26 -0700812 void OnFrameGeneratorCapturerCreated(
813 test::FrameGeneratorCapturer* frame_generator_capturer) override {
814 frame_generator_ = frame_generator_capturer;
815 }
816
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000817 void PerformTest() override {
Peter Boström5811a392015-12-10 13:02:50 +0100818 ASSERT_TRUE(time_to_reconfigure_.Wait(kDefaultTimeoutMs))
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000819 << "Timed out before receiving an initial high bitrate.";
perkjfa10b552016-10-02 23:45:26 -0700820 frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2);
perkj26091b12016-09-01 01:17:40 -0700821 send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy());
Peter Boström5811a392015-12-10 13:02:50 +0100822 EXPECT_TRUE(Wait())
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000823 << "Timed out while waiting for a couple of high bitrate estimates "
824 "after reconfiguring the send stream.";
825 }
826
827 private:
Peter Boström5811a392015-12-10 13:02:50 +0100828 rtc::Event time_to_reconfigure_;
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000829 int encoder_inits_;
Erik Språng08127a92016-11-16 16:41:30 +0100830 uint32_t last_set_bitrate_kbps_;
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000831 VideoSendStream* send_stream_;
perkjfa10b552016-10-02 23:45:26 -0700832 test::FrameGeneratorCapturer* frame_generator_;
Niels Möllercbcbc222018-09-28 09:07:24 +0200833 test::VideoEncoderProxyFactory encoder_factory_;
Jiawei Ouc2ebe212018-11-08 10:02:56 -0800834 std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000835 VideoEncoderConfig encoder_config_;
836 } test;
837
stefane74eef12016-01-08 06:47:13 -0800838 RunBaseTest(&test);
pbos@webrtc.org32452b22014-10-22 12:15:24 +0000839}
840
Alex Narestd0e196b2017-11-22 17:22:35 +0100841// Discovers the minimal supported audio+video bitrate. The test bitrate is
842// considered supported if Rtt does not go above 400ms with the network
843// contrained to the test bitrate.
844//
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000845// |use_bitrate_allocation_strategy| use AudioPriorityBitrateAllocationStrategy
Alex Narestd0e196b2017-11-22 17:22:35 +0100846// |test_bitrate_from test_bitrate_to| bitrate constraint range
847// |test_bitrate_step| bitrate constraint update step during the test
848// |min_bwe max_bwe| BWE range
849// |start_bwe| initial BWE
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000850void CallPerfTest::TestMinAudioVideoBitrate(
851 bool use_bitrate_allocation_strategy,
852 int test_bitrate_from,
853 int test_bitrate_to,
854 int test_bitrate_step,
855 int min_bwe,
856 int start_bwe,
857 int max_bwe) {
Alex Narestd0e196b2017-11-22 17:22:35 +0100858 static const std::string kAudioTrackId = "audio_track_0";
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000859 static constexpr uint32_t kSufficientAudioBitrateBps = 16000;
860 static constexpr int kOpusMinBitrateBps = 6000;
Alex Narestd0e196b2017-11-22 17:22:35 +0100861 static constexpr int kOpusBitrateFbBps = 32000;
862 static constexpr int kBitrateStabilizationMs = 10000;
863 static constexpr int kBitrateMeasurements = 10;
864 static constexpr int kBitrateMeasurementMs = 1000;
Ilya Nikolaevskiy0500b522019-01-22 11:12:51 +0100865 static constexpr int kShortDelayMs = 10;
Alex Narestd0e196b2017-11-22 17:22:35 +0100866 static constexpr int kMinGoodRttMs = 400;
867
868 class MinVideoAndAudioBitrateTester : public test::EndToEndTest {
869 public:
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000870 MinVideoAndAudioBitrateTester(bool use_bitrate_allocation_strategy,
871 int test_bitrate_from,
Alex Narestd0e196b2017-11-22 17:22:35 +0100872 int test_bitrate_to,
873 int test_bitrate_step,
874 int min_bwe,
875 int start_bwe,
876 int max_bwe)
877 : EndToEndTest(),
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000878 allocation_strategy_(new rtc::AudioPriorityBitrateAllocationStrategy(
879 kAudioTrackId,
880 kSufficientAudioBitrateBps)),
881 use_bitrate_allocation_strategy_(use_bitrate_allocation_strategy),
Alex Narestd0e196b2017-11-22 17:22:35 +0100882 test_bitrate_from_(test_bitrate_from),
883 test_bitrate_to_(test_bitrate_to),
884 test_bitrate_step_(test_bitrate_step),
885 min_bwe_(min_bwe),
886 start_bwe_(start_bwe),
887 max_bwe_(max_bwe) {}
888
889 protected:
Artem Titov75e36472018-10-08 12:28:56 +0200890 BuiltInNetworkBehaviorConfig GetFakeNetworkPipeConfig() {
891 BuiltInNetworkBehaviorConfig pipe_config;
Alex Narestd0e196b2017-11-22 17:22:35 +0100892 pipe_config.link_capacity_kbps = test_bitrate_from_;
893 return pipe_config;
894 }
895
896 test::PacketTransport* CreateSendTransport(
897 test::SingleThreadedTaskQueueForTesting* task_queue,
898 Call* sender_call) override {
Artem Titov631cafa2018-08-21 21:01:00 +0200899 auto network =
900 absl::make_unique<SimulatedNetwork>(GetFakeNetworkPipeConfig());
901 send_simulated_network_ = network.get();
902 return new test::PacketTransport(
903 task_queue, sender_call, this, test::PacketTransport::kSender,
904 test::CallTest::payload_type_map_,
905 absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
906 std::move(network)));
Alex Narestd0e196b2017-11-22 17:22:35 +0100907 }
908
909 test::PacketTransport* CreateReceiveTransport(
910 test::SingleThreadedTaskQueueForTesting* task_queue) override {
Artem Titov631cafa2018-08-21 21:01:00 +0200911 auto network =
912 absl::make_unique<SimulatedNetwork>(GetFakeNetworkPipeConfig());
913 receive_simulated_network_ = network.get();
914 return new test::PacketTransport(
915 task_queue, nullptr, this, test::PacketTransport::kReceiver,
916 test::CallTest::payload_type_map_,
917 absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
918 std::move(network)));
Alex Narestd0e196b2017-11-22 17:22:35 +0100919 }
920
921 void PerformTest() override {
Ilya Nikolaevskiy0500b522019-01-22 11:12:51 +0100922 // Quick test mode, just to exercise all the code paths without actually
923 // caring about performance measurements.
924 const bool quick_perf_test =
925 field_trial::IsEnabled("WebRTC-QuickPerfTest");
Alex Narestd0e196b2017-11-22 17:22:35 +0100926 int last_passed_test_bitrate = -1;
927 for (int test_bitrate = test_bitrate_from_;
928 test_bitrate_from_ < test_bitrate_to_
929 ? test_bitrate <= test_bitrate_to_
930 : test_bitrate >= test_bitrate_to_;
931 test_bitrate += test_bitrate_step_) {
Artem Titov75e36472018-10-08 12:28:56 +0200932 BuiltInNetworkBehaviorConfig pipe_config;
Alex Narestd0e196b2017-11-22 17:22:35 +0100933 pipe_config.link_capacity_kbps = test_bitrate;
Artem Titov631cafa2018-08-21 21:01:00 +0200934 send_simulated_network_->SetConfig(pipe_config);
935 receive_simulated_network_->SetConfig(pipe_config);
Alex Narestd0e196b2017-11-22 17:22:35 +0100936
937 rtc::ThreadManager::Instance()->CurrentThread()->SleepMs(
Ilya Nikolaevskiy0500b522019-01-22 11:12:51 +0100938 quick_perf_test ? kShortDelayMs : kBitrateStabilizationMs);
Alex Narestd0e196b2017-11-22 17:22:35 +0100939
940 int64_t avg_rtt = 0;
941 for (int i = 0; i < kBitrateMeasurements; i++) {
942 Call::Stats call_stats = sender_call_->GetStats();
943 avg_rtt += call_stats.rtt_ms;
944 rtc::ThreadManager::Instance()->CurrentThread()->SleepMs(
Ilya Nikolaevskiy0500b522019-01-22 11:12:51 +0100945 quick_perf_test ? kShortDelayMs : kBitrateMeasurementMs);
Alex Narestd0e196b2017-11-22 17:22:35 +0100946 }
947 avg_rtt = avg_rtt / kBitrateMeasurements;
948 if (avg_rtt > kMinGoodRttMs) {
949 break;
950 } else {
951 last_passed_test_bitrate = test_bitrate;
952 }
953 }
954 EXPECT_GT(last_passed_test_bitrate, -1)
955 << "Minimum supported bitrate out of the test scope";
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000956 webrtc::test::PrintResult(
957 "min_test_bitrate_",
958 use_bitrate_allocation_strategy_ ? "with_allocation_strategy"
959 : "no_allocation_strategy",
960 "min_bitrate", last_passed_test_bitrate, "kbps", false);
Alex Narestd0e196b2017-11-22 17:22:35 +0100961 }
962
963 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
964 sender_call_ = sender_call;
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +0100965 BitrateConstraints bitrate_config;
Alex Narestd0e196b2017-11-22 17:22:35 +0100966 bitrate_config.min_bitrate_bps = min_bwe_;
967 bitrate_config.start_bitrate_bps = start_bwe_;
968 bitrate_config.max_bitrate_bps = max_bwe_;
Sebastian Jansson8f83b422018-02-21 13:07:13 +0100969 sender_call->GetTransportControllerSend()->SetSdpBitrateParameters(
970 bitrate_config);
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000971 if (use_bitrate_allocation_strategy_) {
972 sender_call->SetBitrateAllocationStrategy(
973 std::move(allocation_strategy_));
974 }
Alex Narestd0e196b2017-11-22 17:22:35 +0100975 }
976
977 size_t GetNumVideoStreams() const override { return 1; }
978
979 size_t GetNumAudioStreams() const override { return 1; }
980
981 void ModifyAudioConfigs(
982 AudioSendStream::Config* send_config,
983 std::vector<AudioReceiveStream::Config>* receive_configs) override {
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000984 if (use_bitrate_allocation_strategy_) {
985 send_config->track_id = kAudioTrackId;
986 send_config->min_bitrate_bps = kOpusMinBitrateBps;
987 send_config->max_bitrate_bps = kOpusBitrateFbBps;
988 } else {
989 send_config->send_codec_spec->target_bitrate_bps =
990 absl::optional<int>(kOpusBitrateFbBps);
991 }
Alex Narestd0e196b2017-11-22 17:22:35 +0100992 }
993
994 private:
Mirko Bonadeie95b57c2019-07-12 14:55:42 +0000995 std::unique_ptr<rtc::BitrateAllocationStrategy> allocation_strategy_;
996 const bool use_bitrate_allocation_strategy_;
Alex Narestd0e196b2017-11-22 17:22:35 +0100997 const int test_bitrate_from_;
998 const int test_bitrate_to_;
999 const int test_bitrate_step_;
1000 const int min_bwe_;
1001 const int start_bwe_;
1002 const int max_bwe_;
Artem Titov631cafa2018-08-21 21:01:00 +02001003 SimulatedNetwork* send_simulated_network_;
1004 SimulatedNetwork* receive_simulated_network_;
Alex Narestd0e196b2017-11-22 17:22:35 +01001005 Call* sender_call_;
Mirko Bonadeie95b57c2019-07-12 14:55:42 +00001006 } test(use_bitrate_allocation_strategy, test_bitrate_from, test_bitrate_to,
1007 test_bitrate_step, min_bwe, start_bwe, max_bwe);
Alex Narestd0e196b2017-11-22 17:22:35 +01001008
1009 RunBaseTest(&test);
1010}
1011
Taylor Brandstetter85904f42018-02-16 10:11:49 -08001012// TODO(bugs.webrtc.org/8878)
1013#if defined(WEBRTC_MAC)
Yves Gerey665174f2018-06-19 15:03:05 +02001014#define MAYBE_MinVideoAndAudioBitrate DISABLED_MinVideoAndAudioBitrate
Taylor Brandstetter85904f42018-02-16 10:11:49 -08001015#else
Yves Gerey665174f2018-06-19 15:03:05 +02001016#define MAYBE_MinVideoAndAudioBitrate MinVideoAndAudioBitrate
Taylor Brandstetter85904f42018-02-16 10:11:49 -08001017#endif
1018TEST_F(CallPerfTest, MAYBE_MinVideoAndAudioBitrate) {
Mirko Bonadeie95b57c2019-07-12 14:55:42 +00001019 TestMinAudioVideoBitrate(false, 110, 40, -10, 10000, 70000, 200000);
1020}
1021TEST_F(CallPerfTest, MinVideoAndAudioBitrateWStrategy) {
1022 TestMinAudioVideoBitrate(true, 110, 40, -10, 10000, 70000, 200000);
Alex Narestd0e196b2017-11-22 17:22:35 +01001023}
1024
pbos@webrtc.org1d096902013-12-13 12:48:05 +00001025} // namespace webrtc