mediasoup 3.19.19 → 3.19.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/node/lib/Worker.d.ts +1 -1
- package/node/lib/Worker.d.ts.map +1 -1
- package/node/lib/Worker.js +8 -2
- package/node/lib/WorkerTypes.d.ts +8 -4
- package/node/lib/WorkerTypes.d.ts.map +1 -1
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.d.ts.map +1 -1
- package/node/lib/index.js +2 -1
- package/node/lib/sctpParametersTypes.d.ts +3 -13
- package/node/lib/sctpParametersTypes.d.ts.map +1 -1
- package/node/lib/test/test-PlainTransport.js +8 -3
- package/node/lib/test/test-WebRtcTransport.js +9 -4
- package/package.json +10 -10
- package/worker/Makefile +0 -4
- package/worker/fuzzer/src/fuzzer.cpp +6 -5
- package/worker/include/RTC/DataConsumer.hpp +4 -14
- package/worker/include/RTC/SCTP/TODO_SCTP.md +18 -10
- package/worker/include/RTC/SCTP/association/Association.hpp +39 -31
- package/worker/include/RTC/SCTP/association/{AssociationDeferredListener.hpp → AssociationListenerDeferrer.hpp} +10 -8
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +77 -0
- package/worker/include/RTC/SCTP/association/NegotiatedCapabilities.hpp +2 -2
- package/worker/include/RTC/SCTP/association/PacketSender.hpp +2 -2
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +2 -2
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +272 -0
- package/worker/include/RTC/SCTP/association/TCBContext.hpp +67 -0
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +81 -11
- package/worker/include/RTC/SCTP/common/UnwrappedSequenceNumber.hpp +274 -0
- package/worker/include/RTC/SCTP/packet/Chunk.hpp +0 -1
- package/worker/include/RTC/SCTP/packet/UserData.hpp +1 -0
- package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +14 -10
- package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +14 -10
- package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +13 -2
- package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +7 -1
- package/worker/include/RTC/SCTP/public/AssociationListener.hpp +11 -0
- package/worker/include/RTC/SCTP/public/Message.hpp +1 -0
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +4 -4
- package/worker/include/RTC/SctpAssociation.hpp +2 -2
- package/worker/include/RTC/Transport.hpp +9 -13
- package/worker/include/Settings.hpp +2 -1
- package/worker/include/Utils.hpp +130 -6
- package/worker/meson.build +10 -39
- package/worker/meson_options.txt +0 -1
- package/worker/scripts/package-lock.json +6 -6
- package/worker/src/DepLibUring.cpp +1 -1
- package/worker/src/RTC/DataConsumer.cpp +5 -29
- package/worker/src/RTC/PipeTransport.cpp +15 -12
- package/worker/src/RTC/PlainTransport.cpp +15 -12
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +5 -5
- package/worker/src/RTC/RTP/RtpStream.cpp +2 -2
- package/worker/src/RTC/RTP/RtxStream.cpp +1 -1
- package/worker/src/RTC/RateCalculator.cpp +5 -5
- package/worker/src/RTC/SCTP/association/Association.cpp +218 -148
- package/worker/src/RTC/SCTP/association/{AssociationDeferredListener.cpp → AssociationListenerDeferrer.cpp} +38 -30
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +244 -0
- package/worker/src/RTC/SCTP/association/NegotiatedCapabilities.cpp +8 -6
- package/worker/src/RTC/SCTP/association/PacketSender.cpp +7 -2
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +8 -8
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +512 -0
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +45 -39
- package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +1 -1
- package/worker/src/RTC/SCTP/packet/errorCauses/UserInitiatedAbortErrorCause.cpp +1 -1
- package/worker/src/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.cpp +22 -5
- package/worker/src/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.cpp +22 -5
- package/worker/src/RTC/SCTP/tx/RetransmissionErrorCounter.cpp +1 -1
- package/worker/src/RTC/SctpAssociation.cpp +1 -2
- package/worker/src/RTC/SeqManager.cpp +4 -4
- package/worker/src/RTC/Transport.cpp +247 -134
- package/worker/src/RTC/WebRtcTransport.cpp +9 -5
- package/worker/src/Settings.cpp +21 -1
- package/worker/src/Worker.cpp +13 -10
- package/worker/src/lib.cpp +11 -8
- package/worker/tasks.py +2 -35
- package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +13 -12
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +20 -20
- package/worker/test/src/RTC/SCTP/common/TestUnwrappedSequenceNumber.cpp +210 -0
- package/worker/test/src/RTC/SCTP/packet/chunks/TestAbortAssociationChunk.cpp +2 -2
- package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatAckChunk.cpp +9 -4
- package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatRequestChunk.cpp +5 -0
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitAckChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +5 -5
- package/worker/test/src/RTC/SCTP/packet/chunks/TestReConfigChunk.cpp +19 -20
- package/worker/test/src/RTC/SCTP/packet/chunks/TestUnknownChunk.cpp +3 -0
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnknownErrorCause.cpp +3 -0
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIncomingSsnResetRequestParameter.cpp +24 -27
- package/worker/test/src/RTC/SCTP/packet/parameters/TestOutgoingSsnResetRequestParameter.cpp +25 -30
- package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +8 -6
- package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedExtensionsParameter.cpp +12 -0
- package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +5 -8
- package/worker/test/src/Utils/TestNumber.cpp +119 -49
- package/worker/test/src/tests.cpp +11 -8
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#include "RTC/SCTP/public/SctpTypes.hpp"
|
|
2
1
|
#define MS_CLASS "RTC::Transport"
|
|
3
2
|
// #define MS_LOG_DEV_LEVEL 3
|
|
4
3
|
|
|
5
4
|
#include "RTC/Transport.hpp"
|
|
6
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
7
|
-
#include "DepLibUring.hpp"
|
|
8
|
-
#endif
|
|
9
5
|
#include "Logger.hpp"
|
|
10
6
|
#include "MediaSoupErrors.hpp"
|
|
7
|
+
#include "Settings.hpp"
|
|
11
8
|
#include "Utils.hpp"
|
|
9
|
+
#ifdef MS_LIBURING_SUPPORTED
|
|
10
|
+
#include "DepLibUring.hpp"
|
|
11
|
+
#endif
|
|
12
12
|
#include "FBS/transport.h"
|
|
13
13
|
#include "RTC/BweType.hpp"
|
|
14
14
|
#include "RTC/Consts.hpp"
|
|
@@ -20,10 +20,8 @@
|
|
|
20
20
|
#include "RTC/RTCP/FeedbackRtpTransport.hpp"
|
|
21
21
|
#include "RTC/RTCP/XrDelaySinceLastRr.hpp"
|
|
22
22
|
#include "RTC/RtpDictionaries.hpp"
|
|
23
|
-
#ifdef MS_SCTP_STACK
|
|
24
23
|
#include "RTC/SCTP/association/Association.hpp"
|
|
25
24
|
#include "RTC/SCTP/public/SctpOptions.hpp"
|
|
26
|
-
#endif
|
|
27
25
|
#include "RTC/SimpleConsumer.hpp"
|
|
28
26
|
#include "RTC/SimulcastConsumer.hpp"
|
|
29
27
|
#include "RTC/SvcConsumer.hpp"
|
|
@@ -36,8 +34,8 @@
|
|
|
36
34
|
|
|
37
35
|
namespace RTC
|
|
38
36
|
{
|
|
39
|
-
static const size_t DefaultSctpSendBufferSize{ 262144 }; // 2^18.
|
|
40
|
-
static const size_t MaxSctpSendBufferSize{ 268435456 }; // 2^28.
|
|
37
|
+
static const size_t DefaultSctpSendBufferSize{ 262144 }; // 2^18 bytes.
|
|
38
|
+
static const size_t MaxSctpSendBufferSize{ 268435456 }; // 2^28 bytes.
|
|
41
39
|
|
|
42
40
|
/* Instance methods. */
|
|
43
41
|
|
|
@@ -112,28 +110,30 @@ namespace RTC
|
|
|
112
110
|
sctpSendBufferSize = DefaultSctpSendBufferSize;
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
113
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
114
|
+
{
|
|
115
|
+
// TODO: SCTP: Many interesting options missing.
|
|
116
|
+
// NOTE: When using the built-in SCTP stack, `numSctpStreams` given to the
|
|
117
|
+
// transport is ignored.
|
|
118
|
+
const RTC::SCTP::SctpOptions sctpOptions = { // TODO: SCTP: Sure?
|
|
119
|
+
.maxSendMessageSize = this->maxMessageSize,
|
|
120
|
+
.maxSendBufferSize = sctpSendBufferSize
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
this->sctpAssociation = std::make_unique<RTC::SCTP::Association>(sctpOptions, this);
|
|
124
|
+
}
|
|
125
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
126
|
+
else
|
|
127
|
+
{
|
|
128
|
+
// This may throw.
|
|
129
|
+
this->oldSctpAssociation = new RTC::SctpAssociation(
|
|
130
|
+
this,
|
|
131
|
+
options->numSctpStreams()->os(),
|
|
132
|
+
options->numSctpStreams()->mis(),
|
|
133
|
+
this->maxMessageSize,
|
|
134
|
+
sctpSendBufferSize,
|
|
135
|
+
options->isDataChannel());
|
|
136
|
+
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
// Create the RTCP timer.
|
|
@@ -184,11 +184,23 @@ namespace RTC
|
|
|
184
184
|
}
|
|
185
185
|
this->mapDataConsumers.clear();
|
|
186
186
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
188
|
+
{
|
|
189
|
+
// NOTE: When using the built-in SCTP stack we don't do anything here since
|
|
190
|
+
// the `Destroying()` method has already been called by the Transport subclas
|
|
191
|
+
// and it closed the SCTP Association.
|
|
192
|
+
// NOTE: We cannot do it here in the destructor because here we are no longer
|
|
193
|
+
// the Transport subclass but Transport parent (this is how the destruction
|
|
194
|
+
// chain works in C++).
|
|
195
|
+
}
|
|
196
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
197
|
+
else
|
|
198
|
+
{
|
|
199
|
+
// Delete SCTP association.
|
|
200
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
201
|
+
delete this->oldSctpAssociation;
|
|
202
|
+
this->oldSctpAssociation = nullptr;
|
|
203
|
+
}
|
|
192
204
|
|
|
193
205
|
// Delete the RTCP timer.
|
|
194
206
|
delete this->rtcpTimer;
|
|
@@ -361,12 +373,11 @@ namespace RTC
|
|
|
361
373
|
// Add sctpListener.
|
|
362
374
|
flatbuffers::Offset<FBS::Transport::SctpListener> sctpListener;
|
|
363
375
|
|
|
364
|
-
if (this->sctpAssociation)
|
|
376
|
+
if (Settings::configuration.useBuiltInSctpStack && this->sctpAssociation)
|
|
365
377
|
{
|
|
366
378
|
// Add sctpParameters.
|
|
367
379
|
sctpParameters = this->sctpAssociation->FillBuffer(builder);
|
|
368
380
|
|
|
369
|
-
#ifdef MS_SCTP_STACK
|
|
370
381
|
// NOTE: There is never permanent FAILED state.
|
|
371
382
|
switch (this->sctpAssociation->GetAssociationState())
|
|
372
383
|
{
|
|
@@ -395,8 +406,16 @@ namespace RTC
|
|
|
395
406
|
break;
|
|
396
407
|
}
|
|
397
408
|
}
|
|
398
|
-
|
|
399
|
-
|
|
409
|
+
|
|
410
|
+
sctpListener = this->sctpListener.FillBuffer(builder);
|
|
411
|
+
}
|
|
412
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
413
|
+
else if (!Settings::configuration.useBuiltInSctpStack && this->oldSctpAssociation)
|
|
414
|
+
{
|
|
415
|
+
// Add sctpParameters.
|
|
416
|
+
sctpParameters = this->oldSctpAssociation->FillBuffer(builder);
|
|
417
|
+
|
|
418
|
+
switch (this->oldSctpAssociation->GetState())
|
|
400
419
|
{
|
|
401
420
|
case RTC::SctpAssociation::SctpState::NEW:
|
|
402
421
|
{
|
|
@@ -428,7 +447,7 @@ namespace RTC
|
|
|
428
447
|
break;
|
|
429
448
|
}
|
|
430
449
|
}
|
|
431
|
-
|
|
450
|
+
|
|
432
451
|
sctpListener = this->sctpListener.FillBuffer(builder);
|
|
433
452
|
}
|
|
434
453
|
|
|
@@ -458,8 +477,9 @@ namespace RTC
|
|
|
458
477
|
rtpListenerOffset,
|
|
459
478
|
this->maxMessageSize,
|
|
460
479
|
sctpParameters,
|
|
461
|
-
this->sctpAssociation
|
|
462
|
-
|
|
480
|
+
(this->sctpAssociation || this->oldSctpAssociation)
|
|
481
|
+
? flatbuffers::Optional<FBS::SctpAssociation::SctpState>(sctpState)
|
|
482
|
+
: flatbuffers::nullopt,
|
|
463
483
|
sctpListener,
|
|
464
484
|
&traceEventTypes);
|
|
465
485
|
}
|
|
@@ -474,10 +494,9 @@ namespace RTC
|
|
|
474
494
|
// Add sctpState.
|
|
475
495
|
FBS::SctpAssociation::SctpState sctpState{ FBS::SctpAssociation::SctpState::NEW };
|
|
476
496
|
|
|
477
|
-
|
|
497
|
+
// Add sctpState.
|
|
498
|
+
if (Settings::configuration.useBuiltInSctpStack && this->sctpAssociation)
|
|
478
499
|
{
|
|
479
|
-
// Add sctpState.
|
|
480
|
-
#ifdef MS_SCTP_STACK
|
|
481
500
|
// NOTE: There is never permanent FAILED state.
|
|
482
501
|
switch (this->sctpAssociation->GetAssociationState())
|
|
483
502
|
{
|
|
@@ -506,8 +525,11 @@ namespace RTC
|
|
|
506
525
|
break;
|
|
507
526
|
}
|
|
508
527
|
}
|
|
509
|
-
|
|
510
|
-
|
|
528
|
+
}
|
|
529
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
530
|
+
else if (!Settings::configuration.useBuiltInSctpStack && this->oldSctpAssociation)
|
|
531
|
+
{
|
|
532
|
+
switch (this->oldSctpAssociation->GetState())
|
|
511
533
|
{
|
|
512
534
|
case RTC::SctpAssociation::SctpState::NEW:
|
|
513
535
|
{
|
|
@@ -539,7 +561,6 @@ namespace RTC
|
|
|
539
561
|
break;
|
|
540
562
|
}
|
|
541
563
|
}
|
|
542
|
-
#endif
|
|
543
564
|
}
|
|
544
565
|
|
|
545
566
|
return FBS::Transport::CreateStatsDirect(
|
|
@@ -549,8 +570,9 @@ namespace RTC
|
|
|
549
570
|
// timestamp.
|
|
550
571
|
nowMs,
|
|
551
572
|
// sctpState.
|
|
552
|
-
this->sctpAssociation
|
|
553
|
-
|
|
573
|
+
(this->sctpAssociation || this->oldSctpAssociation)
|
|
574
|
+
? flatbuffers::Optional<FBS::SctpAssociation::SctpState>(sctpState)
|
|
575
|
+
: flatbuffers::nullopt,
|
|
554
576
|
// bytesReceived.
|
|
555
577
|
this->recvTransmission.GetBytes(),
|
|
556
578
|
// recvBitrate.
|
|
@@ -1132,7 +1154,10 @@ namespace RTC
|
|
|
1132
1154
|
case Channel::ChannelRequest::Method::TRANSPORT_PRODUCE_DATA:
|
|
1133
1155
|
{
|
|
1134
1156
|
// Early check. The Transport must support SCTP or be direct.
|
|
1135
|
-
if (
|
|
1157
|
+
if (
|
|
1158
|
+
((Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1159
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation)) &&
|
|
1160
|
+
!this->direct)
|
|
1136
1161
|
{
|
|
1137
1162
|
MS_THROW_ERROR("SCTP not enabled and not a direct Transport");
|
|
1138
1163
|
}
|
|
@@ -1153,7 +1178,9 @@ namespace RTC
|
|
|
1153
1178
|
{
|
|
1154
1179
|
case RTC::DataProducer::Type::SCTP:
|
|
1155
1180
|
{
|
|
1156
|
-
if (
|
|
1181
|
+
if (
|
|
1182
|
+
(Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1183
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation))
|
|
1157
1184
|
{
|
|
1158
1185
|
delete dataProducer;
|
|
1159
1186
|
|
|
@@ -1225,12 +1252,16 @@ namespace RTC
|
|
|
1225
1252
|
|
|
1226
1253
|
if (dataProducer->GetType() == RTC::DataProducer::Type::SCTP)
|
|
1227
1254
|
{
|
|
1228
|
-
#ifdef MS_SCTP_STACK
|
|
1229
|
-
// TODO: SCTP
|
|
1230
|
-
#else
|
|
1231
1255
|
// Tell to the SCTP association.
|
|
1232
|
-
|
|
1233
|
-
|
|
1256
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1257
|
+
{
|
|
1258
|
+
this->sctpAssociation->MayConnect();
|
|
1259
|
+
}
|
|
1260
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1261
|
+
else
|
|
1262
|
+
{
|
|
1263
|
+
this->oldSctpAssociation->HandleDataProducer(dataProducer);
|
|
1264
|
+
}
|
|
1234
1265
|
}
|
|
1235
1266
|
|
|
1236
1267
|
break;
|
|
@@ -1239,7 +1270,10 @@ namespace RTC
|
|
|
1239
1270
|
case Channel::ChannelRequest::Method::TRANSPORT_CONSUME_DATA:
|
|
1240
1271
|
{
|
|
1241
1272
|
// Early check. The Transport must support SCTP or be direct.
|
|
1242
|
-
if (
|
|
1273
|
+
if (
|
|
1274
|
+
((Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1275
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation)) &&
|
|
1276
|
+
!this->direct)
|
|
1243
1277
|
{
|
|
1244
1278
|
MS_THROW_ERROR("SCTP not enabled and not a direct Transport");
|
|
1245
1279
|
}
|
|
@@ -1254,22 +1288,16 @@ namespace RTC
|
|
|
1254
1288
|
|
|
1255
1289
|
// This may throw.
|
|
1256
1290
|
auto* dataConsumer = new RTC::DataConsumer(
|
|
1257
|
-
this->shared,
|
|
1258
|
-
dataConsumerId,
|
|
1259
|
-
dataProducerId,
|
|
1260
|
-
#ifndef MS_SCTP_STACK
|
|
1261
|
-
this->sctpAssociation,
|
|
1262
|
-
#endif
|
|
1263
|
-
this,
|
|
1264
|
-
body,
|
|
1265
|
-
this->maxMessageSize);
|
|
1291
|
+
this->shared, dataConsumerId, dataProducerId, this, body, this->maxMessageSize);
|
|
1266
1292
|
|
|
1267
1293
|
// Verify the type of the DataConsumer.
|
|
1268
1294
|
switch (dataConsumer->GetType())
|
|
1269
1295
|
{
|
|
1270
1296
|
case RTC::DataConsumer::Type::SCTP:
|
|
1271
1297
|
{
|
|
1272
|
-
if (
|
|
1298
|
+
if (
|
|
1299
|
+
(Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1300
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation))
|
|
1273
1301
|
{
|
|
1274
1302
|
delete dataConsumer;
|
|
1275
1303
|
|
|
@@ -1328,21 +1356,29 @@ namespace RTC
|
|
|
1328
1356
|
|
|
1329
1357
|
if (dataConsumer->GetType() == RTC::DataConsumer::Type::SCTP)
|
|
1330
1358
|
{
|
|
1331
|
-
|
|
1332
|
-
if (this->sctpAssociation->GetAssociationState() == RTC::SCTP::Types::AssociationState::CONNECTED)
|
|
1333
|
-
#else
|
|
1334
|
-
if (this->sctpAssociation->GetState() == RTC::SctpAssociation::SctpState::CONNECTED)
|
|
1335
|
-
#endif
|
|
1359
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1336
1360
|
{
|
|
1337
|
-
|
|
1361
|
+
if (this->sctpAssociation->GetAssociationState() == RTC::SCTP::Types::AssociationState::CONNECTED)
|
|
1362
|
+
{
|
|
1363
|
+
// Tell to the DataConsumer.
|
|
1364
|
+
dataConsumer->SctpAssociationConnected();
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
// Tell to the SCTP association.
|
|
1368
|
+
this->sctpAssociation->MayConnect();
|
|
1338
1369
|
}
|
|
1370
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1371
|
+
else
|
|
1372
|
+
{
|
|
1373
|
+
if (this->oldSctpAssociation->GetState() == RTC::SctpAssociation::SctpState::CONNECTED)
|
|
1374
|
+
{
|
|
1375
|
+
// Tell to the DataConsumer.
|
|
1376
|
+
dataConsumer->SctpAssociationConnected();
|
|
1377
|
+
}
|
|
1339
1378
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
// Tell to the SCTP association.
|
|
1344
|
-
this->sctpAssociation->HandleDataConsumer(dataConsumer);
|
|
1345
|
-
#endif
|
|
1379
|
+
// Tell to the SCTP association.
|
|
1380
|
+
this->oldSctpAssociation->HandleDataConsumer(dataConsumer);
|
|
1381
|
+
}
|
|
1346
1382
|
}
|
|
1347
1383
|
|
|
1348
1384
|
break;
|
|
@@ -1469,6 +1505,14 @@ namespace RTC
|
|
|
1469
1505
|
|
|
1470
1506
|
case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATAPRODUCER:
|
|
1471
1507
|
{
|
|
1508
|
+
if (
|
|
1509
|
+
((Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1510
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation)) &&
|
|
1511
|
+
!this->direct)
|
|
1512
|
+
{
|
|
1513
|
+
MS_THROW_ERROR("cannot close DataProducer, SCTP not enabled and not a direct Transport");
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1472
1516
|
const auto* body = request->data->body_as<FBS::Transport::CloseDataProducerRequest>();
|
|
1473
1517
|
|
|
1474
1518
|
// This may throw.
|
|
@@ -1490,12 +1534,16 @@ namespace RTC
|
|
|
1490
1534
|
|
|
1491
1535
|
if (dataProducer->GetType() == RTC::DataProducer::Type::SCTP)
|
|
1492
1536
|
{
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1537
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1538
|
+
{
|
|
1539
|
+
// TODO: SCTP
|
|
1540
|
+
}
|
|
1541
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1542
|
+
else
|
|
1543
|
+
{
|
|
1544
|
+
// Tell the SctpAssociation so it can reset the SCTP stream.
|
|
1545
|
+
this->oldSctpAssociation->DataProducerClosed(dataProducer);
|
|
1546
|
+
}
|
|
1499
1547
|
}
|
|
1500
1548
|
|
|
1501
1549
|
// Delete it.
|
|
@@ -1508,6 +1556,14 @@ namespace RTC
|
|
|
1508
1556
|
|
|
1509
1557
|
case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATACONSUMER:
|
|
1510
1558
|
{
|
|
1559
|
+
if (
|
|
1560
|
+
((Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1561
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation)) &&
|
|
1562
|
+
!this->direct)
|
|
1563
|
+
{
|
|
1564
|
+
MS_THROW_ERROR("cannot close DataConsumer, SCTP not enabled and not a direct Transport");
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1511
1567
|
const auto* body = request->data->body_as<FBS::Transport::CloseDataConsumerRequest>();
|
|
1512
1568
|
|
|
1513
1569
|
// This may throw.
|
|
@@ -1523,12 +1579,16 @@ namespace RTC
|
|
|
1523
1579
|
|
|
1524
1580
|
if (dataConsumer->GetType() == RTC::DataConsumer::Type::SCTP)
|
|
1525
1581
|
{
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1582
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1583
|
+
{
|
|
1584
|
+
// TODO: SCTP
|
|
1585
|
+
}
|
|
1586
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1587
|
+
else
|
|
1588
|
+
{
|
|
1589
|
+
// Tell the SctpAssociation so it can reset the SCTP stream.
|
|
1590
|
+
this->oldSctpAssociation->DataConsumerClosed(dataConsumer);
|
|
1591
|
+
}
|
|
1532
1592
|
}
|
|
1533
1593
|
|
|
1534
1594
|
// Delete it.
|
|
@@ -1573,6 +1633,18 @@ namespace RTC
|
|
|
1573
1633
|
{
|
|
1574
1634
|
MS_TRACE();
|
|
1575
1635
|
|
|
1636
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1637
|
+
{
|
|
1638
|
+
if (this->sctpAssociation)
|
|
1639
|
+
{
|
|
1640
|
+
// NOTE: We don't invoke `Shutdown()` but `Close()` in the SCTP Association
|
|
1641
|
+
// because at this point we are closing everything and we won't have any
|
|
1642
|
+
// chance to complete the SCTP SHUTDOWN + SHUTDOWN_ACK + SHUTDOWN_COMPLETE
|
|
1643
|
+
// dance, so we invoke `Close()` which just sends a SCTP ABORT.
|
|
1644
|
+
this->sctpAssociation->Close();
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1576
1648
|
this->destroying = true;
|
|
1577
1649
|
}
|
|
1578
1650
|
|
|
@@ -1597,13 +1669,14 @@ namespace RTC
|
|
|
1597
1669
|
}
|
|
1598
1670
|
|
|
1599
1671
|
// Tell the SctpAssociation.
|
|
1600
|
-
if (this->sctpAssociation)
|
|
1672
|
+
if (Settings::configuration.useBuiltInSctpStack && this->sctpAssociation)
|
|
1601
1673
|
{
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1674
|
+
this->sctpAssociation->MayConnect();
|
|
1675
|
+
}
|
|
1676
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1677
|
+
else if (!Settings::configuration.useBuiltInSctpStack && this->oldSctpAssociation)
|
|
1678
|
+
{
|
|
1679
|
+
this->oldSctpAssociation->TransportConnected();
|
|
1607
1680
|
}
|
|
1608
1681
|
|
|
1609
1682
|
// Start the RTCP timer.
|
|
@@ -1650,14 +1723,11 @@ namespace RTC
|
|
|
1650
1723
|
dataConsumer->TransportDisconnected();
|
|
1651
1724
|
}
|
|
1652
1725
|
|
|
1726
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
1653
1727
|
// Tell the SctpAssociation.
|
|
1654
|
-
if (this->
|
|
1728
|
+
if (!Settings::configuration.useBuiltInSctpStack && this->oldSctpAssociation)
|
|
1655
1729
|
{
|
|
1656
|
-
|
|
1657
|
-
// TODO: SCTP
|
|
1658
|
-
#else
|
|
1659
|
-
this->sctpAssociation->TransportDisconnected();
|
|
1660
|
-
#endif
|
|
1730
|
+
this->oldSctpAssociation->TransportDisconnected();
|
|
1661
1731
|
}
|
|
1662
1732
|
|
|
1663
1733
|
// Stop the RTCP timer.
|
|
@@ -1784,7 +1854,9 @@ namespace RTC
|
|
|
1784
1854
|
{
|
|
1785
1855
|
MS_TRACE();
|
|
1786
1856
|
|
|
1787
|
-
if (
|
|
1857
|
+
if (
|
|
1858
|
+
(Settings::configuration.useBuiltInSctpStack && !this->sctpAssociation) ||
|
|
1859
|
+
(!Settings::configuration.useBuiltInSctpStack && !this->oldSctpAssociation))
|
|
1788
1860
|
{
|
|
1789
1861
|
MS_DEBUG_TAG(sctp, "ignoring SCTP packet (SCTP not enabled)");
|
|
1790
1862
|
|
|
@@ -1792,11 +1864,14 @@ namespace RTC
|
|
|
1792
1864
|
}
|
|
1793
1865
|
|
|
1794
1866
|
// Pass it to the SctpAssociation.
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1867
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
1868
|
+
{
|
|
1869
|
+
this->sctpAssociation->ReceiveSctpData(data, len);
|
|
1870
|
+
}
|
|
1871
|
+
else
|
|
1872
|
+
{
|
|
1873
|
+
this->oldSctpAssociation->ProcessSctpData(data, len);
|
|
1874
|
+
}
|
|
1800
1875
|
}
|
|
1801
1876
|
|
|
1802
1877
|
void Transport::CheckNoDataProducer(const std::string& dataProducerId) const
|
|
@@ -2877,6 +2952,31 @@ namespace RTC
|
|
|
2877
2952
|
SendMessage(dataConsumer, msg, len, ppid, cb);
|
|
2878
2953
|
}
|
|
2879
2954
|
|
|
2955
|
+
void Transport::OnDataConsumerNeedBufferedAmount(
|
|
2956
|
+
RTC::DataConsumer* /*dataConsumer*/, uint32_t& bufferedAmount)
|
|
2957
|
+
{
|
|
2958
|
+
MS_TRACE();
|
|
2959
|
+
|
|
2960
|
+
if (Settings::configuration.useBuiltInSctpStack && this->sctpAssociation)
|
|
2961
|
+
{
|
|
2962
|
+
// TODO: SCTP
|
|
2963
|
+
// TODO: Let's see how to obtain `streamId` argument from the DataConsumer.
|
|
2964
|
+
// bufferedAmount = this->sctpAssociation->GetStreamBufferedAmount(streamId);
|
|
2965
|
+
}
|
|
2966
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
2967
|
+
else if (!Settings::configuration.useBuiltInSctpStack && this->oldSctpAssociation)
|
|
2968
|
+
{
|
|
2969
|
+
// NOTE: The underlaying SCTP association uses a common send buffer for all
|
|
2970
|
+
// data consumers, hence the value given by this method indicates the data
|
|
2971
|
+
// buffered for all data consumers in the transport.
|
|
2972
|
+
bufferedAmount = this->oldSctpAssociation->GetSctpBufferedAmount();
|
|
2973
|
+
}
|
|
2974
|
+
else
|
|
2975
|
+
{
|
|
2976
|
+
bufferedAmount = 0;
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2880
2980
|
void Transport::OnDataConsumerDataProducerClosed(RTC::DataConsumer* dataConsumer)
|
|
2881
2981
|
{
|
|
2882
2982
|
MS_TRACE();
|
|
@@ -2887,43 +2987,43 @@ namespace RTC
|
|
|
2887
2987
|
// Notify the listener.
|
|
2888
2988
|
this->listener->OnTransportDataConsumerDataProducerClosed(this, dataConsumer);
|
|
2889
2989
|
|
|
2890
|
-
if (
|
|
2990
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
2891
2991
|
{
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2992
|
+
if (this->sctpAssociation && dataConsumer->GetType() == RTC::DataConsumer::Type::SCTP)
|
|
2993
|
+
{
|
|
2994
|
+
// TODO: SCTP
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
2998
|
+
else
|
|
2999
|
+
{
|
|
3000
|
+
if (this->oldSctpAssociation && dataConsumer->GetType() == RTC::DataConsumer::Type::SCTP)
|
|
3001
|
+
{
|
|
3002
|
+
// Tell the SctpAssociation so it can reset the SCTP stream.
|
|
3003
|
+
this->oldSctpAssociation->DataConsumerClosed(dataConsumer);
|
|
3004
|
+
}
|
|
2898
3005
|
}
|
|
2899
3006
|
|
|
2900
3007
|
// Delete it.
|
|
2901
3008
|
delete dataConsumer;
|
|
2902
3009
|
}
|
|
2903
3010
|
|
|
2904
|
-
#ifdef MS_SCTP_STACK
|
|
2905
3011
|
bool Transport::OnAssociationSendData(const uint8_t* data, size_t len)
|
|
2906
3012
|
{
|
|
2907
3013
|
MS_TRACE();
|
|
2908
3014
|
|
|
2909
|
-
// TODO: Check if this is still true.
|
|
2910
3015
|
// Ignore if destroying.
|
|
2911
3016
|
// NOTE: This is because when the child class (i.e. WebRtcTransport) is deleted,
|
|
2912
3017
|
// its destructor is called first and then the parent Transport's destructor,
|
|
2913
3018
|
// and we would end here calling SendSctpData() which is an abstract method.
|
|
2914
3019
|
if (this->destroying)
|
|
2915
3020
|
{
|
|
2916
|
-
|
|
2917
|
-
}
|
|
3021
|
+
MS_WARN_DEV("ignoring sending data because Transport is being destroying");
|
|
2918
3022
|
|
|
2919
|
-
if (this->sctpAssociation)
|
|
2920
|
-
{
|
|
2921
|
-
return SendSctpData(data, len);
|
|
2922
|
-
}
|
|
2923
|
-
else
|
|
2924
|
-
{
|
|
2925
3023
|
return false;
|
|
2926
3024
|
}
|
|
3025
|
+
|
|
3026
|
+
return SendSctpData(data, len);
|
|
2927
3027
|
}
|
|
2928
3028
|
|
|
2929
3029
|
void Transport::OnAssociationConnecting()
|
|
@@ -3090,8 +3190,23 @@ namespace RTC
|
|
|
3090
3190
|
// TODO: SCTP
|
|
3091
3191
|
}
|
|
3092
3192
|
|
|
3193
|
+
bool Transport::OnAssociationIsTransportReadyForSctp()
|
|
3194
|
+
{
|
|
3195
|
+
MS_TRACE();
|
|
3196
|
+
|
|
3197
|
+
// We are ready for SCTP traffic if the transport is connected (e.g. the
|
|
3198
|
+
// WebRtcTransport has ICE and DTLS connected) and there is at least a
|
|
3199
|
+
// DataProducer or DataConsumer.
|
|
3200
|
+
//
|
|
3201
|
+
// NOTE: We don't want to start SCTP connection if there are no DataProducers
|
|
3202
|
+
// and DataConsumers because the peer (e.g. a browser) may have not started
|
|
3203
|
+
// its SCTP stack (e.g. no "m=application" media section in its SDP) so if we
|
|
3204
|
+
// initiate the SCTP connection it would fail after some time.
|
|
3205
|
+
return IsConnected() && (this->mapDataProducers.size() > 0 || this->mapDataConsumers.size() > 0);
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3093
3208
|
// TODO: SCTP: Add OnAssociationLifecycleMessageXxxxxx() methods.
|
|
3094
|
-
|
|
3209
|
+
|
|
3095
3210
|
void Transport::OnSctpAssociationConnecting(RTC::SctpAssociation* /*sctpAssociation*/)
|
|
3096
3211
|
{
|
|
3097
3212
|
MS_TRACE();
|
|
@@ -3196,13 +3311,12 @@ namespace RTC
|
|
|
3196
3311
|
// and we would end here calling SendSctpData() which is an abstract method.
|
|
3197
3312
|
if (this->destroying)
|
|
3198
3313
|
{
|
|
3314
|
+
MS_WARN_DEV("ignoring sending data because Transport is being destroying");
|
|
3315
|
+
|
|
3199
3316
|
return;
|
|
3200
3317
|
}
|
|
3201
3318
|
|
|
3202
|
-
|
|
3203
|
-
{
|
|
3204
|
-
SendSctpData(data, len);
|
|
3205
|
-
}
|
|
3319
|
+
SendSctpData(data, len);
|
|
3206
3320
|
}
|
|
3207
3321
|
|
|
3208
3322
|
void Transport::OnSctpAssociationMessageReceived(
|
|
@@ -3253,11 +3367,10 @@ namespace RTC
|
|
|
3253
3367
|
|
|
3254
3368
|
if (dataConsumer->GetType() == RTC::DataConsumer::Type::SCTP)
|
|
3255
3369
|
{
|
|
3256
|
-
dataConsumer->
|
|
3370
|
+
dataConsumer->SetSctpAssociationBufferedAmount(bufferedAmount);
|
|
3257
3371
|
}
|
|
3258
3372
|
}
|
|
3259
3373
|
}
|
|
3260
|
-
#endif
|
|
3261
3374
|
|
|
3262
3375
|
void Transport::OnTransportCongestionControlClientBitrates(
|
|
3263
3376
|
RTC::TransportCongestionControlClient* /*tccClient*/,
|
|
@@ -856,11 +856,15 @@ namespace RTC
|
|
|
856
856
|
{
|
|
857
857
|
MS_TRACE();
|
|
858
858
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
859
|
+
if (Settings::configuration.useBuiltInSctpStack)
|
|
860
|
+
{
|
|
861
|
+
// TODO: SCTP
|
|
862
|
+
}
|
|
863
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
864
|
+
else
|
|
865
|
+
{
|
|
866
|
+
this->oldSctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb);
|
|
867
|
+
}
|
|
864
868
|
}
|
|
865
869
|
|
|
866
870
|
bool WebRtcTransport::SendSctpData(const uint8_t* data, size_t len)
|