| OLD | NEW |
| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 444 } |
| 445 // Start gathering if we never started before, or if an ICE restart occurred. | 445 // Start gathering if we never started before, or if an ICE restart occurred. |
| 446 if (allocator_sessions_.empty() || | 446 if (allocator_sessions_.empty() || |
| 447 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), | 447 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), |
| 448 allocator_sessions_.back()->ice_pwd(), | 448 allocator_sessions_.back()->ice_pwd(), |
| 449 ice_parameters_.ufrag, ice_parameters_.pwd)) { | 449 ice_parameters_.ufrag, ice_parameters_.pwd)) { |
| 450 if (gathering_state_ != kIceGatheringGathering) { | 450 if (gathering_state_ != kIceGatheringGathering) { |
| 451 gathering_state_ = kIceGatheringGathering; | 451 gathering_state_ = kIceGatheringGathering; |
| 452 SignalGatheringState(this); | 452 SignalGatheringState(this); |
| 453 } | 453 } |
| 454 |
| 455 if (!allocator_sessions_.empty()) { |
| 456 IceRegatheringReason reason; |
| 457 if (writable()) { |
| 458 reason = IceRegatheringReason::ICE_RESTART_WHEN_CONNECTED; |
| 459 } else if (IsGettingPorts()) { |
| 460 reason = IceRegatheringReason::ICE_RESTART_WHEN_CONNECTING; |
| 461 } else { |
| 462 reason = IceRegatheringReason::ICE_RESTART_WHEN_DISCONNECTED; |
| 463 } |
| 464 allocator_->ReportIceRegatheringReason(reason); |
| 465 } |
| 466 |
| 454 // Time for a new allocator. | 467 // Time for a new allocator. |
| 455 std::unique_ptr<PortAllocatorSession> pooled_session = | 468 std::unique_ptr<PortAllocatorSession> pooled_session = |
| 456 allocator_->TakePooledSession(transport_name(), component(), | 469 allocator_->TakePooledSession(transport_name(), component(), |
| 457 ice_parameters_.ufrag, | 470 ice_parameters_.ufrag, |
| 458 ice_parameters_.pwd); | 471 ice_parameters_.pwd); |
| 459 if (pooled_session) { | 472 if (pooled_session) { |
| 460 AddAllocatorSession(std::move(pooled_session)); | 473 AddAllocatorSession(std::move(pooled_session)); |
| 461 PortAllocatorSession* raw_pooled_session = | 474 PortAllocatorSession* raw_pooled_session = |
| 462 allocator_sessions_.back().get(); | 475 allocator_sessions_.back().get(); |
| 463 // Process the pooled session's existing candidates/ports, if they exist. | 476 // Process the pooled session's existing candidates/ports, if they exist. |
| 464 OnCandidatesReady(raw_pooled_session, | 477 OnCandidatesReady(raw_pooled_session, |
| 465 raw_pooled_session->ReadyCandidates()); | 478 raw_pooled_session->ReadyCandidates()); |
| 466 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) { | 479 for (PortInterface* port : allocator_sessions_.back()->ReadyPorts()) { |
| 467 OnPortReady(raw_pooled_session, port); | 480 OnPortReady(raw_pooled_session, port); |
| 468 } | 481 } |
| 469 if (allocator_sessions_.back()->CandidatesAllocationDone()) { | 482 if (allocator_sessions_.back()->CandidatesAllocationDone()) { |
| 470 OnCandidatesAllocationDone(raw_pooled_session); | 483 OnCandidatesAllocationDone(raw_pooled_session); |
| 471 } | 484 } |
| 472 } else { | 485 } else { |
| 473 AddAllocatorSession(allocator_->CreateSession( | 486 AddAllocatorSession(allocator_->CreateSession( |
| 474 transport_name(), component(), ice_parameters_.ufrag, | 487 transport_name(), component(), ice_parameters_.ufrag, |
| 475 ice_parameters_.pwd)); | 488 ice_parameters_.pwd)); |
| 476 LOG(LS_INFO) << "Start getting ports"; | |
| 477 allocator_sessions_.back()->StartGettingPorts(); | 489 allocator_sessions_.back()->StartGettingPorts(); |
| 478 } | 490 } |
| 479 } | 491 } |
| 480 } | 492 } |
| 481 | 493 |
| 482 // A new port is available, attempt to make connections for it | 494 // A new port is available, attempt to make connections for it |
| 483 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, | 495 void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, |
| 484 PortInterface* port) { | 496 PortInterface* port) { |
| 485 ASSERT(network_thread_ == rtc::Thread::Current()); | 497 ASSERT(network_thread_ == rtc::Thread::Current()); |
| 486 | 498 |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 | 1979 |
| 1968 // During the initial state when nothing has been pinged yet, return the first | 1980 // During the initial state when nothing has been pinged yet, return the first |
| 1969 // one in the ordered |connections_|. | 1981 // one in the ordered |connections_|. |
| 1970 return *(std::find_if(connections_.begin(), connections_.end(), | 1982 return *(std::find_if(connections_.begin(), connections_.end(), |
| 1971 [conn1, conn2](Connection* conn) { | 1983 [conn1, conn2](Connection* conn) { |
| 1972 return conn == conn1 || conn == conn2; | 1984 return conn == conn1 || conn == conn2; |
| 1973 })); | 1985 })); |
| 1974 } | 1986 } |
| 1975 | 1987 |
| 1976 } // namespace cricket | 1988 } // namespace cricket |
| OLD | NEW |