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 | */ |
| 10 | #ifndef WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_ |
| 11 | #define WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_ |
| 12 | |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 13 | #include <memory> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 14 | #include <string> |
mflodman | d1590b2 | 2015-12-09 07:07:59 -0800 | [diff] [blame] | 15 | #include <vector> |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 16 | |
| 17 | #include "webrtc/test/call_test.h" |
| 18 | #include "webrtc/test/frame_generator.h" |
| 19 | #include "webrtc/test/testsupport/trace_to_stderr.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | class 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 { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 30 | Params(); |
| 31 | ~Params(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 32 | struct { |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 33 | bool send_side_bwe; |
| 34 | Call::Config::BitrateConfig call_bitrate_config; |
| 35 | } call; |
| 36 | struct { |
| 37 | bool enabled; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 38 | 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; |
mflodman | 48a4beb | 2016-07-01 13:03:59 +0200 | [diff] [blame] | 44 | bool suspend_below_min_bitrate; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 45 | std::string codec; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 46 | int num_temporal_layers; |
| 47 | int selected_tl; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 48 | int min_transmit_bps; |
brandtr | 1293aca | 2016-11-16 22:47:29 -0800 | [diff] [blame] | 49 | bool ulpfec; |
| 50 | bool flexfec; |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 51 | std::string encoded_frame_base_path; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 52 | std::string clip_name; |
| 53 | } video; |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 54 | struct { |
| 55 | bool enabled; |
| 56 | bool sync_video; |
| 57 | } audio; |
| 58 | struct { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 59 | bool enabled; |
| 60 | int32_t slide_change_interval; |
| 61 | int32_t scroll_duration; |
| 62 | } screenshare; |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 63 | struct { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 64 | std::string test_label; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 65 | double avg_psnr_threshold; // (*) |
| 66 | double avg_ssim_threshold; // (*) |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 67 | int test_durations_secs; |
| 68 | std::string graph_data_output_filename; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 69 | std::string graph_title; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 70 | } analyzer; |
| 71 | FakeNetworkPipe::Config pipe; |
| 72 | bool logs; |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 73 | struct { // Spatial scalability. |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 74 | std::vector<VideoStream> streams; // If empty, one stream is assumed. |
| 75 | size_t selected_stream; |
| 76 | int num_spatial_layers; |
| 77 | int selected_sl; |
| 78 | // If empty, bitrates are generated in VP9Impl automatically. |
| 79 | std::vector<SpatialLayer> spatial_layers; |
| 80 | } ss; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 81 | }; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 82 | // (*) Set to -1.1 if generating graph data for simulcast or SVC and the |
| 83 | // selected stream/layer doesn't have the same resolution as the largest |
| 84 | // stream/layer (to ignore the PSNR and SSIM calculation errors). |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 85 | |
| 86 | VideoQualityTest(); |
| 87 | void RunWithAnalyzer(const Params& params); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 88 | void RunWithRenderers(const Params& params); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 89 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 90 | 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 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 98 | protected: |
| 99 | // No-op implementation to be able to instantiate this class from non-TEST_F |
| 100 | // locations. |
| 101 | void TestBody() override; |
| 102 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 103 | // 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); |
| 109 | static std::vector<int> ParseCSV(const std::string& str); |
| 110 | |
| 111 | // Helper methods for setting up the call. |
perkj | a49cbd3 | 2016-09-16 07:53:41 -0700 | [diff] [blame] | 112 | void CreateCapturer(); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 113 | void SetupVideo(Transport* send_transport, Transport* recv_transport); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 114 | void SetupScreenshare(); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 115 | void SetupAudio(int send_channel_id, |
| 116 | int receive_channel_id, |
| 117 | Call* call, |
| 118 | Transport* transport, |
| 119 | AudioReceiveStream** audio_receive_stream); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 120 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 121 | void StartEncodedFrameLogs(VideoSendStream* stream); |
| 122 | void StartEncodedFrameLogs(VideoReceiveStream* stream); |
| 123 | |
ivica | 2d4e6c5 | 2015-09-23 01:57:06 -0700 | [diff] [blame] | 124 | // We need a more general capturer than the FrameGeneratorCapturer. |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 125 | std::unique_ptr<test::VideoCapturer> video_capturer_; |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 126 | std::unique_ptr<test::TraceToStderr> trace_to_stderr_; |
| 127 | std::unique_ptr<test::FrameGenerator> frame_generator_; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 128 | std::unique_ptr<VideoEncoder> video_encoder_; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 129 | Clock* const clock_; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 130 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 131 | int receive_logs_; |
| 132 | int send_logs_; |
| 133 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 134 | Params params_; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | } // namespace webrtc |
| 138 | |
| 139 | #endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_ |