blob: 4826b97e6169cbba1f9ff792f97d80b3d99faf87 [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
33#include "talk/app/webrtc/mediastreaminterface.h"
34#include "talk/app/webrtc/peerconnectioninterface.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000035#include "talk/session/media/channelmanager.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000036#include "webrtc/base/scoped_ptr.h"
37#include "webrtc/base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038
39namespace webrtc {
40
perkj@webrtc.org81134d02015-01-12 08:30:16 +000041class PeerConnectionFactory : public PeerConnectionFactoryInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000042 public:
wu@webrtc.org97077a32013-10-25 21:18:33 +000043 virtual void SetOptions(const Options& options) {
44 options_ = options;
45 }
46
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000047 virtual rtc::scoped_refptr<PeerConnectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000048 CreatePeerConnection(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000049 const PeerConnectionInterface::RTCConfiguration& configuration,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050 const MediaConstraintsInterface* constraints,
51 PortAllocatorFactoryInterface* allocator_factory,
52 DTLSIdentityServiceInterface* dtls_identity_service,
53 PeerConnectionObserver* observer);
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000054
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055 bool Initialize();
56
perkj@webrtc.org81134d02015-01-12 08:30:16 +000057 rtc::scoped_refptr<MediaStreamInterface>
58 CreateLocalMediaStream(const std::string& label) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000059
perkj@webrtc.org81134d02015-01-12 08:30:16 +000060 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
61 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000062
perkj@webrtc.org81134d02015-01-12 08:30:16 +000063 rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064 cricket::VideoCapturer* capturer,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000065 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066
perkj@webrtc.org81134d02015-01-12 08:30:16 +000067 rtc::scoped_refptr<VideoTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068 CreateVideoTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000069 VideoSourceInterface* video_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070
perkj@webrtc.org81134d02015-01-12 08:30:16 +000071 rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072 CreateAudioTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000073 AudioSourceInterface* audio_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074
perkj@webrtc.org81134d02015-01-12 08:30:16 +000075 bool StartAecDump(rtc::PlatformFile file) override;
wu@webrtc.orga9890802013-12-13 00:21:03 +000076
henrike@webrtc.org28e20752013-07-10 00:45:36 +000077 virtual cricket::ChannelManager* channel_manager();
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000078 virtual rtc::Thread* signaling_thread();
79 virtual rtc::Thread* worker_thread();
wu@webrtc.org97077a32013-10-25 21:18:33 +000080 const Options& options() const { return options_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000081
82 protected:
83 PeerConnectionFactory();
84 PeerConnectionFactory(
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000085 rtc::Thread* worker_thread,
86 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087 AudioDeviceModule* default_adm,
88 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
89 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
90 virtual ~PeerConnectionFactory();
91
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +000093 bool owns_ptrs_;
perkj@webrtc.org81134d02015-01-12 08:30:16 +000094 bool wraps_current_thread_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000095 rtc::Thread* signaling_thread_;
96 rtc::Thread* worker_thread_;
wu@webrtc.org97077a32013-10-25 21:18:33 +000097 Options options_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000098 rtc::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000099 // External Audio device used for audio playback.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000100 rtc::scoped_refptr<AudioDeviceModule> default_adm_;
101 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000102 // External Video encoder factory. This can be NULL if the client has not
103 // injected any. In that case, video engine will use the internal SW encoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000104 rtc::scoped_ptr<cricket::WebRtcVideoEncoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000105 video_encoder_factory_;
106 // External Video decoder factory. This can be NULL if the client has not
107 // injected any. In that case, video engine will use the internal SW decoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000108 rtc::scoped_ptr<cricket::WebRtcVideoDecoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000109 video_decoder_factory_;
110};
111
112} // namespace webrtc
113
114#endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_