| 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 | 756 |
| 757 // Create connections to this remote candidate. | 757 // Create connections to this remote candidate. |
| 758 CreateConnections(new_remote_candidate, NULL); | 758 CreateConnections(new_remote_candidate, NULL); |
| 759 | 759 |
| 760 // Resort the connections list, which may have new elements. | 760 // Resort the connections list, which may have new elements. |
| 761 SortConnections(); | 761 SortConnections(); |
| 762 } | 762 } |
| 763 | 763 |
| 764 void P2PTransportChannel::RemoveRemoteCandidate( | |
| 765 const Candidate& cand_to_remove) { | |
| 766 auto iter = | |
| 767 std::remove_if(remote_candidates_.begin(), remote_candidates_.end(), | |
| 768 [cand_to_remove](const Candidate& candidate) { | |
| 769 return cand_to_remove.MatchesForRemoval(candidate); | |
| 770 }); | |
| 771 if (iter != remote_candidates_.end()) { | |
| 772 LOG(LS_VERBOSE) << "Removed remote candidate " << cand_to_remove.ToString(); | |
| 773 remote_candidates_.erase(iter, remote_candidates_.end()); | |
| 774 } | |
| 775 } | |
| 776 | |
| 777 // Creates connections from all of the ports that we care about to the given | 764 // Creates connections from all of the ports that we care about to the given |
| 778 // remote candidate. The return value is true if we created a connection from | 765 // remote candidate. The return value is true if we created a connection from |
| 779 // the origin port. | 766 // the origin port. |
| 780 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, | 767 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, |
| 781 PortInterface* origin_port) { | 768 PortInterface* origin_port) { |
| 782 ASSERT(worker_thread_ == rtc::Thread::Current()); | 769 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 783 | 770 |
| 784 // If we've already seen the new remote candidate (in the current candidate | 771 // If we've already seen the new remote candidate (in the current candidate |
| 785 // generation), then we shouldn't try creating connections for it. | 772 // generation), then we shouldn't try creating connections for it. |
| 786 // We either already have a connection for it, or we previously created one | 773 // We either already have a connection for it, or we previously created one |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 return; | 1442 return; |
| 1456 } | 1443 } |
| 1457 auto it = std::find(ports_.begin(), ports_.end(), port); | 1444 auto it = std::find(ports_.begin(), ports_.end(), port); |
| 1458 // Don't need to do anything if the port has been deleted from the port list. | 1445 // Don't need to do anything if the port has been deleted from the port list. |
| 1459 if (it == ports_.end()) { | 1446 if (it == ports_.end()) { |
| 1460 return; | 1447 return; |
| 1461 } | 1448 } |
| 1462 ports_.erase(it); | 1449 ports_.erase(it); |
| 1463 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() | 1450 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() |
| 1464 << " remaining"; | 1451 << " remaining"; |
| 1465 std::vector<Candidate> candidates = port->Candidates(); | 1452 // TODO(honghaiz): Signal candidate removals to the remote side. |
| 1466 for (Candidate& candidate : candidates) { | |
| 1467 candidate.set_transport_name(transport_name()); | |
| 1468 } | |
| 1469 SignalCandidatesRemoved(this, candidates); | |
| 1470 } | 1453 } |
| 1471 | 1454 |
| 1472 // We data is available, let listeners know | 1455 // We data is available, let listeners know |
| 1473 void P2PTransportChannel::OnReadPacket(Connection* connection, | 1456 void P2PTransportChannel::OnReadPacket(Connection* connection, |
| 1474 const char* data, | 1457 const char* data, |
| 1475 size_t len, | 1458 size_t len, |
| 1476 const rtc::PacketTime& packet_time) { | 1459 const rtc::PacketTime& packet_time) { |
| 1477 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1460 ASSERT(worker_thread_ == rtc::Thread::Current()); |
| 1478 | 1461 |
| 1479 // Do not deliver, if packet doesn't belong to the correct transport channel. | 1462 // Do not deliver, if packet doesn't belong to the correct transport channel. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1597 |
| 1615 // During the initial state when nothing has been pinged yet, return the first | 1598 // During the initial state when nothing has been pinged yet, return the first |
| 1616 // one in the ordered |connections_|. | 1599 // one in the ordered |connections_|. |
| 1617 return *(std::find_if(connections_.begin(), connections_.end(), | 1600 return *(std::find_if(connections_.begin(), connections_.end(), |
| 1618 [conn1, conn2](Connection* conn) { | 1601 [conn1, conn2](Connection* conn) { |
| 1619 return conn == conn1 || conn == conn2; | 1602 return conn == conn1 || conn == conn2; |
| 1620 })); | 1603 })); |
| 1621 } | 1604 } |
| 1622 | 1605 |
| 1623 } // namespace cricket | 1606 } // namespace cricket |
| OLD | NEW |