blob: ea230f0ad09983cf30bbc24be0f224b00a7c3e10 [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"
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:
Andrey Logvinf3319812020-05-13 08:02:26 +000057 // The index of required capturing device in OS provided list of video
58 // devices. On Linux and Windows the list will be obtained via
59 // webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via
60 // [RTCCameraVideoCapturer captureDevices].
61 enum class CapturingDeviceIndex : size_t {};
62
Artem Titov7581ff72019-05-15 15:45:33 +020063 // Contains parameters for screen share scrolling.
64 //
65 // If scrolling is enabled, then it will be done by putting sliding window
66 // on source video and moving this window from top left corner to the
67 // bottom right corner of the picture.
68 //
69 // In such case source dimensions must be greater or equal to the sliding
70 // window dimensions. So |source_width| and |source_height| are the dimensions
71 // of the source frame, while |VideoConfig::width| and |VideoConfig::height|
72 // are the dimensions of the sliding window.
73 //
74 // Because |source_width| and |source_height| are dimensions of the source
75 // frame, they have to be width and height of videos from
76 // |ScreenShareConfig::slides_yuv_file_names|.
77 //
78 // Because scrolling have to be done on single slide it also requires, that
79 // |duration| must be less or equal to
80 // |ScreenShareConfig::slide_change_interval|.
81 struct ScrollingParams {
82 ScrollingParams(TimeDelta duration,
83 size_t source_width,
84 size_t source_height)
85 : duration(duration),
86 source_width(source_width),
87 source_height(source_height) {
88 RTC_CHECK_GT(duration.ms(), 0);
89 }
90
91 // Duration of scrolling.
92 TimeDelta duration;
93 // Width of source slides video.
94 size_t source_width;
95 // Height of source slides video.
96 size_t source_height;
97 };
98
Artem Titovebd97702019-01-09 17:55:36 +010099 // Contains screen share video stream properties.
Artem Titovb6c62012019-01-08 14:58:23 +0100100 struct ScreenShareConfig {
Artem Titov7581ff72019-05-15 15:45:33 +0200101 explicit ScreenShareConfig(TimeDelta slide_change_interval)
102 : slide_change_interval(slide_change_interval) {
103 RTC_CHECK_GT(slide_change_interval.ms(), 0);
104 }
105
Artem Titovebd97702019-01-09 17:55:36 +0100106 // Shows how long one slide should be presented on the screen during
107 // slide generation.
108 TimeDelta slide_change_interval;
Artem Titov7581ff72019-05-15 15:45:33 +0200109 // If true, slides will be generated programmatically. No scrolling params
110 // will be applied in such case.
111 bool generate_slides = false;
112 // If present scrolling will be applied. Please read extra requirement on
113 // |slides_yuv_file_names| for scrolling.
114 absl::optional<ScrollingParams> scrolling_params;
115 // Contains list of yuv files with slides.
116 //
117 // If empty, default set of slides will be used. In such case
118 // |VideoConfig::width| must be equal to |kDefaultSlidesWidth| and
119 // |VideoConfig::height| must be equal to |kDefaultSlidesHeight| or if
120 // |scrolling_params| are specified, then |ScrollingParams::source_width|
121 // must be equal to |kDefaultSlidesWidth| and
122 // |ScrollingParams::source_height| must be equal to |kDefaultSlidesHeight|.
Artem Titovb6c62012019-01-08 14:58:23 +0100123 std::vector<std::string> slides_yuv_file_names;
124 };
125
Artem Titovd70d80d2019-07-19 11:00:40 +0200126 // Config for Vp8 simulcast or Vp9 SVC testing.
127 //
128 // SVC support is limited:
129 // During SVC testing there is no SFU, so framework will try to emulate SFU
130 // behavior in regular p2p call. Because of it there are such limitations:
131 // * if |target_spatial_index| is not equal to the highest spatial layer
132 // then no packet/frame drops are allowed.
133 //
134 // If there will be any drops, that will affect requested layer, then
135 // WebRTC SVC implementation will continue decoding only the highest
136 // available layer and won't restore lower layers, so analyzer won't
137 // receive required data which will cause wrong results or test failures.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200138 struct VideoSimulcastConfig {
Artem Titovcc57b932020-05-11 16:09:26 +0200139 explicit VideoSimulcastConfig(int simulcast_streams_count)
140 : simulcast_streams_count(simulcast_streams_count) {
141 RTC_CHECK_GT(simulcast_streams_count, 1);
142 }
Artem Titovef3fd9c2019-06-13 16:36:52 +0200143 VideoSimulcastConfig(int simulcast_streams_count, int target_spatial_index)
144 : simulcast_streams_count(simulcast_streams_count),
145 target_spatial_index(target_spatial_index) {
146 RTC_CHECK_GT(simulcast_streams_count, 1);
147 RTC_CHECK_GE(target_spatial_index, 0);
148 RTC_CHECK_LT(target_spatial_index, simulcast_streams_count);
149 }
150
151 // Specified amount of simulcast streams/SVC layers, depending on which
152 // encoder is used.
153 int simulcast_streams_count;
154 // Specifies spatial index of the video stream to analyze.
155 // There are 2 cases:
156 // 1. simulcast encoder is used:
157 // in such case |target_spatial_index| will specify the index of
158 // simulcast stream, that should be analyzed. Other streams will be
159 // dropped.
160 // 2. SVC encoder is used:
161 // in such case |target_spatial_index| will specify the top interesting
162 // spatial layer and all layers below, including target one will be
163 // processed. All layers above target one will be dropped.
Artem Titovcc57b932020-05-11 16:09:26 +0200164 // If not specified than whatever stream will be received will be analyzed.
165 // It requires Selective Forwarding Unit (SFU) to be configured in the
166 // network.
167 absl::optional<int> target_spatial_index;
Artem Titovf9ed56b2020-05-11 21:17:25 +0200168
169 // Encoding parameters per simulcast layer. If not empty, |encoding_params|
170 // size have to be equal to |simulcast_streams_count|. Will be used to set
171 // transceiver send encoding params for simulcast layers. Applicable only
172 // for codecs that support simulcast (ex. Vp8) and will be ignored
173 // otherwise. RtpEncodingParameters::rid may be changed by fixture
174 // implementation to ensure signaling correctness.
175 std::vector<RtpEncodingParameters> encoding_params;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200176 };
177
Artem Titovebd97702019-01-09 17:55:36 +0100178 // Contains properties of single video stream.
Artem Titovb6c62012019-01-08 14:58:23 +0100179 struct VideoConfig {
Artem Titovc58c01d2019-02-28 13:19:12 +0100180 VideoConfig(size_t width, size_t height, int32_t fps)
181 : width(width), height(height), fps(fps) {}
182
Artem Titov7581ff72019-05-15 15:45:33 +0200183 // Video stream width.
Artem Titovc58c01d2019-02-28 13:19:12 +0100184 const size_t width;
Artem Titov7581ff72019-05-15 15:45:33 +0200185 // Video stream height.
Artem Titovc58c01d2019-02-28 13:19:12 +0100186 const size_t height;
187 const int32_t fps;
Artem Titovb6c62012019-01-08 14:58:23 +0100188 // Have to be unique among all specified configs for all peers in the call.
Artem Titov3481db22019-02-28 13:13:15 +0100189 // Will be auto generated if omitted.
Artem Titovb6c62012019-01-08 14:58:23 +0100190 absl::optional<std::string> stream_label;
Andrey Logvin435fb9a2020-05-08 08:02:49 +0000191 // Will be set for current video track. If equals to kText or kDetailed -
192 // screencast in on.
193 absl::optional<VideoTrackInterface::ContentHint> content_hint;
Artem Titovef3fd9c2019-06-13 16:36:52 +0200194 // If presented video will be transfered in simulcast/SVC mode depending on
195 // which encoder is used.
196 //
Artem Titov46c7a162019-07-29 13:17:14 +0200197 // Simulcast is supported only from 1st added peer. For VP8 simulcast only
198 // without RTX is supported so it will be automatically disabled for all
199 // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX,
200 // but only on non-lossy networks. See more in documentation to
201 // VideoSimulcastConfig.
Artem Titovef3fd9c2019-06-13 16:36:52 +0200202 absl::optional<VideoSimulcastConfig> simulcast_config;
Artem Titov1e49ab22019-07-30 13:17:25 +0200203 // Count of temporal layers for video stream. This value will be set into
204 // each RtpEncodingParameters of RtpParameters of corresponding
205 // RtpSenderInterface for this video stream.
206 absl::optional<int> temporal_layers_count;
Artem Titov4a6f8182020-02-27 13:24:19 +0100207 // Sets the maximum encode bitrate in bps. If this value is not set, the
Johannes Kron1162ba22019-09-18 10:28:33 +0200208 // encoder will be capped at an internal maximum value around 2 Mbps
209 // depending on the resolution. This means that it will never be able to
210 // utilize a high bandwidth link.
211 absl::optional<int> max_encode_bitrate_bps;
212 // Sets the minimum encode bitrate in bps. If this value is not set, the
213 // encoder will use an internal minimum value. Please note that if this
214 // value is set higher than the bandwidth of the link, the encoder will
215 // generate more data than the link can handle regardless of the bandwidth
216 // estimation.
217 absl::optional<int> min_encode_bitrate_bps;
Artem Titovb6c62012019-01-08 14:58:23 +0100218 // If specified the input stream will be also copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100219 // It is actually one of the test's output file, which contains copy of what
220 // was captured during the test for this video stream on sender side.
221 // It is useful when generator is used as input.
Artem Titovb6c62012019-01-08 14:58:23 +0100222 absl::optional<std::string> input_dump_file_name;
Artem Titov484acf22021-02-25 20:44:11 +0100223 // Used only if |input_dump_file_name| is set. Specifies the module for the
224 // video frames to be dumped. Modulo equals X means every Xth frame will be
225 // written to the dump file. The value must be greater than 0.
226 int input_dump_sampling_modulo = 1;
Artem Titovb6c62012019-01-08 14:58:23 +0100227 // If specified this file will be used as output on the receiver side for
228 // this stream. If multiple streams will be produced by input stream,
Artem Titova6a273d2019-02-07 16:43:51 +0100229 // output files will be appended with indexes. The produced files contains
230 // what was rendered for this video stream on receiver side.
231 absl::optional<std::string> output_dump_file_name;
Artem Titov484acf22021-02-25 20:44:11 +0100232 // Used only if |output_dump_file_name| is set. Specifies the module for the
233 // video frames to be dumped. Modulo equals X means every Xth frame will be
234 // written to the dump file. The value must be greater than 0.
235 int output_dump_sampling_modulo = 1;
Artem Titovddef8d12019-09-06 14:31:50 +0200236 // If true will display input and output video on the user's screen.
237 bool show_on_screen = false;
Artem Titov4a6f8182020-02-27 13:24:19 +0100238 // If specified, determines a sync group to which this video stream belongs.
239 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
Andrey Logvin739cfb22020-06-30 07:24:30 +0000240 // for pair of single audio and single video stream.
Artem Titov4a6f8182020-02-27 13:24:19 +0100241 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100242 };
243
Artem Titovebd97702019-01-09 17:55:36 +0100244 // Contains properties for audio in the call.
Artem Titovb6c62012019-01-08 14:58:23 +0100245 struct AudioConfig {
246 enum Mode {
247 kGenerated,
248 kFile,
249 };
Artem Titov3481db22019-02-28 13:13:15 +0100250 // Have to be unique among all specified configs for all peers in the call.
251 // Will be auto generated if omitted.
252 absl::optional<std::string> stream_label;
Artem Titov9a7e7212019-02-28 16:34:17 +0100253 Mode mode = kGenerated;
Artem Titovb6c62012019-01-08 14:58:23 +0100254 // Have to be specified only if mode = kFile
255 absl::optional<std::string> input_file_name;
256 // If specified the input stream will be also copied to specified file.
257 absl::optional<std::string> input_dump_file_name;
258 // If specified the output stream will be copied to specified file.
Artem Titova6a273d2019-02-07 16:43:51 +0100259 absl::optional<std::string> output_dump_file_name;
Artem Titovbc558ce2019-07-08 19:13:21 +0200260
Artem Titovb6c62012019-01-08 14:58:23 +0100261 // Audio options to use.
262 cricket::AudioOptions audio_options;
Artem Titovbc558ce2019-07-08 19:13:21 +0200263 // Sampling frequency of input audio data (from file or generated).
264 int sampling_frequency_in_hz = 48000;
Artem Titov4a6f8182020-02-27 13:24:19 +0100265 // If specified, determines a sync group to which this audio stream belongs.
266 // According to bugs.webrtc.org/4762 WebRTC supports synchronization only
Andrey Logvin739cfb22020-06-30 07:24:30 +0000267 // for pair of single audio and single video stream.
Artem Titov4a6f8182020-02-27 13:24:19 +0100268 absl::optional<std::string> sync_group;
Artem Titovb6c62012019-01-08 14:58:23 +0100269 };
270
Mirko Bonadeif48c3732021-07-15 14:39:43 +0200271 struct VideoCodecConfig {
272 explicit VideoCodecConfig(std::string name)
273 : name(std::move(name)), required_params() {}
274 VideoCodecConfig(std::string name,
275 std::map<std::string, std::string> required_params)
276 : name(std::move(name)), required_params(std::move(required_params)) {}
277 // Next two fields are used to specify concrete video codec, that should be
278 // used in the test. Video code will be negotiated in SDP during offer/
279 // answer exchange.
280 // Video codec name. You can find valid names in
281 // media/base/media_constants.h
282 std::string name = cricket::kVp8CodecName;
283 // Map of parameters, that have to be specified on SDP codec. Each parameter
284 // is described by key and value. Codec parameters will match the specified
285 // map if and only if for each key from |required_params| there will be
286 // a parameter with name equal to this key and parameter value will be equal
287 // to the value from |required_params| for this key.
288 // If empty then only name will be used to match the codec.
289 std::map<std::string, std::string> required_params;
290 };
291
Artem Titovd09bc552019-03-20 11:18:58 +0100292 // This class is used to fully configure one peer inside the call.
293 class PeerConfigurer {
294 public:
295 virtual ~PeerConfigurer() = default;
296
Artem Titovbaa2c832020-05-11 19:51:42 +0200297 // Sets peer name that will be used to report metrics related to this peer.
298 // If not set, some default name will be assigned. All names have to be
299 // unique.
300 virtual PeerConfigurer* SetName(absl::string_view name) = 0;
301
Artem Titov524417f2020-01-17 12:18:20 +0100302 // The parameters of the following 9 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100303 // PeerConnectionFactoryInterface implementation that will be created for
304 // this peer.
Danil Chapovalov1a5fc902019-06-10 12:58:03 +0200305 virtual PeerConfigurer* SetTaskQueueFactory(
306 std::unique_ptr<TaskQueueFactory> task_queue_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100307 virtual PeerConfigurer* SetCallFactory(
308 std::unique_ptr<CallFactoryInterface> call_factory) = 0;
309 virtual PeerConfigurer* SetEventLogFactory(
310 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) = 0;
311 virtual PeerConfigurer* SetFecControllerFactory(
312 std::unique_ptr<FecControllerFactoryInterface>
313 fec_controller_factory) = 0;
314 virtual PeerConfigurer* SetNetworkControllerFactory(
315 std::unique_ptr<NetworkControllerFactoryInterface>
316 network_controller_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100317 virtual PeerConfigurer* SetVideoEncoderFactory(
318 std::unique_ptr<VideoEncoderFactory> video_encoder_factory) = 0;
319 virtual PeerConfigurer* SetVideoDecoderFactory(
320 std::unique_ptr<VideoDecoderFactory> video_decoder_factory) = 0;
Artem Titov524417f2020-01-17 12:18:20 +0100321 // Set a custom NetEqFactory to be used in the call.
322 virtual PeerConfigurer* SetNetEqFactory(
323 std::unique_ptr<NetEqFactory> neteq_factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100324
Jonas Orelandc7bce992020-01-16 11:27:17 +0100325 // The parameters of the following 4 methods will be passed to the
Artem Titovd09bc552019-03-20 11:18:58 +0100326 // PeerConnectionInterface implementation that will be created for this
327 // peer.
328 virtual PeerConfigurer* SetAsyncResolverFactory(
329 std::unique_ptr<webrtc::AsyncResolverFactory>
330 async_resolver_factory) = 0;
331 virtual PeerConfigurer* SetRTCCertificateGenerator(
332 std::unique_ptr<rtc::RTCCertificateGeneratorInterface>
333 cert_generator) = 0;
334 virtual PeerConfigurer* SetSSLCertificateVerifier(
335 std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier) = 0;
Jonas Orelandc7bce992020-01-16 11:27:17 +0100336 virtual PeerConfigurer* SetIceTransportFactory(
337 std::unique_ptr<IceTransportFactory> factory) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100338
339 // Add new video stream to the call that will be sent from this peer.
Andrey Logvin42c59522020-05-06 12:18:26 +0000340 // Default implementation of video frames generator will be used.
Artem Titovd09bc552019-03-20 11:18:58 +0100341 virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0;
Artem Titovb4463ee2019-11-12 17:27:44 +0100342 // Add new video stream to the call that will be sent from this peer with
Artem Titov00202262019-12-04 22:34:41 +0100343 // provided own implementation of video frames generator.
Artem Titovb4463ee2019-11-12 17:27:44 +0100344 virtual PeerConfigurer* AddVideoConfig(
345 VideoConfig config,
Artem Titov00202262019-12-04 22:34:41 +0100346 std::unique_ptr<test::FrameGeneratorInterface> generator) = 0;
Andrey Logvinf3319812020-05-13 08:02:26 +0000347 // Add new video stream to the call that will be sent from this peer.
348 // Capturing device with specified index will be used to get input video.
349 virtual PeerConfigurer* AddVideoConfig(
350 VideoConfig config,
351 CapturingDeviceIndex capturing_device_index) = 0;
Mirko Bonadei4261a732021-07-19 14:28:48 +0200352 // Set the list of video codecs used by the peer during the test. These
353 // codecs will be negotiated in SDP during offer/answer exchange. The order
354 // of these codecs during negotiation will be the same as in |video_codecs|.
355 // Codecs have to be available in codecs list provided by peer connection to
356 // be negotiated. If some of specified codecs won't be found, the test will
357 // crash.
358 virtual PeerConfigurer* SetVideoCodecs(
359 std::vector<VideoCodecConfig> video_codecs) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100360 // Set the audio stream for the call from this peer. If this method won't
361 // be invoked, this peer will send no audio.
362 virtual PeerConfigurer* SetAudioConfig(AudioConfig config) = 0;
363 // If is set, an RTCEventLog will be saved in that location and it will be
364 // available for further analysis.
365 virtual PeerConfigurer* SetRtcEventLogPath(std::string path) = 0;
Artem Titov70f80e52019-04-12 13:13:39 +0200366 // If is set, an AEC dump will be saved in that location and it will be
367 // available for further analysis.
368 virtual PeerConfigurer* SetAecDumpPath(std::string path) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100369 virtual PeerConfigurer* SetRTCConfiguration(
370 PeerConnectionInterface::RTCConfiguration configuration) = 0;
Artem Titov85a9d912019-05-29 14:36:50 +0200371 // Set bitrate parameters on PeerConnection. This constraints will be
372 // applied to all summed RTP streams for this peer.
Niels Möller29d59a12020-06-22 14:48:10 +0200373 virtual PeerConfigurer* SetBitrateSettings(
374 BitrateSettings bitrate_settings) = 0;
Artem Titovd09bc552019-03-20 11:18:58 +0100375 };
376
Artem Titov728a0ee2019-08-20 13:36:35 +0200377 // Contains configuration for echo emulator.
378 struct EchoEmulationConfig {
379 // Delay which represents the echo path delay, i.e. how soon rendered signal
380 // should reach capturer.
Danil Chapovalov0c626af2020-02-10 11:16:00 +0100381 TimeDelta echo_delay = TimeDelta::Millis(50);
Artem Titov728a0ee2019-08-20 13:36:35 +0200382 };
383
Artem Titova6a273d2019-02-07 16:43:51 +0100384 // Contains parameters, that describe how long framework should run quality
385 // test.
386 struct RunParams {
Artem Titovade945d2019-04-02 18:31:48 +0200387 explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {}
388
Artem Titova6a273d2019-02-07 16:43:51 +0100389 // Specifies how long the test should be run. This time shows how long
390 // the media should flow after connection was established and before
391 // it will be shut downed.
392 TimeDelta run_duration;
Artem Titovade945d2019-04-02 18:31:48 +0200393
Artem Titovf65a89b2019-05-07 11:56:44 +0200394 bool use_ulp_fec = false;
395 bool use_flex_fec = false;
Artem Titovade945d2019-04-02 18:31:48 +0200396 // Specifies how much video encoder target bitrate should be different than
397 // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be
398 // used to emulate overshooting of video encoders. This multiplier will
399 // be applied for all video encoder on both sides for all layers. Bitrate
400 // estimated by WebRTC stack will be multiplied on this multiplier and then
Erik Språng16cb8f52019-04-12 13:59:09 +0200401 // provided into VideoEncoder::SetRates(...).
Artem Titovade945d2019-04-02 18:31:48 +0200402 double video_encoder_bitrate_multiplier = 1.0;
Artem Titov39483c62019-07-19 17:03:52 +0200403 // If true will set conference mode in SDP media section for all video
404 // tracks for all peers.
405 bool use_conference_mode = false;
Artem Titov728a0ee2019-08-20 13:36:35 +0200406 // If specified echo emulation will be done, by mixing the render audio into
407 // the capture signal. In such case input signal will be reduced by half to
408 // avoid saturation or compression in the echo path simulation.
409 absl::optional<EchoEmulationConfig> echo_emulation_config;
Artem Titova6a273d2019-02-07 16:43:51 +0100410 };
411
Artem Titov18459222019-04-24 11:09:35 +0200412 // Represent an entity that will report quality metrics after test.
Artem Titova8549212019-08-19 14:38:06 +0200413 class QualityMetricsReporter : public StatsObserverInterface {
Artem Titov18459222019-04-24 11:09:35 +0200414 public:
415 virtual ~QualityMetricsReporter() = default;
416
417 // Invoked by framework after peer connection factory and peer connection
418 // itself will be created but before offer/answer exchange will be started.
Andrey Logvin9d841fb2020-06-30 12:54:23 +0000419 // |test_case_name| is name of test case, that should be used to report all
420 // metrics.
421 // |reporter_helper| is a pointer to a class that will allow track_id to
422 // stream_id matching. The caller is responsible for ensuring the
Andrey Logvin20f45822020-07-01 08:32:15 +0000423 // TrackIdStreamInfoMap will be valid from Start() to
Andrey Logvin9d841fb2020-06-30 12:54:23 +0000424 // StopAndReportResults().
425 virtual void Start(absl::string_view test_case_name,
Andrey Logvin20f45822020-07-01 08:32:15 +0000426 const TrackIdStreamInfoMap* reporter_helper) = 0;
Artem Titov18459222019-04-24 11:09:35 +0200427
428 // Invoked by framework after call is ended and peer connection factory and
429 // peer connection are destroyed.
430 virtual void StopAndReportResults() = 0;
431 };
432
Artem Titovd09bc552019-03-20 11:18:58 +0100433 virtual ~PeerConnectionE2EQualityTestFixture() = default;
434
Artem Titovba82e002019-03-15 15:57:53 +0100435 // Add activity that will be executed on the best effort at least after
436 // |target_time_since_start| after call will be set up (after offer/answer
437 // exchange, ICE gathering will be done and ICE candidates will passed to
438 // remote side). |func| param is amount of time spent from the call set up.
439 virtual void ExecuteAt(TimeDelta target_time_since_start,
440 std::function<void(TimeDelta)> func) = 0;
441 // Add activity that will be executed every |interval| with first execution
442 // on the best effort at least after |initial_delay_since_start| after call
443 // will be set up (after all participants will be connected). |func| param is
444 // amount of time spent from the call set up.
445 virtual void ExecuteEvery(TimeDelta initial_delay_since_start,
446 TimeDelta interval,
447 std::function<void(TimeDelta)> func) = 0;
448
Artem Titov18459222019-04-24 11:09:35 +0200449 // Add stats reporter entity to observe the test.
450 virtual void AddQualityMetricsReporter(
451 std::unique_ptr<QualityMetricsReporter> quality_metrics_reporter) = 0;
452
Artem Titovd09bc552019-03-20 11:18:58 +0100453 // Add a new peer to the call and return an object through which caller
454 // can configure peer's behavior.
455 // |network_thread| will be used as network thread for peer's peer connection
456 // |network_manager| will be used to provide network interfaces for peer's
457 // peer connection.
458 // |configurer| function will be used to configure peer in the call.
459 virtual void AddPeer(rtc::Thread* network_thread,
460 rtc::NetworkManager* network_manager,
461 rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0;
Artem Titov65dd2912020-05-27 13:55:33 +0200462 // Runs the media quality test, which includes setting up the call with
463 // configured participants, running it according to provided |run_params| and
464 // terminating it properly at the end. During call duration media quality
465 // metrics are gathered, which are then reported to stdout and (if configured)
466 // to the json/protobuf output file through the WebRTC perf test results
467 // reporting system.
Artem Titovd09bc552019-03-20 11:18:58 +0100468 virtual void Run(RunParams run_params) = 0;
Artem Titovb93c4e62019-05-02 10:52:07 +0200469
470 // Returns real test duration - the time of test execution measured during
471 // test. Client must call this method only after test is finished (after
472 // Run(...) method returned). Test execution time is time from end of call
473 // setup (offer/answer, ICE candidates exchange done and ICE connected) to
474 // start of call tear down (PeerConnection closed).
475 virtual TimeDelta GetRealTestDuration() const = 0;
Artem Titovb6c62012019-01-08 14:58:23 +0100476};
477
Artem Titov0b443142019-03-20 11:11:08 +0100478} // namespace webrtc_pc_e2e
Artem Titovb6c62012019-01-08 14:58:23 +0100479} // namespace webrtc
480
Artem Titovd57628f2019-03-22 12:34:25 +0100481#endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_