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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void MaybeStartGathering() override; | 97 void MaybeStartGathering() override; |
98 IceGatheringState gathering_state() const override { | 98 IceGatheringState gathering_state() const override { |
99 return gathering_state_; | 99 return gathering_state_; |
100 } | 100 } |
101 void AddRemoteCandidate(const Candidate& candidate) override; | 101 void AddRemoteCandidate(const Candidate& candidate) override; |
102 void RemoveRemoteCandidate(const Candidate& candidate) override; | 102 void RemoveRemoteCandidate(const Candidate& candidate) override; |
103 // Sets the parameters in IceConfig. We do not set them blindly. Instead, we | 103 // Sets the parameters in IceConfig. We do not set them blindly. Instead, we |
104 // only update the parameter if it is considered set in |config|. For example, | 104 // only update the parameter if it is considered set in |config|. For example, |
105 // a negative value of receiving_timeout will be considered "not set" and we | 105 // a negative value of receiving_timeout will be considered "not set" and we |
106 // will not use it to update the respective parameter in |config_|. | 106 // will not use it to update the respective parameter in |config_|. |
| 107 // TODO(deadbeef): Use rtc::Optional instead of negative values. |
107 void SetIceConfig(const IceConfig& config) override; | 108 void SetIceConfig(const IceConfig& config) override; |
108 const IceConfig& config() const; | 109 const IceConfig& config() const; |
109 | 110 |
110 // From TransportChannel: | 111 // From TransportChannel: |
111 int SendPacket(const char* data, | 112 int SendPacket(const char* data, |
112 size_t len, | 113 size_t len, |
113 const rtc::PacketOptions& options, | 114 const rtc::PacketOptions& options, |
114 int flags) override; | 115 int flags) override; |
115 int SetOption(rtc::Socket::Option opt, int value) override; | 116 int SetOption(rtc::Socket::Option opt, int value) override; |
116 bool GetOption(rtc::Socket::Option opt, int* value) override; | 117 bool GetOption(rtc::Socket::Option opt, int* value) override; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 private: | 204 private: |
204 rtc::Thread* thread() { return worker_thread_; } | 205 rtc::Thread* thread() { return worker_thread_; } |
205 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } | 206 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
206 | 207 |
207 // A transport channel is weak if the current best connection is either | 208 // A transport channel is weak if the current best connection is either |
208 // not receiving or not writable, or if there is no best connection at all. | 209 // not receiving or not writable, or if there is no best connection at all. |
209 bool weak() const; | 210 bool weak() const; |
210 void UpdateConnectionStates(); | 211 void UpdateConnectionStates(); |
211 void RequestSort(); | 212 void RequestSort(); |
| 213 |
| 214 // The methods below return a positive value if a is preferable to b, |
| 215 // a negative value if b is preferable, and 0 if they're equally preferable. |
| 216 int CompareConnectionStates(const cricket::Connection* a, |
| 217 const cricket::Connection* b) const; |
| 218 int CompareConnectionCandidates(const cricket::Connection* a, |
| 219 const cricket::Connection* b) const; |
| 220 // Compares first on states, then on candidates, then on RTT. |
| 221 int CompareConnections(const cricket::Connection* a, |
| 222 const cricket::Connection* b) const; |
| 223 bool PresumedWritable(const cricket::Connection* conn) const; |
| 224 |
| 225 bool ShouldSwitchSelectedConnection(const cricket::Connection* selected, |
| 226 const cricket::Connection* conn) const; |
212 void SortConnections(); | 227 void SortConnections(); |
213 void SwitchBestConnectionTo(Connection* conn); | 228 void SwitchBestConnectionTo(Connection* conn); |
214 void UpdateState(); | 229 void UpdateState(); |
215 void HandleAllTimedOut(); | 230 void HandleAllTimedOut(); |
216 void MaybeStopPortAllocatorSessions(); | 231 void MaybeStopPortAllocatorSessions(); |
217 TransportChannelState ComputeState() const; | 232 TransportChannelState ComputeState() const; |
218 | 233 |
219 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; | 234 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; |
220 bool CreateConnections(const Candidate& remote_candidate, | 235 bool CreateConnections(const Candidate& remote_candidate, |
221 PortInterface* origin_port); | 236 PortInterface* origin_port); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 358 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
344 IceConfig config_; | 359 IceConfig config_; |
345 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 360 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
346 | 361 |
347 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 362 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
348 }; | 363 }; |
349 | 364 |
350 } // namespace cricket | 365 } // namespace cricket |
351 | 366 |
352 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 367 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |