blob: e563c513d418d1b3e8bccb31b618946c10745f3d [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"
24#include "api/video_codecs/video_encoder_config.h"
25
26namespace webrtc {
27
28class VideoQualityTestFixtureInterface {
29 public:
30 // Parameters are grouped into smaller structs to make it easier to set
31 // the desired elements and skip unused, using aggregate initialization.
32 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
33 // which makes the implementation of VideoQualityTest a bit uglier.
34 struct Params {
35 Params();
36 ~Params();
37 struct CallConfig {
38 bool send_side_bwe;
philipel569397f2018-09-26 12:25:31 +020039 bool generic_descriptor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020040 BitrateConstraints call_bitrate_config;
41 int num_thumbnails;
42 // Indicates if secondary_(video|ss|screenshare) structures are used.
43 bool dual_video;
44 } call;
45 struct Video {
46 bool enabled;
47 size_t width;
48 size_t height;
49 int32_t fps;
50 int min_bitrate_bps;
51 int target_bitrate_bps;
52 int max_bitrate_bps;
53 bool suspend_below_min_bitrate;
54 std::string codec;
55 int num_temporal_layers;
56 int selected_tl;
57 int min_transmit_bps;
58 bool ulpfec;
59 bool flexfec;
60 bool automatic_scaling;
Rasmus Brandt3c589be2019-03-13 11:32:40 +010061 std::string clip_path; // "Generator" to generate frames instead.
Patrik Höglundb6b29e02018-06-21 16:58:01 +020062 size_t capture_device_index;
Emircan Uysaler0823eec2018-07-13 17:10:00 -070063 SdpVideoFormat::Parameters sdp_params;
Erik Språng616b2332019-02-11 14:16:28 +010064 double encoder_overshoot_factor;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020065 } video[2];
66 struct Audio {
67 bool enabled;
68 bool sync_video;
69 bool dtx;
henrika255750b2018-08-27 16:13:37 +020070 bool use_real_adm;
Minyue Li455d27c2019-01-07 13:14:30 +010071 absl::optional<std::string> ana_config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020072 } audio;
73 struct Screenshare {
74 bool enabled;
75 bool generate_slides;
76 int32_t slide_change_interval;
77 int32_t scroll_duration;
78 std::vector<std::string> slides;
79 } screenshare[2];
80 struct Analyzer {
81 std::string test_label;
82 double avg_psnr_threshold; // (*)
83 double avg_ssim_threshold; // (*)
84 int test_durations_secs;
85 std::string graph_data_output_filename;
86 std::string graph_title;
87 } analyzer;
Artem Titove269cb42018-08-29 09:59:23 +020088 // 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 Titov75e36472018-10-08 12:28:56 +020092 absl::optional<BuiltInNetworkBehaviorConfig> config;
Patrik Höglundb6b29e02018-06-21 16:58:01 +020093 struct SS { // Spatial scalability.
94 std::vector<VideoStream> streams; // If empty, one stream is assumed.
95 size_t selected_stream;
96 int num_spatial_layers;
97 int selected_sl;
98 InterLayerPredMode inter_layer_pred;
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|.
102 bool infer_streams;
103 } ss[2];
104 struct Logging {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200105 std::string rtc_event_log_name;
106 std::string rtp_dump_name;
107 std::string encoded_frame_base_path;
108 } logging;
109 };
110
Artem Titove269cb42018-08-29 09:59:23 +0200111 // 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 Titov8ea1e9d2018-10-04 14:46:31 +0200120 std::unique_ptr<NetworkBehaviorInterface> sender_network;
121 std::unique_ptr<NetworkBehaviorInterface> receiver_network;
Artem Titove269cb42018-08-29 09:59:23 +0200122
123 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
Ying Wangcab77fd2019-04-16 11:12:49 +0200124 std::unique_ptr<NetworkStatePredictorFactoryInterface>
125 network_state_predictor_factory;
Artem Titove269cb42018-08-29 09:59:23 +0200126 };
127
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200128 virtual ~VideoQualityTestFixtureInterface() = default;
129
130 virtual void RunWithAnalyzer(const Params& params) = 0;
131 virtual void RunWithRenderers(const Params& params) = 0;
132
133 virtual const std::map<uint8_t, webrtc::MediaType>& payload_type_map() = 0;
134};
135
136} // namespace webrtc
137
138#endif // API_TEST_VIDEO_QUALITY_TEST_FIXTURE_H_