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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 // Create connections to this remote candidate. | 728 // Create connections to this remote candidate. |
729 CreateConnections(new_remote_candidate, NULL); | 729 CreateConnections(new_remote_candidate, NULL); |
730 | 730 |
731 // Resort the connections list, which may have new elements. | 731 // Resort the connections list, which may have new elements. |
732 SortConnections(); | 732 SortConnections(); |
733 } | 733 } |
734 | 734 |
| 735 void P2PTransportChannel::RemoveRemoteCandidate( |
| 736 const Candidate& cand_to_remove) { |
| 737 auto iter = |
| 738 std::remove_if(remote_candidates_.begin(), remote_candidates_.end(), |
| 739 [cand_to_remove](const Candidate& candidate) { |
| 740 return cand_to_remove.MatchesForRemoval(candidate); |
| 741 }); |
| 742 if (iter != remote_candidates_.end()) { |
| 743 LOG(LS_VERBOSE) << "Removed remote candidate " << cand_to_remove.ToString(); |
| 744 remote_candidates_.erase(iter, remote_candidates_.end()); |
| 745 } |
| 746 } |
| 747 |
735 // Creates connections from all of the ports that we care about to the given | 748 // Creates connections from all of the ports that we care about to the given |
736 // remote candidate. The return value is true if we created a connection from | 749 // remote candidate. The return value is true if we created a connection from |
737 // the origin port. | 750 // the origin port. |
738 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, | 751 bool P2PTransportChannel::CreateConnections(const Candidate& remote_candidate, |
739 PortInterface* origin_port) { | 752 PortInterface* origin_port) { |
740 ASSERT(worker_thread_ == rtc::Thread::Current()); | 753 ASSERT(worker_thread_ == rtc::Thread::Current()); |
741 | 754 |
742 // If we've already seen the new remote candidate (in the current candidate | 755 // If we've already seen the new remote candidate (in the current candidate |
743 // generation), then we shouldn't try creating connections for it. | 756 // generation), then we shouldn't try creating connections for it. |
744 // We either already have a connection for it, or we previously created one | 757 // We either already have a connection for it, or we previously created one |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 return; | 1443 return; |
1431 } | 1444 } |
1432 auto it = std::find(ports_.begin(), ports_.end(), port); | 1445 auto it = std::find(ports_.begin(), ports_.end(), port); |
1433 // Don't need to do anything if the port has been deleted from the port list. | 1446 // Don't need to do anything if the port has been deleted from the port list. |
1434 if (it == ports_.end()) { | 1447 if (it == ports_.end()) { |
1435 return; | 1448 return; |
1436 } | 1449 } |
1437 ports_.erase(it); | 1450 ports_.erase(it); |
1438 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() | 1451 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() |
1439 << " remaining"; | 1452 << " remaining"; |
1440 // TODO(honghaiz): Signal candidate removals to the remote side. | 1453 // Make a copy of the candidates in case the original ones are removed. |
| 1454 std::vector<Candidate> candidates = port->Candidates(); |
| 1455 SignalCandidatesRemoved(this, candidates); |
1441 } | 1456 } |
1442 | 1457 |
1443 // We data is available, let listeners know | 1458 // We data is available, let listeners know |
1444 void P2PTransportChannel::OnReadPacket(Connection* connection, | 1459 void P2PTransportChannel::OnReadPacket(Connection* connection, |
1445 const char* data, | 1460 const char* data, |
1446 size_t len, | 1461 size_t len, |
1447 const rtc::PacketTime& packet_time) { | 1462 const rtc::PacketTime& packet_time) { |
1448 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1463 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1449 | 1464 |
1450 // Do not deliver, if packet doesn't belong to the correct transport channel. | 1465 // Do not deliver, if packet doesn't belong to the correct transport channel. |
(...skipping 17 matching lines...) Expand all Loading... |
1468 SignalSentPacket(this, sent_packet); | 1483 SignalSentPacket(this, sent_packet); |
1469 } | 1484 } |
1470 | 1485 |
1471 void P2PTransportChannel::OnReadyToSend(Connection* connection) { | 1486 void P2PTransportChannel::OnReadyToSend(Connection* connection) { |
1472 if (connection == best_connection_ && writable()) { | 1487 if (connection == best_connection_ && writable()) { |
1473 SignalReadyToSend(this); | 1488 SignalReadyToSend(this); |
1474 } | 1489 } |
1475 } | 1490 } |
1476 | 1491 |
1477 } // namespace cricket | 1492 } // namespace cricket |
OLD | NEW |