Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 1 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 3 | * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license |
| 6 | * that can be found in the LICENSE file in the root of the source |
| 7 | * tree. An additional intellectual property rights grant can be found |
| 8 | * in the file PATENTS. All contributing project authors may |
| 9 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 10 | */ |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 11 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 12 | #ifndef PC_PEER_CONNECTION_FACTORY_H_ |
| 13 | #define PC_PEER_CONNECTION_FACTORY_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 14 | |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 15 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | #include <string> |
| 17 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 18 | #include "api/media_stream_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 19 | #include "api/peer_connection_interface.h" |
Mirko Bonadei | d970807 | 2019-01-25 20:26:48 +0100 | [diff] [blame] | 20 | #include "api/scoped_refptr.h" |
Niels Möller | 65f17ca | 2019-09-12 13:59:36 +0200 | [diff] [blame] | 21 | #include "api/transport/media/media_transport_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "media/sctp/sctp_transport_internal.h" |
| 23 | #include "pc/channel_manager.h" |
| 24 | #include "rtc_base/rtc_certificate_generator.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "rtc_base/thread.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 26 | |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 27 | namespace rtc { |
| 28 | class BasicNetworkManager; |
| 29 | class BasicPacketSocketFactory; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 30 | } // namespace rtc |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 31 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | namespace webrtc { |
| 33 | |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 34 | class RtcEventLog; |
| 35 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 36 | class PeerConnectionFactory : public PeerConnectionFactoryInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | public: |
jbauch | cb56065 | 2016-08-04 05:20:32 -0700 | [diff] [blame] | 38 | void SetOptions(const Options& options) override; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 39 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 40 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 41 | const PeerConnectionInterface::RTCConfiguration& configuration, |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 42 | std::unique_ptr<cricket::PortAllocator> allocator, |
Henrik Boström | d03c23b | 2016-06-01 11:44:18 +0200 | [diff] [blame] | 43 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 44 | PeerConnectionObserver* observer) override; |
| 45 | |
Benjamin Wright | 6f7e6d6 | 2018-05-02 13:46:31 -0700 | [diff] [blame] | 46 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 47 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 48 | PeerConnectionDependencies dependencies) override; |
| 49 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | bool Initialize(); |
| 51 | |
Florent Castelli | 72b751a | 2018-06-28 14:09:33 +0200 | [diff] [blame] | 52 | RtpCapabilities GetRtpSenderCapabilities( |
| 53 | cricket::MediaType kind) const override; |
| 54 | |
| 55 | RtpCapabilities GetRtpReceiverCapabilities( |
| 56 | cricket::MediaType kind) const override; |
| 57 | |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 58 | rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream( |
| 59 | const std::string& stream_id) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 60 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 61 | rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 62 | const cricket::AudioOptions& options) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 63 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 64 | rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack( |
| 65 | const std::string& id, |
| 66 | VideoTrackSourceInterface* video_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 68 | rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack( |
| 69 | const std::string& id, |
| 70 | AudioSourceInterface* audio_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 71 | |
Niels Möller | e8e4dc4 | 2019-06-11 14:04:16 +0200 | [diff] [blame] | 72 | bool StartAecDump(FILE* file, int64_t max_size_bytes) override; |
ivoc | 797ef12 | 2015-10-22 03:25:41 -0700 | [diff] [blame] | 73 | void StopAecDump() override; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 74 | |
Steve Anton | da6c095 | 2017-10-23 11:41:54 -0700 | [diff] [blame] | 75 | virtual std::unique_ptr<cricket::SctpTransportInternalFactory> |
| 76 | CreateSctpTransportInternalFactory(); |
| 77 | |
nisse | eaabdf6 | 2017-05-05 02:23:02 -0700 | [diff] [blame] | 78 | virtual cricket::ChannelManager* channel_manager(); |
Karl Wiberg | 4ae6347 | 2019-02-22 00:57:06 +0100 | [diff] [blame] | 79 | |
| 80 | rtc::Thread* signaling_thread() { |
| 81 | // This method can be called on a different thread when the factory is |
| 82 | // created in CreatePeerConnectionFactory(). |
| 83 | return signaling_thread_; |
| 84 | } |
| 85 | rtc::Thread* worker_thread() { return worker_thread_; } |
| 86 | rtc::Thread* network_thread() { return network_thread_; } |
| 87 | |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 88 | const Options& options() const { return options_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 89 | |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 90 | MediaTransportFactory* media_transport_factory() { |
| 91 | return media_transport_factory_.get(); |
| 92 | } |
| 93 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 94 | protected: |
Danil Chapovalov | f5258be | 2019-03-19 17:45:24 +0100 | [diff] [blame] | 95 | // This structure allows simple management of all new dependencies being added |
| 96 | // to the PeerConnectionFactory. |
Benjamin Wright | 5234a49 | 2018-05-29 15:04:32 -0700 | [diff] [blame] | 97 | explicit PeerConnectionFactory( |
| 98 | PeerConnectionFactoryDependencies dependencies); |
| 99 | |
Harald Alvestrand | 1979384 | 2018-06-25 12:03:50 +0200 | [diff] [blame] | 100 | // Hook to let testing framework insert actions between |
| 101 | // "new RTCPeerConnection" and "pc.Initialize" |
| 102 | virtual void ActionsBeforeInitializeForTesting(PeerConnectionInterface*) {} |
| 103 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 104 | virtual ~PeerConnectionFactory(); |
| 105 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | private: |
Erik Språng | 662678d | 2019-11-15 17:18:52 +0100 | [diff] [blame] | 107 | bool IsTrialEnabled(absl::string_view key) const; |
| 108 | |
eladalon | 248fd4f | 2017-09-06 05:18:15 -0700 | [diff] [blame] | 109 | std::unique_ptr<RtcEventLog> CreateRtcEventLog_w(); |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 110 | std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log); |
| 111 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 112 | bool wraps_current_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 113 | rtc::Thread* network_thread_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 114 | rtc::Thread* worker_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 115 | rtc::Thread* signaling_thread_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 116 | std::unique_ptr<rtc::Thread> owned_network_thread_; |
| 117 | std::unique_ptr<rtc::Thread> owned_worker_thread_; |
Danil Chapovalov | 9435c61 | 2019-04-01 10:33:16 +0200 | [diff] [blame] | 118 | const std::unique_ptr<TaskQueueFactory> task_queue_factory_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 119 | Options options_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 120 | std::unique_ptr<cricket::ChannelManager> channel_manager_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 121 | std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_; |
| 122 | std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 123 | std::unique_ptr<cricket::MediaEngineInterface> media_engine_; |
| 124 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory_; |
| 125 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_; |
Ying Wang | 0dd1b0a | 2018-02-20 12:50:27 +0100 | [diff] [blame] | 126 | std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_; |
Ying Wang | 0810a7c | 2019-04-10 13:48:24 +0200 | [diff] [blame] | 127 | std::unique_ptr<NetworkStatePredictorFactoryInterface> |
| 128 | network_state_predictor_factory_; |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 129 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 130 | injected_network_controller_factory_; |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 131 | std::unique_ptr<MediaTransportFactory> media_transport_factory_; |
Ivo Creusen | c3d1f9b | 2019-11-01 11:47:51 +0100 | [diff] [blame] | 132 | std::unique_ptr<NetEqFactory> neteq_factory_; |
Erik Språng | 662678d | 2019-11-15 17:18:52 +0100 | [diff] [blame] | 133 | const std::unique_ptr<WebRtcKeyValueConfig> trials_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | } // namespace webrtc |
| 137 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 138 | #endif // PC_PEER_CONNECTION_FACTORY_H_ |