henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2011, Google Inc. |
| 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 | */ |
| 27 | #ifndef TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |
| 28 | #define TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |
| 29 | |
| 30 | #include <string> |
| 31 | |
| 32 | #include "talk/app/webrtc/mediastreaminterface.h" |
| 33 | #include "talk/app/webrtc/peerconnectioninterface.h" |
| 34 | #include "talk/base/scoped_ptr.h" |
| 35 | #include "talk/base/thread.h" |
| 36 | #include "talk/session/media/channelmanager.h" |
| 37 | |
| 38 | namespace webrtc { |
| 39 | |
| 40 | class PeerConnectionFactory : public PeerConnectionFactoryInterface, |
| 41 | public talk_base::MessageHandler { |
| 42 | public: |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 43 | virtual void SetOptions(const Options& options) { |
| 44 | options_ = options; |
| 45 | } |
| 46 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | virtual talk_base::scoped_refptr<PeerConnectionInterface> |
| 48 | CreatePeerConnection( |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 49 | const PeerConnectionInterface::RTCConfiguration& configuration, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | const MediaConstraintsInterface* constraints, |
| 51 | PortAllocatorFactoryInterface* allocator_factory, |
| 52 | DTLSIdentityServiceInterface* dtls_identity_service, |
| 53 | PeerConnectionObserver* observer); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 54 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 55 | bool Initialize(); |
| 56 | |
| 57 | virtual talk_base::scoped_refptr<MediaStreamInterface> |
| 58 | CreateLocalMediaStream(const std::string& label); |
| 59 | |
| 60 | virtual talk_base::scoped_refptr<AudioSourceInterface> CreateAudioSource( |
| 61 | const MediaConstraintsInterface* constraints); |
| 62 | |
| 63 | virtual talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource( |
| 64 | cricket::VideoCapturer* capturer, |
| 65 | const MediaConstraintsInterface* constraints); |
| 66 | |
| 67 | virtual talk_base::scoped_refptr<VideoTrackInterface> |
| 68 | CreateVideoTrack(const std::string& id, |
| 69 | VideoSourceInterface* video_source); |
| 70 | |
| 71 | virtual talk_base::scoped_refptr<AudioTrackInterface> |
| 72 | CreateAudioTrack(const std::string& id, |
| 73 | AudioSourceInterface* audio_source); |
| 74 | |
wu@webrtc.org | a8910d2 | 2014-01-23 22:12:45 +0000 | [diff] [blame] | 75 | virtual bool StartAecDump(talk_base::PlatformFile file); |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 76 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | virtual cricket::ChannelManager* channel_manager(); |
| 78 | virtual talk_base::Thread* signaling_thread(); |
| 79 | virtual talk_base::Thread* worker_thread(); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 80 | const Options& options() const { return options_; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 81 | |
| 82 | protected: |
| 83 | PeerConnectionFactory(); |
| 84 | PeerConnectionFactory( |
| 85 | talk_base::Thread* worker_thread, |
| 86 | talk_base::Thread* signaling_thread, |
| 87 | AudioDeviceModule* default_adm, |
| 88 | cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 89 | cricket::WebRtcVideoDecoderFactory* video_decoder_factory); |
| 90 | virtual ~PeerConnectionFactory(); |
| 91 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 92 | private: |
| 93 | bool Initialize_s(); |
| 94 | void Terminate_s(); |
| 95 | talk_base::scoped_refptr<AudioSourceInterface> CreateAudioSource_s( |
| 96 | const MediaConstraintsInterface* constraints); |
| 97 | talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource_s( |
| 98 | cricket::VideoCapturer* capturer, |
| 99 | const MediaConstraintsInterface* constraints); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 100 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_s( |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 102 | const PeerConnectionInterface::RTCConfiguration& configuration, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 103 | const MediaConstraintsInterface* constraints, |
| 104 | PortAllocatorFactoryInterface* allocator_factory, |
wu@webrtc.org | 91053e7 | 2013-08-10 07:18:04 +0000 | [diff] [blame] | 105 | DTLSIdentityServiceInterface* dtls_identity_service, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | PeerConnectionObserver* observer); |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 107 | |
wu@webrtc.org | a8910d2 | 2014-01-23 22:12:45 +0000 | [diff] [blame] | 108 | bool StartAecDump_s(talk_base::PlatformFile file); |
wu@webrtc.org | a989080 | 2013-12-13 00:21:03 +0000 | [diff] [blame] | 109 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 110 | // Implements talk_base::MessageHandler. |
| 111 | void OnMessage(talk_base::Message* msg); |
| 112 | |
| 113 | bool owns_ptrs_; |
| 114 | talk_base::Thread* signaling_thread_; |
| 115 | talk_base::Thread* worker_thread_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 116 | Options options_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 117 | talk_base::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_; |
| 118 | // External Audio device used for audio playback. |
| 119 | talk_base::scoped_refptr<AudioDeviceModule> default_adm_; |
| 120 | talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_; |
| 121 | // External Video encoder factory. This can be NULL if the client has not |
| 122 | // injected any. In that case, video engine will use the internal SW encoder. |
| 123 | talk_base::scoped_ptr<cricket::WebRtcVideoEncoderFactory> |
| 124 | video_encoder_factory_; |
| 125 | // External Video decoder factory. This can be NULL if the client has not |
| 126 | // injected any. In that case, video engine will use the internal SW decoder. |
| 127 | talk_base::scoped_ptr<cricket::WebRtcVideoDecoderFactory> |
| 128 | video_decoder_factory_; |
| 129 | }; |
| 130 | |
| 131 | } // namespace webrtc |
| 132 | |
| 133 | #endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_ |