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