blob: d06421ce6af15ec2bb48837c0b3968194a5f51f1 [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 {
minyue626bc952016-10-31 05:47:02 -070030 Params();
31 ~Params();
ivica5d6a06c2015-09-17 05:30:24 -070032 struct {
minyue626bc952016-10-31 05:47:02 -070033 bool send_side_bwe;
34 Call::Config::BitrateConfig call_bitrate_config;
35 } call;
36 struct {
37 bool enabled;
ivica5d6a06c2015-09-17 05:30:24 -070038 size_t width;
39 size_t height;
40 int32_t fps;
41 int min_bitrate_bps;
42 int target_bitrate_bps;
43 int max_bitrate_bps;
mflodman48a4beb2016-07-01 13:03:59 +020044 bool suspend_below_min_bitrate;
ivica5d6a06c2015-09-17 05:30:24 -070045 std::string codec;
sprangce4aef12015-11-02 07:23:20 -080046 int num_temporal_layers;
47 int selected_tl;
ivica5d6a06c2015-09-17 05:30:24 -070048 int min_transmit_bps;
philipel274c1dc2016-05-04 06:21:01 -070049 bool fec;
palmkviste75f2042016-09-28 06:19:48 -070050 std::string encoded_frame_base_path;
ivica5d6a06c2015-09-17 05:30:24 -070051 std::string clip_name;
52 } video;
minyue626bc952016-10-31 05:47:02 -070053 struct {
54 bool enabled;
55 bool sync_video;
56 } audio;
57 struct {
ivica5d6a06c2015-09-17 05:30:24 -070058 bool enabled;
59 int32_t slide_change_interval;
60 int32_t scroll_duration;
61 } screenshare;
minyue626bc952016-10-31 05:47:02 -070062 struct {
ivica5d6a06c2015-09-17 05:30:24 -070063 std::string test_label;
sprangce4aef12015-11-02 07:23:20 -080064 double avg_psnr_threshold; // (*)
65 double avg_ssim_threshold; // (*)
ivica5d6a06c2015-09-17 05:30:24 -070066 int test_durations_secs;
67 std::string graph_data_output_filename;
sprangce4aef12015-11-02 07:23:20 -080068 std::string graph_title;
ivica5d6a06c2015-09-17 05:30:24 -070069 } analyzer;
70 FakeNetworkPipe::Config pipe;
71 bool logs;
minyue73208662016-08-18 06:28:55 -070072 struct { // Spatial scalability.
sprangce4aef12015-11-02 07:23:20 -080073 std::vector<VideoStream> streams; // If empty, one stream is assumed.
74 size_t selected_stream;
75 int num_spatial_layers;
76 int selected_sl;
77 // If empty, bitrates are generated in VP9Impl automatically.
78 std::vector<SpatialLayer> spatial_layers;
79 } ss;
ivica5d6a06c2015-09-17 05:30:24 -070080 };
sprangce4aef12015-11-02 07:23:20 -080081 // (*) Set to -1.1 if generating graph data for simulcast or SVC and the
82 // selected stream/layer doesn't have the same resolution as the largest
83 // stream/layer (to ignore the PSNR and SSIM calculation errors).
ivica5d6a06c2015-09-17 05:30:24 -070084
85 VideoQualityTest();
86 void RunWithAnalyzer(const Params& params);
minyue73208662016-08-18 06:28:55 -070087 void RunWithRenderers(const Params& params);
ivica5d6a06c2015-09-17 05:30:24 -070088
sprangce4aef12015-11-02 07:23:20 -080089 static void FillScalabilitySettings(
90 Params* params,
91 const std::vector<std::string>& stream_descriptors,
92 size_t selected_stream,
93 int num_spatial_layers,
94 int selected_sl,
95 const std::vector<std::string>& sl_descriptors);
96
ivica5d6a06c2015-09-17 05:30:24 -070097 protected:
98 // No-op implementation to be able to instantiate this class from non-TEST_F
99 // locations.
100 void TestBody() override;
101
sprangce4aef12015-11-02 07:23:20 -0800102 // Helper methods accessing only params_.
103 std::string GenerateGraphTitle() const;
104 void CheckParams();
105
106 // Helper static methods.
107 static VideoStream DefaultVideoStream(const Params& params);
108 static std::vector<int> ParseCSV(const std::string& str);
109
110 // Helper methods for setting up the call.
perkja49cbd32016-09-16 07:53:41 -0700111 void CreateCapturer();
minyuea27172d2016-11-01 05:59:29 -0700112 void SetupVideo(Transport* send_transport, Transport* recv_transport);
sprangce4aef12015-11-02 07:23:20 -0800113 void SetupScreenshare();
minyuea27172d2016-11-01 05:59:29 -0700114 void SetupAudio(int send_channel_id,
115 int receive_channel_id,
116 Call* call,
117 Transport* transport,
118 AudioReceiveStream** audio_receive_stream);
ivica5d6a06c2015-09-17 05:30:24 -0700119
palmkviste75f2042016-09-28 06:19:48 -0700120 void StartEncodedFrameLogs(VideoSendStream* stream);
121 void StartEncodedFrameLogs(VideoReceiveStream* stream);
122
ivica2d4e6c52015-09-23 01:57:06 -0700123 // We need a more general capturer than the FrameGeneratorCapturer.
minyuea27172d2016-11-01 05:59:29 -0700124 std::unique_ptr<test::VideoCapturer> video_capturer_;
kwiberg27f982b2016-03-01 11:52:33 -0800125 std::unique_ptr<test::TraceToStderr> trace_to_stderr_;
126 std::unique_ptr<test::FrameGenerator> frame_generator_;
minyuea27172d2016-11-01 05:59:29 -0700127 std::unique_ptr<VideoEncoder> video_encoder_;
ivica5d6a06c2015-09-17 05:30:24 -0700128 Clock* const clock_;
sprangce4aef12015-11-02 07:23:20 -0800129
palmkviste75f2042016-09-28 06:19:48 -0700130 int receive_logs_;
131 int send_logs_;
132
sprangce4aef12015-11-02 07:23:20 -0800133 Params params_;
ivica5d6a06c2015-09-17 05:30:24 -0700134};
135
136} // namespace webrtc
137
138#endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_