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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // From TransportChannelImpl: | 86 // From TransportChannelImpl: |
87 TransportChannelState GetState() const override; | 87 TransportChannelState GetState() const override; |
88 void SetIceRole(IceRole role) override; | 88 void SetIceRole(IceRole role) override; |
89 IceRole GetIceRole() const override { return ice_role_; } | 89 IceRole GetIceRole() const override { return ice_role_; } |
90 void SetIceTiebreaker(uint64_t tiebreaker) override; | 90 void SetIceTiebreaker(uint64_t tiebreaker) override; |
91 void SetIceCredentials(const std::string& ice_ufrag, | 91 void SetIceCredentials(const std::string& ice_ufrag, |
92 const std::string& ice_pwd) override; | 92 const std::string& ice_pwd) override; |
93 void SetRemoteIceCredentials(const std::string& ice_ufrag, | 93 void SetRemoteIceCredentials(const std::string& ice_ufrag, |
94 const std::string& ice_pwd) override; | 94 const std::string& ice_pwd) override; |
95 void SetRemoteIceMode(IceMode mode) override; | 95 void SetRemoteIceMode(IceMode mode) override; |
96 void Connect() override; | |
97 void MaybeStartGathering() override; | 96 void MaybeStartGathering() override; |
98 IceGatheringState gathering_state() const override { | 97 IceGatheringState gathering_state() const override { |
99 return gathering_state_; | 98 return gathering_state_; |
100 } | 99 } |
101 void AddRemoteCandidate(const Candidate& candidate) override; | 100 void AddRemoteCandidate(const Candidate& candidate) override; |
102 void RemoveRemoteCandidate(const Candidate& candidate) override; | 101 void RemoveRemoteCandidate(const Candidate& candidate) override; |
103 // Sets the parameters in IceConfig. We do not set them blindly. Instead, we | 102 // 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, | 103 // 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 | 104 // 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_|. | 105 // will not use it to update the respective parameter in |config_|. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 206 |
208 private: | 207 private: |
209 rtc::Thread* thread() { return worker_thread_; } | 208 rtc::Thread* thread() { return worker_thread_; } |
210 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } | 209 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } |
211 | 210 |
212 // 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 |
213 // 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. |
214 bool weak() const; | 213 bool weak() const; |
215 void UpdateConnectionStates(); | 214 void UpdateConnectionStates(); |
216 void RequestSort(); | 215 void RequestSort(); |
| 216 // Start pinging if we haven't already started, and we now have a connection |
| 217 // that's pingable. |
| 218 void MaybeStartPinging(); |
217 | 219 |
218 // The methods below return a positive value if a is preferable to b, | 220 // The methods below return a positive value if a is preferable to b, |
219 // a negative value if b is preferable, and 0 if they're equally preferable. | 221 // a negative value if b is preferable, and 0 if they're equally preferable. |
220 int CompareConnectionStates(const cricket::Connection* a, | 222 int CompareConnectionStates(const cricket::Connection* a, |
221 const cricket::Connection* b) const; | 223 const cricket::Connection* b) const; |
222 int CompareConnectionCandidates(const cricket::Connection* a, | 224 int CompareConnectionCandidates(const cricket::Connection* a, |
223 const cricket::Connection* b) const; | 225 const cricket::Connection* b) const; |
224 // Compares two connections based on the connection states | 226 // Compares two connections based on the connection states |
225 // (writable/receiving/connected), nomination states, last data received time, | 227 // (writable/receiving/connected), nomination states, last data received time, |
226 // and static preferences. Does not include latency. Used by both sorting | 228 // and static preferences. Does not include latency. Used by both sorting |
(...skipping 18 matching lines...) Expand all Loading... |
245 PortInterface* origin_port); | 247 PortInterface* origin_port); |
246 bool CreateConnection(PortInterface* port, | 248 bool CreateConnection(PortInterface* port, |
247 const Candidate& remote_candidate, | 249 const Candidate& remote_candidate, |
248 PortInterface* origin_port); | 250 PortInterface* origin_port); |
249 bool FindConnection(cricket::Connection* connection) const; | 251 bool FindConnection(cricket::Connection* connection) const; |
250 | 252 |
251 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); | 253 uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); |
252 bool IsDuplicateRemoteCandidate(const Candidate& candidate); | 254 bool IsDuplicateRemoteCandidate(const Candidate& candidate); |
253 void RememberRemoteCandidate(const Candidate& remote_candidate, | 255 void RememberRemoteCandidate(const Candidate& remote_candidate, |
254 PortInterface* origin_port); | 256 PortInterface* origin_port); |
255 bool IsPingable(Connection* conn, int64_t now); | 257 bool IsPingable(const Connection* conn, int64_t now) const; |
256 bool IsSelectedConnectionPingable(int64_t now); | 258 bool IsSelectedConnectionPingable(int64_t now); |
257 int CalculateActiveWritablePingInterval(Connection* conn, int64_t now); | 259 int CalculateActiveWritablePingInterval(const Connection* conn, |
| 260 int64_t now) const; |
258 void PingConnection(Connection* conn); | 261 void PingConnection(Connection* conn); |
259 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); | 262 void AddAllocatorSession(std::unique_ptr<PortAllocatorSession> session); |
260 void AddConnection(Connection* connection); | 263 void AddConnection(Connection* connection); |
261 | 264 |
262 void OnPortReady(PortAllocatorSession *session, PortInterface* port); | 265 void OnPortReady(PortAllocatorSession *session, PortInterface* port); |
263 void OnCandidatesReady(PortAllocatorSession *session, | 266 void OnCandidatesReady(PortAllocatorSession *session, |
264 const std::vector<Candidate>& candidates); | 267 const std::vector<Candidate>& candidates); |
265 void OnCandidatesAllocationDone(PortAllocatorSession* session); | 268 void OnCandidatesAllocationDone(PortAllocatorSession* session); |
266 void OnUnknownAddress(PortInterface* port, | 269 void OnUnknownAddress(PortInterface* port, |
267 const rtc::SocketAddress& addr, | 270 const rtc::SocketAddress& addr, |
(...skipping 15 matching lines...) Expand all Loading... |
283 void OnNominated(Connection* conn); | 286 void OnNominated(Connection* conn); |
284 | 287 |
285 void OnMessage(rtc::Message* pmsg) override; | 288 void OnMessage(rtc::Message* pmsg) override; |
286 void OnSort(); | 289 void OnSort(); |
287 void OnCheckAndPing(); | 290 void OnCheckAndPing(); |
288 | 291 |
289 // Returns true if the new_connection should be selected for transmission. | 292 // Returns true if the new_connection should be selected for transmission. |
290 bool ShouldSwitchSelectedConnection(Connection* new_connection) const; | 293 bool ShouldSwitchSelectedConnection(Connection* new_connection) const; |
291 | 294 |
292 void PruneConnections(); | 295 void PruneConnections(); |
293 bool IsBackupConnection(Connection* conn) const; | 296 bool IsBackupConnection(const Connection* conn) const; |
294 | 297 |
295 Connection* FindConnectionToPing(int64_t now); | 298 Connection* FindConnectionToPing(int64_t now); |
296 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); | 299 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); |
297 // Between |conn1| and |conn2|, this function returns the one which should | 300 // Between |conn1| and |conn2|, this function returns the one which should |
298 // be pinged first. | 301 // be pinged first. |
299 Connection* SelectMostPingableConnection(Connection* conn1, | 302 Connection* SelectMostPingableConnection(Connection* conn1, |
300 Connection* conn2); | 303 Connection* conn2); |
301 // Select the connection which is Relay/Relay. If both of them are, | 304 // Select the connection which is Relay/Relay. If both of them are, |
302 // UDP relay protocol takes precedence. | 305 // UDP relay protocol takes precedence. |
303 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2); | 306 Connection* MostLikelyToWork(Connection* conn1, Connection* conn2); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 IceRole ice_role_; | 362 IceRole ice_role_; |
360 uint64_t tiebreaker_; | 363 uint64_t tiebreaker_; |
361 IceGatheringState gathering_state_; | 364 IceGatheringState gathering_state_; |
362 | 365 |
363 int check_receiving_interval_; | 366 int check_receiving_interval_; |
364 int64_t last_ping_sent_ms_ = 0; | 367 int64_t last_ping_sent_ms_ = 0; |
365 int weak_ping_interval_ = WEAK_PING_INTERVAL; | 368 int weak_ping_interval_ = WEAK_PING_INTERVAL; |
366 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 369 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
367 IceConfig config_; | 370 IceConfig config_; |
368 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 371 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
| 372 bool started_pinging_ = false; |
369 | 373 |
370 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 374 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
371 }; | 375 }; |
372 | 376 |
373 } // namespace cricket | 377 } // namespace cricket |
374 | 378 |
375 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 379 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |