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" |
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 192 |
192 rtc::scoped_refptr<AudioSourceInterface> | 193 rtc::scoped_refptr<AudioSourceInterface> |
193 PeerConnectionFactory::CreateAudioSource( | 194 PeerConnectionFactory::CreateAudioSource( |
194 const MediaConstraintsInterface* constraints) { | 195 const MediaConstraintsInterface* constraints) { |
195 RTC_DCHECK(signaling_thread_->IsCurrent()); | 196 RTC_DCHECK(signaling_thread_->IsCurrent()); |
196 rtc::scoped_refptr<LocalAudioSource> source( | 197 rtc::scoped_refptr<LocalAudioSource> source( |
197 LocalAudioSource::Create(options_, constraints)); | 198 LocalAudioSource::Create(options_, constraints)); |
198 return source; | 199 return source; |
199 } | 200 } |
200 | 201 |
| 202 rtc::scoped_refptr<AudioSourceInterface> |
| 203 PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) { |
| 204 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 205 rtc::scoped_refptr<LocalAudioSource> source( |
| 206 LocalAudioSource::Create(options_, &options)); |
| 207 return source; |
| 208 } |
| 209 |
201 rtc::scoped_refptr<VideoSourceInterface> | 210 rtc::scoped_refptr<VideoSourceInterface> |
202 PeerConnectionFactory::CreateVideoSource( | 211 PeerConnectionFactory::CreateVideoSource( |
203 cricket::VideoCapturer* capturer, | 212 cricket::VideoCapturer* capturer, |
204 const MediaConstraintsInterface* constraints) { | 213 const MediaConstraintsInterface* constraints) { |
205 RTC_DCHECK(signaling_thread_->IsCurrent()); | 214 RTC_DCHECK(signaling_thread_->IsCurrent()); |
206 rtc::scoped_refptr<VideoSource> source(VideoSource::Create( | 215 rtc::scoped_refptr<VideoSource> source(VideoSource::Create( |
207 channel_manager_.get(), capturer, constraints, false)); | 216 channel_manager_.get(), capturer, constraints, false)); |
208 return VideoSourceProxy::Create(signaling_thread_, source); | 217 return VideoSourceProxy::Create(signaling_thread_, source); |
209 } | 218 } |
210 | 219 |
| 220 rtc::scoped_refptr<VideoSourceInterface> |
| 221 PeerConnectionFactory::CreateVideoSource(cricket::VideoCapturer* capturer) { |
| 222 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 223 rtc::scoped_refptr<VideoSource> source( |
| 224 VideoSource::Create(channel_manager_.get(), capturer, false)); |
| 225 return VideoSourceProxy::Create(signaling_thread_, source); |
| 226 } |
| 227 |
211 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, | 228 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file, |
212 int64_t max_size_bytes) { | 229 int64_t max_size_bytes) { |
213 RTC_DCHECK(signaling_thread_->IsCurrent()); | 230 RTC_DCHECK(signaling_thread_->IsCurrent()); |
214 return channel_manager_->StartAecDump(file, max_size_bytes); | 231 return channel_manager_->StartAecDump(file, max_size_bytes); |
215 } | 232 } |
216 | 233 |
217 void PeerConnectionFactory::StopAecDump() { | 234 void PeerConnectionFactory::StopAecDump() { |
218 RTC_DCHECK(signaling_thread_->IsCurrent()); | 235 RTC_DCHECK(signaling_thread_->IsCurrent()); |
219 channel_manager_->StopAecDump(); | 236 channel_manager_->StopAecDump(); |
220 } | 237 } |
221 | 238 |
222 bool PeerConnectionFactory::StartRtcEventLog(rtc::PlatformFile file) { | 239 bool PeerConnectionFactory::StartRtcEventLog(rtc::PlatformFile file) { |
223 RTC_DCHECK(signaling_thread_->IsCurrent()); | 240 RTC_DCHECK(signaling_thread_->IsCurrent()); |
224 return channel_manager_->StartRtcEventLog(file); | 241 return channel_manager_->StartRtcEventLog(file); |
225 } | 242 } |
226 | 243 |
227 void PeerConnectionFactory::StopRtcEventLog() { | 244 void PeerConnectionFactory::StopRtcEventLog() { |
228 RTC_DCHECK(signaling_thread_->IsCurrent()); | 245 RTC_DCHECK(signaling_thread_->IsCurrent()); |
229 channel_manager_->StopRtcEventLog(); | 246 channel_manager_->StopRtcEventLog(); |
230 } | 247 } |
231 | 248 |
232 rtc::scoped_refptr<PeerConnectionInterface> | 249 rtc::scoped_refptr<PeerConnectionInterface> |
233 PeerConnectionFactory::CreatePeerConnection( | 250 PeerConnectionFactory::CreatePeerConnection( |
| 251 const PeerConnectionInterface::RTCConfiguration& configuration_in, |
| 252 const MediaConstraintsInterface* constraints, |
| 253 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 254 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 255 PeerConnectionObserver* observer) { |
| 256 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 257 |
| 258 // We merge constraints and configuration into a single configuration. |
| 259 PeerConnectionInterface::RTCConfiguration configuration = configuration_in; |
| 260 CopyConstraintsIntoRtcConfiguration(constraints, &configuration); |
| 261 |
| 262 return CreatePeerConnection(configuration, std::move(allocator), |
| 263 std::move(dtls_identity_store), observer); |
| 264 } |
| 265 |
| 266 rtc::scoped_refptr<PeerConnectionInterface> |
| 267 PeerConnectionFactory::CreatePeerConnection( |
234 const PeerConnectionInterface::RTCConfiguration& configuration, | 268 const PeerConnectionInterface::RTCConfiguration& configuration, |
235 const MediaConstraintsInterface* constraints, | |
236 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 269 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
237 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 270 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
238 PeerConnectionObserver* observer) { | 271 PeerConnectionObserver* observer) { |
239 RTC_DCHECK(signaling_thread_->IsCurrent()); | 272 RTC_DCHECK(signaling_thread_->IsCurrent()); |
240 | 273 |
241 if (!dtls_identity_store.get()) { | 274 if (!dtls_identity_store.get()) { |
242 // Because |pc|->Initialize takes ownership of the store we need a new | 275 // Because |pc|->Initialize takes ownership of the store we need a new |
243 // wrapper object that can be deleted without deleting the underlying | 276 // wrapper object that can be deleted without deleting the underlying |
244 // |dtls_identity_store_|, protecting it from being deleted multiple times. | 277 // |dtls_identity_store_|, protecting it from being deleted multiple times. |
245 dtls_identity_store.reset( | 278 dtls_identity_store.reset( |
246 new DtlsIdentityStoreWrapper(dtls_identity_store_)); | 279 new DtlsIdentityStoreWrapper(dtls_identity_store_)); |
247 } | 280 } |
248 | 281 |
249 if (!allocator) { | 282 if (!allocator) { |
250 allocator.reset(new cricket::BasicPortAllocator( | 283 allocator.reset(new cricket::BasicPortAllocator( |
251 default_network_manager_.get(), default_socket_factory_.get())); | 284 default_network_manager_.get(), default_socket_factory_.get())); |
252 } | 285 } |
253 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask); | 286 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask); |
254 | 287 |
255 rtc::scoped_refptr<PeerConnection> pc( | 288 rtc::scoped_refptr<PeerConnection> pc( |
256 new rtc::RefCountedObject<PeerConnection>(this)); | 289 new rtc::RefCountedObject<PeerConnection>(this)); |
257 if (!pc->Initialize(configuration, constraints, std::move(allocator), | 290 // We rely on default values when constraints aren't found. |
| 291 cricket::MediaConfig media_config; |
| 292 |
| 293 media_config.disable_prerenderer_smoothing = |
| 294 configuration.disable_prerenderer_smoothing; |
| 295 if (configuration.enable_dscp) { |
| 296 media_config.enable_dscp = *(configuration.enable_dscp); |
| 297 } |
| 298 if (configuration.cpu_overuse_detection) { |
| 299 media_config.enable_cpu_overuse_detection = |
| 300 *(configuration.cpu_overuse_detection); |
| 301 } |
| 302 |
| 303 if (!pc->Initialize(media_config, configuration, std::move(allocator), |
258 std::move(dtls_identity_store), observer)) { | 304 std::move(dtls_identity_store), observer)) { |
259 return nullptr; | 305 return nullptr; |
260 } | 306 } |
261 return PeerConnectionProxy::Create(signaling_thread(), pc); | 307 return PeerConnectionProxy::Create(signaling_thread(), pc); |
262 } | 308 } |
263 | 309 |
264 rtc::scoped_refptr<MediaStreamInterface> | 310 rtc::scoped_refptr<MediaStreamInterface> |
265 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 311 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
266 RTC_DCHECK(signaling_thread_->IsCurrent()); | 312 RTC_DCHECK(signaling_thread_->IsCurrent()); |
267 return MediaStreamProxy::Create(signaling_thread_, | 313 return MediaStreamProxy::Create(signaling_thread_, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 351 } |
306 | 352 |
307 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { | 353 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { |
308 ASSERT(worker_thread_ == rtc::Thread::Current()); | 354 ASSERT(worker_thread_ == rtc::Thread::Current()); |
309 return cricket::WebRtcMediaEngineFactory::Create( | 355 return cricket::WebRtcMediaEngineFactory::Create( |
310 default_adm_.get(), video_encoder_factory_.get(), | 356 default_adm_.get(), video_encoder_factory_.get(), |
311 video_decoder_factory_.get()); | 357 video_decoder_factory_.get()); |
312 } | 358 } |
313 | 359 |
314 } // namespace webrtc | 360 } // namespace webrtc |
OLD | NEW |