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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 12 | #ifndef PC_PEERCONNECTIONFACTORY_H_ |
| 13 | #define PC_PEERCONNECTIONFACTORY_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 | |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 18 | #include "api/media_transport_interface.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "api/mediastreaminterface.h" |
| 20 | #include "api/peerconnectioninterface.h" |
Steve Anton | da6c095 | 2017-10-23 11:41:54 -0700 | [diff] [blame] | 21 | #include "media/sctp/sctptransportinternal.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "pc/channelmanager.h" |
| 23 | #include "rtc_base/rtccertificategenerator.h" |
| 24 | #include "rtc_base/scoped_ref_ptr.h" |
| 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: |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 38 | // Use the overloads of CreateVideoSource that take raw VideoCapturer |
| 39 | // pointers from PeerConnectionFactoryInterface. |
| 40 | // TODO(deadbeef): Remove this using statement once those overloads are |
| 41 | // removed. |
| 42 | using PeerConnectionFactoryInterface::CreateVideoSource; |
| 43 | |
jbauch | cb56065 | 2016-08-04 05:20:32 -0700 | [diff] [blame] | 44 | void SetOptions(const Options& options) override; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 45 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 46 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 47 | const PeerConnectionInterface::RTCConfiguration& configuration, |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 48 | std::unique_ptr<cricket::PortAllocator> allocator, |
Henrik Boström | d03c23b | 2016-06-01 11:44:18 +0200 | [diff] [blame] | 49 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 50 | PeerConnectionObserver* observer) override; |
| 51 | |
Benjamin Wright | 6f7e6d6 | 2018-05-02 13:46:31 -0700 | [diff] [blame] | 52 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 53 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 54 | PeerConnectionDependencies dependencies) override; |
| 55 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 56 | bool Initialize(); |
| 57 | |
Florent Castelli | 72b751a | 2018-06-28 14:09:33 +0200 | [diff] [blame] | 58 | RtpCapabilities GetRtpSenderCapabilities( |
| 59 | cricket::MediaType kind) const override; |
| 60 | |
| 61 | RtpCapabilities GetRtpReceiverCapabilities( |
| 62 | cricket::MediaType kind) const override; |
| 63 | |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 64 | rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream( |
| 65 | const std::string& stream_id) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 67 | rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 68 | const cricket::AudioOptions& options) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 70 | rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 71 | std::unique_ptr<cricket::VideoCapturer> capturer) override; |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 72 | // This version supports filtering on width, height and frame rate. |
| 73 | // For the "constraints=null" case, use the version without constraints. |
| 74 | // TODO(hta): Design a version without MediaConstraintsInterface. |
| 75 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=5617 |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 76 | rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 77 | std::unique_ptr<cricket::VideoCapturer> capturer, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 78 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 80 | rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack( |
| 81 | const std::string& id, |
| 82 | VideoTrackSourceInterface* video_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 83 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 84 | rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack( |
| 85 | const std::string& id, |
| 86 | AudioSourceInterface* audio_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 87 | |
ivoc | d66b44d | 2016-01-15 03:06:36 -0800 | [diff] [blame] | 88 | bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; |
ivoc | 797ef12 | 2015-10-22 03:25:41 -0700 | [diff] [blame] | 89 | void StopAecDump() override; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 90 | |
Steve Anton | da6c095 | 2017-10-23 11:41:54 -0700 | [diff] [blame] | 91 | virtual std::unique_ptr<cricket::SctpTransportInternalFactory> |
| 92 | CreateSctpTransportInternalFactory(); |
| 93 | |
nisse | eaabdf6 | 2017-05-05 02:23:02 -0700 | [diff] [blame] | 94 | virtual cricket::ChannelManager* channel_manager(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 95 | virtual rtc::Thread* signaling_thread(); |
| 96 | virtual rtc::Thread* worker_thread(); |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 97 | virtual rtc::Thread* network_thread(); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 98 | const Options& options() const { return options_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 99 | |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 100 | MediaTransportFactory* media_transport_factory() { |
| 101 | return media_transport_factory_.get(); |
| 102 | } |
| 103 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 104 | protected: |
kwiberg | 1e4e8cb | 2017-01-31 01:48:08 -0800 | [diff] [blame] | 105 | PeerConnectionFactory( |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 106 | rtc::Thread* network_thread, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 107 | rtc::Thread* worker_thread, |
| 108 | rtc::Thread* signaling_thread, |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 109 | std::unique_ptr<cricket::MediaEngineInterface> media_engine, |
| 110 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory, |
| 111 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory); |
Ying Wang | 0dd1b0a | 2018-02-20 12:50:27 +0100 | [diff] [blame] | 112 | PeerConnectionFactory( |
| 113 | rtc::Thread* network_thread, |
| 114 | rtc::Thread* worker_thread, |
| 115 | rtc::Thread* signaling_thread, |
| 116 | std::unique_ptr<cricket::MediaEngineInterface> media_engine, |
| 117 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory, |
| 118 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory, |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 119 | std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory, |
| 120 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 121 | network_controller_factory); |
Benjamin Wright | 5234a49 | 2018-05-29 15:04:32 -0700 | [diff] [blame] | 122 | // Use this implementation for all future use. This structure allows simple |
| 123 | // management of all new dependencies being added to the |
| 124 | // PeerConnectionFactory. |
| 125 | explicit PeerConnectionFactory( |
| 126 | PeerConnectionFactoryDependencies dependencies); |
| 127 | |
Harald Alvestrand | 1979384 | 2018-06-25 12:03:50 +0200 | [diff] [blame] | 128 | // Hook to let testing framework insert actions between |
| 129 | // "new RTCPeerConnection" and "pc.Initialize" |
| 130 | virtual void ActionsBeforeInitializeForTesting(PeerConnectionInterface*) {} |
| 131 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 132 | virtual ~PeerConnectionFactory(); |
| 133 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 134 | private: |
eladalon | 248fd4f | 2017-09-06 05:18:15 -0700 | [diff] [blame] | 135 | std::unique_ptr<RtcEventLog> CreateRtcEventLog_w(); |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 136 | std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log); |
| 137 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 138 | bool wraps_current_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 139 | rtc::Thread* network_thread_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 140 | rtc::Thread* worker_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 141 | rtc::Thread* signaling_thread_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 142 | std::unique_ptr<rtc::Thread> owned_network_thread_; |
| 143 | std::unique_ptr<rtc::Thread> owned_worker_thread_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 144 | Options options_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 145 | std::unique_ptr<cricket::ChannelManager> channel_manager_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 146 | std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_; |
| 147 | std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 148 | std::unique_ptr<cricket::MediaEngineInterface> media_engine_; |
| 149 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory_; |
| 150 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_; |
Ying Wang | 0dd1b0a | 2018-02-20 12:50:27 +0100 | [diff] [blame] | 151 | std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_; |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 152 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 153 | injected_network_controller_factory_; |
| 154 | std::unique_ptr<NetworkControllerFactoryInterface> |
| 155 | bbr_network_controller_factory_; |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 156 | std::unique_ptr<MediaTransportFactory> media_transport_factory_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | } // namespace webrtc |
| 160 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 161 | #endif // PC_PEERCONNECTIONFACTORY_H_ |