Index: talk/app/webrtc/peerconnectionfactory.cc |
diff --git a/talk/app/webrtc/peerconnectionfactory.cc b/talk/app/webrtc/peerconnectionfactory.cc |
index 3524af7932a4f92f60da84e552f742d1a2aaa7ac..cdfa80517f37cfe5539bd5c8e9488915bfa33801 100644 |
--- a/talk/app/webrtc/peerconnectionfactory.cc |
+++ b/talk/app/webrtc/peerconnectionfactory.cc |
@@ -207,16 +207,36 @@ PeerConnectionFactory::CreatePeerConnection( |
PortAllocatorFactoryInterface* allocator_factory, |
DTLSIdentityServiceInterface* dtls_identity_service, |
PeerConnectionObserver* observer) { |
- DCHECK(signaling_thread_->IsCurrent()); |
- DCHECK(allocator_factory || default_allocator_factory_); |
+ PortAllocatorFactoryInterface* chosen_allocator_factory = |
+ CreatePeerConnectionCommon(allocator_factory); |
if (!dtls_identity_service) { |
dtls_identity_service = new DtlsIdentityService(dtls_identity_store_.get()); |
} |
+ rtc::scoped_refptr<PeerConnection> pc( |
+ new rtc::RefCountedObject<PeerConnection>(this)); |
+ // Note: |pc| takes ownership of |dtls_identity_service|. |
+ if (!pc->Initialize( |
+ configuration, |
+ constraints, |
+ chosen_allocator_factory, |
+ dtls_identity_service, |
+ observer)) { |
+ return nullptr; |
+ } |
+ return PeerConnectionProxy::Create(signaling_thread(), pc); |
+} |
+ |
+rtc::scoped_refptr<PeerConnectionInterface> |
+PeerConnectionFactory::CreatePeerConnection( |
+ const PeerConnectionInterface::RTCConfiguration& configuration, |
+ const MediaConstraintsInterface* constraints, |
+ PortAllocatorFactoryInterface* allocator_factory, |
+ rtc::scoped_refptr<DtlsCertificate> certificate, |
+ PeerConnectionObserver* observer) { |
PortAllocatorFactoryInterface* chosen_allocator_factory = |
- allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
- chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
+ CreatePeerConnectionCommon(allocator_factory); |
rtc::scoped_refptr<PeerConnection> pc( |
new rtc::RefCountedObject<PeerConnection>(this)); |
@@ -224,13 +244,26 @@ PeerConnectionFactory::CreatePeerConnection( |
configuration, |
constraints, |
chosen_allocator_factory, |
- dtls_identity_service, |
+ certificate, |
observer)) { |
- return NULL; |
+ return nullptr; |
} |
return PeerConnectionProxy::Create(signaling_thread(), pc); |
} |
+PortAllocatorFactoryInterface* |
+PeerConnectionFactory::CreatePeerConnectionCommon( |
+ PortAllocatorFactoryInterface* allocator_factory) { |
+ DCHECK(signaling_thread_->IsCurrent()); |
+ DCHECK(allocator_factory || default_allocator_factory_); |
+ |
+ PortAllocatorFactoryInterface* chosen_allocator_factory = |
+ allocator_factory ? allocator_factory : default_allocator_factory_.get(); |
+ chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask); |
+ |
+ return chosen_allocator_factory; |
+} |
+ |
rtc::scoped_refptr<MediaStreamInterface> |
PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
DCHECK(signaling_thread_->IsCurrent()); |