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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), |
| 74 nullptr, |
74 pc_factory); | 75 pc_factory); |
75 } | 76 } |
76 | 77 |
77 rtc::scoped_refptr<PeerConnectionFactoryInterface> | 78 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
78 CreatePeerConnectionFactory( | 79 CreatePeerConnectionFactory( |
79 rtc::Thread* worker_thread, | 80 rtc::Thread* worker_thread, |
80 rtc::Thread* signaling_thread, | 81 rtc::Thread* signaling_thread, |
81 AudioDeviceModule* default_adm, | 82 AudioDeviceModule* default_adm, |
82 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 83 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
83 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 84 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
84 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 85 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
85 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, | 86 new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread, |
86 signaling_thread, | 87 signaling_thread, |
87 default_adm, | 88 default_adm, |
88 encoder_factory, | 89 encoder_factory, |
89 decoder_factory)); | 90 decoder_factory)); |
90 | 91 |
91 // Call Initialize synchronously but make sure its executed on | 92 // Call Initialize synchronously but make sure its executed on |
92 // |signaling_thread|. | 93 // |signaling_thread|. |
93 MethodCall0<PeerConnectionFactory, bool> call( | 94 MethodCall0<PeerConnectionFactory, bool> call( |
94 pc_factory.get(), | 95 pc_factory.get(), |
95 &PeerConnectionFactory::Initialize); | 96 &PeerConnectionFactory::Initialize); |
96 bool result = call.Marshal(signaling_thread); | 97 bool result = call.Marshal(signaling_thread); |
97 | 98 |
98 if (!result) { | 99 if (!result) { |
99 return nullptr; | 100 return nullptr; |
100 } | 101 } |
101 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); | 102 return PeerConnectionFactoryProxy::Create(signaling_thread, nullptr, |
| 103 pc_factory); |
102 } | 104 } |
103 | 105 |
104 PeerConnectionFactory::PeerConnectionFactory() | 106 PeerConnectionFactory::PeerConnectionFactory() |
105 : owns_ptrs_(true), | 107 : owns_ptrs_(true), |
106 wraps_current_thread_(false), | 108 wraps_current_thread_(false), |
107 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), | 109 signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()), |
108 worker_thread_(new rtc::Thread) { | 110 worker_thread_(new rtc::Thread) { |
109 if (!signaling_thread_) { | 111 if (!signaling_thread_) { |
110 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); | 112 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
111 wraps_current_thread_ = true; | 113 wraps_current_thread_ = true; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 206 } |
205 | 207 |
206 rtc::scoped_refptr<VideoTrackSourceInterface> | 208 rtc::scoped_refptr<VideoTrackSourceInterface> |
207 PeerConnectionFactory::CreateVideoSource( | 209 PeerConnectionFactory::CreateVideoSource( |
208 cricket::VideoCapturer* capturer, | 210 cricket::VideoCapturer* capturer, |
209 const MediaConstraintsInterface* constraints) { | 211 const MediaConstraintsInterface* constraints) { |
210 RTC_DCHECK(signaling_thread_->IsCurrent()); | 212 RTC_DCHECK(signaling_thread_->IsCurrent()); |
211 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 213 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
212 VideoCapturerTrackSource::Create(worker_thread_, capturer, constraints, | 214 VideoCapturerTrackSource::Create(worker_thread_, capturer, constraints, |
213 false)); | 215 false)); |
214 return VideoTrackSourceProxy::Create(signaling_thread_, source); | 216 return VideoTrackSourceProxy::Create(signaling_thread_, worker_thread_, |
| 217 source); |
215 } | 218 } |
216 | 219 |
217 rtc::scoped_refptr<VideoTrackSourceInterface> | 220 rtc::scoped_refptr<VideoTrackSourceInterface> |
218 PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer) { | 221 PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer) { |
219 RTC_DCHECK(signaling_thread_->IsCurrent()); | 222 RTC_DCHECK(signaling_thread_->IsCurrent()); |
220 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 223 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
221 VideoCapturerTrackSource::Create(worker_thread_, capturer, false)); | 224 VideoCapturerTrackSource::Create(worker_thread_, capturer, false)); |
222 return VideoTrackSourceProxy::Create(signaling_thread_, source); | 225 return VideoTrackSourceProxy::Create(signaling_thread_, worker_thread_, |
| 226 source); |
223 } | 227 } |
224 | 228 |
225 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, | 229 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, |
226 int64_t max_size_bytes) { | 230 int64_t max_size_bytes) { |
227 RTC_DCHECK(signaling_thread_->IsCurrent()); | 231 RTC_DCHECK(signaling_thread_->IsCurrent()); |
228 return channel_manager_->StartAecDump(file, max_size_bytes); | 232 return channel_manager_->StartAecDump(file, max_size_bytes); |
229 } | 233 } |
230 | 234 |
231 void PeerConnectionFactory::StopAecDump() { | 235 void PeerConnectionFactory::StopAecDump() { |
232 RTC_DCHECK(signaling_thread_->IsCurrent()); | 236 RTC_DCHECK(signaling_thread_->IsCurrent()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 302 } |
299 if (configuration.suspend_below_min_bitrate) { | 303 if (configuration.suspend_below_min_bitrate) { |
300 media_config.video.suspend_below_min_bitrate = | 304 media_config.video.suspend_below_min_bitrate = |
301 *(configuration.suspend_below_min_bitrate); | 305 *(configuration.suspend_below_min_bitrate); |
302 } | 306 } |
303 | 307 |
304 if (!pc->Initialize(media_config, configuration, std::move(allocator), | 308 if (!pc->Initialize(media_config, configuration, std::move(allocator), |
305 std::move(dtls_identity_store), observer)) { | 309 std::move(dtls_identity_store), observer)) { |
306 return nullptr; | 310 return nullptr; |
307 } | 311 } |
308 return PeerConnectionProxy::Create(signaling_thread(), pc); | 312 return PeerConnectionProxy::Create(signaling_thread(), nullptr, pc); |
309 } | 313 } |
310 | 314 |
311 rtc::scoped_refptr<MediaStreamInterface> | 315 rtc::scoped_refptr<MediaStreamInterface> |
312 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 316 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
313 RTC_DCHECK(signaling_thread_->IsCurrent()); | 317 RTC_DCHECK(signaling_thread_->IsCurrent()); |
314 return MediaStreamProxy::Create(signaling_thread_, | 318 return MediaStreamProxy::Create(signaling_thread_, nullptr, |
315 MediaStream::Create(label)); | 319 MediaStream::Create(label)); |
316 } | 320 } |
317 | 321 |
318 rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack( | 322 rtc::scoped_refptr<VideoTrackInterface> PeerConnectionFactory::CreateVideoTrack( |
319 const std::string& id, | 323 const std::string& id, |
320 VideoTrackSourceInterface* source) { | 324 VideoTrackSourceInterface* source) { |
321 RTC_DCHECK(signaling_thread_->IsCurrent()); | 325 RTC_DCHECK(signaling_thread_->IsCurrent()); |
322 rtc::scoped_refptr<VideoTrackInterface> track( | 326 rtc::scoped_refptr<VideoTrackInterface> track( |
323 VideoTrack::Create(id, source)); | 327 VideoTrack::Create(id, source)); |
324 return VideoTrackProxy::Create(signaling_thread_, track); | 328 return VideoTrackProxy::Create(signaling_thread_, worker_thread_, track); |
325 } | 329 } |
326 | 330 |
327 rtc::scoped_refptr<AudioTrackInterface> | 331 rtc::scoped_refptr<AudioTrackInterface> |
328 PeerConnectionFactory::CreateAudioTrack(const std::string& id, | 332 PeerConnectionFactory::CreateAudioTrack(const std::string& id, |
329 AudioSourceInterface* source) { | 333 AudioSourceInterface* source) { |
330 RTC_DCHECK(signaling_thread_->IsCurrent()); | 334 RTC_DCHECK(signaling_thread_->IsCurrent()); |
331 rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source)); | 335 rtc::scoped_refptr<AudioTrackInterface> track(AudioTrack::Create(id, source)); |
332 return AudioTrackProxy::Create(signaling_thread_, track); | 336 return AudioTrackProxy::Create(signaling_thread_, nullptr, track); |
333 } | 337 } |
334 | 338 |
335 webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController( | 339 webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController( |
336 const cricket::MediaConfig& config) const { | 340 const cricket::MediaConfig& config) const { |
337 RTC_DCHECK(signaling_thread_->IsCurrent()); | 341 RTC_DCHECK(signaling_thread_->IsCurrent()); |
338 return MediaControllerInterface::Create(config, worker_thread_, | 342 return MediaControllerInterface::Create(config, worker_thread_, |
339 channel_manager_.get()); | 343 channel_manager_.get()); |
340 } | 344 } |
341 | 345 |
342 rtc::Thread* PeerConnectionFactory::signaling_thread() { | 346 rtc::Thread* PeerConnectionFactory::signaling_thread() { |
343 // This method can be called on a different thread when the factory is | 347 // This method can be called on a different thread when the factory is |
344 // created in CreatePeerConnectionFactory(). | 348 // created in CreatePeerConnectionFactory(). |
345 return signaling_thread_; | 349 return signaling_thread_; |
346 } | 350 } |
347 | 351 |
348 rtc::Thread* PeerConnectionFactory::worker_thread() { | 352 rtc::Thread* PeerConnectionFactory::worker_thread() { |
349 RTC_DCHECK(signaling_thread_->IsCurrent()); | 353 RTC_DCHECK(signaling_thread_->IsCurrent()); |
350 return worker_thread_; | 354 return worker_thread_; |
351 } | 355 } |
352 | 356 |
353 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 357 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
354 ASSERT(worker_thread_ == rtc::Thread::Current()); | 358 ASSERT(worker_thread_ == rtc::Thread::Current()); |
355 return cricket::WebRtcMediaEngineFactory::Create( | 359 return cricket::WebRtcMediaEngineFactory::Create( |
356 default_adm_.get(), video_encoder_factory_.get(), | 360 default_adm_.get(), video_encoder_factory_.get(), |
357 video_decoder_factory_.get()); | 361 video_decoder_factory_.get()); |
358 } | 362 } |
359 | 363 |
360 } // namespace webrtc | 364 } // namespace webrtc |
OLD | NEW |