You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2019 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_H_
  11. #define TEST_PC_E2E_TEST_PEER_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "absl/memory/memory.h"
  16. #include "api/test/peerconnection_quality_test_fixture.h"
  17. #include "media/base/media_engine.h"
  18. #include "modules/audio_device/include/test_audio_device.h"
  19. #include "pc/peer_connection_wrapper.h"
  20. #include "pc/test/mock_peer_connection_observers.h"
  21. #include "rtc_base/network.h"
  22. #include "rtc_base/task_queue.h"
  23. #include "rtc_base/thread.h"
  24. #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h"
  25. #include "test/pc/e2e/peer_connection_quality_test_params.h"
  26. namespace webrtc {
  27. namespace webrtc_pc_e2e {
  28. // Describes a single participant in the call.
  29. class TestPeer final : public PeerConnectionWrapper {
  30. public:
  31. using PeerConnectionWrapper::PeerConnectionWrapper;
  32. using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig;
  33. using AudioConfig = PeerConnectionE2EQualityTestFixture::AudioConfig;
  34. using EchoEmulationConfig =
  35. PeerConnectionE2EQualityTestFixture::EchoEmulationConfig;
  36. struct RemotePeerAudioConfig {
  37. RemotePeerAudioConfig(AudioConfig config)
  38. : sampling_frequency_in_hz(config.sampling_frequency_in_hz),
  39. output_file_name(config.output_dump_file_name) {}
  40. int sampling_frequency_in_hz;
  41. absl::optional<std::string> output_file_name;
  42. };
  43. static absl::optional<RemotePeerAudioConfig> CreateRemoteAudioConfig(
  44. absl::optional<AudioConfig> config);
  45. // Setups all components, that should be provided to WebRTC
  46. // PeerConnectionFactory and PeerConnection creation methods,
  47. // also will setup dependencies, that are required for media analyzers
  48. // injection.
  49. //
  50. // |signaling_thread| will be provided by test fixture implementation.
  51. // |params| - describes current peer parameters, like current peer video
  52. // streams and audio streams
  53. static std::unique_ptr<TestPeer> CreateTestPeer(
  54. std::unique_ptr<InjectableComponents> components,
  55. std::unique_ptr<Params> params,
  56. std::unique_ptr<MockPeerConnectionObserver> observer,
  57. VideoQualityAnalyzerInjectionHelper* video_analyzer_helper,
  58. rtc::Thread* signaling_thread,
  59. absl::optional<RemotePeerAudioConfig> remote_audio_config,
  60. double bitrate_multiplier,
  61. absl::optional<EchoEmulationConfig> echo_emulation_config,
  62. rtc::TaskQueue* task_queue);
  63. Params* params() const { return params_.get(); }
  64. void DetachAecDump() { audio_processing_->DetachAecDump(); }
  65. // Adds provided |candidates| to the owned peer connection.
  66. bool AddIceCandidates(
  67. std::vector<std::unique_ptr<IceCandidateInterface>> candidates);
  68. private:
  69. TestPeer(rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
  70. rtc::scoped_refptr<PeerConnectionInterface> pc,
  71. std::unique_ptr<MockPeerConnectionObserver> observer,
  72. std::unique_ptr<Params> params,
  73. rtc::scoped_refptr<AudioProcessing> audio_processing);
  74. std::unique_ptr<Params> params_;
  75. rtc::scoped_refptr<AudioProcessing> audio_processing_;
  76. std::vector<std::unique_ptr<IceCandidateInterface>> remote_ice_candidates_;
  77. };
  78. } // namespace webrtc_pc_e2e
  79. } // namespace webrtc
  80. #endif // TEST_PC_E2E_TEST_PEER_H_