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 <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...) Expand 10 before | Expand all | Expand 10 after 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 // TODO(deadbeef): Rename to TurnServerConfig. | |
|
pthatcher1
2015/10/20 22:22:00
And RelayCredentials to TurnCredentials?
Taylor Brandstetter
2015/10/20 23:45:29
Added TODO there as well.
| |
| 86 struct RelayServerConfig { | |
| 87 RelayServerConfig(RelayType type) : type(type), priority(0) {} | |
| 88 | |
| 89 RelayType type; | |
| 90 PortList ports; | |
| 91 RelayCredentials credentials; | |
| 92 int priority; | |
| 93 }; | |
| 94 | |
| 74 class PortAllocatorSession : public sigslot::has_slots<> { | 95 class PortAllocatorSession : public sigslot::has_slots<> { |
| 75 public: | 96 public: |
| 76 // Content name passed in mostly for logging and debugging. | 97 // Content name passed in mostly for logging and debugging. |
| 77 PortAllocatorSession(const std::string& content_name, | 98 PortAllocatorSession(const std::string& content_name, |
| 78 int component, | 99 int component, |
| 79 const std::string& ice_ufrag, | 100 const std::string& ice_ufrag, |
| 80 const std::string& ice_pwd, | 101 const std::string& ice_pwd, |
| 81 uint32_t flags); | 102 uint32_t flags); |
| 82 | 103 |
| 83 // Subclasses should clean up any ports created. | 104 // Subclasses should clean up any ports created. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 flags_(kDefaultPortAllocatorFlags), | 151 flags_(kDefaultPortAllocatorFlags), |
| 131 min_port_(0), | 152 min_port_(0), |
| 132 max_port_(0), | 153 max_port_(0), |
| 133 step_delay_(kDefaultStepDelay), | 154 step_delay_(kDefaultStepDelay), |
| 134 allow_tcp_listen_(true), | 155 allow_tcp_listen_(true), |
| 135 candidate_filter_(CF_ALL) { | 156 candidate_filter_(CF_ALL) { |
| 136 // This will allow us to have old behavior on non webrtc clients. | 157 // This will allow us to have old behavior on non webrtc clients. |
| 137 } | 158 } |
| 138 virtual ~PortAllocator() {} | 159 virtual ~PortAllocator() {} |
| 139 | 160 |
| 161 // Set STUN and TURN servers to be used in future sessions. | |
| 162 virtual void SetIceServers( | |
| 163 const ServerAddresses& stun_servers, | |
| 164 const std::vector<RelayServerConfig>& turn_servers) = 0; | |
| 165 | |
| 140 PortAllocatorSession* CreateSession( | 166 PortAllocatorSession* CreateSession( |
| 141 const std::string& sid, | 167 const std::string& sid, |
| 142 const std::string& content_name, | 168 const std::string& content_name, |
| 143 int component, | 169 int component, |
| 144 const std::string& ice_ufrag, | 170 const std::string& ice_ufrag, |
| 145 const std::string& ice_pwd); | 171 const std::string& ice_pwd); |
| 146 | 172 |
| 147 uint32_t flags() const { return flags_; } | 173 uint32_t flags() const { return flags_; } |
| 148 void set_flags(uint32_t flags) { flags_ = flags; } | 174 void set_flags(uint32_t flags) { flags_ = flags; } |
| 149 | 175 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 int max_port_; | 226 int max_port_; |
| 201 uint32_t step_delay_; | 227 uint32_t step_delay_; |
| 202 bool allow_tcp_listen_; | 228 bool allow_tcp_listen_; |
| 203 uint32_t candidate_filter_; | 229 uint32_t candidate_filter_; |
| 204 std::string origin_; | 230 std::string origin_; |
| 205 }; | 231 }; |
| 206 | 232 |
| 207 } // namespace cricket | 233 } // namespace cricket |
| 208 | 234 |
| 209 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ | 235 #endif // WEBRTC_P2P_BASE_PORTALLOCATOR_H_ |
| OLD | NEW |