| 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 25 matching lines...) Expand all Loading... |
| 36 #include "webrtc/base/asyncpacketsocket.h" | 36 #include "webrtc/base/asyncpacketsocket.h" |
| 37 #include "webrtc/base/sigslot.h" | 37 #include "webrtc/base/sigslot.h" |
| 38 | 38 |
| 39 namespace cricket { | 39 namespace cricket { |
| 40 | 40 |
| 41 extern const int WEAK_PING_INTERVAL; | 41 extern const int WEAK_PING_INTERVAL; |
| 42 extern const int STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL; | 42 extern const int STABILIZING_WRITABLE_CONNECTION_PING_INTERVAL; |
| 43 extern const int STABLE_WRITABLE_CONNECTION_PING_INTERVAL; | 43 extern const int STABLE_WRITABLE_CONNECTION_PING_INTERVAL; |
| 44 static const int MIN_PINGS_AT_WEAK_PING_INTERVAL = 3; | 44 static const int MIN_PINGS_AT_WEAK_PING_INTERVAL = 3; |
| 45 | 45 |
| 46 struct IceParameters { | |
| 47 std::string ufrag; | |
| 48 std::string pwd; | |
| 49 IceParameters(const std::string& ice_ufrag, const std::string& ice_pwd) | |
| 50 : ufrag(ice_ufrag), pwd(ice_pwd) {} | |
| 51 | |
| 52 bool operator==(const IceParameters& other) { | |
| 53 return ufrag == other.ufrag && pwd == other.pwd; | |
| 54 } | |
| 55 bool operator!=(const IceParameters& other) { return !(*this == other); } | |
| 56 }; | |
| 57 | |
| 58 // Adds the port on which the candidate originated. | 46 // Adds the port on which the candidate originated. |
| 59 class RemoteCandidate : public Candidate { | 47 class RemoteCandidate : public Candidate { |
| 60 public: | 48 public: |
| 61 RemoteCandidate(const Candidate& c, PortInterface* origin_port) | 49 RemoteCandidate(const Candidate& c, PortInterface* origin_port) |
| 62 : Candidate(c), origin_port_(origin_port) {} | 50 : Candidate(c), origin_port_(origin_port) {} |
| 63 | 51 |
| 64 PortInterface* origin_port() { return origin_port_; } | 52 PortInterface* origin_port() { return origin_port_; } |
| 65 | 53 |
| 66 private: | 54 private: |
| 67 PortInterface* origin_port_; | 55 PortInterface* origin_port_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 int component, | 69 int component, |
| 82 P2PTransport* transport, | 70 P2PTransport* transport, |
| 83 PortAllocator* allocator); | 71 PortAllocator* allocator); |
| 84 virtual ~P2PTransportChannel(); | 72 virtual ~P2PTransportChannel(); |
| 85 | 73 |
| 86 // From TransportChannelImpl: | 74 // From TransportChannelImpl: |
| 87 TransportChannelState GetState() const override; | 75 TransportChannelState GetState() const override; |
| 88 void SetIceRole(IceRole role) override; | 76 void SetIceRole(IceRole role) override; |
| 89 IceRole GetIceRole() const override { return ice_role_; } | 77 IceRole GetIceRole() const override { return ice_role_; } |
| 90 void SetIceTiebreaker(uint64_t tiebreaker) override; | 78 void SetIceTiebreaker(uint64_t tiebreaker) override; |
| 91 void SetIceCredentials(const std::string& ice_ufrag, | 79 void SetIceParameters(const IceParameters& ice_params) override; |
| 92 const std::string& ice_pwd) override; | 80 void SetRemoteIceParameters(const IceParameters& ice_params) override; |
| 93 void SetRemoteIceCredentials(const std::string& ice_ufrag, | |
| 94 const std::string& ice_pwd) override; | |
| 95 void SetRemoteIceMode(IceMode mode) override; | 81 void SetRemoteIceMode(IceMode mode) override; |
| 96 // TODO(deadbeef): Deprecated. Remove when Chromium's | 82 // TODO(deadbeef): Deprecated. Remove when Chromium's |
| 97 // IceTransportChannel does not depend on this. | 83 // IceTransportChannel does not depend on this. |
| 98 void Connect() {} | 84 void Connect() {} |
| 99 void MaybeStartGathering() override; | 85 void MaybeStartGathering() override; |
| 100 IceGatheringState gathering_state() const override { | 86 IceGatheringState gathering_state() const override { |
| 101 return gathering_state_; | 87 return gathering_state_; |
| 102 } | 88 } |
| 103 void AddRemoteCandidate(const Candidate& candidate) override; | 89 void AddRemoteCandidate(const Candidate& candidate) override; |
| 104 void RemoveRemoteCandidate(const Candidate& candidate) override; | 90 void RemoveRemoteCandidate(const Candidate& candidate) override; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // Public for unit tests. | 188 // Public for unit tests. |
| 203 PortAllocatorSession* allocator_session() { | 189 PortAllocatorSession* allocator_session() { |
| 204 return allocator_sessions_.back().get(); | 190 return allocator_sessions_.back().get(); |
| 205 } | 191 } |
| 206 | 192 |
| 207 // Public for unit tests. | 193 // Public for unit tests. |
| 208 const std::vector<RemoteCandidate>& remote_candidates() const { | 194 const std::vector<RemoteCandidate>& remote_candidates() const { |
| 209 return remote_candidates_; | 195 return remote_candidates_; |
| 210 } | 196 } |
| 211 | 197 |
| 212 // Public for unit tests. | |
| 213 void set_remote_supports_renomination(bool remote_supports_renomination) { | |
| 214 remote_supports_renomination_ = remote_supports_renomination; | |
| 215 } | |
| 216 | |
| 217 private: | 198 private: |
| 218 rtc::Thread* thread() const { return worker_thread_; } | 199 rtc::Thread* thread() const { return worker_thread_; } |
| 219 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } | 200 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
| 220 | 201 |
| 221 // A transport channel is weak if the current best connection is either | 202 // A transport channel is weak if the current best connection is either |
| 222 // not receiving or not writable, or if there is no best connection at all. | 203 // not receiving or not writable, or if there is no best connection at all. |
| 223 bool weak() const; | 204 bool weak() const; |
| 224 // Returns true if it's possible to send packets on |connection|. | 205 // Returns true if it's possible to send packets on |connection|. |
| 225 bool ReadyToSend(Connection* connection) const; | 206 bool ReadyToSend(Connection* connection) const; |
| 226 void UpdateConnectionStates(); | 207 void UpdateConnectionStates(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 std::set<Connection*> pinged_connections_; | 369 std::set<Connection*> pinged_connections_; |
| 389 std::set<Connection*> unpinged_connections_; | 370 std::set<Connection*> unpinged_connections_; |
| 390 | 371 |
| 391 Connection* selected_connection_ = nullptr; | 372 Connection* selected_connection_ = nullptr; |
| 392 | 373 |
| 393 std::vector<RemoteCandidate> remote_candidates_; | 374 std::vector<RemoteCandidate> remote_candidates_; |
| 394 bool sort_dirty_; // indicates whether another sort is needed right now | 375 bool sort_dirty_; // indicates whether another sort is needed right now |
| 395 bool had_connection_ = false; // if connections_ has ever been nonempty | 376 bool had_connection_ = false; // if connections_ has ever been nonempty |
| 396 typedef std::map<rtc::Socket::Option, int> OptionMap; | 377 typedef std::map<rtc::Socket::Option, int> OptionMap; |
| 397 OptionMap options_; | 378 OptionMap options_; |
| 398 std::string ice_ufrag_; | 379 IceParameters ice_parameters_; |
| 399 std::string ice_pwd_; | |
| 400 std::vector<IceParameters> remote_ice_parameters_; | 380 std::vector<IceParameters> remote_ice_parameters_; |
| 401 IceMode remote_ice_mode_; | 381 IceMode remote_ice_mode_; |
| 402 IceRole ice_role_; | 382 IceRole ice_role_; |
| 403 uint64_t tiebreaker_; | 383 uint64_t tiebreaker_; |
| 404 IceGatheringState gathering_state_; | 384 IceGatheringState gathering_state_; |
| 405 | 385 |
| 406 int check_receiving_interval_; | 386 int check_receiving_interval_; |
| 407 int64_t last_ping_sent_ms_ = 0; | 387 int64_t last_ping_sent_ms_ = 0; |
| 408 int weak_ping_interval_ = WEAK_PING_INTERVAL; | 388 int weak_ping_interval_ = WEAK_PING_INTERVAL; |
| 409 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 389 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
| 410 IceConfig config_; | 390 IceConfig config_; |
| 411 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 391 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
| 412 bool started_pinging_ = false; | 392 bool started_pinging_ = false; |
| 413 // TODO(honghaiz): Put this and ICE role inside ICEParameters and rename this | |
| 414 // as renomination. Set its value in subsequent CLs based on signaling | |
| 415 // exchange. | |
| 416 bool remote_supports_renomination_ = false; | |
| 417 // The value put in the "nomination" attribute for the next nominated | 393 // The value put in the "nomination" attribute for the next nominated |
| 418 // connection. A zero-value indicates the connection will not be nominated. | 394 // connection. A zero-value indicates the connection will not be nominated. |
| 419 uint32_t nomination_ = 0; | 395 uint32_t nomination_ = 0; |
| 420 | 396 |
| 421 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 397 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
| 422 }; | 398 }; |
| 423 | 399 |
| 424 } // namespace cricket | 400 } // namespace cricket |
| 425 | 401 |
| 426 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 402 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| OLD | NEW |