1 /* 2 * Copyright (c) 2020 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 11 #ifndef TEST_PC_E2E_TEST_PEER_FACTORY_H_ 12 #define TEST_PC_E2E_TEST_PEER_FACTORY_H_ 13 14 #include <map> 15 #include <memory> 16 #include <string> 17 #include <vector> 18 19 #include "absl/strings/string_view.h" 20 #include "api/rtc_event_log/rtc_event_log_factory.h" 21 #include "api/test/peerconnection_quality_test_fixture.h" 22 #include "api/test/time_controller.h" 23 #include "modules/audio_device/include/test_audio_device.h" 24 #include "rtc_base/task_queue.h" 25 #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h" 26 #include "test/pc/e2e/peer_configurer.h" 27 #include "test/pc/e2e/peer_connection_quality_test_params.h" 28 #include "test/pc/e2e/test_peer.h" 29 30 namespace webrtc { 31 namespace webrtc_pc_e2e { 32 33 struct RemotePeerAudioConfig { RemotePeerAudioConfigRemotePeerAudioConfig34 explicit RemotePeerAudioConfig( 35 PeerConnectionE2EQualityTestFixture::AudioConfig config) 36 : sampling_frequency_in_hz(config.sampling_frequency_in_hz), 37 output_file_name(config.output_dump_file_name) {} 38 39 static absl::optional<RemotePeerAudioConfig> Create( 40 absl::optional<PeerConnectionE2EQualityTestFixture::AudioConfig> config); 41 42 int sampling_frequency_in_hz; 43 absl::optional<std::string> output_file_name; 44 }; 45 46 class TestPeerFactory { 47 public: 48 // Creates a test peer factory. 49 // |signaling_thread| will be used as a signaling thread for all peers created 50 // by this factory. 51 // |time_controller| will be used to create required threads, task queue 52 // factories and call factory. 53 // |video_analyzer_helper| will be used to setup video quality analysis for 54 // created peers. 55 // |task_queue| will be used for AEC dump if it is requested. TestPeerFactory(rtc::Thread * signaling_thread,TimeController & time_controller,VideoQualityAnalyzerInjectionHelper * video_analyzer_helper,rtc::TaskQueue * task_queue)56 TestPeerFactory(rtc::Thread* signaling_thread, 57 TimeController& time_controller, 58 VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, 59 rtc::TaskQueue* task_queue) 60 : signaling_thread_(signaling_thread), 61 time_controller_(time_controller), 62 video_analyzer_helper_(video_analyzer_helper), 63 task_queue_(task_queue) {} 64 65 // Setups all components, that should be provided to WebRTC 66 // PeerConnectionFactory and PeerConnection creation methods, 67 // also will setup dependencies, that are required for media analyzers 68 // injection. 69 std::unique_ptr<TestPeer> CreateTestPeer( 70 std::unique_ptr<PeerConfigurerImpl> configurer, 71 std::unique_ptr<MockPeerConnectionObserver> observer, 72 absl::optional<RemotePeerAudioConfig> remote_audio_config, 73 double bitrate_multiplier, 74 absl::optional<PeerConnectionE2EQualityTestFixture::EchoEmulationConfig> 75 echo_emulation_config); 76 77 private: 78 rtc::Thread* signaling_thread_; 79 TimeController& time_controller_; 80 VideoQualityAnalyzerInjectionHelper* video_analyzer_helper_; 81 rtc::TaskQueue* task_queue_; 82 }; 83 84 } // namespace webrtc_pc_e2e 85 } // namespace webrtc 86 87 #endif // TEST_PC_E2E_TEST_PEER_FACTORY_H_ 88