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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 } | 118 } |
119 | 119 |
120 // Add the allocator session to our list so that we know which sessions | 120 // Add the allocator session to our list so that we know which sessions |
121 // are still active. | 121 // are still active. |
122 void P2PTransportChannel::AddAllocatorSession( | 122 void P2PTransportChannel::AddAllocatorSession( |
123 std::unique_ptr<PortAllocatorSession> session) { | 123 std::unique_ptr<PortAllocatorSession> session) { |
124 ASSERT(worker_thread_ == rtc::Thread::Current()); | 124 ASSERT(worker_thread_ == rtc::Thread::Current()); |
125 | 125 |
126 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); | 126 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); |
127 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); | 127 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); |
128 session->SignalPortDeprecated.connect(this, | |
129 &P2PTransportChannel::OnPortDeprecated); | |
128 session->SignalCandidatesReady.connect( | 130 session->SignalCandidatesReady.connect( |
129 this, &P2PTransportChannel::OnCandidatesReady); | 131 this, &P2PTransportChannel::OnCandidatesReady); |
130 session->SignalCandidatesAllocationDone.connect( | 132 session->SignalCandidatesAllocationDone.connect( |
131 this, &P2PTransportChannel::OnCandidatesAllocationDone); | 133 this, &P2PTransportChannel::OnCandidatesAllocationDone); |
132 | 134 |
133 // We now only want to apply new candidates that we receive to the ports | 135 // We now only want to apply new candidates that we receive to the ports |
134 // created by this new session because these are replacing those of the | 136 // created by this new session because these are replacing those of the |
135 // previous sessions. | 137 // previous sessions. |
136 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end()); | 138 removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end()); |
137 ports_.clear(); | 139 ports_.clear(); |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1619 // connection attempts. | 1621 // connection attempts. |
1620 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { | 1622 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { |
1621 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1623 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1622 | 1624 |
1623 // Remove this port from the lists (if we didn't drop it already). | 1625 // Remove this port from the lists (if we didn't drop it already). |
1624 ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end()); | 1626 ports_.erase(std::remove(ports_.begin(), ports_.end(), port), ports_.end()); |
1625 removed_ports_.erase( | 1627 removed_ports_.erase( |
1626 std::remove(removed_ports_.begin(), removed_ports_.end(), port), | 1628 std::remove(removed_ports_.begin(), removed_ports_.end(), port), |
1627 removed_ports_.end()); | 1629 removed_ports_.end()); |
1628 | 1630 |
1629 LOG(INFO) << "Removed port from p2p socket: " | 1631 LOG(INFO) << "Removed port because it is destroyed: " |
1630 << static_cast<int>(ports_.size()) << " remaining"; | 1632 << static_cast<int>(ports_.size()) << " remaining"; |
1631 } | 1633 } |
1632 | 1634 |
1633 void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) { | 1635 void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) { |
1634 // If it does not gather continually, the port will be removed from the list | 1636 // If it does not gather continually, the port will be removed from the list |
1635 // when ICE restarts. | 1637 // when ICE restarts. |
1636 if (!config_.gather_continually) { | 1638 if (!config_.gather_continually) { |
1637 return; | 1639 return; |
1638 } | 1640 } |
1639 auto it = std::find(ports_.begin(), ports_.end(), port); | 1641 RemovePort(port); |
1640 // Don't need to do anything if the port has been deleted from the port list. | 1642 LOG(INFO) << "Removed port because its network is inactive : " |
1641 if (it == ports_.end()) { | 1643 << port->ToString() << " " << ports_.size() << " remaining"; |
1642 return; | |
1643 } | |
1644 removed_ports_.push_back(*it); | |
1645 ports_.erase(it); | |
1646 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() | |
1647 << " remaining"; | |
1648 std::vector<Candidate> candidates = port->Candidates(); | 1644 std::vector<Candidate> candidates = port->Candidates(); |
1649 for (Candidate& candidate : candidates) { | 1645 for (Candidate& candidate : candidates) { |
1650 candidate.set_transport_name(transport_name()); | 1646 candidate.set_transport_name(transport_name()); |
1651 } | 1647 } |
1652 SignalCandidatesRemoved(this, candidates); | 1648 SignalCandidatesRemoved(this, candidates); |
1653 } | 1649 } |
1654 | 1650 |
1651 void P2PTransportChannel::OnPortDeprecated(PortAllocatorSession* session, | |
1652 PortInterface* port) { | |
1653 if (session != allocator_session()) { | |
pthatcher1
2016/06/27 20:35:54
Can you comment on why we need this? Will this ha
honghaiz3
2016/06/28 01:49:25
Perhaps this is not needed.
If this is from the p
| |
1654 return; | |
1655 } | |
1656 RemovePort(port); | |
1657 LOG(INFO) << "Removed port because it is deprecated: " << port->ToString() | |
1658 << " " << ports_.size() << " remaining"; | |
1659 } | |
1660 | |
1661 void P2PTransportChannel::RemovePort(PortInterface* port) { | |
1662 auto it = std::find(ports_.begin(), ports_.end(), port); | |
1663 // Don't need to do anything if the port has been deleted from the port list. | |
1664 if (it == ports_.end()) { | |
1665 return; | |
1666 } | |
1667 ports_.erase(it); | |
1668 removed_ports_.push_back(port); | |
1669 } | |
1670 | |
1655 // We data is available, let listeners know | 1671 // We data is available, let listeners know |
1656 void P2PTransportChannel::OnReadPacket(Connection* connection, | 1672 void P2PTransportChannel::OnReadPacket(Connection* connection, |
1657 const char* data, | 1673 const char* data, |
1658 size_t len, | 1674 size_t len, |
1659 const rtc::PacketTime& packet_time) { | 1675 const rtc::PacketTime& packet_time) { |
1660 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1676 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1661 | 1677 |
1662 // Do not deliver, if packet doesn't belong to the correct transport channel. | 1678 // Do not deliver, if packet doesn't belong to the correct transport channel. |
1663 if (!FindConnection(connection)) | 1679 if (!FindConnection(connection)) |
1664 return; | 1680 return; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1799 | 1815 |
1800 // During the initial state when nothing has been pinged yet, return the first | 1816 // During the initial state when nothing has been pinged yet, return the first |
1801 // one in the ordered |connections_|. | 1817 // one in the ordered |connections_|. |
1802 return *(std::find_if(connections_.begin(), connections_.end(), | 1818 return *(std::find_if(connections_.begin(), connections_.end(), |
1803 [conn1, conn2](Connection* conn) { | 1819 [conn1, conn2](Connection* conn) { |
1804 return conn == conn1 || conn == conn2; | 1820 return conn == conn1 || conn == conn2; |
1805 })); | 1821 })); |
1806 } | 1822 } |
1807 | 1823 |
1808 } // namespace cricket | 1824 } // namespace cricket |
OLD | NEW |