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

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: Fixing uninitialized variable (noticed by msan) 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 uint32_t weak_ping_interval = ::strtoul( 254 uint32_t weak_ping_interval = ::strtoul(
255 webrtc::field_trial::FindFullName("WebRTC-StunInterPacketDelay").c_str(), 255 webrtc::field_trial::FindFullName("WebRTC-StunInterPacketDelay").c_str(),
256 nullptr, 10); 256 nullptr, 10);
257 if (weak_ping_interval) { 257 if (weak_ping_interval) {
258 weak_ping_interval_ = static_cast<int>(weak_ping_interval); 258 weak_ping_interval_ = static_cast<int>(weak_ping_interval);
259 } 259 }
260 } 260 }
261 261
262 P2PTransportChannel::~P2PTransportChannel() { 262 P2PTransportChannel::~P2PTransportChannel() {
263 ASSERT(worker_thread_ == rtc::Thread::Current()); 263 ASSERT(worker_thread_ == rtc::Thread::Current());
264
265 for (size_t i = 0; i < allocator_sessions_.size(); ++i)
266 delete allocator_sessions_[i];
267 } 264 }
268 265
269 // Add the allocator session to our list so that we know which sessions 266 // Add the allocator session to our list so that we know which sessions
270 // are still active. 267 // are still active.
271 void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) { 268 void P2PTransportChannel::AddAllocatorSession(
269 std::unique_ptr<PortAllocatorSession> session) {
272 ASSERT(worker_thread_ == rtc::Thread::Current()); 270 ASSERT(worker_thread_ == rtc::Thread::Current());
273 271
274 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); 272 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
275 allocator_sessions_.push_back(session); 273 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
274 session->SignalCandidatesReady.connect(
275 this, &P2PTransportChannel::OnCandidatesReady);
276 session->SignalCandidatesAllocationDone.connect(
277 this, &P2PTransportChannel::OnCandidatesAllocationDone);
276 278
277 // We now only want to apply new candidates that we receive to the ports 279 // 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 280 // created by this new session because these are replacing those of the
279 // previous sessions. 281 // previous sessions.
280 ports_.clear(); 282 ports_.clear();
281 283
282 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); 284 allocator_sessions_.push_back(std::move(session));
283 session->SignalCandidatesReady.connect(
284 this, &P2PTransportChannel::OnCandidatesReady);
285 session->SignalCandidatesAllocationDone.connect(
286 this, &P2PTransportChannel::OnCandidatesAllocationDone);
287 session->StartGettingPorts();
288 } 285 }
289 286
290 void P2PTransportChannel::AddConnection(Connection* connection) { 287 void P2PTransportChannel::AddConnection(Connection* connection) {
291 connections_.push_back(connection); 288 connections_.push_back(connection);
292 unpinged_connections_.insert(connection); 289 unpinged_connections_.insert(connection);
293 connection->set_remote_ice_mode(remote_ice_mode_); 290 connection->set_remote_ice_mode(remote_ice_mode_);
294 connection->set_receiving_timeout(config_.receiving_timeout); 291 connection->set_receiving_timeout(config_.receiving_timeout);
295 connection->SignalReadPacket.connect( 292 connection->SignalReadPacket.connect(
296 this, &P2PTransportChannel::OnReadPacket); 293 this, &P2PTransportChannel::OnReadPacket);
297 connection->SignalReadyToSend.connect( 294 connection->SignalReadyToSend.connect(
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void P2PTransportChannel::MaybeStartGathering() { 462 void P2PTransportChannel::MaybeStartGathering() {
466 // Start gathering if we never started before, or if an ICE restart occurred. 463 // Start gathering if we never started before, or if an ICE restart occurred.
467 if (allocator_sessions_.empty() || 464 if (allocator_sessions_.empty() ||
468 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), 465 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(),
469 allocator_sessions_.back()->ice_pwd(), ice_ufrag_, 466 allocator_sessions_.back()->ice_pwd(), ice_ufrag_,
470 ice_pwd_)) { 467 ice_pwd_)) {
471 if (gathering_state_ != kIceGatheringGathering) { 468 if (gathering_state_ != kIceGatheringGathering) {
472 gathering_state_ = kIceGatheringGathering; 469 gathering_state_ = kIceGatheringGathering;
473 SignalGatheringState(this); 470 SignalGatheringState(this);
474 } 471 }
475 // Time for a new allocator 472 // Time for a new allocator.
476 AddAllocatorSession(allocator_->CreateSession( 473 std::unique_ptr<PortAllocatorSession> pooled_session =
477 SessionId(), transport_name(), component(), ice_ufrag_, ice_pwd_)); 474 allocator_->TakePooledSession(transport_name(), component(), ice_ufrag_,
475 ice_pwd_);
476 if (pooled_session) {
477 AddAllocatorSession(std::move(pooled_session));
478 PortAllocatorSession* raw_pooled_session =
479 allocator_sessions_.back().get();
480 // Process the pooled session's existing candidates/ports, if they exist.
481 OnCandidatesReady(raw_pooled_session,
482 raw_pooled_session->ReadyCandidates());
483 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) {
484 OnPortReady(raw_pooled_session, port);
485 }
486 if (allocator_sessions_.back()->CandidatesAllocationDone()) {
487 OnCandidatesAllocationDone(raw_pooled_session);
488 }
489 } else {
490 AddAllocatorSession(allocator_->CreateSession(
491 SessionId(), transport_name(), component(), ice_ufrag_, ice_pwd_));
492 allocator_sessions_.back()->StartGettingPorts();
493 }
478 } 494 }
479 } 495 }
480 496
481 // A new port is available, attempt to make connections for it 497 // A new port is available, attempt to make connections for it
482 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, 498 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
483 PortInterface* port) { 499 PortInterface* port) {
484 ASSERT(worker_thread_ == rtc::Thread::Current()); 500 ASSERT(worker_thread_ == rtc::Thread::Current());
485 501
486 // Set in-effect options on the new port 502 // Set in-effect options on the new port
487 for (OptionMap::const_iterator it = options_.begin(); 503 for (OptionMap::const_iterator it = options_.begin();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 } 1222 }
1207 } 1223 }
1208 set_receiving(receiving); 1224 set_receiving(receiving);
1209 } 1225 }
1210 1226
1211 void P2PTransportChannel::MaybeStopPortAllocatorSessions() { 1227 void P2PTransportChannel::MaybeStopPortAllocatorSessions() {
1212 if (!IsGettingPorts()) { 1228 if (!IsGettingPorts()) {
1213 return; 1229 return;
1214 } 1230 }
1215 1231
1216 for (PortAllocatorSession* session : allocator_sessions_) { 1232 for (const auto& session : allocator_sessions_) {
1217 if (!session->IsGettingPorts()) { 1233 if (!session->IsGettingPorts()) {
1218 continue; 1234 continue;
1219 } 1235 }
1220 // If gathering continually, keep the last session running so that it 1236 // If gathering continually, keep the last session running so that it
1221 // will gather candidates if the networks change. 1237 // will gather candidates if the networks change.
1222 if (config_.gather_continually && session == allocator_sessions_.back()) { 1238 if (config_.gather_continually && session == allocator_sessions_.back()) {
1223 session->ClearGettingPorts(); 1239 session->ClearGettingPorts();
1224 break; 1240 break;
1225 } 1241 }
1226 session->StopGettingPorts(); 1242 session->StopGettingPorts();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 1658
1643 // During the initial state when nothing has been pinged yet, return the first 1659 // During the initial state when nothing has been pinged yet, return the first
1644 // one in the ordered |connections_|. 1660 // one in the ordered |connections_|.
1645 return *(std::find_if(connections_.begin(), connections_.end(), 1661 return *(std::find_if(connections_.begin(), connections_.end(),
1646 [conn1, conn2](Connection* conn) { 1662 [conn1, conn2](Connection* conn) {
1647 return conn == conn1 || conn == conn2; 1663 return conn == conn1 || conn == conn2;
1648 })); 1664 }));
1649 } 1665 }
1650 1666
1651 } // namespace cricket 1667 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698