ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef VIDEO_VIDEO_QUALITY_TEST_H_ |
| 11 | #define VIDEO_VIDEO_QUALITY_TEST_H_ |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 12 | |
minyue | 20c84cc | 2017-04-10 16:57:57 -0700 | [diff] [blame] | 13 | #include <map> |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 14 | #include <memory> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 15 | #include <string> |
mflodman | d1590b2 | 2015-12-09 07:07:59 -0800 | [diff] [blame] | 16 | #include <vector> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "media/engine/simulcast_encoder_adapter.h" |
| 19 | #include "test/call_test.h" |
| 20 | #include "test/frame_generator.h" |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class 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 { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 31 | Params(); |
| 32 | ~Params(); |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 33 | struct CallConfig { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 34 | bool send_side_bwe; |
| 35 | Call::Config::BitrateConfig call_bitrate_config; |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 36 | int num_thumbnails; |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 37 | } call; |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 38 | struct Video { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 39 | bool enabled; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 40 | size_t width; |
| 41 | size_t height; |
| 42 | int32_t fps; |
| 43 | int min_bitrate_bps; |
| 44 | int target_bitrate_bps; |
| 45 | int max_bitrate_bps; |
mflodman | 48a4beb | 2016-07-01 13:03:59 +0200 | [diff] [blame] | 46 | bool suspend_below_min_bitrate; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 47 | std::string codec; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 48 | int num_temporal_layers; |
| 49 | int selected_tl; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 50 | int min_transmit_bps; |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 51 | bool ulpfec; |
| 52 | bool flexfec; |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 53 | std::string clip_name; // "Generator" to generate frames instead. |
Tarun Chawla | 8e857d1 | 2017-05-31 19:20:57 +0530 | [diff] [blame] | 54 | size_t capture_device_index; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 55 | } video; |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 56 | struct Audio { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 57 | bool enabled; |
| 58 | bool sync_video; |
minyue | 4c8b942 | 2017-03-21 04:11:43 -0700 | [diff] [blame] | 59 | bool dtx; |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 60 | } audio; |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 61 | struct Screenshare { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 62 | bool enabled; |
erikvarga | 579de6f | 2017-08-29 09:12:57 -0700 | [diff] [blame] | 63 | bool generate_slides; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 64 | int32_t slide_change_interval; |
| 65 | int32_t scroll_duration; |
ilnik | 8d8185c | 2017-04-12 04:52:55 -0700 | [diff] [blame] | 66 | std::vector<std::string> slides; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 67 | } screenshare; |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 68 | struct Analyzer { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 69 | std::string test_label; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 70 | double avg_psnr_threshold; // (*) |
| 71 | double avg_ssim_threshold; // (*) |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 72 | int test_durations_secs; |
| 73 | std::string graph_data_output_filename; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 74 | std::string graph_title; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 75 | } analyzer; |
| 76 | FakeNetworkPipe::Config pipe; |
ilnik | 566c43b | 2017-03-07 04:42:54 -0800 | [diff] [blame] | 77 | struct SS { // Spatial scalability. |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 78 | std::vector<VideoStream> streams; // If empty, one stream is assumed. |
| 79 | size_t selected_stream; |
| 80 | int num_spatial_layers; |
| 81 | int selected_sl; |
| 82 | // If empty, bitrates are generated in VP9Impl automatically. |
| 83 | std::vector<SpatialLayer> spatial_layers; |
ilnik | 6b826ef | 2017-06-16 06:53:48 -0700 | [diff] [blame] | 84 | // If set, default parameters will be used instead of |streams|. |
| 85 | bool infer_streams; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 86 | } ss; |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 87 | struct Logging { |
| 88 | bool logs; |
| 89 | std::string rtc_event_log_name; |
| 90 | std::string rtp_dump_name; |
| 91 | std::string encoded_frame_base_path; |
| 92 | } logging; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | VideoQualityTest(); |
| 96 | void RunWithAnalyzer(const Params& params); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 97 | void RunWithRenderers(const Params& params); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 98 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 99 | static void FillScalabilitySettings( |
| 100 | Params* params, |
| 101 | const std::vector<std::string>& stream_descriptors, |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 102 | int num_streams, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 103 | size_t selected_stream, |
| 104 | int num_spatial_layers, |
| 105 | int selected_sl, |
| 106 | const std::vector<std::string>& sl_descriptors); |
| 107 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 108 | protected: |
minyue | 20c84cc | 2017-04-10 16:57:57 -0700 | [diff] [blame] | 109 | std::map<uint8_t, webrtc::MediaType> payload_type_map_; |
| 110 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 111 | // No-op implementation to be able to instantiate this class from non-TEST_F |
| 112 | // locations. |
| 113 | void TestBody() override; |
| 114 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 115 | // Helper methods accessing only params_. |
| 116 | std::string GenerateGraphTitle() const; |
| 117 | void CheckParams(); |
| 118 | |
| 119 | // Helper static methods. |
| 120 | static VideoStream DefaultVideoStream(const Params& params); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 121 | static VideoStream DefaultThumbnailStream(); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 122 | static std::vector<int> ParseCSV(const std::string& str); |
| 123 | |
| 124 | // Helper methods for setting up the call. |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 125 | void CreateCapturer(); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 126 | void SetupThumbnailCapturers(size_t num_thumbnail_streams); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 127 | void SetupVideo(Transport* send_transport, Transport* recv_transport); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 128 | void SetupThumbnails(Transport* send_transport, Transport* recv_transport); |
| 129 | void DestroyThumbnailStreams(); |
ilnik | 2a8c2f5 | 2017-02-15 02:23:28 -0800 | [diff] [blame] | 130 | void SetupScreenshareOrSVC(); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 131 | void SetupAudio(int send_channel_id, |
| 132 | int receive_channel_id, |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 133 | Transport* transport, |
| 134 | AudioReceiveStream** audio_receive_stream); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 135 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 136 | void StartEncodedFrameLogs(VideoSendStream* stream); |
| 137 | void StartEncodedFrameLogs(VideoReceiveStream* stream); |
| 138 | |
ivica | 2d4e6c5 | 2015-09-23 01:57:06 -0700 | [diff] [blame] | 139 | // We need a more general capturer than the FrameGeneratorCapturer. |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 140 | std::unique_ptr<test::VideoCapturer> video_capturer_; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 141 | std::vector<std::unique_ptr<test::VideoCapturer>> thumbnail_capturers_; |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 142 | std::unique_ptr<test::FrameGenerator> frame_generator_; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 143 | std::unique_ptr<VideoEncoder> video_encoder_; |
Rasmus Brandt | 3102734 | 2017-09-29 13:48:12 +0000 | [diff] [blame] | 144 | std::unique_ptr<cricket::WebRtcVideoEncoderFactory> vp8_encoder_factory_; |
ilnik | cb8c146 | 2017-03-09 09:23:30 -0800 | [diff] [blame] | 145 | |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 146 | std::vector<std::unique_ptr<VideoEncoder>> thumbnail_encoders_; |
| 147 | std::vector<VideoSendStream::Config> thumbnail_send_configs_; |
| 148 | std::vector<VideoEncoderConfig> thumbnail_encoder_configs_; |
| 149 | std::vector<VideoSendStream*> thumbnail_send_streams_; |
| 150 | std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_; |
| 151 | std::vector<VideoReceiveStream*> thumbnail_receive_streams_; |
| 152 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 153 | Clock* const clock_; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 154 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 155 | int receive_logs_; |
| 156 | int send_logs_; |
| 157 | |
kthelgason | 2bc6864 | 2017-02-07 07:02:22 -0800 | [diff] [blame] | 158 | VideoSendStream::DegradationPreference degradation_preference_ = |
sprang | c5d62e2 | 2017-04-02 23:53:04 -0700 | [diff] [blame] | 159 | VideoSendStream::DegradationPreference::kMaintainFramerate; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 160 | Params params_; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | } // namespace webrtc |
| 164 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 165 | #endif // VIDEO_VIDEO_QUALITY_TEST_H_ |