| Index: content/renderer/p2p/port_allocator.cc
|
| diff --git a/content/renderer/p2p/port_allocator.cc b/content/renderer/p2p/port_allocator.cc
|
| index 1f2d1e3af049580208c82a09ab51738ebb34ae81..681e5cbbe1e402e9243e322b54daea5c8a024251 100644
|
| --- a/content/renderer/p2p/port_allocator.cc
|
| +++ b/content/renderer/p2p/port_allocator.cc
|
| @@ -10,6 +10,18 @@
|
| #include "content/renderer/p2p/socket_dispatcher.h"
|
|
|
| namespace content {
|
| +
|
| +P2PPortAllocator::Config::Config() {}
|
| +
|
| +P2PPortAllocator::Config::~Config() {
|
| +}
|
| +
|
| +P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig()
|
| + : port(0) {
|
| +}
|
| +
|
| +P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() {
|
| +}
|
|
|
| P2PPortAllocator::P2PPortAllocator(
|
| const scoped_refptr<P2PSocketDispatcher>& socket_dispatcher,
|
| @@ -25,12 +37,10 @@
|
| origin_(origin),
|
| network_manager_task_runner_(task_runner) {
|
| uint32 flags = 0;
|
| - if (!config_.enable_multiple_routes) {
|
| + if (!config_.enable_multiple_routes)
|
| flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION;
|
| - }
|
| - if (!config_.enable_default_local_candidate) {
|
| + if (!config_.enable_default_local_candidate)
|
| flags |= cricket::PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE;
|
| - }
|
| if (!config_.enable_nonproxied_udp) {
|
| flags |= cricket::PORTALLOCATOR_DISABLE_UDP |
|
| cricket::PORTALLOCATOR_DISABLE_STUN |
|
| @@ -55,4 +65,61 @@
|
| network_manager_.release());
|
| }
|
|
|
| +cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal(
|
| + const std::string& content_name,
|
| + int component,
|
| + const std::string& ice_username_fragment,
|
| + const std::string& ice_password) {
|
| + return new P2PPortAllocatorSession(
|
| + this, content_name, component, ice_username_fragment, ice_password);
|
| +}
|
| +
|
| +P2PPortAllocatorSession::P2PPortAllocatorSession(
|
| + P2PPortAllocator* allocator,
|
| + const std::string& content_name,
|
| + int component,
|
| + const std::string& ice_username_fragment,
|
| + const std::string& ice_password)
|
| + : cricket::BasicPortAllocatorSession(allocator,
|
| + content_name,
|
| + component,
|
| + ice_username_fragment,
|
| + ice_password),
|
| + allocator_(allocator) {
|
| +}
|
| +
|
| +P2PPortAllocatorSession::~P2PPortAllocatorSession() {
|
| +}
|
| +
|
| +void P2PPortAllocatorSession::GetPortConfigurations() {
|
| + const P2PPortAllocator::Config& config = allocator_->config_;
|
| + cricket::PortConfiguration* port_config = new cricket::PortConfiguration(
|
| + config.stun_servers, std::string(), std::string());
|
| +
|
| + for (size_t i = 0; i < config.relays.size(); ++i) {
|
| + cricket::RelayCredentials credentials(config.relays[i].username,
|
| + config.relays[i].password);
|
| + cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
|
| + cricket::ProtocolType protocol;
|
| + if (!cricket::StringToProto(config.relays[i].transport_type.c_str(),
|
| + &protocol)) {
|
| + DLOG(WARNING) << "Ignoring TURN server "
|
| + << config.relays[i].server_address << ". "
|
| + << "Reason= Incorrect "
|
| + << config.relays[i].transport_type
|
| + << " transport parameter.";
|
| + continue;
|
| + }
|
| +
|
| + relay_server.ports.push_back(cricket::ProtocolAddress(
|
| + rtc::SocketAddress(config.relays[i].server_address,
|
| + config.relays[i].port),
|
| + protocol,
|
| + config.relays[i].secure));
|
| + relay_server.credentials = credentials;
|
| + port_config->AddRelay(relay_server);
|
| + }
|
| + ConfigReady(port_config);
|
| +}
|
| +
|
| } // namespace content
|
|
|