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 13 #include <string> 14 #include <vector> 15 16 #include "webrtc/test/call_test.h" 17 #include "webrtc/test/frame_generator.h" 18 #include "webrtc/test/testsupport/trace_to_stderr.h" 19 20 namespace webrtc { 21 22 class VideoQualityTest : public test::CallTest { 23 public: 24 // Parameters are grouped into smaller structs to make it easier to set 25 // the desired elements and skip unused, using aggregate initialization. 26 // Unfortunately, C++11 (as opposed to C11) doesn't support unnamed structs, 27 // which makes the implementation of VideoQualityTest a bit uglier. 28 struct Params { 29 struct { 30 size_t width; 31 size_t height; 32 int32_t fps; 33 int min_bitrate_bps; 34 int target_bitrate_bps; 35 int max_bitrate_bps; 36 std::string codec; 37 int num_temporal_layers; 38 int selected_tl; 39 int min_transmit_bps; 40 41 Call::Config::BitrateConfig call_bitrate_config; 42 bool send_side_bwe; 43 } common; 44 struct { // Video-specific settings. 45 std::string clip_name; 46 } video; 47 struct { // Screenshare-specific settings. 48 bool enabled; 49 int32_t slide_change_interval; 50 int32_t scroll_duration; 51 } screenshare; 52 struct { // Analyzer settings. 53 std::string test_label; 54 double avg_psnr_threshold; // (*) 55 double avg_ssim_threshold; // (*) 56 int test_durations_secs; 57 std::string graph_data_output_filename; 58 std::string graph_title; 59 } analyzer; 60 FakeNetworkPipe::Config pipe; 61 bool logs; 62 struct { // Spatial scalability. 63 std::vector<VideoStream> streams; // If empty, one stream is assumed. 64 size_t selected_stream; 65 int num_spatial_layers; 66 int selected_sl; 67 // If empty, bitrates are generated in VP9Impl automatically. 68 std::vector<SpatialLayer> spatial_layers; 69 } ss; 70 }; 71 // (*) Set to -1.1 if generating graph data for simulcast or SVC and the 72 // selected stream/layer doesn't have the same resolution as the largest 73 // stream/layer (to ignore the PSNR and SSIM calculation errors). 74 75 VideoQualityTest(); 76 void RunWithAnalyzer(const Params& params); 77 void RunWithVideoRenderer(const Params& params); 78 79 static void FillScalabilitySettings( 80 Params* params, 81 const std::vector<std::string>& stream_descriptors, 82 size_t selected_stream, 83 int num_spatial_layers, 84 int selected_sl, 85 const std::vector<std::string>& sl_descriptors); 86 87 protected: 88 // No-op implementation to be able to instantiate this class from non-TEST_F 89 // locations. 90 void TestBody() override; 91 92 // Helper methods accessing only params_. 93 std::string GenerateGraphTitle() const; 94 void CheckParams(); 95 96 // Helper static methods. 97 static VideoStream DefaultVideoStream(const Params& params); 98 static std::vector<int> ParseCSV(const std::string& str); 99 100 // Helper methods for setting up the call. 101 void CreateCapturer(VideoCaptureInput* input); 102 void SetupCommon(Transport* send_transport, Transport* recv_transport); 103 void SetupScreenshare(); 104 105 // We need a more general capturer than the FrameGeneratorCapturer. 106 rtc::scoped_ptr<test::VideoCapturer> capturer_; 107 rtc::scoped_ptr<test::TraceToStderr> trace_to_stderr_; 108 rtc::scoped_ptr<test::FrameGenerator> frame_generator_; 109 rtc::scoped_ptr<VideoEncoder> encoder_; 110 VideoCodecUnion codec_settings_; 111 Clock* const clock_; 112 113 Params params_; 114 }; 115 116 } // namespace webrtc 117 118 #endif // WEBRTC_VIDEO_VIDEO_QUALITY_TEST_H_ 119