Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(742)

Side by Side Diff: talk/app/webrtc/peerconnectionfactory.cc

Issue 1176383004: DtlsIdentityStore[Interface/Impl] updated, DtlsIdentityService to be removed (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed rest of tommi's comments: Removed need for lock Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004--2011 Google Inc. 3 * Copyright 2004--2011 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 10 matching lines...) Expand all
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 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, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 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 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/app/webrtc/peerconnectionfactory.h" 28 #include "talk/app/webrtc/peerconnectionfactory.h"
29 29
30 #include "talk/app/webrtc/audiotrack.h" 30 #include "talk/app/webrtc/audiotrack.h"
31 #include "talk/app/webrtc/dtlsidentityservice.h"
32 #include "talk/app/webrtc/dtlsidentitystore.h"
33 #include "talk/app/webrtc/localaudiosource.h" 31 #include "talk/app/webrtc/localaudiosource.h"
34 #include "talk/app/webrtc/mediastreamproxy.h" 32 #include "talk/app/webrtc/mediastreamproxy.h"
35 #include "talk/app/webrtc/mediastreamtrackproxy.h" 33 #include "talk/app/webrtc/mediastreamtrackproxy.h"
36 #include "talk/app/webrtc/peerconnection.h" 34 #include "talk/app/webrtc/peerconnection.h"
37 #include "talk/app/webrtc/peerconnectionfactoryproxy.h" 35 #include "talk/app/webrtc/peerconnectionfactoryproxy.h"
38 #include "talk/app/webrtc/peerconnectionproxy.h" 36 #include "talk/app/webrtc/peerconnectionproxy.h"
39 #include "talk/app/webrtc/portallocatorfactory.h" 37 #include "talk/app/webrtc/portallocatorfactory.h"
40 #include "talk/app/webrtc/videosource.h" 38 #include "talk/app/webrtc/videosource.h"
41 #include "talk/app/webrtc/videosourceproxy.h" 39 #include "talk/app/webrtc/videosourceproxy.h"
42 #include "talk/app/webrtc/videotrack.h" 40 #include "talk/app/webrtc/videotrack.h"
43 #include "talk/media/devices/dummydevicemanager.h" 41 #include "talk/media/devices/dummydevicemanager.h"
44 #include "talk/media/webrtc/webrtcmediaengine.h" 42 #include "talk/media/webrtc/webrtcmediaengine.h"
45 #include "talk/media/webrtc/webrtcvideodecoderfactory.h" 43 #include "talk/media/webrtc/webrtcvideodecoderfactory.h"
46 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" 44 #include "talk/media/webrtc/webrtcvideoencoderfactory.h"
47 #include "webrtc/base/bind.h" 45 #include "webrtc/base/bind.h"
48 #include "webrtc/modules/audio_device/include/audio_device.h" 46 #include "webrtc/modules/audio_device/include/audio_device.h"
49 47
50 namespace webrtc { 48 namespace webrtc {
51 49
50 namespace {
51
52 // Passes down the calls to |store_|. See usage in CreatePeerConnection.
53 class DtlsIdentityStoreWrapper : public DtlsIdentityStoreInterface {
54 public:
55 DtlsIdentityStoreWrapper(
56 const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store)
57 : store_(store) {
58 DCHECK(store_);
59 }
60
61 void Initialize() override {
62 store_->Initialize();
63 }
64 void RequestIdentity(
65 rtc::KeyType key_type,
66 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>&
67 observer) override {
68 store_->RequestIdentity(key_type, observer);
69 }
70
71 private:
72 rtc::scoped_refptr<RefCountedDtlsIdentityStore> store_;
73 };
74
75 } // anonymous namespace
76
52 rtc::scoped_refptr<PeerConnectionFactoryInterface> 77 rtc::scoped_refptr<PeerConnectionFactoryInterface>
53 CreatePeerConnectionFactory() { 78 CreatePeerConnectionFactory() {
54 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( 79 rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
55 new rtc::RefCountedObject<PeerConnectionFactory>()); 80 new rtc::RefCountedObject<PeerConnectionFactory>());
56 81
57 82
58 // Call Initialize synchronously but make sure its executed on 83 // Call Initialize synchronously but make sure its executed on
59 // |signaling_thread|. 84 // |signaling_thread|.
60 MethodCall0<PeerConnectionFactory, bool> call( 85 MethodCall0<PeerConnectionFactory, bool> call(
61 pc_factory.get(), 86 pc_factory.get(),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 video_decoder_factory_(video_decoder_factory) { 148 video_decoder_factory_(video_decoder_factory) {
124 ASSERT(worker_thread != NULL); 149 ASSERT(worker_thread != NULL);
125 ASSERT(signaling_thread != NULL); 150 ASSERT(signaling_thread != NULL);
126 // TODO: Currently there is no way creating an external adm in 151 // TODO: Currently there is no way creating an external adm in
127 // libjingle source tree. So we can 't currently assert if this is NULL. 152 // libjingle source tree. So we can 't currently assert if this is NULL.
128 // ASSERT(default_adm != NULL); 153 // ASSERT(default_adm != NULL);
129 } 154 }
130 155
131 PeerConnectionFactory::~PeerConnectionFactory() { 156 PeerConnectionFactory::~PeerConnectionFactory() {
132 DCHECK(signaling_thread_->IsCurrent()); 157 DCHECK(signaling_thread_->IsCurrent());
133 channel_manager_.reset(NULL); 158 channel_manager_.reset(nullptr);
134 default_allocator_factory_ = NULL; 159 default_allocator_factory_ = nullptr;
135 160
136 // Make sure |worker_thread_| and |signaling_thread_| outlive 161 // Make sure |worker_thread_| and |signaling_thread_| outlive
137 // |dtls_identity_store_|. 162 // |dtls_identity_store_|.
138 dtls_identity_store_.reset(NULL); 163 dtls_identity_store_ = nullptr;
139 164
140 if (owns_ptrs_) { 165 if (owns_ptrs_) {
141 if (wraps_current_thread_) 166 if (wraps_current_thread_)
142 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); 167 rtc::ThreadManager::Instance()->UnwrapCurrentThread();
143 delete worker_thread_; 168 delete worker_thread_;
144 } 169 }
145 } 170 }
146 171
147 bool PeerConnectionFactory::Initialize() { 172 bool PeerConnectionFactory::Initialize() {
148 DCHECK(signaling_thread_->IsCurrent()); 173 DCHECK(signaling_thread_->IsCurrent());
(...skipping 13 matching lines...) Expand all
162 &PeerConnectionFactory::CreateMediaEngine_w, this)); 187 &PeerConnectionFactory::CreateMediaEngine_w, this));
163 188
164 channel_manager_.reset(new cricket::ChannelManager( 189 channel_manager_.reset(new cricket::ChannelManager(
165 media_engine, device_manager, worker_thread_)); 190 media_engine, device_manager, worker_thread_));
166 191
167 channel_manager_->SetVideoRtxEnabled(true); 192 channel_manager_->SetVideoRtxEnabled(true);
168 if (!channel_manager_->Init()) { 193 if (!channel_manager_->Init()) {
169 return false; 194 return false;
170 } 195 }
171 196
172 dtls_identity_store_.reset( 197 dtls_identity_store_ = new RefCountedDtlsIdentityStore(
173 new DtlsIdentityStore(signaling_thread_, worker_thread_)); 198 signaling_thread_, worker_thread_);
174 dtls_identity_store_->Initialize(); 199 dtls_identity_store_->Initialize();
175 200
176 return true; 201 return true;
177 } 202 }
178 203
179 rtc::scoped_refptr<AudioSourceInterface> 204 rtc::scoped_refptr<AudioSourceInterface>
180 PeerConnectionFactory::CreateAudioSource( 205 PeerConnectionFactory::CreateAudioSource(
181 const MediaConstraintsInterface* constraints) { 206 const MediaConstraintsInterface* constraints) {
182 DCHECK(signaling_thread_->IsCurrent()); 207 DCHECK(signaling_thread_->IsCurrent());
183 rtc::scoped_refptr<LocalAudioSource> source( 208 rtc::scoped_refptr<LocalAudioSource> source(
(...skipping 14 matching lines...) Expand all
198 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) { 223 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) {
199 DCHECK(signaling_thread_->IsCurrent()); 224 DCHECK(signaling_thread_->IsCurrent());
200 return channel_manager_->StartAecDump(file); 225 return channel_manager_->StartAecDump(file);
201 } 226 }
202 227
203 rtc::scoped_refptr<PeerConnectionInterface> 228 rtc::scoped_refptr<PeerConnectionInterface>
204 PeerConnectionFactory::CreatePeerConnection( 229 PeerConnectionFactory::CreatePeerConnection(
205 const PeerConnectionInterface::RTCConfiguration& configuration, 230 const PeerConnectionInterface::RTCConfiguration& configuration,
206 const MediaConstraintsInterface* constraints, 231 const MediaConstraintsInterface* constraints,
207 PortAllocatorFactoryInterface* allocator_factory, 232 PortAllocatorFactoryInterface* allocator_factory,
208 DTLSIdentityServiceInterface* dtls_identity_service, 233 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
209 PeerConnectionObserver* observer) { 234 PeerConnectionObserver* observer) {
210 DCHECK(signaling_thread_->IsCurrent()); 235 DCHECK(signaling_thread_->IsCurrent());
211 DCHECK(allocator_factory || default_allocator_factory_); 236 DCHECK(allocator_factory || default_allocator_factory_);
212 237
213 if (!dtls_identity_service) { 238 if (!dtls_identity_store.get()) {
214 dtls_identity_service = new DtlsIdentityService(dtls_identity_store_.get()); 239 // Because |pc|->Initialize takes ownership of the store we need a new
240 // wrapper object that can be deleted without deleting the underlying
241 // |dtls_identity_store_|, protecting it from being deleted multiple times.
242 dtls_identity_store.reset(
243 new DtlsIdentityStoreWrapper(dtls_identity_store_));
215 } 244 }
216 245
217 PortAllocatorFactoryInterface* chosen_allocator_factory = 246 PortAllocatorFactoryInterface* chosen_allocator_factory =
218 allocator_factory ? allocator_factory : default_allocator_factory_.get(); 247 allocator_factory ? allocator_factory : default_allocator_factory_.get();
219 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); 248 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask);
220 249
221 rtc::scoped_refptr<PeerConnection> pc( 250 rtc::scoped_refptr<PeerConnection> pc(
222 new rtc::RefCountedObject<PeerConnection>(this)); 251 new rtc::RefCountedObject<PeerConnection>(this));
223 if (!pc->Initialize( 252 if (!pc->Initialize(
224 configuration, 253 configuration,
225 constraints, 254 constraints,
226 chosen_allocator_factory, 255 chosen_allocator_factory,
227 dtls_identity_service, 256 dtls_identity_store.Pass(),
228 observer)) { 257 observer)) {
229 return NULL; 258 return NULL;
230 } 259 }
231 return PeerConnectionProxy::Create(signaling_thread(), pc); 260 return PeerConnectionProxy::Create(signaling_thread(), pc);
232 } 261 }
233 262
234 rtc::scoped_refptr<MediaStreamInterface> 263 rtc::scoped_refptr<MediaStreamInterface>
235 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { 264 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) {
236 DCHECK(signaling_thread_->IsCurrent()); 265 DCHECK(signaling_thread_->IsCurrent());
237 return MediaStreamProxy::Create(signaling_thread_, 266 return MediaStreamProxy::Create(signaling_thread_,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 303 }
275 304
276 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 305 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
277 ASSERT(worker_thread_ == rtc::Thread::Current()); 306 ASSERT(worker_thread_ == rtc::Thread::Current());
278 return cricket::WebRtcMediaEngineFactory::Create( 307 return cricket::WebRtcMediaEngineFactory::Create(
279 default_adm_.get(), video_encoder_factory_.get(), 308 default_adm_.get(), video_encoder_factory_.get(),
280 video_decoder_factory_.get()); 309 video_decoder_factory_.get());
281 } 310 }
282 311
283 } // namespace webrtc 312 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698