henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef PC_PEERCONNECTIONFACTORY_H_ |
| 12 | #define PC_PEERCONNECTIONFACTORY_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 14 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | #include <string> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/mediastreaminterface.h" |
| 18 | #include "api/peerconnectioninterface.h" |
| 19 | #include "pc/channelmanager.h" |
| 20 | #include "rtc_base/rtccertificategenerator.h" |
| 21 | #include "rtc_base/scoped_ref_ptr.h" |
| 22 | #include "rtc_base/thread.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 23 | |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 24 | namespace rtc { |
| 25 | class BasicNetworkManager; |
| 26 | class BasicPacketSocketFactory; |
| 27 | } |
| 28 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 29 | namespace webrtc { |
| 30 | |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 31 | class RtcEventLog; |
| 32 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 33 | class PeerConnectionFactory : public PeerConnectionFactoryInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | public: |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 35 | // Use the overloads of CreateVideoSource that take raw VideoCapturer |
| 36 | // pointers from PeerConnectionFactoryInterface. |
| 37 | // TODO(deadbeef): Remove this using statement once those overloads are |
| 38 | // removed. |
| 39 | using PeerConnectionFactoryInterface::CreateVideoSource; |
| 40 | |
jbauch | cb56065 | 2016-08-04 05:20:32 -0700 | [diff] [blame] | 41 | void SetOptions(const Options& options) override; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 42 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 43 | // Deprecated, use version without constraints. |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 44 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 45 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 46 | const MediaConstraintsInterface* constraints, |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 47 | std::unique_ptr<cricket::PortAllocator> allocator, |
Henrik Boström | d03c23b | 2016-06-01 11:44:18 +0200 | [diff] [blame] | 48 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 49 | PeerConnectionObserver* observer) override; |
| 50 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 51 | virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 52 | const PeerConnectionInterface::RTCConfiguration& configuration, |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 53 | std::unique_ptr<cricket::PortAllocator> allocator, |
Henrik Boström | d03c23b | 2016-06-01 11:44:18 +0200 | [diff] [blame] | 54 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 55 | PeerConnectionObserver* observer) override; |
| 56 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 57 | bool Initialize(); |
| 58 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 59 | rtc::scoped_refptr<MediaStreamInterface> |
| 60 | CreateLocalMediaStream(const std::string& label) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 61 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 62 | virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 63 | const cricket::AudioOptions& options) override; |
| 64 | // Deprecated, use version without constraints. |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 65 | rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 66 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 68 | virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 69 | std::unique_ptr<cricket::VideoCapturer> capturer) override; |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 70 | // This version supports filtering on width, height and frame rate. |
| 71 | // For the "constraints=null" case, use the version without constraints. |
| 72 | // TODO(hta): Design a version without MediaConstraintsInterface. |
| 73 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=5617 |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 74 | rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource( |
deadbeef | 112b2e9 | 2017-02-10 20:13:37 -0800 | [diff] [blame] | 75 | std::unique_ptr<cricket::VideoCapturer> capturer, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 76 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 78 | rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack( |
| 79 | const std::string& id, |
| 80 | VideoTrackSourceInterface* video_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 81 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 82 | rtc::scoped_refptr<AudioTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 83 | CreateAudioTrack(const std::string& id, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 84 | AudioSourceInterface* audio_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 85 | |
ivoc | d66b44d | 2016-01-15 03:06:36 -0800 | [diff] [blame] | 86 | bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; |
ivoc | 797ef12 | 2015-10-22 03:25:41 -0700 | [diff] [blame] | 87 | void StopAecDump() override; |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 88 | // TODO(ivoc) Remove after Chrome is updated. |
| 89 | bool StartRtcEventLog(rtc::PlatformFile file) override { return false; } |
| 90 | // TODO(ivoc) Remove after Chrome is updated. |
ivoc | 9e03c3b | 2016-06-30 00:59:43 -0700 | [diff] [blame] | 91 | bool StartRtcEventLog(rtc::PlatformFile file, |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 92 | int64_t max_size_bytes) override { |
| 93 | return false; |
| 94 | } |
| 95 | // TODO(ivoc) Remove after Chrome is updated. |
| 96 | void StopRtcEventLog() override {} |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 97 | |
zhihuang | 29ff844 | 2016-07-27 11:07:25 -0700 | [diff] [blame] | 98 | virtual cricket::TransportController* CreateTransportController( |
Honghai Zhang | bfd398c | 2016-08-30 22:07:42 -0700 | [diff] [blame] | 99 | cricket::PortAllocator* port_allocator, |
| 100 | bool redetermine_role_on_ice_restart); |
nisse | eaabdf6 | 2017-05-05 02:23:02 -0700 | [diff] [blame] | 101 | virtual cricket::ChannelManager* channel_manager(); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 102 | virtual rtc::Thread* signaling_thread(); |
| 103 | virtual rtc::Thread* worker_thread(); |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 104 | virtual rtc::Thread* network_thread(); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 105 | const Options& options() const { return options_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | |
| 107 | protected: |
kwiberg | 1e4e8cb | 2017-01-31 01:48:08 -0800 | [diff] [blame] | 108 | PeerConnectionFactory( |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 109 | rtc::Thread* network_thread, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 110 | rtc::Thread* worker_thread, |
| 111 | rtc::Thread* signaling_thread, |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 112 | std::unique_ptr<cricket::MediaEngineInterface> media_engine, |
| 113 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory, |
| 114 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 115 | virtual ~PeerConnectionFactory(); |
| 116 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 117 | private: |
eladalon | 248fd4f | 2017-09-06 05:18:15 -0700 | [diff] [blame] | 118 | std::unique_ptr<RtcEventLog> CreateRtcEventLog_w(); |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 119 | std::unique_ptr<Call> CreateCall_w(RtcEventLog* event_log); |
| 120 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 121 | bool wraps_current_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 122 | rtc::Thread* network_thread_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 123 | rtc::Thread* worker_thread_; |
danilchap | e9021a3 | 2016-05-17 01:52:02 -0700 | [diff] [blame] | 124 | rtc::Thread* signaling_thread_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 125 | std::unique_ptr<rtc::Thread> owned_network_thread_; |
| 126 | std::unique_ptr<rtc::Thread> owned_worker_thread_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 127 | Options options_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 128 | std::unique_ptr<cricket::ChannelManager> channel_manager_; |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 129 | std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_; |
| 130 | std::unique_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_; |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 131 | std::unique_ptr<cricket::MediaEngineInterface> media_engine_; |
| 132 | std::unique_ptr<webrtc::CallFactoryInterface> call_factory_; |
| 133 | std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | } // namespace webrtc |
| 137 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 138 | #endif // PC_PEERCONNECTIONFACTORY_H_ |