video_quality_test_fixture.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (c) 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 API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_
  11. #define API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_
  12. #include <map>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/fec_controller.h"
  17. #include "api/media_types.h"
  18. #include "api/network_state_predictor.h"
  19. #include "api/test/simulated_network.h"
  20. #include "api/transport/bitrate_settings.h"
  21. #include "api/transport/network_control.h"
  22. #include "api/video_codecs/sdp_video_format.h"
  23. #include "api/video_codecs/video_decoder_factory.h"
  24. #include "api/video_codecs/video_encoder_config.h"
  25. #include "api/video_codecs/video_encoder_factory.h"
  26. namespace webrtc {
  27. class VideoQualityTestFixtureInterface {
  28. public:
  29. // Parameters are grouped into smaller structs to make it easier to set
  30. // the desired elements and skip unused.
  31. struct Params {
  32. struct CallConfig {
  33. bool send_side_bwe = false;
  34. bool generic_descriptor = false;
  35. BitrateConstraints call_bitrate_config;
  36. int num_thumbnails = 0;
  37. // Indicates if secondary_(video|ss|screenshare) structures are used.
  38. bool dual_video = false;
  39. } call;
  40. struct Video {
  41. bool enabled = false;
  42. size_t width = 640;
  43. size_t height = 480;
  44. int32_t fps = 30;
  45. int min_bitrate_bps = 50;
  46. int target_bitrate_bps = 800;
  47. int max_bitrate_bps = 800;
  48. bool suspend_below_min_bitrate = false;
  49. std::string codec = "VP8";
  50. int num_temporal_layers = 1;
  51. int selected_tl = -1;
  52. int min_transmit_bps = 0;
  53. bool ulpfec = false;
  54. bool flexfec = false;
  55. bool automatic_scaling = false;
  56. std::string clip_path; // "Generator" to generate frames instead.
  57. size_t capture_device_index = 0;
  58. SdpVideoFormat::Parameters sdp_params;
  59. double encoder_overshoot_factor = 0.0;
  60. } video[2];
  61. struct Audio {
  62. bool enabled = false;
  63. bool sync_video = false;
  64. bool dtx = false;
  65. bool use_real_adm = false;
  66. absl::optional<std::string> ana_config;
  67. } audio;
  68. struct Screenshare {
  69. bool enabled = false;
  70. bool generate_slides = false;
  71. int32_t slide_change_interval = 10;
  72. int32_t scroll_duration = 0;
  73. std::vector<std::string> slides;
  74. } screenshare[2];
  75. struct Analyzer {
  76. std::string test_label;
  77. double avg_psnr_threshold = 0.0; // (*)
  78. double avg_ssim_threshold = 0.0; // (*)
  79. int test_durations_secs = 0;
  80. std::string graph_data_output_filename;
  81. std::string graph_title;
  82. } analyzer;
  83. // Config for default simulation implementation. Must be nullopt if
  84. // `sender_network` and `receiver_network` in InjectionComponents are
  85. // non-null. May be nullopt even if `sender_network` and `receiver_network`
  86. // are null; in that case, a default config will be used.
  87. absl::optional<BuiltInNetworkBehaviorConfig> config;
  88. struct SS { // Spatial scalability.
  89. std::vector<VideoStream> streams; // If empty, one stream is assumed.
  90. size_t selected_stream = 0;
  91. int num_spatial_layers = 0;
  92. int selected_sl = -1;
  93. InterLayerPredMode inter_layer_pred = InterLayerPredMode::kOn;
  94. // If empty, bitrates are generated in VP9Impl automatically.
  95. std::vector<SpatialLayer> spatial_layers;
  96. // If set, default parameters will be used instead of |streams|.
  97. bool infer_streams = false;
  98. } ss[2];
  99. struct Logging {
  100. std::string rtc_event_log_name;
  101. std::string rtp_dump_name;
  102. std::string encoded_frame_base_path;
  103. } logging;
  104. };
  105. // Contains objects, that will be injected on different layers of test
  106. // framework to override the behavior of system parts.
  107. struct InjectionComponents {
  108. InjectionComponents();
  109. ~InjectionComponents();
  110. // Simulations of sender and receiver networks. They must either both be
  111. // null (in which case `config` from Params is used), or both be non-null
  112. // (in which case `config` from Params must be nullopt).
  113. std::unique_ptr<NetworkBehaviorInterface> sender_network;
  114. std::unique_ptr<NetworkBehaviorInterface> receiver_network;
  115. std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
  116. std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
  117. std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
  118. std::unique_ptr<NetworkStatePredictorFactoryInterface>
  119. network_state_predictor_factory;
  120. std::unique_ptr<NetworkControllerFactoryInterface>
  121. network_controller_factory;
  122. };
  123. virtual ~VideoQualityTestFixtureInterface() = default;
  124. virtual void RunWithAnalyzer(const Params& params) = 0;
  125. virtual void RunWithRenderers(const Params& params) = 0;
  126. virtual const std::map<uint8_t, webrtc::MediaType>& payload_type_map() = 0;
  127. };
  128. } // namespace webrtc
  129. #endif // API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_