(Auto)update libjingle 65055925-> 65086785

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5921 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
buildbot@webrtc.org 2014-04-17 00:04:39 +00:00
parent 8f88f20af2
commit 39b868bad3
4 changed files with 63 additions and 21 deletions

View File

@ -257,6 +257,7 @@ void TurnPort::PrepareAddress() {
socket_ = socket_factory()->CreateUdpSocket(
talk_base::SocketAddress(ip(), 0), min_port(), max_port());
} else if (server_address_.proto == PROTO_TCP) {
ASSERT(!SharedSocket());
int opts = talk_base::PacketSocketFactory::OPT_STUN;
// If secure bit is enabled in server address, use TLS over TCP.
if (server_address_.secure) {

View File

@ -197,6 +197,8 @@ class TurnPortTest : public testing::Test,
void CreateSharedTurnPort(const std::string& username,
const std::string& password,
const cricket::ProtocolAddress& server_address) {
ASSERT(server_address.proto == cricket::PROTO_UDP);
socket_.reset(socket_factory_.CreateUdpSocket(
talk_base::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0));
ASSERT_TRUE(socket_ != NULL);

View File

@ -1003,12 +1003,28 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
for (relay_port = config.ports.begin();
relay_port != config.ports.end(); ++relay_port) {
TurnPort* port = NULL;
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
// Shared socket mode must be enabled only for UDP based ports. Hence
// don't pass shared socket for ports which will create TCP sockets.
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET) &&
relay_port->proto == PROTO_UDP) {
port = TurnPort::Create(session_->network_thread(),
session_->socket_factory(),
network_, udp_socket_.get(),
session_->username(), session_->password(),
*relay_port, config.credentials);
// If we are using shared socket for TURN and udp ports, we need to
// find a way to demux the packets to the correct port when received.
// Mapping against server_address is one way of doing this. When packet
// is received the remote_address will be checked against the map.
// If server address is not resolved, a signal will be sent from the port
// after the address is resolved. The map entry will updated with the
// resolved address when the signal is received from the port.
if ((*relay_port).address.IsUnresolved()) {
// If server address is not resolved then listen for signal from port.
port->SignalResolvedServerAddress.connect(
this, &AllocationSequence::OnResolvedTurnServerAddress);
}
turn_ports_[(*relay_port).address] = port;
} else {
port = TurnPort::Create(session_->network_thread(),
session_->socket_factory(),
@ -1019,27 +1035,10 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
session_->password(),
*relay_port, config.credentials);
}
if (port) {
// If we are using shared socket for TURN and udp ports, we need to
// find a way to demux the packets to the correct port when received.
// Mapping against server_address is one way of doing this. When packet
// is received the remote_address will be checked against the map.
// If server address is not resolved, a signal will be sent from the port
// after the address is resolved. The map entry will updated with the
// resolved address when the signal is received from the port.
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
// If server address is not resolved then listen for signal from port.
if ((*relay_port).address.IsUnresolved()) {
port->SignalResolvedServerAddress.connect(
this, &AllocationSequence::OnResolvedTurnServerAddress);
}
turn_ports_[(*relay_port).address] = port;
}
ASSERT(port != NULL);
session_->AddAllocatedPort(port, this, true);
}
}
}
void AllocationSequence::OnReadPacket(
talk_base::AsyncPacketSocket* socket, const char* data, size_t size,

View File

@ -65,7 +65,8 @@ static const SocketAddress kRelayTcpExtAddr("99.99.99.3", 5003);
static const SocketAddress kRelaySslTcpIntAddr("99.99.99.2", 5004);
static const SocketAddress kRelaySslTcpExtAddr("99.99.99.3", 5005);
static const SocketAddress kTurnUdpIntAddr("99.99.99.4", 3478);
static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0);
static const SocketAddress kTurnTcpIntAddr("99.99.99.5", 3478);
static const SocketAddress kTurnUdpExtAddr("99.99.99.6", 0);
// Minimum and maximum port for port range tests.
static const int kMinPort = 10000;
@ -701,6 +702,43 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNat) {
EXPECT_EQ(3U, candidates_.size());
}
// Test TURN port in shared socket mode with UDP and TCP TURN server adderesses.
TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) {
turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
AddInterface(kClientAddr);
allocator_.reset(new cricket::BasicPortAllocator(&network_manager_));
cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword);
relay_server.credentials = credentials;
relay_server.ports.push_back(cricket::ProtocolAddress(
kTurnUdpIntAddr, cricket::PROTO_UDP, false));
relay_server.ports.push_back(cricket::ProtocolAddress(
kTurnTcpIntAddr, cricket::PROTO_TCP, false));
allocator_->AddRelay(relay_server);
allocator_->set_step_delay(cricket::kMinimumStepDelay);
allocator_->set_flags(allocator().flags() |
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
cricket::PORTALLOCATOR_DISABLE_TCP);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
ASSERT_EQ(3U, ports_.size());
EXPECT_PRED5(CheckCandidate, candidates_[0],
cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr);
EXPECT_PRED5(CheckCandidate, candidates_[1],
cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
talk_base::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
EXPECT_PRED5(CheckCandidate, candidates_[2],
cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
talk_base::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
EXPECT_EQ(3U, candidates_.size());
}
// Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port
// is allocated for udp/stun/turn. In this test we should expect all local,
// stun and turn candidates.
@ -722,8 +760,10 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) {
cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET |
cricket::PORTALLOCATOR_DISABLE_TCP);
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
session_->StartGettingPorts();
ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout);
ASSERT_EQ(2U, ports_.size());
EXPECT_PRED5(CheckCandidate, candidates_[0],