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

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

Issue 2025573002: Use continual gathering to restore backup connections (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 5 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
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/portinterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // CF = CANDIDATE FILTER 82 // CF = CANDIDATE FILTER
83 enum { 83 enum {
84 CF_NONE = 0x0, 84 CF_NONE = 0x0,
85 CF_HOST = 0x1, 85 CF_HOST = 0x1,
86 CF_REFLEXIVE = 0x2, 86 CF_REFLEXIVE = 0x2,
87 CF_RELAY = 0x4, 87 CF_RELAY = 0x4,
88 CF_ALL = 0x7, 88 CF_ALL = 0x7,
89 }; 89 };
90 90
91 enum class SessionState {
92 GATHERING, // Actively allocating ports and gathering candidates.
93 CLEARED, // Current allocation process has been stopped but may start
94 // new ones.
95 STOPPED // This session has completely stopped, no new allocation
96 // process will be started.
97 };
98
91 // TODO(deadbeef): Rename to TurnCredentials (and username to ufrag). 99 // TODO(deadbeef): Rename to TurnCredentials (and username to ufrag).
92 struct RelayCredentials { 100 struct RelayCredentials {
93 RelayCredentials() {} 101 RelayCredentials() {}
94 RelayCredentials(const std::string& username, const std::string& password) 102 RelayCredentials(const std::string& username, const std::string& password)
95 : username(username), password(password) {} 103 : username(username), password(password) {}
96 104
97 bool operator==(const RelayCredentials& o) const { 105 bool operator==(const RelayCredentials& o) const {
98 return username == o.username && password == o.password; 106 return username == o.username && password == o.password;
99 } 107 }
100 bool operator!=(const RelayCredentials& o) const { return !(*this == o); } 108 bool operator!=(const RelayCredentials& o) const { return !(*this == o); }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bool pooled() const { return ice_ufrag_.empty(); } 160 bool pooled() const { return ice_ufrag_.empty(); }
153 161
154 // Setting this filter should affect not only candidates gathered in the 162 // Setting this filter should affect not only candidates gathered in the
155 // future, but candidates already gathered and ports already "ready", 163 // future, but candidates already gathered and ports already "ready",
156 // which would be returned by ReadyCandidates() and ReadyPorts(). 164 // which would be returned by ReadyCandidates() and ReadyPorts().
157 // 165 //
158 // Default filter should be CF_ALL. 166 // Default filter should be CF_ALL.
159 virtual void SetCandidateFilter(uint32_t filter) = 0; 167 virtual void SetCandidateFilter(uint32_t filter) = 0;
160 168
161 // Starts gathering STUN and Relay configurations. 169 // Starts gathering STUN and Relay configurations.
162 virtual void StartGettingPorts() = 0; 170 virtual void StartGettingPorts() { state_ = SessionState::GATHERING; }
163 virtual void StopGettingPorts() = 0; 171 // Completely stops the gathering process and will not start new ones.
164 // Only stop the existing gathering process but may start new ones if needed. 172 virtual void StopGettingPorts() { state_ = SessionState::STOPPED; }
165 virtual void ClearGettingPorts() = 0; 173 // Only stops the existing gathering process but may start new ones if needed.
166 // Whether the process of getting ports has been stopped. 174 virtual void ClearGettingPorts() { state_ = SessionState::CLEARED; }
167 virtual bool IsGettingPorts() = 0; 175 // Whether the session is actively getting ports.
176 bool IsGettingPorts() { return state_ == SessionState::GATHERING; }
177 // Whether it is in the state where the existing gathering process is stopped,
178 // but new ones may be started (basically after calling ClearGettingPorts).
179 bool IsCleared() { return state_ == SessionState::CLEARED; }
180 // Whether the session has completely stopped.
181 bool IsStopped() { return state_ == SessionState::STOPPED; }
182 // Re-gathers candidates on networks that do not have any connections. More
183 // precisely, a network interface may have more than one IP addresses (e.g.,
184 // IPv4 and IPv6 addresses). Each address subnet will be used to create a
185 // network. Only if all networks of an interface have no connection, the
186 // implementation should start re-gathering on all networks of that interface.
187 virtual void RegatherOnFailedNetworks() {}
188 // Re-gathers candidates on all networks.
189 // TODO(honghaiz): Implement this in BasicPortAllocator.
190 virtual void RegatherOnAllNetworks() {}
168 191
169 // Another way of getting the information provided by the signals below. 192 // Another way of getting the information provided by the signals below.
170 // 193 //
171 // Ports and candidates are not guaranteed to be in the same order as the 194 // Ports and candidates are not guaranteed to be in the same order as the
172 // signals were emitted in. 195 // signals were emitted in.
173 virtual std::vector<PortInterface*> ReadyPorts() const = 0; 196 virtual std::vector<PortInterface*> ReadyPorts() const = 0;
174 virtual std::vector<Candidate> ReadyCandidates() const = 0; 197 virtual std::vector<Candidate> ReadyCandidates() const = 0;
175 virtual bool CandidatesAllocationDone() const = 0; 198 virtual bool CandidatesAllocationDone() const = 0;
176 199
177 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady; 200 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady;
201 // Ports should be signaled to be removed when the networks of the ports
202 // failed (either because the interface is down, or because there is no
203 // connection on the interface).
204 sigslot::signal2<PortAllocatorSession*, const std::vector<PortInterface*>&>
205 SignalPortsRemoved;
178 sigslot::signal2<PortAllocatorSession*, 206 sigslot::signal2<PortAllocatorSession*,
179 const std::vector<Candidate>&> SignalCandidatesReady; 207 const std::vector<Candidate>&> SignalCandidatesReady;
208 // Candidates should be signaled to be removed when the port that generated
209 // the candidates is removed.
210 sigslot::signal2<PortAllocatorSession*, const std::vector<Candidate>&>
211 SignalCandidatesRemoved;
180 sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone; 212 sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone;
181 // A TURN port is pruned if a higher-priority TURN port becomes ready 213 // A TURN port is pruned if a higher-priority TURN port becomes ready
182 // (pairable). When it is pruned, it will not be used for creating 214 // (pairable). When it is pruned, it will not be used for creating
183 // connections and its candidates will not be sent to the remote side 215 // connections and its candidates will not be sent to the remote side
184 // if they have not been sent. 216 // if they have not been sent.
185 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortPruned; 217 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortPruned;
186 218
187 virtual uint32_t generation() { return generation_; } 219 virtual uint32_t generation() { return generation_; }
188 virtual void set_generation(uint32_t generation) { generation_ = generation; } 220 virtual void set_generation(uint32_t generation) { generation_ = generation; }
189 sigslot::signal1<PortAllocatorSession*> SignalDestroyed; 221 sigslot::signal1<PortAllocatorSession*> SignalDestroyed;
(...skipping 23 matching lines...) Expand all
213 ice_pwd_ = ice_pwd; 245 ice_pwd_ = ice_pwd;
214 UpdateIceParametersInternal(); 246 UpdateIceParametersInternal();
215 } 247 }
216 248
217 uint32_t flags_; 249 uint32_t flags_;
218 uint32_t generation_; 250 uint32_t generation_;
219 std::string content_name_; 251 std::string content_name_;
220 int component_; 252 int component_;
221 std::string ice_ufrag_; 253 std::string ice_ufrag_;
222 std::string ice_pwd_; 254 std::string ice_pwd_;
255 SessionState state_ = SessionState::CLEARED;
223 256
224 // SetIceParameters is an implementation detail which only PortAllocator 257 // SetIceParameters is an implementation detail which only PortAllocator
225 // should be able to call. 258 // should be able to call.
226 friend class PortAllocator; 259 friend class PortAllocator;
227 }; 260 };
228 261
229 // Every method of PortAllocator (including the destructor) must be called on 262 // Every method of PortAllocator (including the destructor) must be called on
230 // the same thread, except for the constructor which may be called on any 263 // the same thread, except for the constructor which may be called on any
231 // thread. 264 // thread.
232 // 265 //
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // This variable represents the total number of pooled sessions 397 // This variable represents the total number of pooled sessions
365 // both owned by this class and taken by TakePooledSession. 398 // both owned by this class and taken by TakePooledSession.
366 int allocated_pooled_session_count_ = 0; 399 int allocated_pooled_session_count_ = 0;
367 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; 400 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_;
368 bool prune_turn_ports_ = false; 401 bool prune_turn_ports_ = false;
369 }; 402 };
370 403
371 } // namespace cricket 404 } // namespace cricket
372 405
373 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ 406 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/portinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698