blob: e425ace73bccd997bf32ce1c3db3358660ee8889 [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
19#include "api/bitrate_constraints.h"
Patrik Höglundd8f3c172018-09-26 14:39:17 +020020#include "api/fec_controller.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/media_types.h"
Ying Wangcab77fd2019-04-16 11:12:49 +020022#include "api/network_state_predictor.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020023#include "api/test/simulated_network.h"
Sebastian Jansson1391ed22019-04-30 14:23:51 +020024#include "api/transport/network_control.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020025#include "api/video_codecs/video_encoder_config.h"
26
27namespace webrtc {
28
29class VideoQualityTestFixtureInterface {
30 public:
31 // Parameters are grouped into smaller structs to make it easier to set
32 // the desired elements and skip unused, using aggregate initialization.
33 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
34 // which makes the implementation of VideoQualityTest a bit uglier.
35 struct Params {
36 Params();
37 ~Params();
38 struct CallConfig {
39 bool send_side_bwe;
philipel569397f2018-09-26 12:25:31 +020040 bool generic_descriptor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020041 BitrateConstraints call_bitrate_config;
42 int num_thumbnails;
43 // Indicates if secondary_(video|ss|screenshare) structures are used.
44 bool dual_video;
45 } call;
46 struct Video {
47 bool enabled;
48 size_t width;
49 size_t height;
50 int32_t fps;
51 int min_bitrate_bps;
52 int target_bitrate_bps;
53 int max_bitrate_bps;
54 bool suspend_below_min_bitrate;
55 std::string codec;
56 int num_temporal_layers;
57 int selected_tl;
58 int min_transmit_bps;
59 bool ulpfec;
60 bool flexfec;
61 bool automatic_scaling;
Rasmus Brandt3c589be2019-03-13 11:32:40 +010062 std::string clip_path; // "Generator" to generate frames instead.
Patrik Höglundb6b29e02018-06-21 16:58:01 +020063 size_t capture_device_index;
Emircan Uysaler0823eec2018-07-13 17:10:00 -070064 SdpVideoFormat::Parameters sdp_params;
Erik Språng616b2332019-02-11 14:16:28 +010065 double encoder_overshoot_factor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020066 } video[2];
67 struct Audio {
68 bool enabled;
69 bool sync_video;
70 bool dtx;
henrika255750b2018-08-27 16:13:37 +020071 bool use_real_adm;
Minyue Li455d27c2019-01-07 13:14:30 +010072 absl::optional<std::string> ana_config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020073 } audio;
74 struct Screenshare {
75 bool enabled;
76 bool generate_slides;
77 int32_t slide_change_interval;
78 int32_t scroll_duration;
79 std::vector<std::string> slides;
80 } screenshare[2];
81 struct Analyzer {
82 std::string test_label;
83 double avg_psnr_threshold; // (*)
84 double avg_ssim_threshold; // (*)
85 int test_durations_secs;
86 std::string graph_data_output_filename;
87 std::string graph_title;
88 } analyzer;
Artem Titove269cb42018-08-29 09:59:23 +020089 // Config for default simulation implementation. Must be nullopt if
90 // `sender_network` and `receiver_network` in InjectionComponents are
91 // non-null. May be nullopt even if `sender_network` and `receiver_network`
92 // are null; in that case, a default config will be used.
Artem Titov75e36472018-10-08 12:28:56 +020093 absl::optional<BuiltInNetworkBehaviorConfig> config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020094 struct SS { // Spatial scalability.
95 std::vector<VideoStream> streams; // If empty, one stream is assumed.
96 size_t selected_stream;
97 int num_spatial_layers;
98 int selected_sl;
99 InterLayerPredMode inter_layer_pred;
100 // If empty, bitrates are generated in VP9Impl automatically.
101 std::vector<SpatialLayer> spatial_layers;
102 // If set, default parameters will be used instead of |streams|.
103 bool infer_streams;
104 } ss[2];
105 struct Logging {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200106 std::string rtc_event_log_name;
107 std::string rtp_dump_name;
108 std::string encoded_frame_base_path;
109 } logging;
110 };
111
Artem Titove269cb42018-08-29 09:59:23 +0200112 // Contains objects, that will be injected on different layers of test
113 // framework to override the behavior of system parts.
114 struct InjectionComponents {
115 InjectionComponents();
116 ~InjectionComponents();
117
118 // Simulations of sender and receiver networks. They must either both be
119 // null (in which case `config` from Params is used), or both be non-null
120 // (in which case `config` from Params must be nullopt).
Artem Titov8ea1e9d2018-10-04 14:46:31 +0200121 std::unique_ptr<NetworkBehaviorInterface> sender_network;
122 std::unique_ptr<NetworkBehaviorInterface> receiver_network;
Artem Titove269cb42018-08-29 09:59:23 +0200123
124 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
Ying Wangcab77fd2019-04-16 11:12:49 +0200125 std::unique_ptr<NetworkStatePredictorFactoryInterface>
126 network_state_predictor_factory;
Sebastian Jansson1391ed22019-04-30 14:23:51 +0200127 std::unique_ptr<NetworkControllerFactoryInterface>
128 network_controller_factory;
Artem Titove269cb42018-08-29 09:59:23 +0200129 };
130
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200131 virtual ~VideoQualityTestFixtureInterface() = default;
132
133 virtual void RunWithAnalyzer(const Params& params) = 0;
134 virtual void RunWithRenderers(const Params& params) = 0;
135
136 virtual const std::map<uint8_t, webrtc::MediaType>& payload_type_map() = 0;
137};
138
139} // namespace webrtc
140
141#endif // API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_