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 <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/p2p/base/port.h" | |
18 #include "webrtc/p2p/base/portinterface.h" | 17 #include "webrtc/p2p/base/portinterface.h" |
19 #include "webrtc/base/helpers.h" | 18 #include "webrtc/base/helpers.h" |
20 #include "webrtc/base/proxyinfo.h" | 19 #include "webrtc/base/proxyinfo.h" |
21 #include "webrtc/base/sigslot.h" | 20 #include "webrtc/base/sigslot.h" |
22 | 21 |
23 namespace cricket { | 22 namespace cricket { |
24 | 23 |
25 // PortAllocator is responsible for allocating Port types for a given | 24 // PortAllocator is responsible for allocating Port types for a given |
26 // P2PSocket. It also handles port freeing. | 25 // P2PSocket. It also handles port freeing. |
27 // | 26 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 64 |
66 // CF = CANDIDATE FILTER | 65 // CF = CANDIDATE FILTER |
67 enum { | 66 enum { |
68 CF_NONE = 0x0, | 67 CF_NONE = 0x0, |
69 CF_HOST = 0x1, | 68 CF_HOST = 0x1, |
70 CF_REFLEXIVE = 0x2, | 69 CF_REFLEXIVE = 0x2, |
71 CF_RELAY = 0x4, | 70 CF_RELAY = 0x4, |
72 CF_ALL = 0x7, | 71 CF_ALL = 0x7, |
73 }; | 72 }; |
74 | 73 |
75 // TODO(deadbeef): Rename to TurnCredentials (and username to ufrag). | |
76 struct RelayCredentials { | |
77 RelayCredentials() {} | |
78 RelayCredentials(const std::string& username, const std::string& password) | |
79 : username(username), password(password) {} | |
80 | |
81 std::string username; | |
82 std::string password; | |
83 }; | |
84 | |
85 typedef std::vector<ProtocolAddress> PortList; | |
86 // TODO(deadbeef): Rename to TurnServerConfig. | |
87 struct RelayServerConfig { | |
88 RelayServerConfig(RelayType type) : type(type), priority(0) {} | |
89 | |
90 RelayType type; | |
91 PortList ports; | |
92 RelayCredentials credentials; | |
93 int priority; | |
94 }; | |
95 | |
96 class PortAllocatorSession : public sigslot::has_slots<> { | 74 class PortAllocatorSession : public sigslot::has_slots<> { |
97 public: | 75 public: |
98 // Content name passed in mostly for logging and debugging. | 76 // Content name passed in mostly for logging and debugging. |
99 PortAllocatorSession(const std::string& content_name, | 77 PortAllocatorSession(const std::string& content_name, |
100 int component, | 78 int component, |
101 const std::string& ice_ufrag, | 79 const std::string& ice_ufrag, |
102 const std::string& ice_pwd, | 80 const std::string& ice_pwd, |
103 uint32_t flags); | 81 uint32_t flags); |
104 | 82 |
105 // Subclasses should clean up any ports created. | 83 // Subclasses should clean up any ports created. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 flags_(kDefaultPortAllocatorFlags), | 130 flags_(kDefaultPortAllocatorFlags), |
153 min_port_(0), | 131 min_port_(0), |
154 max_port_(0), | 132 max_port_(0), |
155 step_delay_(kDefaultStepDelay), | 133 step_delay_(kDefaultStepDelay), |
156 allow_tcp_listen_(true), | 134 allow_tcp_listen_(true), |
157 candidate_filter_(CF_ALL) { | 135 candidate_filter_(CF_ALL) { |
158 // This will allow us to have old behavior on non webrtc clients. | 136 // This will allow us to have old behavior on non webrtc clients. |
159 } | 137 } |
160 virtual ~PortAllocator() {} | 138 virtual ~PortAllocator() {} |
161 | 139 |
162 // Set STUN and TURN servers to be used in future sessions. | |
163 virtual void SetIceServers( | |
164 const ServerAddresses& stun_servers, | |
165 const std::vector<RelayServerConfig>& turn_servers) = 0; | |
166 | |
167 PortAllocatorSession* CreateSession( | 140 PortAllocatorSession* CreateSession( |
168 const std::string& sid, | 141 const std::string& sid, |
169 const std::string& content_name, | 142 const std::string& content_name, |
170 int component, | 143 int component, |
171 const std::string& ice_ufrag, | 144 const std::string& ice_ufrag, |
172 const std::string& ice_pwd); | 145 const std::string& ice_pwd); |
173 | 146 |
174 uint32_t flags() const { return flags_; } | 147 uint32_t flags() const { return flags_; } |
175 void set_flags(uint32_t flags) { flags_ = flags; } | 148 void set_flags(uint32_t flags) { flags_ = flags; } |
176 | 149 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 int max_port_; | 200 int max_port_; |
228 uint32_t step_delay_; | 201 uint32_t step_delay_; |
229 bool allow_tcp_listen_; | 202 bool allow_tcp_listen_; |
230 uint32_t candidate_filter_; | 203 uint32_t candidate_filter_; |
231 std::string origin_; | 204 std::string origin_; |
232 }; | 205 }; |
233 | 206 |
234 } // namespace cricket | 207 } // namespace cricket |
235 | 208 |
236 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 209 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
OLD | NEW |