diff options
author | mallinath@chromium.org <mallinath@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 07:33:16 +0000 |
---|---|---|
committer | mallinath@chromium.org <mallinath@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-01 07:33:16 +0000 |
commit | 3d540a9119af4d525f5ff887d0cc83ad9dedbe42 (patch) | |
tree | 4c0f9919b0b57d8585b64d8759748938e99c7e25 /content | |
parent | 40674ccd66aba076ebf13184c80bf010674cd8e8 (diff) | |
download | chromium_src-3d540a9119af4d525f5ff887d0cc83ad9dedbe42.zip chromium_src-3d540a9119af4d525f5ff887d0cc83ad9dedbe42.tar.gz chromium_src-3d540a9119af4d525f5ff887d0cc83ad9dedbe42.tar.bz2 |
In latest version of libjingle, local UDP and STUN merged into
a single Port using same socket for stun candidate discovery
along with local candidate. This option is used in WebRTC peerconnection.
If we allocate a local UDP port before setting STUN address, libjingle will
allocate only UDP port. This change will not affect if
udp and stun are not combined, but will be post-poning just
until stun address resolved.
This CL will also add support of standard relay configuration
(TURN).
Review URL: https://chromiumcodereview.appspot.com/11366002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165306 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/media/media_stream_dependency_factory.cc | 1 | ||||
-rw-r--r-- | content/renderer/p2p/port_allocator.cc | 87 | ||||
-rw-r--r-- | content/renderer/p2p/port_allocator.h | 3 |
3 files changed, 53 insertions, 38 deletions
diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc index 89964e5..26d76a5 100644 --- a/content/renderer/media/media_stream_dependency_factory.cc +++ b/content/renderer/media/media_stream_dependency_factory.cc @@ -54,6 +54,7 @@ class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { config.stun_server_port = stun_servers[0].server.port(); } if (turn_configurations.size() > 0) { + config.legacy_relay = false; config.relay_server = turn_configurations[0].server.hostname(); config.relay_server_port = turn_configurations[0].server.port(); config.relay_username = turn_configurations[0].username; diff --git a/content/renderer/p2p/port_allocator.cc b/content/renderer/p2p/port_allocator.cc index 5581394..60eb347 100644 --- a/content/renderer/p2p/port_allocator.cc +++ b/content/renderer/p2p/port_allocator.cc @@ -53,7 +53,7 @@ bool ParsePortNumber( P2PPortAllocator::Config::Config() : stun_server_port(0), relay_server_port(0), - legacy_relay(false), + legacy_relay(true), disable_tcp_transport(false) { } @@ -135,28 +135,23 @@ void P2PPortAllocatorSession::didFail(WebKit::WebURLLoader* loader, LOG(ERROR) << "Relay session request failed."; // Retry the request. - AllocateRelaySession(); + AllocateLegacyRelaySession(); } void P2PPortAllocatorSession::GetPortConfigurations() { - // Add an empty configuration synchronously, so a local connection - // can be started immediately. - ConfigReady(new cricket::PortConfiguration(talk_base::SocketAddress(), - "", "")); - - if (stun_server_address_.IsNil()) { + if (!allocator_->config_.stun_server.empty() && + stun_server_address_.IsNil()) { ResolveStunServerAddress(); } else { AddConfig(); } - AllocateRelaySession(); + if (allocator_->config_.legacy_relay) { + AllocateLegacyRelaySession(); + } } void P2PPortAllocatorSession::ResolveStunServerAddress() { - if (allocator_->config_.stun_server.empty()) - return; - if (stun_address_request_) return; @@ -172,6 +167,8 @@ void P2PPortAllocatorSession::OnStunServerAddress( if (address.empty()) { LOG(ERROR) << "Failed to resolve STUN server address " << allocator_->config_.stun_server; + // Allocating local ports on stun failure. + AddConfig(); return; } @@ -184,15 +181,10 @@ void P2PPortAllocatorSession::OnStunServerAddress( AddConfig(); } -void P2PPortAllocatorSession::AllocateRelaySession() { +void P2PPortAllocatorSession::AllocateLegacyRelaySession() { if (allocator_->config_.relay_server.empty()) return; - if (!allocator_->config_.legacy_relay) { - NOTIMPLEMENTED() << " TURN support is not implemented yet."; - return; - } - if (relay_session_attempts_ > kRelaySessionRetries) return; relay_session_attempts_++; @@ -293,26 +285,47 @@ void P2PPortAllocatorSession::AddConfig() { cricket::PortConfiguration* config = new cricket::PortConfiguration(stun_server_address_, "", ""); - if (relay_ip_.ip() != 0) { - cricket::PortList ports; - if (relay_udp_port_ > 0) { - talk_base::SocketAddress address(relay_ip_.ip(), relay_udp_port_); - ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_UDP)); - } - if (relay_tcp_port_ > 0 && !allocator_->config_.disable_tcp_transport) { - talk_base::SocketAddress address(relay_ip_.ip(), relay_tcp_port_); - ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_TCP)); - } - if (relay_ssltcp_port_ > 0 && !allocator_->config_.disable_tcp_transport) { - talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); - ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); + if (allocator_->config_.legacy_relay) { + if (relay_ip_.ip() != 0) { + cricket::PortList ports; + if (relay_udp_port_ > 0) { + talk_base::SocketAddress address(relay_ip_.ip(), relay_udp_port_); + ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_UDP)); + } + if (relay_tcp_port_ > 0 && !allocator_->config_.disable_tcp_transport) { + talk_base::SocketAddress address(relay_ip_.ip(), relay_tcp_port_); + ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_TCP)); + } + if (relay_ssltcp_port_ > 0 && + !allocator_->config_.disable_tcp_transport) { + talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); + ports.push_back(cricket::ProtocolAddress( + address, cricket::PROTO_SSLTCP)); + } + if (!ports.empty()) { + // Passing empty credentials, our implementation of RelayServer + // doesn't need credentials to allocate ports. It uses a different + // mechanism for authentication. After migrating to standard + // TURN, need to push real credentials. + cricket::RelayCredentials credentials; + config->AddRelay(ports, credentials, 0.0f); + } } - if (!ports.empty()) { - // Passing empty credentials, our implementation of RelayServer - // doesn't need credentials to allocate ports. It uses a different - // mechanism for authentication. After migrating to standard - // TURN, need to push real credentials. - cricket::RelayCredentials credentials; + } else { + if (!(allocator_->config_.relay_username.empty() || + allocator_->config_.relay_server.empty())) { + // Adding TURN related information to config. + // As per TURN RFC, same turn server should be used for stun as well. + // Configuration should have same address for both stun and turn. + DCHECK_EQ(allocator_->config_.stun_server, + allocator_->config_.relay_server); + cricket::PortList ports; + cricket::RelayCredentials credentials( + allocator_->config_.relay_username, + allocator_->config_.relay_password); + // Using the stun resolved address if available for TURN. + ports.push_back(cricket::ProtocolAddress( + stun_server_address_, cricket::PROTO_UDP)); config->AddRelay(ports, credentials, 0.0f); } } diff --git a/content/renderer/p2p/port_allocator.h b/content/renderer/p2p/port_allocator.h index 5080150..d929449 100644 --- a/content/renderer/p2p/port_allocator.h +++ b/content/renderer/p2p/port_allocator.h @@ -104,7 +104,8 @@ class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, void ResolveStunServerAddress(); void OnStunServerAddress(const net::IPAddressNumber& address); - void AllocateRelaySession(); + // This method allocates non-TURN relay sessions. + void AllocateLegacyRelaySession(); void ParseRelayResponse(); void AddConfig(); |