OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #if defined(WEBRTC_POSIX) | 10 #if defined(WEBRTC_POSIX) |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 // Version of CreateTurnPort that takes all possible parameters; all other | 255 // Version of CreateTurnPort that takes all possible parameters; all other |
256 // helper methods call this, such that "SetIceRole" and "ConnectSignals" (and | 256 // helper methods call this, such that "SetIceRole" and "ConnectSignals" (and |
257 // possibly other things in the future) only happen in one place. | 257 // possibly other things in the future) only happen in one place. |
258 void CreateTurnPortWithAllParams(rtc::Network* network, | 258 void CreateTurnPortWithAllParams(rtc::Network* network, |
259 const std::string& username, | 259 const std::string& username, |
260 const std::string& password, | 260 const std::string& password, |
261 const ProtocolAddress& server_address, | 261 const ProtocolAddress& server_address, |
262 const std::string& origin) { | 262 const std::string& origin) { |
263 RelayCredentials credentials(username, password); | 263 RelayCredentials credentials(username, password); |
264 webrtc::RtcEventLog* event_log = nullptr; | |
265 turn_port_.reset(TurnPort::Create(&main_, &socket_factory_, network, 0, 0, | 264 turn_port_.reset(TurnPort::Create(&main_, &socket_factory_, network, 0, 0, |
266 kIceUfrag1, kIcePwd1, server_address, | 265 kIceUfrag1, kIcePwd1, server_address, |
267 credentials, 0, origin, event_log)); | 266 credentials, 0, origin)); |
268 // This TURN port will be the controlling. | 267 // This TURN port will be the controlling. |
269 turn_port_->SetIceRole(ICEROLE_CONTROLLING); | 268 turn_port_->SetIceRole(ICEROLE_CONTROLLING); |
270 ConnectSignals(); | 269 ConnectSignals(); |
271 } | 270 } |
272 | 271 |
273 void CreateSharedTurnPort(const std::string& username, | 272 void CreateSharedTurnPort(const std::string& username, |
274 const std::string& password, | 273 const std::string& password, |
275 const ProtocolAddress& server_address) { | 274 const ProtocolAddress& server_address) { |
276 RTC_CHECK(server_address.proto == PROTO_UDP); | 275 RTC_CHECK(server_address.proto == PROTO_UDP); |
277 | 276 |
278 if (!socket_) { | 277 if (!socket_) { |
279 socket_.reset(socket_factory_.CreateUdpSocket( | 278 socket_.reset(socket_factory_.CreateUdpSocket( |
280 rtc::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); | 279 rtc::SocketAddress(kLocalAddr1.ipaddr(), 0), 0, 0)); |
281 ASSERT_TRUE(socket_ != NULL); | 280 ASSERT_TRUE(socket_ != NULL); |
282 socket_->SignalReadPacket.connect( | 281 socket_->SignalReadPacket.connect( |
283 this, &TurnPortTest::OnSocketReadPacket); | 282 this, &TurnPortTest::OnSocketReadPacket); |
284 } | 283 } |
285 | 284 |
286 RelayCredentials credentials(username, password); | 285 RelayCredentials credentials(username, password); |
287 webrtc::RtcEventLog* event_log = nullptr; | 286 turn_port_.reset(TurnPort::Create( |
288 turn_port_.reset( | 287 &main_, &socket_factory_, MakeNetwork(kLocalAddr1), socket_.get(), |
289 TurnPort::Create(&main_, &socket_factory_, MakeNetwork(kLocalAddr1), | 288 kIceUfrag1, kIcePwd1, server_address, credentials, 0, std::string())); |
290 socket_.get(), kIceUfrag1, kIcePwd1, server_address, | |
291 credentials, 0, std::string(), event_log)); | |
292 // This TURN port will be the controlling. | 289 // This TURN port will be the controlling. |
293 turn_port_->SetIceRole(ICEROLE_CONTROLLING); | 290 turn_port_->SetIceRole(ICEROLE_CONTROLLING); |
294 ConnectSignals(); | 291 ConnectSignals(); |
295 } | 292 } |
296 | 293 |
297 void ConnectSignals() { | 294 void ConnectSignals() { |
298 turn_port_->SignalPortComplete.connect(this, | 295 turn_port_->SignalPortComplete.connect(this, |
299 &TurnPortTest::OnTurnPortComplete); | 296 &TurnPortTest::OnTurnPortComplete); |
300 turn_port_->SignalPortError.connect(this, | 297 turn_port_->SignalPortError.connect(this, |
301 &TurnPortTest::OnTurnPortError); | 298 &TurnPortTest::OnTurnPortError); |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1355 EXPECT_TRUE(turn_port_->Candidates().empty()); |
1359 turn_port_.reset(); | 1356 turn_port_.reset(); |
1360 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); | 1357 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); |
1361 // Waiting for above message to be processed. | 1358 // Waiting for above message to be processed. |
1362 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); | 1359 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); |
1363 EXPECT_EQ(last_fd_count, GetFDCount()); | 1360 EXPECT_EQ(last_fd_count, GetFDCount()); |
1364 } | 1361 } |
1365 #endif | 1362 #endif |
1366 | 1363 |
1367 } // namespace cricket | 1364 } // namespace cricket |
OLD | NEW |