1 /* 2 * Copyright 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 */ 10 #ifndef TEST_SCENARIO_SCENARIO_CONFIG_H_ 11 #define TEST_SCENARIO_SCENARIO_CONFIG_H_ 12 13 #include <stddef.h> 14 15 #include <string> 16 17 #include "absl/types/optional.h" 18 #include "api/fec_controller.h" 19 #include "api/rtp_parameters.h" 20 #include "api/test/frame_generator_interface.h" 21 #include "api/transport/network_control.h" 22 #include "api/units/data_rate.h" 23 #include "api/units/data_size.h" 24 #include "api/units/time_delta.h" 25 #include "api/video/video_codec_type.h" 26 #include "api/video_codecs/scalability_mode.h" 27 #include "test/scenario/performance_stats.h" 28 29 namespace webrtc { 30 namespace test { 31 struct PacketOverhead { 32 static constexpr size_t kSrtp = 10; 33 static constexpr size_t kStun = 4; 34 // TURN messages can be sent either with or without an establieshed channel. 35 // In the latter case, a TURN Send/Data Indication is sent which has 36 // significantly more overhead. 37 static constexpr size_t kTurnChannelMessage = 4; 38 static constexpr size_t kTurnIndicationMessage = 36; 39 static constexpr size_t kDefault = kSrtp; 40 }; 41 struct TransportControllerConfig { 42 struct Rates { 43 Rates(); 44 Rates(const Rates&); 45 ~Rates(); 46 DataRate min_rate = DataRate::KilobitsPerSec(30); 47 DataRate max_rate = DataRate::KilobitsPerSec(3000); 48 DataRate start_rate = DataRate::KilobitsPerSec(300); 49 } rates; 50 NetworkControllerFactoryInterface* cc_factory = nullptr; 51 TimeDelta state_log_interval = TimeDelta::Millis(100); 52 }; 53 54 struct CallClientConfig { 55 TransportControllerConfig transport; 56 const FieldTrialsView* field_trials = nullptr; 57 }; 58 59 struct PacketStreamConfig { 60 PacketStreamConfig(); 61 PacketStreamConfig(const PacketStreamConfig&); 62 ~PacketStreamConfig(); 63 int frame_rate = 30; 64 DataRate max_data_rate = DataRate::Infinity(); 65 DataSize max_packet_size = DataSize::Bytes(1400); 66 DataSize min_frame_size = DataSize::Bytes(100); 67 double keyframe_multiplier = 1; 68 DataSize packet_overhead = DataSize::Bytes(PacketOverhead::kDefault); 69 }; 70 71 struct VideoStreamConfig { 72 bool autostart = true; 73 struct Source { 74 enum Capture { 75 kGenerator, 76 kVideoFile, 77 kGenerateSlides, 78 kImageSlides, 79 // Support for explicit frame triggers should be added here if needed. 80 } capture = Capture::kGenerator; 81 struct Slides { 82 TimeDelta change_interval = TimeDelta::Seconds(10); 83 struct Generator { 84 int width = 1600; 85 int height = 1200; 86 } generator; 87 struct Images { 88 struct Crop { 89 TimeDelta scroll_duration = TimeDelta::Seconds(0); 90 absl::optional<int> width; 91 absl::optional<int> height; 92 } crop; 93 int width = 1850; 94 int height = 1110; 95 std::vector<std::string> paths = { 96 "web_screenshot_1850_1110", 97 "presentation_1850_1110", 98 "photo_1850_1110", 99 "difficult_photo_1850_1110", 100 }; 101 } images; 102 } slides; 103 struct Generator { 104 using PixelFormat = FrameGeneratorInterface::OutputType; 105 PixelFormat pixel_format = PixelFormat::kI420; 106 int width = 320; 107 int height = 180; 108 } generator; 109 struct VideoFile { 110 std::string name; 111 // Must be set to width and height of the source video file. 112 int width = 0; 113 int height = 0; 114 } video_file; 115 int framerate = 30; 116 } source; 117 struct Encoder { 118 Encoder(); 119 Encoder(const Encoder&); 120 ~Encoder(); 121 enum class ContentType { 122 kVideo, 123 kScreen, 124 } content_type = ContentType::kVideo; 125 enum Implementation { kFake, kSoftware, kHardware } implementation = kFake; 126 struct Fake { 127 DataRate max_rate = DataRate::Infinity(); 128 } fake; 129 130 using Codec = VideoCodecType; 131 Codec codec = Codec::kVideoCodecGeneric; 132 absl::optional<DataRate> max_data_rate; 133 absl::optional<DataRate> min_data_rate; 134 absl::optional<int> max_framerate; 135 // Counted in frame count. 136 absl::optional<int> key_frame_interval = 3000; 137 bool frame_dropping = true; 138 struct SingleLayer { 139 bool denoising = true; 140 bool automatic_scaling = true; 141 } single; 142 std::vector<webrtc::ScalabilityMode> simulcast_streams = { 143 webrtc::ScalabilityMode::kL1T1}; 144 145 DegradationPreference degradation_preference = 146 DegradationPreference::MAINTAIN_FRAMERATE; 147 bool suspend_below_min_bitrate = false; 148 } encoder; 149 struct Stream { 150 Stream(); 151 Stream(const Stream&); 152 ~Stream(); 153 bool abs_send_time = false; 154 bool packet_feedback = true; 155 bool use_rtx = true; 156 DataRate pad_to_rate = DataRate::Zero(); 157 TimeDelta nack_history_time = TimeDelta::Millis(1000); 158 bool use_flexfec = false; 159 bool use_ulpfec = false; 160 FecControllerFactoryInterface* fec_controller_factory = nullptr; 161 } stream; 162 struct Rendering { 163 enum Type { kFake } type = kFake; 164 std::string sync_group; 165 } render; 166 struct Hooks { 167 std::vector<std::function<void(const VideoFramePair&)>> frame_pair_handlers; 168 } hooks; 169 }; 170 171 struct AudioStreamConfig { 172 AudioStreamConfig(); 173 AudioStreamConfig(const AudioStreamConfig&); 174 ~AudioStreamConfig(); 175 bool autostart = true; 176 struct Source { 177 int channels = 1; 178 } source; 179 bool network_adaptation = false; 180 struct NetworkAdaptation { 181 struct FrameLength { 182 double min_packet_loss_for_decrease = 0; 183 double max_packet_loss_for_increase = 1; 184 DataRate min_rate_for_20_ms = DataRate::Zero(); 185 DataRate max_rate_for_60_ms = DataRate::Infinity(); 186 DataRate min_rate_for_60_ms = DataRate::Zero(); 187 DataRate max_rate_for_120_ms = DataRate::Infinity(); 188 } frame; 189 std::string binary_proto; 190 } adapt; 191 struct Encoder { 192 Encoder(); 193 Encoder(const Encoder&); 194 ~Encoder(); 195 bool allocate_bitrate = false; 196 bool enable_dtx = false; 197 absl::optional<DataRate> fixed_rate; 198 absl::optional<DataRate> min_rate; 199 absl::optional<DataRate> max_rate; 200 TimeDelta initial_frame_length = TimeDelta::Millis(20); 201 } encoder; 202 struct Stream { 203 Stream(); 204 Stream(const Stream&); 205 ~Stream(); 206 bool abs_send_time = false; 207 bool in_bandwidth_estimation = false; 208 } stream; 209 struct Rendering { 210 std::string sync_group; 211 } render; 212 }; 213 214 // TODO(srte): Merge this with BuiltInNetworkBehaviorConfig. 215 struct NetworkSimulationConfig { 216 DataRate bandwidth = DataRate::Infinity(); 217 TimeDelta delay = TimeDelta::Zero(); 218 TimeDelta delay_std_dev = TimeDelta::Zero(); 219 double loss_rate = 0; 220 absl::optional<int> packet_queue_length_limit; 221 DataSize packet_overhead = DataSize::Zero(); 222 }; 223 } // namespace test 224 } // namespace webrtc 225 226 #endif // TEST_SCENARIO_SCENARIO_CONFIG_H_ 227