OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/p2p/port_allocator.h" | 5 #include "content/renderer/p2p/port_allocator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 62 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
63 : port(0) { | 63 : port(0) { |
64 } | 64 } |
65 | 65 |
66 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { | 66 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { |
67 } | 67 } |
68 | 68 |
69 P2PPortAllocator::P2PPortAllocator( | 69 P2PPortAllocator::P2PPortAllocator( |
70 blink::WebFrame* web_frame, | 70 blink::WebFrame* web_frame, |
71 P2PSocketDispatcher* socket_dispatcher, | 71 P2PSocketDispatcher* socket_dispatcher, |
72 talk_base::NetworkManager* network_manager, | 72 rtc::NetworkManager* network_manager, |
73 talk_base::PacketSocketFactory* socket_factory, | 73 rtc::PacketSocketFactory* socket_factory, |
74 const Config& config) | 74 const Config& config) |
75 : cricket::BasicPortAllocator(network_manager, socket_factory), | 75 : cricket::BasicPortAllocator(network_manager, socket_factory), |
76 web_frame_(web_frame), | 76 web_frame_(web_frame), |
77 socket_dispatcher_(socket_dispatcher), | 77 socket_dispatcher_(socket_dispatcher), |
78 config_(config) { | 78 config_(config) { |
79 uint32 flags = 0; | 79 uint32 flags = 0; |
80 if (config_.disable_tcp_transport) | 80 if (config_.disable_tcp_transport) |
81 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; | 81 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; |
82 set_flags(flags); | 82 set_flags(flags); |
83 set_allow_tcp_listen(false); | 83 set_allow_tcp_listen(false); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 return; | 252 return; |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 AddConfig(); | 256 AddConfig(); |
257 } | 257 } |
258 | 258 |
259 void P2PPortAllocatorSession::AddConfig() { | 259 void P2PPortAllocatorSession::AddConfig() { |
260 const P2PPortAllocator::Config& config = allocator_->config_; | 260 const P2PPortAllocator::Config& config = allocator_->config_; |
261 cricket::PortConfiguration* port_config = new cricket::PortConfiguration( | 261 cricket::PortConfiguration* port_config = new cricket::PortConfiguration( |
262 talk_base::SocketAddress(config.stun_server, config.stun_server_port), | 262 rtc::SocketAddress(config.stun_server, config.stun_server_port), |
263 std::string(), std::string()); | 263 std::string(), std::string()); |
264 | 264 |
265 for (size_t i = 0; i < config.relays.size(); ++i) { | 265 for (size_t i = 0; i < config.relays.size(); ++i) { |
266 cricket::RelayCredentials credentials(config.relays[i].username, | 266 cricket::RelayCredentials credentials(config.relays[i].username, |
267 config.relays[i].password); | 267 config.relays[i].password); |
268 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 268 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
269 cricket::ProtocolType protocol; | 269 cricket::ProtocolType protocol; |
270 if (!cricket::StringToProto(config.relays[i].transport_type.c_str(), | 270 if (!cricket::StringToProto(config.relays[i].transport_type.c_str(), |
271 &protocol)) { | 271 &protocol)) { |
272 DLOG(WARNING) << "Ignoring TURN server " | 272 DLOG(WARNING) << "Ignoring TURN server " |
273 << config.relays[i].server_address << ". " | 273 << config.relays[i].server_address << ". " |
274 << "Reason= Incorrect " | 274 << "Reason= Incorrect " |
275 << config.relays[i].transport_type | 275 << config.relays[i].transport_type |
276 << " transport parameter."; | 276 << " transport parameter."; |
277 continue; | 277 continue; |
278 } | 278 } |
279 | 279 |
280 relay_server.ports.push_back(cricket::ProtocolAddress( | 280 relay_server.ports.push_back(cricket::ProtocolAddress( |
281 talk_base::SocketAddress(config.relays[i].server_address, | 281 rtc::SocketAddress(config.relays[i].server_address, |
282 config.relays[i].port), | 282 config.relays[i].port), |
283 protocol, | 283 protocol, |
284 config.relays[i].secure)); | 284 config.relays[i].secure)); |
285 relay_server.credentials = credentials; | 285 relay_server.credentials = credentials; |
286 port_config->AddRelay(relay_server); | 286 port_config->AddRelay(relay_server); |
287 } | 287 } |
288 ConfigReady(port_config); | 288 ConfigReady(port_config); |
289 } | 289 } |
290 | 290 |
291 } // namespace content | 291 } // namespace content |
OLD | NEW |