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