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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 void UpdateConnectionStates(); | 219 void UpdateConnectionStates(); |
220 void RequestSortAndStateUpdate(); | 220 void RequestSortAndStateUpdate(); |
221 // Start pinging if we haven't already started, and we now have a connection | 221 // Start pinging if we haven't already started, and we now have a connection |
222 // that's pingable. | 222 // that's pingable. |
223 void MaybeStartPinging(); | 223 void MaybeStartPinging(); |
224 | 224 |
225 // The methods below return a positive value if a is preferable to b, | 225 // The methods below return a positive value if a is preferable to b, |
226 // a negative value if b is preferable, and 0 if they're equally preferable. | 226 // a negative value if b is preferable, and 0 if they're equally preferable. |
227 int CompareConnectionStates(const cricket::Connection* a, | 227 int CompareConnectionStates(const cricket::Connection* a, |
228 const cricket::Connection* b) const; | 228 const cricket::Connection* b) const; |
| 229 int CompareConnectionWriteAndConnectedStates( |
| 230 const cricket::Connection* a, |
| 231 const cricket::Connection* b) const; |
229 int CompareConnectionCandidates(const cricket::Connection* a, | 232 int CompareConnectionCandidates(const cricket::Connection* a, |
230 const cricket::Connection* b) const; | 233 const cricket::Connection* b) const; |
231 // Compares two connections based on the connection states | 234 // Compares two connections based on the connection states |
232 // (writable/receiving/connected), nomination states, last data received time, | 235 // (writable/receiving/connected), nomination states, last data received time, |
233 // and static preferences. Does not include latency. Used by both sorting | 236 // and static preferences, and latency. Used by sorting connections. |
234 // and ShouldSwitchSelectedConnection(). | |
235 // Returns a positive value if |a| is better than |b|. | 237 // Returns a positive value if |a| is better than |b|. |
236 int CompareConnections(const cricket::Connection* a, | 238 int CompareConnections(const cricket::Connection* a, |
237 const cricket::Connection* b) const; | 239 const cricket::Connection* b) const; |
| 240 int CompareConnectionsWithoutStates(const cricket::Connection* a, |
| 241 const cricket::Connection* b) const; |
| 242 // This is similar to CompareConnectionStates except that if the selected |
| 243 // connection is not receiving and the new connection is receiving, return a |
| 244 // negative value (indicating the new connection is better) only if the new |
| 245 // connection has been in receiving state for |receiving_dampening_interval_| |
| 246 // milliseconds. If the new connection is receiving but is dampened by this |
| 247 // mechanism, set |connection_dampened| to be true. |
| 248 int CompareConnectionStatesWithDampening( |
| 249 const cricket::Connection* selected_conn, |
| 250 const cricket::Connection* new_conn, |
| 251 bool* connection_dampened) const; |
238 | 252 |
239 bool PresumedWritable(const cricket::Connection* conn) const; | 253 bool PresumedWritable(const cricket::Connection* conn) const; |
240 | 254 |
241 bool ShouldSwitchSelectedConnection(const cricket::Connection* selected, | |
242 const cricket::Connection* conn) const; | |
243 void SortConnectionsAndUpdateState(); | 255 void SortConnectionsAndUpdateState(); |
244 void SwitchSelectedConnection(Connection* conn); | 256 void SwitchSelectedConnection(Connection* conn); |
245 void UpdateState(); | 257 void UpdateState(); |
246 void HandleAllTimedOut(); | 258 void HandleAllTimedOut(); |
247 void MaybeStopPortAllocatorSessions(); | 259 void MaybeStopPortAllocatorSessions(); |
248 TransportChannelState ComputeState() const; | 260 TransportChannelState ComputeState() const; |
249 | 261 |
250 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; | 262 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; |
251 bool CreateConnections(const Candidate& remote_candidate, | 263 bool CreateConnections(const Candidate& remote_candidate, |
252 PortInterface* origin_port); | 264 PortInterface* origin_port); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 void OnReadyToSend(Connection* connection); | 312 void OnReadyToSend(Connection* connection); |
301 void OnConnectionDestroyed(Connection *connection); | 313 void OnConnectionDestroyed(Connection *connection); |
302 | 314 |
303 void OnNominated(Connection* conn); | 315 void OnNominated(Connection* conn); |
304 | 316 |
305 void OnMessage(rtc::Message* pmsg) override; | 317 void OnMessage(rtc::Message* pmsg) override; |
306 void OnCheckAndPing(); | 318 void OnCheckAndPing(); |
307 void OnRegatherOnFailedNetworks(); | 319 void OnRegatherOnFailedNetworks(); |
308 | 320 |
309 // Returns true if the new_connection should be selected for transmission. | 321 // Returns true if the new_connection should be selected for transmission. |
310 bool ShouldSwitchSelectedConnection(Connection* new_connection) const; | 322 bool ShouldSwitchSelectedConnection(Connection* new_connection); |
311 | 323 |
312 void PruneConnections(); | 324 void PruneConnections(); |
313 bool IsBackupConnection(const Connection* conn) const; | 325 bool IsBackupConnection(const Connection* conn) const; |
314 | 326 |
315 Connection* FindConnectionToPing(int64_t now); | 327 Connection* FindConnectionToPing(int64_t now); |
316 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); | 328 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); |
317 // Between |conn1| and |conn2|, this function returns the one which should | 329 // Between |conn1| and |conn2|, this function returns the one which should |
318 // be pinged first. | 330 // be pinged first. |
319 Connection* SelectMostPingableConnection(Connection* conn1, | 331 Connection* SelectMostPingableConnection(Connection* conn1, |
320 Connection* conn2); | 332 Connection* conn2); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // |connections_| is a sorted list with the first one always be the | 371 // |connections_| is a sorted list with the first one always be the |
360 // |selected_connection_| when it's not nullptr. The combination of | 372 // |selected_connection_| when it's not nullptr. The combination of |
361 // |pinged_connections_| and |unpinged_connections_| has the same | 373 // |pinged_connections_| and |unpinged_connections_| has the same |
362 // connections as |connections_|. These 2 sets maintain whether a | 374 // connections as |connections_|. These 2 sets maintain whether a |
363 // connection should be pinged next or not. | 375 // connection should be pinged next or not. |
364 std::vector<Connection *> connections_; | 376 std::vector<Connection *> connections_; |
365 std::set<Connection*> pinged_connections_; | 377 std::set<Connection*> pinged_connections_; |
366 std::set<Connection*> unpinged_connections_; | 378 std::set<Connection*> unpinged_connections_; |
367 | 379 |
368 Connection* selected_connection_ = nullptr; | 380 Connection* selected_connection_ = nullptr; |
| 381 Connection* pending_selected_connection_ = nullptr; |
369 | 382 |
370 std::vector<RemoteCandidate> remote_candidates_; | 383 std::vector<RemoteCandidate> remote_candidates_; |
371 bool sort_dirty_; // indicates whether another sort is needed right now | 384 bool sort_dirty_; // indicates whether another sort is needed right now |
372 bool had_connection_ = false; // if connections_ has ever been nonempty | 385 bool had_connection_ = false; // if connections_ has ever been nonempty |
373 typedef std::map<rtc::Socket::Option, int> OptionMap; | 386 typedef std::map<rtc::Socket::Option, int> OptionMap; |
374 OptionMap options_; | 387 OptionMap options_; |
375 std::string ice_ufrag_; | 388 std::string ice_ufrag_; |
376 std::string ice_pwd_; | 389 std::string ice_pwd_; |
377 std::vector<IceParameters> remote_ice_parameters_; | 390 std::vector<IceParameters> remote_ice_parameters_; |
378 IceMode remote_ice_mode_; | 391 IceMode remote_ice_mode_; |
379 IceRole ice_role_; | 392 IceRole ice_role_; |
380 uint64_t tiebreaker_; | 393 uint64_t tiebreaker_; |
381 IceGatheringState gathering_state_; | 394 IceGatheringState gathering_state_; |
382 | 395 |
383 int check_receiving_interval_; | 396 int check_receiving_interval_; |
384 int64_t last_ping_sent_ms_ = 0; | 397 int64_t last_ping_sent_ms_ = 0; |
385 int weak_ping_interval_ = WEAK_PING_INTERVAL; | 398 int weak_ping_interval_ = WEAK_PING_INTERVAL; |
386 TransportChannelState state_ = TransportChannelState::STATE_INIT; | 399 TransportChannelState state_ = TransportChannelState::STATE_INIT; |
387 IceConfig config_; | 400 IceConfig config_; |
388 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. | 401 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. |
389 bool started_pinging_ = false; | 402 bool started_pinging_ = false; |
| 403 bool was_strong_ = false; |
390 | 404 |
391 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); | 405 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); |
392 }; | 406 }; |
393 | 407 |
394 } // namespace cricket | 408 } // namespace cricket |
395 | 409 |
396 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ | 410 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ |
OLD | NEW |