blob: 7a17284284225b9a57553b8ffe2b34f2fb19ad3b [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"
Artem Titovd57628f2019-03-22 12:34:25 +010035#include "api/test/video_quality_analyzer_interface.h"
Niels Möller65f17ca2019-09-12 13:59:36 +020036#include "api/transport/media/media_transport_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"
Artem Titovb6c62012019-01-08 14:58:23 +010043#include "rtc_base/network.h"
Steve Anton10542f22019-01-11 09:11:00 -080044#include "rtc_base/rtc_certificate_generator.h"
45#include "rtc_base/ssl_certificate.h"
Artem Titovb6c62012019-01-08 14:58:23 +010046#include "rtc_base/thread.h"
Artem Titovb6c62012019-01-08 14:58:23 +010047
48namespace webrtc {
Artem Titov0b443142019-03-20 11:11:08 +010049namespace webrtc_pc_e2e {
Artem Titovb6c62012019-01-08 14:58:23 +010050
Artem Titov7581ff72019-05-15 15:45:33 +020051constexpr size_t kDefaultSlidesWidth = 1850;
52constexpr size_t kDefaultSlidesHeight = 1110;
53
Artem Titovd57628f2019-03-22 12:34:25 +010054// API is in development. Can be changed/removed without notice.
Artem Titovb6c62012019-01-08 14:58:23 +010055class PeerConnectionE2EQualityTestFixture {
56 public:
Artem Titov7581ff72019-05-15 15:45:33 +020057 // Contains parameters for screen share scrolling.
58 //
59 // If scrolling is enabled, then it will be done by putting sliding window
60 // on source video and moving this window from top left corner to the
61 // bottom right corner of the picture.
62 //
63 // In such case source dimensions must be greater or equal to the sliding
64 // window dimensions. So |source_width| and |source_height| are the dimensions
65 // of the source frame, while |VideoConfig::width| and |VideoConfig::height|
66 // are the dimensions of the sliding window.
67 //
68 // Because |source_width| and |source_height| are dimensions of the source
69 // frame, they have to be width and height of videos from
70 // |ScreenShareConfig::slides_yuv_file_names|.
71 //
72 // Because scrolling have to be done on single slide it also requires, that
73 // |duration| must be less or equal to
74 // |ScreenShareConfig::slide_change_interval|.
75 struct ScrollingParams {
76 ScrollingParams(TimeDelta duration,
77 size_t source_width,
78 size_t source_height)
79 : duration(duration),
80 source_width(source_width),
81 source_height(source_height) {
82 RTC_CHECK_GT(duration.ms(), 0);
83 }
84
85 // Duration of scrolling.
86 TimeDelta duration;
87 // Width of source slides video.
88 size_t source_width;
89 // Height of source slides video.
90 size_t source_height;
91 };
92
Artem Titovebd97702019-01-09 17:55:36 +010093 // Contains screen share video stream properties.
Artem Titovb6c62012019-01-08 14:58:23 +010094 struct ScreenShareConfig {
Artem Titov7581ff72019-05-15 15:45:33 +020095 explicit ScreenShareConfig(TimeDelta slide_change_interval)
96 : slide_change_interval(slide_change_interval) {
97 RTC_CHECK_GT(slide_change_interval.ms(), 0);
98 }
99
Artem Titovebd97702019-01-09 17:55:36 +0100100 // Shows how long one slide should be presented on the screen during
101 // slide generation.
102 TimeDelta slide_change_interval;
Artem Titov7581ff72019-05-15 15:45:33 +0200103 // If true, slides will be generated programmatically. No scrolling params
104 // will be applied in such case.
105 bool generate_slides = false;
106 // If present scrolling will be applied. Please read extra requirement on
107 // |slides_yuv_file_names| for scrolling.
108 absl::optional<ScrollingParams> scrolling_params;
109 // Contains list of yuv files with slides.
110 //
111 // If empty, default set of slides will be used. In such case
112 // |VideoConfig::width| must be equal to |kDefaultSlidesWidth| and
113 // |VideoConfig::height| must be equal to |kDefaultSlidesHeight| or if
114 // |scrolling_params| are specified, then |ScrollingParams::source_width|
115 // must be equal to |kDefaultSlidesWidth| and
116 // |ScrollingParams::source_height| must be equal to |kDefaultSlidesHeight|.
Artem Titovb6c62012019-01-08 14:58:23 +0100117 std::vector<std::string> slides_yuv_file_names;
118 };
119
Artem Titova6a273d2019-02-07 16:43:51 +0100120 enum VideoGeneratorType { kDefault, kI420A, kI010 };
121
Artem Titovd70d80d2019-07-19 11:00:40 +0200122 // Config for Vp8 simulcast or Vp9 SVC testing.
123 //
124 // SVC support is limited:
125 // During SVC testing there is no SFU, so framework will try to emulate SFU
126 // behavior in regular p2p call. Because of it there are such limitations:
127 // * if |target_spatial_index| is not equal to the highest spatial layer
128 // then no packet/frame drops are allowed.
129 //
130 // If there will be any drops, that will affect requested layer, then
131 // WebRTC SVC implementation will continue decoding only the highest
132 // available layer and won't restore lower layers, so analyzer won't
133 // receive required data which will cause wrong results or test failures.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200134 struct VideoSimulcastConfig {
Artem Titovcc57b932020-05-11 16:09:26 +0200135 explicit VideoSimulcastConfig(int simulcast_streams_count)
136 : simulcast_streams_count(simulcast_streams_count) {
137 RTC_CHECK_GT(simulcast_streams_count, 1);
138 }
Artem Titovef3fd9c2019-06-13 16:36:52 +0200139 VideoSimulcastConfig(int simulcast_streams_count, int target_spatial_index)
140 : simulcast_streams_count(simulcast_streams_count),
141 target_spatial_index(target_spatial_index) {
142 RTC_CHECK_GT(simulcast_streams_count, 1);
143 RTC_CHECK_GE(target_spatial_index, 0);
144 RTC_CHECK_LT(target_spatial_index, simulcast_streams_count);
145 }
146
147 // Specified amount of simulcast streams/SVC layers, depending on which
148 // encoder is used.
149 int simulcast_streams_count;
150 // Specifies spatial index of the video stream to analyze.
151 // There are 2 cases:
152 // 1. simulcast encoder is used:
153 // in such case |target_spatial_index| will specify the index of
154 // simulcast stream, that should be analyzed. Other streams will be
155 // dropped.
156 // 2. SVC encoder is used:
157 // in such case |target_spatial_index| will specify the top interesting
158 // spatial layer and all layers below, including target one will be
159 // processed. All layers above target one will be dropped.
Artem Titovcc57b932020-05-11 16:09:26 +0200160 // If not specified than whatever stream will be received will be analyzed.
161 // It requires Selective Forwarding Unit (SFU) to be configured in the
162 // network.
163 absl::optional<int> target_spatial_index;
Artem Titovf9ed56b2020-05-11 21:17:25 +0200164
165 // Encoding parameters per simulcast layer. If not empty, |encoding_params|
166 // size have to be equal to |simulcast_streams_count|. Will be used to set
167 // transceiver send encoding params for simulcast layers. Applicable only
168 // for codecs that support simulcast (ex. Vp8) and will be ignored
169 // otherwise. RtpEncodingParameters::rid may be changed by fixture
170 // implementation to ensure signaling correctness.
171 std::vector<RtpEncodingParameters> encoding_params;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200172 };
173
Artem Titovebd97702019-01-09 17:55:36 +0100174 // Contains properties of single video stream.
Artem Titovb6c62012019-01-08 14:58:23 +0100175 struct VideoConfig {
Artem Titovc58c01d2019-02-28 13:19:12 +0100176 VideoConfig(size_t width, size_t height, int32_t fps)
177 : width(width), height(height), fps(fps) {}
178
Artem Titov7581ff72019-05-15 15:45:33 +0200179 // Video stream width.
Artem Titovc58c01d2019-02-28 13:19:12 +0100180 const size_t width;
Artem Titov7581ff72019-05-15 15:45:33 +0200181 // Video stream height.
Artem Titovc58c01d2019-02-28 13:19:12 +0100182 const size_t height;
183 const int32_t fps;
Artem Titovb6c62012019-01-08 14:58:23 +0100184 // Have to be unique among all specified configs for all peers in the call.
Artem Titov3481db22019-02-28 13:13:15 +0100185 // Will be auto generated if omitted.
Artem Titovb6c62012019-01-08 14:58:23 +0100186 absl::optional<std::string> stream_label;
Andrey Logvin435fb9a2020-05-08 08:02:49 +0000187 // Will be set for current video track. If equals to kText or kDetailed -
188 // screencast in on.
189 absl::optional<VideoTrackInterface::ContentHint> content_hint;
Artem Titov9afdddf2019-10-10 13:29:03 +0200190 // If specified this capturing device will be used to get input video. The
191 // |capturing_device_index| is the index of required capturing device in OS
192 // provided list of video devices. On Linux and Windows the list will be
193 // obtained via webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via
194 // [RTCCameraVideoCapturer captureDevices].
195 absl::optional<size_t> capturing_device_index;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200196 // If presented video will be transfered in simulcast/SVC mode depending on
197 // which encoder is used.
198 //
Artem Titov46c7a162019-07-29 13:17:14 +0200199 // Simulcast is supported only from 1st added peer. For VP8 simulcast only
200 // without RTX is supported so it will be automatically disabled for all
201 // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX,
202 // but only on non-lossy networks. See more in documentation to
203 // VideoSimulcastConfig.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200204 absl::optional<VideoSimulcastConfig> simulcast_config;
Artem Titov1e49ab22019-07-30 13:17:25 +0200205 // Count of temporal layers for video stream. This value will be set into
206 // each RtpEncodingParameters of RtpParameters of corresponding
207 // RtpSenderInterface for this video stream.
208 absl::optional<int> temporal_layers_count;
Artem Titov4a6f8182020-02-27 13:24:19 +0100209 // Sets the maximum encode bitrate in bps. If this value is not set, the
Johannes Kron1162ba22019-09-18 10:28:33 +0200210 // encoder will be capped at an internal maximum value around 2 Mbps
211 // depending on the resolution. This means that it will never be able to
212 // utilize a high bandwidth link.
213 absl::optional<int> max_encode_bitrate_bps;
214 // Sets the minimum encode bitrate in bps. If this value is not set, the
215 // encoder will use an internal minimum value. Please note that if this
216 // value is set higher than the bandwidth of the link, the encoder will
217 // generate more data than the link can handle regardless of the bandwidth
218 // estimation.
219 absl::optional<int> min_encode_bitrate_bps;
Artem Titovb6c62012019-01-08 14:58:23 +0100220 // If specified the input stream will be also copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100221 // It is actually one of the test's output file, which contains copy of what
222 // was captured during the test for this video stream on sender side.
223 // It is useful when generator is used as input.
Artem Titovb6c62012019-01-08 14:58:23 +0100224 absl::optional<std::string> input_dump_file_name;
225 // If specified this file will be used as output on the receiver side for
226 // this stream. If multiple streams will be produced by input stream,
Artem Titova6a273d2019-02-07 16:43:51 +0100227 // output files will be appended with indexes. The produced files contains
228 // what was rendered for this video stream on receiver side.
229 absl::optional<std::string> output_dump_file_name;
Artem Titovddef8d12019-09-06 14:31:50 +0200230 // If true will display input and output video on the user's screen.
231 bool show_on_screen = false;
Artem Titov4a6f8182020-02-27 13:24:19 +0100232 // If specified, determines a sync group to which this video stream belongs.
233 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
234 // for pair of single audio and single video stream. Framework won't do any
235 // enforcements on this field.
236 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100237 };
238
Artem Titovebd97702019-01-09 17:55:36 +0100239 // Contains properties for audio in the call.
Artem Titovb6c62012019-01-08 14:58:23 +0100240 struct AudioConfig {
241 enum Mode {
242 kGenerated,
243 kFile,
244 };
Artem Titov3481db22019-02-28 13:13:15 +0100245 // Have to be unique among all specified configs for all peers in the call.
246 // Will be auto generated if omitted.
247 absl::optional<std::string> stream_label;
Artem Titov9a7e7212019-02-28 16:34:17 +0100248 Mode mode = kGenerated;
Artem Titovb6c62012019-01-08 14:58:23 +0100249 // Have to be specified only if mode = kFile
250 absl::optional<std::string> input_file_name;
251 // If specified the input stream will be also copied to specified file.
252 absl::optional<std::string> input_dump_file_name;
253 // If specified the output stream will be copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100254 absl::optional<std::string> output_dump_file_name;
Artem Titovbc558ce2019-07-08 19:13:21 +0200255
Artem Titovb6c62012019-01-08 14:58:23 +0100256 // Audio options to use.
257 cricket::AudioOptions audio_options;
Artem Titovbc558ce2019-07-08 19:13:21 +0200258 // Sampling frequency of input audio data (from file or generated).
259 int sampling_frequency_in_hz = 48000;
Artem Titov4a6f8182020-02-27 13:24:19 +0100260 // If specified, determines a sync group to which this audio stream belongs.
261 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
262 // for pair of single audio and single video stream. Framework won't do any
263 // enforcements on this field.
264 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100265 };
266
Artem Titovd09bc552019-03-20 11:18:58 +0100267 // This class is used to fully configure one peer inside the call.
268 class PeerConfigurer {
269 public:
270 virtual ~PeerConfigurer() = default;
271
Artem Titovbaa2c832020-05-11 19:51:42 +0200272 // Sets peer name that will be used to report metrics related to this peer.
273 // If not set, some default name will be assigned. All names have to be
274 // unique.
275 virtual PeerConfigurer* SetName(absl::string_view name) = 0;
276
Artem Titov524417f2020-01-17 12:18:20 +0100277 // The parameters of the following 9 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100278 // PeerConnectionFactoryInterface implementation that will be created for
279 // this peer.
Danil Chapovalov1a5fc902019-06-10 12:58:03 +0200280 virtual PeerConfigurer* SetTaskQueueFactory(
281 std::unique_ptr<TaskQueueFactory> task_queue_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100282 virtual PeerConfigurer* SetCallFactory(
283 std::unique_ptr<CallFactoryInterface> call_factory) = 0;
284 virtual PeerConfigurer* SetEventLogFactory(
285 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) = 0;
286 virtual PeerConfigurer* SetFecControllerFactory(
287 std::unique_ptr<FecControllerFactoryInterface>
288 fec_controller_factory) = 0;
289 virtual PeerConfigurer* SetNetworkControllerFactory(
290 std::unique_ptr<NetworkControllerFactoryInterface>
291 network_controller_factory) = 0;
292 virtual PeerConfigurer* SetMediaTransportFactory(
293 std::unique_ptr<MediaTransportFactory> media_transport_factory) = 0;
294 virtual PeerConfigurer* SetVideoEncoderFactory(
295 std::unique_ptr<VideoEncoderFactory> video_encoder_factory) = 0;
296 virtual PeerConfigurer* SetVideoDecoderFactory(
297 std::unique_ptr<VideoDecoderFactory> video_decoder_factory) = 0;
Artem Titov524417f2020-01-17 12:18:20 +0100298 // Set a custom NetEqFactory to be used in the call.
299 virtual PeerConfigurer* SetNetEqFactory(
300 std::unique_ptr<NetEqFactory> neteq_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100301
Jonas Orelandc7bce992020-01-16 11:27:17 +0100302 // The parameters of the following 4 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100303 // PeerConnectionInterface implementation that will be created for this
304 // peer.
305 virtual PeerConfigurer* SetAsyncResolverFactory(
306 std::unique_ptr<webrtc::AsyncResolverFactory>
307 async_resolver_factory) = 0;
308 virtual PeerConfigurer* SetRTCCertificateGenerator(
309 std::unique_ptr<rtc::RTCCertificateGeneratorInterface>
310 cert_generator) = 0;
311 virtual PeerConfigurer* SetSSLCertificateVerifier(
312 std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier) = 0;
Jonas Orelandc7bce992020-01-16 11:27:17 +0100313 virtual PeerConfigurer* SetIceTransportFactory(
314 std::unique_ptr<IceTransportFactory> factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100315
316 // Add new video stream to the call that will be sent from this peer.
Andrey Logvin42c59522020-05-06 12:18:26 +0000317 // Default implementation of video frames generator will be used.
Artem Titovd09bc552019-03-20 11:18:58 +0100318 virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0;
Artem Titovb4463ee2019-11-12 17:27:44 +0100319 // Add new video stream to the call that will be sent from this peer with
Artem Titov00202262019-12-04 22:34:41 +0100320 // provided own implementation of video frames generator.
Artem Titovb4463ee2019-11-12 17:27:44 +0100321 virtual PeerConfigurer* AddVideoConfig(
322 VideoConfig config,
Artem Titov00202262019-12-04 22:34:41 +0100323 std::unique_ptr<test::FrameGeneratorInterface> generator) = 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.
337 virtual PeerConfigurer* SetBitrateParameters(
338 PeerConnectionInterface::BitrateParameters bitrate_params) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100339 };
340
Artem Titov728a0ee2019-08-20 13:36:35 +0200341 // Contains configuration for echo emulator.
342 struct EchoEmulationConfig {
343 // Delay which represents the echo path delay, i.e. how soon rendered signal
344 // should reach capturer.
Danil Chapovalov0c626af2020-02-10 11:16:00 +0100345 TimeDelta echo_delay = TimeDelta::Millis(50);
Artem Titov728a0ee2019-08-20 13:36:35 +0200346 };
347
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100348 struct VideoCodecConfig {
349 explicit VideoCodecConfig(std::string name)
350 : name(std::move(name)), required_params() {}
351 VideoCodecConfig(std::string name,
352 std::map<std::string, std::string> required_params)
353 : name(std::move(name)), required_params(std::move(required_params)) {}
354 // Next two fields are used to specify concrete video codec, that should be
355 // used in the test. Video code will be negotiated in SDP during offer/
356 // answer exchange.
357 // Video codec name. You can find valid names in
358 // media/base/media_constants.h
359 std::string name = cricket::kVp8CodecName;
360 // Map of parameters, that have to be specified on SDP codec. Each parameter
361 // is described by key and value. Codec parameters will match the specified
362 // map if and only if for each key from |required_params| there will be
363 // a parameter with name equal to this key and parameter value will be equal
364 // to the value from |required_params| for this key.
365 // If empty then only name will be used to match the codec.
366 std::map<std::string, std::string> required_params;
367 };
368
Artem Titova6a273d2019-02-07 16:43:51 +0100369 // Contains parameters, that describe how long framework should run quality
370 // test.
371 struct RunParams {
Artem Titovade945d2019-04-02 18:31:48 +0200372 explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {}
373
Artem Titova6a273d2019-02-07 16:43:51 +0100374 // Specifies how long the test should be run. This time shows how long
375 // the media should flow after connection was established and before
376 // it will be shut downed.
377 TimeDelta run_duration;
Artem Titovade945d2019-04-02 18:31:48 +0200378
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100379 // List of video codecs to use during the test. These codecs will be
380 // negotiated in SDP during offer/answer exchange. The order of these codecs
381 // during negotiation will be the same as in |video_codecs|. Codecs have
382 // to be available in codecs list provided by peer connection to be
383 // negotiated. If some of specified codecs won't be found, the test will
384 // crash.
Artem Titov80a82f12020-02-12 16:28:14 +0100385 // If list is empty Vp8 with no required_params will be used.
Artem Titov9fbe9ae2020-01-20 11:53:26 +0100386 std::vector<VideoCodecConfig> video_codecs;
Artem Titovf65a89b2019-05-07 11:56:44 +0200387 bool use_ulp_fec = false;
388 bool use_flex_fec = false;
Artem Titovade945d2019-04-02 18:31:48 +0200389 // Specifies how much video encoder target bitrate should be different than
390 // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be
391 // used to emulate overshooting of video encoders. This multiplier will
392 // be applied for all video encoder on both sides for all layers. Bitrate
393 // estimated by WebRTC stack will be multiplied on this multiplier and then
Erik Språng16cb8f52019-04-12 13:59:09 +0200394 // provided into VideoEncoder::SetRates(...).
Artem Titovade945d2019-04-02 18:31:48 +0200395 double video_encoder_bitrate_multiplier = 1.0;
Artem Titov39483c62019-07-19 17:03:52 +0200396 // If true will set conference mode in SDP media section for all video
397 // tracks for all peers.
398 bool use_conference_mode = false;
Artem Titov728a0ee2019-08-20 13:36:35 +0200399 // If specified echo emulation will be done, by mixing the render audio into
400 // the capture signal. In such case input signal will be reduced by half to
401 // avoid saturation or compression in the echo path simulation.
402 absl::optional<EchoEmulationConfig> echo_emulation_config;
Artem Titova6a273d2019-02-07 16:43:51 +0100403 };
404
Artem Titov18459222019-04-24 11:09:35 +0200405 // Represent an entity that will report quality metrics after test.
Artem Titova8549212019-08-19 14:38:06 +0200406 class QualityMetricsReporter : public StatsObserverInterface {
Artem Titov18459222019-04-24 11:09:35 +0200407 public:
408 virtual ~QualityMetricsReporter() = default;
409
410 // Invoked by framework after peer connection factory and peer connection
411 // itself will be created but before offer/answer exchange will be started.
412 virtual void Start(absl::string_view test_case_name) = 0;
413
414 // Invoked by framework after call is ended and peer connection factory and
415 // peer connection are destroyed.
416 virtual void StopAndReportResults() = 0;
417 };
418
Artem Titovd09bc552019-03-20 11:18:58 +0100419 virtual ~PeerConnectionE2EQualityTestFixture() = default;
420
Artem Titovba82e002019-03-15 15:57:53 +0100421 // Add activity that will be executed on the best effort at least after
422 // |target_time_since_start| after call will be set up (after offer/answer
423 // exchange, ICE gathering will be done and ICE candidates will passed to
424 // remote side). |func| param is amount of time spent from the call set up.
425 virtual void ExecuteAt(TimeDelta target_time_since_start,
426 std::function<void(TimeDelta)> func) = 0;
427 // Add activity that will be executed every |interval| with first execution
428 // on the best effort at least after |initial_delay_since_start| after call
429 // will be set up (after all participants will be connected). |func| param is
430 // amount of time spent from the call set up.
431 virtual void ExecuteEvery(TimeDelta initial_delay_since_start,
432 TimeDelta interval,
433 std::function<void(TimeDelta)> func) = 0;
434
Artem Titov18459222019-04-24 11:09:35 +0200435 // Add stats reporter entity to observe the test.
436 virtual void AddQualityMetricsReporter(
437 std::unique_ptr<QualityMetricsReporter> quality_metrics_reporter) = 0;
438
Artem Titovd09bc552019-03-20 11:18:58 +0100439 // Add a new peer to the call and return an object through which caller
440 // can configure peer's behavior.
441 // |network_thread| will be used as network thread for peer's peer connection
442 // |network_manager| will be used to provide network interfaces for peer's
443 // peer connection.
444 // |configurer| function will be used to configure peer in the call.
445 virtual void AddPeer(rtc::Thread* network_thread,
446 rtc::NetworkManager* network_manager,
447 rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0;
448 virtual void Run(RunParams run_params) = 0;
Artem Titovb93c4e62019-05-02 10:52:07 +0200449
450 // Returns real test duration - the time of test execution measured during
451 // test. Client must call this method only after test is finished (after
452 // Run(...) method returned). Test execution time is time from end of call
453 // setup (offer/answer, ICE candidates exchange done and ICE connected) to
454 // start of call tear down (PeerConnection closed).
455 virtual TimeDelta GetRealTestDuration() const = 0;
Artem Titovb6c62012019-01-08 14:58:23 +0100456};
457
Artem Titov0b443142019-03-20 11:11:08 +0100458} // namespace webrtc_pc_e2e
Artem Titovb6c62012019-01-08 14:58:23 +0100459} // namespace webrtc
460
Artem Titovd57628f2019-03-22 12:34:25 +0100461#endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_