blob: 33a1a8a4f0d2b5ccb8e90ce04f4fec7e23d71ce8 [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
ilnikcb8c1462017-03-09 09:23:30 -080017#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
ivica5d6a06c2015-09-17 05:30:24 -070018#include "webrtc/test/call_test.h"
19#include "webrtc/test/frame_generator.h"
20#include "webrtc/test/testsupport/trace_to_stderr.h"
21
22namespace webrtc {
23
24class VideoQualityTest : public test::CallTest {
25 public:
26 // Parameters are grouped into smaller structs to make it easier to set
27 // the desired elements and skip unused, using aggregate initialization.
28 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
29 // which makes the implementation of VideoQualityTest a bit uglier.
30 struct Params {
minyue626bc952016-10-31 05:47:02 -070031 Params();
32 ~Params();
ilnik566c43b2017-03-07 04:42:54 -080033 struct CallConfig {
minyue626bc952016-10-31 05:47:02 -070034 bool send_side_bwe;
35 Call::Config::BitrateConfig call_bitrate_config;
36 } call;
ilnik566c43b2017-03-07 04:42:54 -080037 struct Video {
minyue626bc952016-10-31 05:47:02 -070038 bool enabled;
ivica5d6a06c2015-09-17 05:30:24 -070039 size_t width;
40 size_t height;
41 int32_t fps;
42 int min_bitrate_bps;
43 int target_bitrate_bps;
44 int max_bitrate_bps;
mflodman48a4beb2016-07-01 13:03:59 +020045 bool suspend_below_min_bitrate;
ivica5d6a06c2015-09-17 05:30:24 -070046 std::string codec;
sprangce4aef12015-11-02 07:23:20 -080047 int num_temporal_layers;
48 int selected_tl;
ivica5d6a06c2015-09-17 05:30:24 -070049 int min_transmit_bps;
brandtr1293aca2016-11-16 22:47:29 -080050 bool ulpfec;
51 bool flexfec;
palmkviste75f2042016-09-28 06:19:48 -070052 std::string encoded_frame_base_path;
ivica5d6a06c2015-09-17 05:30:24 -070053 std::string clip_name;
54 } video;
ilnik566c43b2017-03-07 04:42:54 -080055 struct Audio {
minyue626bc952016-10-31 05:47:02 -070056 bool enabled;
57 bool sync_video;
minyue4c8b9422017-03-21 04:11:43 -070058 bool dtx;
minyue626bc952016-10-31 05:47:02 -070059 } audio;
ilnik566c43b2017-03-07 04:42:54 -080060 struct Screenshare {
ivica5d6a06c2015-09-17 05:30:24 -070061 bool enabled;
62 int32_t slide_change_interval;
63 int32_t scroll_duration;
64 } screenshare;
ilnik566c43b2017-03-07 04:42:54 -080065 struct Analyzer {
ivica5d6a06c2015-09-17 05:30:24 -070066 std::string test_label;
sprangce4aef12015-11-02 07:23:20 -080067 double avg_psnr_threshold; // (*)
68 double avg_ssim_threshold; // (*)
ivica5d6a06c2015-09-17 05:30:24 -070069 int test_durations_secs;
70 std::string graph_data_output_filename;
sprangce4aef12015-11-02 07:23:20 -080071 std::string graph_title;
ivica5d6a06c2015-09-17 05:30:24 -070072 } analyzer;
73 FakeNetworkPipe::Config pipe;
74 bool logs;
ilnik566c43b2017-03-07 04:42:54 -080075 struct SS { // Spatial scalability.
sprangce4aef12015-11-02 07:23:20 -080076 std::vector<VideoStream> streams; // If empty, one stream is assumed.
77 size_t selected_stream;
78 int num_spatial_layers;
79 int selected_sl;
80 // If empty, bitrates are generated in VP9Impl automatically.
81 std::vector<SpatialLayer> spatial_layers;
82 } ss;
ilnika014cc52017-03-07 04:21:04 -080083 int num_thumbnails;
ivica5d6a06c2015-09-17 05:30:24 -070084 };
85
86 VideoQualityTest();
87 void RunWithAnalyzer(const Params& params);
minyue73208662016-08-18 06:28:55 -070088 void RunWithRenderers(const Params& params);
ivica5d6a06c2015-09-17 05:30:24 -070089
sprangce4aef12015-11-02 07:23:20 -080090 static void FillScalabilitySettings(
91 Params* params,
92 const std::vector<std::string>& stream_descriptors,
93 size_t selected_stream,
94 int num_spatial_layers,
95 int selected_sl,
96 const std::vector<std::string>& sl_descriptors);
97
ivica5d6a06c2015-09-17 05:30:24 -070098 protected:
99 // No-op implementation to be able to instantiate this class from non-TEST_F
100 // locations.
101 void TestBody() override;
102
sprangce4aef12015-11-02 07:23:20 -0800103 // Helper methods accessing only params_.
104 std::string GenerateGraphTitle() const;
105 void CheckParams();
106
107 // Helper static methods.
108 static VideoStream DefaultVideoStream(const Params& params);
ilnika014cc52017-03-07 04:21:04 -0800109 static VideoStream DefaultThumbnailStream();
sprangce4aef12015-11-02 07:23:20 -0800110 static std::vector<int> ParseCSV(const std::string& str);
111
112 // Helper methods for setting up the call.
perkja49cbd32016-09-16 07:53:41 -0700113 void CreateCapturer();
ilnika014cc52017-03-07 04:21:04 -0800114 void SetupThumbnailCapturers(size_t num_thumbnail_streams);
minyuea27172d2016-11-01 05:59:29 -0700115 void SetupVideo(Transport* send_transport, Transport* recv_transport);
ilnika014cc52017-03-07 04:21:04 -0800116 void SetupThumbnails(Transport* send_transport, Transport* recv_transport);
117 void DestroyThumbnailStreams();
ilnik2a8c2f52017-02-15 02:23:28 -0800118 void SetupScreenshareOrSVC();
minyuea27172d2016-11-01 05:59:29 -0700119 void SetupAudio(int send_channel_id,
120 int receive_channel_id,
121 Call* call,
122 Transport* transport,
123 AudioReceiveStream** audio_receive_stream);
ivica5d6a06c2015-09-17 05:30:24 -0700124
palmkviste75f2042016-09-28 06:19:48 -0700125 void StartEncodedFrameLogs(VideoSendStream* stream);
126 void StartEncodedFrameLogs(VideoReceiveStream* stream);
127
ivica2d4e6c52015-09-23 01:57:06 -0700128 // We need a more general capturer than the FrameGeneratorCapturer.
minyuea27172d2016-11-01 05:59:29 -0700129 std::unique_ptr<test::VideoCapturer> video_capturer_;
ilnika014cc52017-03-07 04:21:04 -0800130 std::vector<std::unique_ptr<test::VideoCapturer>> thumbnail_capturers_;
kwiberg27f982b2016-03-01 11:52:33 -0800131 std::unique_ptr<test::TraceToStderr> trace_to_stderr_;
132 std::unique_ptr<test::FrameGenerator> frame_generator_;
minyuea27172d2016-11-01 05:59:29 -0700133 std::unique_ptr<VideoEncoder> video_encoder_;
ilnikcb8c1462017-03-09 09:23:30 -0800134 std::unique_ptr<VideoEncoderFactory> vp8_encoder_factory_;
135
ilnika014cc52017-03-07 04:21:04 -0800136 std::vector<std::unique_ptr<VideoEncoder>> thumbnail_encoders_;
137 std::vector<VideoSendStream::Config> thumbnail_send_configs_;
138 std::vector<VideoEncoderConfig> thumbnail_encoder_configs_;
139 std::vector<VideoSendStream*> thumbnail_send_streams_;
140 std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_;
141 std::vector<VideoReceiveStream*> thumbnail_receive_streams_;
142
ivica5d6a06c2015-09-17 05:30:24 -0700143 Clock* const clock_;
sprangce4aef12015-11-02 07:23:20 -0800144
palmkviste75f2042016-09-28 06:19:48 -0700145 int receive_logs_;
146 int send_logs_;
147
kthelgason2bc68642017-02-07 07:02:22 -0800148 VideoSendStream::DegradationPreference degradation_preference_ =
sprangc5d62e22017-04-02 23:53:04 -0700149 VideoSendStream::DegradationPreference::kMaintainFramerate;
sprangce4aef12015-11-02 07:23:20 -0800150 Params params_;
ivica5d6a06c2015-09-17 05:30:24 -0700151};
152
153} // namespace webrtc
154
155#endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_