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 |
11 #include "webrtc/api/peerconnectionfactory.h" | 11 #include "webrtc/api/peerconnectionfactory.h" |
12 | 12 |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "webrtc/api/audiotrack.h" | 15 #include "webrtc/api/audiotrack.h" |
16 #include "webrtc/api/localaudiosource.h" | 16 #include "webrtc/api/localaudiosource.h" |
17 #include "webrtc/api/mediaconstraintsinterface.h" | |
perkj_webrtc
2016/03/04 08:44:36
nit: I would expect this to be included in the hea
hta-webrtc
2016/03/04 09:54:47
Nope, it isn't. Just a forward declaration.
| |
17 #include "webrtc/api/mediastream.h" | 18 #include "webrtc/api/mediastream.h" |
18 #include "webrtc/api/mediastreamproxy.h" | 19 #include "webrtc/api/mediastreamproxy.h" |
19 #include "webrtc/api/mediastreamtrackproxy.h" | 20 #include "webrtc/api/mediastreamtrackproxy.h" |
20 #include "webrtc/api/peerconnection.h" | 21 #include "webrtc/api/peerconnection.h" |
21 #include "webrtc/api/peerconnectionfactoryproxy.h" | 22 #include "webrtc/api/peerconnectionfactoryproxy.h" |
22 #include "webrtc/api/peerconnectionproxy.h" | 23 #include "webrtc/api/peerconnectionproxy.h" |
23 #include "webrtc/api/videosource.h" | 24 #include "webrtc/api/videosource.h" |
24 #include "webrtc/api/videosourceproxy.h" | 25 #include "webrtc/api/videosourceproxy.h" |
25 #include "webrtc/api/videotrack.h" | 26 #include "webrtc/api/videotrack.h" |
26 #include "webrtc/base/bind.h" | 27 #include "webrtc/base/bind.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 193 |
193 rtc::scoped_refptr<AudioSourceInterface> | 194 rtc::scoped_refptr<AudioSourceInterface> |
194 PeerConnectionFactory::CreateAudioSource( | 195 PeerConnectionFactory::CreateAudioSource( |
195 const MediaConstraintsInterface* constraints) { | 196 const MediaConstraintsInterface* constraints) { |
196 RTC_DCHECK(signaling_thread_->IsCurrent()); | 197 RTC_DCHECK(signaling_thread_->IsCurrent()); |
197 rtc::scoped_refptr<LocalAudioSource> source( | 198 rtc::scoped_refptr<LocalAudioSource> source( |
198 LocalAudioSource::Create(options_, constraints)); | 199 LocalAudioSource::Create(options_, constraints)); |
199 return source; | 200 return source; |
200 } | 201 } |
201 | 202 |
203 rtc::scoped_refptr<AudioSourceInterface> | |
204 PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) { | |
205 RTC_DCHECK(signaling_thread_->IsCurrent()); | |
206 rtc::scoped_refptr<LocalAudioSource> source( | |
207 LocalAudioSource::Create(options_, &options)); | |
208 return source; | |
209 } | |
210 | |
202 rtc::scoped_refptr<VideoSourceInterface> | 211 rtc::scoped_refptr<VideoSourceInterface> |
203 PeerConnectionFactory::CreateVideoSource( | 212 PeerConnectionFactory::CreateVideoSource( |
204 cricket::VideoCapturer* capturer, | 213 cricket::VideoCapturer* capturer, |
205 const MediaConstraintsInterface* constraints) { | 214 const MediaConstraintsInterface* constraints) { |
206 RTC_DCHECK(signaling_thread_->IsCurrent()); | 215 RTC_DCHECK(signaling_thread_->IsCurrent()); |
207 rtc::scoped_refptr<VideoSource> source(VideoSource::Create( | 216 rtc::scoped_refptr<VideoSource> source(VideoSource::Create( |
208 worker_thread_, capturer, constraints, false)); | 217 worker_thread_, capturer, constraints, false)); |
209 return VideoSourceProxy::Create(signaling_thread_, source); | 218 return VideoSourceProxy::Create(signaling_thread_, source); |
210 } | 219 } |
211 | 220 |
221 rtc::scoped_refptr<VideoSourceInterface> | |
222 PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer) { | |
223 RTC_DCHECK(signaling_thread_->IsCurrent()); | |
224 rtc::scoped_refptr<VideoSource> source( | |
225 VideoSource::Create(worker_thread_, capturer, false)); | |
226 return VideoSourceProxy::Create(signaling_thread_, source); | |
227 } | |
228 | |
212 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, | 229 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, |
213 int64_t max_size_bytes) { | 230 int64_t max_size_bytes) { |
214 RTC_DCHECK(signaling_thread_->IsCurrent()); | 231 RTC_DCHECK(signaling_thread_->IsCurrent()); |
215 return channel_manager_->StartAecDump(file, max_size_bytes); | 232 return channel_manager_->StartAecDump(file, max_size_bytes); |
216 } | 233 } |
217 | 234 |
218 void PeerConnectionFactory::StopAecDump() { | 235 void PeerConnectionFactory::StopAecDump() { |
219 RTC_DCHECK(signaling_thread_->IsCurrent()); | 236 RTC_DCHECK(signaling_thread_->IsCurrent()); |
220 channel_manager_->StopAecDump(); | 237 channel_manager_->StopAecDump(); |
221 } | 238 } |
222 | 239 |
223 bool PeerConnectionFactory::StartRtcEventLog(rtc::PlatformFile file) { | 240 bool PeerConnectionFactory::StartRtcEventLog(rtc::PlatformFile file) { |
224 RTC_DCHECK(signaling_thread_->IsCurrent()); | 241 RTC_DCHECK(signaling_thread_->IsCurrent()); |
225 return channel_manager_->StartRtcEventLog(file); | 242 return channel_manager_->StartRtcEventLog(file); |
226 } | 243 } |
227 | 244 |
228 void PeerConnectionFactory::StopRtcEventLog() { | 245 void PeerConnectionFactory::StopRtcEventLog() { |
229 RTC_DCHECK(signaling_thread_->IsCurrent()); | 246 RTC_DCHECK(signaling_thread_->IsCurrent()); |
230 channel_manager_->StopRtcEventLog(); | 247 channel_manager_->StopRtcEventLog(); |
231 } | 248 } |
232 | 249 |
233 rtc::scoped_refptr<PeerConnectionInterface> | 250 rtc::scoped_refptr<PeerConnectionInterface> |
234 PeerConnectionFactory::CreatePeerConnection( | 251 PeerConnectionFactory::CreatePeerConnection( |
252 const PeerConnectionInterface::RTCConfiguration& configuration_in, | |
253 const MediaConstraintsInterface* constraints, | |
254 rtc::scoped_ptr<cricket::PortAllocator> allocator, | |
255 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | |
256 PeerConnectionObserver* observer) { | |
257 RTC_DCHECK(signaling_thread_->IsCurrent()); | |
258 | |
259 // We merge constraints and configuration into a single configuration. | |
260 PeerConnectionInterface::RTCConfiguration configuration = configuration_in; | |
261 CopyConstraintsIntoRtcConfiguration(constraints, &configuration); | |
262 | |
263 return CreatePeerConnection(configuration, std::move(allocator), | |
264 std::move(dtls_identity_store), observer); | |
265 } | |
266 | |
267 rtc::scoped_refptr<PeerConnectionInterface> | |
268 PeerConnectionFactory::CreatePeerConnection( | |
235 const PeerConnectionInterface::RTCConfiguration& configuration, | 269 const PeerConnectionInterface::RTCConfiguration& configuration, |
236 const MediaConstraintsInterface* constraints, | |
237 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 270 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
238 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 271 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
239 PeerConnectionObserver* observer) { | 272 PeerConnectionObserver* observer) { |
240 RTC_DCHECK(signaling_thread_->IsCurrent()); | 273 RTC_DCHECK(signaling_thread_->IsCurrent()); |
241 | 274 |
242 if (!dtls_identity_store.get()) { | 275 if (!dtls_identity_store.get()) { |
243 // Because |pc|->Initialize takes ownership of the store we need a new | 276 // Because |pc|->Initialize takes ownership of the store we need a new |
244 // wrapper object that can be deleted without deleting the underlying | 277 // wrapper object that can be deleted without deleting the underlying |
245 // |dtls_identity_store_|, protecting it from being deleted multiple times. | 278 // |dtls_identity_store_|, protecting it from being deleted multiple times. |
246 dtls_identity_store.reset( | 279 dtls_identity_store.reset( |
247 new DtlsIdentityStoreWrapper(dtls_identity_store_)); | 280 new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
248 } | 281 } |
249 | 282 |
250 if (!allocator) { | 283 if (!allocator) { |
251 allocator.reset(new cricket::BasicPortAllocator( | 284 allocator.reset(new cricket::BasicPortAllocator( |
252 default_network_manager_.get(), default_socket_factory_.get())); | 285 default_network_manager_.get(), default_socket_factory_.get())); |
253 } | 286 } |
254 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask); | 287 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask); |
255 | 288 |
256 rtc::scoped_refptr<PeerConnection> pc( | 289 rtc::scoped_refptr<PeerConnection> pc( |
257 new rtc::RefCountedObject<PeerConnection>(this)); | 290 new rtc::RefCountedObject<PeerConnection>(this)); |
258 if (!pc->Initialize(configuration, constraints, std::move(allocator), | 291 // We rely on default values when constraints aren't found. |
292 cricket::MediaConfig media_config; | |
293 | |
294 media_config.video.disable_prerenderer_smoothing = | |
295 configuration.disable_prerenderer_smoothing; | |
296 if (configuration.enable_dscp) { | |
297 media_config.enable_dscp = *(configuration.enable_dscp); | |
298 } | |
299 if (configuration.cpu_overuse_detection) { | |
300 media_config.video.enable_cpu_overuse_detection = | |
301 *(configuration.cpu_overuse_detection); | |
302 } | |
303 if (configuration.suspend_below_min_bitrate) { | |
304 media_config.video.suspend_below_min_bitrate = | |
305 *(configuration.suspend_below_min_bitrate); | |
306 } | |
307 | |
308 if (!pc->Initialize(media_config, configuration, std::move(allocator), | |
259 std::move(dtls_identity_store), observer)) { | 309 std::move(dtls_identity_store), observer)) { |
260 return nullptr; | 310 return nullptr; |
261 } | 311 } |
262 return PeerConnectionProxy::Create(signaling_thread(), pc); | 312 return PeerConnectionProxy::Create(signaling_thread(), pc); |
263 } | 313 } |
264 | 314 |
265 rtc::scoped_refptr<MediaStreamInterface> | 315 rtc::scoped_refptr<MediaStreamInterface> |
266 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 316 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
267 RTC_DCHECK(signaling_thread_->IsCurrent()); | 317 RTC_DCHECK(signaling_thread_->IsCurrent()); |
268 return MediaStreamProxy::Create(signaling_thread_, | 318 return MediaStreamProxy::Create(signaling_thread_, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 } | 356 } |
307 | 357 |
308 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 358 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
309 ASSERT(worker_thread_ == rtc::Thread::Current()); | 359 ASSERT(worker_thread_ == rtc::Thread::Current()); |
310 return cricket::WebRtcMediaEngineFactory::Create( | 360 return cricket::WebRtcMediaEngineFactory::Create( |
311 default_adm_.get(), video_encoder_factory_.get(), | 361 default_adm_.get(), video_encoder_factory_.get(), |
312 video_decoder_factory_.get()); | 362 video_decoder_factory_.get()); |
313 } | 363 } |
314 | 364 |
315 } // namespace webrtc | 365 } // namespace webrtc |
OLD | NEW |