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/p2p/client/basicportallocator.h" | 29 #include "webrtc/p2p/client/basicportallocator.h" |
30 #include "webrtc/pc/audiotrack.h" | 30 #include "webrtc/pc/audiotrack.h" |
31 #include "webrtc/pc/localaudiosource.h" | 31 #include "webrtc/pc/localaudiosource.h" |
32 #include "webrtc/pc/mediastream.h" | 32 #include "webrtc/pc/mediastream.h" |
33 #include "webrtc/pc/peerconnection.h" | 33 #include "webrtc/pc/peerconnection.h" |
34 #include "webrtc/pc/videocapturertracksource.h" | 34 #include "webrtc/pc/videocapturertracksource.h" |
35 #include "webrtc/pc/videotrack.h" | 35 #include "webrtc/pc/videotrack.h" |
36 | 36 |
37 namespace webrtc { | 37 namespace webrtc { |
38 | 38 |
39 rtc::scoped_refptr<PeerConnectionFactoryInterface> | 39 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
40 CreatePeerConnectionFactory() { | 40 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 41 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) { |
41 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 42 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
42 new rtc::RefCountedObject<PeerConnectionFactory>()); | 43 new rtc::RefCountedObject<PeerConnectionFactory>(audio_encoder_factory, |
| 44 audio_decoder_factory)); |
43 | 45 |
44 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); | 46 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); |
45 // The signaling thread is the current thread so we can | 47 // The signaling thread is the current thread so we can |
46 // safely call Initialize directly. | 48 // safely call Initialize directly. |
47 if (!pc_factory->Initialize()) { | 49 if (!pc_factory->Initialize()) { |
48 return nullptr; | 50 return nullptr; |
49 } | 51 } |
50 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), | 52 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), |
51 pc_factory); | 53 pc_factory); |
52 } | 54 } |
53 | 55 |
| 56 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 57 CreatePeerConnectionFactory() { |
| 58 return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(), |
| 59 CreateBuiltinAudioDecoderFactory()); |
| 60 } |
| 61 |
54 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( | 62 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
55 rtc::Thread* network_thread, | 63 rtc::Thread* network_thread, |
56 rtc::Thread* worker_thread, | 64 rtc::Thread* worker_thread, |
| 65 rtc::Thread* signaling_thread, |
| 66 AudioDeviceModule* default_adm, |
| 67 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 68 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 69 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 70 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { |
| 71 return CreatePeerConnectionFactoryWithAudioMixer( |
| 72 network_thread, worker_thread, signaling_thread, default_adm, |
| 73 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
| 74 video_decoder_factory, nullptr); |
| 75 } |
| 76 |
| 77 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 78 rtc::Thread* network_thread, |
| 79 rtc::Thread* worker_thread, |
57 rtc::Thread* signaling_thread, | 80 rtc::Thread* signaling_thread, |
58 AudioDeviceModule* default_adm, | 81 AudioDeviceModule* default_adm, |
59 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 82 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
60 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | 83 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
61 return CreatePeerConnectionFactoryWithAudioMixer( | 84 return CreatePeerConnectionFactoryWithAudioMixer( |
62 network_thread, worker_thread, signaling_thread, default_adm, | 85 network_thread, worker_thread, signaling_thread, default_adm, |
63 encoder_factory, decoder_factory, nullptr); | 86 encoder_factory, decoder_factory, nullptr); |
64 } | 87 } |
65 | 88 |
66 PeerConnectionFactory::PeerConnectionFactory() | |
67 : owns_ptrs_(true), | |
68 wraps_current_thread_(false), | |
69 network_thread_(rtc::Thread::CreateWithSocketServer().release()), | |
70 worker_thread_(rtc::Thread::Create().release()), | |
71 signaling_thread_(rtc::Thread::Current()), | |
72 audio_decoder_factory_(CreateBuiltinAudioDecoderFactory()) { | |
73 if (!signaling_thread_) { | |
74 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); | |
75 wraps_current_thread_ = true; | |
76 } | |
77 network_thread_->Start(); | |
78 worker_thread_->Start(); | |
79 } | |
80 | |
81 rtc::scoped_refptr<PeerConnectionFactoryInterface> | 89 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
82 CreatePeerConnectionFactoryWithAudioMixer( | 90 CreatePeerConnectionFactoryWithAudioMixer( |
83 rtc::Thread* network_thread, | 91 rtc::Thread* network_thread, |
84 rtc::Thread* worker_thread, | 92 rtc::Thread* worker_thread, |
85 rtc::Thread* signaling_thread, | 93 rtc::Thread* signaling_thread, |
86 AudioDeviceModule* default_adm, | 94 AudioDeviceModule* default_adm, |
87 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 95 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
88 cricket::WebRtcVideoDecoderFactory* decoder_factory, | 96 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 97 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 98 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
89 rtc::scoped_refptr<AudioMixer> audio_mixer) { | 99 rtc::scoped_refptr<AudioMixer> audio_mixer) { |
90 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 100 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
91 new rtc::RefCountedObject<PeerConnectionFactory>( | 101 new rtc::RefCountedObject<PeerConnectionFactory>( |
92 network_thread, worker_thread, signaling_thread, default_adm, | 102 network_thread, worker_thread, signaling_thread, default_adm, |
93 CreateBuiltinAudioDecoderFactory(), encoder_factory, decoder_factory, | 103 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
94 audio_mixer)); | 104 video_decoder_factory, audio_mixer)); |
95 | 105 |
96 // Call Initialize synchronously but make sure it is executed on | 106 // Call Initialize synchronously but make sure it is executed on |
97 // |signaling_thread|. | 107 // |signaling_thread|. |
98 MethodCall0<PeerConnectionFactory, bool> call( | 108 MethodCall0<PeerConnectionFactory, bool> call( |
99 pc_factory.get(), &PeerConnectionFactory::Initialize); | 109 pc_factory.get(), &PeerConnectionFactory::Initialize); |
100 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); | 110 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); |
101 | 111 |
102 if (!result) { | 112 if (!result) { |
103 return nullptr; | 113 return nullptr; |
104 } | 114 } |
105 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); | 115 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); |
106 } | 116 } |
107 | 117 |
| 118 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 119 CreatePeerConnectionFactoryWithAudioMixer( |
| 120 rtc::Thread* network_thread, |
| 121 rtc::Thread* worker_thread, |
| 122 rtc::Thread* signaling_thread, |
| 123 AudioDeviceModule* default_adm, |
| 124 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 125 cricket::WebRtcVideoDecoderFactory* decoder_factory, |
| 126 rtc::scoped_refptr<AudioMixer> audio_mixer) { |
| 127 return CreatePeerConnectionFactoryWithAudioMixer( |
| 128 network_thread, worker_thread, signaling_thread, default_adm, |
| 129 CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(), |
| 130 encoder_factory, decoder_factory, audio_mixer); |
| 131 } |
| 132 |
| 133 PeerConnectionFactory::PeerConnectionFactory( |
| 134 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
| 135 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) |
| 136 : owns_ptrs_(true), |
| 137 wraps_current_thread_(false), |
| 138 network_thread_(rtc::Thread::CreateWithSocketServer().release()), |
| 139 worker_thread_(rtc::Thread::Create().release()), |
| 140 signaling_thread_(rtc::Thread::Current()), |
| 141 // TODO(ossu): Take care of audio_encoder_factory (see bug 5806). |
| 142 audio_decoder_factory_(audio_decoder_factory) { |
| 143 if (!signaling_thread_) { |
| 144 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
| 145 wraps_current_thread_ = true; |
| 146 } |
| 147 network_thread_->Start(); |
| 148 worker_thread_->Start(); |
| 149 } |
| 150 |
108 PeerConnectionFactory::PeerConnectionFactory( | 151 PeerConnectionFactory::PeerConnectionFactory( |
109 rtc::Thread* network_thread, | 152 rtc::Thread* network_thread, |
110 rtc::Thread* worker_thread, | 153 rtc::Thread* worker_thread, |
111 rtc::Thread* signaling_thread, | 154 rtc::Thread* signaling_thread, |
112 AudioDeviceModule* default_adm, | 155 AudioDeviceModule* default_adm, |
113 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& | 156 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
114 audio_decoder_factory, | 157 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, |
115 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | 158 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
116 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, | 159 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
117 rtc::scoped_refptr<AudioMixer> audio_mixer) | 160 rtc::scoped_refptr<AudioMixer> audio_mixer) |
118 : owns_ptrs_(false), | 161 : owns_ptrs_(false), |
119 wraps_current_thread_(false), | 162 wraps_current_thread_(false), |
120 network_thread_(network_thread), | 163 network_thread_(network_thread), |
121 worker_thread_(worker_thread), | 164 worker_thread_(worker_thread), |
122 signaling_thread_(signaling_thread), | 165 signaling_thread_(signaling_thread), |
123 default_adm_(default_adm), | 166 default_adm_(default_adm), |
| 167 // TODO(ossu): Take care of audio_encoder_factory (see bug 5806). |
124 audio_decoder_factory_(audio_decoder_factory), | 168 audio_decoder_factory_(audio_decoder_factory), |
125 video_encoder_factory_(video_encoder_factory), | 169 video_encoder_factory_(video_encoder_factory), |
126 video_decoder_factory_(video_decoder_factory), | 170 video_decoder_factory_(video_decoder_factory), |
127 external_audio_mixer_(audio_mixer) { | 171 external_audio_mixer_(audio_mixer) { |
128 RTC_DCHECK(network_thread); | 172 RTC_DCHECK(network_thread); |
129 RTC_DCHECK(worker_thread); | 173 RTC_DCHECK(worker_thread); |
130 RTC_DCHECK(signaling_thread); | 174 RTC_DCHECK(signaling_thread); |
131 // TODO: Currently there is no way creating an external adm in | 175 // TODO: Currently there is no way creating an external adm in |
132 // libjingle source tree. So we can 't currently assert if this is NULL. | 176 // libjingle source tree. So we can 't currently assert if this is NULL. |
133 // RTC_DCHECK(default_adm != NULL); | 177 // RTC_DCHECK(default_adm != NULL); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 390 } |
347 | 391 |
348 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 392 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
349 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 393 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); |
350 return cricket::WebRtcMediaEngineFactory::Create( | 394 return cricket::WebRtcMediaEngineFactory::Create( |
351 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(), | 395 default_adm_.get(), audio_decoder_factory_, video_encoder_factory_.get(), |
352 video_decoder_factory_.get(), external_audio_mixer_); | 396 video_decoder_factory_.get(), external_audio_mixer_); |
353 } | 397 } |
354 | 398 |
355 } // namespace webrtc | 399 } // namespace webrtc |
OLD | NEW |