scenario_config.h 6.9 KB

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