blob: 787e5ba64d6581ae665ddfe4b125a61434606d52 [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"
Danil Chapovalov53d45ba2019-07-03 14:56:33 +020025#include "api/task_queue/default_task_queue_factory.h"
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080026#include "api/test/fake_media_transport.h"
Yves Gerey3e707812018-11-28 16:47:49 +010027#include "media/base/codec.h"
Steve Anton10542f22019-01-11 09:11:00 -080028#include "media/base/fake_media_engine.h"
29#include "media/base/media_constants.h"
30#include "media/base/media_engine.h"
31#include "media/sctp/sctp_transport_internal.h"
32#include "p2p/base/p2p_constants.h"
33#include "p2p/base/port_allocator.h"
34#include "pc/media_session.h"
35#include "pc/peer_connection.h"
36#include "pc/peer_connection_factory.h"
37#include "pc/peer_connection_wrapper.h"
38#include "pc/sdp_utils.h"
39#include "pc/session_description.h"
40#include "pc/test/mock_peer_connection_observers.h"
Yves Gerey3e707812018-11-28 16:47:49 +010041#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080042#include "rtc_base/ref_counted_object.h"
43#include "rtc_base/rtc_certificate_generator.h"
Yves Gerey3e707812018-11-28 16:47:49 +010044#include "rtc_base/thread.h"
Harald Alvestrand4aa11922019-05-14 22:00:01 +020045#include "test/gmock.h"
Yves Gerey3e707812018-11-28 16:47:49 +010046#include "test/gtest.h"
Steve Antonda6c0952017-10-23 11:41:54 -070047#ifdef WEBRTC_ANDROID
Steve Anton10542f22019-01-11 09:11:00 -080048#include "pc/test/android_test_initializer.h"
Steve Antonda6c0952017-10-23 11:41:54 -070049#endif
Karl Wiberg918f50c2018-07-05 11:40:33 +020050#include "absl/memory/memory.h"
Steve Anton10542f22019-01-11 09:11:00 -080051#include "pc/test/fake_sctp_transport.h"
52#include "rtc_base/virtual_socket_server.h"
Steve Antonda6c0952017-10-23 11:41:54 -070053
54namespace webrtc {
55
56using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
57using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
Harald Alvestrand4aa11922019-05-14 22:00:01 +020058using ::testing::HasSubstr;
59using ::testing::Not;
Steve Antonda6c0952017-10-23 11:41:54 -070060using ::testing::Values;
61
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080062namespace {
63
64PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies(
65 rtc::Thread* network_thread,
66 rtc::Thread* worker_thread,
67 rtc::Thread* signaling_thread,
68 std::unique_ptr<cricket::MediaEngineInterface> media_engine,
69 std::unique_ptr<CallFactoryInterface> call_factory,
70 std::unique_ptr<MediaTransportFactory> media_transport_factory) {
71 PeerConnectionFactoryDependencies deps;
72 deps.network_thread = network_thread;
73 deps.worker_thread = worker_thread;
74 deps.signaling_thread = signaling_thread;
Danil Chapovalov53d45ba2019-07-03 14:56:33 +020075 deps.task_queue_factory = CreateDefaultTaskQueueFactory();
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080076 deps.media_engine = std::move(media_engine);
77 deps.call_factory = std::move(call_factory);
78 deps.media_transport_factory = std::move(media_transport_factory);
79 return deps;
80}
81
82} // namespace
83
Steve Antonda6c0952017-10-23 11:41:54 -070084class PeerConnectionFactoryForDataChannelTest
85 : public rtc::RefCountedObject<PeerConnectionFactory> {
86 public:
87 PeerConnectionFactoryForDataChannelTest()
88 : rtc::RefCountedObject<PeerConnectionFactory>(
Bjorn Mellem175aa2e2018-11-08 11:23:22 -080089 CreatePeerConnectionFactoryDependencies(
90 rtc::Thread::Current(),
91 rtc::Thread::Current(),
92 rtc::Thread::Current(),
93 absl::make_unique<cricket::FakeMediaEngine>(),
94 CreateCallFactory(),
95 absl::make_unique<FakeMediaTransportFactory>())) {}
Steve Antonda6c0952017-10-23 11:41:54 -070096
97 std::unique_ptr<cricket::SctpTransportInternalFactory>
98 CreateSctpTransportInternalFactory() {
Karl Wiberg918f50c2018-07-05 11:40:33 +020099 auto factory = absl::make_unique<FakeSctpTransportFactory>();
Steve Antonda6c0952017-10-23 11:41:54 -0700100 last_fake_sctp_transport_factory_ = factory.get();
101 return factory;
102 }
103
104 FakeSctpTransportFactory* last_fake_sctp_transport_factory_ = nullptr;
105};
106
107class PeerConnectionWrapperForDataChannelTest : public PeerConnectionWrapper {
108 public:
109 using PeerConnectionWrapper::PeerConnectionWrapper;
110
111 FakeSctpTransportFactory* sctp_transport_factory() {
112 return sctp_transport_factory_;
113 }
114
115 void set_sctp_transport_factory(
116 FakeSctpTransportFactory* sctp_transport_factory) {
117 sctp_transport_factory_ = sctp_transport_factory;
118 }
119
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200120 absl::optional<std::string> sctp_content_name() {
Steve Antonda6c0952017-10-23 11:41:54 -0700121 return GetInternalPeerConnection()->sctp_content_name();
122 }
123
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200124 absl::optional<std::string> sctp_transport_name() {
Steve Antonda6c0952017-10-23 11:41:54 -0700125 return GetInternalPeerConnection()->sctp_transport_name();
126 }
127
128 PeerConnection* GetInternalPeerConnection() {
Mirko Bonadeie97de912017-12-13 11:29:34 +0100129 auto* pci =
130 static_cast<PeerConnectionProxyWithInternal<PeerConnectionInterface>*>(
131 pc());
132 return static_cast<PeerConnection*>(pci->internal());
Steve Antonda6c0952017-10-23 11:41:54 -0700133 }
134
135 private:
136 FakeSctpTransportFactory* sctp_transport_factory_ = nullptr;
137};
138
Steve Antondbf9d032018-01-19 15:23:40 -0800139class PeerConnectionDataChannelBaseTest : public ::testing::Test {
Steve Antonda6c0952017-10-23 11:41:54 -0700140 protected:
141 typedef std::unique_ptr<PeerConnectionWrapperForDataChannelTest> WrapperPtr;
142
Steve Antondbf9d032018-01-19 15:23:40 -0800143 explicit PeerConnectionDataChannelBaseTest(SdpSemantics sdp_semantics)
144 : vss_(new rtc::VirtualSocketServer()),
145 main_(vss_.get()),
146 sdp_semantics_(sdp_semantics) {
Steve Antonda6c0952017-10-23 11:41:54 -0700147#ifdef WEBRTC_ANDROID
148 InitializeAndroidObjects();
149#endif
150 }
151
152 WrapperPtr CreatePeerConnection() {
153 return CreatePeerConnection(RTCConfiguration());
154 }
155
156 WrapperPtr CreatePeerConnection(const RTCConfiguration& config) {
157 return CreatePeerConnection(config,
158 PeerConnectionFactoryInterface::Options());
159 }
160
161 WrapperPtr CreatePeerConnection(
162 const RTCConfiguration& config,
163 const PeerConnectionFactoryInterface::Options factory_options) {
164 rtc::scoped_refptr<PeerConnectionFactoryForDataChannelTest> pc_factory(
165 new PeerConnectionFactoryForDataChannelTest());
166 pc_factory->SetOptions(factory_options);
167 RTC_CHECK(pc_factory->Initialize());
Karl Wiberg918f50c2018-07-05 11:40:33 +0200168 auto observer = absl::make_unique<MockPeerConnectionObserver>();
Steve Antondbf9d032018-01-19 15:23:40 -0800169 RTCConfiguration modified_config = config;
170 modified_config.sdp_semantics = sdp_semantics_;
171 auto pc = pc_factory->CreatePeerConnection(modified_config, nullptr,
172 nullptr, observer.get());
Steve Antonda6c0952017-10-23 11:41:54 -0700173 if (!pc) {
174 return nullptr;
175 }
176
Yves Gerey4e933292018-10-31 15:36:05 +0100177 observer->SetPeerConnectionInterface(pc.get());
Karl Wiberg918f50c2018-07-05 11:40:33 +0200178 auto wrapper = absl::make_unique<PeerConnectionWrapperForDataChannelTest>(
Steve Antonda6c0952017-10-23 11:41:54 -0700179 pc_factory, pc, std::move(observer));
180 RTC_DCHECK(pc_factory->last_fake_sctp_transport_factory_);
181 wrapper->set_sctp_transport_factory(
182 pc_factory->last_fake_sctp_transport_factory_);
183 return wrapper;
184 }
185
186 // Accepts the same arguments as CreatePeerConnection and adds a default data
187 // channel.
188 template <typename... Args>
189 WrapperPtr CreatePeerConnectionWithDataChannel(Args&&... args) {
190 auto wrapper = CreatePeerConnection(std::forward<Args>(args)...);
191 if (!wrapper) {
192 return nullptr;
193 }
194 EXPECT_TRUE(wrapper->pc()->CreateDataChannel("dc", nullptr));
195 return wrapper;
196 }
197
198 // Changes the SCTP data channel port on the given session description.
199 void ChangeSctpPortOnDescription(cricket::SessionDescription* desc,
200 int port) {
Steve Antonda6c0952017-10-23 11:41:54 -0700201 auto* data_content = cricket::GetFirstDataContent(desc);
202 RTC_DCHECK(data_content);
Harald Alvestrand5fc28b12019-05-13 13:36:16 +0200203 auto* data_desc = data_content->media_description()->as_sctp();
204 RTC_DCHECK(data_desc);
205 data_desc->set_port(port);
Steve Antonda6c0952017-10-23 11:41:54 -0700206 }
207
208 std::unique_ptr<rtc::VirtualSocketServer> vss_;
209 rtc::AutoSocketServerThread main_;
Steve Antondbf9d032018-01-19 15:23:40 -0800210 const SdpSemantics sdp_semantics_;
Steve Antonda6c0952017-10-23 11:41:54 -0700211};
212
Steve Antondbf9d032018-01-19 15:23:40 -0800213class PeerConnectionDataChannelTest
214 : public PeerConnectionDataChannelBaseTest,
215 public ::testing::WithParamInterface<SdpSemantics> {
216 protected:
217 PeerConnectionDataChannelTest()
218 : PeerConnectionDataChannelBaseTest(GetParam()) {}
219};
220
221TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700222 NoSctpTransportCreatedIfRtpDataChannelEnabled) {
223 RTCConfiguration config;
224 config.enable_rtp_data_channel = true;
225 auto caller = CreatePeerConnectionWithDataChannel(config);
226
227 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
228 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
229}
230
Steve Antondbf9d032018-01-19 15:23:40 -0800231TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700232 RtpDataChannelCreatedEvenIfSctpAvailable) {
233 RTCConfiguration config;
234 config.enable_rtp_data_channel = true;
235 PeerConnectionFactoryInterface::Options options;
236 options.disable_sctp_data_channels = false;
237 auto caller = CreatePeerConnectionWithDataChannel(config, options);
238
239 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
240 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
241}
242
243// Test that sctp_content_name/sctp_transport_name (used for stats) are correct
244// before and after BUNDLE is negotiated.
Steve Antondbf9d032018-01-19 15:23:40 -0800245TEST_P(PeerConnectionDataChannelTest, SctpContentAndTransportNameSetCorrectly) {
Steve Antonda6c0952017-10-23 11:41:54 -0700246 auto caller = CreatePeerConnection();
247 auto callee = CreatePeerConnection();
248
249 // Initially these fields should be empty.
250 EXPECT_FALSE(caller->sctp_content_name());
251 EXPECT_FALSE(caller->sctp_transport_name());
252
253 // Create offer with audio/video/data.
254 // Default bundle policy is "balanced", so data should be using its own
255 // transport.
256 caller->AddAudioTrack("a");
257 caller->AddVideoTrack("v");
258 caller->pc()->CreateDataChannel("dc", nullptr);
Steve Antondbf9d032018-01-19 15:23:40 -0800259
260 auto offer = caller->CreateOffer();
261 const auto& offer_contents = offer->description()->contents();
262 ASSERT_EQ(cricket::MEDIA_TYPE_AUDIO,
263 offer_contents[0].media_description()->type());
264 std::string audio_mid = offer_contents[0].name;
265 ASSERT_EQ(cricket::MEDIA_TYPE_DATA,
266 offer_contents[2].media_description()->type());
267 std::string data_mid = offer_contents[2].name;
268
269 ASSERT_TRUE(
270 caller->SetLocalDescription(CloneSessionDescription(offer.get())));
271 ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
Steve Antonda6c0952017-10-23 11:41:54 -0700272
273 ASSERT_TRUE(caller->sctp_content_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800274 EXPECT_EQ(data_mid, *caller->sctp_content_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700275 ASSERT_TRUE(caller->sctp_transport_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800276 EXPECT_EQ(data_mid, *caller->sctp_transport_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700277
278 // Create answer that finishes BUNDLE negotiation, which means everything
279 // should be bundled on the first transport (audio).
280 RTCOfferAnswerOptions options;
281 options.use_rtp_mux = true;
282 ASSERT_TRUE(
283 caller->SetRemoteDescription(callee->CreateAnswerAndSetAsLocal()));
284
285 ASSERT_TRUE(caller->sctp_content_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800286 EXPECT_EQ(data_mid, *caller->sctp_content_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700287 ASSERT_TRUE(caller->sctp_transport_name());
Steve Antondbf9d032018-01-19 15:23:40 -0800288 EXPECT_EQ(audio_mid, *caller->sctp_transport_name());
Steve Antonda6c0952017-10-23 11:41:54 -0700289}
290
Steve Antondbf9d032018-01-19 15:23:40 -0800291TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700292 CreateOfferWithNoDataChannelsGivesNoDataSection) {
293 auto caller = CreatePeerConnection();
294 auto offer = caller->CreateOffer();
295
296 EXPECT_FALSE(offer->description()->GetContentByName(cricket::CN_DATA));
297 EXPECT_FALSE(offer->description()->GetTransportInfoByName(cricket::CN_DATA));
298}
299
Steve Antondbf9d032018-01-19 15:23:40 -0800300TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700301 CreateAnswerWithRemoteSctpDataChannelIncludesDataSection) {
302 auto caller = CreatePeerConnectionWithDataChannel();
303 auto callee = CreatePeerConnection();
304
305 ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
306
307 auto answer = callee->CreateAnswer();
308 ASSERT_TRUE(answer);
Steve Antondbf9d032018-01-19 15:23:40 -0800309 auto* data_content = cricket::GetFirstDataContent(answer->description());
Steve Antonda6c0952017-10-23 11:41:54 -0700310 ASSERT_TRUE(data_content);
311 EXPECT_FALSE(data_content->rejected);
Steve Antondbf9d032018-01-19 15:23:40 -0800312 EXPECT_TRUE(
313 answer->description()->GetTransportInfoByName(data_content->name));
Steve Antonda6c0952017-10-23 11:41:54 -0700314}
315
Steve Antondbf9d032018-01-19 15:23:40 -0800316TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700317 CreateDataChannelWithDtlsDisabledSucceeds) {
318 RTCConfiguration config;
319 config.enable_dtls_srtp.emplace(false);
320 auto caller = CreatePeerConnection();
321
322 EXPECT_TRUE(caller->pc()->CreateDataChannel("dc", nullptr));
323}
324
Steve Antondbf9d032018-01-19 15:23:40 -0800325TEST_P(PeerConnectionDataChannelTest, CreateDataChannelWithSctpDisabledFails) {
Steve Antonda6c0952017-10-23 11:41:54 -0700326 PeerConnectionFactoryInterface::Options options;
327 options.disable_sctp_data_channels = true;
328 auto caller = CreatePeerConnection(RTCConfiguration(), options);
329
330 EXPECT_FALSE(caller->pc()->CreateDataChannel("dc", nullptr));
331}
332
333// Test that if a callee has SCTP disabled and receives an offer with an SCTP
334// data channel, the data section is rejected and no SCTP transport is created
335// on the callee.
Steve Antondbf9d032018-01-19 15:23:40 -0800336TEST_P(PeerConnectionDataChannelTest,
Steve Antonda6c0952017-10-23 11:41:54 -0700337 DataSectionRejectedIfCalleeHasSctpDisabled) {
338 auto caller = CreatePeerConnectionWithDataChannel();
339 PeerConnectionFactoryInterface::Options options;
340 options.disable_sctp_data_channels = true;
341 auto callee = CreatePeerConnection(RTCConfiguration(), options);
342
343 ASSERT_TRUE(callee->SetRemoteDescription(caller->CreateOfferAndSetAsLocal()));
344
345 EXPECT_FALSE(callee->sctp_transport_factory()->last_fake_sctp_transport());
346
347 auto answer = callee->CreateAnswer();
Steve Antondbf9d032018-01-19 15:23:40 -0800348 auto* data_content = cricket::GetFirstDataContent(answer->description());
Steve Antonda6c0952017-10-23 11:41:54 -0700349 ASSERT_TRUE(data_content);
350 EXPECT_TRUE(data_content->rejected);
351}
352
Steve Antondbf9d032018-01-19 15:23:40 -0800353TEST_P(PeerConnectionDataChannelTest, SctpPortPropagatedFromSdpToTransport) {
Steve Antonda6c0952017-10-23 11:41:54 -0700354 constexpr int kNewSendPort = 9998;
355 constexpr int kNewRecvPort = 7775;
356
357 auto caller = CreatePeerConnectionWithDataChannel();
358 auto callee = CreatePeerConnectionWithDataChannel();
359
360 auto offer = caller->CreateOffer();
361 ChangeSctpPortOnDescription(offer->description(), kNewSendPort);
362 ASSERT_TRUE(callee->SetRemoteDescription(std::move(offer)));
363
364 auto answer = callee->CreateAnswer();
365 ChangeSctpPortOnDescription(answer->description(), kNewRecvPort);
366 ASSERT_TRUE(callee->SetLocalDescription(std::move(answer)));
367
368 auto* callee_transport =
369 callee->sctp_transport_factory()->last_fake_sctp_transport();
370 ASSERT_TRUE(callee_transport);
371 EXPECT_EQ(kNewSendPort, callee_transport->remote_port());
372 EXPECT_EQ(kNewRecvPort, callee_transport->local_port());
373}
374
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800375TEST_P(PeerConnectionDataChannelTest,
376 NoSctpTransportCreatedIfMediaTransportDataChannelsEnabled) {
377 RTCConfiguration config;
378 config.use_media_transport_for_data_channels = true;
379 config.enable_dtls_srtp = false; // SDES is required to use media transport.
380 auto caller = CreatePeerConnectionWithDataChannel(config);
381
382 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
383 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
384}
385
386TEST_P(PeerConnectionDataChannelTest,
387 MediaTransportDataChannelCreatedEvenIfSctpAvailable) {
388 RTCConfiguration config;
389 config.use_media_transport_for_data_channels = true;
390 config.enable_dtls_srtp = false; // SDES is required to use media transport.
391 PeerConnectionFactoryInterface::Options options;
392 options.disable_sctp_data_channels = false;
393 auto caller = CreatePeerConnectionWithDataChannel(config, options);
394
395 ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
396 EXPECT_FALSE(caller->sctp_transport_factory()->last_fake_sctp_transport());
397}
398
399TEST_P(PeerConnectionDataChannelTest,
400 CannotEnableBothMediaTransportAndRtpDataChannels) {
401 RTCConfiguration config;
402 config.enable_rtp_data_channel = true;
403 config.use_media_transport_for_data_channels = true;
404 config.enable_dtls_srtp = false; // SDES is required to use media transport.
405 EXPECT_EQ(CreatePeerConnection(config), nullptr);
406}
407
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800408// This test now DCHECKs, instead of failing to SetLocalDescription.
409TEST_P(PeerConnectionDataChannelTest, MediaTransportWithoutSdesFails) {
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800410 RTCConfiguration config;
411 config.use_media_transport_for_data_channels = true;
412 config.enable_dtls_srtp = true; // Disables SDES for data sections.
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800413
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800414 auto caller = CreatePeerConnectionWithDataChannel(config);
415
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800416 EXPECT_EQ(nullptr, caller);
Bjorn Mellem175aa2e2018-11-08 11:23:22 -0800417}
418
Guido Urdanetacecf87f2019-05-31 10:17:38 +0000419TEST_P(PeerConnectionDataChannelTest, ModernSdpSyntaxByDefault) {
Harald Alvestrand4aa11922019-05-14 22:00:01 +0200420 PeerConnectionInterface::RTCOfferAnswerOptions options;
421 auto caller = CreatePeerConnectionWithDataChannel();
422 auto offer = caller->CreateOffer(options);
423 EXPECT_FALSE(cricket::GetFirstSctpDataContentDescription(offer->description())
424 ->use_sctpmap());
425 std::string sdp;
426 offer->ToString(&sdp);
427 RTC_LOG(LS_ERROR) << sdp;
428 EXPECT_THAT(sdp, HasSubstr(" UDP/DTLS/SCTP webrtc-datachannel"));
429 EXPECT_THAT(sdp, Not(HasSubstr("a=sctpmap:")));
430}
431
432TEST_P(PeerConnectionDataChannelTest, ObsoleteSdpSyntaxIfSet) {
433 PeerConnectionInterface::RTCOfferAnswerOptions options;
434 options.use_obsolete_sctp_sdp = true;
435 auto caller = CreatePeerConnectionWithDataChannel();
436 auto offer = caller->CreateOffer(options);
437 EXPECT_TRUE(cricket::GetFirstSctpDataContentDescription(offer->description())
438 ->use_sctpmap());
439 std::string sdp;
440 offer->ToString(&sdp);
441 EXPECT_THAT(sdp, Not(HasSubstr(" UDP/DTLS/SCTP webrtc-datachannel")));
442 EXPECT_THAT(sdp, HasSubstr("a=sctpmap:"));
443}
444
Mirko Bonadeic84f6612019-01-31 12:20:57 +0100445INSTANTIATE_TEST_SUITE_P(PeerConnectionDataChannelTest,
446 PeerConnectionDataChannelTest,
447 Values(SdpSemantics::kPlanB,
448 SdpSemantics::kUnifiedPlan));
Steve Antondbf9d032018-01-19 15:23:40 -0800449
Steve Antonda6c0952017-10-23 11:41:54 -0700450} // namespace webrtc