blob: e1ebebb8ddaea1112648228ceb5146c21b148a63 [file] [log] [blame]
Seth Hampsond1003d72018-06-22 15:40:16 -07001/*
2 * Copyright 2018 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Yves Gerey3e707812018-11-28 16:47:49 +010011#include <memory>
12#include <string>
13#include <utility>
14#include <vector>
15
Yves Gerey3e707812018-11-28 16:47:49 +010016#include "absl/types/optional.h"
17#include "api/audio/audio_mixer.h"
Seth Hampsond1003d72018-06-22 15:40:16 -070018#include "api/audio_codecs/builtin_audio_decoder_factory.h"
19#include "api/audio_codecs/builtin_audio_encoder_factory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "api/audio_options.h"
Mirko Bonadei2ff3f492018-11-22 09:00:13 +010021#include "api/create_peerconnection_factory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010022#include "api/jsep.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "api/media_stream_interface.h"
24#include "api/peer_connection_interface.h"
Harald Alvestrandc24a2182022-02-23 13:44:59 +000025#include "api/rtc_error.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010026#include "api/scoped_refptr.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "api/stats/rtc_stats.h"
28#include "api/stats/rtc_stats_report.h"
Seth Hampsond1003d72018-06-22 15:40:16 -070029#include "api/stats/rtcstats_objects.h"
Seth Hampsond1003d72018-06-22 15:40:16 -070030#include "api/video_codecs/builtin_video_decoder_factory.h"
31#include "api/video_codecs/builtin_video_encoder_factory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010032#include "modules/audio_device/include/audio_device.h"
33#include "modules/audio_processing/include/audio_processing.h"
Steve Anton10542f22019-01-11 09:11:00 -080034#include "p2p/base/port_allocator.h"
35#include "p2p/base/port_interface.h"
36#include "p2p/base/test_turn_server.h"
37#include "p2p/client/basic_port_allocator.h"
38#include "pc/peer_connection.h"
39#include "pc/peer_connection_wrapper.h"
40#include "pc/test/fake_audio_capture_module.h"
41#include "pc/test/frame_generator_capturer_video_track_source.h"
42#include "pc/test/mock_peer_connection_observers.h"
Yves Gerey3e707812018-11-28 16:47:49 +010043#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080044#include "rtc_base/fake_network.h"
45#include "rtc_base/firewall_socket_server.h"
Seth Hampsond1003d72018-06-22 15:40:16 -070046#include "rtc_base/gunit.h"
Yves Gerey3e707812018-11-28 16:47:49 +010047#include "rtc_base/helpers.h"
48#include "rtc_base/location.h"
Steve Anton10542f22019-01-11 09:11:00 -080049#include "rtc_base/ref_counted_object.h"
Steve Anton10542f22019-01-11 09:11:00 -080050#include "rtc_base/socket_address.h"
Harald Alvestrandc24a2182022-02-23 13:44:59 +000051#include "rtc_base/socket_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080052#include "rtc_base/ssl_certificate.h"
53#include "rtc_base/test_certificate_verifier.h"
Yves Gerey3e707812018-11-28 16:47:49 +010054#include "rtc_base/thread.h"
Steve Anton10542f22019-01-11 09:11:00 -080055#include "rtc_base/virtual_socket_server.h"
Yves Gerey3e707812018-11-28 16:47:49 +010056#include "system_wrappers/include/clock.h"
Seth Hampsond1003d72018-06-22 15:40:16 -070057#include "test/gtest.h"
58#include "test/testsupport/perf_test.h"
59
60namespace webrtc {
61
62namespace {
63static const int kDefaultTestTimeMs = 15000;
64static const int kRampUpTimeMs = 5000;
65static const int kPollIntervalTimeMs = 50;
66static const int kDefaultTimeoutMs = 10000;
67static const rtc::SocketAddress kDefaultLocalAddress("1.1.1.1", 0);
Seth Hampsonec207102018-06-29 11:12:19 -070068static const char kTurnInternalAddress[] = "88.88.88.0";
69static const char kTurnExternalAddress[] = "88.88.88.1";
70static const int kTurnInternalPort = 3478;
71static const int kTurnExternalPort = 0;
Seth Hampsond1003d72018-06-22 15:40:16 -070072// The video's configured max bitrate in webrtcvideoengine.cc is 1.7 Mbps.
73// Setting the network bandwidth to 1 Mbps allows the video's bitrate to push
74// the network's limitations.
75static const int kNetworkBandwidth = 1000000;
76} // namespace
77
78using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
79
80// This is an end to end test to verify that BWE is functioning when setting
81// up a one to one call at the PeerConnection level. The intention of the test
82// is to catch potential regressions for different ICE path configurations. The
83// test uses a VirtualSocketServer for it's underlying simulated network and
84// fake audio and video sources. The test is based upon rampup_tests.cc, but
85// instead is at the PeerConnection level and uses a different fake network
86// (rampup_tests.cc uses SimulatedNetwork). In the future, this test could
87// potentially test different network conditions and test video quality as well
88// (video_quality_test.cc does this, but at the call level).
89//
90// The perf test results are printed using the perf test support. If the
91// isolated_script_test_perf_output flag is specified in test_main.cc, then
92// the results are written to a JSON formatted file for the Chrome perf
93// dashboard. Since this test is a webrtc_perf_test, it will be run in the perf
94// console every webrtc commit.
95class PeerConnectionWrapperForRampUpTest : public PeerConnectionWrapper {
96 public:
97 using PeerConnectionWrapper::PeerConnectionWrapper;
98
99 PeerConnectionWrapperForRampUpTest(
100 rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory,
101 rtc::scoped_refptr<PeerConnectionInterface> pc,
Seth Hampsonec207102018-06-29 11:12:19 -0700102 std::unique_ptr<MockPeerConnectionObserver> observer)
Seth Hampsond1003d72018-06-22 15:40:16 -0700103 : PeerConnectionWrapper::PeerConnectionWrapper(pc_factory,
104 pc,
Seth Hampsonec207102018-06-29 11:12:19 -0700105 std::move(observer)) {}
Seth Hampsond1003d72018-06-22 15:40:16 -0700106
107 bool AddIceCandidates(std::vector<const IceCandidateInterface*> candidates) {
108 bool success = true;
109 for (const auto candidate : candidates) {
110 if (!pc()->AddIceCandidate(candidate)) {
111 success = false;
112 }
113 }
114 return success;
115 }
116
117 rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrack(
118 FrameGeneratorCapturerVideoTrackSource::Config config,
119 Clock* clock) {
120 video_track_sources_.emplace_back(
Tommi87f70902021-04-27 14:43:08 +0200121 rtc::make_ref_counted<FrameGeneratorCapturerVideoTrackSource>(
Artem Titov232b6a12019-05-29 11:05:01 +0200122 config, clock, /*is_screencast=*/false));
Seth Hampsond1003d72018-06-22 15:40:16 -0700123 video_track_sources_.back()->Start();
124 return rtc::scoped_refptr<VideoTrackInterface>(
125 pc_factory()->CreateVideoTrack(rtc::CreateRandomUuid(),
Niels Möllerafb246b2022-04-20 14:26:50 +0200126 video_track_sources_.back().get()));
Seth Hampsond1003d72018-06-22 15:40:16 -0700127 }
128
129 rtc::scoped_refptr<AudioTrackInterface> CreateLocalAudioTrack(
130 const cricket::AudioOptions options) {
131 rtc::scoped_refptr<AudioSourceInterface> source =
132 pc_factory()->CreateAudioSource(options);
Niels Möllerafb246b2022-04-20 14:26:50 +0200133 return pc_factory()->CreateAudioTrack(rtc::CreateRandomUuid(),
134 source.get());
Seth Hampsond1003d72018-06-22 15:40:16 -0700135 }
136
137 private:
Seth Hampsond1003d72018-06-22 15:40:16 -0700138 std::vector<rtc::scoped_refptr<FrameGeneratorCapturerVideoTrackSource>>
139 video_track_sources_;
140};
141
142// TODO(shampson): Paramaterize the test to run for both Plan B & Unified Plan.
143class PeerConnectionRampUpTest : public ::testing::Test {
144 public:
145 PeerConnectionRampUpTest()
146 : clock_(Clock::GetRealTimeClock()),
147 virtual_socket_server_(new rtc::VirtualSocketServer()),
148 firewall_socket_server_(
149 new rtc::FirewallSocketServer(virtual_socket_server_.get())),
150 network_thread_(new rtc::Thread(firewall_socket_server_.get())),
151 worker_thread_(rtc::Thread::Create()) {
152 network_thread_->SetName("PCNetworkThread", this);
153 worker_thread_->SetName("PCWorkerThread", this);
154 RTC_CHECK(network_thread_->Start());
155 RTC_CHECK(worker_thread_->Start());
156
157 virtual_socket_server_->set_bandwidth(kNetworkBandwidth / 8);
158 pc_factory_ = CreatePeerConnectionFactory(
159 network_thread_.get(), worker_thread_.get(), rtc::Thread::Current(),
160 rtc::scoped_refptr<AudioDeviceModule>(FakeAudioCaptureModule::Create()),
161 CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
162 CreateBuiltinVideoEncoderFactory(), CreateBuiltinVideoDecoderFactory(),
163 nullptr /* audio_mixer */, nullptr /* audio_processing */);
164 }
165
166 virtual ~PeerConnectionRampUpTest() {
167 network_thread()->Invoke<void>(RTC_FROM_HERE,
168 [this] { turn_servers_.clear(); });
169 }
170
171 bool CreatePeerConnectionWrappers(const RTCConfiguration& caller_config,
172 const RTCConfiguration& callee_config) {
173 caller_ = CreatePeerConnectionWrapper(caller_config);
174 callee_ = CreatePeerConnectionWrapper(callee_config);
175 return caller_ && callee_;
176 }
177
178 std::unique_ptr<PeerConnectionWrapperForRampUpTest>
179 CreatePeerConnectionWrapper(const RTCConfiguration& config) {
180 auto* fake_network_manager = new rtc::FakeNetworkManager();
181 fake_network_manager->AddInterface(kDefaultLocalAddress);
182 fake_network_managers_.emplace_back(fake_network_manager);
Seth Hampsond1003d72018-06-22 15:40:16 -0700183
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200184 auto observer = std::make_unique<MockPeerConnectionObserver>();
Seth Hampsonec207102018-06-29 11:12:19 -0700185 webrtc::PeerConnectionDependencies dependencies(observer.get());
186 cricket::BasicPortAllocator* port_allocator =
187 new cricket::BasicPortAllocator(fake_network_manager);
188 port_allocator->set_step_delay(cricket::kDefaultStepDelay);
189 dependencies.allocator =
190 std::unique_ptr<cricket::BasicPortAllocator>(port_allocator);
191 dependencies.tls_cert_verifier =
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200192 std::make_unique<rtc::TestCertificateVerifier>();
Seth Hampsonec207102018-06-29 11:12:19 -0700193
Harald Alvestrandf33f7a22021-05-09 14:58:57 +0000194 auto result = pc_factory_->CreatePeerConnectionOrError(
195 config, std::move(dependencies));
196 if (!result.ok()) {
Seth Hampsond1003d72018-06-22 15:40:16 -0700197 return nullptr;
198 }
199
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200200 return std::make_unique<PeerConnectionWrapperForRampUpTest>(
Harald Alvestrandf33f7a22021-05-09 14:58:57 +0000201 pc_factory_, result.MoveValue(), std::move(observer));
Seth Hampsond1003d72018-06-22 15:40:16 -0700202 }
203
204 void SetupOneWayCall() {
205 ASSERT_TRUE(caller_);
206 ASSERT_TRUE(callee_);
207 FrameGeneratorCapturerVideoTrackSource::Config config;
208 caller_->AddTrack(caller_->CreateLocalVideoTrack(config, clock_));
209 // Disable highpass filter so that we can get all the test audio frames.
210 cricket::AudioOptions options;
211 options.highpass_filter = false;
212 caller_->AddTrack(caller_->CreateLocalAudioTrack(options));
213
214 // Do the SDP negotiation, and also exchange ice candidates.
215 ASSERT_TRUE(caller_->ExchangeOfferAnswerWith(callee_.get()));
216 ASSERT_TRUE_WAIT(
217 caller_->signaling_state() == PeerConnectionInterface::kStable,
218 kDefaultTimeoutMs);
219 ASSERT_TRUE_WAIT(caller_->IsIceGatheringDone(), kDefaultTimeoutMs);
220 ASSERT_TRUE_WAIT(callee_->IsIceGatheringDone(), kDefaultTimeoutMs);
221
222 // Connect an ICE candidate pairs.
223 ASSERT_TRUE(
224 callee_->AddIceCandidates(caller_->observer()->GetAllCandidates()));
225 ASSERT_TRUE(
226 caller_->AddIceCandidates(callee_->observer()->GetAllCandidates()));
227 // This means that ICE and DTLS are connected.
228 ASSERT_TRUE_WAIT(callee_->IsIceConnected(), kDefaultTimeoutMs);
229 ASSERT_TRUE_WAIT(caller_->IsIceConnected(), kDefaultTimeoutMs);
230 }
231
Seth Hampsonec207102018-06-29 11:12:19 -0700232 void CreateTurnServer(cricket::ProtocolType type,
233 const std::string& common_name = "test turn server") {
Seth Hampsond1003d72018-06-22 15:40:16 -0700234 rtc::Thread* thread = network_thread();
Niels Möller6dd49972021-11-24 14:05:55 +0100235 rtc::SocketFactory* factory = firewall_socket_server_.get();
Seth Hampsond1003d72018-06-22 15:40:16 -0700236 std::unique_ptr<cricket::TestTurnServer> turn_server =
237 network_thread_->Invoke<std::unique_ptr<cricket::TestTurnServer>>(
Niels Möller6dd49972021-11-24 14:05:55 +0100238 RTC_FROM_HERE, [thread, factory, type, common_name] {
Seth Hampsond1003d72018-06-22 15:40:16 -0700239 static const rtc::SocketAddress turn_server_internal_address{
Seth Hampsonec207102018-06-29 11:12:19 -0700240 kTurnInternalAddress, kTurnInternalPort};
Seth Hampsond1003d72018-06-22 15:40:16 -0700241 static const rtc::SocketAddress turn_server_external_address{
Seth Hampsonec207102018-06-29 11:12:19 -0700242 kTurnExternalAddress, kTurnExternalPort};
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200243 return std::make_unique<cricket::TestTurnServer>(
Niels Möller6dd49972021-11-24 14:05:55 +0100244 thread, factory, turn_server_internal_address,
Seth Hampsonec207102018-06-29 11:12:19 -0700245 turn_server_external_address, type,
246 true /*ignore_bad_certs=*/, common_name);
Seth Hampsond1003d72018-06-22 15:40:16 -0700247 });
248 turn_servers_.push_back(std::move(turn_server));
249 }
250
251 // First runs the call for kRampUpTimeMs to ramp up the bandwidth estimate.
252 // Then runs the test for the remaining test time, grabbing the bandwidth
253 // estimation stat, every kPollIntervalTimeMs. When finished, averages the
254 // bandwidth estimations and prints the bandwidth estimation result as a perf
255 // metric.
256 void RunTest(const std::string& test_string) {
257 rtc::Thread::Current()->ProcessMessages(kRampUpTimeMs);
258 int number_of_polls =
259 (kDefaultTestTimeMs - kRampUpTimeMs) / kPollIntervalTimeMs;
260 int total_bwe = 0;
261 for (int i = 0; i < number_of_polls; ++i) {
262 rtc::Thread::Current()->ProcessMessages(kPollIntervalTimeMs);
263 total_bwe += static_cast<int>(GetCallerAvailableBitrateEstimate());
264 }
265 double average_bandwidth_estimate = total_bwe / number_of_polls;
266 std::string value_description =
267 "bwe_after_" + std::to_string(kDefaultTestTimeMs / 1000) + "_seconds";
268 test::PrintResult("peerconnection_ramp_up_", test_string, value_description,
269 average_bandwidth_estimate, "bwe", false);
270 }
271
272 rtc::Thread* network_thread() { return network_thread_.get(); }
273
Seth Hampsonec207102018-06-29 11:12:19 -0700274 rtc::FirewallSocketServer* firewall_socket_server() {
275 return firewall_socket_server_.get();
276 }
277
Seth Hampsond1003d72018-06-22 15:40:16 -0700278 PeerConnectionWrapperForRampUpTest* caller() { return caller_.get(); }
279
280 PeerConnectionWrapperForRampUpTest* callee() { return callee_.get(); }
281
282 private:
283 // Gets the caller's outgoing available bitrate from the stats. Returns 0 if
284 // something went wrong. It takes the outgoing bitrate from the current
285 // selected ICE candidate pair's stats.
286 double GetCallerAvailableBitrateEstimate() {
287 auto stats = caller_->GetStats();
288 auto transport_stats = stats->GetStatsOfType<RTCTransportStats>();
289 if (transport_stats.size() == 0u ||
290 !transport_stats[0]->selected_candidate_pair_id.is_defined()) {
291 return 0;
292 }
293 std::string selected_ice_id =
294 transport_stats[0]->selected_candidate_pair_id.ValueToString();
295 // Use the selected ICE candidate pair ID to get the appropriate ICE stats.
296 const RTCIceCandidatePairStats ice_candidate_pair_stats =
297 stats->Get(selected_ice_id)->cast_to<const RTCIceCandidatePairStats>();
298 if (ice_candidate_pair_stats.available_outgoing_bitrate.is_defined()) {
299 return *ice_candidate_pair_stats.available_outgoing_bitrate;
300 }
Artem Titov880fa812021-07-30 22:30:23 +0200301 // We couldn't get the `available_outgoing_bitrate` for the active candidate
Seth Hampsond1003d72018-06-22 15:40:16 -0700302 // pair.
303 return 0;
304 }
305
306 Clock* const clock_;
307 // The turn servers should be accessed & deleted on the network thread to
308 // avoid a race with the socket read/write which occurs on the network thread.
309 std::vector<std::unique_ptr<cricket::TestTurnServer>> turn_servers_;
Artem Titov880fa812021-07-30 22:30:23 +0200310 // `virtual_socket_server_` is used by `network_thread_` so it must be
Seth Hampsond1003d72018-06-22 15:40:16 -0700311 // destroyed later.
312 // TODO(bugs.webrtc.org/7668): We would like to update the virtual network we
313 // use for this test. VirtualSocketServer isn't ideal because:
314 // 1) It uses the same queue & network capacity for both directions.
315 // 2) VirtualSocketServer implements how the network bandwidth affects the
316 // send delay differently than the SimulatedNetwork, used by the
317 // FakeNetworkPipe. It would be ideal if all of levels of virtual
318 // networks used in testing were consistent.
319 // We would also like to update this test to record the time to ramp up,
320 // down, and back up (similar to in rampup_tests.cc). This is problematic with
321 // the VirtualSocketServer. The first ramp down time is very noisy and the
322 // second ramp up time can take up to 300 seconds, most likely due to a built
323 // up queue.
324 std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
325 std::unique_ptr<rtc::FirewallSocketServer> firewall_socket_server_;
326 std::unique_ptr<rtc::Thread> network_thread_;
327 std::unique_ptr<rtc::Thread> worker_thread_;
Artem Titov880fa812021-07-30 22:30:23 +0200328 // The `pc_factory` uses `network_thread_` & `worker_thread_`, so it must be
Seth Hampsond1003d72018-06-22 15:40:16 -0700329 // destroyed first.
330 std::vector<std::unique_ptr<rtc::FakeNetworkManager>> fake_network_managers_;
331 rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
332 std::unique_ptr<PeerConnectionWrapperForRampUpTest> caller_;
333 std::unique_ptr<PeerConnectionWrapperForRampUpTest> callee_;
334};
335
Jeremy Lecontec8850cb2020-09-10 20:46:33 +0200336TEST_F(PeerConnectionRampUpTest, Bwe_After_TurnOverTCP) {
Seth Hampsond1003d72018-06-22 15:40:16 -0700337 CreateTurnServer(cricket::ProtocolType::PROTO_TCP);
338 PeerConnectionInterface::IceServer ice_server;
Seth Hampsonec207102018-06-29 11:12:19 -0700339 std::string ice_server_url = "turn:" + std::string(kTurnInternalAddress) +
340 ":" + std::to_string(kTurnInternalPort) +
341 "?transport=tcp";
342 ice_server.urls.push_back(ice_server_url);
Seth Hampsond1003d72018-06-22 15:40:16 -0700343 ice_server.username = "test";
344 ice_server.password = "test";
345 PeerConnectionInterface::RTCConfiguration client_1_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100346 client_1_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsond1003d72018-06-22 15:40:16 -0700347 client_1_config.servers.push_back(ice_server);
348 client_1_config.type = PeerConnectionInterface::kRelay;
349 PeerConnectionInterface::RTCConfiguration client_2_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100350 client_2_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsond1003d72018-06-22 15:40:16 -0700351 client_2_config.servers.push_back(ice_server);
352 client_2_config.type = PeerConnectionInterface::kRelay;
353 ASSERT_TRUE(CreatePeerConnectionWrappers(client_1_config, client_2_config));
354
355 SetupOneWayCall();
356 RunTest("turn_over_tcp");
357}
358
Jeremy Lecontec8850cb2020-09-10 20:46:33 +0200359TEST_F(PeerConnectionRampUpTest, Bwe_After_TurnOverUDP) {
Seth Hampsonec207102018-06-29 11:12:19 -0700360 CreateTurnServer(cricket::ProtocolType::PROTO_UDP);
361 PeerConnectionInterface::IceServer ice_server;
362 std::string ice_server_url = "turn:" + std::string(kTurnInternalAddress) +
363 ":" + std::to_string(kTurnInternalPort);
364
365 ice_server.urls.push_back(ice_server_url);
366 ice_server.username = "test";
367 ice_server.password = "test";
368 PeerConnectionInterface::RTCConfiguration client_1_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100369 client_1_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700370 client_1_config.servers.push_back(ice_server);
371 client_1_config.type = PeerConnectionInterface::kRelay;
372 PeerConnectionInterface::RTCConfiguration client_2_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100373 client_2_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700374 client_2_config.servers.push_back(ice_server);
375 client_2_config.type = PeerConnectionInterface::kRelay;
376 ASSERT_TRUE(CreatePeerConnectionWrappers(client_1_config, client_2_config));
377
378 SetupOneWayCall();
379 RunTest("turn_over_udp");
380}
381
Jeremy Lecontec8850cb2020-09-10 20:46:33 +0200382TEST_F(PeerConnectionRampUpTest, Bwe_After_TurnOverTLS) {
Seth Hampsonec207102018-06-29 11:12:19 -0700383 CreateTurnServer(cricket::ProtocolType::PROTO_TLS, kTurnInternalAddress);
384 PeerConnectionInterface::IceServer ice_server;
385 std::string ice_server_url = "turns:" + std::string(kTurnInternalAddress) +
386 ":" + std::to_string(kTurnInternalPort) +
387 "?transport=tcp";
388 ice_server.urls.push_back(ice_server_url);
389 ice_server.username = "test";
390 ice_server.password = "test";
391 PeerConnectionInterface::RTCConfiguration client_1_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100392 client_1_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700393 client_1_config.servers.push_back(ice_server);
394 client_1_config.type = PeerConnectionInterface::kRelay;
395 PeerConnectionInterface::RTCConfiguration client_2_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100396 client_2_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700397 client_2_config.servers.push_back(ice_server);
398 client_2_config.type = PeerConnectionInterface::kRelay;
399
400 ASSERT_TRUE(CreatePeerConnectionWrappers(client_1_config, client_2_config));
401
402 SetupOneWayCall();
403 RunTest("turn_over_tls");
404}
405
Jeremy Lecontec8850cb2020-09-10 20:46:33 +0200406TEST_F(PeerConnectionRampUpTest, Bwe_After_UDPPeerToPeer) {
Seth Hampsonec207102018-06-29 11:12:19 -0700407 PeerConnectionInterface::RTCConfiguration client_1_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100408 client_1_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700409 client_1_config.tcp_candidate_policy =
410 PeerConnection::kTcpCandidatePolicyDisabled;
411 PeerConnectionInterface::RTCConfiguration client_2_config;
Henrik Boström62995db2022-01-03 09:58:10 +0100412 client_2_config.sdp_semantics = SdpSemantics::kUnifiedPlan;
Seth Hampsonec207102018-06-29 11:12:19 -0700413 client_2_config.tcp_candidate_policy =
414 PeerConnection::kTcpCandidatePolicyDisabled;
415 ASSERT_TRUE(CreatePeerConnectionWrappers(client_1_config, client_2_config));
416
417 SetupOneWayCall();
418 RunTest("udp_peer_to_peer");
419}
420
Jeremy Lecontec8850cb2020-09-10 20:46:33 +0200421TEST_F(PeerConnectionRampUpTest, Bwe_After_TCPPeerToPeer) {
Seth Hampsonec207102018-06-29 11:12:19 -0700422 firewall_socket_server()->set_udp_sockets_enabled(false);
Henrik Boström62995db2022-01-03 09:58:10 +0100423 PeerConnectionInterface::RTCConfiguration config;
424 config.sdp_semantics = SdpSemantics::kUnifiedPlan;
425 ASSERT_TRUE(CreatePeerConnectionWrappers(config, config));
Seth Hampsonec207102018-06-29 11:12:19 -0700426
427 SetupOneWayCall();
428 RunTest("tcp_peer_to_peer");
429}
Seth Hampsond1003d72018-06-22 15:40:16 -0700430
431} // namespace webrtc