OLD | NEW |
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 rtc::scoped_refptr<PeerConnectionInterface> | 224 rtc::scoped_refptr<PeerConnectionInterface> |
225 PeerConnectionFactory::CreatePeerConnection( | 225 PeerConnectionFactory::CreatePeerConnection( |
226 const PeerConnectionInterface::RTCConfiguration& configuration, | 226 const PeerConnectionInterface::RTCConfiguration& configuration, |
227 const MediaConstraintsInterface* constraints, | 227 const MediaConstraintsInterface* constraints, |
228 PortAllocatorFactoryInterface* allocator_factory, | 228 PortAllocatorFactoryInterface* allocator_factory, |
229 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 229 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
230 PeerConnectionObserver* observer) { | 230 PeerConnectionObserver* observer) { |
231 DCHECK(signaling_thread_->IsCurrent()); | 231 DCHECK(signaling_thread_->IsCurrent()); |
232 DCHECK(allocator_factory || default_allocator_factory_); | 232 DCHECK(allocator_factory || default_allocator_factory_); |
233 | 233 |
| 234 PortAllocatorFactoryInterface* chosen_allocator_factory = |
| 235 CreatePeerConnectionChooseAllocatorFactory(allocator_factory); |
| 236 |
234 if (!dtls_identity_store.get()) { | 237 if (!dtls_identity_store.get()) { |
235 // Because |pc|->Initialize takes ownership of the store we need a new | 238 // Because |pc|->Initialize takes ownership of the store in Pass()ing we |
236 // wrapper object that can be deleted without deleting the underlying | 239 // need a new wrapper object that can be passed and eventually deleted |
237 // |dtls_identity_store_|, protecting it from being deleted multiple times. | 240 // without passing and deleting our |dtls_identity_store_|. |
238 dtls_identity_store.reset( | 241 dtls_identity_store.reset( |
239 new DtlsIdentityStoreWrapper(dtls_identity_store_)); | 242 new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
240 } | 243 } |
241 | 244 |
| 245 rtc::scoped_refptr<PeerConnection> pc( |
| 246 new rtc::RefCountedObject<PeerConnection>(this)); |
| 247 if (!pc->Initialize( |
| 248 configuration, |
| 249 constraints, |
| 250 chosen_allocator_factory, |
| 251 dtls_identity_store.Pass(), |
| 252 observer)) { |
| 253 return nullptr; |
| 254 } |
| 255 return PeerConnectionProxy::Create(signaling_thread(), pc); |
| 256 } |
| 257 |
| 258 rtc::scoped_refptr<PeerConnectionInterface> |
| 259 PeerConnectionFactory::CreatePeerConnection( |
| 260 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 261 const MediaConstraintsInterface* constraints, |
| 262 PortAllocatorFactoryInterface* allocator_factory, |
| 263 const rtc::scoped_refptr<DtlsCertificate>& certificate, |
| 264 PeerConnectionObserver* observer) { |
| 265 DCHECK(signaling_thread_->IsCurrent()); |
| 266 DCHECK(allocator_factory || default_allocator_factory_); |
| 267 |
242 PortAllocatorFactoryInterface* chosen_allocator_factory = | 268 PortAllocatorFactoryInterface* chosen_allocator_factory = |
243 allocator_factory ? allocator_factory : default_allocator_factory_.get(); | 269 CreatePeerConnectionChooseAllocatorFactory(allocator_factory); |
244 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); | |
245 | 270 |
246 rtc::scoped_refptr<PeerConnection> pc( | 271 rtc::scoped_refptr<PeerConnection> pc( |
247 new rtc::RefCountedObject<PeerConnection>(this)); | 272 new rtc::RefCountedObject<PeerConnection>(this)); |
248 if (!pc->Initialize( | 273 if (!pc->Initialize( |
249 configuration, | 274 configuration, |
250 constraints, | 275 constraints, |
251 chosen_allocator_factory, | 276 chosen_allocator_factory, |
252 dtls_identity_store.Pass(), | 277 certificate, |
253 observer)) { | 278 observer)) { |
254 return NULL; | 279 return nullptr; |
255 } | 280 } |
256 return PeerConnectionProxy::Create(signaling_thread(), pc); | 281 return PeerConnectionProxy::Create(signaling_thread(), pc); |
257 } | 282 } |
258 | 283 |
| 284 PortAllocatorFactoryInterface* |
| 285 PeerConnectionFactory::CreatePeerConnectionChooseAllocatorFactory( |
| 286 PortAllocatorFactoryInterface* allocator_factory) { |
| 287 DCHECK(signaling_thread_->IsCurrent()); |
| 288 DCHECK(allocator_factory || default_allocator_factory_); |
| 289 |
| 290 PortAllocatorFactoryInterface* chosen_allocator_factory = |
| 291 allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
| 292 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
| 293 |
| 294 return chosen_allocator_factory; |
| 295 } |
| 296 |
259 rtc::scoped_refptr<MediaStreamInterface> | 297 rtc::scoped_refptr<MediaStreamInterface> |
260 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 298 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
261 DCHECK(signaling_thread_->IsCurrent()); | 299 DCHECK(signaling_thread_->IsCurrent()); |
262 return MediaStreamProxy::Create(signaling_thread_, | 300 return MediaStreamProxy::Create(signaling_thread_, |
263 MediaStream::Create(label)); | 301 MediaStream::Create(label)); |
264 } | 302 } |
265 | 303 |
266 rtc::scoped_refptr<VideoTrackInterface> | 304 rtc::scoped_refptr<VideoTrackInterface> |
267 PeerConnectionFactory::CreateVideoTrack( | 305 PeerConnectionFactory::CreateVideoTrack( |
268 const std::string& id, | 306 const std::string& id, |
(...skipping 30 matching lines...) Expand all Loading... |
299 } | 337 } |
300 | 338 |
301 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 339 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
302 ASSERT(worker_thread_ == rtc::Thread::Current()); | 340 ASSERT(worker_thread_ == rtc::Thread::Current()); |
303 return cricket::WebRtcMediaEngineFactory::Create( | 341 return cricket::WebRtcMediaEngineFactory::Create( |
304 default_adm_.get(), video_encoder_factory_.get(), | 342 default_adm_.get(), video_encoder_factory_.get(), |
305 video_decoder_factory_.get()); | 343 video_decoder_factory_.get()); |
306 } | 344 } |
307 | 345 |
308 } // namespace webrtc | 346 } // namespace webrtc |
OLD | NEW |