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 | |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 18 | #include "api/fec_controller.h" |
Danil Chapovalov | 4ba04b7 | 2019-06-26 15:49:47 +0200 | [diff] [blame] | 19 | #include "api/rtc_event_log/rtc_event_log_factory.h" |
Danil Chapovalov | 44db436 | 2019-09-30 04:16:28 +0200 | [diff] [blame] | 20 | #include "api/task_queue/task_queue_base.h" |
Danil Chapovalov | 1c41be6 | 2019-04-01 09:16:12 +0200 | [diff] [blame] | 21 | #include "api/task_queue/task_queue_factory.h" |
Artem Titov | 33f9d2b | 2019-12-05 15:59:00 +0100 | [diff] [blame] | 22 | #include "api/test/frame_generator_interface.h" |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 23 | #include "api/test/video_quality_test_fixture.h" |
Jiawei Ou | c2ebe21 | 2018-11-08 10:02:56 -0800 | [diff] [blame] | 24 | #include "api/video/video_bitrate_allocator_factory.h" |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 25 | #include "call/fake_network_pipe.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 26 | #include "media/engine/internal_decoder_factory.h" |
| 27 | #include "media/engine/internal_encoder_factory.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 28 | #include "test/call_test.h" |
Christoffer Rodbro | b4bb4eb | 2017-11-13 13:03:52 +0100 | [diff] [blame] | 29 | #include "test/layer_filtering_transport.h" |
Niels Möller | 88be972 | 2018-10-10 10:58:52 +0200 | [diff] [blame] | 30 | #include "video/video_analyzer.h" |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 31 | #ifdef WEBRTC_WIN |
| 32 | #include "modules/audio_device/win/core_audio_utility_win.h" |
| 33 | #endif |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 34 | |
| 35 | namespace webrtc { |
| 36 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 37 | class VideoQualityTest : public test::CallTest, |
| 38 | public VideoQualityTestFixtureInterface { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 39 | public: |
Ying Wang | 0dd1b0a | 2018-02-20 12:50:27 +0100 | [diff] [blame] | 40 | explicit VideoQualityTest( |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 41 | std::unique_ptr<InjectionComponents> injection_components); |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 42 | |
| 43 | void RunWithAnalyzer(const Params& params) override; |
| 44 | void RunWithRenderers(const Params& params) override; |
| 45 | |
| 46 | const std::map<uint8_t, webrtc::MediaType>& payload_type_map() override { |
| 47 | return payload_type_map_; |
| 48 | } |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 49 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 50 | static void FillScalabilitySettings( |
| 51 | Params* params, |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 52 | size_t video_idx, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 53 | const std::vector<std::string>& stream_descriptors, |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 54 | int num_streams, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 55 | size_t selected_stream, |
| 56 | int num_spatial_layers, |
| 57 | int selected_sl, |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 58 | InterLayerPredMode inter_layer_pred, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 59 | const std::vector<std::string>& sl_descriptors); |
| 60 | |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 61 | // Helper static methods. |
| 62 | static VideoStream DefaultVideoStream(const Params& params, size_t video_idx); |
| 63 | static VideoStream DefaultThumbnailStream(); |
| 64 | static std::vector<int> ParseCSV(const std::string& str); |
| 65 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 66 | protected: |
minyue | 20c84cc | 2017-04-10 16:57:57 -0700 | [diff] [blame] | 67 | std::map<uint8_t, webrtc::MediaType> payload_type_map_; |
| 68 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 69 | // No-op implementation to be able to instantiate this class from non-TEST_F |
| 70 | // locations. |
| 71 | void TestBody() override; |
| 72 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 73 | // Helper methods accessing only params_. |
| 74 | std::string GenerateGraphTitle() const; |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 75 | void CheckParamsAndInjectionComponents(); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 76 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 77 | // Helper methods for setting up the call. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 78 | void CreateCapturers(); |
Artem Titov | 33f9d2b | 2019-12-05 15:59:00 +0100 | [diff] [blame] | 79 | std::unique_ptr<test::FrameGeneratorInterface> CreateFrameGenerator( |
| 80 | size_t video_idx); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 81 | void SetupThumbnailCapturers(size_t num_thumbnail_streams); |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 82 | std::unique_ptr<VideoDecoder> CreateVideoDecoder( |
| 83 | const SdpVideoFormat& format); |
Niels Möller | 88be972 | 2018-10-10 10:58:52 +0200 | [diff] [blame] | 84 | std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format, |
| 85 | VideoAnalyzer* analyzer); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 86 | void SetupVideo(Transport* send_transport, Transport* recv_transport); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 87 | void SetupThumbnails(Transport* send_transport, Transport* recv_transport); |
Christoffer Rodbro | 39a44b2 | 2018-08-07 17:07:24 +0200 | [diff] [blame] | 88 | void StartAudioStreams(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 89 | void StartThumbnails(); |
| 90 | void StopThumbnails(); |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 91 | void DestroyThumbnailStreams(); |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 92 | // Helper method for creating a real ADM (using hardware) for all platforms. |
| 93 | rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice(); |
Christoffer Rodbro | c2a0288 | 2018-08-07 14:10:56 +0200 | [diff] [blame] | 94 | void InitializeAudioDevice(Call::Config* send_call_config, |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 95 | Call::Config* recv_call_config, |
| 96 | bool use_real_adm); |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 97 | void SetupAudio(Transport* transport); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 98 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 99 | void StartEncodedFrameLogs(VideoReceiveStream* stream); |
| 100 | |
Christoffer Rodbro | b4bb4eb | 2017-11-13 13:03:52 +0100 | [diff] [blame] | 101 | virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport(); |
| 102 | virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport(); |
| 103 | |
Niels Möller | 1c931c4 | 2018-12-18 16:08:11 +0100 | [diff] [blame] | 104 | std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>> |
| 105 | thumbnail_capturers_; |
Sebastian Jansson | e6d7c3e | 2018-07-11 15:00:41 +0200 | [diff] [blame] | 106 | Clock* const clock_; |
Danil Chapovalov | 1c41be6 | 2019-04-01 09:16:12 +0200 | [diff] [blame] | 107 | const std::unique_ptr<TaskQueueFactory> task_queue_factory_; |
Danil Chapovalov | 304ea5f | 2019-04-11 15:18:18 +0200 | [diff] [blame] | 108 | RtcEventLogFactory rtc_event_log_factory_; |
ilnik | cb8c146 | 2017-03-09 09:23:30 -0800 | [diff] [blame] | 109 | |
Niels Möller | cbcbc22 | 2018-09-28 09:07:24 +0200 | [diff] [blame] | 110 | test::FunctionVideoDecoderFactory video_decoder_factory_; |
“Michael | 3c396e5 | 2019-06-12 09:47:14 -0500 | [diff] [blame] | 111 | std::unique_ptr<VideoDecoderFactory> decoder_factory_; |
Sebastian Jansson | e6d7c3e | 2018-07-11 15:00:41 +0200 | [diff] [blame] | 112 | test::FunctionVideoEncoderFactory video_encoder_factory_; |
Niels Möller | 88be972 | 2018-10-10 10:58:52 +0200 | [diff] [blame] | 113 | test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_; |
Jiawei Ou | c2ebe21 | 2018-11-08 10:02:56 -0800 | [diff] [blame] | 114 | std::unique_ptr<VideoBitrateAllocatorFactory> |
| 115 | video_bitrate_allocator_factory_; |
“Michael | 3c396e5 | 2019-06-12 09:47:14 -0500 | [diff] [blame] | 116 | std::unique_ptr<VideoEncoderFactory> encoder_factory_; |
ilnik | a014cc5 | 2017-03-07 04:21:04 -0800 | [diff] [blame] | 117 | std::vector<VideoSendStream::Config> thumbnail_send_configs_; |
| 118 | std::vector<VideoEncoderConfig> thumbnail_encoder_configs_; |
| 119 | std::vector<VideoSendStream*> thumbnail_send_streams_; |
| 120 | std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_; |
| 121 | std::vector<VideoReceiveStream*> thumbnail_receive_streams_; |
| 122 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 123 | int receive_logs_; |
| 124 | int send_logs_; |
| 125 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 126 | Params params_; |
Artem Titov | e269cb4 | 2018-08-29 09:59:23 +0200 | [diff] [blame] | 127 | std::unique_ptr<InjectionComponents> injection_components_; |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 128 | |
Niels Möller | 88be972 | 2018-10-10 10:58:52 +0200 | [diff] [blame] | 129 | // Set non-null when running with analyzer. |
| 130 | std::unique_ptr<VideoAnalyzer> analyzer_; |
| 131 | |
Sebastian Jansson | 3bd2c79 | 2018-07-13 13:29:03 +0200 | [diff] [blame] | 132 | // Note: not same as similarly named member in CallTest. This is the number of |
| 133 | // separate send streams, the one in CallTest is the number of substreams for |
| 134 | // a single send stream. |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 135 | size_t num_video_streams_; |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 136 | |
| 137 | #ifdef WEBRTC_WIN |
| 138 | // Windows Core Audio based ADM needs to run on a COM initialized thread. |
| 139 | // Only referenced in combination with --audio --use_real_adm flags. |
| 140 | std::unique_ptr<webrtc_win::ScopedCOMInitializer> com_initializer_; |
| 141 | #endif |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | } // namespace webrtc |
| 145 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 146 | #endif // VIDEO_VIDEO_QUALITY_TEST_H_ |