Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.h

Issue 2069493002: Do not switch best connection on the controlled side too frequently (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // From TransportChannel: 108 // From TransportChannel:
109 int SendPacket(const char* data, 109 int SendPacket(const char* data,
110 size_t len, 110 size_t len,
111 const rtc::PacketOptions& options, 111 const rtc::PacketOptions& options,
112 int flags) override; 112 int flags) override;
113 int SetOption(rtc::Socket::Option opt, int value) override; 113 int SetOption(rtc::Socket::Option opt, int value) override;
114 bool GetOption(rtc::Socket::Option opt, int* value) override; 114 bool GetOption(rtc::Socket::Option opt, int* value) override;
115 int GetError() override { return error_; } 115 int GetError() override { return error_; }
116 bool GetStats(std::vector<ConnectionInfo>* stats) override; 116 bool GetStats(std::vector<ConnectionInfo>* stats) override;
117 117
118 const Connection* best_connection() const { return best_connection_; } 118 const Connection* selected_connection() const { return selected_connection_; }
119 void set_incoming_only(bool value) { incoming_only_ = value; } 119 void set_incoming_only(bool value) { incoming_only_ = value; }
120 120
121 // Note: This is only for testing purpose. 121 // Note: This is only for testing purpose.
122 // |ports_| should not be changed from outside. 122 // |ports_| should not be changed from outside.
123 const std::vector<PortInterface*>& ports() { return ports_; } 123 const std::vector<PortInterface*>& ports() { return ports_; }
124 124
125 IceMode remote_ice_mode() const { return remote_ice_mode_; } 125 IceMode remote_ice_mode() const { return remote_ice_mode_; }
126 126
127 // DTLS methods. 127 // DTLS methods.
128 bool IsDtlsActive() const override { return false; } 128 bool IsDtlsActive() const override { return false; }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 private: 201 private:
202 rtc::Thread* thread() { return worker_thread_; } 202 rtc::Thread* thread() { return worker_thread_; }
203 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } 203 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); }
204 204
205 // A transport channel is weak if the current best connection is either 205 // A transport channel is weak if the current best connection is either
206 // not receiving or not writable, or if there is no best connection at all. 206 // not receiving or not writable, or if there is no best connection at all.
207 bool weak() const; 207 bool weak() const;
208 void UpdateConnectionStates(); 208 void UpdateConnectionStates();
209 void RequestSort(); 209 void RequestSort();
210 void SortConnections(); 210 void SortConnections();
211 void SwitchBestConnectionTo(Connection* conn); 211 void SwitchSelectedConnection(Connection* conn);
212 void UpdateState(); 212 void UpdateState();
213 void HandleAllTimedOut(); 213 void HandleAllTimedOut();
214 void MaybeStopPortAllocatorSessions(); 214 void MaybeStopPortAllocatorSessions();
215 TransportChannelState ComputeState() const; 215 TransportChannelState ComputeState() const;
216 216
217 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; 217 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
218 bool CreateConnections(const Candidate& remote_candidate, 218 bool CreateConnections(const Candidate& remote_candidate,
219 PortInterface* origin_port); 219 PortInterface* origin_port);
220 bool CreateConnection(PortInterface* port, 220 bool CreateConnection(PortInterface* port,
221 const Candidate& remote_candidate, 221 const Candidate& remote_candidate,
(...skipping 29 matching lines...) Expand all
251 void OnSentPacket(const rtc::SentPacket& sent_packet); 251 void OnSentPacket(const rtc::SentPacket& sent_packet);
252 void OnReadyToSend(Connection* connection); 252 void OnReadyToSend(Connection* connection);
253 void OnConnectionDestroyed(Connection *connection); 253 void OnConnectionDestroyed(Connection *connection);
254 254
255 void OnNominated(Connection* conn); 255 void OnNominated(Connection* conn);
256 256
257 void OnMessage(rtc::Message* pmsg) override; 257 void OnMessage(rtc::Message* pmsg) override;
258 void OnSort(); 258 void OnSort();
259 void OnCheckAndPing(); 259 void OnCheckAndPing();
260 260
261 bool ShouldSwitchOnNominatedOrDataReceived(Connection* new_connection) const;
pthatcher1 2016/06/17 00:27:11 I still think ShouldSwitchSelectedCandidate makes
honghaiz3 2016/06/17 19:18:18 Done.
262
261 void PruneConnections(); 263 void PruneConnections();
262 Connection* best_nominated_connection() const; 264 Connection* selected_nominated_connection() const;
263 bool IsBackupConnection(Connection* conn) const; 265 bool IsBackupConnection(Connection* conn) const;
264 266
265 Connection* FindConnectionToPing(int64_t now); 267 Connection* FindConnectionToPing(int64_t now);
266 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); 268 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
267 // Between |conn1| and |conn2|, this function returns the one which should 269 // Between |conn1| and |conn2|, this function returns the one which should
268 // be pinged first. 270 // be pinged first.
269 Connection* SelectMostPingableConnection(Connection* conn1, 271 Connection* SelectMostPingableConnection(Connection* conn1,
270 Connection* conn2); 272 Connection* conn2);
271 // Select the connection which is Relay/Relay. If both of them are, 273 // Select the connection which is Relay/Relay. If both of them are,
272 // UDP relay protocol takes precedence. 274 // UDP relay protocol takes precedence.
(...skipping 20 matching lines...) Expand all
293 } 295 }
294 296
295 PortAllocator* allocator_; 297 PortAllocator* allocator_;
296 rtc::Thread* worker_thread_; 298 rtc::Thread* worker_thread_;
297 bool incoming_only_; 299 bool incoming_only_;
298 int error_; 300 int error_;
299 std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_; 301 std::vector<std::unique_ptr<PortAllocatorSession>> allocator_sessions_;
300 std::vector<PortInterface *> ports_; 302 std::vector<PortInterface *> ports_;
301 303
302 // |connections_| is a sorted list with the first one always be the 304 // |connections_| is a sorted list with the first one always be the
303 // |best_connection_| when it's not nullptr. The combination of 305 // |selected_connection_| when it's not nullptr. The combination of
304 // |pinged_connections_| and |unpinged_connections_| has the same 306 // |pinged_connections_| and |unpinged_connections_| has the same
305 // connections as |connections_|. These 2 sets maintain whether a 307 // connections as |connections_|. These 2 sets maintain whether a
306 // connection should be pinged next or not. 308 // connection should be pinged next or not.
307 std::vector<Connection *> connections_; 309 std::vector<Connection *> connections_;
308 std::set<Connection*> pinged_connections_; 310 std::set<Connection*> pinged_connections_;
309 std::set<Connection*> unpinged_connections_; 311 std::set<Connection*> unpinged_connections_;
310 312
311 Connection* best_connection_; 313 Connection* selected_connection_ = nullptr;
312 314
313 // Connection selected by the controlling agent. This should be used only 315 // Connection most recently nominated by the controlling agent.
314 // at controlled side when protocol type is RFC5245. 316 // This should be used only at the controlled side.
315 Connection* pending_best_connection_; 317 Connection* last_nominated_connection_ = nullptr;
318 // The connection on which the data was most recently received.
319 // Should only be used at the controlled side.
320 Connection* last_receiving_connection_ = nullptr;
321
316 std::vector<RemoteCandidate> remote_candidates_; 322 std::vector<RemoteCandidate> remote_candidates_;
317 bool sort_dirty_; // indicates whether another sort is needed right now 323 bool sort_dirty_; // indicates whether another sort is needed right now
318 bool had_connection_ = false; // if connections_ has ever been nonempty 324 bool had_connection_ = false; // if connections_ has ever been nonempty
319 typedef std::map<rtc::Socket::Option, int> OptionMap; 325 typedef std::map<rtc::Socket::Option, int> OptionMap;
320 OptionMap options_; 326 OptionMap options_;
321 std::string ice_ufrag_; 327 std::string ice_ufrag_;
322 std::string ice_pwd_; 328 std::string ice_pwd_;
323 std::vector<IceParameters> remote_ice_parameters_; 329 std::vector<IceParameters> remote_ice_parameters_;
324 IceMode remote_ice_mode_; 330 IceMode remote_ice_mode_;
325 IceRole ice_role_; 331 IceRole ice_role_;
326 uint64_t tiebreaker_; 332 uint64_t tiebreaker_;
327 IceGatheringState gathering_state_; 333 IceGatheringState gathering_state_;
328 334
329 int check_receiving_interval_; 335 int check_receiving_interval_;
330 int64_t last_ping_sent_ms_ = 0; 336 int64_t last_ping_sent_ms_ = 0;
331 int weak_ping_interval_ = WEAK_PING_INTERVAL; 337 int weak_ping_interval_ = WEAK_PING_INTERVAL;
332 TransportChannelState state_ = TransportChannelState::STATE_INIT; 338 TransportChannelState state_ = TransportChannelState::STATE_INIT;
333 IceConfig config_; 339 IceConfig config_;
334 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. 340 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before.
335 341
336 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 342 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
337 }; 343 };
338 344
339 } // namespace cricket 345 } // namespace cricket
340 346
341 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 347 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | webrtc/p2p/base/p2ptransportchannel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698