Index: webrtc/p2p/base/p2ptransportchannel.cc |
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc |
index 952cfab7471e01147b3ca22b6aa4e4d5339fe0fc..2157d871e1411c9bcb1bbac9e96bc8740603da10 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel.cc |
+++ b/webrtc/p2p/base/p2ptransportchannel.cc |
@@ -12,13 +12,15 @@ |
#include <algorithm> |
#include <set> |
-#include "webrtc/p2p/base/common.h" |
-#include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. |
-#include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. |
+ |
#include "webrtc/base/common.h" |
#include "webrtc/base/crc32.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/stringencode.h" |
+#include "webrtc/p2p/base/candidate.h" |
+#include "webrtc/p2p/base/common.h" |
+#include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. |
+#include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. |
#include "webrtc/system_wrappers/include/field_trial.h" |
namespace { |
@@ -453,6 +455,7 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession *session, |
port->SignalUnknownAddress.connect( |
this, &P2PTransportChannel::OnUnknownAddress); |
port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); |
+ port->SignalStopped.connect(this, &P2PTransportChannel::OnPortStopped); |
port->SignalRoleConflict.connect( |
this, &P2PTransportChannel::OnRoleConflict); |
port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); |
@@ -711,6 +714,18 @@ void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) { |
SortConnections(); |
} |
+void P2PTransportChannel::RemoveRemoteCandidate(const Candidate& target) { |
+ auto iter = |
+ std::remove_if(remote_candidates_.begin(), remote_candidates_.end(), |
+ [target](const Candidate& candidate) { |
+ return target.IsWeaklyEquivalent(candidate); |
+ }); |
+ if (iter != remote_candidates_.end()) { |
+ LOG(LS_VERBOSE) << "Removed remote candidate " << target.ToString(); |
+ remote_candidates_.erase(iter, remote_candidates_.end()); |
+ } |
+} |
+ |
// Creates connections from all of the ports that we care about to the given |
// remote candidate. The return value is true if we created a connection from |
// the origin port. |
@@ -1402,6 +1417,28 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { |
<< static_cast<int>(ports_.size()) << " remaining"; |
} |
+void P2PTransportChannel::OnPortStopped(PortInterface* port) { |
+ // If it does not gather continually, the port will be removed from the list |
+ // when ICE restarts. |
+ if (!gather_continually_) { |
+ return; |
+ } |
+ auto it = std::find(ports_.begin(), ports_.end(), port); |
+ // Don't need to do anything if the port has been deleted from the port list. |
+ if (it == ports_.end()) { |
+ return; |
+ } |
+ ports_.erase(it); |
+ LOG(INFO) << "Removed port that has stopped: " << ports_.size() |
+ << " remaining"; |
+ // Make a copy of the candidates and change the priority on the copies. |
+ std::vector<Candidate> candidates = port->Candidates(); |
+ for (Candidate& candidate : candidates) { |
+ candidate.set_priority(0); |
+ } |
+ SignalCandidatesRemoved(this, candidates); |
+} |
+ |
// We data is available, let listeners know |
void P2PTransportChannel::OnReadPacket(Connection* connection, |
const char* data, |