• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <memory>
15 #include <string>
16 #include <vector>
17 
18 #include "api/async_resolver_factory.h"
19 #include "api/audio/audio_mixer.h"
20 #include "api/call/call_factory_interface.h"
21 #include "api/fec_controller.h"
22 #include "api/field_trials_view.h"
23 #include "api/rtc_event_log/rtc_event_log_factory_interface.h"
24 #include "api/task_queue/task_queue_factory.h"
25 #include "api/test/pclf/media_configuration.h"
26 #include "api/transport/network_control.h"
27 #include "api/video_codecs/video_decoder_factory.h"
28 #include "api/video_codecs/video_encoder_factory.h"
29 #include "modules/audio_processing/include/audio_processing.h"
30 #include "p2p/base/port_allocator.h"
31 #include "rtc_base/network.h"
32 #include "rtc_base/rtc_certificate_generator.h"
33 #include "rtc_base/ssl_certificate.h"
34 #include "rtc_base/thread.h"
35 
36 namespace webrtc {
37 namespace webrtc_pc_e2e {
38 
39 // Contains most part from PeerConnectionFactoryDependencies. Also all fields
40 // are optional and defaults will be provided by fixture implementation if
41 // any will be omitted.
42 //
43 // Separate class was introduced to clarify which components can be
44 // overridden. For example worker and signaling threads will be provided by
45 // fixture implementation. The same is applicable to the media engine. So user
46 // can override only some parts of media engine like video encoder/decoder
47 // factories.
48 struct PeerConnectionFactoryComponents {
49   std::unique_ptr<TaskQueueFactory> task_queue_factory;
50   std::unique_ptr<CallFactoryInterface> call_factory;
51   std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory;
52   std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
53   std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
54   std::unique_ptr<NetEqFactory> neteq_factory;
55 
56   // Will be passed to MediaEngineInterface, that will be used in
57   // PeerConnectionFactory.
58   std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
59   std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
60 
61   std::unique_ptr<FieldTrialsView> trials;
62 
63   rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
64   rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer;
65 };
66 
67 // Contains most parts from PeerConnectionDependencies. Also all fields are
68 // optional and defaults will be provided by fixture implementation if any
69 // will be omitted.
70 //
71 // Separate class was introduced to clarify which components can be
72 // overridden. For example observer, which is required to
73 // PeerConnectionDependencies, will be provided by fixture implementation,
74 // so client can't inject its own. Also only network manager can be overridden
75 // inside port allocator.
76 struct PeerConnectionComponents {
PeerConnectionComponentsPeerConnectionComponents77   PeerConnectionComponents(rtc::NetworkManager* network_manager,
78                            rtc::PacketSocketFactory* packet_socket_factory)
79       : network_manager(network_manager),
80         packet_socket_factory(packet_socket_factory) {
81     RTC_CHECK(network_manager);
82   }
83 
84   rtc::NetworkManager* const network_manager;
85   rtc::PacketSocketFactory* const packet_socket_factory;
86   std::unique_ptr<webrtc::AsyncResolverFactory> async_resolver_factory;
87   std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
88   std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier;
89   std::unique_ptr<IceTransportFactory> ice_transport_factory;
90 };
91 
92 // Contains all components, that can be overridden in peer connection. Also
93 // has a network thread, that will be used to communicate with another peers.
94 struct InjectableComponents {
InjectableComponentsInjectableComponents95   InjectableComponents(rtc::Thread* network_thread,
96                        rtc::NetworkManager* network_manager,
97                        rtc::PacketSocketFactory* packet_socket_factory)
98       : network_thread(network_thread),
99         worker_thread(nullptr),
100         pcf_dependencies(std::make_unique<PeerConnectionFactoryComponents>()),
101         pc_dependencies(
102             std::make_unique<PeerConnectionComponents>(network_manager,
103                                                        packet_socket_factory)) {
104     RTC_CHECK(network_thread);
105   }
106 
107   rtc::Thread* const network_thread;
108   rtc::Thread* worker_thread;
109 
110   std::unique_ptr<PeerConnectionFactoryComponents> pcf_dependencies;
111   std::unique_ptr<PeerConnectionComponents> pc_dependencies;
112 };
113 
114 // Contains information about call media streams (up to 1 audio stream and
115 // unlimited amount of video streams) and rtc configuration, that will be used
116 // to set up peer connection.
117 struct Params {
118   // Peer name. If empty - default one will be set by the fixture.
119   absl::optional<std::string> name;
120   // If `audio_config` is set audio stream will be configured
121   absl::optional<AudioConfig> audio_config;
122   // Flags to set on `cricket::PortAllocator`. These flags will be added
123   // to the default ones that are presented on the port allocator.
124   uint32_t port_allocator_extra_flags = cricket::kDefaultPortAllocatorFlags;
125   // If `rtc_event_log_path` is set, an RTCEventLog will be saved in that
126   // location and it will be available for further analysis.
127   absl::optional<std::string> rtc_event_log_path;
128   // If `aec_dump_path` is set, an AEC dump will be saved in that location and
129   // it will be available for further analysis.
130   absl::optional<std::string> aec_dump_path;
131 
132   bool use_ulp_fec = false;
133   bool use_flex_fec = false;
134   // Specifies how much video encoder target bitrate should be different than
135   // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be
136   // used to emulate overshooting of video encoders. This multiplier will
137   // be applied for all video encoder on both sides for all layers. Bitrate
138   // estimated by WebRTC stack will be multiplied by this multiplier and then
139   // provided into VideoEncoder::SetRates(...).
140   double video_encoder_bitrate_multiplier = 1.0;
141 
142   PeerConnectionInterface::RTCConfiguration rtc_configuration;
143   PeerConnectionInterface::RTCOfferAnswerOptions rtc_offer_answer_options;
144   BitrateSettings bitrate_settings;
145   std::vector<VideoCodecConfig> video_codecs;
146 };
147 
148 // Contains parameters that maybe changed by test writer during the test call.
149 struct ConfigurableParams {
150   // If `video_configs` is empty - no video should be added to the test call.
151   std::vector<VideoConfig> video_configs;
152 
153   VideoSubscription video_subscription =
154       VideoSubscription().SubscribeToAllPeers();
155 };
156 
157 // Contains parameters, that describe how long framework should run quality
158 // test.
159 struct RunParams {
RunParamsRunParams160   explicit RunParams(TimeDelta run_duration) : run_duration(run_duration) {}
161 
162   // Specifies how long the test should be run. This time shows how long
163   // the media should flow after connection was established and before
164   // it will be shut downed.
165   TimeDelta run_duration;
166 
167   // If set to true peers will be able to use Flex FEC, otherwise they won't
168   // be able to negotiate it even if it's enabled on per peer level.
169   bool enable_flex_fec_support = false;
170   // If true will set conference mode in SDP media section for all video
171   // tracks for all peers.
172   bool use_conference_mode = false;
173   // If specified echo emulation will be done, by mixing the render audio into
174   // the capture signal. In such case input signal will be reduced by half to
175   // avoid saturation or compression in the echo path simulation.
176   absl::optional<EchoEmulationConfig> echo_emulation_config;
177 };
178 
179 }  // namespace webrtc_pc_e2e
180 }  // namespace webrtc
181 
182 #endif  // API_TEST_PCLF_MEDIA_QUALITY_TEST_PARAMS_H_
183