Chromium Code Reviews| 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 |
| 11 #ifndef WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 11 #ifndef WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| 12 #define WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 12 #define WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| 13 | 13 |
| 14 #include <deque> | 14 #include <deque> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/p2p/base/port.h" | 19 #include "webrtc/p2p/base/port.h" |
| 20 #include "webrtc/p2p/base/portinterface.h" | 20 #include "webrtc/p2p/base/portinterface.h" |
| 21 #include "webrtc/base/helpers.h" | 21 #include "webrtc/base/helpers.h" |
| 22 #include "webrtc/base/proxyinfo.h" | 22 #include "webrtc/base/proxyinfo.h" |
| 23 #include "webrtc/base/sigslot.h" | 23 #include "webrtc/base/sigslot.h" |
| 24 #include "webrtc/base/thread.h" | 24 #include "webrtc/base/thread.h" |
| 25 | 25 |
| 26 namespace rtc { | |
| 27 class Network; | |
| 28 class NetworkManager; | |
| 29 } // namespace rtc | |
|
Taylor Brandstetter
2016/06/21 23:36:12
Is this still needed?
| |
| 30 | |
| 26 namespace cricket { | 31 namespace cricket { |
| 27 | 32 |
| 28 // PortAllocator is responsible for allocating Port types for a given | 33 // PortAllocator is responsible for allocating Port types for a given |
| 29 // P2PSocket. It also handles port freeing. | 34 // P2PSocket. It also handles port freeing. |
| 30 // | 35 // |
| 31 // Clients can override this class to control port allocation, including | 36 // Clients can override this class to control port allocation, including |
| 32 // what kinds of ports are allocated. | 37 // what kinds of ports are allocated. |
| 33 | 38 |
| 34 enum { | 39 enum { |
| 35 // Disable local UDP ports. This doesn't impact how we connect to relay | 40 // Disable local UDP ports. This doesn't impact how we connect to relay |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 // Default filter should be CF_ALL. | 163 // Default filter should be CF_ALL. |
| 159 virtual void SetCandidateFilter(uint32_t filter) = 0; | 164 virtual void SetCandidateFilter(uint32_t filter) = 0; |
| 160 | 165 |
| 161 // Starts gathering STUN and Relay configurations. | 166 // Starts gathering STUN and Relay configurations. |
| 162 virtual void StartGettingPorts() = 0; | 167 virtual void StartGettingPorts() = 0; |
| 163 virtual void StopGettingPorts() = 0; | 168 virtual void StopGettingPorts() = 0; |
| 164 // Only stop the existing gathering process but may start new ones if needed. | 169 // Only stop the existing gathering process but may start new ones if needed. |
| 165 virtual void ClearGettingPorts() = 0; | 170 virtual void ClearGettingPorts() = 0; |
| 166 // Whether the process of getting ports has been stopped. | 171 // Whether the process of getting ports has been stopped. |
| 167 virtual bool IsGettingPorts() = 0; | 172 virtual bool IsGettingPorts() = 0; |
| 173 // Re-gathers candidates on networks that do not have connections. Returns | |
| 174 // true if any network does not have connections and regathering is started. | |
| 175 virtual bool RegatherOnFailedNetworks() {} | |
|
Taylor Brandstetter
2016/06/21 23:36:12
Default implementation should return false.
| |
| 176 // Re-gathers candidates on all networks. | |
| 177 virtual void RegatherOnAllNetworks() {} | |
| 168 | 178 |
| 169 // Another way of getting the information provided by the signals below. | 179 // Another way of getting the information provided by the signals below. |
| 170 // | 180 // |
| 171 // Ports and candidates are not guaranteed to be in the same order as the | 181 // Ports and candidates are not guaranteed to be in the same order as the |
| 172 // signals were emitted in. | 182 // signals were emitted in. |
| 173 virtual std::vector<PortInterface*> ReadyPorts() const = 0; | 183 virtual std::vector<PortInterface*> ReadyPorts() const = 0; |
| 174 virtual std::vector<Candidate> ReadyCandidates() const = 0; | 184 virtual std::vector<Candidate> ReadyCandidates() const = 0; |
| 185 // Returns the sanitized candidates on |port|. | |
| 186 virtual std::vector<Candidate> ReadyCandidates(PortInterface* port) const = 0; | |
| 175 virtual bool CandidatesAllocationDone() const = 0; | 187 virtual bool CandidatesAllocationDone() const = 0; |
| 176 | 188 |
| 177 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady; | 189 sigslot::signal2<PortAllocatorSession*, PortInterface*> SignalPortReady; |
| 178 sigslot::signal2<PortAllocatorSession*, | 190 sigslot::signal2<PortAllocatorSession*, |
| 179 const std::vector<Candidate>&> SignalCandidatesReady; | 191 const std::vector<Candidate>&> SignalCandidatesReady; |
| 180 sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone; | 192 sigslot::signal1<PortAllocatorSession*> SignalCandidatesAllocationDone; |
| 181 | 193 |
| 182 virtual uint32_t generation() { return generation_; } | 194 virtual uint32_t generation() { return generation_; } |
| 183 virtual void set_generation(uint32_t generation) { generation_ = generation; } | 195 virtual void set_generation(uint32_t generation) { generation_ = generation; } |
| 184 sigslot::signal1<PortAllocatorSession*> SignalDestroyed; | 196 sigslot::signal1<PortAllocatorSession*> SignalDestroyed; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 268 |
| 257 int candidate_pool_size() const { return target_pooled_session_count_; } | 269 int candidate_pool_size() const { return target_pooled_session_count_; } |
| 258 | 270 |
| 259 // Sets the network types to ignore. | 271 // Sets the network types to ignore. |
| 260 // Values are defined by the AdapterType enum. | 272 // Values are defined by the AdapterType enum. |
| 261 // For instance, calling this with | 273 // For instance, calling this with |
| 262 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and | 274 // ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and |
| 263 // loopback interfaces. | 275 // loopback interfaces. |
| 264 virtual void SetNetworkIgnoreMask(int network_ignore_mask) = 0; | 276 virtual void SetNetworkIgnoreMask(int network_ignore_mask) = 0; |
| 265 | 277 |
| 278 virtual rtc::NetworkManager* network_manager() const = 0; | |
|
Taylor Brandstetter
2016/06/21 23:36:12
I didn't notice this before, but the PortAllocator
| |
| 279 | |
| 266 std::unique_ptr<PortAllocatorSession> CreateSession( | 280 std::unique_ptr<PortAllocatorSession> CreateSession( |
| 267 const std::string& sid, | 281 const std::string& sid, |
| 268 const std::string& content_name, | 282 const std::string& content_name, |
| 269 int component, | 283 int component, |
| 270 const std::string& ice_ufrag, | 284 const std::string& ice_ufrag, |
| 271 const std::string& ice_pwd); | 285 const std::string& ice_pwd); |
| 272 | 286 |
| 273 // Get an available pooled session and set the transport information on it. | 287 // Get an available pooled session and set the transport information on it. |
| 274 // | 288 // |
| 275 // Caller takes ownership of the returned session. | 289 // Caller takes ownership of the returned session. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 int target_pooled_session_count_ = 0; | 362 int target_pooled_session_count_ = 0; |
| 349 // This variable represents the total number of pooled sessions | 363 // This variable represents the total number of pooled sessions |
| 350 // both owned by this class and taken by TakePooledSession. | 364 // both owned by this class and taken by TakePooledSession. |
| 351 int allocated_pooled_session_count_ = 0; | 365 int allocated_pooled_session_count_ = 0; |
| 352 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; | 366 std::deque<std::unique_ptr<PortAllocatorSession>> pooled_sessions_; |
| 353 }; | 367 }; |
| 354 | 368 |
| 355 } // namespace cricket | 369 } // namespace cricket |
| 356 | 370 |
| 357 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 371 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| OLD | NEW |