From edbd389ecc7388973b55e6e3787ed6a95254dc99 Mon Sep 17 00:00:00 2001 From: Benjamin Wright Date: Wed, 25 Apr 2018 14:06:31 -0700 Subject: [PATCH] TCP TURN Integration Test This changeset adds a new integration test to do basic validation that TCP TURN functionality works in WebRTC. It simply sets up a TestTurnServer configured to relay over TCP and then allows the clients to connect to this server over TCP. Bug: webrtc:7668 Change-Id: Id9f3b4e22f40ace7c7eeddf103b5d954a0872777 Reviewed-on: https://webrtc-review.googlesource.com/70568 Commit-Queue: Benjamin Wright Reviewed-by: Taylor Brandstetter Cr-Commit-Position: refs/heads/master@{#23044} --- pc/peerconnection_integrationtest.cc | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index ab4410b20b..f5dd93e5b4 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -3887,6 +3887,49 @@ TEST_P(PeerConnectionIntegrationTest, TurnCustomizerUsedForTurnConnections) { delete SetCalleePcWrapperAndReturnCurrent(nullptr); } +// Verifies that you can use TCP instead of UDP to connect to a TURN server. +TEST_P(PeerConnectionIntegrationTest, TCPUsedForTurnConnections) { + static const rtc::SocketAddress turn_server_internal_address{"88.88.88.0", + 3478}; + static const rtc::SocketAddress turn_server_external_address{"88.88.88.1", 0}; + + // Enable TCP for the fake turn server. + cricket::TestTurnServer turn_server( + network_thread(), turn_server_internal_address, + turn_server_external_address, cricket::PROTO_TCP); + + webrtc::PeerConnectionInterface::IceServer ice_server; + ice_server.urls.push_back("turn:88.88.88.0:3478?transport=tcp"); + ice_server.username = "test"; + ice_server.password = "test"; + + PeerConnectionInterface::RTCConfiguration client_1_config; + client_1_config.servers.push_back(ice_server); + client_1_config.type = webrtc::PeerConnectionInterface::kRelay; + + PeerConnectionInterface::RTCConfiguration client_2_config; + client_2_config.servers.push_back(ice_server); + client_2_config.type = webrtc::PeerConnectionInterface::kRelay; + + ASSERT_TRUE( + CreatePeerConnectionWrappersWithConfig(client_1_config, client_2_config)); + ConnectFakeSignaling(); + + // Set "offer to receive audio/video" without adding any tracks, so we just + // set up ICE/DTLS with no media. + PeerConnectionInterface::RTCOfferAnswerOptions options; + options.offer_to_receive_audio = 1; + options.offer_to_receive_video = 1; + caller()->SetOfferAnswerOptions(options); + caller()->CreateAndSetAndSignalOffer(); + EXPECT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout); + + // Need to free the clients here since they're using things we created on + // the stack. + delete SetCallerPcWrapperAndReturnCurrent(nullptr); + delete SetCalleePcWrapperAndReturnCurrent(nullptr); +} + // Test that audio and video flow end-to-end when codec names don't use the // expected casing, given that they're supposed to be case insensitive. To test // this, all but one codec is removed from each media description, and its