blob: 9c7f0e7e1dc777c02760b307ef192bcde5c81bda [file] [log] [blame]
ivica5d6a06c2015-09-17 05:30:24 -07001/*
2 * Copyright (c) 2015 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#ifndef WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_
11#define WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_
12
kwiberg27f982b2016-03-01 11:52:33 -080013#include <memory>
ivica5d6a06c2015-09-17 05:30:24 -070014#include <string>
mflodmand1590b22015-12-09 07:07:59 -080015#include <vector>
ivica5d6a06c2015-09-17 05:30:24 -070016
17#include "webrtc/test/call_test.h"
18#include "webrtc/test/frame_generator.h"
19#include "webrtc/test/testsupport/trace_to_stderr.h"
20
21namespace webrtc {
22
23class VideoQualityTest : public test::CallTest {
24 public:
25 // Parameters are grouped into smaller structs to make it easier to set
26 // the desired elements and skip unused, using aggregate initialization.
27 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
28 // which makes the implementation of VideoQualityTest a bit uglier.
29 struct Params {
30 struct {
31 size_t width;
32 size_t height;
33 int32_t fps;
34 int min_bitrate_bps;
35 int target_bitrate_bps;
36 int max_bitrate_bps;
mflodman48a4beb2016-07-01 13:03:59 +020037 bool suspend_below_min_bitrate;
ivica5d6a06c2015-09-17 05:30:24 -070038 std::string codec;
sprangce4aef12015-11-02 07:23:20 -080039 int num_temporal_layers;
40 int selected_tl;
ivica5d6a06c2015-09-17 05:30:24 -070041 int min_transmit_bps;
Erik Språng6b8d3552015-09-24 15:06:57 +020042 bool send_side_bwe;
philipel274c1dc2016-05-04 06:21:01 -070043 bool fec;
stefanb1797672016-08-11 07:00:57 -070044
45 Call::Config::BitrateConfig call_bitrate_config;
ivica5d6a06c2015-09-17 05:30:24 -070046 } common;
47 struct { // Video-specific settings.
48 std::string clip_name;
49 } video;
50 struct { // Screenshare-specific settings.
51 bool enabled;
52 int32_t slide_change_interval;
53 int32_t scroll_duration;
54 } screenshare;
55 struct { // Analyzer settings.
56 std::string test_label;
sprangce4aef12015-11-02 07:23:20 -080057 double avg_psnr_threshold; // (*)
58 double avg_ssim_threshold; // (*)
ivica5d6a06c2015-09-17 05:30:24 -070059 int test_durations_secs;
60 std::string graph_data_output_filename;
sprangce4aef12015-11-02 07:23:20 -080061 std::string graph_title;
ivica5d6a06c2015-09-17 05:30:24 -070062 } analyzer;
63 FakeNetworkPipe::Config pipe;
64 bool logs;
sprangce4aef12015-11-02 07:23:20 -080065 struct { // Spatial scalability.
66 std::vector<VideoStream> streams; // If empty, one stream is assumed.
67 size_t selected_stream;
68 int num_spatial_layers;
69 int selected_sl;
70 // If empty, bitrates are generated in VP9Impl automatically.
71 std::vector<SpatialLayer> spatial_layers;
72 } ss;
ivica5d6a06c2015-09-17 05:30:24 -070073 };
sprangce4aef12015-11-02 07:23:20 -080074 // (*) Set to -1.1 if generating graph data for simulcast or SVC and the
75 // selected stream/layer doesn't have the same resolution as the largest
76 // stream/layer (to ignore the PSNR and SSIM calculation errors).
ivica5d6a06c2015-09-17 05:30:24 -070077
78 VideoQualityTest();
79 void RunWithAnalyzer(const Params& params);
80 void RunWithVideoRenderer(const Params& params);
81
sprangce4aef12015-11-02 07:23:20 -080082 static void FillScalabilitySettings(
83 Params* params,
84 const std::vector<std::string>& stream_descriptors,
85 size_t selected_stream,
86 int num_spatial_layers,
87 int selected_sl,
88 const std::vector<std::string>& sl_descriptors);
89
ivica5d6a06c2015-09-17 05:30:24 -070090 protected:
91 // No-op implementation to be able to instantiate this class from non-TEST_F
92 // locations.
93 void TestBody() override;
94
sprangce4aef12015-11-02 07:23:20 -080095 // Helper methods accessing only params_.
96 std::string GenerateGraphTitle() const;
97 void CheckParams();
98
99 // Helper static methods.
100 static VideoStream DefaultVideoStream(const Params& params);
101 static std::vector<int> ParseCSV(const std::string& str);
102
103 // Helper methods for setting up the call.
104 void CreateCapturer(VideoCaptureInput* input);
105 void SetupCommon(Transport* send_transport, Transport* recv_transport);
106 void SetupScreenshare();
ivica5d6a06c2015-09-17 05:30:24 -0700107
ivica2d4e6c52015-09-23 01:57:06 -0700108 // We need a more general capturer than the FrameGeneratorCapturer.
kwiberg27f982b2016-03-01 11:52:33 -0800109 std::unique_ptr<test::VideoCapturer> capturer_;
110 std::unique_ptr<test::TraceToStderr> trace_to_stderr_;
111 std::unique_ptr<test::FrameGenerator> frame_generator_;
112 std::unique_ptr<VideoEncoder> encoder_;
ivica5d6a06c2015-09-17 05:30:24 -0700113 VideoCodecUnion codec_settings_;
114 Clock* const clock_;
sprangce4aef12015-11-02 07:23:20 -0800115
116 Params params_;
ivica5d6a06c2015-09-17 05:30:24 -0700117};
118
119} // namespace webrtc
120
121#endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_