blob: cad89d4ab5185a48ee1c36248d3325594afcb51a [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 * Copyright 2011 Google Inc.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00004 *
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.org5f93d0a2015-01-20 21:36:13 +000027
henrike@webrtc.org28e20752013-07-10 00:45:36 +000028#ifndef TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_
29#define TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_
30
31#include <string>
32
Henrik Boström5e56c592015-08-11 10:33:13 +020033#include "talk/app/webrtc/dtlsidentitystore.h"
stefanc1aeaf02015-10-15 07:26:07 -070034#include "talk/app/webrtc/mediacontroller.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000035#include "talk/app/webrtc/mediastreaminterface.h"
36#include "talk/app/webrtc/peerconnectioninterface.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000037#include "talk/session/media/channelmanager.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000038#include "webrtc/base/scoped_ptr.h"
Henrik Boström5e56c592015-08-11 10:33:13 +020039#include "webrtc/base/scoped_ref_ptr.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000040#include "webrtc/base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041
deadbeef41b07982015-12-01 15:01:24 -080042namespace rtc {
43class BasicNetworkManager;
44class BasicPacketSocketFactory;
45}
46
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047namespace webrtc {
48
Henrik Boström5e56c592015-08-11 10:33:13 +020049typedef rtc::RefCountedObject<DtlsIdentityStoreImpl>
50 RefCountedDtlsIdentityStore;
jiayl@webrtc.org61e00b02015-03-04 22:17:38 +000051
perkj@webrtc.org81134d02015-01-12 08:30:16 +000052class PeerConnectionFactory : public PeerConnectionFactoryInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053 public:
wu@webrtc.org97077a32013-10-25 21:18:33 +000054 virtual void SetOptions(const Options& options) {
55 options_ = options;
56 }
57
Henrik Boström5e56c592015-08-11 10:33:13 +020058 // webrtc::PeerConnectionFactoryInterface override;
deadbeef41b07982015-12-01 15:01:24 -080059 // TODO(deadbeef): Get rid of this overload once clients are moved to the
60 // new version.
Henrik Boström5e56c592015-08-11 10:33:13 +020061 rtc::scoped_refptr<PeerConnectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000062 CreatePeerConnection(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000063 const PeerConnectionInterface::RTCConfiguration& configuration,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064 const MediaConstraintsInterface* constraints,
65 PortAllocatorFactoryInterface* allocator_factory,
Henrik Boström5e56c592015-08-11 10:33:13 +020066 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
67 PeerConnectionObserver* observer) override;
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000068
deadbeef41b07982015-12-01 15:01:24 -080069 rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
70 const PeerConnectionInterface::RTCConfiguration& configuration,
71 const MediaConstraintsInterface* constraints,
72 rtc::scoped_ptr<cricket::PortAllocator> allocator,
73 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
74 PeerConnectionObserver* observer) override;
75
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076 bool Initialize();
77
perkj@webrtc.org81134d02015-01-12 08:30:16 +000078 rtc::scoped_refptr<MediaStreamInterface>
79 CreateLocalMediaStream(const std::string& label) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080
perkj@webrtc.org81134d02015-01-12 08:30:16 +000081 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
82 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000083
perkj@webrtc.org81134d02015-01-12 08:30:16 +000084 rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085 cricket::VideoCapturer* capturer,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000086 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087
perkj@webrtc.org81134d02015-01-12 08:30:16 +000088 rtc::scoped_refptr<VideoTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000089 CreateVideoTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000090 VideoSourceInterface* video_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091
perkj@webrtc.org81134d02015-01-12 08:30:16 +000092 rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000093 CreateAudioTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000094 AudioSourceInterface* audio_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000095
perkj@webrtc.org81134d02015-01-12 08:30:16 +000096 bool StartAecDump(rtc::PlatformFile file) override;
ivoc797ef122015-10-22 03:25:41 -070097 void StopAecDump() override;
ivoc112a3d82015-10-16 02:22:18 -070098 bool StartRtcEventLog(rtc::PlatformFile file) override;
99 void StopRtcEventLog() override;
wu@webrtc.orga9890802013-12-13 00:21:03 +0000100
stefanc1aeaf02015-10-15 07:26:07 -0700101 virtual webrtc::MediaControllerInterface* CreateMediaController() const;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000102 virtual rtc::Thread* signaling_thread();
103 virtual rtc::Thread* worker_thread();
wu@webrtc.org97077a32013-10-25 21:18:33 +0000104 const Options& options() const { return options_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000105
106 protected:
107 PeerConnectionFactory();
108 PeerConnectionFactory(
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000109 rtc::Thread* worker_thread,
110 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000111 AudioDeviceModule* default_adm,
112 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
113 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
114 virtual ~PeerConnectionFactory();
115
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000116 private:
henrika@webrtc.org62f6e752015-02-11 08:38:35 +0000117 cricket::MediaEngineInterface* CreateMediaEngine_w();
118
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000119 bool owns_ptrs_;
perkj@webrtc.org81134d02015-01-12 08:30:16 +0000120 bool wraps_current_thread_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000121 rtc::Thread* signaling_thread_;
122 rtc::Thread* worker_thread_;
wu@webrtc.org97077a32013-10-25 21:18:33 +0000123 Options options_;
phoglund@webrtc.org006521d2015-02-12 09:23:59 +0000124 rtc::scoped_refptr<PortAllocatorFactoryInterface> default_allocator_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000125 // External Audio device used for audio playback.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000126 rtc::scoped_refptr<AudioDeviceModule> default_adm_;
127 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000128 // External Video encoder factory. This can be NULL if the client has not
129 // injected any. In that case, video engine will use the internal SW encoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000130 rtc::scoped_ptr<cricket::WebRtcVideoEncoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000131 video_encoder_factory_;
132 // External Video decoder factory. This can be NULL if the client has not
133 // injected any. In that case, video engine will use the internal SW decoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000134 rtc::scoped_ptr<cricket::WebRtcVideoDecoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000135 video_decoder_factory_;
deadbeef41b07982015-12-01 15:01:24 -0800136 rtc::scoped_ptr<rtc::BasicNetworkManager> default_network_manager_;
137 rtc::scoped_ptr<rtc::BasicPacketSocketFactory> default_socket_factory_;
jiayl@webrtc.org61e00b02015-03-04 22:17:38 +0000138
Henrik Boström5e56c592015-08-11 10:33:13 +0200139 rtc::scoped_refptr<RefCountedDtlsIdentityStore> dtls_identity_store_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000140};
141
142} // namespace webrtc
143
144#endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_