blob: 1b734d6a9886986d75af1d667d9dbeb9cf60e148 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
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"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000034#include "talk/session/media/channelmanager.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000035#include "webrtc/base/scoped_ptr.h"
36#include "webrtc/base/thread.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037
38namespace webrtc {
39
perkj@webrtc.org81134d02015-01-12 08:30:16 +000040class PeerConnectionFactory : public PeerConnectionFactoryInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041 public:
wu@webrtc.org97077a32013-10-25 21:18:33 +000042 virtual void SetOptions(const Options& options) {
43 options_ = options;
44 }
45
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000046 virtual rtc::scoped_refptr<PeerConnectionInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047 CreatePeerConnection(
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000048 const PeerConnectionInterface::RTCConfiguration& configuration,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000049 const MediaConstraintsInterface* constraints,
50 PortAllocatorFactoryInterface* allocator_factory,
51 DTLSIdentityServiceInterface* dtls_identity_service,
52 PeerConnectionObserver* observer);
buildbot@webrtc.org41451d42014-05-03 05:39:45 +000053
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054 bool Initialize();
55
perkj@webrtc.org81134d02015-01-12 08:30:16 +000056 rtc::scoped_refptr<MediaStreamInterface>
57 CreateLocalMediaStream(const std::string& label) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000058
perkj@webrtc.org81134d02015-01-12 08:30:16 +000059 rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
60 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000061
perkj@webrtc.org81134d02015-01-12 08:30:16 +000062 rtc::scoped_refptr<VideoSourceInterface> CreateVideoSource(
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063 cricket::VideoCapturer* capturer,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000064 const MediaConstraintsInterface* constraints) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000065
perkj@webrtc.org81134d02015-01-12 08:30:16 +000066 rtc::scoped_refptr<VideoTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000067 CreateVideoTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000068 VideoSourceInterface* video_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069
perkj@webrtc.org81134d02015-01-12 08:30:16 +000070 rtc::scoped_refptr<AudioTrackInterface>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071 CreateAudioTrack(const std::string& id,
perkj@webrtc.org81134d02015-01-12 08:30:16 +000072 AudioSourceInterface* audio_source) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000073
perkj@webrtc.org81134d02015-01-12 08:30:16 +000074 bool StartAecDump(rtc::PlatformFile file) override;
wu@webrtc.orga9890802013-12-13 00:21:03 +000075
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076 virtual cricket::ChannelManager* channel_manager();
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000077 virtual rtc::Thread* signaling_thread();
78 virtual rtc::Thread* worker_thread();
wu@webrtc.org97077a32013-10-25 21:18:33 +000079 const Options& options() const { return options_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080
81 protected:
82 PeerConnectionFactory();
83 PeerConnectionFactory(
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000084 rtc::Thread* worker_thread,
85 rtc::Thread* signaling_thread,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000086 AudioDeviceModule* default_adm,
87 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
88 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
89 virtual ~PeerConnectionFactory();
90
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092 bool owns_ptrs_;
perkj@webrtc.org81134d02015-01-12 08:30:16 +000093 bool wraps_current_thread_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000094 rtc::Thread* signaling_thread_;
95 rtc::Thread* worker_thread_;
wu@webrtc.org97077a32013-10-25 21:18:33 +000096 Options options_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000097 rtc::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000098 // External Audio device used for audio playback.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000099 rtc::scoped_refptr<AudioDeviceModule> default_adm_;
100 rtc::scoped_ptr<cricket::ChannelManager> channel_manager_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101 // External Video encoder factory. This can be NULL if the client has not
102 // injected any. In that case, video engine will use the internal SW encoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000103 rtc::scoped_ptr<cricket::WebRtcVideoEncoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000104 video_encoder_factory_;
105 // External Video decoder factory. This can be NULL if the client has not
106 // injected any. In that case, video engine will use the internal SW decoder.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000107 rtc::scoped_ptr<cricket::WebRtcVideoDecoderFactory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000108 video_decoder_factory_;
109};
110
111} // namespace webrtc
112
113#endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_