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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 // if one is pending. | 500 // if one is pending. |
501 | 501 |
502 port->SetIceRole(ice_role_); | 502 port->SetIceRole(ice_role_); |
503 port->SetIceTiebreaker(tiebreaker_); | 503 port->SetIceTiebreaker(tiebreaker_); |
504 ports_.push_back(port); | 504 ports_.push_back(port); |
505 port->SignalUnknownAddress.connect( | 505 port->SignalUnknownAddress.connect( |
506 this, &P2PTransportChannel::OnUnknownAddress); | 506 this, &P2PTransportChannel::OnUnknownAddress); |
507 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); | 507 port->SignalDestroyed.connect(this, &P2PTransportChannel::OnPortDestroyed); |
508 port->SignalNetworkInactive.connect( | 508 port->SignalNetworkInactive.connect( |
509 this, &P2PTransportChannel::OnPortNetworkInactive); | 509 this, &P2PTransportChannel::OnPortNetworkInactive); |
| 510 port->SignalNetworkCostChanged.connect( |
| 511 this, &P2PTransportChannel::OnPortNetworkCostChanged); |
510 port->SignalRoleConflict.connect( | 512 port->SignalRoleConflict.connect( |
511 this, &P2PTransportChannel::OnRoleConflict); | 513 this, &P2PTransportChannel::OnRoleConflict); |
512 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); | 514 port->SignalSentPacket.connect(this, &P2PTransportChannel::OnSentPacket); |
513 | 515 |
514 // Attempt to create a connection from this new port to all of the remote | 516 // Attempt to create a connection from this new port to all of the remote |
515 // candidates that we were given so far. | 517 // candidates that we were given so far. |
516 | 518 |
517 std::vector<RemoteCandidate>::iterator iter; | 519 std::vector<RemoteCandidate>::iterator iter; |
518 for (iter = remote_candidates_.begin(); iter != remote_candidates_.end(); | 520 for (iter = remote_candidates_.begin(); iter != remote_candidates_.end(); |
519 ++iter) { | 521 ++iter) { |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 ports_.erase(it); | 1492 ports_.erase(it); |
1491 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() | 1493 LOG(INFO) << "Removed port due to inactive networks: " << ports_.size() |
1492 << " remaining"; | 1494 << " remaining"; |
1493 std::vector<Candidate> candidates = port->Candidates(); | 1495 std::vector<Candidate> candidates = port->Candidates(); |
1494 for (Candidate& candidate : candidates) { | 1496 for (Candidate& candidate : candidates) { |
1495 candidate.set_transport_name(transport_name()); | 1497 candidate.set_transport_name(transport_name()); |
1496 } | 1498 } |
1497 SignalCandidatesRemoved(this, candidates); | 1499 SignalCandidatesRemoved(this, candidates); |
1498 } | 1500 } |
1499 | 1501 |
| 1502 void P2PTransportChannel::OnPortNetworkCostChanged(PortInterface* port) { |
| 1503 // Network cost of a port will affect the connection comparison. |
| 1504 // So request sorting if the network cost of any port has changed. |
| 1505 RequestSort(); |
| 1506 } |
| 1507 |
1500 // We data is available, let listeners know | 1508 // We data is available, let listeners know |
1501 void P2PTransportChannel::OnReadPacket(Connection* connection, | 1509 void P2PTransportChannel::OnReadPacket(Connection* connection, |
1502 const char* data, | 1510 const char* data, |
1503 size_t len, | 1511 size_t len, |
1504 const rtc::PacketTime& packet_time) { | 1512 const rtc::PacketTime& packet_time) { |
1505 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1513 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1506 | 1514 |
1507 // Do not deliver, if packet doesn't belong to the correct transport channel. | 1515 // Do not deliver, if packet doesn't belong to the correct transport channel. |
1508 if (!FindConnection(connection)) | 1516 if (!FindConnection(connection)) |
1509 return; | 1517 return; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 | 1650 |
1643 // During the initial state when nothing has been pinged yet, return the first | 1651 // During the initial state when nothing has been pinged yet, return the first |
1644 // one in the ordered |connections_|. | 1652 // one in the ordered |connections_|. |
1645 return *(std::find_if(connections_.begin(), connections_.end(), | 1653 return *(std::find_if(connections_.begin(), connections_.end(), |
1646 [conn1, conn2](Connection* conn) { | 1654 [conn1, conn2](Connection* conn) { |
1647 return conn == conn1 || conn == conn2; | 1655 return conn == conn1 || conn == conn2; |
1648 })); | 1656 })); |
1649 } | 1657 } |
1650 | 1658 |
1651 } // namespace cricket | 1659 } // namespace cricket |
OLD | NEW |