blob: 217783079404455ca5cbc52314dc18e68d9c4d48 [file] [log] [blame]
ivica5d6a06c2015-09-17 05:30:24 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef VIDEO_VIDEO_QUALITY_TEST_H_
11#define VIDEO_VIDEO_QUALITY_TEST_H_
ivica5d6a06c2015-09-17 05:30:24 -070012
minyue20c84cc2017-04-10 16:57:57 -070013#include <map>
kwiberg27f982b2016-03-01 11:52:33 -080014#include <memory>
ivica5d6a06c2015-09-17 05:30:24 -070015#include <string>
mflodmand1590b22015-12-09 07:07:59 -080016#include <vector>
ivica5d6a06c2015-09-17 05:30:24 -070017
Patrik Höglundb6b29e02018-06-21 16:58:01 +020018#include "api/fec_controller.h"
Danil Chapovalov4ba04b72019-06-26 15:49:47 +020019#include "api/rtc_event_log/rtc_event_log_factory.h"
Danil Chapovalov44db4362019-09-30 04:16:28 +020020#include "api/task_queue/task_queue_base.h"
Danil Chapovalov1c41be62019-04-01 09:16:12 +020021#include "api/task_queue/task_queue_factory.h"
Artem Titov33f9d2b2019-12-05 15:59:00 +010022#include "api/test/frame_generator_interface.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020023#include "api/test/video_quality_test_fixture.h"
Jiawei Ouc2ebe212018-11-08 10:02:56 -080024#include "api/video/video_bitrate_allocator_factory.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020025#include "call/fake_network_pipe.h"
Steve Anton10542f22019-01-11 09:11:00 -080026#include "media/engine/internal_decoder_factory.h"
27#include "media/engine/internal_encoder_factory.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "test/call_test.h"
Christoffer Rodbrob4bb4eb2017-11-13 13:03:52 +010029#include "test/layer_filtering_transport.h"
Niels Möller88be9722018-10-10 10:58:52 +020030#include "video/video_analyzer.h"
henrika255750b2018-08-27 16:13:37 +020031#ifdef WEBRTC_WIN
32#include "modules/audio_device/win/core_audio_utility_win.h"
33#endif
ivica5d6a06c2015-09-17 05:30:24 -070034
35namespace webrtc {
36
Jonas Olssona4d87372019-07-05 19:08:33 +020037class VideoQualityTest : public test::CallTest,
38 public VideoQualityTestFixtureInterface {
ivica5d6a06c2015-09-17 05:30:24 -070039 public:
Ying Wang0dd1b0a2018-02-20 12:50:27 +010040 explicit VideoQualityTest(
Artem Titove269cb42018-08-29 09:59:23 +020041 std::unique_ptr<InjectionComponents> injection_components);
Patrik Höglundb6b29e02018-06-21 16:58:01 +020042
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 }
ivica5d6a06c2015-09-17 05:30:24 -070049
sprangce4aef12015-11-02 07:23:20 -080050 static void FillScalabilitySettings(
51 Params* params,
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +010052 size_t video_idx,
sprangce4aef12015-11-02 07:23:20 -080053 const std::vector<std::string>& stream_descriptors,
sprang1168fd42017-06-21 09:00:17 -070054 int num_streams,
sprangce4aef12015-11-02 07:23:20 -080055 size_t selected_stream,
56 int num_spatial_layers,
57 int selected_sl,
Sergey Silkin57027362018-05-15 09:12:05 +020058 InterLayerPredMode inter_layer_pred,
sprangce4aef12015-11-02 07:23:20 -080059 const std::vector<std::string>& sl_descriptors);
60
Patrik Höglundb6b29e02018-06-21 16:58:01 +020061 // 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
ivica5d6a06c2015-09-17 05:30:24 -070066 protected:
minyue20c84cc2017-04-10 16:57:57 -070067 std::map<uint8_t, webrtc::MediaType> payload_type_map_;
68
ivica5d6a06c2015-09-17 05:30:24 -070069 // No-op implementation to be able to instantiate this class from non-TEST_F
70 // locations.
71 void TestBody() override;
72
sprangce4aef12015-11-02 07:23:20 -080073 // Helper methods accessing only params_.
74 std::string GenerateGraphTitle() const;
Artem Titove269cb42018-08-29 09:59:23 +020075 void CheckParamsAndInjectionComponents();
sprangce4aef12015-11-02 07:23:20 -080076
sprangce4aef12015-11-02 07:23:20 -080077 // Helper methods for setting up the call.
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +010078 void CreateCapturers();
Artem Titov33f9d2b2019-12-05 15:59:00 +010079 std::unique_ptr<test::FrameGeneratorInterface> CreateFrameGenerator(
80 size_t video_idx);
ilnika014cc52017-03-07 04:21:04 -080081 void SetupThumbnailCapturers(size_t num_thumbnail_streams);
Niels Möllercbcbc222018-09-28 09:07:24 +020082 std::unique_ptr<VideoDecoder> CreateVideoDecoder(
83 const SdpVideoFormat& format);
Niels Möller88be9722018-10-10 10:58:52 +020084 std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
85 VideoAnalyzer* analyzer);
minyuea27172d2016-11-01 05:59:29 -070086 void SetupVideo(Transport* send_transport, Transport* recv_transport);
ilnika014cc52017-03-07 04:21:04 -080087 void SetupThumbnails(Transport* send_transport, Transport* recv_transport);
Christoffer Rodbro39a44b22018-08-07 17:07:24 +020088 void StartAudioStreams();
Christoffer Rodbroc2a02882018-08-07 14:10:56 +020089 void StartThumbnails();
90 void StopThumbnails();
ilnika014cc52017-03-07 04:21:04 -080091 void DestroyThumbnailStreams();
henrika255750b2018-08-27 16:13:37 +020092 // Helper method for creating a real ADM (using hardware) for all platforms.
93 rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice();
Christoffer Rodbroc2a02882018-08-07 14:10:56 +020094 void InitializeAudioDevice(Call::Config* send_call_config,
henrika255750b2018-08-27 16:13:37 +020095 Call::Config* recv_call_config,
96 bool use_real_adm);
Sebastian Jansson3bd2c792018-07-13 13:29:03 +020097 void SetupAudio(Transport* transport);
ivica5d6a06c2015-09-17 05:30:24 -070098
palmkviste75f2042016-09-28 06:19:48 -070099 void StartEncodedFrameLogs(VideoReceiveStream* stream);
100
Christoffer Rodbrob4bb4eb2017-11-13 13:03:52 +0100101 virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport();
102 virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport();
103
Niels Möller1c931c42018-12-18 16:08:11 +0100104 std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>>
105 thumbnail_capturers_;
Sebastian Janssone6d7c3e2018-07-11 15:00:41 +0200106 Clock* const clock_;
Danil Chapovalov1c41be62019-04-01 09:16:12 +0200107 const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
Danil Chapovalov304ea5f2019-04-11 15:18:18 +0200108 RtcEventLogFactory rtc_event_log_factory_;
ilnikcb8c1462017-03-09 09:23:30 -0800109
Niels Möllercbcbc222018-09-28 09:07:24 +0200110 test::FunctionVideoDecoderFactory video_decoder_factory_;
“Michael3c396e52019-06-12 09:47:14 -0500111 std::unique_ptr<VideoDecoderFactory> decoder_factory_;
Sebastian Janssone6d7c3e2018-07-11 15:00:41 +0200112 test::FunctionVideoEncoderFactory video_encoder_factory_;
Niels Möller88be9722018-10-10 10:58:52 +0200113 test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_;
Jiawei Ouc2ebe212018-11-08 10:02:56 -0800114 std::unique_ptr<VideoBitrateAllocatorFactory>
115 video_bitrate_allocator_factory_;
“Michael3c396e52019-06-12 09:47:14 -0500116 std::unique_ptr<VideoEncoderFactory> encoder_factory_;
ilnika014cc52017-03-07 04:21:04 -0800117 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
palmkviste75f2042016-09-28 06:19:48 -0700123 int receive_logs_;
124 int send_logs_;
125
sprangce4aef12015-11-02 07:23:20 -0800126 Params params_;
Artem Titove269cb42018-08-29 09:59:23 +0200127 std::unique_ptr<InjectionComponents> injection_components_;
Ilya Nikolaevskiya4259f62017-12-05 13:19:45 +0100128
Niels Möller88be9722018-10-10 10:58:52 +0200129 // Set non-null when running with analyzer.
130 std::unique_ptr<VideoAnalyzer> analyzer_;
131
Sebastian Jansson3bd2c792018-07-13 13:29:03 +0200132 // 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 Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100135 size_t num_video_streams_;
henrika255750b2018-08-27 16:13:37 +0200136
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
ivica5d6a06c2015-09-17 05:30:24 -0700142};
143
144} // namespace webrtc
145
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200146#endif // VIDEO_VIDEO_QUALITY_TEST_H_