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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // Called when the socket is currently able to send. | 289 // Called when the socket is currently able to send. |
290 void OnReadyToSend(); | 290 void OnReadyToSend(); |
291 | 291 |
292 // Called when the Connection discovers a local peer reflexive candidate. | 292 // Called when the Connection discovers a local peer reflexive candidate. |
293 // Returns the index of the new local candidate. | 293 // Returns the index of the new local candidate. |
294 size_t AddPrflxCandidate(const Candidate& local); | 294 size_t AddPrflxCandidate(const Candidate& local); |
295 | 295 |
296 void set_candidate_filter(uint32_t candidate_filter) { | 296 void set_candidate_filter(uint32_t candidate_filter) { |
297 candidate_filter_ = candidate_filter; | 297 candidate_filter_ = candidate_filter; |
298 } | 298 } |
| 299 int32_t network_cost() const { return network_cost_; } |
299 | 300 |
300 protected: | 301 protected: |
301 enum { | 302 enum { |
302 MSG_DEAD = 0, | 303 MSG_DEAD = 0, |
303 MSG_FIRST_AVAILABLE | 304 MSG_FIRST_AVAILABLE |
304 }; | 305 }; |
305 | 306 |
306 void set_type(const std::string& type) { type_ = type; } | 307 void set_type(const std::string& type) { type_ = type; } |
307 | 308 |
308 void AddAddress(const rtc::SocketAddress& address, | 309 void AddAddress(const rtc::SocketAddress& address, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 // Information to use when going through a proxy. | 389 // Information to use when going through a proxy. |
389 std::string user_agent_; | 390 std::string user_agent_; |
390 rtc::ProxyInfo proxy_; | 391 rtc::ProxyInfo proxy_; |
391 | 392 |
392 // Candidate filter is pushed down to Port such that each Port could | 393 // Candidate filter is pushed down to Port such that each Port could |
393 // make its own decision on how to create candidates. For example, | 394 // make its own decision on how to create candidates. For example, |
394 // when IceTransportsType is set to relay, both RelayPort and | 395 // when IceTransportsType is set to relay, both RelayPort and |
395 // TurnPort will hide raddr to avoid local address leakage. | 396 // TurnPort will hide raddr to avoid local address leakage. |
396 uint32_t candidate_filter_; | 397 uint32_t candidate_filter_; |
397 | 398 |
| 399 // A virtual cost perceived by the user, usually based on the network type |
| 400 // (WiFi. vs. Cellular). It takes precedence over the priority when |
| 401 // comparing two connections. |
| 402 uint32_t network_cost_; |
| 403 |
398 friend class Connection; | 404 friend class Connection; |
399 }; | 405 }; |
400 | 406 |
401 // Represents a communication link between a port on the local client and a | 407 // Represents a communication link between a port on the local client and a |
402 // port on the remote client. | 408 // port on the remote client. |
403 class Connection : public rtc::MessageHandler, | 409 class Connection : public rtc::MessageHandler, |
404 public sigslot::has_slots<> { | 410 public sigslot::has_slots<> { |
405 public: | 411 public: |
406 struct SentPing { | 412 struct SentPing { |
407 SentPing(const std::string id, uint32_t sent_time) | 413 SentPing(const std::string id, uint32_t sent_time) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 // controlling side. | 559 // controlling side. |
554 sigslot::signal1<Connection*> SignalNominated; | 560 sigslot::signal1<Connection*> SignalNominated; |
555 | 561 |
556 // Invoked when Connection receives STUN error response with 487 code. | 562 // Invoked when Connection receives STUN error response with 487 code. |
557 void HandleRoleConflictFromPeer(); | 563 void HandleRoleConflictFromPeer(); |
558 | 564 |
559 State state() const { return state_; } | 565 State state() const { return state_; } |
560 | 566 |
561 IceMode remote_ice_mode() const { return remote_ice_mode_; } | 567 IceMode remote_ice_mode() const { return remote_ice_mode_; } |
562 | 568 |
| 569 uint32_t ComputeNetworkCost() const; |
| 570 |
563 // Update the ICE password of the remote candidate if |ice_ufrag| matches | 571 // Update the ICE password of the remote candidate if |ice_ufrag| matches |
564 // the candidate's ufrag, and the candidate's passwrod has not been set. | 572 // the candidate's ufrag, and the candidate's passwrod has not been set. |
565 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, | 573 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, |
566 const std::string& ice_pwd); | 574 const std::string& ice_pwd); |
567 | 575 |
568 // If |remote_candidate_| is peer reflexive and is equivalent to | 576 // If |remote_candidate_| is peer reflexive and is equivalent to |
569 // |new_candidate| except the type, update |remote_candidate_| to | 577 // |new_candidate| except the type, update |remote_candidate_| to |
570 // |new_candidate|. | 578 // |new_candidate|. |
571 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); | 579 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); |
572 | 580 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 const rtc::PacketOptions& options) override; | 661 const rtc::PacketOptions& options) override; |
654 int GetError() override { return error_; } | 662 int GetError() override { return error_; } |
655 | 663 |
656 private: | 664 private: |
657 int error_ = 0; | 665 int error_ = 0; |
658 }; | 666 }; |
659 | 667 |
660 } // namespace cricket | 668 } // namespace cricket |
661 | 669 |
662 #endif // WEBRTC_P2P_BASE_PORT_H_ | 670 #endif // WEBRTC_P2P_BASE_PORT_H_ |
OLD | NEW |