Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 1 | /* |
| 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 Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 10 | #ifndef API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ |
| 11 | #define API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 12 | |
Artem Titov | f65a89b | 2019-05-07 11:56:44 +0200 | [diff] [blame] | 13 | #include <map> |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 14 | #include <memory> |
| 15 | #include <string> |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 16 | #include <utility> |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 17 | #include <vector> |
| 18 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 19 | #include "absl/memory/memory.h" |
Artem Titov | 4a6f818 | 2020-02-27 13:24:19 +0100 | [diff] [blame] | 20 | #include "absl/strings/string_view.h" |
| 21 | #include "absl/types/optional.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "api/async_resolver_factory.h" |
| 23 | #include "api/call/call_factory_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 24 | #include "api/fec_controller.h" |
Artem Titov | 741daaf | 2019-03-21 14:37:36 +0100 | [diff] [blame] | 25 | #include "api/function_view.h" |
Andrey Logvin | 435fb9a | 2020-05-08 08:02:49 +0000 | [diff] [blame] | 26 | #include "api/media_stream_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 27 | #include "api/peer_connection_interface.h" |
Danil Chapovalov | 9305d11 | 2019-09-04 13:16:09 +0200 | [diff] [blame] | 28 | #include "api/rtc_event_log/rtc_event_log_factory_interface.h" |
Danil Chapovalov | 1a5fc90 | 2019-06-10 12:58:03 +0200 | [diff] [blame] | 29 | #include "api/task_queue/task_queue_factory.h" |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 30 | #include "api/test/audio_quality_analyzer_interface.h" |
Artem Titov | 0020226 | 2019-12-04 22:34:41 +0100 | [diff] [blame] | 31 | #include "api/test/frame_generator_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 32 | #include "api/test/simulated_network.h" |
Artem Titov | a854921 | 2019-08-19 14:38:06 +0200 | [diff] [blame] | 33 | #include "api/test/stats_observer_interface.h" |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 34 | #include "api/test/video_quality_analyzer_interface.h" |
Niels Möller | 65f17ca | 2019-09-12 13:59:36 +0200 | [diff] [blame] | 35 | #include "api/transport/media/media_transport_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 36 | #include "api/transport/network_control.h" |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 37 | #include "api/units/time_delta.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 38 | #include "api/video_codecs/video_decoder_factory.h" |
| 39 | #include "api/video_codecs/video_encoder.h" |
| 40 | #include "api/video_codecs/video_encoder_factory.h" |
Artem Titov | f65a89b | 2019-05-07 11:56:44 +0200 | [diff] [blame] | 41 | #include "media/base/media_constants.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 42 | #include "rtc_base/network.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 43 | #include "rtc_base/rtc_certificate_generator.h" |
| 44 | #include "rtc_base/ssl_certificate.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 45 | #include "rtc_base/thread.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 46 | |
| 47 | namespace webrtc { |
Artem Titov | 0b44314 | 2019-03-20 11:11:08 +0100 | [diff] [blame] | 48 | namespace webrtc_pc_e2e { |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 49 | |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 50 | constexpr size_t kDefaultSlidesWidth = 1850; |
| 51 | constexpr size_t kDefaultSlidesHeight = 1110; |
| 52 | |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 53 | // API is in development. Can be changed/removed without notice. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 54 | class PeerConnectionE2EQualityTestFixture { |
| 55 | public: |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 56 | // Contains parameters for screen share scrolling. |
| 57 | // |
| 58 | // If scrolling is enabled, then it will be done by putting sliding window |
| 59 | // on source video and moving this window from top left corner to the |
| 60 | // bottom right corner of the picture. |
| 61 | // |
| 62 | // In such case source dimensions must be greater or equal to the sliding |
| 63 | // window dimensions. So |source_width| and |source_height| are the dimensions |
| 64 | // of the source frame, while |VideoConfig::width| and |VideoConfig::height| |
| 65 | // are the dimensions of the sliding window. |
| 66 | // |
| 67 | // Because |source_width| and |source_height| are dimensions of the source |
| 68 | // frame, they have to be width and height of videos from |
| 69 | // |ScreenShareConfig::slides_yuv_file_names|. |
| 70 | // |
| 71 | // Because scrolling have to be done on single slide it also requires, that |
| 72 | // |duration| must be less or equal to |
| 73 | // |ScreenShareConfig::slide_change_interval|. |
| 74 | struct ScrollingParams { |
| 75 | ScrollingParams(TimeDelta duration, |
| 76 | size_t source_width, |
| 77 | size_t source_height) |
| 78 | : duration(duration), |
| 79 | source_width(source_width), |
| 80 | source_height(source_height) { |
| 81 | RTC_CHECK_GT(duration.ms(), 0); |
| 82 | } |
| 83 | |
| 84 | // Duration of scrolling. |
| 85 | TimeDelta duration; |
| 86 | // Width of source slides video. |
| 87 | size_t source_width; |
| 88 | // Height of source slides video. |
| 89 | size_t source_height; |
| 90 | }; |
| 91 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 92 | // Contains screen share video stream properties. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 93 | struct ScreenShareConfig { |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 94 | explicit ScreenShareConfig(TimeDelta slide_change_interval) |
| 95 | : slide_change_interval(slide_change_interval) { |
| 96 | RTC_CHECK_GT(slide_change_interval.ms(), 0); |
| 97 | } |
| 98 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 99 | // Shows how long one slide should be presented on the screen during |
| 100 | // slide generation. |
| 101 | TimeDelta slide_change_interval; |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 102 | // If true, slides will be generated programmatically. No scrolling params |
| 103 | // will be applied in such case. |
| 104 | bool generate_slides = false; |
| 105 | // If present scrolling will be applied. Please read extra requirement on |
| 106 | // |slides_yuv_file_names| for scrolling. |
| 107 | absl::optional<ScrollingParams> scrolling_params; |
| 108 | // Contains list of yuv files with slides. |
| 109 | // |
| 110 | // If empty, default set of slides will be used. In such case |
| 111 | // |VideoConfig::width| must be equal to |kDefaultSlidesWidth| and |
| 112 | // |VideoConfig::height| must be equal to |kDefaultSlidesHeight| or if |
| 113 | // |scrolling_params| are specified, then |ScrollingParams::source_width| |
| 114 | // must be equal to |kDefaultSlidesWidth| and |
| 115 | // |ScrollingParams::source_height| must be equal to |kDefaultSlidesHeight|. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 116 | std::vector<std::string> slides_yuv_file_names; |
| 117 | }; |
| 118 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 119 | enum VideoGeneratorType { kDefault, kI420A, kI010 }; |
| 120 | |
Artem Titov | d70d80d | 2019-07-19 11:00:40 +0200 | [diff] [blame] | 121 | // Config for Vp8 simulcast or Vp9 SVC testing. |
| 122 | // |
| 123 | // SVC support is limited: |
| 124 | // During SVC testing there is no SFU, so framework will try to emulate SFU |
| 125 | // behavior in regular p2p call. Because of it there are such limitations: |
| 126 | // * if |target_spatial_index| is not equal to the highest spatial layer |
| 127 | // then no packet/frame drops are allowed. |
| 128 | // |
| 129 | // If there will be any drops, that will affect requested layer, then |
| 130 | // WebRTC SVC implementation will continue decoding only the highest |
| 131 | // available layer and won't restore lower layers, so analyzer won't |
| 132 | // receive required data which will cause wrong results or test failures. |
Artem Titov | ef3fd9c | 2019-06-13 16:36:52 +0200 | [diff] [blame] | 133 | struct VideoSimulcastConfig { |
Artem Titov | cc57b93 | 2020-05-11 16:09:26 +0200 | [diff] [blame] | 134 | explicit VideoSimulcastConfig(int simulcast_streams_count) |
| 135 | : simulcast_streams_count(simulcast_streams_count) { |
| 136 | RTC_CHECK_GT(simulcast_streams_count, 1); |
| 137 | } |
Artem Titov | ef3fd9c | 2019-06-13 16:36:52 +0200 | [diff] [blame] | 138 | VideoSimulcastConfig(int simulcast_streams_count, int target_spatial_index) |
| 139 | : simulcast_streams_count(simulcast_streams_count), |
| 140 | target_spatial_index(target_spatial_index) { |
| 141 | RTC_CHECK_GT(simulcast_streams_count, 1); |
| 142 | RTC_CHECK_GE(target_spatial_index, 0); |
| 143 | RTC_CHECK_LT(target_spatial_index, simulcast_streams_count); |
| 144 | } |
| 145 | |
| 146 | // Specified amount of simulcast streams/SVC layers, depending on which |
| 147 | // encoder is used. |
| 148 | int simulcast_streams_count; |
| 149 | // Specifies spatial index of the video stream to analyze. |
| 150 | // There are 2 cases: |
| 151 | // 1. simulcast encoder is used: |
| 152 | // in such case |target_spatial_index| will specify the index of |
| 153 | // simulcast stream, that should be analyzed. Other streams will be |
| 154 | // dropped. |
| 155 | // 2. SVC encoder is used: |
| 156 | // in such case |target_spatial_index| will specify the top interesting |
| 157 | // spatial layer and all layers below, including target one will be |
| 158 | // processed. All layers above target one will be dropped. |
Artem Titov | cc57b93 | 2020-05-11 16:09:26 +0200 | [diff] [blame] | 159 | // If not specified than whatever stream will be received will be analyzed. |
| 160 | // It requires Selective Forwarding Unit (SFU) to be configured in the |
| 161 | // network. |
| 162 | absl::optional<int> target_spatial_index; |
Artem Titov | ef3fd9c | 2019-06-13 16:36:52 +0200 | [diff] [blame] | 163 | }; |
| 164 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 165 | // Contains properties of single video stream. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 166 | struct VideoConfig { |
Artem Titov | c58c01d | 2019-02-28 13:19:12 +0100 | [diff] [blame] | 167 | VideoConfig(size_t width, size_t height, int32_t fps) |
| 168 | : width(width), height(height), fps(fps) {} |
| 169 | |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 170 | // Video stream width. |
Artem Titov | c58c01d | 2019-02-28 13:19:12 +0100 | [diff] [blame] | 171 | const size_t width; |
Artem Titov | 7581ff7 | 2019-05-15 15:45:33 +0200 | [diff] [blame] | 172 | // Video stream height. |
Artem Titov | c58c01d | 2019-02-28 13:19:12 +0100 | [diff] [blame] | 173 | const size_t height; |
| 174 | const int32_t fps; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 175 | // Have to be unique among all specified configs for all peers in the call. |
Artem Titov | 3481db2 | 2019-02-28 13:13:15 +0100 | [diff] [blame] | 176 | // Will be auto generated if omitted. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 177 | absl::optional<std::string> stream_label; |
Andrey Logvin | 435fb9a | 2020-05-08 08:02:49 +0000 | [diff] [blame] | 178 | // Will be set for current video track. If equals to kText or kDetailed - |
| 179 | // screencast in on. |
| 180 | absl::optional<VideoTrackInterface::ContentHint> content_hint; |
Artem Titov | 9afdddf | 2019-10-10 13:29:03 +0200 | [diff] [blame] | 181 | // If specified this capturing device will be used to get input video. The |
| 182 | // |capturing_device_index| is the index of required capturing device in OS |
| 183 | // provided list of video devices. On Linux and Windows the list will be |
| 184 | // obtained via webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via |
| 185 | // [RTCCameraVideoCapturer captureDevices]. |
| 186 | absl::optional<size_t> capturing_device_index; |
Artem Titov | ef3fd9c | 2019-06-13 16:36:52 +0200 | [diff] [blame] | 187 | // If presented video will be transfered in simulcast/SVC mode depending on |
| 188 | // which encoder is used. |
| 189 | // |
Artem Titov | 46c7a16 | 2019-07-29 13:17:14 +0200 | [diff] [blame] | 190 | // Simulcast is supported only from 1st added peer. For VP8 simulcast only |
| 191 | // without RTX is supported so it will be automatically disabled for all |
| 192 | // simulcast tracks. For VP9 simulcast enables VP9 SVC mode and support RTX, |
| 193 | // but only on non-lossy networks. See more in documentation to |
| 194 | // VideoSimulcastConfig. |
Artem Titov | ef3fd9c | 2019-06-13 16:36:52 +0200 | [diff] [blame] | 195 | absl::optional<VideoSimulcastConfig> simulcast_config; |
Artem Titov | 1e49ab2 | 2019-07-30 13:17:25 +0200 | [diff] [blame] | 196 | // Count of temporal layers for video stream. This value will be set into |
| 197 | // each RtpEncodingParameters of RtpParameters of corresponding |
| 198 | // RtpSenderInterface for this video stream. |
| 199 | absl::optional<int> temporal_layers_count; |
Artem Titov | 4a6f818 | 2020-02-27 13:24:19 +0100 | [diff] [blame] | 200 | // Sets the maximum encode bitrate in bps. If this value is not set, the |
Johannes Kron | 1162ba2 | 2019-09-18 10:28:33 +0200 | [diff] [blame] | 201 | // encoder will be capped at an internal maximum value around 2 Mbps |
| 202 | // depending on the resolution. This means that it will never be able to |
| 203 | // utilize a high bandwidth link. |
| 204 | absl::optional<int> max_encode_bitrate_bps; |
| 205 | // Sets the minimum encode bitrate in bps. If this value is not set, the |
| 206 | // encoder will use an internal minimum value. Please note that if this |
| 207 | // value is set higher than the bandwidth of the link, the encoder will |
| 208 | // generate more data than the link can handle regardless of the bandwidth |
| 209 | // estimation. |
| 210 | absl::optional<int> min_encode_bitrate_bps; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 211 | // If specified the input stream will be also copied to specified file. |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 212 | // It is actually one of the test's output file, which contains copy of what |
| 213 | // was captured during the test for this video stream on sender side. |
| 214 | // It is useful when generator is used as input. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 215 | absl::optional<std::string> input_dump_file_name; |
| 216 | // If specified this file will be used as output on the receiver side for |
| 217 | // this stream. If multiple streams will be produced by input stream, |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 218 | // output files will be appended with indexes. The produced files contains |
| 219 | // what was rendered for this video stream on receiver side. |
| 220 | absl::optional<std::string> output_dump_file_name; |
Artem Titov | ddef8d1 | 2019-09-06 14:31:50 +0200 | [diff] [blame] | 221 | // If true will display input and output video on the user's screen. |
| 222 | bool show_on_screen = false; |
Artem Titov | 4a6f818 | 2020-02-27 13:24:19 +0100 | [diff] [blame] | 223 | // If specified, determines a sync group to which this video stream belongs. |
| 224 | // According to bugs.webrtc.org/4762 WebRTC supports synchronization only |
| 225 | // for pair of single audio and single video stream. Framework won't do any |
| 226 | // enforcements on this field. |
| 227 | absl::optional<std::string> sync_group; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 228 | }; |
| 229 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 230 | // Contains properties for audio in the call. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 231 | struct AudioConfig { |
| 232 | enum Mode { |
| 233 | kGenerated, |
| 234 | kFile, |
| 235 | }; |
Artem Titov | 3481db2 | 2019-02-28 13:13:15 +0100 | [diff] [blame] | 236 | // Have to be unique among all specified configs for all peers in the call. |
| 237 | // Will be auto generated if omitted. |
| 238 | absl::optional<std::string> stream_label; |
Artem Titov | 9a7e721 | 2019-02-28 16:34:17 +0100 | [diff] [blame] | 239 | Mode mode = kGenerated; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 240 | // Have to be specified only if mode = kFile |
| 241 | absl::optional<std::string> input_file_name; |
| 242 | // If specified the input stream will be also copied to specified file. |
| 243 | absl::optional<std::string> input_dump_file_name; |
| 244 | // If specified the output stream will be copied to specified file. |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 245 | absl::optional<std::string> output_dump_file_name; |
Artem Titov | bc558ce | 2019-07-08 19:13:21 +0200 | [diff] [blame] | 246 | |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 247 | // Audio options to use. |
| 248 | cricket::AudioOptions audio_options; |
Artem Titov | bc558ce | 2019-07-08 19:13:21 +0200 | [diff] [blame] | 249 | // Sampling frequency of input audio data (from file or generated). |
| 250 | int sampling_frequency_in_hz = 48000; |
Artem Titov | 4a6f818 | 2020-02-27 13:24:19 +0100 | [diff] [blame] | 251 | // If specified, determines a sync group to which this audio stream belongs. |
| 252 | // According to bugs.webrtc.org/4762 WebRTC supports synchronization only |
| 253 | // for pair of single audio and single video stream. Framework won't do any |
| 254 | // enforcements on this field. |
| 255 | absl::optional<std::string> sync_group; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 256 | }; |
| 257 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 258 | // This class is used to fully configure one peer inside the call. |
| 259 | class PeerConfigurer { |
| 260 | public: |
| 261 | virtual ~PeerConfigurer() = default; |
| 262 | |
Artem Titov | baa2c83 | 2020-05-11 19:51:42 +0200 | [diff] [blame] | 263 | // Sets peer name that will be used to report metrics related to this peer. |
| 264 | // If not set, some default name will be assigned. All names have to be |
| 265 | // unique. |
| 266 | virtual PeerConfigurer* SetName(absl::string_view name) = 0; |
| 267 | |
Artem Titov | 524417f | 2020-01-17 12:18:20 +0100 | [diff] [blame] | 268 | // The parameters of the following 9 methods will be passed to the |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 269 | // PeerConnectionFactoryInterface implementation that will be created for |
| 270 | // this peer. |
Danil Chapovalov | 1a5fc90 | 2019-06-10 12:58:03 +0200 | [diff] [blame] | 271 | virtual PeerConfigurer* SetTaskQueueFactory( |
| 272 | std::unique_ptr<TaskQueueFactory> task_queue_factory) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 273 | virtual PeerConfigurer* SetCallFactory( |
| 274 | std::unique_ptr<CallFactoryInterface> call_factory) = 0; |
| 275 | virtual PeerConfigurer* SetEventLogFactory( |
| 276 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) = 0; |
| 277 | virtual PeerConfigurer* SetFecControllerFactory( |
| 278 | std::unique_ptr<FecControllerFactoryInterface> |
| 279 | fec_controller_factory) = 0; |
| 280 | virtual PeerConfigurer* SetNetworkControllerFactory( |
| 281 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 282 | network_controller_factory) = 0; |
| 283 | virtual PeerConfigurer* SetMediaTransportFactory( |
| 284 | std::unique_ptr<MediaTransportFactory> media_transport_factory) = 0; |
| 285 | virtual PeerConfigurer* SetVideoEncoderFactory( |
| 286 | std::unique_ptr<VideoEncoderFactory> video_encoder_factory) = 0; |
| 287 | virtual PeerConfigurer* SetVideoDecoderFactory( |
| 288 | std::unique_ptr<VideoDecoderFactory> video_decoder_factory) = 0; |
Artem Titov | 524417f | 2020-01-17 12:18:20 +0100 | [diff] [blame] | 289 | // Set a custom NetEqFactory to be used in the call. |
| 290 | virtual PeerConfigurer* SetNetEqFactory( |
| 291 | std::unique_ptr<NetEqFactory> neteq_factory) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 292 | |
Jonas Oreland | c7bce99 | 2020-01-16 11:27:17 +0100 | [diff] [blame] | 293 | // The parameters of the following 4 methods will be passed to the |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 294 | // PeerConnectionInterface implementation that will be created for this |
| 295 | // peer. |
| 296 | virtual PeerConfigurer* SetAsyncResolverFactory( |
| 297 | std::unique_ptr<webrtc::AsyncResolverFactory> |
| 298 | async_resolver_factory) = 0; |
| 299 | virtual PeerConfigurer* SetRTCCertificateGenerator( |
| 300 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> |
| 301 | cert_generator) = 0; |
| 302 | virtual PeerConfigurer* SetSSLCertificateVerifier( |
| 303 | std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier) = 0; |
Jonas Oreland | c7bce99 | 2020-01-16 11:27:17 +0100 | [diff] [blame] | 304 | virtual PeerConfigurer* SetIceTransportFactory( |
| 305 | std::unique_ptr<IceTransportFactory> factory) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 306 | |
| 307 | // Add new video stream to the call that will be sent from this peer. |
Andrey Logvin | 42c5952 | 2020-05-06 12:18:26 +0000 | [diff] [blame] | 308 | // Default implementation of video frames generator will be used. |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 309 | virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0; |
Artem Titov | b4463ee | 2019-11-12 17:27:44 +0100 | [diff] [blame] | 310 | // Add new video stream to the call that will be sent from this peer with |
Artem Titov | 0020226 | 2019-12-04 22:34:41 +0100 | [diff] [blame] | 311 | // provided own implementation of video frames generator. |
Artem Titov | b4463ee | 2019-11-12 17:27:44 +0100 | [diff] [blame] | 312 | virtual PeerConfigurer* AddVideoConfig( |
| 313 | VideoConfig config, |
Artem Titov | 0020226 | 2019-12-04 22:34:41 +0100 | [diff] [blame] | 314 | std::unique_ptr<test::FrameGeneratorInterface> generator) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 315 | // Set the audio stream for the call from this peer. If this method won't |
| 316 | // be invoked, this peer will send no audio. |
| 317 | virtual PeerConfigurer* SetAudioConfig(AudioConfig config) = 0; |
| 318 | // If is set, an RTCEventLog will be saved in that location and it will be |
| 319 | // available for further analysis. |
| 320 | virtual PeerConfigurer* SetRtcEventLogPath(std::string path) = 0; |
Artem Titov | 70f80e5 | 2019-04-12 13:13:39 +0200 | [diff] [blame] | 321 | // If is set, an AEC dump will be saved in that location and it will be |
| 322 | // available for further analysis. |
| 323 | virtual PeerConfigurer* SetAecDumpPath(std::string path) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 324 | virtual PeerConfigurer* SetRTCConfiguration( |
| 325 | PeerConnectionInterface::RTCConfiguration configuration) = 0; |
Artem Titov | 85a9d91 | 2019-05-29 14:36:50 +0200 | [diff] [blame] | 326 | // Set bitrate parameters on PeerConnection. This constraints will be |
| 327 | // applied to all summed RTP streams for this peer. |
| 328 | virtual PeerConfigurer* SetBitrateParameters( |
| 329 | PeerConnectionInterface::BitrateParameters bitrate_params) = 0; |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 330 | }; |
| 331 | |
Artem Titov | 728a0ee | 2019-08-20 13:36:35 +0200 | [diff] [blame] | 332 | // Contains configuration for echo emulator. |
| 333 | struct EchoEmulationConfig { |
| 334 | // Delay which represents the echo path delay, i.e. how soon rendered signal |
| 335 | // should reach capturer. |
Danil Chapovalov | 0c626af | 2020-02-10 11:16:00 +0100 | [diff] [blame] | 336 | TimeDelta echo_delay = TimeDelta::Millis(50); |
Artem Titov | 728a0ee | 2019-08-20 13:36:35 +0200 | [diff] [blame] | 337 | }; |
| 338 | |
Artem Titov | 9fbe9ae | 2020-01-20 11:53:26 +0100 | [diff] [blame] | 339 | struct VideoCodecConfig { |
| 340 | explicit VideoCodecConfig(std::string name) |
| 341 | : name(std::move(name)), required_params() {} |
| 342 | VideoCodecConfig(std::string name, |
| 343 | std::map<std::string, std::string> required_params) |
| 344 | : name(std::move(name)), required_params(std::move(required_params)) {} |
| 345 | // Next two fields are used to specify concrete video codec, that should be |
| 346 | // used in the test. Video code will be negotiated in SDP during offer/ |
| 347 | // answer exchange. |
| 348 | // Video codec name. You can find valid names in |
| 349 | // media/base/media_constants.h |
| 350 | std::string name = cricket::kVp8CodecName; |
| 351 | // Map of parameters, that have to be specified on SDP codec. Each parameter |
| 352 | // is described by key and value. Codec parameters will match the specified |
| 353 | // map if and only if for each key from |required_params| there will be |
| 354 | // a parameter with name equal to this key and parameter value will be equal |
| 355 | // to the value from |required_params| for this key. |
| 356 | // If empty then only name will be used to match the codec. |
| 357 | std::map<std::string, std::string> required_params; |
| 358 | }; |
| 359 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 360 | // Contains parameters, that describe how long framework should run quality |
| 361 | // test. |
| 362 | struct RunParams { |
Artem Titov | ade945d | 2019-04-02 18:31:48 +0200 | [diff] [blame] | 363 | explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {} |
| 364 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 365 | // Specifies how long the test should be run. This time shows how long |
| 366 | // the media should flow after connection was established and before |
| 367 | // it will be shut downed. |
| 368 | TimeDelta run_duration; |
Artem Titov | ade945d | 2019-04-02 18:31:48 +0200 | [diff] [blame] | 369 | |
Artem Titov | 9fbe9ae | 2020-01-20 11:53:26 +0100 | [diff] [blame] | 370 | // List of video codecs to use during the test. These codecs will be |
| 371 | // negotiated in SDP during offer/answer exchange. The order of these codecs |
| 372 | // during negotiation will be the same as in |video_codecs|. Codecs have |
| 373 | // to be available in codecs list provided by peer connection to be |
| 374 | // negotiated. If some of specified codecs won't be found, the test will |
| 375 | // crash. |
Artem Titov | 80a82f1 | 2020-02-12 16:28:14 +0100 | [diff] [blame] | 376 | // If list is empty Vp8 with no required_params will be used. |
Artem Titov | 9fbe9ae | 2020-01-20 11:53:26 +0100 | [diff] [blame] | 377 | std::vector<VideoCodecConfig> video_codecs; |
Artem Titov | f65a89b | 2019-05-07 11:56:44 +0200 | [diff] [blame] | 378 | bool use_ulp_fec = false; |
| 379 | bool use_flex_fec = false; |
Artem Titov | ade945d | 2019-04-02 18:31:48 +0200 | [diff] [blame] | 380 | // Specifies how much video encoder target bitrate should be different than |
| 381 | // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be |
| 382 | // used to emulate overshooting of video encoders. This multiplier will |
| 383 | // be applied for all video encoder on both sides for all layers. Bitrate |
| 384 | // estimated by WebRTC stack will be multiplied on this multiplier and then |
Erik Språng | 16cb8f5 | 2019-04-12 13:59:09 +0200 | [diff] [blame] | 385 | // provided into VideoEncoder::SetRates(...). |
Artem Titov | ade945d | 2019-04-02 18:31:48 +0200 | [diff] [blame] | 386 | double video_encoder_bitrate_multiplier = 1.0; |
Artem Titov | 39483c6 | 2019-07-19 17:03:52 +0200 | [diff] [blame] | 387 | // If true will set conference mode in SDP media section for all video |
| 388 | // tracks for all peers. |
| 389 | bool use_conference_mode = false; |
Artem Titov | 728a0ee | 2019-08-20 13:36:35 +0200 | [diff] [blame] | 390 | // If specified echo emulation will be done, by mixing the render audio into |
| 391 | // the capture signal. In such case input signal will be reduced by half to |
| 392 | // avoid saturation or compression in the echo path simulation. |
| 393 | absl::optional<EchoEmulationConfig> echo_emulation_config; |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 394 | }; |
| 395 | |
Artem Titov | 1845922 | 2019-04-24 11:09:35 +0200 | [diff] [blame] | 396 | // Represent an entity that will report quality metrics after test. |
Artem Titov | a854921 | 2019-08-19 14:38:06 +0200 | [diff] [blame] | 397 | class QualityMetricsReporter : public StatsObserverInterface { |
Artem Titov | 1845922 | 2019-04-24 11:09:35 +0200 | [diff] [blame] | 398 | public: |
| 399 | virtual ~QualityMetricsReporter() = default; |
| 400 | |
| 401 | // Invoked by framework after peer connection factory and peer connection |
| 402 | // itself will be created but before offer/answer exchange will be started. |
| 403 | virtual void Start(absl::string_view test_case_name) = 0; |
| 404 | |
| 405 | // Invoked by framework after call is ended and peer connection factory and |
| 406 | // peer connection are destroyed. |
| 407 | virtual void StopAndReportResults() = 0; |
| 408 | }; |
| 409 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 410 | virtual ~PeerConnectionE2EQualityTestFixture() = default; |
| 411 | |
Artem Titov | ba82e00 | 2019-03-15 15:57:53 +0100 | [diff] [blame] | 412 | // Add activity that will be executed on the best effort at least after |
| 413 | // |target_time_since_start| after call will be set up (after offer/answer |
| 414 | // exchange, ICE gathering will be done and ICE candidates will passed to |
| 415 | // remote side). |func| param is amount of time spent from the call set up. |
| 416 | virtual void ExecuteAt(TimeDelta target_time_since_start, |
| 417 | std::function<void(TimeDelta)> func) = 0; |
| 418 | // Add activity that will be executed every |interval| with first execution |
| 419 | // on the best effort at least after |initial_delay_since_start| after call |
| 420 | // will be set up (after all participants will be connected). |func| param is |
| 421 | // amount of time spent from the call set up. |
| 422 | virtual void ExecuteEvery(TimeDelta initial_delay_since_start, |
| 423 | TimeDelta interval, |
| 424 | std::function<void(TimeDelta)> func) = 0; |
| 425 | |
Artem Titov | 1845922 | 2019-04-24 11:09:35 +0200 | [diff] [blame] | 426 | // Add stats reporter entity to observe the test. |
| 427 | virtual void AddQualityMetricsReporter( |
| 428 | std::unique_ptr<QualityMetricsReporter> quality_metrics_reporter) = 0; |
| 429 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 430 | // Add a new peer to the call and return an object through which caller |
| 431 | // can configure peer's behavior. |
| 432 | // |network_thread| will be used as network thread for peer's peer connection |
| 433 | // |network_manager| will be used to provide network interfaces for peer's |
| 434 | // peer connection. |
| 435 | // |configurer| function will be used to configure peer in the call. |
| 436 | virtual void AddPeer(rtc::Thread* network_thread, |
| 437 | rtc::NetworkManager* network_manager, |
| 438 | rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0; |
| 439 | virtual void Run(RunParams run_params) = 0; |
Artem Titov | b93c4e6 | 2019-05-02 10:52:07 +0200 | [diff] [blame] | 440 | |
| 441 | // Returns real test duration - the time of test execution measured during |
| 442 | // test. Client must call this method only after test is finished (after |
| 443 | // Run(...) method returned). Test execution time is time from end of call |
| 444 | // setup (offer/answer, ICE candidates exchange done and ICE connected) to |
| 445 | // start of call tear down (PeerConnection closed). |
| 446 | virtual TimeDelta GetRealTestDuration() const = 0; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 447 | }; |
| 448 | |
Artem Titov | 0b44314 | 2019-03-20 11:11:08 +0100 | [diff] [blame] | 449 | } // namespace webrtc_pc_e2e |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 450 | } // namespace webrtc |
| 451 | |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 452 | #endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ |