Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: webrtc/api/peerconnectionfactory.cc

Issue 1717583002: Non-constraint interfaces for all constrainable interfaces (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase result (no intentional change) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
nisse-webrtc 2016/02/25 08:26:51 I think this is a logical place to handle run-time
hta-webrtc 2016/02/25 14:32:42 I think I see one reason why this review has been
259 PeerConnectionInterface::RTCConfiguration configuration = configuration_in;
260
261 if (!dtls_identity_store.get()) {
262 // Because |pc|->Initialize takes ownership of the store we need a new
263 // wrapper object that can be deleted without deleting the underlying
264 // |dtls_identity_store_|, protecting it from being deleted multiple times.
265 dtls_identity_store.reset(
266 new DtlsIdentityStoreWrapper(dtls_identity_store_));
267 }
268
269 if (!allocator) {
270 allocator.reset(new cricket::BasicPortAllocator(
271 default_network_manager_.get(), default_socket_factory_.get()));
272 }
273 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
274
275 rtc::scoped_refptr<PeerConnection> pc(
276 new rtc::RefCountedObject<PeerConnection>(this));
277
278 CopyConstraintsIntoRtcConfiguration(constraints, &configuration);
279
280 if (!pc->Initialize(configuration, std::move(allocator),
281 std::move(dtls_identity_store), observer)) {
282 return nullptr;
283 }
284 return PeerConnectionProxy::Create(signaling_thread(), pc);
285 }
286
287 rtc::scoped_refptr<PeerConnectionInterface>
288 PeerConnectionFactory::CreatePeerConnection(
234 const PeerConnectionInterface::RTCConfiguration& configuration, 289 const PeerConnectionInterface::RTCConfiguration& configuration,
235 const MediaConstraintsInterface* constraints,
236 rtc::scoped_ptr<cricket::PortAllocator> allocator, 290 rtc::scoped_ptr<cricket::PortAllocator> allocator,
237 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 291 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
238 PeerConnectionObserver* observer) { 292 PeerConnectionObserver* observer) {
239 RTC_DCHECK(signaling_thread_->IsCurrent()); 293 RTC_DCHECK(signaling_thread_->IsCurrent());
240 294
241 if (!dtls_identity_store.get()) { 295 if (!dtls_identity_store.get()) {
242 // Because |pc|->Initialize takes ownership of the store we need a new 296 // Because |pc|->Initialize takes ownership of the store we need a new
243 // wrapper object that can be deleted without deleting the underlying 297 // wrapper object that can be deleted without deleting the underlying
244 // |dtls_identity_store_|, protecting it from being deleted multiple times. 298 // |dtls_identity_store_|, protecting it from being deleted multiple times.
245 dtls_identity_store.reset( 299 dtls_identity_store.reset(
246 new DtlsIdentityStoreWrapper(dtls_identity_store_)); 300 new DtlsIdentityStoreWrapper(dtls_identity_store_));
247 } 301 }
248 302
249 if (!allocator) { 303 if (!allocator) {
250 allocator.reset(new cricket::BasicPortAllocator( 304 allocator.reset(new cricket::BasicPortAllocator(
251 default_network_manager_.get(), default_socket_factory_.get())); 305 default_network_manager_.get(), default_socket_factory_.get()));
252 } 306 }
253 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask); 307 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
254 308
255 rtc::scoped_refptr<PeerConnection> pc( 309 rtc::scoped_refptr<PeerConnection> pc(
256 new rtc::RefCountedObject<PeerConnection>(this)); 310 new rtc::RefCountedObject<PeerConnection>(this));
257 if (!pc->Initialize(configuration, constraints, std::move(allocator), 311 if (!pc->Initialize(configuration, std::move(allocator),
258 std::move(dtls_identity_store), observer)) { 312 std::move(dtls_identity_store), observer)) {
259 return nullptr; 313 return nullptr;
260 } 314 }
261 return PeerConnectionProxy::Create(signaling_thread(), pc); 315 return PeerConnectionProxy::Create(signaling_thread(), pc);
262 } 316 }
263 317
264 rtc::scoped_refptr<MediaStreamInterface> 318 rtc::scoped_refptr<MediaStreamInterface>
265 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { 319 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) {
266 RTC_DCHECK(signaling_thread_->IsCurrent()); 320 RTC_DCHECK(signaling_thread_->IsCurrent());
267 return MediaStreamProxy::Create(signaling_thread_, 321 return MediaStreamProxy::Create(signaling_thread_,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 359 }
306 360
307 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 361 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
308 ASSERT(worker_thread_ == rtc::Thread::Current()); 362 ASSERT(worker_thread_ == rtc::Thread::Current());
309 return cricket::WebRtcMediaEngineFactory::Create( 363 return cricket::WebRtcMediaEngineFactory::Create(
310 default_adm_.get(), video_encoder_factory_.get(), 364 default_adm_.get(), video_encoder_factory_.get(),
311 video_decoder_factory_.get()); 365 video_decoder_factory_.get());
312 } 366 }
313 367
314 } // namespace webrtc 368 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698