blob: ec07c23cd41aab5584e5f3b040ab8b1ac9640e5f [file] [log] [blame]
Patrik Höglundb6b29e02018-06-21 16:58:01 +02001/*
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öglundd8f3c172018-09-26 14:39:17 +020019#include "api/fec_controller.h"
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/media_types.h"
Ying Wangcab77fd2019-04-16 11:12:49 +020021#include "api/network_state_predictor.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020022#include "api/test/simulated_network.h"
Mirko Bonadei738bfa72019-09-17 14:47:38 +020023#include "api/transport/bitrate_settings.h"
Sebastian Jansson1391ed22019-04-30 14:23:51 +020024#include "api/transport/network_control.h"
“Michael3c396e52019-06-12 09:47:14 -050025#include "api/video_codecs/video_decoder_factory.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020026#include "api/video_codecs/video_encoder_config.h"
“Michael3c396e52019-06-12 09:47:14 -050027#include "api/video_codecs/video_encoder_factory.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020028
29namespace webrtc {
30
31class VideoQualityTestFixtureInterface {
32 public:
33 // Parameters are grouped into smaller structs to make it easier to set
34 // the desired elements and skip unused, using aggregate initialization.
35 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
36 // which makes the implementation of VideoQualityTest a bit uglier.
37 struct Params {
38 Params();
39 ~Params();
40 struct CallConfig {
41 bool send_side_bwe;
philipel569397f2018-09-26 12:25:31 +020042 bool generic_descriptor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020043 BitrateConstraints call_bitrate_config;
44 int num_thumbnails;
45 // Indicates if secondary_(video|ss|screenshare) structures are used.
46 bool dual_video;
47 } call;
48 struct Video {
49 bool enabled;
50 size_t width;
51 size_t height;
52 int32_t fps;
53 int min_bitrate_bps;
54 int target_bitrate_bps;
55 int max_bitrate_bps;
56 bool suspend_below_min_bitrate;
57 std::string codec;
58 int num_temporal_layers;
59 int selected_tl;
60 int min_transmit_bps;
61 bool ulpfec;
62 bool flexfec;
63 bool automatic_scaling;
Rasmus Brandt3c589be2019-03-13 11:32:40 +010064 std::string clip_path; // "Generator" to generate frames instead.
Patrik Höglundb6b29e02018-06-21 16:58:01 +020065 size_t capture_device_index;
Emircan Uysaler0823eec2018-07-13 17:10:00 -070066 SdpVideoFormat::Parameters sdp_params;
Erik Språng616b2332019-02-11 14:16:28 +010067 double encoder_overshoot_factor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020068 } video[2];
69 struct Audio {
70 bool enabled;
71 bool sync_video;
72 bool dtx;
henrika255750b2018-08-27 16:13:37 +020073 bool use_real_adm;
Minyue Li455d27c2019-01-07 13:14:30 +010074 absl::optional<std::string> ana_config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020075 } audio;
76 struct Screenshare {
77 bool enabled;
78 bool generate_slides;
79 int32_t slide_change_interval;
80 int32_t scroll_duration;
81 std::vector<std::string> slides;
82 } screenshare[2];
83 struct Analyzer {
84 std::string test_label;
85 double avg_psnr_threshold; // (*)
86 double avg_ssim_threshold; // (*)
87 int test_durations_secs;
88 std::string graph_data_output_filename;
89 std::string graph_title;
90 } analyzer;
Artem Titove269cb42018-08-29 09:59:23 +020091 // Config for default simulation implementation. Must be nullopt if
92 // `sender_network` and `receiver_network` in InjectionComponents are
93 // non-null. May be nullopt even if `sender_network` and `receiver_network`
94 // are null; in that case, a default config will be used.
Artem Titov75e36472018-10-08 12:28:56 +020095 absl::optional<BuiltInNetworkBehaviorConfig> config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020096 struct SS { // Spatial scalability.
97 std::vector<VideoStream> streams; // If empty, one stream is assumed.
98 size_t selected_stream;
99 int num_spatial_layers;
100 int selected_sl;
101 InterLayerPredMode inter_layer_pred;
102 // If empty, bitrates are generated in VP9Impl automatically.
103 std::vector<SpatialLayer> spatial_layers;
104 // If set, default parameters will be used instead of |streams|.
105 bool infer_streams;
106 } ss[2];
107 struct Logging {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200108 std::string rtc_event_log_name;
109 std::string rtp_dump_name;
110 std::string encoded_frame_base_path;
111 } logging;
112 };
113
Artem Titove269cb42018-08-29 09:59:23 +0200114 // Contains objects, that will be injected on different layers of test
115 // framework to override the behavior of system parts.
116 struct InjectionComponents {
117 InjectionComponents();
118 ~InjectionComponents();
119
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).
Artem Titov8ea1e9d2018-10-04 14:46:31 +0200123 std::unique_ptr<NetworkBehaviorInterface> sender_network;
124 std::unique_ptr<NetworkBehaviorInterface> receiver_network;
Artem Titove269cb42018-08-29 09:59:23 +0200125
126 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
“Michael3c396e52019-06-12 09:47:14 -0500127 std::unique_ptr<VideoEncoderFactory> video_encoder_factory;
128 std::unique_ptr<VideoDecoderFactory> video_decoder_factory;
Ying Wangcab77fd2019-04-16 11:12:49 +0200129 std::unique_ptr<NetworkStatePredictorFactoryInterface>
130 network_state_predictor_factory;
Sebastian Jansson1391ed22019-04-30 14:23:51 +0200131 std::unique_ptr<NetworkControllerFactoryInterface>
132 network_controller_factory;
Artem Titove269cb42018-08-29 09:59:23 +0200133 };
134
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200135 virtual ~VideoQualityTestFixtureInterface() = default;
136
137 virtual void RunWithAnalyzer(const Params& params) = 0;
138 virtual void RunWithRenderers(const Params& params) = 0;
139
140 virtual const std::map<uint8_t, webrtc::MediaType>& payload_type_map() = 0;
141};
142
143} // namespace webrtc
144
145#endif // API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_