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