blob: 7faf609424437c5ee640c251ae4df2274a80a072 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
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
38namespace webrtc {
39
40class PeerConnectionFactory : public PeerConnectionFactoryInterface,
41 public talk_base::MessageHandler {
42 public:
43 virtual talk_base::scoped_refptr<PeerConnectionInterface>
44 CreatePeerConnection(
45 const PeerConnectionInterface::IceServers& configuration,
46 const MediaConstraintsInterface* constraints,
47 DTLSIdentityServiceInterface* dtls_identity_service,
48 PeerConnectionObserver* observer);
49
50 virtual talk_base::scoped_refptr<PeerConnectionInterface>
51 CreatePeerConnection(
52 const PeerConnectionInterface::IceServers& configuration,
53 const MediaConstraintsInterface* constraints,
54 PortAllocatorFactoryInterface* allocator_factory,
55 DTLSIdentityServiceInterface* dtls_identity_service,
56 PeerConnectionObserver* observer);
57 bool Initialize();
58
59 virtual talk_base::scoped_refptr<MediaStreamInterface>
60 CreateLocalMediaStream(const std::string& label);
61
62 virtual talk_base::scoped_refptr<AudioSourceInterface> CreateAudioSource(
63 const MediaConstraintsInterface* constraints);
64
65 virtual talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource(
66 cricket::VideoCapturer* capturer,
67 const MediaConstraintsInterface* constraints);
68
69 virtual talk_base::scoped_refptr<VideoTrackInterface>
70 CreateVideoTrack(const std::string& id,
71 VideoSourceInterface* video_source);
72
73 virtual talk_base::scoped_refptr<AudioTrackInterface>
74 CreateAudioTrack(const std::string& id,
75 AudioSourceInterface* audio_source);
76
77 virtual cricket::ChannelManager* channel_manager();
78 virtual talk_base::Thread* signaling_thread();
79 virtual talk_base::Thread* worker_thread();
80
81 protected:
82 PeerConnectionFactory();
83 PeerConnectionFactory(
84 talk_base::Thread* worker_thread,
85 talk_base::Thread* signaling_thread,
86 AudioDeviceModule* default_adm,
87 cricket::WebRtcVideoEncoderFactory* video_encoder_factory,
88 cricket::WebRtcVideoDecoderFactory* video_decoder_factory);
89 virtual ~PeerConnectionFactory();
90
91
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);
100 talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_s(
101 const PeerConnectionInterface::IceServers& configuration,
102 const MediaConstraintsInterface* constraints,
103 PortAllocatorFactoryInterface* allocator_factory,
wu@webrtc.org91053e72013-08-10 07:18:04104 DTLSIdentityServiceInterface* dtls_identity_service,
henrike@webrtc.org28e20752013-07-10 00:45:36105 PeerConnectionObserver* observer);
106 // Implements talk_base::MessageHandler.
107 void OnMessage(talk_base::Message* msg);
108
109 bool owns_ptrs_;
110 talk_base::Thread* signaling_thread_;
111 talk_base::Thread* worker_thread_;
112 talk_base::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
113 // External Audio device used for audio playback.
114 talk_base::scoped_refptr<AudioDeviceModule> default_adm_;
115 talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_;
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.
118 talk_base::scoped_ptr<cricket::WebRtcVideoEncoderFactory>
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.
122 talk_base::scoped_ptr<cricket::WebRtcVideoDecoderFactory>
123 video_decoder_factory_;
124};
125
126} // namespace webrtc
127
128#endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_