test_peer_factory.h 3.2 KB

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