Chromium Code Reviews| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. | 198 // Public for unit tests. |
| 213 void set_remote_supports_renomination(bool remote_supports_renomination) { | 199 bool set_remote_supports_renomination(bool remote_supports_renomination) { |
|
Taylor Brandstetter
2016/08/08 22:28:16
Can the unit tests just use SetRemoteIceParameters
honghaiz3
2016/08/11 04:57:57
Done.
| |
| 214 remote_supports_renomination_ = remote_supports_renomination; | 200 if (remote_ice_parameters_.empty()) { |
| 201 return false; | |
| 202 } | |
| 203 remote_ice_parameters_.back().renomination = remote_supports_renomination; | |
| 204 return true; | |
|
pthatcher1
2016/08/08 21:56:23
Can the unit tests just use SetRemoteIceParameters
honghaiz3
2016/08/11 04:57:57
Done.
| |
| 215 } | 205 } |
| 216 | 206 |
| 217 private: | 207 private: |
| 218 rtc::Thread* thread() const { return worker_thread_; } | 208 rtc::Thread* thread() const { return worker_thread_; } |
| 219 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } | 209 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
| 220 | 210 |
| 221 // A transport channel is weak if the current best connection is either | 211 // 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. | 212 // not receiving or not writable, or if there is no best connection at all. |
| 223 bool weak() const; | 213 bool weak() const; |
| 224 // Returns true if it's possible to send packets on this channel. | 214 // Returns true if it's possible to send packets on this channel. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 std::set<Connection*> pinged_connections_; | 378 std::set<Connection*> pinged_connections_; |
| 389 std::set<Connection*> unpinged_connections_; | 379 std::set<Connection*> unpinged_connections_; |
| 390 | 380 |
| 391 Connection* selected_connection_ = nullptr; | 381 Connection* selected_connection_ = nullptr; |
| 392 | 382 |
| 393 std::vector<RemoteCandidate> remote_candidates_; | 383 std::vector<RemoteCandidate> remote_candidates_; |
| 394 bool sort_dirty_; // indicates whether another sort is needed right now | 384 bool sort_dirty_; // indicates whether another sort is needed right now |
| 395 bool had_connection_ = false; // if connections_ has ever been nonempty | 385 bool had_connection_ = false; // if connections_ has ever been nonempty |
| 396 typedef std::map<rtc::Socket::Option, int> OptionMap; | 386 typedef std::map<rtc::Socket::Option, int> OptionMap; |
| 397 OptionMap options_; | 387 OptionMap options_; |
| 398 std::string ice_ufrag_; | 388 IceParameters ice_parameters_; |
| 399 std::string ice_pwd_; | |
| 400 std::vector<IceParameters> remote_ice_parameters_; | 389 std::vector<IceParameters> remote_ice_parameters_; |
| 401 IceMode remote_ice_mode_; | 390 IceMode remote_ice_mode_; |
| 402 IceRole ice_role_; | 391 IceRole ice_role_; |
| 403 uint64_t tiebreaker_; | 392 uint64_t tiebreaker_; |
| 404 IceGatheringState gathering_state_; | 393 IceGatheringState gathering_state_; |
| 405 | 394 |
| 406 int check_receiving_interval_; | 395 int check_receiving_interval_; |
| 407 int64_t last_ping_sent_ms_ = 0; | 396 int64_t last_ping_sent_ms_ = 0; |
| 408 int weak_ping_interval_ = WEAK_PING_INTERVAL; | 397 int weak_ping_interval_ = WEAK_PING_INTERVAL; |
| 409 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 398 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
| 410 IceConfig config_; | 399 IceConfig config_; |
| 411 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 400 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
| 412 bool started_pinging_ = false; | 401 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 | 402 // The value put in the "nomination" attribute for the next nominated |
| 418 // connection. A zero-value indicates the connection will not be nominated. | 403 // connection. A zero-value indicates the connection will not be nominated. |
| 419 uint32_t nomination_ = 0; | 404 uint32_t nomination_ = 0; |
| 420 | 405 |
| 421 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 406 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
| 422 }; | 407 }; |
| 423 | 408 |
| 424 } // namespace cricket | 409 } // namespace cricket |
| 425 | 410 |
| 426 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 411 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
| OLD | NEW |