blob: c9d636a67f36d6cf6c4829a5d1d1d0b02bdd6056 [file] [log] [blame]
Sebastian Jansson98b07e92018-09-27 13:47:01 +02001/*
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
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <stddef.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020014
Sebastian Jansson98b07e92018-09-27 13:47:01 +020015#include <string>
Sebastian Jansson98b07e92018-09-27 13:47:01 +020016
17#include "absl/types/optional.h"
Sebastian Janssoncc5be542019-04-01 13:34:55 +020018#include "api/fec_controller.h"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "api/rtp_parameters.h"
Artem Titov33f9d2b2019-12-05 15:59:00 +010020#include "api/test/frame_generator_interface.h"
Sebastian Janssonf0d03122018-12-18 15:53:04 +010021#include "api/transport/network_control.h"
Sebastian Jansson98b07e92018-09-27 13:47:01 +020022#include "api/units/data_rate.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "api/units/data_size.h"
Sebastian Jansson98b07e92018-09-27 13:47:01 +020024#include "api/units/time_delta.h"
Niels Möller0cc2fe52019-03-22 14:25:57 +010025#include "api/video/video_codec_type.h"
Sebastian Jansson7150d8c2019-04-09 14:18:09 +020026#include "test/scenario/performance_stats.h"
Sebastian Jansson98b07e92018-09-27 13:47:01 +020027
28namespace webrtc {
29namespace test {
30struct PacketOverhead {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020031 static constexpr size_t kSrtp = 10;
Sebastian Jansson800e1212018-10-22 11:49:03 +020032 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;
Sebastian Janssonc9f42ad2020-01-17 11:47:35 +010038 static constexpr size_t kDefault = kSrtp;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020039};
40struct TransportControllerConfig {
41 struct Rates {
42 Rates();
43 Rates(const Rates&);
44 ~Rates();
Danil Chapovalovcad3e0e2020-02-17 18:46:07 +010045 DataRate min_rate = DataRate::KilobitsPerSec(30);
46 DataRate max_rate = DataRate::KilobitsPerSec(3000);
47 DataRate start_rate = DataRate::KilobitsPerSec(300);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020048 } rates;
Sebastian Janssonf0d03122018-12-18 15:53:04 +010049 NetworkControllerFactoryInterface* cc_factory = nullptr;
Danil Chapovalov0c626af2020-02-10 11:16:00 +010050 TimeDelta state_log_interval = TimeDelta::Millis(100);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020051};
52
53struct CallClientConfig {
54 TransportControllerConfig transport;
Erik Språng014dd3c2019-11-28 13:44:25 +010055 const WebRtcKeyValueConfig* field_trials = nullptr;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020056};
57
Sebastian Jansson71a091e2018-09-27 19:08:21 +020058struct PacketStreamConfig {
59 PacketStreamConfig();
60 PacketStreamConfig(const PacketStreamConfig&);
61 ~PacketStreamConfig();
62 int frame_rate = 30;
63 DataRate max_data_rate = DataRate::Infinity();
Danil Chapovalovcad3e0e2020-02-17 18:46:07 +010064 DataSize max_packet_size = DataSize::Bytes(1400);
65 DataSize min_frame_size = DataSize::Bytes(100);
Sebastian Jansson71a091e2018-09-27 19:08:21 +020066 double keyframe_multiplier = 1;
Danil Chapovalovcad3e0e2020-02-17 18:46:07 +010067 DataSize packet_overhead = DataSize::Bytes(PacketOverhead::kDefault);
Sebastian Jansson71a091e2018-09-27 19:08:21 +020068};
69
Sebastian Jansson98b07e92018-09-27 13:47:01 +020070struct VideoStreamConfig {
71 bool autostart = true;
72 struct Source {
73 enum Capture {
74 kGenerator,
75 kVideoFile,
Sebastian Janssonf2727fb2019-02-18 16:54:55 +010076 kGenerateSlides,
77 kImageSlides,
78 // Support for explicit frame triggers should be added here if needed.
Sebastian Jansson98b07e92018-09-27 13:47:01 +020079 } capture = Capture::kGenerator;
Sebastian Janssonf2727fb2019-02-18 16:54:55 +010080 struct Slides {
Danil Chapovalov0c626af2020-02-10 11:16:00 +010081 TimeDelta change_interval = TimeDelta::Seconds(10);
Sebastian Janssonf2727fb2019-02-18 16:54:55 +010082 struct Generator {
83 int width = 1600;
84 int height = 1200;
85 } generator;
86 struct Images {
87 struct Crop {
Danil Chapovalov0c626af2020-02-10 11:16:00 +010088 TimeDelta scroll_duration = TimeDelta::Seconds(0);
Sebastian Janssonf2727fb2019-02-18 16:54:55 +010089 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;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200102 struct Generator {
Artem Titov33f9d2b2019-12-05 15:59:00 +0100103 using PixelFormat = FrameGeneratorInterface::OutputType;
Sebastian Janssoned0febf2019-07-26 15:58:11 +0200104 PixelFormat pixel_format = PixelFormat::kI420;
Sebastian Janssonf0c366b2019-02-14 13:18:42 +0100105 int width = 320;
106 int height = 180;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200107 } generator;
108 struct VideoFile {
109 std::string name;
Sebastian Janssonf0c366b2019-02-14 13:18:42 +0100110 // Must be set to width and height of the source video file.
111 int width = 0;
112 int height = 0;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200113 } video_file;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200114 int framerate = 30;
115 } source;
116 struct Encoder {
117 Encoder();
118 Encoder(const Encoder&);
119 ~Encoder();
Sebastian Janssonf0c366b2019-02-14 13:18:42 +0100120 enum class ContentType {
121 kVideo,
122 kScreen,
123 } content_type = ContentType::kVideo;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200124 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;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200131 absl::optional<DataRate> max_data_rate;
Sebastian Jansson0c32e332018-11-12 16:47:43 +0100132 absl::optional<int> max_framerate;
Sebastian Janssonf0c366b2019-02-14 13:18:42 +0100133 // 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;
Sebastian Jansson06c51452019-02-18 16:55:15 +0100140 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
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200150 DegradationPreference degradation_preference =
151 DegradationPreference::MAINTAIN_FRAMERATE;
152 } encoder;
153 struct Stream {
154 Stream();
155 Stream(const Stream&);
156 ~Stream();
Sebastian Janssone112bb82019-06-13 17:36:01 +0200157 bool abs_send_time = false;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200158 bool packet_feedback = true;
159 bool use_rtx = true;
Sebastian Jansson985ee682018-11-12 16:33:29 +0100160 DataRate pad_to_rate = DataRate::Zero();
Danil Chapovalov0c626af2020-02-10 11:16:00 +0100161 TimeDelta nack_history_time = TimeDelta::Millis(1000);
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200162 bool use_flexfec = false;
163 bool use_ulpfec = false;
Sebastian Janssoncc5be542019-04-01 13:34:55 +0200164 FecControllerFactoryInterface* fec_controller_factory = nullptr;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200165 } stream;
Sebastian Janssoncc5be542019-04-01 13:34:55 +0200166 struct Rendering {
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200167 enum Type { kFake } type = kFake;
Sebastian Janssoncc5be542019-04-01 13:34:55 +0200168 std::string sync_group;
169 } render;
Sebastian Janssoncf2df2f2019-04-02 11:51:28 +0200170 struct Hooks {
171 std::vector<std::function<void(const VideoFramePair&)>> frame_pair_handlers;
172 } hooks;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200173};
174
175struct AudioStreamConfig {
176 AudioStreamConfig();
177 AudioStreamConfig(const AudioStreamConfig&);
178 ~AudioStreamConfig();
179 bool autostart = true;
180 struct Source {
181 int channels = 1;
182 } source;
Sebastian Janssonb9972fa2018-10-17 16:27:55 +0200183 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;
Sebastian Jansson7c1ac762020-02-27 12:04:20 +0100193 std::string binary_proto;
Sebastian Janssonb9972fa2018-10-17 16:27:55 +0200194 } adapt;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200195 struct Encoder {
196 Encoder();
197 Encoder(const Encoder&);
198 ~Encoder();
199 bool allocate_bitrate = false;
Sebastian Janssonad871942019-01-16 17:21:28 +0100200 bool enable_dtx = false;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200201 absl::optional<DataRate> fixed_rate;
202 absl::optional<DataRate> min_rate;
203 absl::optional<DataRate> max_rate;
Danil Chapovalov0c626af2020-02-10 11:16:00 +0100204 TimeDelta initial_frame_length = TimeDelta::Millis(20);
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200205 } encoder;
206 struct Stream {
207 Stream();
208 Stream(const Stream&);
209 ~Stream();
Sebastian Janssone112bb82019-06-13 17:36:01 +0200210 bool abs_send_time = false;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200211 bool in_bandwidth_estimation = false;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200212 } stream;
Sebastian Janssoncc5be542019-04-01 13:34:55 +0200213 struct Rendering {
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200214 std::string sync_group;
215 } render;
216};
217
Sebastian Janssonef86d142019-04-15 14:42:42 +0200218// TODO(srte): Merge this with BuiltInNetworkBehaviorConfig.
219struct 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;
Sebastian Jansson24c678f2019-10-14 15:07:58 +0200225 absl::optional<int> packet_queue_length_limit;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200226 DataSize packet_overhead = DataSize::Zero();
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200227};
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200228} // namespace test
229} // namespace webrtc
230
231#endif // TEST_SCENARIO_SCENARIO_CONFIG_H_