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 { |
| 30 | struct { |
| 31 | size_t width; |
| 32 | size_t height; |
| 33 | int32_t fps; |
| 34 | int min_bitrate_bps; |
| 35 | int target_bitrate_bps; |
| 36 | int max_bitrate_bps; |
mflodman | 48a4beb | 2016-07-01 13:03:59 +0200 | [diff] [blame] | 37 | bool suspend_below_min_bitrate; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 38 | std::string codec; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 39 | int num_temporal_layers; |
| 40 | int selected_tl; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 41 | int min_transmit_bps; |
Erik Språng | 6b8d355 | 2015-09-24 15:06:57 +0200 | [diff] [blame] | 42 | bool send_side_bwe; |
philipel | 274c1dc | 2016-05-04 06:21:01 -0700 | [diff] [blame] | 43 | bool fec; |
stefan | b179767 | 2016-08-11 07:00:57 -0700 | [diff] [blame^] | 44 | |
| 45 | Call::Config::BitrateConfig call_bitrate_config; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 46 | } common; |
| 47 | struct { // Video-specific settings. |
| 48 | std::string clip_name; |
| 49 | } video; |
| 50 | struct { // Screenshare-specific settings. |
| 51 | bool enabled; |
| 52 | int32_t slide_change_interval; |
| 53 | int32_t scroll_duration; |
| 54 | } screenshare; |
| 55 | struct { // Analyzer settings. |
| 56 | std::string test_label; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 57 | double avg_psnr_threshold; // (*) |
| 58 | double avg_ssim_threshold; // (*) |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 59 | int test_durations_secs; |
| 60 | std::string graph_data_output_filename; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 61 | std::string graph_title; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 62 | } analyzer; |
| 63 | FakeNetworkPipe::Config pipe; |
| 64 | bool logs; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 65 | struct { // Spatial scalability. |
| 66 | std::vector<VideoStream> streams; // If empty, one stream is assumed. |
| 67 | size_t selected_stream; |
| 68 | int num_spatial_layers; |
| 69 | int selected_sl; |
| 70 | // If empty, bitrates are generated in VP9Impl automatically. |
| 71 | std::vector<SpatialLayer> spatial_layers; |
| 72 | } ss; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 73 | }; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 74 | // (*) Set to -1.1 if generating graph data for simulcast or SVC and the |
| 75 | // selected stream/layer doesn't have the same resolution as the largest |
| 76 | // stream/layer (to ignore the PSNR and SSIM calculation errors). |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 77 | |
| 78 | VideoQualityTest(); |
| 79 | void RunWithAnalyzer(const Params& params); |
| 80 | void RunWithVideoRenderer(const Params& params); |
| 81 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 82 | static void FillScalabilitySettings( |
| 83 | Params* params, |
| 84 | const std::vector<std::string>& stream_descriptors, |
| 85 | size_t selected_stream, |
| 86 | int num_spatial_layers, |
| 87 | int selected_sl, |
| 88 | const std::vector<std::string>& sl_descriptors); |
| 89 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 90 | protected: |
| 91 | // No-op implementation to be able to instantiate this class from non-TEST_F |
| 92 | // locations. |
| 93 | void TestBody() override; |
| 94 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 95 | // Helper methods accessing only params_. |
| 96 | std::string GenerateGraphTitle() const; |
| 97 | void CheckParams(); |
| 98 | |
| 99 | // Helper static methods. |
| 100 | static VideoStream DefaultVideoStream(const Params& params); |
| 101 | static std::vector<int> ParseCSV(const std::string& str); |
| 102 | |
| 103 | // Helper methods for setting up the call. |
| 104 | void CreateCapturer(VideoCaptureInput* input); |
| 105 | void SetupCommon(Transport* send_transport, Transport* recv_transport); |
| 106 | void SetupScreenshare(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 107 | |
ivica | 2d4e6c5 | 2015-09-23 01:57:06 -0700 | [diff] [blame] | 108 | // We need a more general capturer than the FrameGeneratorCapturer. |
kwiberg | 27f982b | 2016-03-01 11:52:33 -0800 | [diff] [blame] | 109 | std::unique_ptr<test::VideoCapturer> capturer_; |
| 110 | std::unique_ptr<test::TraceToStderr> trace_to_stderr_; |
| 111 | std::unique_ptr<test::FrameGenerator> frame_generator_; |
| 112 | std::unique_ptr<VideoEncoder> encoder_; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 113 | VideoCodecUnion codec_settings_; |
| 114 | Clock* const clock_; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 115 | |
| 116 | Params params_; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | } // namespace webrtc |
| 120 | |
| 121 | #endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_ |