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

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: Fixing patch conflicts 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 19 matching lines...) Expand all
30 #include <utility> 30 #include <utility>
31 31
32 #include "talk/app/webrtc/audiotrack.h" 32 #include "talk/app/webrtc/audiotrack.h"
33 #include "talk/app/webrtc/localaudiosource.h" 33 #include "talk/app/webrtc/localaudiosource.h"
34 #include "talk/app/webrtc/mediastream.h" 34 #include "talk/app/webrtc/mediastream.h"
35 #include "talk/app/webrtc/mediastreamproxy.h" 35 #include "talk/app/webrtc/mediastreamproxy.h"
36 #include "talk/app/webrtc/mediastreamtrackproxy.h" 36 #include "talk/app/webrtc/mediastreamtrackproxy.h"
37 #include "talk/app/webrtc/peerconnection.h" 37 #include "talk/app/webrtc/peerconnection.h"
38 #include "talk/app/webrtc/peerconnectionfactoryproxy.h" 38 #include "talk/app/webrtc/peerconnectionfactoryproxy.h"
39 #include "talk/app/webrtc/peerconnectionproxy.h" 39 #include "talk/app/webrtc/peerconnectionproxy.h"
40 #include "talk/app/webrtc/portallocatorfactory.h"
41 #include "talk/app/webrtc/videosource.h" 40 #include "talk/app/webrtc/videosource.h"
42 #include "talk/app/webrtc/videosourceproxy.h" 41 #include "talk/app/webrtc/videosourceproxy.h"
43 #include "talk/app/webrtc/videotrack.h" 42 #include "talk/app/webrtc/videotrack.h"
44 #include "talk/media/webrtc/webrtcmediaengine.h" 43 #include "talk/media/webrtc/webrtcmediaengine.h"
45 #include "talk/media/webrtc/webrtcvideodecoderfactory.h" 44 #include "talk/media/webrtc/webrtcvideodecoderfactory.h"
46 #include "talk/media/webrtc/webrtcvideoencoderfactory.h" 45 #include "talk/media/webrtc/webrtcvideoencoderfactory.h"
47 #include "webrtc/base/bind.h" 46 #include "webrtc/base/bind.h"
48 #include "webrtc/modules/audio_device/include/audio_device.h" 47 #include "webrtc/modules/audio_device/include/audio_device.h"
49 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 48 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
50 #include "webrtc/p2p/client/basicportallocator.h" 49 #include "webrtc/p2p/client/basicportallocator.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ASSERT(worker_thread != NULL); 149 ASSERT(worker_thread != NULL);
151 ASSERT(signaling_thread != NULL); 150 ASSERT(signaling_thread != NULL);
152 // TODO: Currently there is no way creating an external adm in 151 // TODO: Currently there is no way creating an external adm in
153 // libjingle source tree. So we can 't currently assert if this is NULL. 152 // libjingle source tree. So we can 't currently assert if this is NULL.
154 // ASSERT(default_adm != NULL); 153 // ASSERT(default_adm != NULL);
155 } 154 }
156 155
157 PeerConnectionFactory::~PeerConnectionFactory() { 156 PeerConnectionFactory::~PeerConnectionFactory() {
158 RTC_DCHECK(signaling_thread_->IsCurrent()); 157 RTC_DCHECK(signaling_thread_->IsCurrent());
159 channel_manager_.reset(nullptr); 158 channel_manager_.reset(nullptr);
160 default_allocator_factory_ = nullptr;
161 159
162 // Make sure |worker_thread_| and |signaling_thread_| outlive 160 // Make sure |worker_thread_| and |signaling_thread_| outlive
163 // |dtls_identity_store_|, |default_socket_factory_| and 161 // |dtls_identity_store_|, |default_socket_factory_| and
164 // |default_network_manager_|. 162 // |default_network_manager_|.
165 dtls_identity_store_ = nullptr; 163 dtls_identity_store_ = nullptr;
166 default_socket_factory_ = nullptr; 164 default_socket_factory_ = nullptr;
167 default_network_manager_ = nullptr; 165 default_network_manager_ = nullptr;
168 166
169 if (owns_ptrs_) { 167 if (owns_ptrs_) {
170 if (wraps_current_thread_) 168 if (wraps_current_thread_)
171 rtc::ThreadManager::Instance()->UnwrapCurrentThread(); 169 rtc::ThreadManager::Instance()->UnwrapCurrentThread();
172 delete worker_thread_; 170 delete worker_thread_;
173 } 171 }
174 } 172 }
175 173
176 bool PeerConnectionFactory::Initialize() { 174 bool PeerConnectionFactory::Initialize() {
177 RTC_DCHECK(signaling_thread_->IsCurrent()); 175 RTC_DCHECK(signaling_thread_->IsCurrent());
178 rtc::InitRandom(rtc::Time()); 176 rtc::InitRandom(rtc::Time());
179 177
180 default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_);
181 if (!default_allocator_factory_) {
182 return false;
183 }
184
185 default_network_manager_.reset(new rtc::BasicNetworkManager()); 178 default_network_manager_.reset(new rtc::BasicNetworkManager());
186 if (!default_network_manager_) { 179 if (!default_network_manager_) {
187 return false; 180 return false;
188 } 181 }
189 182
190 default_socket_factory_.reset( 183 default_socket_factory_.reset(
191 new rtc::BasicPacketSocketFactory(worker_thread_)); 184 new rtc::BasicPacketSocketFactory(worker_thread_));
192 if (!default_socket_factory_) { 185 if (!default_socket_factory_) {
193 return false; 186 return false;
194 } 187 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 242
250 void PeerConnectionFactory::StopRtcEventLog() { 243 void PeerConnectionFactory::StopRtcEventLog() {
251 RTC_DCHECK(signaling_thread_->IsCurrent()); 244 RTC_DCHECK(signaling_thread_->IsCurrent());
252 channel_manager_->StopRtcEventLog(); 245 channel_manager_->StopRtcEventLog();
253 } 246 }
254 247
255 rtc::scoped_refptr<PeerConnectionInterface> 248 rtc::scoped_refptr<PeerConnectionInterface>
256 PeerConnectionFactory::CreatePeerConnection( 249 PeerConnectionFactory::CreatePeerConnection(
257 const PeerConnectionInterface::RTCConfiguration& configuration, 250 const PeerConnectionInterface::RTCConfiguration& configuration,
258 const MediaConstraintsInterface* constraints, 251 const MediaConstraintsInterface* constraints,
259 PortAllocatorFactoryInterface* allocator_factory,
260 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
261 PeerConnectionObserver* observer) {
262 RTC_DCHECK(signaling_thread_->IsCurrent());
263 RTC_DCHECK(allocator_factory || default_allocator_factory_);
264
265 if (!dtls_identity_store.get()) {
266 // Because |pc|->Initialize takes ownership of the store we need a new
267 // wrapper object that can be deleted without deleting the underlying
268 // |dtls_identity_store_|, protecting it from being deleted multiple times.
269 dtls_identity_store.reset(
270 new DtlsIdentityStoreWrapper(dtls_identity_store_));
271 }
272
273 PortAllocatorFactoryInterface* chosen_allocator_factory =
274 allocator_factory ? allocator_factory : default_allocator_factory_.get();
275 chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask);
276
277 rtc::scoped_refptr<PeerConnection> pc(
278 new rtc::RefCountedObject<PeerConnection>(this));
279 if (!pc->Initialize(configuration, constraints, chosen_allocator_factory,
280 std::move(dtls_identity_store), observer)) {
281 return NULL;
282 }
283 return PeerConnectionProxy::Create(signaling_thread(), pc);
284 }
285
286 rtc::scoped_refptr<PeerConnectionInterface>
287 PeerConnectionFactory::CreatePeerConnection(
288 const PeerConnectionInterface::RTCConfiguration& configuration,
289 const MediaConstraintsInterface* constraints,
290 rtc::scoped_ptr<cricket::PortAllocator> allocator, 252 rtc::scoped_ptr<cricket::PortAllocator> allocator,
291 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, 253 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
292 PeerConnectionObserver* observer) { 254 PeerConnectionObserver* observer) {
293 RTC_DCHECK(signaling_thread_->IsCurrent()); 255 RTC_DCHECK(signaling_thread_->IsCurrent());
294 256
295 if (!dtls_identity_store.get()) { 257 if (!dtls_identity_store.get()) {
296 // Because |pc|->Initialize takes ownership of the store we need a new 258 // Because |pc|->Initialize takes ownership of the store we need a new
297 // wrapper object that can be deleted without deleting the underlying 259 // wrapper object that can be deleted without deleting the underlying
298 // |dtls_identity_store_|, protecting it from being deleted multiple times. 260 // |dtls_identity_store_|, protecting it from being deleted multiple times.
299 dtls_identity_store.reset( 261 dtls_identity_store.reset(
300 new DtlsIdentityStoreWrapper(dtls_identity_store_)); 262 new DtlsIdentityStoreWrapper(dtls_identity_store_));
301 } 263 }
302 264
303 if (!allocator) { 265 if (!allocator) {
304 allocator.reset(new cricket::BasicPortAllocator( 266 allocator.reset(new cricket::BasicPortAllocator(
305 default_network_manager_.get(), default_socket_factory_.get())); 267 default_network_manager_.get(), default_socket_factory_.get()));
306 } 268 }
307 default_network_manager_->set_network_ignore_mask( 269 allocator->SetNetworkIgnoreMask(options_.network_ignore_mask);
308 options_.network_ignore_mask);
309 270
310 rtc::scoped_refptr<PeerConnection> pc( 271 rtc::scoped_refptr<PeerConnection> pc(
311 new rtc::RefCountedObject<PeerConnection>(this)); 272 new rtc::RefCountedObject<PeerConnection>(this));
312 if (!pc->Initialize(configuration, constraints, std::move(allocator), 273 if (!pc->Initialize(configuration, constraints, std::move(allocator),
313 std::move(dtls_identity_store), observer)) { 274 std::move(dtls_identity_store), observer)) {
314 return nullptr; 275 return nullptr;
315 } 276 }
316 return PeerConnectionProxy::Create(signaling_thread(), pc); 277 return PeerConnectionProxy::Create(signaling_thread(), pc);
317 } 278 }
318 279
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 321 }
361 322
362 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() { 323 cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
363 ASSERT(worker_thread_ == rtc::Thread::Current()); 324 ASSERT(worker_thread_ == rtc::Thread::Current());
364 return cricket::WebRtcMediaEngineFactory::Create( 325 return cricket::WebRtcMediaEngineFactory::Create(
365 default_adm_.get(), video_encoder_factory_.get(), 326 default_adm_.get(), video_encoder_factory_.get(),
366 video_decoder_factory_.get()); 327 video_decoder_factory_.get());
367 } 328 }
368 329
369 } // namespace webrtc 330 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698