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.

134 lines
4.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2011 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 PC_PEER_CONNECTION_FACTORY_H_
  11. #define PC_PEER_CONNECTION_FACTORY_H_
  12. #include <memory>
  13. #include <string>
  14. #include "api/media_stream_interface.h"
  15. #include "api/peer_connection_interface.h"
  16. #include "api/scoped_refptr.h"
  17. #include "api/transport/media/media_transport_interface.h"
  18. #include "media/sctp/sctp_transport_internal.h"
  19. #include "pc/channel_manager.h"
  20. #include "rtc_base/rtc_certificate_generator.h"
  21. #include "rtc_base/thread.h"
  22. namespace rtc {
  23. class BasicNetworkManager;
  24. class BasicPacketSocketFactory;
  25. } // namespace rtc
  26. namespace webrtc {
  27. class RtcEventLog;
  28. class PeerConnectionFactory : public PeerConnectionFactoryInterface {
  29. public:
  30. void SetOptions(const Options& options) override;
  31. rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
  32. const PeerConnectionInterface::RTCConfiguration& configuration,
  33. std::unique_ptr<cricket::PortAllocator> allocator,
  34. std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
  35. PeerConnectionObserver* observer) override;
  36. rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
  37. const PeerConnectionInterface::RTCConfiguration& configuration,
  38. PeerConnectionDependencies dependencies) override;
  39. bool Initialize();
  40. RtpCapabilities GetRtpSenderCapabilities(
  41. cricket::MediaType kind) const override;
  42. RtpCapabilities GetRtpReceiverCapabilities(
  43. cricket::MediaType kind) const override;
  44. rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream(
  45. const std::string& stream_id) override;
  46. rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
  47. const cricket::AudioOptions& options) override;
  48. rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
  49. const std::string& id,
  50. VideoTrackSourceInterface* video_source) override;
  51. rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
  52. const std::string& id,
  53. AudioSourceInterface* audio_source) override;
  54. bool StartAecDump(FILE* file, int64_t max_size_bytes) override;
  55. void StopAecDump() override;
  56. virtual std::unique_ptr<cricket::SctpTransportInternalFactory>
  57. CreateSctpTransportInternalFactory();
  58. virtual cricket::ChannelManager* channel_manager();
  59. rtc::Thread* signaling_thread() {
  60. // This method can be called on a different thread when the factory is
  61. // created in CreatePeerConnectionFactory().
  62. return signaling_thread_;
  63. }
  64. rtc::Thread* worker_thread() { return worker_thread_; }
  65. rtc::Thread* network_thread() { return network_thread_; }
  66. const Options& options() const { return options_; }
  67. MediaTransportFactory* media_transport_factory() {
  68. return media_transport_factory_.get();
  69. }
  70. protected:
  71. // This structure allows simple management of all new dependencies being added
  72. // to the PeerConnectionFactory.
  73. explicit PeerConnectionFactory(
  74. PeerConnectionFactoryDependencies dependencies);
  75. // Hook to let testing framework insert actions between
  76. // "new RTCPeerConnection" and "pc.Initialize"
  77. virtual void ActionsBeforeInitializeForTesting(PeerConnectionInterface*) {}
  78. virtual ~PeerConnectionFactory();
  79. private:
  80. std::unique_ptr<RtcEventLog> CreateRtcEventLog_w();
  81. std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log);
  82. bool wraps_current_thread_;
  83. rtc::Thread* network_thread_;
  84. rtc::Thread* worker_thread_;
  85. rtc::Thread* signaling_thread_;
  86. std::unique_ptr<rtc::Thread> owned_network_thread_;
  87. std::unique_ptr<rtc::Thread> owned_worker_thread_;
  88. const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
  89. Options options_;
  90. std::unique_ptr<cricket::ChannelManager> channel_manager_;
  91. std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_;
  92. std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_;
  93. std::unique_ptr<cricket::MediaEngineInterface> media_engine_;
  94. std::unique_ptr<webrtc::CallFactoryInterface> call_factory_;
  95. std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_;
  96. std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
  97. std::unique_ptr<NetworkStatePredictorFactoryInterface>
  98. network_state_predictor_factory_;
  99. std::unique_ptr<NetworkControllerFactoryInterface>
  100. injected_network_controller_factory_;
  101. std::unique_ptr<MediaTransportFactory> media_transport_factory_;
  102. };
  103. } // namespace webrtc
  104. #endif // PC_PEER_CONNECTION_FACTORY_H_