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 |
11 #include "webrtc/p2p/base/p2ptransportchannel.h" | 11 #include "webrtc/p2p/base/p2ptransportchannel.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "webrtc/base/common.h" | 16 #include "webrtc/base/common.h" |
17 #include "webrtc/base/crc32.h" | 17 #include "webrtc/base/crc32.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/stringencode.h" | 19 #include "webrtc/base/stringencode.h" |
20 #include "webrtc/p2p/base/candidate.h" | 20 #include "webrtc/p2p/base/candidate.h" |
| 21 #include "webrtc/p2p/base/candidatepairinterface.h" |
21 #include "webrtc/p2p/base/common.h" | 22 #include "webrtc/p2p/base/common.h" |
22 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. | 23 #include "webrtc/p2p/base/relayport.h" // For RELAY_PORT_TYPE. |
23 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. | 24 #include "webrtc/p2p/base/stunport.h" // For STUN_PORT_TYPE. |
24 #include "webrtc/system_wrappers/include/field_trial.h" | 25 #include "webrtc/system_wrappers/include/field_trial.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // messages for queuing up work for ourselves | 29 // messages for queuing up work for ourselves |
29 enum { MSG_SORT = 1, MSG_CHECK_AND_PING }; | 30 enum { MSG_SORT = 1, MSG_CHECK_AND_PING }; |
30 | 31 |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 if (old_best_connection) { | 1159 if (old_best_connection) { |
1159 LOG_J(LS_INFO, this) << "Previous best connection: " | 1160 LOG_J(LS_INFO, this) << "Previous best connection: " |
1160 << old_best_connection->ToString(); | 1161 << old_best_connection->ToString(); |
1161 } | 1162 } |
1162 LOG_J(LS_INFO, this) << "New best connection: " | 1163 LOG_J(LS_INFO, this) << "New best connection: " |
1163 << best_connection_->ToString(); | 1164 << best_connection_->ToString(); |
1164 SignalRouteChange(this, best_connection_->remote_candidate()); | 1165 SignalRouteChange(this, best_connection_->remote_candidate()); |
1165 } else { | 1166 } else { |
1166 LOG_J(LS_INFO, this) << "No best connection"; | 1167 LOG_J(LS_INFO, this) << "No best connection"; |
1167 } | 1168 } |
| 1169 // TODO(honghaiz): rename best_connection_ with selected_connection_ or |
| 1170 // selected_candidate pair_. |
| 1171 SignalSelectedCandidatePairChanged(this, best_connection_); |
1168 } | 1172 } |
1169 | 1173 |
1170 // Warning: UpdateState should eventually be called whenever a connection | 1174 // Warning: UpdateState should eventually be called whenever a connection |
1171 // is added, deleted, or the write state of any connection changes so that the | 1175 // is added, deleted, or the write state of any connection changes so that the |
1172 // transport controller will get the up-to-date channel state. However it | 1176 // transport controller will get the up-to-date channel state. However it |
1173 // should not be called too often; in the case that multiple connection states | 1177 // should not be called too often; in the case that multiple connection states |
1174 // change, it should be called after all the connection states have changed. For | 1178 // change, it should be called after all the connection states have changed. For |
1175 // example, we call this at the end of SortConnections. | 1179 // example, we call this at the end of SortConnections. |
1176 void P2PTransportChannel::UpdateState() { | 1180 void P2PTransportChannel::UpdateState() { |
1177 state_ = ComputeState(); | 1181 state_ = ComputeState(); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 | 1623 |
1620 // During the initial state when nothing has been pinged yet, return the first | 1624 // During the initial state when nothing has been pinged yet, return the first |
1621 // one in the ordered |connections_|. | 1625 // one in the ordered |connections_|. |
1622 return *(std::find_if(connections_.begin(), connections_.end(), | 1626 return *(std::find_if(connections_.begin(), connections_.end(), |
1623 [conn1, conn2](Connection* conn) { | 1627 [conn1, conn2](Connection* conn) { |
1624 return conn == conn1 || conn == conn2; | 1628 return conn == conn1 || conn == conn2; |
1625 })); | 1629 })); |
1626 } | 1630 } |
1627 | 1631 |
1628 } // namespace cricket | 1632 } // namespace cricket |
OLD | NEW |