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