1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker #ifndef VIDEO_VIDEO_QUALITY_TEST_H_ 11*d9f75844SAndroid Build Coastguard Worker #define VIDEO_VIDEO_QUALITY_TEST_H_ 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker #include <map> 14*d9f75844SAndroid Build Coastguard Worker #include <memory> 15*d9f75844SAndroid Build Coastguard Worker #include <string> 16*d9f75844SAndroid Build Coastguard Worker #include <vector> 17*d9f75844SAndroid Build Coastguard Worker 18*d9f75844SAndroid Build Coastguard Worker #include "api/fec_controller.h" 19*d9f75844SAndroid Build Coastguard Worker #include "api/rtc_event_log/rtc_event_log_factory.h" 20*d9f75844SAndroid Build Coastguard Worker #include "api/task_queue/task_queue_base.h" 21*d9f75844SAndroid Build Coastguard Worker #include "api/task_queue/task_queue_factory.h" 22*d9f75844SAndroid Build Coastguard Worker #include "api/test/frame_generator_interface.h" 23*d9f75844SAndroid Build Coastguard Worker #include "api/test/video_quality_test_fixture.h" 24*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_bitrate_allocator_factory.h" 25*d9f75844SAndroid Build Coastguard Worker #include "call/fake_network_pipe.h" 26*d9f75844SAndroid Build Coastguard Worker #include "media/engine/internal_decoder_factory.h" 27*d9f75844SAndroid Build Coastguard Worker #include "media/engine/internal_encoder_factory.h" 28*d9f75844SAndroid Build Coastguard Worker #include "test/call_test.h" 29*d9f75844SAndroid Build Coastguard Worker #include "test/layer_filtering_transport.h" 30*d9f75844SAndroid Build Coastguard Worker #include "video/video_analyzer.h" 31*d9f75844SAndroid Build Coastguard Worker #ifdef WEBRTC_WIN 32*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_device/win/core_audio_utility_win.h" 33*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/win/scoped_com_initializer.h" 34*d9f75844SAndroid Build Coastguard Worker #endif 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 37*d9f75844SAndroid Build Coastguard Worker 38*d9f75844SAndroid Build Coastguard Worker class VideoQualityTest : public test::CallTest, 39*d9f75844SAndroid Build Coastguard Worker public VideoQualityTestFixtureInterface { 40*d9f75844SAndroid Build Coastguard Worker public: 41*d9f75844SAndroid Build Coastguard Worker explicit VideoQualityTest( 42*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<InjectionComponents> injection_components); 43*d9f75844SAndroid Build Coastguard Worker 44*d9f75844SAndroid Build Coastguard Worker void RunWithAnalyzer(const Params& params) override; 45*d9f75844SAndroid Build Coastguard Worker void RunWithRenderers(const Params& params) override; 46*d9f75844SAndroid Build Coastguard Worker payload_type_map()47*d9f75844SAndroid Build Coastguard Worker const std::map<uint8_t, webrtc::MediaType>& payload_type_map() override { 48*d9f75844SAndroid Build Coastguard Worker return payload_type_map_; 49*d9f75844SAndroid Build Coastguard Worker } 50*d9f75844SAndroid Build Coastguard Worker 51*d9f75844SAndroid Build Coastguard Worker static void FillScalabilitySettings( 52*d9f75844SAndroid Build Coastguard Worker Params* params, 53*d9f75844SAndroid Build Coastguard Worker size_t video_idx, 54*d9f75844SAndroid Build Coastguard Worker const std::vector<std::string>& stream_descriptors, 55*d9f75844SAndroid Build Coastguard Worker int num_streams, 56*d9f75844SAndroid Build Coastguard Worker size_t selected_stream, 57*d9f75844SAndroid Build Coastguard Worker int num_spatial_layers, 58*d9f75844SAndroid Build Coastguard Worker int selected_sl, 59*d9f75844SAndroid Build Coastguard Worker InterLayerPredMode inter_layer_pred, 60*d9f75844SAndroid Build Coastguard Worker const std::vector<std::string>& sl_descriptors); 61*d9f75844SAndroid Build Coastguard Worker 62*d9f75844SAndroid Build Coastguard Worker // Helper static methods. 63*d9f75844SAndroid Build Coastguard Worker static VideoStream DefaultVideoStream(const Params& params, size_t video_idx); 64*d9f75844SAndroid Build Coastguard Worker static VideoStream DefaultThumbnailStream(); 65*d9f75844SAndroid Build Coastguard Worker static std::vector<int> ParseCSV(const std::string& str); 66*d9f75844SAndroid Build Coastguard Worker 67*d9f75844SAndroid Build Coastguard Worker protected: 68*d9f75844SAndroid Build Coastguard Worker std::map<uint8_t, webrtc::MediaType> payload_type_map_; 69*d9f75844SAndroid Build Coastguard Worker 70*d9f75844SAndroid Build Coastguard Worker // No-op implementation to be able to instantiate this class from non-TEST_F 71*d9f75844SAndroid Build Coastguard Worker // locations. 72*d9f75844SAndroid Build Coastguard Worker void TestBody() override; 73*d9f75844SAndroid Build Coastguard Worker 74*d9f75844SAndroid Build Coastguard Worker // Helper methods accessing only params_. 75*d9f75844SAndroid Build Coastguard Worker std::string GenerateGraphTitle() const; 76*d9f75844SAndroid Build Coastguard Worker void CheckParamsAndInjectionComponents(); 77*d9f75844SAndroid Build Coastguard Worker 78*d9f75844SAndroid Build Coastguard Worker // Helper methods for setting up the call. 79*d9f75844SAndroid Build Coastguard Worker void CreateCapturers(); 80*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<test::FrameGeneratorInterface> CreateFrameGenerator( 81*d9f75844SAndroid Build Coastguard Worker size_t video_idx); 82*d9f75844SAndroid Build Coastguard Worker void SetupThumbnailCapturers(size_t num_thumbnail_streams); 83*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoDecoder> CreateVideoDecoder( 84*d9f75844SAndroid Build Coastguard Worker const SdpVideoFormat& format); 85*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format, 86*d9f75844SAndroid Build Coastguard Worker VideoAnalyzer* analyzer); 87*d9f75844SAndroid Build Coastguard Worker void SetupVideo(Transport* send_transport, Transport* recv_transport); 88*d9f75844SAndroid Build Coastguard Worker void SetupThumbnails(Transport* send_transport, Transport* recv_transport); 89*d9f75844SAndroid Build Coastguard Worker void StartAudioStreams(); 90*d9f75844SAndroid Build Coastguard Worker void StartThumbnails(); 91*d9f75844SAndroid Build Coastguard Worker void StopThumbnails(); 92*d9f75844SAndroid Build Coastguard Worker void DestroyThumbnailStreams(); 93*d9f75844SAndroid Build Coastguard Worker // Helper method for creating a real ADM (using hardware) for all platforms. 94*d9f75844SAndroid Build Coastguard Worker rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice(); 95*d9f75844SAndroid Build Coastguard Worker void InitializeAudioDevice(Call::Config* send_call_config, 96*d9f75844SAndroid Build Coastguard Worker Call::Config* recv_call_config, 97*d9f75844SAndroid Build Coastguard Worker bool use_real_adm); 98*d9f75844SAndroid Build Coastguard Worker void SetupAudio(Transport* transport); 99*d9f75844SAndroid Build Coastguard Worker 100*d9f75844SAndroid Build Coastguard Worker void StartEncodedFrameLogs(VideoReceiveStreamInterface* stream); 101*d9f75844SAndroid Build Coastguard Worker 102*d9f75844SAndroid Build Coastguard Worker virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport(); 103*d9f75844SAndroid Build Coastguard Worker virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport(); 104*d9f75844SAndroid Build Coastguard Worker 105*d9f75844SAndroid Build Coastguard Worker std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>> 106*d9f75844SAndroid Build Coastguard Worker thumbnail_capturers_; 107*d9f75844SAndroid Build Coastguard Worker Clock* const clock_; 108*d9f75844SAndroid Build Coastguard Worker const std::unique_ptr<TaskQueueFactory> task_queue_factory_; 109*d9f75844SAndroid Build Coastguard Worker RtcEventLogFactory rtc_event_log_factory_; 110*d9f75844SAndroid Build Coastguard Worker 111*d9f75844SAndroid Build Coastguard Worker test::FunctionVideoDecoderFactory video_decoder_factory_; 112*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoDecoderFactory> decoder_factory_; 113*d9f75844SAndroid Build Coastguard Worker test::FunctionVideoEncoderFactory video_encoder_factory_; 114*d9f75844SAndroid Build Coastguard Worker test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_; 115*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoBitrateAllocatorFactory> 116*d9f75844SAndroid Build Coastguard Worker video_bitrate_allocator_factory_; 117*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoEncoderFactory> encoder_factory_; 118*d9f75844SAndroid Build Coastguard Worker std::vector<VideoSendStream::Config> thumbnail_send_configs_; 119*d9f75844SAndroid Build Coastguard Worker std::vector<VideoEncoderConfig> thumbnail_encoder_configs_; 120*d9f75844SAndroid Build Coastguard Worker std::vector<VideoSendStream*> thumbnail_send_streams_; 121*d9f75844SAndroid Build Coastguard Worker std::vector<VideoReceiveStreamInterface::Config> thumbnail_receive_configs_; 122*d9f75844SAndroid Build Coastguard Worker std::vector<VideoReceiveStreamInterface*> thumbnail_receive_streams_; 123*d9f75844SAndroid Build Coastguard Worker 124*d9f75844SAndroid Build Coastguard Worker int receive_logs_; 125*d9f75844SAndroid Build Coastguard Worker int send_logs_; 126*d9f75844SAndroid Build Coastguard Worker 127*d9f75844SAndroid Build Coastguard Worker Params params_; 128*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<InjectionComponents> injection_components_; 129*d9f75844SAndroid Build Coastguard Worker 130*d9f75844SAndroid Build Coastguard Worker // Set non-null when running with analyzer. 131*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<VideoAnalyzer> analyzer_; 132*d9f75844SAndroid Build Coastguard Worker 133*d9f75844SAndroid Build Coastguard Worker // Note: not same as similarly named member in CallTest. This is the number of 134*d9f75844SAndroid Build Coastguard Worker // separate send streams, the one in CallTest is the number of substreams for 135*d9f75844SAndroid Build Coastguard Worker // a single send stream. 136*d9f75844SAndroid Build Coastguard Worker size_t num_video_streams_; 137*d9f75844SAndroid Build Coastguard Worker 138*d9f75844SAndroid Build Coastguard Worker #ifdef WEBRTC_WIN 139*d9f75844SAndroid Build Coastguard Worker // Windows Core Audio based ADM needs to run on a COM initialized thread. 140*d9f75844SAndroid Build Coastguard Worker // Only referenced in combination with --audio --use_real_adm flags. 141*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<ScopedCOMInitializer> com_initializer_; 142*d9f75844SAndroid Build Coastguard Worker #endif 143*d9f75844SAndroid Build Coastguard Worker }; 144*d9f75844SAndroid Build Coastguard Worker 145*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 146*d9f75844SAndroid Build Coastguard Worker 147*d9f75844SAndroid Build Coastguard Worker #endif // VIDEO_VIDEO_QUALITY_TEST_H_ 148