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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CreatePeerConnectionFactory() { | 63 CreatePeerConnectionFactory() { |
64 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 64 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
65 new rtc::RefCountedObject<PeerConnectionFactory>()); | 65 new rtc::RefCountedObject<PeerConnectionFactory>()); |
66 | 66 |
67 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); | 67 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); |
68 // The signaling thread is the current thread so we can | 68 // The signaling thread is the current thread so we can |
69 // safely call Initialize directly. | 69 // safely call Initialize directly. |
70 if (!pc_factory->Initialize()) { | 70 if (!pc_factory->Initialize()) { |
71 return nullptr; | 71 return nullptr; |
72 } | 72 } |
73 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), | 73 return PeerConnectionFactorySignallingProxy::Create( |
74 pc_factory); | 74 pc_factory->signaling_thread(), pc_factory); |
75 } | 75 } |
76 | 76 |
77 rtc::scoped_refptr<PeerConnectionFactoryInterface> | 77 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
78 CreatePeerConnectionFactory( | 78 CreatePeerConnectionFactory( |
79 rtc::Thread* worker_thread, | 79 rtc::Thread* worker_thread, |
80 rtc::Thread* signaling_thread, | 80 rtc::Thread* signaling_thread, |
81 AudioDeviceModule* default_adm, | 81 AudioDeviceModule* default_adm, |
82 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 82 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
83 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 83 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
84 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 84 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
85 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, | 85 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, |
86 signaling_thread, | 86 signaling_thread, |
87 default_adm, | 87 default_adm, |
88 encoder_factory, | 88 encoder_factory, |
89 decoder_factory)); | 89 decoder_factory)); |
90 | 90 |
91 // Call Initialize synchronously but make sure its executed on | 91 // Call Initialize synchronously but make sure its executed on |
92 // |signaling_thread|. | 92 // |signaling_thread|. |
93 MethodCall0<PeerConnectionFactory, bool> call( | 93 MethodCall0<PeerConnectionFactory, bool> call( |
94 pc_factory.get(), | 94 pc_factory.get(), |
95 &PeerConnectionFactory::Initialize); | 95 &PeerConnectionFactory::Initialize); |
96 bool result = call.Marshal(signaling_thread); | 96 bool result = call.Marshal(signaling_thread); |
97 | 97 |
98 if (!result) { | 98 if (!result) { |
99 return nullptr; | 99 return nullptr; |
100 } | 100 } |
101 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); | 101 return PeerConnectionFactorySignallingProxy::Create(signaling_thread, |
| 102 pc_factory); |
102 } | 103 } |
103 | 104 |
104 PeerConnectionFactory::PeerConnectionFactory() | 105 PeerConnectionFactory::PeerConnectionFactory() |
105 : owns_ptrs_(true), | 106 : owns_ptrs_(true), |
106 wraps_current_thread_(false), | 107 wraps_current_thread_(false), |
107 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), | 108 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), |
108 worker_thread_(new rtc::Thread) { | 109 worker_thread_(new rtc::Thread) { |
109 if (!signaling_thread_) { | 110 if (!signaling_thread_) { |
110 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); | 111 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
111 wraps_current_thread_ = true; | 112 wraps_current_thread_ = true; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 301 } |
301 if (configuration.suspend_below_min_bitrate) { | 302 if (configuration.suspend_below_min_bitrate) { |
302 media_config.video.suspend_below_min_bitrate = | 303 media_config.video.suspend_below_min_bitrate = |
303 *(configuration.suspend_below_min_bitrate); | 304 *(configuration.suspend_below_min_bitrate); |
304 } | 305 } |
305 | 306 |
306 if (!pc->Initialize(media_config, configuration, std::move(allocator), | 307 if (!pc->Initialize(media_config, configuration, std::move(allocator), |
307 std::move(dtls_identity_store), observer)) { | 308 std::move(dtls_identity_store), observer)) { |
308 return nullptr; | 309 return nullptr; |
309 } | 310 } |
310 return PeerConnectionProxy::Create(signaling_thread(), pc); | 311 return PeerConnectionSignallingProxy::Create(signaling_thread(), pc); |
311 } | 312 } |
312 | 313 |
313 rtc::scoped_refptr<MediaStreamInterface> | 314 rtc::scoped_refptr<MediaStreamInterface> |
314 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 315 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
315 RTC_DCHECK(signaling_thread_->IsCurrent()); | 316 RTC_DCHECK(signaling_thread_->IsCurrent()); |
316 return MediaStreamProxy::Create(signaling_thread_, | 317 return MediaStreamSignallingProxy::Create(signaling_thread_, |
317 MediaStream::Create(label)); | 318 MediaStream::Create(label)); |
318 } | 319 } |
319 | 320 |
320 rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack( | 321 rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack( |
321 const std::string& id, | 322 const std::string& id, |
322 VideoTrackSourceInterface* source) { | 323 VideoTrackSourceInterface* source) { |
323 RTC_DCHECK(signaling_thread_->IsCurrent()); | 324 RTC_DCHECK(signaling_thread_->IsCurrent()); |
324 rtc::scoped_refptr<VideoTrackInterface> track( | 325 rtc::scoped_refptr<VideoTrackInterface> track( |
325 VideoTrack::Create(id, source)); | 326 VideoTrack::Create(id, source)); |
326 return VideoTrackProxy::Create(signaling_thread_, worker_thread_, track); | 327 return VideoTrackProxy::Create(signaling_thread_, worker_thread_, track); |
327 } | 328 } |
328 | 329 |
329 rtc::scoped_refptr<AudioTrackInterface> | 330 rtc::scoped_refptr<AudioTrackInterface> |
330 PeerConnectionFactory::CreateAudioTrack(const std::string& id, | 331 PeerConnectionFactory::CreateAudioTrack(const std::string& id, |
331 AudioSourceInterface* source) { | 332 AudioSourceInterface* source) { |
332 RTC_DCHECK(signaling_thread_->IsCurrent()); | 333 RTC_DCHECK(signaling_thread_->IsCurrent()); |
333 rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source)); | 334 rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source)); |
334 return AudioTrackProxy::Create(signaling_thread_, track); | 335 return AudioTrackSignallingProxy::Create(signaling_thread_, track); |
335 } | 336 } |
336 | 337 |
337 webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController( | 338 webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController( |
338 const cricket::MediaConfig& config) const { | 339 const cricket::MediaConfig& config) const { |
339 RTC_DCHECK(signaling_thread_->IsCurrent()); | 340 RTC_DCHECK(signaling_thread_->IsCurrent()); |
340 return MediaControllerInterface::Create(config, worker_thread_, | 341 return MediaControllerInterface::Create(config, worker_thread_, |
341 channel_manager_.get()); | 342 channel_manager_.get()); |
342 } | 343 } |
343 | 344 |
344 rtc::Thread* PeerConnectionFactory::signaling_thread() { | 345 rtc::Thread* PeerConnectionFactory::signaling_thread() { |
345 // This method can be called on a different thread when the factory is | 346 // This method can be called on a different thread when the factory is |
346 // created in CreatePeerConnectionFactory(). | 347 // created in CreatePeerConnectionFactory(). |
347 return signaling_thread_; | 348 return signaling_thread_; |
348 } | 349 } |
349 | 350 |
350 rtc::Thread* PeerConnectionFactory::worker_thread() { | 351 rtc::Thread* PeerConnectionFactory::worker_thread() { |
351 RTC_DCHECK(signaling_thread_->IsCurrent()); | 352 RTC_DCHECK(signaling_thread_->IsCurrent()); |
352 return worker_thread_; | 353 return worker_thread_; |
353 } | 354 } |
354 | 355 |
355 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 356 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
356 ASSERT(worker_thread_ == rtc::Thread::Current()); | 357 ASSERT(worker_thread_ == rtc::Thread::Current()); |
357 return cricket::WebRtcMediaEngineFactory::Create( | 358 return cricket::WebRtcMediaEngineFactory::Create( |
358 default_adm_.get(), video_encoder_factory_.get(), | 359 default_adm_.get(), video_encoder_factory_.get(), |
359 video_decoder_factory_.get()); | 360 video_decoder_factory_.get()); |
360 } | 361 } |
361 | 362 |
362 } // namespace webrtc | 363 } // namespace webrtc |
OLD | NEW |