| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 pc_factory); | 50 pc_factory); |
| 51 } | 51 } |
| 52 | 52 |
| 53 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( | 53 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 54 rtc::Thread* network_thread, | 54 rtc::Thread* network_thread, |
| 55 rtc::Thread* worker_thread, | 55 rtc::Thread* worker_thread, |
| 56 rtc::Thread* signaling_thread, | 56 rtc::Thread* signaling_thread, |
| 57 AudioDeviceModule* default_adm, | 57 AudioDeviceModule* default_adm, |
| 58 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 58 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 59 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 59 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 60 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 60 return CreatePeerConnectionFactoryWithAudioMixer( |
| 61 new rtc::RefCountedObject<PeerConnectionFactory>( | 61 network_thread, worker_thread, signaling_thread, default_adm, |
| 62 network_thread, | 62 encoder_factory, decoder_factory, nullptr); |
| 63 worker_thread, | |
| 64 signaling_thread, | |
| 65 default_adm, | |
| 66 CreateBuiltinAudioDecoderFactory(), | |
| 67 encoder_factory, | |
| 68 decoder_factory)); | |
| 69 | |
| 70 // Call Initialize synchronously but make sure its executed on | |
| 71 // |signaling_thread|. | |
| 72 MethodCall0<PeerConnectionFactory, bool> call( | |
| 73 pc_factory.get(), | |
| 74 &PeerConnectionFactory::Initialize); | |
| 75 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); | |
| 76 | |
| 77 if (!result) { | |
| 78 return nullptr; | |
| 79 } | |
| 80 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); | |
| 81 } | 63 } |
| 82 | 64 |
| 83 PeerConnectionFactory::PeerConnectionFactory() | 65 PeerConnectionFactory::PeerConnectionFactory() |
| 84 : owns_ptrs_(true), | 66 : owns_ptrs_(true), |
| 85 wraps_current_thread_(false), | 67 wraps_current_thread_(false), |
| 86 network_thread_(rtc::Thread::CreateWithSocketServer().release()), | 68 network_thread_(rtc::Thread::CreateWithSocketServer().release()), |
| 87 worker_thread_(rtc::Thread::Create().release()), | 69 worker_thread_(rtc::Thread::Create().release()), |
| 88 signaling_thread_(rtc::Thread::Current()), | 70 signaling_thread_(rtc::Thread::Current()), |
| 89 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) { | 71 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) { |
| 90 if (!signaling_thread_) { | 72 if (!signaling_thread_) { |
| 91 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); | 73 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
| 92 wraps_current_thread_ = true; | 74 wraps_current_thread_ = true; |
| 93 } | 75 } |
| 94 network_thread_->Start(); | 76 network_thread_->Start(); |
| 95 worker_thread_->Start(); | 77 worker_thread_->Start(); |
| 96 } | 78 } |
| 97 | 79 |
| 80 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 81 CreatePeerConnectionFactoryWithAudioMixer( |
| 82 rtc::Thread* network_thread, |
| 83 rtc::Thread* worker_thread, |
| 84 rtc::Thread* signaling_thread, |
| 85 AudioDeviceModule* default_adm, |
| 86 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 87 cricket::WebRtcVideoDecoderFactory* decoder_factory, |
| 88 rtc::scoped_refptr<AudioMixer> audio_mixer) { |
| 89 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
| 90 new rtc::RefCountedObject<PeerConnectionFactory>( |
| 91 network_thread, worker_thread, signaling_thread, default_adm, |
| 92 CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory, |
| 93 audio_mixer)); |
| 94 |
| 95 // Call Initialize synchronously but make sure it is executed on |
| 96 // |signaling_thread|. |
| 97 MethodCall0<PeerConnectionFactory, bool> call( |
| 98 pc_factory.get(), &PeerConnectionFactory::Initialize); |
| 99 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); |
| 100 |
| 101 if (!result) { |
| 102 return nullptr; |
| 103 } |
| 104 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); |
| 105 } |
| 106 |
| 98 PeerConnectionFactory::PeerConnectionFactory( | 107 PeerConnectionFactory::PeerConnectionFactory( |
| 99 rtc::Thread* network_thread, | 108 rtc::Thread* network_thread, |
| 100 rtc::Thread* worker_thread, | 109 rtc::Thread* worker_thread, |
| 101 rtc::Thread* signaling_thread, | 110 rtc::Thread* signaling_thread, |
| 102 AudioDeviceModule* default_adm, | 111 AudioDeviceModule* default_adm, |
| 103 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& | 112 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& |
| 104 audio_decoder_factory, | 113 audio_decoder_factory, |
| 105 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | 114 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 106 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) | 115 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
| 116 rtc::scoped_refptr<AudioMixer> audio_mixer) |
| 107 : owns_ptrs_(false), | 117 : owns_ptrs_(false), |
| 108 wraps_current_thread_(false), | 118 wraps_current_thread_(false), |
| 109 network_thread_(network_thread), | 119 network_thread_(network_thread), |
| 110 worker_thread_(worker_thread), | 120 worker_thread_(worker_thread), |
| 111 signaling_thread_(signaling_thread), | 121 signaling_thread_(signaling_thread), |
| 112 default_adm_(default_adm), | 122 default_adm_(default_adm), |
| 113 audio_decoder_factory_(audio_decoder_factory), | 123 audio_decoder_factory_(audio_decoder_factory), |
| 114 video_encoder_factory_(video_encoder_factory), | 124 video_encoder_factory_(video_encoder_factory), |
| 115 video_decoder_factory_(video_decoder_factory) { | 125 video_decoder_factory_(video_decoder_factory), |
| 126 external_audio_mixer_(audio_mixer) { |
| 116 RTC_DCHECK(network_thread); | 127 RTC_DCHECK(network_thread); |
| 117 RTC_DCHECK(worker_thread); | 128 RTC_DCHECK(worker_thread); |
| 118 RTC_DCHECK(signaling_thread); | 129 RTC_DCHECK(signaling_thread); |
| 119 // TODO: Currently there is no way creating an external adm in | 130 // TODO: Currently there is no way creating an external adm in |
| 120 // libjingle source tree. So we can 't currently assert if this is NULL. | 131 // libjingle source tree. So we can 't currently assert if this is NULL. |
| 121 // ASSERT(default_adm != NULL); | 132 // ASSERT(default_adm != NULL); |
| 122 } | 133 } |
| 123 | 134 |
| 124 PeerConnectionFactory::~PeerConnectionFactory() { | 135 PeerConnectionFactory::~PeerConnectionFactory() { |
| 125 RTC_DCHECK(signaling_thread_->IsCurrent()); | 136 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return worker_thread_; | 340 return worker_thread_; |
| 330 } | 341 } |
| 331 | 342 |
| 332 rtc::Thread* PeerConnectionFactory::network_thread() { | 343 rtc::Thread* PeerConnectionFactory::network_thread() { |
| 333 return network_thread_; | 344 return network_thread_; |
| 334 } | 345 } |
| 335 | 346 |
| 336 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 347 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
| 337 ASSERT(worker_thread_ == rtc::Thread::Current()); | 348 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 338 return cricket::WebRtcMediaEngineFactory::Create( | 349 return cricket::WebRtcMediaEngineFactory::Create( |
| 339 default_adm_.get(), | 350 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(), |
| 340 audio_decoder_factory_, | 351 video_decoder_factory_.get(), external_audio_mixer_); |
| 341 video_encoder_factory_.get(), | |
| 342 video_decoder_factory_.get()); | |
| 343 } | 352 } |
| 344 | 353 |
| 345 } // namespace webrtc | 354 } // namespace webrtc |
| OLD | NEW |