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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 rtc::NetworkManager* network_manager, | 97 rtc::NetworkManager* network_manager, |
98 const ServerAddresses& stun_servers, | 98 const ServerAddresses& stun_servers, |
99 const rtc::SocketAddress& relay_address_udp, | 99 const rtc::SocketAddress& relay_address_udp, |
100 const rtc::SocketAddress& relay_address_tcp, | 100 const rtc::SocketAddress& relay_address_tcp, |
101 const rtc::SocketAddress& relay_address_ssl) | 101 const rtc::SocketAddress& relay_address_ssl) |
102 : network_manager_(network_manager), | 102 : network_manager_(network_manager), |
103 socket_factory_(NULL), | 103 socket_factory_(NULL), |
104 stun_servers_(stun_servers) { | 104 stun_servers_(stun_servers) { |
105 | 105 |
106 RelayServerConfig config(RELAY_GTURN); | 106 RelayServerConfig config(RELAY_GTURN); |
107 if (!relay_address_udp.IsNil()) { | 107 if (!relay_address_udp.IsNil()) |
108 config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP)); | 108 config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP)); |
109 } | 109 if (!relay_address_tcp.IsNil()) |
110 if (!relay_address_tcp.IsNil()) { | |
111 config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP)); | 110 config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP)); |
112 } | 111 if (!relay_address_ssl.IsNil()) |
113 if (!relay_address_ssl.IsNil()) { | |
114 config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP)); | 112 config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP)); |
115 } | |
116 | 113 |
117 if (!config.ports.empty()) { | 114 if (!config.ports.empty()) |
118 AddTurnServer(config); | 115 AddRelay(config); |
119 } | |
120 | 116 |
121 Construct(); | 117 Construct(); |
122 } | 118 } |
123 | 119 |
124 void BasicPortAllocator::Construct() { | 120 void BasicPortAllocator::Construct() { |
125 allow_tcp_listen_ = true; | 121 allow_tcp_listen_ = true; |
126 } | 122 } |
127 | 123 |
128 BasicPortAllocator::~BasicPortAllocator() { | 124 BasicPortAllocator::~BasicPortAllocator() { |
129 } | 125 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 default: | 234 default: |
239 ASSERT(false); | 235 ASSERT(false); |
240 } | 236 } |
241 } | 237 } |
242 | 238 |
243 void BasicPortAllocatorSession::GetPortConfigurations() { | 239 void BasicPortAllocatorSession::GetPortConfigurations() { |
244 PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(), | 240 PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(), |
245 username(), | 241 username(), |
246 password()); | 242 password()); |
247 | 243 |
248 for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { | 244 for (size_t i = 0; i < allocator_->relays().size(); ++i) { |
249 config->AddRelay(turn_server); | 245 config->AddRelay(allocator_->relays()[i]); |
250 } | 246 } |
251 ConfigReady(config); | 247 ConfigReady(config); |
252 } | 248 } |
253 | 249 |
254 void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) { | 250 void BasicPortAllocatorSession::ConfigReady(PortConfiguration* config) { |
255 network_thread_->Post(this, MSG_CONFIG_READY, config); | 251 network_thread_->Post(this, MSG_CONFIG_READY, config); |
256 } | 252 } |
257 | 253 |
258 // Adds a configuration to the list. | 254 // Adds a configuration to the list. |
259 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) { | 255 void BasicPortAllocatorSession::OnConfigReady(PortConfiguration* config) { |
260 if (config) { | 256 if (config) |
261 configs_.push_back(config); | 257 configs_.push_back(config); |
262 } | |
263 | 258 |
264 AllocatePorts(); | 259 AllocatePorts(); |
265 } | 260 } |
266 | 261 |
267 void BasicPortAllocatorSession::OnConfigStop() { | 262 void BasicPortAllocatorSession::OnConfigStop() { |
268 ASSERT(rtc::Thread::Current() == network_thread_); | 263 ASSERT(rtc::Thread::Current() == network_thread_); |
269 | 264 |
270 // If any of the allocated ports have not completed the candidates allocation, | 265 // If any of the allocated ports have not completed the candidates allocation, |
271 // mark those as error. Since session doesn't need any new candidates | 266 // mark those as error. Since session doesn't need any new candidates |
272 // at this stage of the allocation, it's safe to discard any new candidates. | 267 // at this stage of the allocation, it's safe to discard any new candidates. |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 ServerAddresses servers; | 1190 ServerAddresses servers; |
1196 for (size_t i = 0; i < relays.size(); ++i) { | 1191 for (size_t i = 0; i < relays.size(); ++i) { |
1197 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1192 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1198 servers.insert(relays[i].ports.front().address); | 1193 servers.insert(relays[i].ports.front().address); |
1199 } | 1194 } |
1200 } | 1195 } |
1201 return servers; | 1196 return servers; |
1202 } | 1197 } |
1203 | 1198 |
1204 } // namespace cricket | 1199 } // namespace cricket |
OLD | NEW |