blob: b7ba74dca6aca3c70f596068c13312cfef6adc0b [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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef VIDEO_VIDEO_QUALITY_TEST_H_
11#define VIDEO_VIDEO_QUALITY_TEST_H_
ivica5d6a06c2015-09-17 05:30:24 -070012
minyue20c84cc2017-04-10 16:57:57 -070013#include <map>
kwiberg27f982b2016-03-01 11:52:33 -080014#include <memory>
ivica5d6a06c2015-09-17 05:30:24 -070015#include <string>
mflodmand1590b22015-12-09 07:07:59 -080016#include <vector>
ivica5d6a06c2015-09-17 05:30:24 -070017
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "media/engine/simulcast_encoder_adapter.h"
19#include "test/call_test.h"
20#include "test/frame_generator.h"
Christoffer Rodbrob4bb4eb2017-11-13 13:03:52 +010021#include "test/layer_filtering_transport.h"
ivica5d6a06c2015-09-17 05:30:24 -070022
23namespace webrtc {
24
25class VideoQualityTest : public test::CallTest {
26 public:
27 // Parameters are grouped into smaller structs to make it easier to set
28 // the desired elements and skip unused, using aggregate initialization.
29 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs,
30 // which makes the implementation of VideoQualityTest a bit uglier.
31 struct Params {
minyue626bc952016-10-31 05:47:02 -070032 Params();
33 ~Params();
ilnik566c43b2017-03-07 04:42:54 -080034 struct CallConfig {
minyue626bc952016-10-31 05:47:02 -070035 bool send_side_bwe;
36 Call::Config::BitrateConfig call_bitrate_config;
ilnik98436952017-07-13 00:47:03 -070037 int num_thumbnails;
minyue626bc952016-10-31 05:47:02 -070038 } call;
ilnik566c43b2017-03-07 04:42:54 -080039 struct Video {
minyue626bc952016-10-31 05:47:02 -070040 bool enabled;
ivica5d6a06c2015-09-17 05:30:24 -070041 size_t width;
42 size_t height;
43 int32_t fps;
44 int min_bitrate_bps;
45 int target_bitrate_bps;
46 int max_bitrate_bps;
mflodman48a4beb2016-07-01 13:03:59 +020047 bool suspend_below_min_bitrate;
ivica5d6a06c2015-09-17 05:30:24 -070048 std::string codec;
sprangce4aef12015-11-02 07:23:20 -080049 int num_temporal_layers;
50 int selected_tl;
ivica5d6a06c2015-09-17 05:30:24 -070051 int min_transmit_bps;
brandtr1293aca2016-11-16 22:47:29 -080052 bool ulpfec;
53 bool flexfec;
ilnik6b826ef2017-06-16 06:53:48 -070054 std::string clip_name; // "Generator" to generate frames instead.
Tarun Chawla8e857d12017-05-31 19:20:57 +053055 size_t capture_device_index;
ivica5d6a06c2015-09-17 05:30:24 -070056 } video;
ilnik566c43b2017-03-07 04:42:54 -080057 struct Audio {
minyue626bc952016-10-31 05:47:02 -070058 bool enabled;
59 bool sync_video;
minyue4c8b9422017-03-21 04:11:43 -070060 bool dtx;
minyue626bc952016-10-31 05:47:02 -070061 } audio;
ilnik566c43b2017-03-07 04:42:54 -080062 struct Screenshare {
ivica5d6a06c2015-09-17 05:30:24 -070063 bool enabled;
erikvarga579de6f2017-08-29 09:12:57 -070064 bool generate_slides;
ivica5d6a06c2015-09-17 05:30:24 -070065 int32_t slide_change_interval;
66 int32_t scroll_duration;
ilnik8d8185c2017-04-12 04:52:55 -070067 std::vector<std::string> slides;
ivica5d6a06c2015-09-17 05:30:24 -070068 } screenshare;
ilnik566c43b2017-03-07 04:42:54 -080069 struct Analyzer {
ivica5d6a06c2015-09-17 05:30:24 -070070 std::string test_label;
sprangce4aef12015-11-02 07:23:20 -080071 double avg_psnr_threshold; // (*)
72 double avg_ssim_threshold; // (*)
ivica5d6a06c2015-09-17 05:30:24 -070073 int test_durations_secs;
74 std::string graph_data_output_filename;
sprangce4aef12015-11-02 07:23:20 -080075 std::string graph_title;
ivica5d6a06c2015-09-17 05:30:24 -070076 } analyzer;
77 FakeNetworkPipe::Config pipe;
ilnik566c43b2017-03-07 04:42:54 -080078 struct SS { // Spatial scalability.
sprangce4aef12015-11-02 07:23:20 -080079 std::vector<VideoStream> streams; // If empty, one stream is assumed.
80 size_t selected_stream;
81 int num_spatial_layers;
82 int selected_sl;
83 // If empty, bitrates are generated in VP9Impl automatically.
84 std::vector<SpatialLayer> spatial_layers;
ilnik6b826ef2017-06-16 06:53:48 -070085 // If set, default parameters will be used instead of |streams|.
86 bool infer_streams;
sprangce4aef12015-11-02 07:23:20 -080087 } ss;
ilnik98436952017-07-13 00:47:03 -070088 struct Logging {
89 bool logs;
90 std::string rtc_event_log_name;
91 std::string rtp_dump_name;
92 std::string encoded_frame_base_path;
93 } logging;
ivica5d6a06c2015-09-17 05:30:24 -070094 };
95
96 VideoQualityTest();
97 void RunWithAnalyzer(const Params& params);
minyue73208662016-08-18 06:28:55 -070098 void RunWithRenderers(const Params& params);
ivica5d6a06c2015-09-17 05:30:24 -070099
sprangce4aef12015-11-02 07:23:20 -0800100 static void FillScalabilitySettings(
101 Params* params,
102 const std::vector<std::string>& stream_descriptors,
sprang1168fd42017-06-21 09:00:17 -0700103 int num_streams,
sprangce4aef12015-11-02 07:23:20 -0800104 size_t selected_stream,
105 int num_spatial_layers,
106 int selected_sl,
107 const std::vector<std::string>& sl_descriptors);
108
ivica5d6a06c2015-09-17 05:30:24 -0700109 protected:
minyue20c84cc2017-04-10 16:57:57 -0700110 std::map<uint8_t, webrtc::MediaType> payload_type_map_;
111
ivica5d6a06c2015-09-17 05:30:24 -0700112 // No-op implementation to be able to instantiate this class from non-TEST_F
113 // locations.
114 void TestBody() override;
115
sprangce4aef12015-11-02 07:23:20 -0800116 // Helper methods accessing only params_.
117 std::string GenerateGraphTitle() const;
118 void CheckParams();
119
120 // Helper static methods.
121 static VideoStream DefaultVideoStream(const Params& params);
ilnika014cc52017-03-07 04:21:04 -0800122 static VideoStream DefaultThumbnailStream();
sprangce4aef12015-11-02 07:23:20 -0800123 static std::vector<int> ParseCSV(const std::string& str);
124
125 // Helper methods for setting up the call.
perkja49cbd32016-09-16 07:53:41 -0700126 void CreateCapturer();
ilnika014cc52017-03-07 04:21:04 -0800127 void SetupThumbnailCapturers(size_t num_thumbnail_streams);
minyuea27172d2016-11-01 05:59:29 -0700128 void SetupVideo(Transport* send_transport, Transport* recv_transport);
ilnika014cc52017-03-07 04:21:04 -0800129 void SetupThumbnails(Transport* send_transport, Transport* recv_transport);
130 void DestroyThumbnailStreams();
ilnik2a8c2f52017-02-15 02:23:28 -0800131 void SetupScreenshareOrSVC();
minyuea27172d2016-11-01 05:59:29 -0700132 void SetupAudio(int send_channel_id,
133 int receive_channel_id,
minyuea27172d2016-11-01 05:59:29 -0700134 Transport* transport,
135 AudioReceiveStream** audio_receive_stream);
ivica5d6a06c2015-09-17 05:30:24 -0700136
palmkviste75f2042016-09-28 06:19:48 -0700137 void StartEncodedFrameLogs(VideoSendStream* stream);
138 void StartEncodedFrameLogs(VideoReceiveStream* stream);
139
Christoffer Rodbrob4bb4eb2017-11-13 13:03:52 +0100140 virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport();
141 virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport();
142
ivica2d4e6c52015-09-23 01:57:06 -0700143 // We need a more general capturer than the FrameGeneratorCapturer.
minyuea27172d2016-11-01 05:59:29 -0700144 std::unique_ptr<test::VideoCapturer> video_capturer_;
ilnika014cc52017-03-07 04:21:04 -0800145 std::vector<std::unique_ptr<test::VideoCapturer>> thumbnail_capturers_;
kwiberg27f982b2016-03-01 11:52:33 -0800146 std::unique_ptr<test::FrameGenerator> frame_generator_;
minyuea27172d2016-11-01 05:59:29 -0700147 std::unique_ptr<VideoEncoder> video_encoder_;
ilnikcb8c1462017-03-09 09:23:30 -0800148
ilnika014cc52017-03-07 04:21:04 -0800149 std::vector<std::unique_ptr<VideoEncoder>> thumbnail_encoders_;
150 std::vector<VideoSendStream::Config> thumbnail_send_configs_;
151 std::vector<VideoEncoderConfig> thumbnail_encoder_configs_;
152 std::vector<VideoSendStream*> thumbnail_send_streams_;
153 std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_;
154 std::vector<VideoReceiveStream*> thumbnail_receive_streams_;
155
ivica5d6a06c2015-09-17 05:30:24 -0700156 Clock* const clock_;
sprangce4aef12015-11-02 07:23:20 -0800157
palmkviste75f2042016-09-28 06:19:48 -0700158 int receive_logs_;
159 int send_logs_;
160
kthelgason2bc68642017-02-07 07:02:22 -0800161 VideoSendStream::DegradationPreference degradation_preference_ =
sprangc5d62e22017-04-02 23:53:04 -0700162 VideoSendStream::DegradationPreference::kMaintainFramerate;
sprangce4aef12015-11-02 07:23:20 -0800163 Params params_;
ivica5d6a06c2015-09-17 05:30:24 -0700164};
165
166} // namespace webrtc
167
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200168#endif // VIDEO_VIDEO_QUALITY_TEST_H_