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