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 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_API_PEERCONNECTIONFACTORY_H_ |
| 12 | #define WEBRTC_API_PEERCONNECTIONFACTORY_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 16 | #include "webrtc/api/dtlsidentitystore.h" |
| 17 | #include "webrtc/api/mediacontroller.h" |
| 18 | #include "webrtc/api/mediastreaminterface.h" |
| 19 | #include "webrtc/api/peerconnectioninterface.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 20 | #include "webrtc/base/scoped_ptr.h" |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 21 | #include "webrtc/base/scoped_ref_ptr.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 22 | #include "webrtc/base/thread.h" |
kjellander@webrtc.org | 9b8df25 | 2016-02-12 06:47:59 +0100 | [diff] [blame] | 23 | #include "webrtc/pc/channelmanager.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 24 | |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 25 | namespace rtc { |
| 26 | class BasicNetworkManager; |
| 27 | class BasicPacketSocketFactory; |
| 28 | } |
| 29 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | namespace webrtc { |
| 31 | |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 32 | typedef rtc::RefCountedObject<DtlsIdentityStoreImpl> |
| 33 | RefCountedDtlsIdentityStore; |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 34 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 35 | class PeerConnectionFactory : public PeerConnectionFactoryInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | public: |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 37 | virtual void SetOptions(const Options& options) { |
| 38 | options_ = options; |
| 39 | } |
| 40 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame^] | 41 | // Deprecated, use version without constraints. |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 42 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 43 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 44 | const MediaConstraintsInterface* constraints, |
| 45 | rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 46 | rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 47 | PeerConnectionObserver* observer) override; |
| 48 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame^] | 49 | virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 50 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 51 | rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 52 | rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 53 | PeerConnectionObserver* observer) override; |
| 54 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | bool Initialize(); |
| 56 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 57 | rtc::scoped_refptr<MediaStreamInterface> |
| 58 | CreateLocalMediaStream(const std::string& label) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 59 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame^] | 60 | virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 61 | const cricket::AudioOptions& options) override; |
| 62 | // Deprecated, use version without constraints. |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 63 | rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 64 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 | |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame^] | 66 | virtual rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource( |
| 67 | cricket::VideoCapturer* capturer) override; |
| 68 | // This version supports filtering on width, height and frame rate. |
| 69 | // For the "constraints=null" case, use the version without constraints. |
| 70 | // TODO(hta): Design a version without MediaConstraintsInterface. |
| 71 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=5617 |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 72 | rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 73 | cricket::VideoCapturer* capturer, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 74 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 75 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 76 | rtc::scoped_refptr<VideoTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | CreateVideoTrack(const std::string& id, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 78 | VideoSourceInterface* video_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 80 | rtc::scoped_refptr<AudioTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 81 | CreateAudioTrack(const std::string& id, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 82 | AudioSourceInterface* audio_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 83 | |
ivoc | d66b44d | 2016-01-15 03:06:36 -0800 | [diff] [blame] | 84 | bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; |
ivoc | 797ef12 | 2015-10-22 03:25:41 -0700 | [diff] [blame] | 85 | void StopAecDump() override; |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 86 | bool StartRtcEventLog(rtc::PlatformFile file) override; |
| 87 | void StopRtcEventLog() override; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 88 | |
nisse | 51542be | 2016-02-12 02:27:06 -0800 | [diff] [blame] | 89 | virtual webrtc::MediaControllerInterface* CreateMediaController( |
| 90 | const cricket::MediaConfig& config) const; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 91 | virtual rtc::Thread* signaling_thread(); |
| 92 | virtual rtc::Thread* worker_thread(); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 93 | const Options& options() const { return options_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 94 | |
| 95 | protected: |
| 96 | PeerConnectionFactory(); |
| 97 | PeerConnectionFactory( |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 98 | rtc::Thread* worker_thread, |
| 99 | rtc::Thread* signaling_thread, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 100 | AudioDeviceModule* default_adm, |
| 101 | cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 102 | cricket::WebRtcVideoDecoderFactory* video_decoder_factory); |
| 103 | virtual ~PeerConnectionFactory(); |
| 104 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 105 | private: |
henrika@webrtc.org | 62f6e75 | 2015-02-11 08:38:35 +0000 | [diff] [blame] | 106 | cricket::MediaEngineInterface* CreateMediaEngine_w(); |
| 107 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 108 | bool owns_ptrs_; |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 109 | bool wraps_current_thread_; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 110 | rtc::Thread* signaling_thread_; |
| 111 | rtc::Thread* worker_thread_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 112 | Options options_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 113 | // External Audio device used for audio playback. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 114 | rtc::scoped_refptr<AudioDeviceModule> default_adm_; |
| 115 | rtc::scoped_ptr<cricket::ChannelManager> channel_manager_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 116 | // External Video encoder factory. This can be NULL if the client has not |
| 117 | // injected any. In that case, video engine will use the internal SW encoder. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 118 | rtc::scoped_ptr<cricket::WebRtcVideoEncoderFactory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 119 | video_encoder_factory_; |
| 120 | // External Video decoder factory. This can be NULL if the client has not |
| 121 | // injected any. In that case, video engine will use the internal SW decoder. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 122 | rtc::scoped_ptr<cricket::WebRtcVideoDecoderFactory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 123 | video_decoder_factory_; |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 124 | rtc::scoped_ptr<rtc::BasicNetworkManager> default_network_manager_; |
| 125 | rtc::scoped_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_; |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 126 | |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 127 | rtc::scoped_refptr<RefCountedDtlsIdentityStore> dtls_identity_store_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | } // namespace webrtc |
| 131 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 132 | #endif // WEBRTC_API_PEERCONNECTIONFACTORY_H_ |