henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 27 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 28 | #ifndef TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |
| 29 | #define TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |
| 30 | |
| 31 | #include <string> |
| 32 | |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 33 | #include "talk/app/webrtc/dtlsidentitystore.h" |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 34 | #include "talk/app/webrtc/mediacontroller.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 35 | #include "talk/app/webrtc/mediastreaminterface.h" |
| 36 | #include "talk/app/webrtc/peerconnectioninterface.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 37 | #include "talk/session/media/channelmanager.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 38 | #include "webrtc/base/scoped_ptr.h" |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 39 | #include "webrtc/base/scoped_ref_ptr.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 40 | #include "webrtc/base/thread.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 42 | namespace rtc { |
| 43 | class BasicNetworkManager; |
| 44 | class BasicPacketSocketFactory; |
| 45 | } |
| 46 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | namespace webrtc { |
| 48 | |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 49 | typedef rtc::RefCountedObject<DtlsIdentityStoreImpl> |
| 50 | RefCountedDtlsIdentityStore; |
jiayl@webrtc.org | 61e00b0 | 2015-03-04 22:17:38 +0000 | [diff] [blame] | 51 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 52 | class PeerConnectionFactory : public PeerConnectionFactoryInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 53 | public: |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 54 | virtual void SetOptions(const Options& options) { |
| 55 | options_ = options; |
| 56 | } |
| 57 | |
deadbeef | 41b0798 | 2015-12-01 15:01:24 -0800 | [diff] [blame] | 58 | rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( |
| 59 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 60 | const MediaConstraintsInterface* constraints, |
| 61 | rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 62 | rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 63 | PeerConnectionObserver* observer) override; |
| 64 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 | bool Initialize(); |
| 66 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 67 | rtc::scoped_refptr<MediaStreamInterface> |
| 68 | CreateLocalMediaStream(const std::string& label) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 70 | rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 71 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 73 | rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 74 | cricket::VideoCapturer* capturer, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 75 | const MediaConstraintsInterface* constraints) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 76 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 77 | rtc::scoped_refptr<VideoTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 78 | CreateVideoTrack(const std::string& id, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 79 | VideoSourceInterface* video_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 80 | |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 81 | rtc::scoped_refptr<AudioTrackInterface> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | CreateAudioTrack(const std::string& id, |
perkj@webrtc.org | 81134d0 | 2015-01-12 08:30:16 +0000 | [diff] [blame] | 83 | AudioSourceInterface* audio_source) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 84 | |
ivoc | d66b44d | 2016-01-15 03:06:36 -0800 | [diff] [blame^] | 85 | bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override; |
ivoc | 797ef12 | 2015-10-22 03:25:41 -0700 | [diff] [blame] | 86 | void StopAecDump() override; |
ivoc | 112a3d8 | 2015-10-16 02:22:18 -0700 | [diff] [blame] | 87 | bool StartRtcEventLog(rtc::PlatformFile file) override; |
| 88 | void StopRtcEventLog() override; |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 89 | |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 90 | virtual webrtc::MediaControllerInterface* CreateMediaController() 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 | |
| 132 | #endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |