blob: 94a2ad6b8a7b47030bbe24afba4ce980fdab1fdc [file] [log] [blame]
Artem Titovb6c62012019-01-08 14:58:23 +01001/*
2 * Copyright (c) 2018 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 */
Artem Titovd57628f2019-03-22 12:34:25 +010010#ifndef API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_
11#define API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_
Artem Titovb6c62012019-01-08 14:58:23 +010012
Artem Titovf65a89b2019-05-07 11:56:44 +020013#include <map>
Artem Titovb6c62012019-01-08 14:58:23 +010014#include <memory>
15#include <string>
Artem Titov7581ff72019-05-15 15:45:33 +020016#include <utility>
Artem Titovb6c62012019-01-08 14:58:23 +010017#include <vector>
18
Artem Titova6a273d2019-02-07 16:43:51 +010019#include "absl/memory/memory.h"
Artem Titov4a6f8182020-02-27 13:24:19 +010020#include "absl/strings/string_view.h"
21#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 09:11:00 -080022#include "api/async_resolver_factory.h"
23#include "api/call/call_factory_interface.h"
Artem Titovb6c62012019-01-08 14:58:23 +010024#include "api/fec_controller.h"
Artem Titov741daaf2019-03-21 14:37:36 +010025#include "api/function_view.h"
Andrey Logvin435fb9a2020-05-08 08:02:49 +000026#include "api/media_stream_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "api/peer_connection_interface.h"
Danil Chapovalov9305d112019-09-04 13:16:09 +020028#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
Artem Titovf9ed56b2020-05-11 21:17:25 +020029#include "api/rtp_parameters.h"
Danil Chapovalov1a5fc902019-06-10 12:58:03 +020030#include "api/task_queue/task_queue_factory.h"
Artem Titovd57628f2019-03-22 12:34:25 +010031#include "api/test/audio_quality_analyzer_interface.h"
Artem Titov00202262019-12-04 22:34:41 +010032#include "api/test/frame_generator_interface.h"
Artem Titovb6c62012019-01-08 14:58:23 +010033#include "api/test/simulated_network.h"
Artem Titova8549212019-08-19 14:38:06 +020034#include "api/test/stats_observer_interface.h"
Andrey Logvin20f45822020-07-01 08:32:15 +000035#include "api/test/track_id_stream_info_map.h"
Artem Titovd57628f2019-03-22 12:34:25 +010036#include "api/test/video_quality_analyzer_interface.h"
Artem Titovb6c62012019-01-08 14:58:23 +010037#include "api/transport/network_control.h"
Artem Titovebd97702019-01-09 17:55:36 +010038#include "api/units/time_delta.h"
Artem Titovb6c62012019-01-08 14:58:23 +010039#include "api/video_codecs/video_decoder_factory.h"
40#include "api/video_codecs/video_encoder.h"
41#include "api/video_codecs/video_encoder_factory.h"
Artem Titovf65a89b2019-05-07 11:56:44 +020042#include "media/base/media_constants.h"
Niels Möller29d59a12020-06-22 14:48:10 +020043#include "rtc_base/deprecation.h"
Artem Titovb6c62012019-01-08 14:58:23 +010044#include "rtc_base/network.h"
Steve Anton10542f22019-01-11 09:11:00 -080045#include "rtc_base/rtc_certificate_generator.h"
46#include "rtc_base/ssl_certificate.h"
Artem Titovb6c62012019-01-08 14:58:23 +010047#include "rtc_base/thread.h"
Artem Titovb6c62012019-01-08 14:58:23 +010048
49namespace webrtc {
Artem Titov0b443142019-03-20 11:11:08 +010050namespace webrtc_pc_e2e {
Artem Titovb6c62012019-01-08 14:58:23 +010051
Artem Titov7581ff72019-05-15 15:45:33 +020052constexpr size_t kDefaultSlidesWidth = 1850;
53constexpr size_t kDefaultSlidesHeight = 1110;
54
Artem Titovd57628f2019-03-22 12:34:25 +010055// API is in development. Can be changed/removed without notice.
Artem Titovb6c62012019-01-08 14:58:23 +010056class PeerConnectionE2EQualityTestFixture {
57 public:
Andrey Logvinf3319812020-05-13 08:02:26 +000058 // The index of required capturing device in OS provided list of video
59 // devices. On Linux and Windows the list will be obtained via
60 // webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via
61 // [RTCCameraVideoCapturer captureDevices].
62 enum class CapturingDeviceIndex : size_t {};
63
Artem Titov7581ff72019-05-15 15:45:33 +020064 // Contains parameters for screen share scrolling.
65 //
66 // If scrolling is enabled, then it will be done by putting sliding window
67 // on source video and moving this window from top left corner to the
68 // bottom right corner of the picture.
69 //
70 // In such case source dimensions must be greater or equal to the sliding
71 // window dimensions. So |source_width| and |source_height| are the dimensions
72 // of the source frame, while |VideoConfig::width| and |VideoConfig::height|
73 // are the dimensions of the sliding window.
74 //
75 // Because |source_width| and |source_height| are dimensions of the source
76 // frame, they have to be width and height of videos from
77 // |ScreenShareConfig::slides_yuv_file_names|.
78 //
79 // Because scrolling have to be done on single slide it also requires, that
80 // |duration| must be less or equal to
81 // |ScreenShareConfig::slide_change_interval|.
82 struct ScrollingParams {
83 ScrollingParams(TimeDelta duration,
84 size_t source_width,
85 size_t source_height)
86 : duration(duration),
87 source_width(source_width),
88 source_height(source_height) {
89 RTC_CHECK_GT(duration.ms(), 0);
90 }
91
92 // Duration of scrolling.
93 TimeDelta duration;
94 // Width of source slides video.
95 size_t source_width;
96 // Height of source slides video.
97 size_t source_height;
98 };
99
Artem Titovebd97702019-01-09 17:55:36 +0100100 // Contains screen share video stream properties.
Artem Titovb6c62012019-01-08 14:58:23 +0100101 struct ScreenShareConfig {
Artem Titov7581ff72019-05-15 15:45:33 +0200102 explicit ScreenShareConfig(TimeDelta slide_change_interval)
103 : slide_change_interval(slide_change_interval) {
104 RTC_CHECK_GT(slide_change_interval.ms(), 0);
105 }
106
Artem Titovebd97702019-01-09 17:55:36 +0100107 // Shows how long one slide should be presented on the screen during
108 // slide generation.
109 TimeDelta slide_change_interval;
Artem Titov7581ff72019-05-15 15:45:33 +0200110 // If true, slides will be generated programmatically. No scrolling params
111 // will be applied in such case.
112 bool generate_slides = false;
113 // If present scrolling will be applied. Please read extra requirement on
114 // |slides_yuv_file_names| for scrolling.
115 absl::optional<ScrollingParams> scrolling_params;
116 // Contains list of yuv files with slides.
117 //
118 // If empty, default set of slides will be used. In such case
119 // |VideoConfig::width| must be equal to |kDefaultSlidesWidth| and
120 // |VideoConfig::height| must be equal to |kDefaultSlidesHeight| or if
121 // |scrolling_params| are specified, then |ScrollingParams::source_width|
122 // must be equal to |kDefaultSlidesWidth| and
123 // |ScrollingParams::source_height| must be equal to |kDefaultSlidesHeight|.
Artem Titovb6c62012019-01-08 14:58:23 +0100124 std::vector<std::string> slides_yuv_file_names;
125 };
126
Artem Titovd70d80d2019-07-19 11:00:40 +0200127 // Config for Vp8 simulcast or Vp9 SVC testing.
128 //
129 // SVC support is limited:
130 // During SVC testing there is no SFU, so framework will try to emulate SFU
131 // behavior in regular p2p call. Because of it there are such limitations:
132 // * if |target_spatial_index| is not equal to the highest spatial layer
133 // then no packet/frame drops are allowed.
134 //
135 // If there will be any drops, that will affect requested layer, then
136 // WebRTC SVC implementation will continue decoding only the highest
137 // available layer and won't restore lower layers, so analyzer won't
138 // receive required data which will cause wrong results or test failures.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200139 struct VideoSimulcastConfig {
Artem Titovcc57b932020-05-11 16:09:26 +0200140 explicit VideoSimulcastConfig(int simulcast_streams_count)
141 : simulcast_streams_count(simulcast_streams_count) {
142 RTC_CHECK_GT(simulcast_streams_count, 1);
143 }
Artem Titovef3fd9c2019-06-13 16:36:52 +0200144 VideoSimulcastConfig(int simulcast_streams_count, int target_spatial_index)
145 : simulcast_streams_count(simulcast_streams_count),
146 target_spatial_index(target_spatial_index) {
147 RTC_CHECK_GT(simulcast_streams_count, 1);
148 RTC_CHECK_GE(target_spatial_index, 0);
149 RTC_CHECK_LT(target_spatial_index, simulcast_streams_count);
150 }
151
152 // Specified amount of simulcast streams/SVC layers, depending on which
153 // encoder is used.
154 int simulcast_streams_count;
155 // Specifies spatial index of the video stream to analyze.
156 // There are 2 cases:
157 // 1. simulcast encoder is used:
158 // in such case |target_spatial_index| will specify the index of
159 // simulcast stream, that should be analyzed. Other streams will be
160 // dropped.
161 // 2. SVC encoder is used:
162 // in such case |target_spatial_index| will specify the top interesting
163 // spatial layer and all layers below, including target one will be
164 // processed. All layers above target one will be dropped.
Artem Titovcc57b932020-05-11 16:09:26 +0200165 // If not specified than whatever stream will be received will be analyzed.
166 // It requires Selective Forwarding Unit (SFU) to be configured in the
167 // network.
168 absl::optional<int> target_spatial_index;
Artem Titovf9ed56b2020-05-11 21:17:25 +0200169
170 // Encoding parameters per simulcast layer. If not empty, |encoding_params|
171 // size have to be equal to |simulcast_streams_count|. Will be used to set
172 // transceiver send encoding params for simulcast layers. Applicable only
173 // for codecs that support simulcast (ex. Vp8) and will be ignored
174 // otherwise. RtpEncodingParameters::rid may be changed by fixture
175 // implementation to ensure signaling correctness.
176 std::vector<RtpEncodingParameters> encoding_params;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200177 };
178
Artem Titovebd97702019-01-09 17:55:36 +0100179 // Contains properties of single video stream.
Artem Titovb6c62012019-01-08 14:58:23 +0100180 struct VideoConfig {
Artem Titovc58c01d2019-02-28 13:19:12 +0100181 VideoConfig(size_t width, size_t height, int32_t fps)
182 : width(width), height(height), fps(fps) {}
183
Artem Titov7581ff72019-05-15 15:45:33 +0200184 // Video stream width.
Artem Titovc58c01d2019-02-28 13:19:12 +0100185 const size_t width;
Artem Titov7581ff72019-05-15 15:45:33 +0200186 // Video stream height.
Artem Titovc58c01d2019-02-28 13:19:12 +0100187 const size_t height;
188 const int32_t fps;
Artem Titovb6c62012019-01-08 14:58:23 +0100189 // Have to be unique among all specified configs for all peers in the call.
Artem Titov3481db22019-02-28 13:13:15 +0100190 // Will be auto generated if omitted.
Artem Titovb6c62012019-01-08 14:58:23 +0100191 absl::optional<std::string> stream_label;
Andrey Logvin435fb9a2020-05-08 08:02:49 +0000192 // Will be set for current video track. If equals to kText or kDetailed -
193 // screencast in on.
194 absl::optional<VideoTrackInterface::ContentHint> content_hint;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200195 // If presented video will be transfered in simulcast/SVC mode depending on
196 // which encoder is used.
197 //
Artem Titov46c7a162019-07-29 13:17:14 +0200198 // Simulcast is supported only from 1st added peer. For VP8 simulcast only
199 // without RTX is supported so it will be automatically disabled for all
200 // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX,
201 // but only on non-lossy networks. See more in documentation to
202 // VideoSimulcastConfig.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200203 absl::optional<VideoSimulcastConfig> simulcast_config;
Artem Titov1e49ab22019-07-30 13:17:25 +0200204 // Count of temporal layers for video stream. This value will be set into
205 // each RtpEncodingParameters of RtpParameters of corresponding
206 // RtpSenderInterface for this video stream.
207 absl::optional<int> temporal_layers_count;
Artem Titov4a6f8182020-02-27 13:24:19 +0100208 // Sets the maximum encode bitrate in bps. If this value is not set, the
Johannes Kron1162ba22019-09-18 10:28:33 +0200209 // encoder will be capped at an internal maximum value around 2 Mbps
210 // depending on the resolution. This means that it will never be able to
211 // utilize a high bandwidth link.
212 absl::optional<int> max_encode_bitrate_bps;
213 // Sets the minimum encode bitrate in bps. If this value is not set, the
214 // encoder will use an internal minimum value. Please note that if this
215 // value is set higher than the bandwidth of the link, the encoder will
216 // generate more data than the link can handle regardless of the bandwidth
217 // estimation.
218 absl::optional<int> min_encode_bitrate_bps;
Artem Titovb6c62012019-01-08 14:58:23 +0100219 // If specified the input stream will be also copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100220 // It is actually one of the test's output file, which contains copy of what
221 // was captured during the test for this video stream on sender side.
222 // It is useful when generator is used as input.
Artem Titovb6c62012019-01-08 14:58:23 +0100223 absl::optional<std::string> input_dump_file_name;
224 // If specified this file will be used as output on the receiver side for
225 // this stream. If multiple streams will be produced by input stream,
Artem Titova6a273d2019-02-07 16:43:51 +0100226 // output files will be appended with indexes. The produced files contains
227 // what was rendered for this video stream on receiver side.
228 absl::optional<std::string> output_dump_file_name;
Artem Titovddef8d12019-09-06 14:31:50 +0200229 // If true will display input and output video on the user's screen.
230 bool show_on_screen = false;
Artem Titov4a6f8182020-02-27 13:24:19 +0100231 // If specified, determines a sync group to which this video stream belongs.
232 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
Andrey Logvin739cfb22020-06-30 07:24:30 +0000233 // for pair of single audio and single video stream.
Artem Titov4a6f8182020-02-27 13:24:19 +0100234 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100235 };
236
Artem Titovebd97702019-01-09 17:55:36 +0100237 // Contains properties for audio in the call.
Artem Titovb6c62012019-01-08 14:58:23 +0100238 struct AudioConfig {
239 enum Mode {
240 kGenerated,
241 kFile,
242 };
Artem Titov3481db22019-02-28 13:13:15 +0100243 // Have to be unique among all specified configs for all peers in the call.
244 // Will be auto generated if omitted.
245 absl::optional<std::string> stream_label;
Artem Titov9a7e7212019-02-28 16:34:17 +0100246 Mode mode = kGenerated;
Artem Titovb6c62012019-01-08 14:58:23 +0100247 // Have to be specified only if mode = kFile
248 absl::optional<std::string> input_file_name;
249 // If specified the input stream will be also copied to specified file.
250 absl::optional<std::string> input_dump_file_name;
251 // If specified the output stream will be copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100252 absl::optional<std::string> output_dump_file_name;
Artem Titovbc558ce2019-07-08 19:13:21 +0200253
Artem Titovb6c62012019-01-08 14:58:23 +0100254 // Audio options to use.
255 cricket::AudioOptions audio_options;
Artem Titovbc558ce2019-07-08 19:13:21 +0200256 // Sampling frequency of input audio data (from file or generated).
257 int sampling_frequency_in_hz = 48000;
Artem Titov4a6f8182020-02-27 13:24:19 +0100258 // If specified, determines a sync group to which this audio stream belongs.
259 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
Andrey Logvin739cfb22020-06-30 07:24:30 +0000260 // for pair of single audio and single video stream.
Artem Titov4a6f8182020-02-27 13:24:19 +0100261 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100262 };
263
Artem Titovd09bc552019-03-20 11:18:58 +0100264 // This class is used to fully configure one peer inside the call.
265 class PeerConfigurer {
266 public:
267 virtual ~PeerConfigurer() = default;
268
Artem Titovbaa2c832020-05-11 19:51:42 +0200269 // Sets peer name that will be used to report metrics related to this peer.
270 // If not set, some default name will be assigned. All names have to be
271 // unique.
272 virtual PeerConfigurer* SetName(absl::string_view name) = 0;
273
Artem Titov524417f2020-01-17 12:18:20 +0100274 // The parameters of the following 9 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100275 // PeerConnectionFactoryInterface implementation that will be created for
276 // this peer.
Danil Chapovalov1a5fc902019-06-10 12:58:03 +0200277 virtual PeerConfigurer* SetTaskQueueFactory(
278 std::unique_ptr<TaskQueueFactory> task_queue_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100279 virtual PeerConfigurer* SetCallFactory(
280 std::unique_ptr<CallFactoryInterface> call_factory) = 0;
281 virtual PeerConfigurer* SetEventLogFactory(
282 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) = 0;
283 virtual PeerConfigurer* SetFecControllerFactory(
284 std::unique_ptr<FecControllerFactoryInterface>
285 fec_controller_factory) = 0;
286 virtual PeerConfigurer* SetNetworkControllerFactory(
287 std::unique_ptr<NetworkControllerFactoryInterface>
288 network_controller_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100289 virtual PeerConfigurer* SetVideoEncoderFactory(
290 std::unique_ptr<VideoEncoderFactory> video_encoder_factory) = 0;
291 virtual PeerConfigurer* SetVideoDecoderFactory(
292 std::unique_ptr<VideoDecoderFactory> video_decoder_factory) = 0;
Artem Titov524417f2020-01-17 12:18:20 +0100293 // Set a custom NetEqFactory to be used in the call.
294 virtual PeerConfigurer* SetNetEqFactory(
295 std::unique_ptr<NetEqFactory> neteq_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100296
Jonas Orelandc7bce992020-01-16 11:27:17 +0100297 // The parameters of the following 4 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100298 // PeerConnectionInterface implementation that will be created for this
299 // peer.
300 virtual PeerConfigurer* SetAsyncResolverFactory(
301 std::unique_ptr<webrtc::AsyncResolverFactory>
302 async_resolver_factory) = 0;
303 virtual PeerConfigurer* SetRTCCertificateGenerator(
304 std::unique_ptr<rtc::RTCCertificateGeneratorInterface>
305 cert_generator) = 0;
306 virtual PeerConfigurer* SetSSLCertificateVerifier(
307 std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier) = 0;
Jonas Orelandc7bce992020-01-16 11:27:17 +0100308 virtual PeerConfigurer* SetIceTransportFactory(
309 std::unique_ptr<IceTransportFactory> factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100310
311 // Add new video stream to the call that will be sent from this peer.
Andrey Logvin42c59522020-05-06 12:18:26 +0000312 // Default implementation of video frames generator will be used.
Artem Titovd09bc552019-03-20 11:18:58 +0100313 virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0;
Artem Titovb4463ee2019-11-12 17:27:44 +0100314 // Add new video stream to the call that will be sent from this peer with
Artem Titov00202262019-12-04 22:34:41 +0100315 // provided own implementation of video frames generator.
Artem Titovb4463ee2019-11-12 17:27:44 +0100316 virtual PeerConfigurer* AddVideoConfig(
317 VideoConfig config,
Artem Titov00202262019-12-04 22:34:41 +0100318 std::unique_ptr<test::FrameGeneratorInterface> generator) = 0;
Andrey Logvinf3319812020-05-13 08:02:26 +0000319 // Add new video stream to the call that will be sent from this peer.
320 // Capturing device with specified index will be used to get input video.
321 virtual PeerConfigurer* AddVideoConfig(
322 VideoConfig config,
323 CapturingDeviceIndex capturing_device_index) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100324 // Set the audio stream for the call from this peer. If this method won't
325 // be invoked, this peer will send no audio.
326 virtual PeerConfigurer* SetAudioConfig(AudioConfig config) = 0;
327 // If is set, an RTCEventLog will be saved in that location and it will be
328 // available for further analysis.
329 virtual PeerConfigurer* SetRtcEventLogPath(std::string path) = 0;
Artem Titov70f80e52019-04-12 13:13:39 +0200330 // If is set, an AEC dump will be saved in that location and it will be
331 // available for further analysis.
332 virtual PeerConfigurer* SetAecDumpPath(std::string path) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100333 virtual PeerConfigurer* SetRTCConfiguration(
334 PeerConnectionInterface::RTCConfiguration configuration) = 0;
Artem Titov85a9d912019-05-29 14:36:50 +0200335 // Set bitrate parameters on PeerConnection. This constraints will be
336 // applied to all summed RTP streams for this peer.
Niels Möller29d59a12020-06-22 14:48:10 +0200337 virtual PeerConfigurer* SetBitrateSettings(
338 BitrateSettings bitrate_settings) = 0;
339 RTC_DEPRECATED
Artem Titov85a9d912019-05-29 14:36:50 +0200340 virtual PeerConfigurer* SetBitrateParameters(
341 PeerConnectionInterface::BitrateParameters bitrate_params) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100342 };
343
Artem Titov728a0ee2019-08-20 13:36:35 +0200344 // Contains configuration for echo emulator.
345 struct EchoEmulationConfig {
346 // Delay which represents the echo path delay, i.e. how soon rendered signal
347 // should reach capturer.
Danil Chapovalov0c626af2020-02-10 11:16:00 +0100348 TimeDelta echo_delay = TimeDelta::Millis(50);
Artem Titov728a0ee2019-08-20 13:36:35 +0200349 };
350
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100351 struct VideoCodecConfig {
352 explicit VideoCodecConfig(std::string name)
353 : name(std::move(name)), required_params() {}
354 VideoCodecConfig(std::string name,
355 std::map<std::string, std::string> required_params)
356 : name(std::move(name)), required_params(std::move(required_params)) {}
357 // Next two fields are used to specify concrete video codec, that should be
358 // used in the test. Video code will be negotiated in SDP during offer/
359 // answer exchange.
360 // Video codec name. You can find valid names in
361 // media/base/media_constants.h
362 std::string name = cricket::kVp8CodecName;
363 // Map of parameters, that have to be specified on SDP codec. Each parameter
364 // is described by key and value. Codec parameters will match the specified
365 // map if and only if for each key from |required_params| there will be
366 // a parameter with name equal to this key and parameter value will be equal
367 // to the value from |required_params| for this key.
368 // If empty then only name will be used to match the codec.
369 std::map<std::string, std::string> required_params;
370 };
371
Artem Titova6a273d2019-02-07 16:43:51 +0100372 // Contains parameters, that describe how long framework should run quality
373 // test.
374 struct RunParams {
Artem Titovade945d2019-04-02 18:31:48 +0200375 explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {}
376
Artem Titova6a273d2019-02-07 16:43:51 +0100377 // Specifies how long the test should be run. This time shows how long
378 // the media should flow after connection was established and before
379 // it will be shut downed.
380 TimeDelta run_duration;
Artem Titovade945d2019-04-02 18:31:48 +0200381
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100382 // List of video codecs to use during the test. These codecs will be
383 // negotiated in SDP during offer/answer exchange. The order of these codecs
384 // during negotiation will be the same as in |video_codecs|. Codecs have
385 // to be available in codecs list provided by peer connection to be
386 // negotiated. If some of specified codecs won't be found, the test will
387 // crash.
Artem Titov80a82f12020-02-12 16:28:14 +0100388 // If list is empty Vp8 with no required_params will be used.
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100389 std::vector<VideoCodecConfig> video_codecs;
Artem Titovf65a89b2019-05-07 11:56:44 +0200390 bool use_ulp_fec = false;
391 bool use_flex_fec = false;
Artem Titovade945d2019-04-02 18:31:48 +0200392 // Specifies how much video encoder target bitrate should be different than
393 // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be
394 // used to emulate overshooting of video encoders. This multiplier will
395 // be applied for all video encoder on both sides for all layers. Bitrate
396 // estimated by WebRTC stack will be multiplied on this multiplier and then
Erik Språng16cb8f52019-04-12 13:59:09 +0200397 // provided into VideoEncoder::SetRates(...).
Artem Titovade945d2019-04-02 18:31:48 +0200398 double video_encoder_bitrate_multiplier = 1.0;
Artem Titov39483c62019-07-19 17:03:52 +0200399 // If true will set conference mode in SDP media section for all video
400 // tracks for all peers.
401 bool use_conference_mode = false;
Artem Titov728a0ee2019-08-20 13:36:35 +0200402 // If specified echo emulation will be done, by mixing the render audio into
403 // the capture signal. In such case input signal will be reduced by half to
404 // avoid saturation or compression in the echo path simulation.
405 absl::optional<EchoEmulationConfig> echo_emulation_config;
Artem Titova6a273d2019-02-07 16:43:51 +0100406 };
407
Artem Titov18459222019-04-24 11:09:35 +0200408 // Represent an entity that will report quality metrics after test.
Artem Titova8549212019-08-19 14:38:06 +0200409 class QualityMetricsReporter : public StatsObserverInterface {
Artem Titov18459222019-04-24 11:09:35 +0200410 public:
411 virtual ~QualityMetricsReporter() = default;
412
413 // Invoked by framework after peer connection factory and peer connection
414 // itself will be created but before offer/answer exchange will be started.
Andrey Logvin9d841fb2020-06-30 12:54:23 +0000415 // |test_case_name| is name of test case, that should be used to report all
416 // metrics.
417 // |reporter_helper| is a pointer to a class that will allow track_id to
418 // stream_id matching. The caller is responsible for ensuring the
Andrey Logvin20f45822020-07-01 08:32:15 +0000419 // TrackIdStreamInfoMap will be valid from Start() to
Andrey Logvin9d841fb2020-06-30 12:54:23 +0000420 // StopAndReportResults().
421 virtual void Start(absl::string_view test_case_name,
Andrey Logvin20f45822020-07-01 08:32:15 +0000422 const TrackIdStreamInfoMap* reporter_helper) = 0;
Andrey Logvin9d841fb2020-06-30 12:54:23 +0000423 // This method has been added for backwards compatibility with upstream
424 // project.
425 void Start(absl::string_view test_case_name) {
426 Start(test_case_name, nullptr);
427 }
Artem Titov18459222019-04-24 11:09:35 +0200428
429 // Invoked by framework after call is ended and peer connection factory and
430 // peer connection are destroyed.
431 virtual void StopAndReportResults() = 0;
432 };
433
Artem Titovd09bc552019-03-20 11:18:58 +0100434 virtual ~PeerConnectionE2EQualityTestFixture() = default;
435
Artem Titovba82e002019-03-15 15:57:53 +0100436 // Add activity that will be executed on the best effort at least after
437 // |target_time_since_start| after call will be set up (after offer/answer
438 // exchange, ICE gathering will be done and ICE candidates will passed to
439 // remote side). |func| param is amount of time spent from the call set up.
440 virtual void ExecuteAt(TimeDelta target_time_since_start,
441 std::function<void(TimeDelta)> func) = 0;
442 // Add activity that will be executed every |interval| with first execution
443 // on the best effort at least after |initial_delay_since_start| after call
444 // will be set up (after all participants will be connected). |func| param is
445 // amount of time spent from the call set up.
446 virtual void ExecuteEvery(TimeDelta initial_delay_since_start,
447 TimeDelta interval,
448 std::function<void(TimeDelta)> func) = 0;
449
Artem Titov18459222019-04-24 11:09:35 +0200450 // Add stats reporter entity to observe the test.
451 virtual void AddQualityMetricsReporter(
452 std::unique_ptr<QualityMetricsReporter> quality_metrics_reporter) = 0;
453
Artem Titovd09bc552019-03-20 11:18:58 +0100454 // Add a new peer to the call and return an object through which caller
455 // can configure peer's behavior.
456 // |network_thread| will be used as network thread for peer's peer connection
457 // |network_manager| will be used to provide network interfaces for peer's
458 // peer connection.
459 // |configurer| function will be used to configure peer in the call.
460 virtual void AddPeer(rtc::Thread* network_thread,
461 rtc::NetworkManager* network_manager,
462 rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0;
Artem Titov65dd2912020-05-27 13:55:33 +0200463 // Runs the media quality test, which includes setting up the call with
464 // configured participants, running it according to provided |run_params| and
465 // terminating it properly at the end. During call duration media quality
466 // metrics are gathered, which are then reported to stdout and (if configured)
467 // to the json/protobuf output file through the WebRTC perf test results
468 // reporting system.
Artem Titovd09bc552019-03-20 11:18:58 +0100469 virtual void Run(RunParams run_params) = 0;
Artem Titovb93c4e62019-05-02 10:52:07 +0200470
471 // Returns real test duration - the time of test execution measured during
472 // test. Client must call this method only after test is finished (after
473 // Run(...) method returned). Test execution time is time from end of call
474 // setup (offer/answer, ICE candidates exchange done and ICE connected) to
475 // start of call tear down (PeerConnection closed).
476 virtual TimeDelta GetRealTestDuration() const = 0;
Artem Titovb6c62012019-01-08 14:58:23 +0100477};
478
Artem Titov0b443142019-03-20 11:11:08 +0100479} // namespace webrtc_pc_e2e
Artem Titovb6c62012019-01-08 14:58:23 +0100480} // namespace webrtc
481
Artem Titovd57628f2019-03-22 12:34:25 +0100482#endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_