blob: c7fad1e7a5633ba0e12bc53e6a5c1ca3622df535 [file] [log] [blame]
Artem Titova6a273d2019-02-07 16:43:51 +01001/*
2 * Copyright (c) 2019 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 */
10
11#include <cstdint>
12#include <memory>
13
Artem Titov7bf8c7f2019-03-15 15:00:37 +010014#include "api/test/create_network_emulation_manager.h"
Artem Titovd57628f2019-03-22 12:34:25 +010015#include "api/test/create_peerconnection_quality_test_fixture.h"
Artem Titov7bf8c7f2019-03-15 15:00:37 +010016#include "api/test/network_emulation_manager.h"
Artem Titovd57628f2019-03-22 12:34:25 +010017#include "api/test/peerconnection_quality_test_fixture.h"
Artem Titova6a273d2019-02-07 16:43:51 +010018#include "call/simulated_network.h"
Niels Möllerd27a0c12019-09-26 16:21:02 +020019#include "system_wrappers/include/field_trial.h"
20#include "test/field_trial.h"
Artem Titova6a273d2019-02-07 16:43:51 +010021#include "test/gtest.h"
Mirko Bonadei12ae4f42019-02-26 15:19:07 +010022#include "test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h"
Artem Titov6b88a8f2019-02-13 22:15:04 +010023#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h"
Artem Titov18459222019-04-24 11:09:35 +020024#include "test/pc/e2e/network_quality_metrics_reporter.h"
Artem Titova6a273d2019-02-07 16:43:51 +010025#include "test/testsupport/file_utils.h"
26
27namespace webrtc {
Artem Titov0b443142019-03-20 11:11:08 +010028namespace webrtc_pc_e2e {
Artem Titovef3fd9c2019-06-13 16:36:52 +020029namespace {
Artem Titova6a273d2019-02-07 16:43:51 +010030
Artem Titovef3fd9c2019-06-13 16:36:52 +020031class PeerConnectionE2EQualityTestSmokeTest : public ::testing::Test {
32 public:
Artem Titovd09bc552019-03-20 11:18:58 +010033 using PeerConfigurer = PeerConnectionE2EQualityTestFixture::PeerConfigurer;
Artem Titova6a273d2019-02-07 16:43:51 +010034 using RunParams = PeerConnectionE2EQualityTestFixture::RunParams;
Artem Titova6a273d2019-02-07 16:43:51 +010035 using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig;
36 using AudioConfig = PeerConnectionE2EQualityTestFixture::AudioConfig;
Artem Titov7581ff72019-05-15 15:45:33 +020037 using ScreenShareConfig =
38 PeerConnectionE2EQualityTestFixture::ScreenShareConfig;
39 using ScrollingParams = PeerConnectionE2EQualityTestFixture::ScrollingParams;
Artem Titovef3fd9c2019-06-13 16:36:52 +020040 using VideoSimulcastConfig =
41 PeerConnectionE2EQualityTestFixture::VideoSimulcastConfig;
Artem Titov728a0ee2019-08-20 13:36:35 +020042 using EchoEmulationConfig =
43 PeerConnectionE2EQualityTestFixture::EchoEmulationConfig;
Artem Titov7c554152019-02-28 10:25:52 +010044
Artem Titovef3fd9c2019-06-13 16:36:52 +020045 void RunTest(const std::string& test_case_name,
46 const RunParams& run_params,
47 rtc::FunctionView<void(PeerConfigurer*)> alice_configurer,
48 rtc::FunctionView<void(PeerConfigurer*)> bob_configurer) {
49 // Setup emulated network
50 std::unique_ptr<NetworkEmulationManager> network_emulation_manager =
51 CreateNetworkEmulationManager();
Artem Titova6a273d2019-02-07 16:43:51 +010052
Artem Titovef3fd9c2019-06-13 16:36:52 +020053 auto alice_network_behavior =
Mirko Bonadei317a1f02019-09-17 17:06:18 +020054 std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig());
Artem Titovef3fd9c2019-06-13 16:36:52 +020055 SimulatedNetwork* alice_network_behavior_ptr = alice_network_behavior.get();
56 EmulatedNetworkNode* alice_node =
57 network_emulation_manager->CreateEmulatedNode(
58 std::move(alice_network_behavior));
59 EmulatedNetworkNode* bob_node =
60 network_emulation_manager->CreateEmulatedNode(
Mirko Bonadei317a1f02019-09-17 17:06:18 +020061 std::make_unique<SimulatedNetwork>(BuiltInNetworkBehaviorConfig()));
Artem Titovef3fd9c2019-06-13 16:36:52 +020062 auto* alice_endpoint =
63 network_emulation_manager->CreateEndpoint(EmulatedEndpointConfig());
64 EmulatedEndpoint* bob_endpoint =
65 network_emulation_manager->CreateEndpoint(EmulatedEndpointConfig());
66 network_emulation_manager->CreateRoute(alice_endpoint, {alice_node},
67 bob_endpoint);
68 network_emulation_manager->CreateRoute(bob_endpoint, {bob_node},
69 alice_endpoint);
Artem Titova6a273d2019-02-07 16:43:51 +010070
Artem Titovef3fd9c2019-06-13 16:36:52 +020071 // Create analyzers.
72 std::unique_ptr<VideoQualityAnalyzerInterface> video_quality_analyzer =
Mirko Bonadei317a1f02019-09-17 17:06:18 +020073 std::make_unique<DefaultVideoQualityAnalyzer>();
Artem Titovef3fd9c2019-06-13 16:36:52 +020074 // This is only done for the sake of smoke testing. In general there should
75 // be no need to explicitly pull data from analyzers after the run.
76 auto* video_analyzer_ptr =
77 static_cast<DefaultVideoQualityAnalyzer*>(video_quality_analyzer.get());
Artem Titova6a273d2019-02-07 16:43:51 +010078
Artem Titovef3fd9c2019-06-13 16:36:52 +020079 auto fixture = CreatePeerConnectionE2EQualityTestFixture(
80 test_case_name, /*audio_quality_analyzer=*/nullptr,
81 std::move(video_quality_analyzer));
82 fixture->ExecuteAt(TimeDelta::seconds(2),
83 [alice_network_behavior_ptr](TimeDelta) {
84 BuiltInNetworkBehaviorConfig config;
85 config.loss_percent = 5;
86 alice_network_behavior_ptr->SetConfig(config);
87 });
Mirko Bonadei12ae4f42019-02-26 15:19:07 +010088
Artem Titovef3fd9c2019-06-13 16:36:52 +020089 // Setup components. We need to provide rtc::NetworkManager compatible with
90 // emulated network layer.
91 EmulatedNetworkManagerInterface* alice_network =
92 network_emulation_manager->CreateEmulatedNetworkManagerInterface(
93 {alice_endpoint});
94 EmulatedNetworkManagerInterface* bob_network =
95 network_emulation_manager->CreateEmulatedNetworkManagerInterface(
96 {bob_endpoint});
Artem Titovd09bc552019-03-20 11:18:58 +010097
Artem Titovef3fd9c2019-06-13 16:36:52 +020098 fixture->AddPeer(alice_network->network_thread(),
99 alice_network->network_manager(), alice_configurer);
100 fixture->AddPeer(bob_network->network_thread(),
101 bob_network->network_manager(), bob_configurer);
102 fixture->AddQualityMetricsReporter(
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200103 std::make_unique<NetworkQualityMetricsReporter>(alice_network,
104 bob_network));
Artem Titov7581ff72019-05-15 15:45:33 +0200105
Artem Titovef3fd9c2019-06-13 16:36:52 +0200106 fixture->Run(run_params);
Artem Titovd09bc552019-03-20 11:18:58 +0100107
Artem Titovef3fd9c2019-06-13 16:36:52 +0200108 EXPECT_GE(fixture->GetRealTestDuration(), run_params.run_duration);
109 for (auto stream_label : video_analyzer_ptr->GetKnownVideoStreams()) {
110 FrameCounters stream_conters =
111 video_analyzer_ptr->GetPerStreamCounters().at(stream_label);
112 // 150 = 30fps * 5s. On some devices pipeline can be too slow, so it can
113 // happen, that frames will stuck in the middle, so we actually can't
114 // force real constraints here, so lets just check, that at least 1 frame
115 // passed whole pipeline.
116 EXPECT_GE(stream_conters.captured, 150);
117 EXPECT_GE(stream_conters.pre_encoded, 1);
118 EXPECT_GE(stream_conters.encoded, 1);
119 EXPECT_GE(stream_conters.received, 1);
120 EXPECT_GE(stream_conters.decoded, 1);
121 EXPECT_GE(stream_conters.rendered, 1);
122 }
123 }
124};
125
126} // namespace
127
128// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
129#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
Artem Titovad82e8e2019-06-14 10:45:18 +0200130#define MAYBE_Smoke DISABLED_Smoke
Artem Titovef3fd9c2019-06-13 16:36:52 +0200131#else
Artem Titovad82e8e2019-06-14 10:45:18 +0200132#define MAYBE_Smoke Smoke
Artem Titovef3fd9c2019-06-13 16:36:52 +0200133#endif
134TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Smoke) {
135 RunParams run_params(TimeDelta::seconds(7));
136 run_params.video_codec_name = cricket::kVp9CodecName;
137 run_params.video_codec_required_params = {{"profile-id", "0"}};
138 run_params.use_flex_fec = true;
139 run_params.use_ulp_fec = true;
140 run_params.video_encoder_bitrate_multiplier = 1.1;
Niels Möllerd27a0c12019-09-26 16:21:02 +0200141 test::ScopedFieldTrials field_trials(
142 std::string(field_trial::GetFieldTrialString()) +
143 "WebRTC-UseStandardBytesStats/Enabled/");
Artem Titovef3fd9c2019-06-13 16:36:52 +0200144 RunTest(
145 "smoke", run_params,
146 [](PeerConfigurer* alice) {
147 VideoConfig video(640, 360, 30);
148 video.stream_label = "alice-video";
149 alice->AddVideoConfig(std::move(video));
150
151 AudioConfig audio;
152 audio.stream_label = "alice-audio";
153 audio.mode = AudioConfig::Mode::kFile;
154 audio.input_file_name =
155 test::ResourcePath("pc_quality_smoke_test_alice_source", "wav");
Artem Titovbc558ce2019-07-08 19:13:21 +0200156 audio.sampling_frequency_in_hz = 48000;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200157 alice->SetAudioConfig(std::move(audio));
158 },
Artem Titov7581ff72019-05-15 15:45:33 +0200159 [](PeerConfigurer* bob) {
160 VideoConfig video(640, 360, 30);
161 video.stream_label = "bob-video";
Artem Titov1e49ab22019-07-30 13:17:25 +0200162 video.temporal_layers_count = 2;
Artem Titov7581ff72019-05-15 15:45:33 +0200163 bob->AddVideoConfig(std::move(video));
164
165 VideoConfig screenshare(640, 360, 30);
166 screenshare.stream_label = "bob-screenshare";
167 screenshare.screen_share_config =
168 ScreenShareConfig(TimeDelta::seconds(2));
169 screenshare.screen_share_config->scrolling_params = ScrollingParams(
170 TimeDelta::ms(1800), kDefaultSlidesWidth, kDefaultSlidesHeight);
171 bob->AddVideoConfig(screenshare);
172
173 AudioConfig audio;
174 audio.stream_label = "bob-audio";
175 audio.mode = AudioConfig::Mode::kFile;
176 audio.input_file_name =
177 test::ResourcePath("pc_quality_smoke_test_bob_source", "wav");
178 bob->SetAudioConfig(std::move(audio));
179 });
Artem Titovef3fd9c2019-06-13 16:36:52 +0200180}
Artem Titovd09bc552019-03-20 11:18:58 +0100181
Artem Titovef3fd9c2019-06-13 16:36:52 +0200182// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
183#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
Artem Titov728a0ee2019-08-20 13:36:35 +0200184#define MAYBE_Echo DISABLED_Echo
185#else
186#define MAYBE_Echo Echo
187#endif
188TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Echo) {
189 RunParams run_params(TimeDelta::seconds(7));
190 run_params.echo_emulation_config = EchoEmulationConfig();
191 RunTest(
192 "smoke", run_params,
193 [](PeerConfigurer* alice) {
194 AudioConfig audio;
195 audio.stream_label = "alice-audio";
196 audio.mode = AudioConfig::Mode::kFile;
197 audio.input_file_name =
198 test::ResourcePath("pc_quality_smoke_test_alice_source", "wav");
199 audio.sampling_frequency_in_hz = 48000;
200 alice->SetAudioConfig(std::move(audio));
201 },
202 [](PeerConfigurer* bob) {
203 AudioConfig audio;
204 audio.stream_label = "bob-audio";
205 audio.mode = AudioConfig::Mode::kFile;
206 audio.input_file_name =
207 test::ResourcePath("pc_quality_smoke_test_bob_source", "wav");
208 bob->SetAudioConfig(std::move(audio));
209 });
210}
211
212// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
213#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
Artem Titovad82e8e2019-06-14 10:45:18 +0200214#define MAYBE_Simulcast DISABLED_Simulcast
Artem Titovef3fd9c2019-06-13 16:36:52 +0200215#else
Artem Titovad82e8e2019-06-14 10:45:18 +0200216#define MAYBE_Simulcast Simulcast
Artem Titovef3fd9c2019-06-13 16:36:52 +0200217#endif
218TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Simulcast) {
Artem Titov70f80e52019-04-12 13:13:39 +0200219 RunParams run_params(TimeDelta::seconds(7));
Artem Titovef3fd9c2019-06-13 16:36:52 +0200220 run_params.video_codec_name = cricket::kVp8CodecName;
221 RunTest(
222 "simulcast", run_params,
223 [](PeerConfigurer* alice) {
224 VideoConfig simulcast(1280, 720, 30);
225 simulcast.stream_label = "alice-simulcast";
226 simulcast.simulcast_config = VideoSimulcastConfig(3, 0);
227 alice->AddVideoConfig(std::move(simulcast));
Artem Titova6a273d2019-02-07 16:43:51 +0100228
Artem Titovef3fd9c2019-06-13 16:36:52 +0200229 AudioConfig audio;
230 audio.stream_label = "alice-audio";
231 audio.mode = AudioConfig::Mode::kFile;
232 audio.input_file_name =
233 test::ResourcePath("pc_quality_smoke_test_alice_source", "wav");
234 alice->SetAudioConfig(std::move(audio));
235 },
236 [](PeerConfigurer* bob) {
237 VideoConfig video(640, 360, 30);
238 video.stream_label = "bob-video";
239 bob->AddVideoConfig(std::move(video));
240
241 AudioConfig audio;
242 audio.stream_label = "bob-audio";
243 audio.mode = AudioConfig::Mode::kFile;
244 audio.input_file_name =
245 test::ResourcePath("pc_quality_smoke_test_bob_source", "wav");
246 bob->SetAudioConfig(std::move(audio));
247 });
Artem Titova6a273d2019-02-07 16:43:51 +0100248}
249
Artem Titovd70d80d2019-07-19 11:00:40 +0200250// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
251#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
252#define MAYBE_Svc DISABLED_Svc
253#else
254#define MAYBE_Svc Svc
255#endif
256TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Svc) {
257 RunParams run_params(TimeDelta::seconds(7));
258 run_params.video_codec_name = cricket::kVp9CodecName;
259 RunTest(
260 "simulcast", run_params,
261 [](PeerConfigurer* alice) {
262 VideoConfig simulcast(1280, 720, 30);
263 simulcast.stream_label = "alice-simulcast";
264 // Because we have network with packets loss we can analyze only the
265 // highest spatial layer in SVC mode.
266 simulcast.simulcast_config = VideoSimulcastConfig(3, 2);
267 alice->AddVideoConfig(std::move(simulcast));
268
269 AudioConfig audio;
270 audio.stream_label = "alice-audio";
271 audio.mode = AudioConfig::Mode::kFile;
272 audio.input_file_name =
273 test::ResourcePath("pc_quality_smoke_test_alice_source", "wav");
274 alice->SetAudioConfig(std::move(audio));
275 },
276 [](PeerConfigurer* bob) {
277 VideoConfig video(640, 360, 30);
278 video.stream_label = "bob-video";
279 bob->AddVideoConfig(std::move(video));
280
281 AudioConfig audio;
282 audio.stream_label = "bob-audio";
283 audio.mode = AudioConfig::Mode::kFile;
284 audio.input_file_name =
285 test::ResourcePath("pc_quality_smoke_test_bob_source", "wav");
286 bob->SetAudioConfig(std::move(audio));
287 });
288}
289
Johannes Kronac315b22019-09-19 14:55:58 +0200290// IOS debug builds can be quite slow, disabling to avoid issues with timeouts.
291#if defined(WEBRTC_IOS) && defined(WEBRTC_ARCH_ARM64) && !defined(NDEBUG)
292#define MAYBE_HighBitrate DISABLED_HighBitrate
293#else
294#define MAYBE_HighBitrate HighBitrate
295#endif
296TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_HighBitrate) {
297 RunParams run_params(TimeDelta::seconds(7));
298 run_params.video_codec_name = cricket::kVp9CodecName;
299 run_params.video_codec_required_params = {{"profile-id", "0"}};
300
301 RunTest(
302 "smoke", run_params,
303 [](PeerConfigurer* alice) {
304 PeerConnectionInterface::BitrateParameters bitrate_params;
Johannes Kron3433d562019-09-23 14:46:16 +0200305 bitrate_params.current_bitrate_bps = 3'000'000;
306 bitrate_params.max_bitrate_bps = 3'000'000;
Johannes Kronac315b22019-09-19 14:55:58 +0200307 alice->SetBitrateParameters(bitrate_params);
Johannes Kron3433d562019-09-23 14:46:16 +0200308 VideoConfig video(800, 600, 30);
Johannes Kronac315b22019-09-19 14:55:58 +0200309 video.stream_label = "alice-video";
Johannes Kron3433d562019-09-23 14:46:16 +0200310 video.min_encode_bitrate_bps = 500'000;
311 video.max_encode_bitrate_bps = 3'000'000;
Johannes Kronac315b22019-09-19 14:55:58 +0200312 alice->AddVideoConfig(std::move(video));
313
314 AudioConfig audio;
315 audio.stream_label = "alice-audio";
316 audio.mode = AudioConfig::Mode::kFile;
317 audio.input_file_name =
318 test::ResourcePath("pc_quality_smoke_test_alice_source", "wav");
319 audio.sampling_frequency_in_hz = 48000;
320 alice->SetAudioConfig(std::move(audio));
321 },
322 [](PeerConfigurer* bob) {
323 PeerConnectionInterface::BitrateParameters bitrate_params;
Johannes Kron3433d562019-09-23 14:46:16 +0200324 bitrate_params.current_bitrate_bps = 3'000'000;
325 bitrate_params.max_bitrate_bps = 3'000'000;
Johannes Kronac315b22019-09-19 14:55:58 +0200326 bob->SetBitrateParameters(bitrate_params);
Johannes Kron3433d562019-09-23 14:46:16 +0200327 VideoConfig video(800, 600, 30);
Johannes Kronac315b22019-09-19 14:55:58 +0200328 video.stream_label = "bob-video";
Johannes Kron3433d562019-09-23 14:46:16 +0200329 video.min_encode_bitrate_bps = 500'000;
330 video.max_encode_bitrate_bps = 3'000'000;
Johannes Kronac315b22019-09-19 14:55:58 +0200331 bob->AddVideoConfig(std::move(video));
332
333 AudioConfig audio;
334 audio.stream_label = "bob-audio";
335 audio.mode = AudioConfig::Mode::kFile;
336 audio.input_file_name =
337 test::ResourcePath("pc_quality_smoke_test_bob_source", "wav");
338 bob->SetAudioConfig(std::move(audio));
339 });
340}
341
Artem Titov0b443142019-03-20 11:11:08 +0100342} // namespace webrtc_pc_e2e
Artem Titova6a273d2019-02-07 16:43:51 +0100343} // namespace webrtc