blob: 435d1eb5ddecdf884301f711e949bc13083e040c [file] [log] [blame]
Steve Antonda6c0952017-10-23 11:41:54 -07001/*
2 * Copyright 2017 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 <type_traits>
14#include <utility>
15#include <vector>
Steve Antonda6c0952017-10-23 11:41:54 -070016
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 09:11:00 -080018#include "api/call/call_factory_interface.h"
Yves Gerey3e707812018-11-28 16:47:49 +010019#include "api/jsep.h"
20#include "api/media_transport_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/media_types.h"
22#include "api/peer_connection_interface.h"
23#include "api/peer_connection_proxy.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010024#include "api/scoped_refptr.h"
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080025#include "api/test/fake_media_transport.h"
Yves Gerey3e707812018-11-28 16:47:49 +010026#include "media/base/codec.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "media/base/fake_media_engine.h"
28#include "media/base/media_constants.h"
29#include "media/base/media_engine.h"
30#include "media/sctp/sctp_transport_internal.h"
31#include "p2p/base/p2p_constants.h"
32#include "p2p/base/port_allocator.h"
33#include "pc/media_session.h"
34#include "pc/peer_connection.h"
35#include "pc/peer_connection_factory.h"
36#include "pc/peer_connection_wrapper.h"
37#include "pc/sdp_utils.h"
38#include "pc/session_description.h"
39#include "pc/test/mock_peer_connection_observers.h"
Yves Gerey3e707812018-11-28 16:47:49 +010040#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080041#include "rtc_base/ref_counted_object.h"
42#include "rtc_base/rtc_certificate_generator.h"
Yves Gerey3e707812018-11-28 16:47:49 +010043#include "rtc_base/thread.h"
Harald Alvestrand4aa11922019-05-14 22:00:01 +020044#include "test/gmock.h"
Yves Gerey3e707812018-11-28 16:47:49 +010045#include "test/gtest.h"
Steve Antonda6c0952017-10-23 11:41:54 -070046#ifdef WEBRTC_ANDROID
Steve Anton10542f22019-01-11 09:11:00 -080047#include "pc/test/android_test_initializer.h"
Steve Antonda6c0952017-10-23 11:41:54 -070048#endif
Karl Wiberg918f50c2018-07-05 11:40:33 +020049#include "absl/memory/memory.h"
Steve Anton10542f22019-01-11 09:11:00 -080050#include "pc/test/fake_sctp_transport.h"
51#include "rtc_base/virtual_socket_server.h"
Steve Antonda6c0952017-10-23 11:41:54 -070052
53namespace webrtc {
54
55using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
56using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
Harald Alvestrand4aa11922019-05-14 22:00:01 +020057using ::testing::HasSubstr;
58using ::testing::Not;
Steve Antonda6c0952017-10-23 11:41:54 -070059using ::testing::Values;
60
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080061namespace {
62
63PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies(
64 rtc::Thread* network_thread,
65 rtc::Thread* worker_thread,
66 rtc::Thread* signaling_thread,
67 std::unique_ptr<cricket::MediaEngineInterface> media_engine,
68 std::unique_ptr<CallFactoryInterface> call_factory,
69 std::unique_ptr<MediaTransportFactory> media_transport_factory) {
70 PeerConnectionFactoryDependencies deps;
71 deps.network_thread = network_thread;
72 deps.worker_thread = worker_thread;
73 deps.signaling_thread = signaling_thread;
74 deps.media_engine = std::move(media_engine);
75 deps.call_factory = std::move(call_factory);
76 deps.media_transport_factory = std::move(media_transport_factory);
77 return deps;
78}
79
80} // namespace
81
Steve Antonda6c0952017-10-23 11:41:54 -070082class PeerConnectionFactoryForDataChannelTest
83 : public rtc::RefCountedObject<PeerConnectionFactory> {
84 public:
85 PeerConnectionFactoryForDataChannelTest()
86 : rtc::RefCountedObject<PeerConnectionFactory>(
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080087 CreatePeerConnectionFactoryDependencies(
88 rtc::Thread::Current(),
89 rtc::Thread::Current(),
90 rtc::Thread::Current(),
91 absl::make_unique<cricket::FakeMediaEngine>(),
92 CreateCallFactory(),
93 absl::make_unique<FakeMediaTransportFactory>())) {}
Steve Antonda6c0952017-10-23 11:41:54 -070094
95 std::unique_ptr<cricket::SctpTransportInternalFactory>
96 CreateSctpTransportInternalFactory() {
Karl Wiberg918f50c2018-07-05 11:40:33 +020097 auto factory = absl::make_unique<FakeSctpTransportFactory>();
Steve Antonda6c0952017-10-23 11:41:54 -070098 last_fake_sctp_transport_factory_ = factory.get();
99 return factory;
100 }
101
102 FakeSctpTransportFactory* last_fake_sctp_transport_factory_ = nullptr;
103};
104
105class PeerConnectionWrapperForDataChannelTest : public PeerConnectionWrapper {
106 public:
107 using PeerConnectionWrapper::PeerConnectionWrapper;
108
109 FakeSctpTransportFactory* sctp_transport_factory() {
110 return sctp_transport_factory_;
111 }
112
113 void set_sctp_transport_factory(
114 FakeSctpTransportFactory* sctp_transport_factory) {
115 sctp_transport_factory_ = sctp_transport_factory;
116 }
117
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200118 absl::optional<std::string> sctp_content_name() {
Steve Antonda6c0952017-10-23 11:41:54 -0700119 return GetInternalPeerConnection()->sctp_content_name();
120 }
121
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200122 absl::optional<std::string> sctp_transport_name() {
Steve Antonda6c0952017-10-23 11:41:54 -0700123 return GetInternalPeerConnection()->sctp_transport_name();
124 }
125
126 PeerConnection* GetInternalPeerConnection() {
Mirko Bonadeie97de912017-12-13 11:29:34 +0100127 auto* pci =
128 static_cast<PeerConnectionProxyWithInternal<PeerConnectionInterface>*>(
129 pc());
130 return static_cast<PeerConnection*>(pci->internal());
Steve Antonda6c0952017-10-23 11:41:54 -0700131 }
132
133 private:
134 FakeSctpTransportFactory* sctp_transport_factory_ = nullptr;
135};
136
Steve Antondbf9d032018-01-19 15:23:40 -0800137class PeerConnectionDataChannelBaseTest : public ::testing::Test {
Steve Antonda6c0952017-10-23 11:41:54 -0700138 protected:
139 typedef std::unique_ptr<PeerConnectionWrapperForDataChannelTest> WrapperPtr;
140
Steve Antondbf9d032018-01-19 15:23:40 -0800141 explicit PeerConnectionDataChannelBaseTest(SdpSemantics sdp_semantics)
142 : vss_(new rtc::VirtualSocketServer()),
143 main_(vss_.get()),
144 sdp_semantics_(sdp_semantics) {
Steve Antonda6c0952017-10-23 11:41:54 -0700145#ifdef WEBRTC_ANDROID
146 InitializeAndroidObjects();
147#endif
148 }
149
150 WrapperPtr CreatePeerConnection() {
151 return CreatePeerConnection(RTCConfiguration());
152 }
153
154 WrapperPtr CreatePeerConnection(const RTCConfiguration& config) {
155 return CreatePeerConnection(config,
156 PeerConnectionFactoryInterface::Options());
157 }
158
159 WrapperPtr CreatePeerConnection(
160 const RTCConfiguration& config,
161 const PeerConnectionFactoryInterface::Options factory_options) {
162 rtc::scoped_refptr<PeerConnectionFactoryForDataChannelTest> pc_factory(
163 new PeerConnectionFactoryForDataChannelTest());
164 pc_factory->SetOptions(factory_options);
165 RTC_CHECK(pc_factory->Initialize());
Karl Wiberg918f50c2018-07-05 11:40:33 +0200166 auto observer = absl::make_unique<MockPeerConnectionObserver>();
Steve Antondbf9d032018-01-19 15:23:40 -0800167 RTCConfiguration modified_config = config;
168 modified_config.sdp_semantics = sdp_semantics_;
169 auto pc = pc_factory->CreatePeerConnection(modified_config, nullptr,
170 nullptr, observer.get());
Steve Antonda6c0952017-10-23 11:41:54 -0700171 if (!pc) {
172 return nullptr;
173 }
174
Yves Gerey4e933292018-10-31 15:36:05 +0100175 observer->SetPeerConnectionInterface(pc.get());
Karl Wiberg918f50c2018-07-05 11:40:33 +0200176 auto wrapper = absl::make_unique<PeerConnectionWrapperForDataChannelTest>(
Steve Antonda6c0952017-10-23 11:41:54 -0700177 pc_factory, pc, std::move(observer));
178 RTC_DCHECK(pc_factory->last_fake_sctp_transport_factory_);
179 wrapper->set_sctp_transport_factory(
180 pc_factory->last_fake_sctp_transport_factory_);
181 return wrapper;
182 }
183
184 // Accepts the same arguments as CreatePeerConnection and adds a default data
185 // channel.
186 template <typename... Args>
187 WrapperPtr CreatePeerConnectionWithDataChannel(Args&&... args) {
188 auto wrapper = CreatePeerConnection(std::forward<Args>(args)...);
189 if (!wrapper) {
190 return nullptr;
191 }
192 EXPECT_TRUE(wrapper->pc()->CreateDataChannel("dc", nullptr));
193 return wrapper;
194 }
195
196 // Changes the SCTP data channel port on the given session description.
197 void ChangeSctpPortOnDescription(cricket::SessionDescription* desc,
198 int port) {
Steve Antonda6c0952017-10-23 11:41:54 -0700199 auto* data_content = cricket::GetFirstDataContent(desc);
200 RTC_DCHECK(data_content);
Harald Alvestrand5fc28b12019-05-13 13:36:16 +0200201 auto* data_desc = data_content->media_description()->as_sctp();
202 RTC_DCHECK(data_desc);
203 data_desc->set_port(port);
Steve Antonda6c0952017-10-23 11:41:54 -0700204 }
205
206 std::unique_ptr<rtc::VirtualSocketServer> vss_;
207 rtc::AutoSocketServerThread main_;
Steve Antondbf9d032018-01-19 15:23:40 -0800208 const SdpSemantics sdp_semantics_;
Steve Antonda6c0952017-10-23 11:41:54 -0700209};
210
Steve Antondbf9d032018-01-19 15:23:40 -0800211class PeerConnectionDataChannelTest
212 : public PeerConnectionDataChannelBaseTest,
213 public ::testing::WithParamInterface<SdpSemantics> {
214 protected:
215 PeerConnectionDataChannelTest()
216 : PeerConnectionDataChannelBaseTest(GetParam()) {}
217};
218
219TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700220 NoSctpTransportCreatedIfRtpDataChannelEnabled) {
221 RTCConfiguration config;
222 config.enable_rtp_data_channel = true;
223 auto caller = CreatePeerConnectionWithDataChannel(config);
224
225 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
226 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
227}
228
Steve Antondbf9d032018-01-19 15:23:40 -0800229TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700230 RtpDataChannelCreatedEvenIfSctpAvailable) {
231 RTCConfiguration config;
232 config.enable_rtp_data_channel = true;
233 PeerConnectionFactoryInterface::Options options;
234 options.disable_sctp_data_channels = false;
235 auto caller = CreatePeerConnectionWithDataChannel(config, options);
236
237 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
238 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
239}
240
241// Test that sctp_content_name/sctp_transport_name (used for stats) are correct
242// before and after BUNDLE is negotiated.
Steve Antondbf9d032018-01-19 15:23:40 -0800243TEST_P(PeerConnectionDataChannelTest, SctpContentAndTransportNameSetCorrectly) {
Steve Antonda6c0952017-10-23 11:41:54 -0700244 auto caller = CreatePeerConnection();
245 auto callee = CreatePeerConnection();
246
247 // Initially these fields should be empty.
248 EXPECT_FALSE(caller->sctp_content_name());
249 EXPECT_FALSE(caller->sctp_transport_name());
250
251 // Create offer with audio/video/data.
252 // Default bundle policy is "balanced", so data should be using its own
253 // transport.
254 caller->AddAudioTrack("a");
255 caller->AddVideoTrack("v");
256 caller->pc()->CreateDataChannel("dc", nullptr);
Steve Antondbf9d032018-01-19 15:23:40 -0800257
258 auto offer = caller->CreateOffer();
259 const auto& offer_contents = offer->description()->contents();
260 ASSERT_EQ(cricket::MEDIA_TYPE_AUDIO,
261 offer_contents[0].media_description()->type());
262 std::string audio_mid = offer_contents[0].name;
263 ASSERT_EQ(cricket::MEDIA_TYPE_DATA,
264 offer_contents[2].media_description()->type());
265 std::string data_mid = offer_contents[2].name;
266
267 ASSERT_TRUE(
268 caller->SetLocalDescription(CloneSessionDescription(offer.get())));
269 ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
Steve Antonda6c0952017-10-23 11:41:54 -0700270
271 ASSERT_TRUE(caller->sctp_content_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800272 EXPECT_EQ(data_mid, *caller->sctp_content_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700273 ASSERT_TRUE(caller->sctp_transport_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800274 EXPECT_EQ(data_mid, *caller->sctp_transport_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700275
276 // Create answer that finishes BUNDLE negotiation, which means everything
277 // should be bundled on the first transport (audio).
278 RTCOfferAnswerOptions options;
279 options.use_rtp_mux = true;
280 ASSERT_TRUE(
281 caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal()));
282
283 ASSERT_TRUE(caller->sctp_content_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800284 EXPECT_EQ(data_mid, *caller->sctp_content_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700285 ASSERT_TRUE(caller->sctp_transport_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800286 EXPECT_EQ(audio_mid, *caller->sctp_transport_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700287}
288
Steve Antondbf9d032018-01-19 15:23:40 -0800289TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700290 CreateOfferWithNoDataChannelsGivesNoDataSection) {
291 auto caller = CreatePeerConnection();
292 auto offer = caller->CreateOffer();
293
294 EXPECT_FALSE(offer->description()->GetContentByName(cricket::CN_DATA));
295 EXPECT_FALSE(offer->description()->GetTransportInfoByName(cricket::CN_DATA));
296}
297
Steve Antondbf9d032018-01-19 15:23:40 -0800298TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700299 CreateAnswerWithRemoteSctpDataChannelIncludesDataSection) {
300 auto caller = CreatePeerConnectionWithDataChannel();
301 auto callee = CreatePeerConnection();
302
303 ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
304
305 auto answer = callee->CreateAnswer();
306 ASSERT_TRUE(answer);
Steve Antondbf9d032018-01-19 15:23:40 -0800307 auto* data_content = cricket::GetFirstDataContent(answer->description());
Steve Antonda6c0952017-10-23 11:41:54 -0700308 ASSERT_TRUE(data_content);
309 EXPECT_FALSE(data_content->rejected);
Steve Antondbf9d032018-01-19 15:23:40 -0800310 EXPECT_TRUE(
311 answer->description()->GetTransportInfoByName(data_content->name));
Steve Antonda6c0952017-10-23 11:41:54 -0700312}
313
Steve Antondbf9d032018-01-19 15:23:40 -0800314TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700315 CreateDataChannelWithDtlsDisabledSucceeds) {
316 RTCConfiguration config;
317 config.enable_dtls_srtp.emplace(false);
318 auto caller = CreatePeerConnection();
319
320 EXPECT_TRUE(caller->pc()->CreateDataChannel("dc", nullptr));
321}
322
Steve Antondbf9d032018-01-19 15:23:40 -0800323TEST_P(PeerConnectionDataChannelTest, CreateDataChannelWithSctpDisabledFails) {
Steve Antonda6c0952017-10-23 11:41:54 -0700324 PeerConnectionFactoryInterface::Options options;
325 options.disable_sctp_data_channels = true;
326 auto caller = CreatePeerConnection(RTCConfiguration(), options);
327
328 EXPECT_FALSE(caller->pc()->CreateDataChannel("dc", nullptr));
329}
330
331// Test that if a callee has SCTP disabled and receives an offer with an SCTP
332// data channel, the data section is rejected and no SCTP transport is created
333// on the callee.
Steve Antondbf9d032018-01-19 15:23:40 -0800334TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700335 DataSectionRejectedIfCalleeHasSctpDisabled) {
336 auto caller = CreatePeerConnectionWithDataChannel();
337 PeerConnectionFactoryInterface::Options options;
338 options.disable_sctp_data_channels = true;
339 auto callee = CreatePeerConnection(RTCConfiguration(), options);
340
341 ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
342
343 EXPECT_FALSE(callee->sctp_transport_factory()->last_fake_sctp_transport());
344
345 auto answer = callee->CreateAnswer();
Steve Antondbf9d032018-01-19 15:23:40 -0800346 auto* data_content = cricket::GetFirstDataContent(answer->description());
Steve Antonda6c0952017-10-23 11:41:54 -0700347 ASSERT_TRUE(data_content);
348 EXPECT_TRUE(data_content->rejected);
349}
350
Steve Antondbf9d032018-01-19 15:23:40 -0800351TEST_P(PeerConnectionDataChannelTest, SctpPortPropagatedFromSdpToTransport) {
Steve Antonda6c0952017-10-23 11:41:54 -0700352 constexpr int kNewSendPort = 9998;
353 constexpr int kNewRecvPort = 7775;
354
355 auto caller = CreatePeerConnectionWithDataChannel();
356 auto callee = CreatePeerConnectionWithDataChannel();
357
358 auto offer = caller->CreateOffer();
359 ChangeSctpPortOnDescription(offer->description(), kNewSendPort);
360 ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
361
362 auto answer = callee->CreateAnswer();
363 ChangeSctpPortOnDescription(answer->description(), kNewRecvPort);
364 ASSERT_TRUE(callee->SetLocalDescription(std::move(answer)));
365
366 auto* callee_transport =
367 callee->sctp_transport_factory()->last_fake_sctp_transport();
368 ASSERT_TRUE(callee_transport);
369 EXPECT_EQ(kNewSendPort, callee_transport->remote_port());
370 EXPECT_EQ(kNewRecvPort, callee_transport->local_port());
371}
372
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800373TEST_P(PeerConnectionDataChannelTest,
374 NoSctpTransportCreatedIfMediaTransportDataChannelsEnabled) {
375 RTCConfiguration config;
376 config.use_media_transport_for_data_channels = true;
377 config.enable_dtls_srtp = false; // SDES is required to use media transport.
378 auto caller = CreatePeerConnectionWithDataChannel(config);
379
380 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
381 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
382}
383
384TEST_P(PeerConnectionDataChannelTest,
385 MediaTransportDataChannelCreatedEvenIfSctpAvailable) {
386 RTCConfiguration config;
387 config.use_media_transport_for_data_channels = true;
388 config.enable_dtls_srtp = false; // SDES is required to use media transport.
389 PeerConnectionFactoryInterface::Options options;
390 options.disable_sctp_data_channels = false;
391 auto caller = CreatePeerConnectionWithDataChannel(config, options);
392
393 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
394 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
395}
396
397TEST_P(PeerConnectionDataChannelTest,
398 CannotEnableBothMediaTransportAndRtpDataChannels) {
399 RTCConfiguration config;
400 config.enable_rtp_data_channel = true;
401 config.use_media_transport_for_data_channels = true;
402 config.enable_dtls_srtp = false; // SDES is required to use media transport.
403 EXPECT_EQ(CreatePeerConnection(config), nullptr);
404}
405
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800406// This test now DCHECKs, instead of failing to SetLocalDescription.
407TEST_P(PeerConnectionDataChannelTest, MediaTransportWithoutSdesFails) {
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800408 RTCConfiguration config;
409 config.use_media_transport_for_data_channels = true;
410 config.enable_dtls_srtp = true; // Disables SDES for data sections.
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800411
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800412 auto caller = CreatePeerConnectionWithDataChannel(config);
413
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800414 EXPECT_EQ(nullptr, caller);
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800415}
416
Guido Urdanetacecf87f2019-05-31 10:17:38 +0000417TEST_P(PeerConnectionDataChannelTest, ModernSdpSyntaxByDefault) {
Harald Alvestrand4aa11922019-05-14 22:00:01 +0200418 PeerConnectionInterface::RTCOfferAnswerOptions options;
419 auto caller = CreatePeerConnectionWithDataChannel();
420 auto offer = caller->CreateOffer(options);
421 EXPECT_FALSE(cricket::GetFirstSctpDataContentDescription(offer->description())
422 ->use_sctpmap());
423 std::string sdp;
424 offer->ToString(&sdp);
425 RTC_LOG(LS_ERROR) << sdp;
426 EXPECT_THAT(sdp, HasSubstr(" UDP/DTLS/SCTP webrtc-datachannel"));
427 EXPECT_THAT(sdp, Not(HasSubstr("a=sctpmap:")));
428}
429
430TEST_P(PeerConnectionDataChannelTest, ObsoleteSdpSyntaxIfSet) {
431 PeerConnectionInterface::RTCOfferAnswerOptions options;
432 options.use_obsolete_sctp_sdp = true;
433 auto caller = CreatePeerConnectionWithDataChannel();
434 auto offer = caller->CreateOffer(options);
435 EXPECT_TRUE(cricket::GetFirstSctpDataContentDescription(offer->description())
436 ->use_sctpmap());
437 std::string sdp;
438 offer->ToString(&sdp);
439 EXPECT_THAT(sdp, Not(HasSubstr(" UDP/DTLS/SCTP webrtc-datachannel")));
440 EXPECT_THAT(sdp, HasSubstr("a=sctpmap:"));
441}
442
Mirko Bonadeic84f6612019-01-31 12:20:57 +0100443INSTANTIATE_TEST_SUITE_P(PeerConnectionDataChannelTest,
444 PeerConnectionDataChannelTest,
445 Values(SdpSemantics::kPlanB,
446 SdpSemantics::kUnifiedPlan));
Steve Antondbf9d032018-01-19 15:23:40 -0800447
Steve Antonda6c0952017-10-23 11:41:54 -0700448} // namespace webrtc