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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 1956453003: Relanding: Implement RTCConfiguration.iceCandidatePoolSize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 P2PTransportChannel::~P2PTransportChannel() { 262 P2PTransportChannel::~P2PTransportChannel() {
263 ASSERT(worker_thread_ == rtc::Thread::Current()); 263 ASSERT(worker_thread_ == rtc::Thread::Current());
264 264
265 for (size_t i = 0; i < allocator_sessions_.size(); ++i) 265 for (size_t i = 0; i < allocator_sessions_.size(); ++i)
266 delete allocator_sessions_[i]; 266 delete allocator_sessions_[i];
267 } 267 }
268 268
269 // Add the allocator session to our list so that we know which sessions 269 // Add the allocator session to our list so that we know which sessions
270 // are still active. 270 // are still active.
271 void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) { 271 void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session,
272 bool pooled) {
272 ASSERT(worker_thread_ == rtc::Thread::Current()); 273 ASSERT(worker_thread_ == rtc::Thread::Current());
273 274
274 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); 275 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
275 allocator_sessions_.push_back(session); 276 allocator_sessions_.push_back(session);
276 277
277 // We now only want to apply new candidates that we receive to the ports 278 // We now only want to apply new candidates that we receive to the ports
278 // created by this new session because these are replacing those of the 279 // created by this new session because these are replacing those of the
279 // previous sessions. 280 // previous sessions.
280 ports_.clear(); 281 ports_.clear();
281 282
282 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); 283 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
283 session->SignalCandidatesReady.connect( 284 session->SignalCandidatesReady.connect(
284 this, &P2PTransportChannel::OnCandidatesReady); 285 this, &P2PTransportChannel::OnCandidatesReady);
285 session->SignalCandidatesAllocationDone.connect( 286 session->SignalCandidatesAllocationDone.connect(
286 this, &P2PTransportChannel::OnCandidatesAllocationDone); 287 this, &P2PTransportChannel::OnCandidatesAllocationDone);
287 session->StartGettingPorts(); 288 if (!pooled) {
289 session->StartGettingPorts();
290 }
pthatcher1 2016/05/05 21:51:24 Instead of having a bool passed in, I think it mig
Taylor Brandstetter 2016/05/06 03:53:34 Not much point in making a method (StartAllocatorS
pthatcher1 2016/05/07 00:21:44 That was actually the first idea I had. Now seein
288 } 291 }
pthatcher1 2016/05/05 21:51:24 Actually, is StartGettingPorts a no-op if it's alr
Taylor Brandstetter 2016/05/06 03:53:34 No, it isn't a no-op.
289 292
290 void P2PTransportChannel::AddConnection(Connection* connection) { 293 void P2PTransportChannel::AddConnection(Connection* connection) {
291 connections_.push_back(connection); 294 connections_.push_back(connection);
292 unpinged_connections_.insert(connection); 295 unpinged_connections_.insert(connection);
293 connection->set_remote_ice_mode(remote_ice_mode_); 296 connection->set_remote_ice_mode(remote_ice_mode_);
294 connection->set_receiving_timeout(config_.receiving_timeout); 297 connection->set_receiving_timeout(config_.receiving_timeout);
295 connection->SignalReadPacket.connect( 298 connection->SignalReadPacket.connect(
296 this, &P2PTransportChannel::OnReadPacket); 299 this, &P2PTransportChannel::OnReadPacket);
297 connection->SignalReadyToSend.connect( 300 connection->SignalReadyToSend.connect(
298 this, &P2PTransportChannel::OnReadyToSend); 301 this, &P2PTransportChannel::OnReadyToSend);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 467
465 void P2PTransportChannel::MaybeStartGathering() { 468 void P2PTransportChannel::MaybeStartGathering() {
466 // Start gathering if we never started before, or if an ICE restart occurred. 469 // Start gathering if we never started before, or if an ICE restart occurred.
467 if (allocator_sessions_.empty() || 470 if (allocator_sessions_.empty() ||
468 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), 471 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(),
469 allocator_sessions_.back()->ice_pwd(), ice_ufrag_, 472 allocator_sessions_.back()->ice_pwd(), ice_ufrag_,
470 ice_pwd_)) { 473 ice_pwd_)) {
471 if (gathering_state_ != kIceGatheringGathering) { 474 if (gathering_state_ != kIceGatheringGathering) {
472 gathering_state_ = kIceGatheringGathering; 475 gathering_state_ = kIceGatheringGathering;
473 SignalGatheringState(this); 476 SignalGatheringState(this);
474 } 477 }
Taylor Brandstetter 2016/05/05 19:56:22 You might think "we shouldn't use pooled sessions
475 // Time for a new allocator 478 // Time for a new allocator.
476 AddAllocatorSession(allocator_->CreateSession( 479 PortAllocatorSession* pooled_session = allocator_->GetPooledSession(
477 SessionId(), transport_name(), component(), ice_ufrag_, ice_pwd_)); 480 transport_name(), component(), ice_ufrag_, ice_pwd_);
481 if (pooled_session) {
482 AddAllocatorSession(pooled_session, true);
483 // Process the pooled session's existing candidates/ports, if they exist.
484 OnCandidatesReady(pooled_session, pooled_session->ReadyCandidates());
485 for (PortInterface* port : pooled_session->ReadyPorts()) {
486 OnPortReady(pooled_session, port);
487 }
488 if (pooled_session->CandidatesAllocationDone()) {
489 OnCandidatesAllocationDone(pooled_session);
490 }
491 } else {
492 AddAllocatorSession(
493 allocator_->CreateSession(SessionId(), transport_name(), component(),
494 ice_ufrag_, ice_pwd_),
495 false);
496 }
478 } 497 }
479 } 498 }
480 499
481 // A new port is available, attempt to make connections for it 500 // A new port is available, attempt to make connections for it
482 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, 501 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
483 PortInterface* port) { 502 PortInterface* port) {
484 ASSERT(worker_thread_ == rtc::Thread::Current()); 503 ASSERT(worker_thread_ == rtc::Thread::Current());
485 504
486 // Set in-effect options on the new port 505 // Set in-effect options on the new port
487 for (OptionMap::const_iterator it = options_.begin(); 506 for (OptionMap::const_iterator it = options_.begin();
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 1657
1639 // During the initial state when nothing has been pinged yet, return the first 1658 // During the initial state when nothing has been pinged yet, return the first
1640 // one in the ordered |connections_|. 1659 // one in the ordered |connections_|.
1641 return *(std::find_if(connections_.begin(), connections_.end(), 1660 return *(std::find_if(connections_.begin(), connections_.end(),
1642 [conn1, conn2](Connection* conn) { 1661 [conn1, conn2](Connection* conn) {
1643 return conn == conn1 || conn == conn2; 1662 return conn == conn1 || conn == conn2;
1644 })); 1663 }));
1645 } 1664 }
1646 1665
1647 } // namespace cricket 1666 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698