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