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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 enum IcePriorityValue { | 83 enum IcePriorityValue { |
84 // The reason we are choosing Relay preference 2 is because, we can run | 84 // The reason we are choosing Relay preference 2 is because, we can run |
85 // Relay from client to server on UDP/TCP/TLS. To distinguish the transport | 85 // Relay from client to server on UDP/TCP/TLS. To distinguish the transport |
86 // protocol, we prefer UDP over TCP over TLS. | 86 // protocol, we prefer UDP over TCP over TLS. |
87 // For UDP ICE_TYPE_PREFERENCE_RELAY will be 2. | 87 // For UDP ICE_TYPE_PREFERENCE_RELAY will be 2. |
88 // For TCP ICE_TYPE_PREFERENCE_RELAY will be 1. | 88 // For TCP ICE_TYPE_PREFERENCE_RELAY will be 1. |
89 // For TLS ICE_TYPE_PREFERENCE_RELAY will be 0. | 89 // For TLS ICE_TYPE_PREFERENCE_RELAY will be 0. |
90 // Check turnport.cc for setting these values. | 90 // Check turnport.cc for setting these values. |
91 ICE_TYPE_PREFERENCE_RELAY = 2, | 91 ICE_TYPE_PREFERENCE_RELAY = 2, |
| 92 ICE_TYPE_PREFERENCE_PRFLX_TCP = 80, |
92 ICE_TYPE_PREFERENCE_HOST_TCP = 90, | 93 ICE_TYPE_PREFERENCE_HOST_TCP = 90, |
93 ICE_TYPE_PREFERENCE_SRFLX = 100, | 94 ICE_TYPE_PREFERENCE_SRFLX = 100, |
94 ICE_TYPE_PREFERENCE_PRFLX = 110, | 95 ICE_TYPE_PREFERENCE_PRFLX = 110, |
95 ICE_TYPE_PREFERENCE_HOST = 126 | 96 ICE_TYPE_PREFERENCE_HOST = 126 |
96 }; | 97 }; |
97 | 98 |
98 const char* ProtoToString(ProtocolType proto); | 99 const char* ProtoToString(ProtocolType proto); |
99 bool StringToProto(const char* value, ProtocolType* proto); | 100 bool StringToProto(const char* value, ProtocolType* proto); |
100 | 101 |
101 struct ProtocolAddress { | 102 struct ProtocolAddress { |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 647 |
647 Port* port_; | 648 Port* port_; |
648 size_t local_candidate_index_; | 649 size_t local_candidate_index_; |
649 Candidate remote_candidate_; | 650 Candidate remote_candidate_; |
650 | 651 |
651 ConnectionInfo stats_; | 652 ConnectionInfo stats_; |
652 rtc::RateTracker recv_rate_tracker_; | 653 rtc::RateTracker recv_rate_tracker_; |
653 rtc::RateTracker send_rate_tracker_; | 654 rtc::RateTracker send_rate_tracker_; |
654 | 655 |
655 private: | 656 private: |
| 657 // Update the local candidate based on the mapped address attribute. |
| 658 // If the local candidate changed, fires SignalStateChange. |
| 659 void MaybeUpdateLocalCandidate(ConnectionRequest* request, |
| 660 StunMessage* response); |
| 661 |
656 WriteState write_state_; | 662 WriteState write_state_; |
657 bool receiving_; | 663 bool receiving_; |
658 bool connected_; | 664 bool connected_; |
659 bool pruned_; | 665 bool pruned_; |
660 // By default |use_candidate_attr_| flag will be true, | 666 // By default |use_candidate_attr_| flag will be true, |
661 // as we will be using aggressive nomination. | 667 // as we will be using aggressive nomination. |
662 // But when peer is ice-lite, this flag "must" be initialized to false and | 668 // But when peer is ice-lite, this flag "must" be initialized to false and |
663 // turn on when connection becomes "best connection". | 669 // turn on when connection becomes "best connection". |
664 bool use_candidate_attr_; | 670 bool use_candidate_attr_; |
665 // Used by the controlling side to indicate that this connection will be | 671 // Used by the controlling side to indicate that this connection will be |
(...skipping 14 matching lines...) Expand all Loading... |
680 int rtt_; | 686 int rtt_; |
681 int rtt_samples_ = 0; | 687 int rtt_samples_ = 0; |
682 int64_t last_ping_sent_; // last time we sent a ping to the other side | 688 int64_t last_ping_sent_; // last time we sent a ping to the other side |
683 int64_t last_ping_received_; // last time we received a ping from the other | 689 int64_t last_ping_received_; // last time we received a ping from the other |
684 // side | 690 // side |
685 int64_t last_data_received_; | 691 int64_t last_data_received_; |
686 int64_t last_ping_response_received_; | 692 int64_t last_ping_response_received_; |
687 int64_t receiving_unchanged_since_ = 0; | 693 int64_t receiving_unchanged_since_ = 0; |
688 std::vector<SentPing> pings_since_last_response_; | 694 std::vector<SentPing> pings_since_last_response_; |
689 | 695 |
690 void MaybeAddPrflxCandidate(ConnectionRequest* request, | |
691 StunMessage* response); | |
692 | |
693 bool reported_; | 696 bool reported_; |
694 State state_; | 697 State state_; |
695 // Time duration to switch from receiving to not receiving. | 698 // Time duration to switch from receiving to not receiving. |
696 int receiving_timeout_; | 699 int receiving_timeout_; |
697 int64_t time_created_ms_; | 700 int64_t time_created_ms_; |
698 int num_pings_sent_ = 0; | 701 int num_pings_sent_ = 0; |
699 | 702 |
700 friend class Port; | 703 friend class Port; |
701 friend class ConnectionRequest; | 704 friend class ConnectionRequest; |
702 }; | 705 }; |
703 | 706 |
704 // ProxyConnection defers all the interesting work to the port. | 707 // ProxyConnection defers all the interesting work to the port. |
705 class ProxyConnection : public Connection { | 708 class ProxyConnection : public Connection { |
706 public: | 709 public: |
707 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); | 710 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); |
708 | 711 |
709 int Send(const void* data, | 712 int Send(const void* data, |
710 size_t size, | 713 size_t size, |
711 const rtc::PacketOptions& options) override; | 714 const rtc::PacketOptions& options) override; |
712 int GetError() override { return error_; } | 715 int GetError() override { return error_; } |
713 | 716 |
714 private: | 717 private: |
715 int error_ = 0; | 718 int error_ = 0; |
716 }; | 719 }; |
717 | 720 |
718 } // namespace cricket | 721 } // namespace cricket |
719 | 722 |
720 #endif // WEBRTC_P2P_BASE_PORT_H_ | 723 #endif // WEBRTC_P2P_BASE_PORT_H_ |
OLD | NEW |