| Index: webrtc/p2p/base/p2ptransportchannel.cc
|
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
|
| index 952cfab7471e01147b3ca22b6aa4e4d5339fe0fc..30896b30f44977f132476a6baba3b105ffaa65d0 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,8 @@ void P2PTransportChannel::OnPortReady(PortAllocatorSession *session,
|
| port->SignalUnknownAddress.connect(
|
| this, &P2PTransportChannel::OnUnknownAddress);
|
| port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed);
|
| + port->SignalNetworkInactive.connect(
|
| + this, &P2PTransportChannel::OnPortNetworkInactive);
|
| port->SignalRoleConflict.connect(
|
| this, &P2PTransportChannel::OnRoleConflict);
|
| port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket);
|
| @@ -711,6 +715,19 @@ void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) {
|
| SortConnections();
|
| }
|
|
|
| +void P2PTransportChannel::RemoveRemoteCandidate(
|
| + const Candidate& cand_to_remove) {
|
| + auto iter =
|
| + std::remove_if(remote_candidates_.begin(), remote_candidates_.end(),
|
| + [cand_to_remove](const Candidate& candidate) {
|
| + return cand_to_remove.MatchesForRemoval(candidate);
|
| + });
|
| + if (iter != remote_candidates_.end()) {
|
| + LOG(LS_VERBOSE) << "Removed remote candidate " << cand_to_remove.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 +1419,28 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
|
| << static_cast<int>(ports_.size()) << " remaining";
|
| }
|
|
|
| +void P2PTransportChannel::OnPortNetworkInactive(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,
|
|
|