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

Side by Side Diff: talk/app/webrtc/peerconnectionfactory.cc

Issue 1520963002: Removing webrtc::PortAllocatorFactoryInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Using new CreatePeerConnection method in objc wrapper. Created 5 years 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 * libjingle 2 * libjingle
3 * Copyright 2004--2011 Google Inc. 3 * Copyright 2004--2011 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 17 matching lines...) Expand all
28 #include "talk/app/webrtc/peerconnectionfactory.h" 28 #include "talk/app/webrtc/peerconnectionfactory.h"
29 29
30 #include "talk/app/webrtc/audiotrack.h" 30 #include "talk/app/webrtc/audiotrack.h"
31 #include "talk/app/webrtc/localaudiosource.h" 31 #include "talk/app/webrtc/localaudiosource.h"
32 #include "talk/app/webrtc/mediastream.h" 32 #include "talk/app/webrtc/mediastream.h"
33 #include "talk/app/webrtc/mediastreamproxy.h" 33 #include "talk/app/webrtc/mediastreamproxy.h"
34 #include "talk/app/webrtc/mediastreamtrackproxy.h" 34 #include "talk/app/webrtc/mediastreamtrackproxy.h"
35 #include "talk/app/webrtc/peerconnection.h" 35 #include "talk/app/webrtc/peerconnection.h"
36 #include "talk/app/webrtc/peerconnectionfactoryproxy.h" 36 #include "talk/app/webrtc/peerconnectionfactoryproxy.h"
37 #include "talk/app/webrtc/peerconnectionproxy.h" 37 #include "talk/app/webrtc/peerconnectionproxy.h"
38 #include "talk/app/webrtc/portallocatorfactory.h"
39 #include "talk/app/webrtc/videosource.h" 38 #include "talk/app/webrtc/videosource.h"
40 #include "talk/app/webrtc/videosourceproxy.h" 39 #include "talk/app/webrtc/videosourceproxy.h"
41 #include "talk/app/webrtc/videotrack.h" 40 #include "talk/app/webrtc/videotrack.h"
42 #include "talk/media/webrtc/webrtcmediaengine.h" 41 #include "talk/media/webrtc/webrtcmediaengine.h"
43 #include "talk/media/webrtc/webrtcvideodecoderfactory.h" 42 #include "talk/media/webrtc/webrtcvideodecoderfactory.h"
44 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" 43 #include "talk/media/webrtc/webrtcvideoencoderfactory.h"
45 #include "webrtc/base/bind.h" 44 #include "webrtc/base/bind.h"
46 #include "webrtc/modules/audio_device/include/audio_device.h" 45 #include "webrtc/modules/audio_device/include/audio_device.h"
47 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 46 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
48 #include "webrtc/p2p/client/basicportallocator.h" 47 #include "webrtc/p2p/client/basicportallocator.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ASSERT(worker_thread != NULL); 147 ASSERT(worker_thread != NULL);
149 ASSERT(signaling_thread != NULL); 148 ASSERT(signaling_thread != NULL);
150 // TODO: Currently there is no way creating an external adm in 149 // TODO: Currently there is no way creating an external adm in
151 // libjingle source tree. So we can 't currently assert if this is NULL. 150 // libjingle source tree. So we can 't currently assert if this is NULL.
152 // ASSERT(default_adm != NULL); 151 // ASSERT(default_adm != NULL);
153 } 152 }
154 153
155 PeerConnectionFactory::~PeerConnectionFactory() { 154 PeerConnectionFactory::~PeerConnectionFactory() {
156 RTC_DCHECK(signaling_thread_->IsCurrent()); 155 RTC_DCHECK(signaling_thread_->IsCurrent());
157 channel_manager_.reset(nullptr); 156 channel_manager_.reset(nullptr);
158 default_allocator_factory_ = nullptr;
159 157
160 // Make sure |worker_thread_| and |signaling_thread_| outlive 158 // Make sure |worker_thread_| and |signaling_thread_| outlive
161 // |dtls_identity_store_|, |default_socket_factory_| and 159 // |dtls_identity_store_|, |default_socket_factory_| and
162 // |default_network_manager_|. 160 // |default_network_manager_|.
163 dtls_identity_store_ = nullptr; 161 dtls_identity_store_ = nullptr;
164 default_socket_factory_ = nullptr; 162 default_socket_factory_ = nullptr;
165 default_network_manager_ = nullptr; 163 default_network_manager_ = nullptr;
166 164
167 if (owns_ptrs_) { 165 if (owns_ptrs_) {
168 if (wraps_current_thread_) 166 if (wraps_current_thread_)
169 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); 167 rtc::ThreadManager::Instance()->UnwrapCurrentThread();
170 delete worker_thread_; 168 delete worker_thread_;
171 } 169 }
172 } 170 }
173 171
174 bool PeerConnectionFactory::Initialize() { 172 bool PeerConnectionFactory::Initialize() {
175 RTC_DCHECK(signaling_thread_->IsCurrent()); 173 RTC_DCHECK(signaling_thread_->IsCurrent());
176 rtc::InitRandom(rtc::Time()); 174 rtc::InitRandom(rtc::Time());
177 175
178 default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_);
179 if (!default_allocator_factory_) {
180 return false;
181 }
182
183 default_network_manager_.reset(new rtc::BasicNetworkManager()); 176 default_network_manager_.reset(new rtc::BasicNetworkManager());
184 if (!default_network_manager_) { 177 if (!default_network_manager_) {
185 return false; 178 return false;
186 } 179 }
187 180
188 default_socket_factory_.reset( 181 default_socket_factory_.reset(
189 new rtc::BasicPacketSocketFactory(worker_thread_)); 182 new rtc::BasicPacketSocketFactory(worker_thread_));
190 if (!default_socket_factory_) { 183 if (!default_socket_factory_) {
191 return false; 184 return false;
192 } 185 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 240
248 void PeerConnectionFactory::StopRtcEventLog() { 241 void PeerConnectionFactory::StopRtcEventLog() {
249 RTC_DCHECK(signaling_thread_->IsCurrent()); 242 RTC_DCHECK(signaling_thread_->IsCurrent());
250 channel_manager_->StopRtcEventLog(); 243 channel_manager_->StopRtcEventLog();
251 } 244 }
252 245
253 rtc::scoped_refptr<PeerConnectionInterface> 246 rtc::scoped_refptr<PeerConnectionInterface>
254 PeerConnectionFactory::CreatePeerConnection( 247 PeerConnectionFactory::CreatePeerConnection(
255 const PeerConnectionInterface::RTCConfiguration& configuration, 248 const PeerConnectionInterface::RTCConfiguration& configuration,
256 const MediaConstraintsInterface* constraints, 249 const MediaConstraintsInterface* constraints,
257 PortAllocatorFactoryInterface* allocator_factory,
258 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
259 PeerConnectionObserver* observer) {
260 RTC_DCHECK(signaling_thread_->IsCurrent());
261 RTC_DCHECK(allocator_factory || default_allocator_factory_);
262
263 if (!dtls_identity_store.get()) {
264 // Because |pc|->Initialize takes ownership of the store we need a new
265 // wrapper object that can be deleted without deleting the underlying
266 // |dtls_identity_store_|, protecting it from being deleted multiple times.
267 dtls_identity_store.reset(
268 new DtlsIdentityStoreWrapper(dtls_identity_store_));
269 }
270
271 PortAllocatorFactoryInterface* chosen_allocator_factory =
272 allocator_factory ? allocator_factory : default_allocator_factory_.get();
273 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask);
274
275 rtc::scoped_refptr<PeerConnection> pc(
276 new rtc::RefCountedObject<PeerConnection>(this));
277 if (!pc->Initialize(
278 configuration,
279 constraints,
280 chosen_allocator_factory,
281 dtls_identity_store.Pass(),
282 observer)) {
283 return NULL;
284 }
285 return PeerConnectionProxy::Create(signaling_thread(), pc);
286 }
287
288 rtc::scoped_refptr<PeerConnectionInterface>
289 PeerConnectionFactory::CreatePeerConnection(
290 const PeerConnectionInterface::RTCConfiguration& configuration,
291 const MediaConstraintsInterface* constraints,
292 rtc::scoped_ptr<cricket::PortAllocator> allocator, 250 rtc::scoped_ptr<cricket::PortAllocator> allocator,
293 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 251 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
294 PeerConnectionObserver* observer) { 252 PeerConnectionObserver* observer) {
295 RTC_DCHECK(signaling_thread_->IsCurrent()); 253 RTC_DCHECK(signaling_thread_->IsCurrent());
296 254
297 if (!dtls_identity_store.get()) { 255 if (!dtls_identity_store.get()) {
298 // Because |pc|->Initialize takes ownership of the store we need a new 256 // Because |pc|->Initialize takes ownership of the store we need a new
299 // wrapper object that can be deleted without deleting the underlying 257 // wrapper object that can be deleted without deleting the underlying
300 // |dtls_identity_store_|, protecting it from being deleted multiple times. 258 // |dtls_identity_store_|, protecting it from being deleted multiple times.
301 dtls_identity_store.reset( 259 dtls_identity_store.reset(
302 new DtlsIdentityStoreWrapper(dtls_identity_store_)); 260 new DtlsIdentityStoreWrapper(dtls_identity_store_));
303 } 261 }
304 262
305 if (!allocator) { 263 if (!allocator) {
306 allocator.reset(new cricket::BasicPortAllocator( 264 allocator.reset(new cricket::BasicPortAllocator(
307 default_network_manager_.get(), default_socket_factory_.get())); 265 default_network_manager_.get(), default_socket_factory_.get()));
308 } 266 }
309 default_network_manager_->set_network_ignore_mask( 267 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
pthatcher1 2015/12/15 07:58:44 So is this is really just a way to set the network
phoglund 2015/12/15 12:41:31 Yeah. When I made the network mask change, I had t
310 options_.network_ignore_mask);
311 268
312 rtc::scoped_refptr<PeerConnection> pc( 269 rtc::scoped_refptr<PeerConnection> pc(
313 new rtc::RefCountedObject<PeerConnection>(this)); 270 new rtc::RefCountedObject<PeerConnection>(this));
314 if (!pc->Initialize(configuration, constraints, std::move(allocator), 271 if (!pc->Initialize(configuration, constraints, std::move(allocator),
315 std::move(dtls_identity_store), observer)) { 272 std::move(dtls_identity_store), observer)) {
316 return nullptr; 273 return nullptr;
317 } 274 }
318 return PeerConnectionProxy::Create(signaling_thread(), pc); 275 return PeerConnectionProxy::Create(signaling_thread(), pc);
319 } 276 }
320 277
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 320 }
364 321
365 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 322 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
366 ASSERT(worker_thread_ == rtc::Thread::Current()); 323 ASSERT(worker_thread_ == rtc::Thread::Current());
367 return cricket::WebRtcMediaEngineFactory::Create( 324 return cricket::WebRtcMediaEngineFactory::Create(
368 default_adm_.get(), video_encoder_factory_.get(), 325 default_adm_.get(), video_encoder_factory_.get(),
369 video_decoder_factory_.get()); 326 video_decoder_factory_.get());
370 } 327 }
371 328
372 } // namespace webrtc 329 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698