| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" | 29 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" |
| 30 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 30 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 31 #include "webrtc/modules/audio_device/include/audio_device.h" | 31 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 32 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 32 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 33 #include "webrtc/p2p/client/basicportallocator.h" | 33 #include "webrtc/p2p/client/basicportallocator.h" |
| 34 | 34 |
| 35 namespace webrtc { | 35 namespace webrtc { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // Passes down the calls to |cert_generator_|. See usage in | 39 // Passes down the calls to |store_|. See usage in CreatePeerConnection. |
| 40 // |CreatePeerConnection|. | 40 class DtlsIdentityStoreWrapper : public DtlsIdentityStoreInterface { |
| 41 class RTCCertificateGeneratorWrapper | |
| 42 : public rtc::RTCCertificateGeneratorInterface { | |
| 43 public: | 41 public: |
| 44 RTCCertificateGeneratorWrapper( | 42 DtlsIdentityStoreWrapper( |
| 45 const rtc::scoped_refptr<RefCountedRTCCertificateGenerator>& cert_gen) | 43 const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store) |
| 46 : cert_generator_(cert_gen) { | 44 : store_(store) { |
| 47 RTC_DCHECK(cert_generator_); | 45 RTC_DCHECK(store_); |
| 48 } | 46 } |
| 49 | 47 |
| 50 void GenerateCertificateAsync( | 48 void RequestIdentity( |
| 51 const rtc::KeyParams& key_params, | 49 const rtc::KeyParams& key_params, |
| 52 const rtc::Optional<uint64_t>& expires_ms, | 50 const rtc::Optional<uint64_t>& expires_ms, |
| 53 const rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback>& callback) | 51 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& |
| 54 override { | 52 observer) override { |
| 55 cert_generator_->GenerateCertificateAsync(key_params, expires_ms, callback); | 53 store_->RequestIdentity(key_params, expires_ms, observer); |
| 56 } | 54 } |
| 57 | 55 |
| 58 private: | 56 private: |
| 59 rtc::scoped_refptr<RefCountedRTCCertificateGenerator> cert_generator_; | 57 rtc::scoped_refptr<RefCountedDtlsIdentityStore> store_; |
| 60 }; | 58 }; |
| 61 | 59 |
| 62 } // anonymous namespace | 60 } // anonymous namespace |
| 63 | 61 |
| 64 rtc::scoped_refptr<PeerConnectionFactoryInterface> | 62 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 65 CreatePeerConnectionFactory() { | 63 CreatePeerConnectionFactory() { |
| 66 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 64 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
| 67 new rtc::RefCountedObject<PeerConnectionFactory>()); | 65 new rtc::RefCountedObject<PeerConnectionFactory>()); |
| 68 | 66 |
| 69 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); | 67 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // TODO: Currently there is no way creating an external adm in | 134 // TODO: Currently there is no way creating an external adm in |
| 137 // libjingle source tree. So we can 't currently assert if this is NULL. | 135 // libjingle source tree. So we can 't currently assert if this is NULL. |
| 138 // ASSERT(default_adm != NULL); | 136 // ASSERT(default_adm != NULL); |
| 139 } | 137 } |
| 140 | 138 |
| 141 PeerConnectionFactory::~PeerConnectionFactory() { | 139 PeerConnectionFactory::~PeerConnectionFactory() { |
| 142 RTC_DCHECK(signaling_thread_->IsCurrent()); | 140 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 143 channel_manager_.reset(nullptr); | 141 channel_manager_.reset(nullptr); |
| 144 | 142 |
| 145 // Make sure |worker_thread_| and |signaling_thread_| outlive | 143 // Make sure |worker_thread_| and |signaling_thread_| outlive |
| 146 // |cert_generator_|, |default_socket_factory_| and | 144 // |dtls_identity_store_|, |default_socket_factory_| and |
| 147 // |default_network_manager_|. | 145 // |default_network_manager_|. |
| 148 cert_generator_ = nullptr; | 146 dtls_identity_store_ = nullptr; |
| 149 default_socket_factory_ = nullptr; | 147 default_socket_factory_ = nullptr; |
| 150 default_network_manager_ = nullptr; | 148 default_network_manager_ = nullptr; |
| 151 | 149 |
| 152 if (owns_ptrs_) { | 150 if (owns_ptrs_) { |
| 153 if (wraps_current_thread_) | 151 if (wraps_current_thread_) |
| 154 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); | 152 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); |
| 155 delete worker_thread_; | 153 delete worker_thread_; |
| 156 delete network_thread_; | 154 delete network_thread_; |
| 157 } | 155 } |
| 158 } | 156 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 179 &PeerConnectionFactory::CreateMediaEngine_w, this)); | 177 &PeerConnectionFactory::CreateMediaEngine_w, this)); |
| 180 | 178 |
| 181 channel_manager_.reset(new cricket::ChannelManager( | 179 channel_manager_.reset(new cricket::ChannelManager( |
| 182 media_engine, worker_thread_, network_thread_)); | 180 media_engine, worker_thread_, network_thread_)); |
| 183 | 181 |
| 184 channel_manager_->SetVideoRtxEnabled(true); | 182 channel_manager_->SetVideoRtxEnabled(true); |
| 185 if (!channel_manager_->Init()) { | 183 if (!channel_manager_->Init()) { |
| 186 return false; | 184 return false; |
| 187 } | 185 } |
| 188 | 186 |
| 189 cert_generator_ = | 187 dtls_identity_store_ = |
| 190 new RefCountedRTCCertificateGenerator(signaling_thread_, network_thread_); | 188 new RefCountedDtlsIdentityStore(signaling_thread_, network_thread_); |
| 191 | 189 |
| 192 return true; | 190 return true; |
| 193 } | 191 } |
| 194 | 192 |
| 195 rtc::scoped_refptr<AudioSourceInterface> | 193 rtc::scoped_refptr<AudioSourceInterface> |
| 196 PeerConnectionFactory::CreateAudioSource( | 194 PeerConnectionFactory::CreateAudioSource( |
| 197 const MediaConstraintsInterface* constraints) { | 195 const MediaConstraintsInterface* constraints) { |
| 198 RTC_DCHECK(signaling_thread_->IsCurrent()); | 196 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 199 rtc::scoped_refptr<LocalAudioSource> source( | 197 rtc::scoped_refptr<LocalAudioSource> source( |
| 200 LocalAudioSource::Create(options_, constraints)); | 198 LocalAudioSource::Create(options_, constraints)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 void PeerConnectionFactory::StopRtcEventLog() { | 248 void PeerConnectionFactory::StopRtcEventLog() { |
| 251 RTC_DCHECK(signaling_thread_->IsCurrent()); | 249 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 252 channel_manager_->StopRtcEventLog(); | 250 channel_manager_->StopRtcEventLog(); |
| 253 } | 251 } |
| 254 | 252 |
| 255 rtc::scoped_refptr<PeerConnectionInterface> | 253 rtc::scoped_refptr<PeerConnectionInterface> |
| 256 PeerConnectionFactory::CreatePeerConnection( | 254 PeerConnectionFactory::CreatePeerConnection( |
| 257 const PeerConnectionInterface::RTCConfiguration& configuration_in, | 255 const PeerConnectionInterface::RTCConfiguration& configuration_in, |
| 258 const MediaConstraintsInterface* constraints, | 256 const MediaConstraintsInterface* constraints, |
| 259 std::unique_ptr<cricket::PortAllocator> allocator, | 257 std::unique_ptr<cricket::PortAllocator> allocator, |
| 260 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 258 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 261 PeerConnectionObserver* observer) { | 259 PeerConnectionObserver* observer) { |
| 262 RTC_DCHECK(signaling_thread_->IsCurrent()); | 260 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 263 | 261 |
| 264 // We merge constraints and configuration into a single configuration. | 262 // We merge constraints and configuration into a single configuration. |
| 265 PeerConnectionInterface::RTCConfiguration configuration = configuration_in; | 263 PeerConnectionInterface::RTCConfiguration configuration = configuration_in; |
| 266 CopyConstraintsIntoRtcConfiguration(constraints, &configuration); | 264 CopyConstraintsIntoRtcConfiguration(constraints, &configuration); |
| 267 | 265 |
| 268 return CreatePeerConnection(configuration, std::move(allocator), | 266 return CreatePeerConnection(configuration, std::move(allocator), |
| 269 std::move(cert_generator), observer); | 267 std::move(dtls_identity_store), observer); |
| 270 } | 268 } |
| 271 | 269 |
| 272 rtc::scoped_refptr<PeerConnectionInterface> | 270 rtc::scoped_refptr<PeerConnectionInterface> |
| 273 PeerConnectionFactory::CreatePeerConnection( | 271 PeerConnectionFactory::CreatePeerConnection( |
| 274 const PeerConnectionInterface::RTCConfiguration& configuration, | 272 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 275 std::unique_ptr<cricket::PortAllocator> allocator, | 273 std::unique_ptr<cricket::PortAllocator> allocator, |
| 276 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 274 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 277 PeerConnectionObserver* observer) { | 275 PeerConnectionObserver* observer) { |
| 278 RTC_DCHECK(signaling_thread_->IsCurrent()); | 276 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 279 | 277 |
| 280 if (!cert_generator.get()) { | 278 if (!dtls_identity_store.get()) { |
| 281 // Because |pc|->Initialize takes ownership of the generator we need a new | 279 // Because |pc|->Initialize takes ownership of the store we need a new |
| 282 // wrapper object that can be deleted without deleting the underlying | 280 // wrapper object that can be deleted without deleting the underlying |
| 283 // |cert_generator_|, protecting it from being deleted multiple times. | 281 // |dtls_identity_store_|, protecting it from being deleted multiple times. |
| 284 cert_generator.reset( | 282 dtls_identity_store.reset( |
| 285 new RTCCertificateGeneratorWrapper(cert_generator_)); | 283 new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
| 286 } | 284 } |
| 287 | 285 |
| 288 if (!allocator) { | 286 if (!allocator) { |
| 289 allocator.reset(new cricket::BasicPortAllocator( | 287 allocator.reset(new cricket::BasicPortAllocator( |
| 290 default_network_manager_.get(), default_socket_factory_.get())); | 288 default_network_manager_.get(), default_socket_factory_.get())); |
| 291 } | 289 } |
| 292 network_thread_->Invoke<void>( | 290 network_thread_->Invoke<void>( |
| 293 rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask, allocator.get(), | 291 rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask, allocator.get(), |
| 294 options_.network_ignore_mask)); | 292 options_.network_ignore_mask)); |
| 295 | 293 |
| 296 rtc::scoped_refptr<PeerConnection> pc( | 294 rtc::scoped_refptr<PeerConnection> pc( |
| 297 new rtc::RefCountedObject<PeerConnection>(this)); | 295 new rtc::RefCountedObject<PeerConnection>(this)); |
| 298 | 296 |
| 299 if (!pc->Initialize(configuration, std::move(allocator), | 297 if (!pc->Initialize(configuration, std::move(allocator), |
| 300 std::move(cert_generator), observer)) { | 298 std::move(dtls_identity_store), observer)) { |
| 301 return nullptr; | 299 return nullptr; |
| 302 } | 300 } |
| 303 return PeerConnectionProxy::Create(signaling_thread(), pc); | 301 return PeerConnectionProxy::Create(signaling_thread(), pc); |
| 304 } | 302 } |
| 305 | 303 |
| 306 rtc::scoped_refptr<MediaStreamInterface> | 304 rtc::scoped_refptr<MediaStreamInterface> |
| 307 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 305 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
| 308 RTC_DCHECK(signaling_thread_->IsCurrent()); | 306 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 309 return MediaStreamProxy::Create(signaling_thread_, | 307 return MediaStreamProxy::Create(signaling_thread_, |
| 310 MediaStream::Create(label)); | 308 MediaStream::Create(label)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 348 } |
| 351 | 349 |
| 352 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 350 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
| 353 ASSERT(worker_thread_ == rtc::Thread::Current()); | 351 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 354 return cricket::WebRtcMediaEngineFactory::Create( | 352 return cricket::WebRtcMediaEngineFactory::Create( |
| 355 default_adm_.get(), video_encoder_factory_.get(), | 353 default_adm_.get(), video_encoder_factory_.get(), |
| 356 video_decoder_factory_.get()); | 354 video_decoder_factory_.get()); |
| 357 } | 355 } |
| 358 | 356 |
| 359 } // namespace webrtc | 357 } // namespace webrtc |
| OLD | NEW |