diff options
author | buildbot@webrtc.org <buildbot@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-09 18:10:55 +0000 |
---|---|---|
committer | buildbot@webrtc.org <buildbot@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2014-05-09 18:10:55 +0000 |
commit | 353ac3047d480819550f0a305849b03e7ff1f8c8 (patch) | |
tree | 59fe4d19ae743fb38449b070c1b7c9561da1648e /p2p/client | |
parent | 864aac1e9a0be2a8e432612f26ad12f215db5db1 (diff) | |
download | talk-353ac3047d480819550f0a305849b03e7ff1f8c8.tar.gz |
(Auto)update libjingle 66624678-> 66643715
git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6095 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'p2p/client')
-rw-r--r-- | p2p/client/basicportallocator.cc | 43 | ||||
-rw-r--r-- | p2p/client/basicportallocator.h | 6 | ||||
-rw-r--r-- | p2p/client/portallocator_unittest.cc | 5 |
3 files changed, 18 insertions, 36 deletions
diff --git a/p2p/client/basicportallocator.cc b/p2p/client/basicportallocator.cc index c801be2..12d70a3 100644 --- a/p2p/client/basicportallocator.cc +++ b/p2p/client/basicportallocator.cc @@ -161,7 +161,7 @@ class AllocationSequence : public talk_base::MessageHandler, ProtocolList protocols_; talk_base::scoped_ptr<talk_base::AsyncPacketSocket> udp_socket_; // There will be only one udp port per AllocationSequence. - UDPPort* udp_port_; + Port* udp_port_; // Keeping a map for turn ports keyed with server addresses. std::map<talk_base::SocketAddress, Port*> turn_ports_; int phase_; @@ -206,15 +206,13 @@ BasicPortAllocator::BasicPortAllocator( stun_address_(stun_address) { RelayServerConfig config(RELAY_GTURN); - if (!relay_address_udp.IsAny() && !relay_address_udp.IsNil()) + if (!relay_address_udp.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_udp, PROTO_UDP)); - if (!relay_address_tcp.IsAny() && !relay_address_tcp.IsNil()) + if (!relay_address_tcp.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_tcp, PROTO_TCP)); - if (!relay_address_ssl.IsAny() && !relay_address_ssl.IsNil()) + if (!relay_address_ssl.IsAny()) config.ports.push_back(ProtocolAddress(relay_address_ssl, PROTO_SSLTCP)); - - if (!config.ports.empty()) - AddRelay(config); + AddRelay(config); Construct(); } @@ -870,18 +868,13 @@ void AllocationSequence::CreateUDPPorts() { // If STUN is not disabled, setting stun server address to port. if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { - // If config has stun_address, use it to get server reflexive candidate - // otherwise use first TURN server which supports UDP. - if (config_ && !config_->stun_address.IsNil()) { - LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the " - << "STUN candidate generation."; + // If there is a TURN UDP server available, then we will use TURN port + // to get stun address, otherwise by UDP port. + // Shared socket mode is not used in GTURN mode. + if (config_ && + !config_->SupportsProtocol(RELAY_TURN, PROTO_UDP) && + !config_->stun_address.IsNil()) { port->set_server_addr(config_->stun_address); - } else if (config_ && - config_->SupportsProtocol(RELAY_TURN, PROTO_UDP)) { - port->set_server_addr(config_->GetFirstRelayServerAddress( - RELAY_TURN, PROTO_UDP)); - LOG(LS_INFO) << "AllocationSequence: TURN Server address will be " - << " used for generating STUN candidate."; } } } @@ -918,6 +911,8 @@ void AllocationSequence::CreateStunPorts() { } if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { + LOG(LS_INFO) << "AllocationSequence: " + << "UDPPort will be handling the STUN candidate generation."; return; } @@ -1123,7 +1118,7 @@ bool PortConfiguration::SupportsProtocol( return false; } -bool PortConfiguration::SupportsProtocol(RelayType turn_type, +bool PortConfiguration::SupportsProtocol(const RelayType turn_type, ProtocolType type) const { for (size_t i = 0; i < relays.size(); ++i) { if (relays[i].type == turn_type && @@ -1133,14 +1128,4 @@ bool PortConfiguration::SupportsProtocol(RelayType turn_type, return false; } -talk_base::SocketAddress PortConfiguration::GetFirstRelayServerAddress( - RelayType turn_type, ProtocolType type) const { - for (size_t i = 0; i < relays.size(); ++i) { - if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { - return relays[i].ports.front().address; - } - } - return talk_base::SocketAddress(); -} - } // namespace cricket diff --git a/p2p/client/basicportallocator.h b/p2p/client/basicportallocator.h index 8a60c42..b8660f0 100644 --- a/p2p/client/basicportallocator.h +++ b/p2p/client/basicportallocator.h @@ -234,11 +234,7 @@ struct PortConfiguration : public talk_base::MessageData { // Determines whether the given relay server supports the given protocol. bool SupportsProtocol(const RelayServerConfig& relay, ProtocolType type) const; - bool SupportsProtocol(RelayType turn_type, ProtocolType type) const; - // Helper method returns the first server address for the matching - // RelayType and Protocol type. - talk_base::SocketAddress GetFirstRelayServerAddress( - RelayType turn_type, ProtocolType type) const; + bool SupportsProtocol(const RelayType turn_type, ProtocolType type) const; }; } // namespace cricket diff --git a/p2p/client/portallocator_unittest.cc b/p2p/client/portallocator_unittest.cc index 44a8f27..1f027e8 100644 --- a/p2p/client/portallocator_unittest.cc +++ b/p2p/client/portallocator_unittest.cc @@ -804,8 +804,9 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); EXPECT_EQ(3U, candidates_.size()); // Local port will be created first and then TURN port. - EXPECT_EQ(2U, ports_[0]->Candidates().size()); - EXPECT_EQ(1U, ports_[1]->Candidates().size()); + // Checking TURN port has two candidates, STUN + TURN. + EXPECT_EQ(1U, ports_[0]->Candidates().size()); + EXPECT_EQ(2U, ports_[1]->Candidates().size()); } // This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled |