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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 if (networks.find(network) == networks.end()) { | 350 if (networks.find(network) == networks.end()) { |
351 networks.insert(network); | 351 networks.insert(network); |
352 } else { | 352 } else { |
353 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as " | 353 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as " |
354 << network->ToString() | 354 << network->ToString() |
355 << " has more than 1 connection."; | 355 << " has more than 1 connection."; |
356 return TransportChannelState::STATE_CONNECTING; | 356 return TransportChannelState::STATE_CONNECTING; |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel."; | |
361 return TransportChannelState::STATE_COMPLETED; | 360 return TransportChannelState::STATE_COMPLETED; |
362 } | 361 } |
363 | 362 |
364 void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag, | 363 void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag, |
365 const std::string& ice_pwd) { | 364 const std::string& ice_pwd) { |
366 ASSERT(worker_thread_ == rtc::Thread::Current()); | 365 ASSERT(worker_thread_ == rtc::Thread::Current()); |
367 ice_ufrag_ = ice_ufrag; | 366 ice_ufrag_ = ice_ufrag; |
368 ice_pwd_ = ice_pwd; | 367 ice_pwd_ = ice_pwd; |
369 // Note: Candidate gathering will restart when MaybeStartGathering is next | 368 // Note: Candidate gathering will restart when MaybeStartGathering is next |
370 // called. | 369 // called. |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 last_sent_packet_id_); | 1201 last_sent_packet_id_); |
1203 } | 1202 } |
1204 | 1203 |
1205 // Warning: UpdateState should eventually be called whenever a connection | 1204 // Warning: UpdateState should eventually be called whenever a connection |
1206 // is added, deleted, or the write state of any connection changes so that the | 1205 // is added, deleted, or the write state of any connection changes so that the |
1207 // transport controller will get the up-to-date channel state. However it | 1206 // transport controller will get the up-to-date channel state. However it |
1208 // should not be called too often; in the case that multiple connection states | 1207 // should not be called too often; in the case that multiple connection states |
1209 // change, it should be called after all the connection states have changed. For | 1208 // change, it should be called after all the connection states have changed. For |
1210 // example, we call this at the end of SortConnections. | 1209 // example, we call this at the end of SortConnections. |
1211 void P2PTransportChannel::UpdateState() { | 1210 void P2PTransportChannel::UpdateState() { |
1212 state_ = ComputeState(); | 1211 TransportChannelState state = ComputeState(); |
| 1212 if (state_ != state) { |
| 1213 LOG_J(LS_INFO, this) << "Transport channel state changed from " << state_ |
| 1214 << " to " << state; |
| 1215 state_ = state; |
| 1216 SignalStateChanged(this); |
| 1217 } |
1213 | 1218 |
1214 bool writable = best_connection_ && best_connection_->writable(); | 1219 bool writable = best_connection_ && best_connection_->writable(); |
1215 set_writable(writable); | 1220 set_writable(writable); |
1216 | 1221 |
1217 bool receiving = false; | 1222 bool receiving = false; |
1218 for (const Connection* connection : connections_) { | 1223 for (const Connection* connection : connections_) { |
1219 if (connection->receiving()) { | 1224 if (connection->receiving()) { |
1220 receiving = true; | 1225 receiving = true; |
1221 break; | 1226 break; |
1222 } | 1227 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 // best connection in order to avoid switching between fairly similar ones. | 1470 // best connection in order to avoid switching between fairly similar ones. |
1466 // Since this connection is no longer an option, we can just set best to NULL | 1471 // Since this connection is no longer an option, we can just set best to NULL |
1467 // and re-choose a best assuming that there was no best connection. | 1472 // and re-choose a best assuming that there was no best connection. |
1468 if (best_connection_ == connection) { | 1473 if (best_connection_ == connection) { |
1469 LOG(LS_INFO) << "Best connection destroyed. Will choose a new one."; | 1474 LOG(LS_INFO) << "Best connection destroyed. Will choose a new one."; |
1470 SwitchBestConnectionTo(NULL); | 1475 SwitchBestConnectionTo(NULL); |
1471 RequestSort(); | 1476 RequestSort(); |
1472 } | 1477 } |
1473 | 1478 |
1474 UpdateState(); | 1479 UpdateState(); |
1475 // SignalConnectionRemoved should be called after the channel state is | |
1476 // updated because the receiver of the event may access the channel state. | |
1477 SignalConnectionRemoved(this); | |
1478 } | 1480 } |
1479 | 1481 |
1480 // When a port is destroyed remove it from our list of ports to use for | 1482 // When a port is destroyed remove it from our list of ports to use for |
1481 // connection attempts. | 1483 // connection attempts. |
1482 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { | 1484 void P2PTransportChannel::OnPortDestroyed(PortInterface* port) { |
1483 ASSERT(worker_thread_ == rtc::Thread::Current()); | 1485 ASSERT(worker_thread_ == rtc::Thread::Current()); |
1484 | 1486 |
1485 // Remove this port from the list (if we didn't drop it already). | 1487 // Remove this port from the list (if we didn't drop it already). |
1486 std::vector<PortInterface*>::iterator iter = | 1488 std::vector<PortInterface*>::iterator iter = |
1487 std::find(ports_.begin(), ports_.end(), port); | 1489 std::find(ports_.begin(), ports_.end(), port); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 | 1660 |
1659 // During the initial state when nothing has been pinged yet, return the first | 1661 // During the initial state when nothing has been pinged yet, return the first |
1660 // one in the ordered |connections_|. | 1662 // one in the ordered |connections_|. |
1661 return *(std::find_if(connections_.begin(), connections_.end(), | 1663 return *(std::find_if(connections_.begin(), connections_.end(), |
1662 [conn1, conn2](Connection* conn) { | 1664 [conn1, conn2](Connection* conn) { |
1663 return conn == conn1 || conn == conn2; | 1665 return conn == conn1 || conn == conn2; |
1664 })); | 1666 })); |
1665 } | 1667 } |
1666 | 1668 |
1667 } // namespace cricket | 1669 } // namespace cricket |
OLD | NEW |