media_quality_test_params.h (8177B)
1 /* 2 * Copyright (c) 2022 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 */ 10 #ifndef API_TEST_PCLF_MEDIA_QUALITY_TEST_PARAMS_H_ 11 #define API_TEST_PCLF_MEDIA_QUALITY_TEST_PARAMS_H_ 12 13 #include <cstddef> 14 #include <cstdint> 15 #include <memory> 16 #include <optional> 17 #include <string> 18 #include <utility> 19 #include <vector> 20 21 #include "api/async_dns_resolver.h" 22 #include "api/audio/audio_mixer.h" 23 #include "api/audio/audio_processing.h" 24 #include "api/audio_codecs/audio_decoder_factory.h" 25 #include "api/audio_codecs/audio_encoder_factory.h" 26 #include "api/fec_controller.h" 27 #include "api/field_trials.h" 28 #include "api/ice_transport_interface.h" 29 #include "api/neteq/neteq_factory.h" 30 #include "api/peer_connection_interface.h" 31 #include "api/rtc_event_log/rtc_event_log_factory_interface.h" 32 #include "api/scoped_refptr.h" 33 #include "api/test/pclf/media_configuration.h" 34 #include "api/transport/bitrate_settings.h" 35 #include "api/transport/network_control.h" 36 #include "api/units/time_delta.h" 37 #include "api/video_codecs/video_decoder_factory.h" 38 #include "api/video_codecs/video_encoder_factory.h" 39 #include "p2p/base/port_allocator.h" 40 #include "rtc_base/checks.h" 41 #include "rtc_base/network.h" 42 #include "rtc_base/rtc_certificate_generator.h" 43 #include "rtc_base/socket_factory.h" 44 #include "rtc_base/ssl_certificate.h" 45 #include "rtc_base/thread.h" 46 47 namespace webrtc { 48 namespace webrtc_pc_e2e { 49 50 // Contains most part from PeerConnectionFactoryDependencies. Also all fields 51 // are optional and defaults will be provided by fixture implementation if 52 // any will be omitted. 53 // 54 // Separate class was introduced to clarify which components can be 55 // overridden. For example worker and signaling threads will be provided by 56 // fixture implementation. The same is applicable to the media engine. So user 57 // can override only some parts of media engine like video encoder/decoder 58 // factories. 59 struct PeerConnectionFactoryComponents { 60 std::unique_ptr<NetworkManager> network_manager; 61 SocketFactory* socket_factory = nullptr; 62 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory; 63 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory; 64 std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory; 65 std::unique_ptr<NetEqFactory> neteq_factory; 66 67 std::unique_ptr<VideoEncoderFactory> video_encoder_factory; 68 std::unique_ptr<VideoDecoderFactory> video_decoder_factory; 69 scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory; 70 scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory; 71 72 std::unique_ptr<FieldTrials> field_trials; 73 74 std::unique_ptr<AudioProcessingBuilderInterface> audio_processing; 75 scoped_refptr<webrtc::AudioMixer> audio_mixer; 76 }; 77 78 // Contains most parts from PeerConnectionDependencies. Also all fields are 79 // optional and defaults will be provided by fixture implementation if any 80 // will be omitted. 81 // 82 // Separate class was introduced to clarify which components can be 83 // overridden. For example observer, which is required to 84 // PeerConnectionDependencies, will be provided by fixture implementation, 85 // so client can't inject its own. 86 struct PeerConnectionComponents { 87 std::unique_ptr<webrtc::AsyncDnsResolverFactoryInterface> 88 async_dns_resolver_factory; 89 std::unique_ptr<RTCCertificateGeneratorInterface> cert_generator; 90 std::unique_ptr<SSLCertificateVerifier> tls_cert_verifier; 91 std::unique_ptr<IceTransportFactory> ice_transport_factory; 92 }; 93 94 // Contains all components, that can be overridden in peer connection. Also 95 // has a network thread, that will be used to communicate with another peers. 96 struct InjectableComponents { 97 InjectableComponents(Thread* network_thread, 98 std::unique_ptr<NetworkManager> network_manager, 99 SocketFactory* socket_factory) 100 : network_thread(network_thread), 101 worker_thread(nullptr), 102 pcf_dependencies(std::make_unique<PeerConnectionFactoryComponents>()), 103 pc_dependencies(std::make_unique<PeerConnectionComponents>()) { 104 RTC_CHECK(network_thread); 105 pcf_dependencies->network_manager = std::move(network_manager); 106 pcf_dependencies->socket_factory = socket_factory; 107 } 108 109 Thread* const network_thread; 110 Thread* worker_thread; 111 112 std::unique_ptr<PeerConnectionFactoryComponents> pcf_dependencies; 113 std::unique_ptr<PeerConnectionComponents> pc_dependencies; 114 }; 115 116 // Contains information about call media streams (up to 1 audio stream and 117 // unlimited amount of video streams) and rtc configuration, that will be used 118 // to set up peer connection. 119 struct Params { 120 // Peer name. If empty - default one will be set by the fixture. 121 std::optional<std::string> name; 122 // If `audio_config` is set audio stream will be configured 123 std::optional<AudioConfig> audio_config; 124 // Flags to override `rtc_configuration.port_allocator_config.flags` 125 // 126 // IMPORTANT: if you use WebRTC Network Emulation 127 // (api/test/network_emulation_manager.h) and set this field, remember to set 128 // webrtc::PORTALLOCATOR_DISABLE_TCP. 129 uint32_t port_allocator_flags = PORTALLOCATOR_DISABLE_TCP; 130 // If `rtc_event_log_path` is set, an RTCEventLog will be saved in that 131 // location and it will be available for further analysis. 132 std::optional<std::string> rtc_event_log_path; 133 // If `aec_dump_path` is set, an AEC dump will be saved in that location and 134 // it will be available for further analysis. 135 std::optional<std::string> aec_dump_path; 136 137 bool use_ulp_fec = false; 138 bool use_flex_fec = false; 139 // Specifies how much video encoder target bitrate should be different than 140 // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be 141 // used to emulate overshooting of video encoders. This multiplier will 142 // be applied for all video encoder on both sides for all layers. Bitrate 143 // estimated by WebRTC stack will be multiplied by this multiplier and then 144 // provided into VideoEncoder::SetRates(...). 145 double video_encoder_bitrate_multiplier = 1.0; 146 147 PeerConnectionFactoryInterface::Options peer_connection_factory_options; 148 PeerConnectionInterface::RTCConfiguration rtc_configuration; 149 PeerConnectionInterface::RTCOfferAnswerOptions rtc_offer_answer_options; 150 BitrateSettings bitrate_settings; 151 std::vector<VideoCodecConfig> video_codecs; 152 153 // A list of RTP header extensions which will be enforced on all video streams 154 // added to this peer. 155 std::vector<std::string> extra_video_rtp_header_extensions; 156 // A list of RTP header extensions which will be enforced on all audio streams 157 // added to this peer. 158 std::vector<std::string> extra_audio_rtp_header_extensions; 159 }; 160 161 // Contains parameters that maybe changed by test writer during the test call. 162 struct ConfigurableParams { 163 // If `video_configs` is empty - no video should be added to the test call. 164 std::vector<VideoConfig> video_configs; 165 166 VideoSubscription video_subscription = 167 VideoSubscription().SubscribeToAllPeers(); 168 }; 169 170 // Contains parameters, that describe how long framework should run quality 171 // test. 172 struct RunParams { 173 explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {} 174 175 // Specifies how long the test should be run. This time shows how long 176 // the media should flow after connection was established and before 177 // it will be shut downed. 178 TimeDelta run_duration; 179 180 // If true will set conference mode in SDP media section for all video 181 // tracks for all peers. 182 bool use_conference_mode = false; 183 // If specified echo emulation will be done, by mixing the render audio into 184 // the capture signal. In such case input signal will be reduced by half to 185 // avoid saturation or compression in the echo path simulation. 186 std::optional<EchoEmulationConfig> echo_emulation_config; 187 }; 188 189 } // namespace webrtc_pc_e2e 190 } // namespace webrtc 191 192 #endif // API_TEST_PCLF_MEDIA_QUALITY_TEST_PARAMS_H_