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 | |
| 13 | #include <memory> |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 17 | #include "absl/memory/memory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 18 | #include "api/async_resolver_factory.h" |
| 19 | #include "api/call/call_factory_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 20 | #include "api/fec_controller.h" |
Artem Titov | 741daaf | 2019-03-21 14:37:36 +0100 | [diff] [blame] | 21 | #include "api/function_view.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 22 | #include "api/media_transport_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 23 | #include "api/peer_connection_interface.h" |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 24 | #include "api/test/audio_quality_analyzer_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 25 | #include "api/test/simulated_network.h" |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 26 | #include "api/test/video_quality_analyzer_interface.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 27 | #include "api/transport/network_control.h" |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 28 | #include "api/units/time_delta.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 29 | #include "api/video_codecs/video_decoder_factory.h" |
| 30 | #include "api/video_codecs/video_encoder.h" |
| 31 | #include "api/video_codecs/video_encoder_factory.h" |
| 32 | #include "logging/rtc_event_log/rtc_event_log_factory_interface.h" |
| 33 | #include "rtc_base/network.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 34 | #include "rtc_base/rtc_certificate_generator.h" |
| 35 | #include "rtc_base/ssl_certificate.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 36 | #include "rtc_base/thread.h" |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 37 | |
| 38 | namespace webrtc { |
Artem Titov | 0b44314 | 2019-03-20 11:11:08 +0100 | [diff] [blame] | 39 | namespace webrtc_pc_e2e { |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 40 | |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 41 | // API is in development. Can be changed/removed without notice. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 42 | class PeerConnectionE2EQualityTestFixture { |
| 43 | public: |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 44 | // Contains screen share video stream properties. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 45 | struct ScreenShareConfig { |
| 46 | // If true, slides will be generated programmatically. |
| 47 | bool generate_slides; |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 48 | // Shows how long one slide should be presented on the screen during |
| 49 | // slide generation. |
| 50 | TimeDelta slide_change_interval; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 51 | // If equal to 0, no scrolling will be applied. |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 52 | TimeDelta scroll_duration; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 53 | // If empty, default set of slides will be used. |
| 54 | std::vector<std::string> slides_yuv_file_names; |
| 55 | }; |
| 56 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 57 | enum VideoGeneratorType { kDefault, kI420A, kI010 }; |
| 58 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 59 | // Contains properties of single video stream. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 60 | struct VideoConfig { |
Artem Titov | c58c01d | 2019-02-28 13:19:12 +0100 | [diff] [blame] | 61 | VideoConfig(size_t width, size_t height, int32_t fps) |
| 62 | : width(width), height(height), fps(fps) {} |
| 63 | |
| 64 | const size_t width; |
| 65 | const size_t height; |
| 66 | const int32_t fps; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 67 | // 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] | 68 | // Will be auto generated if omitted. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 69 | absl::optional<std::string> stream_label; |
Artem Titov | 9a7e721 | 2019-02-28 16:34:17 +0100 | [diff] [blame] | 70 | // Only 1 from |generator|, |input_file_name| and |screen_share_config| can |
| 71 | // be specified. If none of them are specified, then |generator| will be set |
| 72 | // to VideoGeneratorType::kDefault. |
| 73 | // If specified generator of this type will be used to produce input video. |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 74 | absl::optional<VideoGeneratorType> generator; |
| 75 | // If specified this file will be used as input. Input video will be played |
| 76 | // in a circle. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 77 | absl::optional<std::string> input_file_name; |
| 78 | // If specified screen share video stream will be created as input. |
| 79 | absl::optional<ScreenShareConfig> screen_share_config; |
Artem Titov | 32232e9 | 2019-02-20 21:13:14 +0100 | [diff] [blame] | 80 | // Specifies spatial index of the video stream to analyze. |
| 81 | // There are 3 cases: |
| 82 | // 1. |target_spatial_index| omitted: in such case it will be assumed that |
| 83 | // video stream has not spatial layers and simulcast streams. |
| 84 | // 2. |target_spatial_index| presented and simulcast encoder is used: |
| 85 | // in such case |target_spatial_index| will specify the index of |
Artem Titov | 3481db2 | 2019-02-28 13:13:15 +0100 | [diff] [blame] | 86 | // simulcast stream, that should be analyzed. Other streams will be |
Artem Titov | 32232e9 | 2019-02-20 21:13:14 +0100 | [diff] [blame] | 87 | // dropped. |
| 88 | // 3. |target_spatial_index| presented and SVP encoder is used: |
| 89 | // in such case |target_spatial_index| will specify the top interesting |
| 90 | // spatial layer and all layers bellow, including target one will be |
| 91 | // processed. All layers above target one will be dropped. |
| 92 | absl::optional<int> target_spatial_index; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 93 | // If specified the input stream will be also copied to specified file. |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 94 | // It is actually one of the test's output file, which contains copy of what |
| 95 | // was captured during the test for this video stream on sender side. |
| 96 | // It is useful when generator is used as input. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 97 | absl::optional<std::string> input_dump_file_name; |
| 98 | // If specified this file will be used as output on the receiver side for |
| 99 | // this stream. If multiple streams will be produced by input stream, |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 100 | // output files will be appended with indexes. The produced files contains |
| 101 | // what was rendered for this video stream on receiver side. |
| 102 | absl::optional<std::string> output_dump_file_name; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 103 | }; |
| 104 | |
Artem Titov | ebd9770 | 2019-01-09 17:55:36 +0100 | [diff] [blame] | 105 | // Contains properties for audio in the call. |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 106 | struct AudioConfig { |
| 107 | enum Mode { |
| 108 | kGenerated, |
| 109 | kFile, |
| 110 | }; |
Artem Titov | 3481db2 | 2019-02-28 13:13:15 +0100 | [diff] [blame] | 111 | // Have to be unique among all specified configs for all peers in the call. |
| 112 | // Will be auto generated if omitted. |
| 113 | absl::optional<std::string> stream_label; |
Artem Titov | 9a7e721 | 2019-02-28 16:34:17 +0100 | [diff] [blame] | 114 | Mode mode = kGenerated; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 115 | // Have to be specified only if mode = kFile |
| 116 | absl::optional<std::string> input_file_name; |
| 117 | // If specified the input stream will be also copied to specified file. |
| 118 | absl::optional<std::string> input_dump_file_name; |
| 119 | // If specified the output stream will be copied to specified file. |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 120 | absl::optional<std::string> output_dump_file_name; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 121 | // Audio options to use. |
| 122 | cricket::AudioOptions audio_options; |
| 123 | }; |
| 124 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 125 | // This class is used to fully configure one peer inside the call. |
| 126 | class PeerConfigurer { |
| 127 | public: |
| 128 | virtual ~PeerConfigurer() = default; |
| 129 | |
| 130 | // The parameters of the following 7 methods will be passed to the |
| 131 | // PeerConnectionFactoryInterface implementation that will be created for |
| 132 | // this peer. |
| 133 | virtual PeerConfigurer* SetCallFactory( |
| 134 | std::unique_ptr<CallFactoryInterface> call_factory) = 0; |
| 135 | virtual PeerConfigurer* SetEventLogFactory( |
| 136 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) = 0; |
| 137 | virtual PeerConfigurer* SetFecControllerFactory( |
| 138 | std::unique_ptr<FecControllerFactoryInterface> |
| 139 | fec_controller_factory) = 0; |
| 140 | virtual PeerConfigurer* SetNetworkControllerFactory( |
| 141 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 142 | network_controller_factory) = 0; |
| 143 | virtual PeerConfigurer* SetMediaTransportFactory( |
| 144 | std::unique_ptr<MediaTransportFactory> media_transport_factory) = 0; |
| 145 | virtual PeerConfigurer* SetVideoEncoderFactory( |
| 146 | std::unique_ptr<VideoEncoderFactory> video_encoder_factory) = 0; |
| 147 | virtual PeerConfigurer* SetVideoDecoderFactory( |
| 148 | std::unique_ptr<VideoDecoderFactory> video_decoder_factory) = 0; |
| 149 | |
| 150 | // The parameters of the following 3 methods will be passed to the |
| 151 | // PeerConnectionInterface implementation that will be created for this |
| 152 | // peer. |
| 153 | virtual PeerConfigurer* SetAsyncResolverFactory( |
| 154 | std::unique_ptr<webrtc::AsyncResolverFactory> |
| 155 | async_resolver_factory) = 0; |
| 156 | virtual PeerConfigurer* SetRTCCertificateGenerator( |
| 157 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> |
| 158 | cert_generator) = 0; |
| 159 | virtual PeerConfigurer* SetSSLCertificateVerifier( |
| 160 | std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier) = 0; |
| 161 | |
| 162 | // Add new video stream to the call that will be sent from this peer. |
| 163 | virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0; |
| 164 | // Set the audio stream for the call from this peer. If this method won't |
| 165 | // be invoked, this peer will send no audio. |
| 166 | virtual PeerConfigurer* SetAudioConfig(AudioConfig config) = 0; |
| 167 | // If is set, an RTCEventLog will be saved in that location and it will be |
| 168 | // available for further analysis. |
| 169 | virtual PeerConfigurer* SetRtcEventLogPath(std::string path) = 0; |
| 170 | virtual PeerConfigurer* SetRTCConfiguration( |
| 171 | PeerConnectionInterface::RTCConfiguration configuration) = 0; |
| 172 | }; |
| 173 | |
Artem Titov | a6a273d | 2019-02-07 16:43:51 +0100 | [diff] [blame] | 174 | // Contains parameters, that describe how long framework should run quality |
| 175 | // test. |
| 176 | struct RunParams { |
| 177 | // Specifies how long the test should be run. This time shows how long |
| 178 | // the media should flow after connection was established and before |
| 179 | // it will be shut downed. |
| 180 | TimeDelta run_duration; |
| 181 | }; |
| 182 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 183 | virtual ~PeerConnectionE2EQualityTestFixture() = default; |
| 184 | |
Artem Titov | ba82e00 | 2019-03-15 15:57:53 +0100 | [diff] [blame] | 185 | // Add activity that will be executed on the best effort at least after |
| 186 | // |target_time_since_start| after call will be set up (after offer/answer |
| 187 | // exchange, ICE gathering will be done and ICE candidates will passed to |
| 188 | // remote side). |func| param is amount of time spent from the call set up. |
| 189 | virtual void ExecuteAt(TimeDelta target_time_since_start, |
| 190 | std::function<void(TimeDelta)> func) = 0; |
| 191 | // Add activity that will be executed every |interval| with first execution |
| 192 | // on the best effort at least after |initial_delay_since_start| after call |
| 193 | // will be set up (after all participants will be connected). |func| param is |
| 194 | // amount of time spent from the call set up. |
| 195 | virtual void ExecuteEvery(TimeDelta initial_delay_since_start, |
| 196 | TimeDelta interval, |
| 197 | std::function<void(TimeDelta)> func) = 0; |
| 198 | |
Artem Titov | d09bc55 | 2019-03-20 11:18:58 +0100 | [diff] [blame] | 199 | // Add a new peer to the call and return an object through which caller |
| 200 | // can configure peer's behavior. |
| 201 | // |network_thread| will be used as network thread for peer's peer connection |
| 202 | // |network_manager| will be used to provide network interfaces for peer's |
| 203 | // peer connection. |
| 204 | // |configurer| function will be used to configure peer in the call. |
| 205 | virtual void AddPeer(rtc::Thread* network_thread, |
| 206 | rtc::NetworkManager* network_manager, |
| 207 | rtc::FunctionView<void(PeerConfigurer*)> configurer) = 0; |
| 208 | virtual void Run(RunParams run_params) = 0; |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 209 | }; |
| 210 | |
Artem Titov | 0b44314 | 2019-03-20 11:11:08 +0100 | [diff] [blame] | 211 | } // namespace webrtc_pc_e2e |
Artem Titov | b6c6201 | 2019-01-08 14:58:23 +0100 | [diff] [blame] | 212 | } // namespace webrtc |
| 213 | |
Artem Titov | d57628f | 2019-03-22 12:34:25 +0100 | [diff] [blame] | 214 | #endif // API_TEST_PEERCONNECTION_QUALITY_TEST_FIXTURE_H_ |