blob: f49ce385b606610ff8d277300d09828324408089 [file] [log] [blame]
ivica5d6a06c2015-09-17 12:30:241/*
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 04:47:3110#ifndef VIDEO_VIDEO_QUALITY_TEST_H_
11#define VIDEO_VIDEO_QUALITY_TEST_H_
ivica5d6a06c2015-09-17 12:30:2412
minyue20c84cc2017-04-10 23:57:5713#include <map>
kwiberg27f982b2016-03-01 19:52:3314#include <memory>
ivica5d6a06c2015-09-17 12:30:2415#include <string>
mflodmand1590b22015-12-09 15:07:5916#include <vector>
ivica5d6a06c2015-09-17 12:30:2417
Patrik Höglundb6b29e02018-06-21 14:58:0118#include "api/fec_controller.h"
Danil Chapovalov4ba04b72019-06-26 13:49:4719#include "api/rtc_event_log/rtc_event_log_factory.h"
Danil Chapovalov44db4362019-09-30 02:16:2820#include "api/task_queue/task_queue_base.h"
Danil Chapovalov1c41be62019-04-01 07:16:1221#include "api/task_queue/task_queue_factory.h"
Artem Titov33f9d2b2019-12-05 14:59:0022#include "api/test/frame_generator_interface.h"
Patrik Höglundb6b29e02018-06-21 14:58:0123#include "api/test/video_quality_test_fixture.h"
Jiawei Ouc2ebe212018-11-08 18:02:5624#include "api/video/video_bitrate_allocator_factory.h"
Patrik Höglundb6b29e02018-06-21 14:58:0125#include "call/fake_network_pipe.h"
Steve Anton10542f22019-01-11 17:11:0026#include "media/engine/internal_decoder_factory.h"
27#include "media/engine/internal_encoder_factory.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3128#include "test/call_test.h"
Christoffer Rodbrob4bb4eb2017-11-13 12:03:5229#include "test/layer_filtering_transport.h"
Niels Möller88be9722018-10-10 08:58:5230#include "video/video_analyzer.h"
henrika255750b2018-08-27 14:13:3731#ifdef WEBRTC_WIN
32#include "modules/audio_device/win/core_audio_utility_win.h"
Austin Orion0bb354c2020-10-29 18:30:1033#include "rtc_base/win/scoped_com_initializer.h"
henrika255750b2018-08-27 14:13:3734#endif
ivica5d6a06c2015-09-17 12:30:2435
36namespace webrtc {
37
Jonas Olssona4d87372019-07-05 17:08:3338class VideoQualityTest : public test::CallTest,
39 public VideoQualityTestFixtureInterface {
ivica5d6a06c2015-09-17 12:30:2440 public:
Ying Wang0dd1b0a2018-02-20 11:50:2741 explicit VideoQualityTest(
Artem Titove269cb42018-08-29 07:59:2342 std::unique_ptr<InjectionComponents> injection_components);
Patrik Höglundb6b29e02018-06-21 14:58:0143
44 void RunWithAnalyzer(const Params& params) override;
45 void RunWithRenderers(const Params& params) override;
46
47 const std::map<uint8_t, webrtc::MediaType>& payload_type_map() override {
48 return payload_type_map_;
49 }
ivica5d6a06c2015-09-17 12:30:2450
sprangce4aef12015-11-02 15:23:2051 static void FillScalabilitySettings(
52 Params* params,
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:5953 size_t video_idx,
sprangce4aef12015-11-02 15:23:2054 const std::vector<std::string>& stream_descriptors,
sprang1168fd42017-06-21 16:00:1755 int num_streams,
sprangce4aef12015-11-02 15:23:2056 size_t selected_stream,
57 int num_spatial_layers,
58 int selected_sl,
Sergey Silkin57027362018-05-15 07:12:0559 InterLayerPredMode inter_layer_pred,
sprangce4aef12015-11-02 15:23:2060 const std::vector<std::string>& sl_descriptors);
61
Patrik Höglundb6b29e02018-06-21 14:58:0162 // Helper static methods.
63 static VideoStream DefaultVideoStream(const Params& params, size_t video_idx);
64 static VideoStream DefaultThumbnailStream();
65 static std::vector<int> ParseCSV(const std::string& str);
66
ivica5d6a06c2015-09-17 12:30:2467 protected:
minyue20c84cc2017-04-10 23:57:5768 std::map<uint8_t, webrtc::MediaType> payload_type_map_;
69
ivica5d6a06c2015-09-17 12:30:2470 // No-op implementation to be able to instantiate this class from non-TEST_F
71 // locations.
72 void TestBody() override;
73
sprangce4aef12015-11-02 15:23:2074 // Helper methods accessing only params_.
75 std::string GenerateGraphTitle() const;
Artem Titove269cb42018-08-29 07:59:2376 void CheckParamsAndInjectionComponents();
sprangce4aef12015-11-02 15:23:2077
sprangce4aef12015-11-02 15:23:2078 // Helper methods for setting up the call.
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:5979 void CreateCapturers();
Artem Titov33f9d2b2019-12-05 14:59:0080 std::unique_ptr<test::FrameGeneratorInterface> CreateFrameGenerator(
81 size_t video_idx);
ilnika014cc52017-03-07 12:21:0482 void SetupThumbnailCapturers(size_t num_thumbnail_streams);
Niels Möllercbcbc222018-09-28 07:07:2483 std::unique_ptr<VideoDecoder> CreateVideoDecoder(
84 const SdpVideoFormat& format);
Niels Möller88be9722018-10-10 08:58:5285 std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
86 VideoAnalyzer* analyzer);
minyuea27172d2016-11-01 12:59:2987 void SetupVideo(Transport* send_transport, Transport* recv_transport);
ilnika014cc52017-03-07 12:21:0488 void SetupThumbnails(Transport* send_transport, Transport* recv_transport);
Christoffer Rodbro39a44b22018-08-07 15:07:2489 void StartAudioStreams();
Christoffer Rodbroc2a02882018-08-07 12:10:5690 void StartThumbnails();
91 void StopThumbnails();
ilnika014cc52017-03-07 12:21:0492 void DestroyThumbnailStreams();
henrika255750b2018-08-27 14:13:3793 // Helper method for creating a real ADM (using hardware) for all platforms.
94 rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice();
Christoffer Rodbroc2a02882018-08-07 12:10:5695 void InitializeAudioDevice(Call::Config* send_call_config,
henrika255750b2018-08-27 14:13:3796 Call::Config* recv_call_config,
97 bool use_real_adm);
Sebastian Jansson3bd2c792018-07-13 11:29:0398 void SetupAudio(Transport* transport);
ivica5d6a06c2015-09-17 12:30:2499
palmkviste75f2042016-09-28 13:19:48100 void StartEncodedFrameLogs(VideoReceiveStream* stream);
101
Christoffer Rodbrob4bb4eb2017-11-13 12:03:52102 virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport();
103 virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport();
104
Niels Möller1c931c42018-12-18 15:08:11105 std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>>
106 thumbnail_capturers_;
Sebastian Janssone6d7c3e2018-07-11 13:00:41107 Clock* const clock_;
Danil Chapovalov1c41be62019-04-01 07:16:12108 const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
Danil Chapovalov304ea5f2019-04-11 13:18:18109 RtcEventLogFactory rtc_event_log_factory_;
ilnikcb8c1462017-03-09 17:23:30110
Niels Möllercbcbc222018-09-28 07:07:24111 test::FunctionVideoDecoderFactory video_decoder_factory_;
“Michael3c396e52019-06-12 14:47:14112 std::unique_ptr<VideoDecoderFactory> decoder_factory_;
Sebastian Janssone6d7c3e2018-07-11 13:00:41113 test::FunctionVideoEncoderFactory video_encoder_factory_;
Niels Möller88be9722018-10-10 08:58:52114 test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_;
Jiawei Ouc2ebe212018-11-08 18:02:56115 std::unique_ptr<VideoBitrateAllocatorFactory>
116 video_bitrate_allocator_factory_;
“Michael3c396e52019-06-12 14:47:14117 std::unique_ptr<VideoEncoderFactory> encoder_factory_;
ilnika014cc52017-03-07 12:21:04118 std::vector<VideoSendStream::Config> thumbnail_send_configs_;
119 std::vector<VideoEncoderConfig> thumbnail_encoder_configs_;
120 std::vector<VideoSendStream*> thumbnail_send_streams_;
121 std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_;
122 std::vector<VideoReceiveStream*> thumbnail_receive_streams_;
123
palmkviste75f2042016-09-28 13:19:48124 int receive_logs_;
125 int send_logs_;
126
sprangce4aef12015-11-02 15:23:20127 Params params_;
Artem Titove269cb42018-08-29 07:59:23128 std::unique_ptr<InjectionComponents> injection_components_;
Ilya Nikolaevskiya4259f62017-12-05 12:19:45129
Niels Möller88be9722018-10-10 08:58:52130 // Set non-null when running with analyzer.
131 std::unique_ptr<VideoAnalyzer> analyzer_;
132
Sebastian Jansson3bd2c792018-07-13 11:29:03133 // Note: not same as similarly named member in CallTest. This is the number of
134 // separate send streams, the one in CallTest is the number of substreams for
135 // a single send stream.
Ilya Nikolaevskiy255d1cd2017-12-21 17:02:59136 size_t num_video_streams_;
henrika255750b2018-08-27 14:13:37137
138#ifdef WEBRTC_WIN
139 // Windows Core Audio based ADM needs to run on a COM initialized thread.
140 // Only referenced in combination with --audio --use_real_adm flags.
Austin Orion0bb354c2020-10-29 18:30:10141 std::unique_ptr<ScopedCOMInitializer> com_initializer_;
henrika255750b2018-08-27 14:13:37142#endif
ivica5d6a06c2015-09-17 12:30:24143};
144
145} // namespace webrtc
146
Mirko Bonadei92ea95e2017-09-15 04:47:31147#endif // VIDEO_VIDEO_QUALITY_TEST_H_