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