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