blob: b476004aae86322f84ec79a12edd7d87df74fa29 [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;
37 std::string codec;
sprangce4aef12015-11-02 07:23:20 -080038 int num_temporal_layers;
39 int selected_tl;
ivica5d6a06c2015-09-17 05:30:24 -070040 int min_transmit_bps;
ivicac7199c22015-10-07 06:43:33 -070041
ivica5d6a06c2015-09-17 05:30:24 -070042 Call::Config::BitrateConfig call_bitrate_config;
Erik Språng6b8d3552015-09-24 15:06:57 +020043 bool send_side_bwe;
ivica5d6a06c2015-09-17 05:30:24 -070044 } common;
45 struct { // Video-specific settings.
46 std::string clip_name;
47 } video;
48 struct { // Screenshare-specific settings.
49 bool enabled;
50 int32_t slide_change_interval;
51 int32_t scroll_duration;
52 } screenshare;
53 struct { // Analyzer settings.
54 std::string test_label;
sprangce4aef12015-11-02 07:23:20 -080055 double avg_psnr_threshold; // (*)
56 double avg_ssim_threshold; // (*)
ivica5d6a06c2015-09-17 05:30:24 -070057 int test_durations_secs;
58 std::string graph_data_output_filename;
sprangce4aef12015-11-02 07:23:20 -080059 std::string graph_title;
ivica5d6a06c2015-09-17 05:30:24 -070060 } analyzer;
61 FakeNetworkPipe::Config pipe;
62 bool logs;
sprangce4aef12015-11-02 07:23:20 -080063 struct { // Spatial scalability.
64 std::vector<VideoStream> streams; // If empty, one stream is assumed.
65 size_t selected_stream;
66 int num_spatial_layers;
67 int selected_sl;
68 // If empty, bitrates are generated in VP9Impl automatically.
69 std::vector<SpatialLayer> spatial_layers;
70 } ss;
ivica5d6a06c2015-09-17 05:30:24 -070071 };
sprangce4aef12015-11-02 07:23:20 -080072 // (*) Set to -1.1 if generating graph data for simulcast or SVC and the
73 // selected stream/layer doesn't have the same resolution as the largest
74 // stream/layer (to ignore the PSNR and SSIM calculation errors).
ivica5d6a06c2015-09-17 05:30:24 -070075
76 VideoQualityTest();
77 void RunWithAnalyzer(const Params& params);
78 void RunWithVideoRenderer(const Params& params);
79
sprangce4aef12015-11-02 07:23:20 -080080 static void FillScalabilitySettings(
81 Params* params,
82 const std::vector<std::string>& stream_descriptors,
83 size_t selected_stream,
84 int num_spatial_layers,
85 int selected_sl,
86 const std::vector<std::string>& sl_descriptors);
87
ivica5d6a06c2015-09-17 05:30:24 -070088 protected:
89 // No-op implementation to be able to instantiate this class from non-TEST_F
90 // locations.
91 void TestBody() override;
92
sprangce4aef12015-11-02 07:23:20 -080093 // Helper methods accessing only params_.
94 std::string GenerateGraphTitle() const;
95 void CheckParams();
96
97 // Helper static methods.
98 static VideoStream DefaultVideoStream(const Params& params);
99 static std::vector<int> ParseCSV(const std::string& str);
100
101 // Helper methods for setting up the call.
102 void CreateCapturer(VideoCaptureInput* input);
103 void SetupCommon(Transport* send_transport, Transport* recv_transport);
104 void SetupScreenshare();
ivica5d6a06c2015-09-17 05:30:24 -0700105
ivica2d4e6c52015-09-23 01:57:06 -0700106 // We need a more general capturer than the FrameGeneratorCapturer.
kwiberg27f982b2016-03-01 11:52:33 -0800107 std::unique_ptr<test::VideoCapturer> capturer_;
108 std::unique_ptr<test::TraceToStderr> trace_to_stderr_;
109 std::unique_ptr<test::FrameGenerator> frame_generator_;
110 std::unique_ptr<VideoEncoder> encoder_;
ivica5d6a06c2015-09-17 05:30:24 -0700111 VideoCodecUnion codec_settings_;
112 Clock* const clock_;
sprangce4aef12015-11-02 07:23:20 -0800113
114 Params params_;
ivica5d6a06c2015-09-17 05:30:24 -0700115};
116
117} // namespace webrtc
118
119#endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_