• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/pclf/media_configuration.h"
22 #include "api/test/pclf/media_quality_test_params.h"
23 #include "api/test/pclf/peer_configurer.h"
24 #include "api/test/time_controller.h"
25 #include "modules/audio_device/include/test_audio_device.h"
26 #include "rtc_base/task_queue.h"
27 #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.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(AudioConfig config)
35       : sampling_frequency_in_hz(config.sampling_frequency_in_hz),
36         output_file_name(config.output_dump_file_name) {}
37 
38   static absl::optional<RemotePeerAudioConfig> Create(
39       absl::optional<AudioConfig> config);
40 
41   int sampling_frequency_in_hz;
42   absl::optional<std::string> output_file_name;
43 };
44 
45 class TestPeerFactory {
46  public:
47   // Creates a test peer factory.
48   // `signaling_thread` will be used as a signaling thread for all peers created
49   // by this factory.
50   // `time_controller` will be used to create required threads, task queue
51   // factories and call factory.
52   // `video_analyzer_helper` will be used to setup video quality analysis for
53   // created peers.
54   // `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)55   TestPeerFactory(rtc::Thread* signaling_thread,
56                   TimeController& time_controller,
57                   VideoQualityAnalyzerInjectionHelper* video_analyzer_helper,
58                   rtc::TaskQueue* task_queue)
59       : signaling_thread_(signaling_thread),
60         time_controller_(time_controller),
61         video_analyzer_helper_(video_analyzer_helper),
62         task_queue_(task_queue) {}
63 
64   // Setups all components, that should be provided to WebRTC
65   // PeerConnectionFactory and PeerConnection creation methods,
66   // also will setup dependencies, that are required for media analyzers
67   // injection.
68   std::unique_ptr<TestPeer> CreateTestPeer(
69       std::unique_ptr<PeerConfigurer> configurer,
70       std::unique_ptr<MockPeerConnectionObserver> observer,
71       absl::optional<RemotePeerAudioConfig> remote_audio_config,
72       absl::optional<EchoEmulationConfig> echo_emulation_config);
73 
74  private:
75   rtc::Thread* signaling_thread_;
76   TimeController& time_controller_;
77   VideoQualityAnalyzerInjectionHelper* video_analyzer_helper_;
78   rtc::TaskQueue* task_queue_;
79 };
80 
81 }  // namespace webrtc_pc_e2e
82 }  // namespace webrtc
83 
84 #endif  // TEST_PC_E2E_TEST_PEER_FACTORY_H_
85