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
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
#ifndef MS_RTC_SCTP_UNWRAPPED_SEQUENCE_NUMBER_HPP
|
|
2
|
+
#define MS_RTC_SCTP_UNWRAPPED_SEQUENCE_NUMBER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "Utils.hpp"
|
|
6
|
+
#include <limits>
|
|
7
|
+
#include <ostream>
|
|
8
|
+
#include <typeinfo>
|
|
9
|
+
|
|
10
|
+
namespace RTC
|
|
11
|
+
{
|
|
12
|
+
namespace SCTP
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* UnwrappedSequenceNumber handles wrapping sequence numbers and unwraps
|
|
16
|
+
* them to an int64_t value space, to allow wrapped sequence numbers to be
|
|
17
|
+
* easily compared for ordering.
|
|
18
|
+
*
|
|
19
|
+
* Sequence numbers are expected to be monotonically increasing, but they
|
|
20
|
+
* do not need to be unwrapped in order, as long as the difference to the
|
|
21
|
+
* previous one is not larger than half the range of the wrapped sequence
|
|
22
|
+
* number.
|
|
23
|
+
*/
|
|
24
|
+
template<typename T>
|
|
25
|
+
class UnwrappedSequenceNumber
|
|
26
|
+
{
|
|
27
|
+
public:
|
|
28
|
+
static_assert(!std::numeric_limits<T>::is_signed, "the wrapped type must be unsigned");
|
|
29
|
+
static_assert(
|
|
30
|
+
std::numeric_limits<T>::max() < std::numeric_limits<int64_t>::max(),
|
|
31
|
+
"the wrapped type must be less than the int64_t value space");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The unwrapper is a sort of factory and converts wrapped sequence
|
|
35
|
+
* numbers to unwrapped ones.
|
|
36
|
+
*/
|
|
37
|
+
class Unwrapper
|
|
38
|
+
{
|
|
39
|
+
public:
|
|
40
|
+
Unwrapper() = default;
|
|
41
|
+
|
|
42
|
+
Unwrapper(const Unwrapper&) = default;
|
|
43
|
+
|
|
44
|
+
Unwrapper& operator=(const Unwrapper&) = default;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
/**
|
|
48
|
+
* Given a wrapped `value`, and with knowledge of its current last seen
|
|
49
|
+
* largest number, will return a value that can be compared using normal
|
|
50
|
+
* operators, such as less-than, greater-than etc.
|
|
51
|
+
*
|
|
52
|
+
* This will also update the Unwrapper's state, to track the last seen
|
|
53
|
+
* largest value.
|
|
54
|
+
*/
|
|
55
|
+
UnwrappedSequenceNumber<T> Unwrap(T value)
|
|
56
|
+
{
|
|
57
|
+
if (!this->lastValue)
|
|
58
|
+
{
|
|
59
|
+
this->lastUnwrapped = value;
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
const uint64_t prev = this->lastValue->GetValue();
|
|
64
|
+
const uint64_t curr = value;
|
|
65
|
+
auto delta = static_cast<int64_t>(curr - prev);
|
|
66
|
+
const auto half = static_cast<int64_t>(1) << (sizeof(T) * 8 - 1);
|
|
67
|
+
|
|
68
|
+
if (delta < -half)
|
|
69
|
+
{
|
|
70
|
+
delta += static_cast<int64_t>(1) << (sizeof(T) * 8);
|
|
71
|
+
}
|
|
72
|
+
else if (delta > half)
|
|
73
|
+
{
|
|
74
|
+
delta -= static_cast<int64_t>(1) << (sizeof(T) * 8);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this->lastUnwrapped += delta;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this->lastValue = UnwrappedSequenceNumber<T>(value);
|
|
81
|
+
|
|
82
|
+
return UnwrappedSequenceNumber<T>(this->lastUnwrapped);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Similar to `Unwrap()`, but will not update the Unwrappers's internal
|
|
87
|
+
* state.
|
|
88
|
+
*/
|
|
89
|
+
UnwrappedSequenceNumber<T> PeekUnwrap(T value) const
|
|
90
|
+
{
|
|
91
|
+
if (!this->lastValue)
|
|
92
|
+
{
|
|
93
|
+
return UnwrappedSequenceNumber<T>(value);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const uint64_t prev = this->lastValue->GetValue();
|
|
97
|
+
const uint64_t curr = value;
|
|
98
|
+
auto delta = static_cast<int64_t>(curr - prev);
|
|
99
|
+
const auto half = static_cast<int64_t>(1) << (sizeof(T) * 8 - 1);
|
|
100
|
+
|
|
101
|
+
if (delta < -half)
|
|
102
|
+
{
|
|
103
|
+
delta += static_cast<int64_t>(1) << (sizeof(T) * 8);
|
|
104
|
+
}
|
|
105
|
+
else if (delta > half)
|
|
106
|
+
{
|
|
107
|
+
delta -= static_cast<int64_t>(1) << (sizeof(T) * 8);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return UnwrappedSequenceNumber<T>(this->lastUnwrapped + delta);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Resets the Unwrapper to its pristine state. Used when a sequence number
|
|
115
|
+
* is to be reset to zero.
|
|
116
|
+
*/
|
|
117
|
+
void Reset()
|
|
118
|
+
{
|
|
119
|
+
this->lastUnwrapped = 0;
|
|
120
|
+
this->lastValue.reset();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private:
|
|
124
|
+
int64_t lastUnwrapped{ 0 };
|
|
125
|
+
std::optional<UnwrappedSequenceNumber<T>> lastValue;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
public:
|
|
129
|
+
/**
|
|
130
|
+
* Returns a new sequence number based on `value`, and adding `delta`
|
|
131
|
+
* (which may be negative).
|
|
132
|
+
*/
|
|
133
|
+
static UnwrappedSequenceNumber<T> AddTo(UnwrappedSequenceNumber<T> value, int64_t delta)
|
|
134
|
+
{
|
|
135
|
+
return UnwrappedSequenceNumber<T>(value.value + delta);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns the absolute difference between `lhs` and `rhs`.
|
|
140
|
+
*/
|
|
141
|
+
static T Difference(UnwrappedSequenceNumber<T> lhs, UnwrappedSequenceNumber<T> rhs)
|
|
142
|
+
{
|
|
143
|
+
return (lhs.value > rhs.value) ? (lhs.value - rhs.value) : (rhs.value - lhs.value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private:
|
|
147
|
+
static constexpr auto ValueLimit = static_cast<int64_t>(1) << std::numeric_limits<T>::digits;
|
|
148
|
+
|
|
149
|
+
public:
|
|
150
|
+
explicit UnwrappedSequenceNumber(int64_t value) : value(value)
|
|
151
|
+
{
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public:
|
|
155
|
+
/**
|
|
156
|
+
* Returns the wrapped value this type represents.
|
|
157
|
+
*/
|
|
158
|
+
T Wrap() const
|
|
159
|
+
{
|
|
160
|
+
return static_cast<T>(this->value % UnwrappedSequenceNumber::ValueLimit);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
bool operator==(const UnwrappedSequenceNumber<T>& other) const
|
|
164
|
+
{
|
|
165
|
+
return this->value == other.value;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
bool operator!=(const UnwrappedSequenceNumber<T>& other) const
|
|
169
|
+
{
|
|
170
|
+
return this->value != other.value;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
bool operator<(const UnwrappedSequenceNumber<T>& other) const
|
|
174
|
+
{
|
|
175
|
+
return this->value < other.value;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
bool operator>(const UnwrappedSequenceNumber<T>& other) const
|
|
179
|
+
{
|
|
180
|
+
return this->value > other.value;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bool operator>=(const UnwrappedSequenceNumber<T>& other) const
|
|
184
|
+
{
|
|
185
|
+
return this->value >= other.value;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
bool operator<=(const UnwrappedSequenceNumber<T>& other) const
|
|
189
|
+
{
|
|
190
|
+
return this->value <= other.value;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Const accessors for underlying value.
|
|
194
|
+
|
|
195
|
+
constexpr const int64_t* operator->() const
|
|
196
|
+
{
|
|
197
|
+
return std::addressof(this->value);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
constexpr const int64_t& operator*() const&
|
|
201
|
+
{
|
|
202
|
+
return this->value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
constexpr const int64_t&& operator*() const&&
|
|
206
|
+
{
|
|
207
|
+
return std::move(this->value);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
constexpr const int64_t& GetValue() const&
|
|
211
|
+
{
|
|
212
|
+
return this->value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
constexpr const int64_t&& GetValue() const&&
|
|
216
|
+
{
|
|
217
|
+
return std::move(this->value);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
constexpr explicit operator const int64_t&() const&
|
|
221
|
+
{
|
|
222
|
+
return this->value;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Increments the value.
|
|
227
|
+
*/
|
|
228
|
+
void Increment()
|
|
229
|
+
{
|
|
230
|
+
++this->value;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Returns the next value relative to this sequence number.
|
|
235
|
+
*/
|
|
236
|
+
UnwrappedSequenceNumber<T> GetNextValue() const
|
|
237
|
+
{
|
|
238
|
+
return UnwrappedSequenceNumber<T>(this->value + 1);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private:
|
|
242
|
+
int64_t value{ 0 };
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* For logging purposes in Catch2 tests.
|
|
247
|
+
*/
|
|
248
|
+
template<typename T>
|
|
249
|
+
inline std::ostream& operator<<(std::ostream& os, const UnwrappedSequenceNumber<T>& s)
|
|
250
|
+
{
|
|
251
|
+
return os << "{T:" << typeid(T).name() << ", wrapped:" << s.Wrap();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
template<>
|
|
255
|
+
inline std::ostream& operator<<(std::ostream& os, const UnwrappedSequenceNumber<uint8_t>& s)
|
|
256
|
+
{
|
|
257
|
+
return os << "{T:uint8_t, wrapped:" << s.Wrap() << "}";
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
template<>
|
|
261
|
+
inline std::ostream& operator<<(std::ostream& os, const UnwrappedSequenceNumber<uint16_t>& s)
|
|
262
|
+
{
|
|
263
|
+
return os << "{T:uint16_t, wrapped:" << s.Wrap() << "}";
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
template<>
|
|
267
|
+
inline std::ostream& operator<<(std::ostream& os, const UnwrappedSequenceNumber<uint32_t>& s)
|
|
268
|
+
{
|
|
269
|
+
return os << "{T:uint32_t, wrapped:" << s.Wrap() << "}";
|
|
270
|
+
}
|
|
271
|
+
} // namespace SCTP
|
|
272
|
+
} // namespace RTC
|
|
273
|
+
|
|
274
|
+
#endif
|
|
@@ -279,7 +279,6 @@ namespace RTC
|
|
|
279
279
|
* - MediaSoupError - If `BuildParameterInPlace()` or
|
|
280
280
|
* `BuildErrorCauseInPlace()` was called before and the caller didn't
|
|
281
281
|
* invoke `Consolidate()` on the returned Parameter or Error Cause yet.
|
|
282
|
-
|
|
283
282
|
*/
|
|
284
283
|
virtual void AddParameter(const Parameter* parameter) final;
|
|
285
284
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "common.hpp"
|
|
5
5
|
#include "Utils.hpp"
|
|
6
6
|
#include "RTC/SCTP/packet/Parameter.hpp"
|
|
7
|
+
#include <vector>
|
|
7
8
|
|
|
8
9
|
namespace RTC
|
|
9
10
|
{
|
|
@@ -88,17 +89,9 @@ namespace RTC
|
|
|
88
89
|
|
|
89
90
|
void SetReconfigurationRequestSequenceNumber(uint32_t value);
|
|
90
91
|
|
|
91
|
-
uint16_t
|
|
92
|
-
{
|
|
93
|
-
return GetVariableLengthValueLength() / 2;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
uint16_t GetStreamAt(uint16_t idx) const
|
|
97
|
-
{
|
|
98
|
-
return Utils::Byte::Get2Bytes(GetVariableLengthValuePointer(), (idx * 2));
|
|
99
|
-
}
|
|
92
|
+
std::vector<uint16_t> GetStreamIds() const;
|
|
100
93
|
|
|
101
|
-
void
|
|
94
|
+
void AddStreamId(uint16_t streamId);
|
|
102
95
|
|
|
103
96
|
protected:
|
|
104
97
|
IncomingSsnResetRequestParameter* SoftClone(const uint8_t* buffer) const final;
|
|
@@ -111,6 +104,17 @@ namespace RTC
|
|
|
111
104
|
{
|
|
112
105
|
return IncomingSsnResetRequestParameter::IncomingSsnResetRequestParameterHeaderLength;
|
|
113
106
|
}
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
uint16_t GetNumberOfStreams() const
|
|
110
|
+
{
|
|
111
|
+
return GetVariableLengthValueLength() / 2;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
uint16_t GetStreamAt(uint16_t idx) const
|
|
115
|
+
{
|
|
116
|
+
return Utils::Byte::Get2Bytes(GetVariableLengthValuePointer(), (idx * 2));
|
|
117
|
+
}
|
|
114
118
|
};
|
|
115
119
|
} // namespace SCTP
|
|
116
120
|
} // namespace RTC
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "common.hpp"
|
|
5
5
|
#include "Utils.hpp"
|
|
6
6
|
#include "RTC/SCTP/packet/Parameter.hpp"
|
|
7
|
+
#include <vector>
|
|
7
8
|
|
|
8
9
|
namespace RTC
|
|
9
10
|
{
|
|
@@ -106,17 +107,9 @@ namespace RTC
|
|
|
106
107
|
|
|
107
108
|
void SetSenderLastAssignedTsn(uint32_t value);
|
|
108
109
|
|
|
109
|
-
uint16_t
|
|
110
|
-
{
|
|
111
|
-
return GetVariableLengthValueLength() / 2;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
uint16_t GetStreamAt(uint16_t idx) const
|
|
115
|
-
{
|
|
116
|
-
return Utils::Byte::Get2Bytes(GetVariableLengthValuePointer(), (idx * 2));
|
|
117
|
-
}
|
|
110
|
+
std::vector<uint16_t> GetStreamIds() const;
|
|
118
111
|
|
|
119
|
-
void
|
|
112
|
+
void AddStreamId(uint16_t streamId);
|
|
120
113
|
|
|
121
114
|
protected:
|
|
122
115
|
OutgoingSsnResetRequestParameter* SoftClone(const uint8_t* buffer) const final;
|
|
@@ -129,6 +122,17 @@ namespace RTC
|
|
|
129
122
|
{
|
|
130
123
|
return OutgoingSsnResetRequestParameter::OutgoingSsnResetRequestParameterHeaderLength;
|
|
131
124
|
}
|
|
125
|
+
|
|
126
|
+
private:
|
|
127
|
+
uint16_t GetNumberOfStreams() const
|
|
128
|
+
{
|
|
129
|
+
return GetVariableLengthValueLength() / 2;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
uint16_t GetStreamAt(uint16_t idx) const
|
|
133
|
+
{
|
|
134
|
+
return Utils::Byte::Get2Bytes(GetVariableLengthValuePointer(), (idx * 2));
|
|
135
|
+
}
|
|
132
136
|
};
|
|
133
137
|
} // namespace SCTP
|
|
134
138
|
} // namespace RTC
|
|
@@ -42,7 +42,7 @@ namespace RTC
|
|
|
42
42
|
enum class AlternateErrorDetectionMethod : uint32_t
|
|
43
43
|
{
|
|
44
44
|
NONE = 0x0000,
|
|
45
|
-
SCTP_OVER_DTLS = 0x0001
|
|
45
|
+
SCTP_OVER_DTLS = 0x0001,
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
public:
|
|
@@ -96,7 +96,18 @@ namespace RTC
|
|
|
96
96
|
|
|
97
97
|
AlternateErrorDetectionMethod GetAlternateErrorDetectionMethod() const
|
|
98
98
|
{
|
|
99
|
-
|
|
99
|
+
const auto method = Utils::Byte::Get4Bytes(GetBuffer(), 4);
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
method == static_cast<uint32_t>(AlternateErrorDetectionMethod::NONE) ||
|
|
103
|
+
method == static_cast<uint32_t>(AlternateErrorDetectionMethod::SCTP_OVER_DTLS))
|
|
104
|
+
{
|
|
105
|
+
return static_cast<AlternateErrorDetectionMethod>(method);
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
{
|
|
109
|
+
return AlternateErrorDetectionMethod::NONE;
|
|
110
|
+
}
|
|
100
111
|
}
|
|
101
112
|
|
|
102
113
|
void SetAlternateErrorDetectionMethod(AlternateErrorDetectionMethod alternateErrorDetectionMethod);
|
|
@@ -32,12 +32,18 @@ namespace RTC
|
|
|
32
32
|
|
|
33
33
|
virtual Types::AssociationState GetAssociationState() const = 0;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* May invoke `Connect()` but only if the parent transport is ready for
|
|
37
|
+
* SCTP transmission (e.g. the WebRtcTransport has ICE and DTLS connected).
|
|
38
|
+
*/
|
|
39
|
+
virtual void MayConnect() = 0;
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
42
|
* Initiate the SCTP association with the remote peer. It sends an INIT
|
|
37
43
|
* Chunk.
|
|
38
44
|
*
|
|
39
45
|
* @remarks
|
|
40
|
-
* - The SCTP association must be in
|
|
46
|
+
* - The SCTP association must be in New state.
|
|
41
47
|
*/
|
|
42
48
|
virtual void Connect() = 0;
|
|
43
49
|
|
|
@@ -143,6 +143,17 @@ namespace RTC
|
|
|
143
143
|
*/
|
|
144
144
|
virtual void OnAssociationTotalBufferedAmountLow() = 0;
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Called when the Association needs to know if the parent transport is
|
|
148
|
+
* ready for SCTP traffic (e.g. whether the WebRtcTransport has ICE and
|
|
149
|
+
* DTLS connected and at least a DataProducer or DataConsumer has been
|
|
150
|
+
* created). Returned boolean indicates it.
|
|
151
|
+
*
|
|
152
|
+
* @remarks
|
|
153
|
+
* - It is NOT allowed to call methods in Association within this callback.
|
|
154
|
+
*/
|
|
155
|
+
virtual bool OnAssociationIsTransportReadyForSctp() = 0;
|
|
156
|
+
|
|
146
157
|
/**
|
|
147
158
|
* SCTP message lifecycle events.
|
|
148
159
|
*
|
|
@@ -17,12 +17,12 @@ namespace RTC
|
|
|
17
17
|
/**
|
|
18
18
|
* Signaled source port.
|
|
19
19
|
*/
|
|
20
|
-
uint16_t sourcePort{
|
|
20
|
+
uint16_t sourcePort{ 5000 };
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Signaled destination port.
|
|
24
24
|
*/
|
|
25
|
-
uint16_t destinationPort{
|
|
25
|
+
uint16_t destinationPort{ 5000 };
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Announced maximum number of outbound streams (OS).
|
|
@@ -30,7 +30,7 @@ namespace RTC
|
|
|
30
30
|
* @remarks
|
|
31
31
|
* - We use maximum value by default.
|
|
32
32
|
*/
|
|
33
|
-
uint16_t
|
|
33
|
+
uint16_t announcedMaxOutboundStreams{ 65535 };
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Announced maximum number of inbound streams (MIS).
|
|
@@ -38,7 +38,7 @@ namespace RTC
|
|
|
38
38
|
* @remarks
|
|
39
39
|
* - We use maximum value by default.
|
|
40
40
|
*/
|
|
41
|
-
uint16_t
|
|
41
|
+
uint16_t announcedMaxInboundStreams{ 65535 };
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Maximum size of an SCTP Packet. It doesn't include any overhead of
|
|
@@ -18,14 +18,12 @@
|
|
|
18
18
|
#include "RTC/RTP/Packet.hpp"
|
|
19
19
|
#include "RTC/RateCalculator.hpp"
|
|
20
20
|
#include "RTC/RtpListener.hpp"
|
|
21
|
-
#ifdef MS_SCTP_STACK
|
|
22
21
|
#include "RTC/SCTP/public/AssociationInterface.hpp"
|
|
23
22
|
#include "RTC/SCTP/public/AssociationListener.hpp"
|
|
24
23
|
#include "RTC/SCTP/public/Message.hpp"
|
|
25
24
|
#include "RTC/SCTP/public/SctpTypes.hpp"
|
|
26
|
-
|
|
25
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
27
26
|
#include "RTC/SctpAssociation.hpp"
|
|
28
|
-
#endif
|
|
29
27
|
#include "RTC/SctpListener.hpp"
|
|
30
28
|
#include "RTC/Shared.hpp"
|
|
31
29
|
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
|
|
@@ -44,11 +42,9 @@ namespace RTC
|
|
|
44
42
|
public RTC::Consumer::Listener,
|
|
45
43
|
public RTC::DataProducer::Listener,
|
|
46
44
|
public RTC::DataConsumer::Listener,
|
|
47
|
-
#ifdef MS_SCTP_STACK
|
|
48
45
|
public RTC::SCTP::AssociationListener,
|
|
49
|
-
|
|
46
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
50
47
|
public RTC::SctpAssociation::Listener,
|
|
51
|
-
#endif
|
|
52
48
|
public RTC::TransportCongestionControlClient::Listener,
|
|
53
49
|
public RTC::TransportCongestionControlServer::Listener,
|
|
54
50
|
public Channel::ChannelSocket::RequestHandler,
|
|
@@ -289,9 +285,10 @@ namespace RTC
|
|
|
289
285
|
size_t len,
|
|
290
286
|
uint32_t ppid,
|
|
291
287
|
onQueuedCallback* cb = nullptr) override;
|
|
288
|
+
void OnDataConsumerNeedBufferedAmount(
|
|
289
|
+
RTC::DataConsumer* dataConsumer, uint32_t& bufferedAmount) override;
|
|
292
290
|
void OnDataConsumerDataProducerClosed(RTC::DataConsumer* dataConsumer) override;
|
|
293
291
|
|
|
294
|
-
#ifdef MS_SCTP_STACK
|
|
295
292
|
/* Pure virtual methods inherited from RTC::SCTP::AssociationListener. */
|
|
296
293
|
public:
|
|
297
294
|
bool OnAssociationSendData(const uint8_t* data, size_t len) override;
|
|
@@ -308,9 +305,11 @@ namespace RTC
|
|
|
308
305
|
void OnAssociationInboundStreamsReset(std::span<const uint16_t> inboundStreamIds) override;
|
|
309
306
|
void OnAssociationStreamBufferedAmountLow(uint16_t streamId) override;
|
|
310
307
|
void OnAssociationTotalBufferedAmountLow() override;
|
|
308
|
+
bool OnAssociationIsTransportReadyForSctp() override;
|
|
311
309
|
// TODO: SCTP: Add OnAssociationLifecycleMessageXxxxxx() methods.
|
|
312
|
-
|
|
310
|
+
|
|
313
311
|
/* Pure virtual methods inherited from RTC::SctpAssociation::Listener. */
|
|
312
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
314
313
|
public:
|
|
315
314
|
void OnSctpAssociationConnecting(RTC::SctpAssociation* sctpAssociation) override;
|
|
316
315
|
void OnSctpAssociationConnected(RTC::SctpAssociation* sctpAssociation) override;
|
|
@@ -326,7 +325,6 @@ namespace RTC
|
|
|
326
325
|
uint32_t ppid) override;
|
|
327
326
|
void OnSctpAssociationBufferedAmount(
|
|
328
327
|
RTC::SctpAssociation* sctpAssociation, uint32_t bufferedAmount) override;
|
|
329
|
-
#endif
|
|
330
328
|
|
|
331
329
|
/* Pure virtual methods inherited from RTC::TransportCongestionControlClient::Listener. */
|
|
332
330
|
public:
|
|
@@ -364,11 +362,9 @@ namespace RTC
|
|
|
364
362
|
RTC::Shared* shared{ nullptr };
|
|
365
363
|
size_t maxMessageSize{ 262144u };
|
|
366
364
|
// Allocated by this.
|
|
367
|
-
#ifdef MS_SCTP_STACK
|
|
368
365
|
std::unique_ptr<RTC::SCTP::AssociationInterface> sctpAssociation{ nullptr };
|
|
369
|
-
|
|
370
|
-
RTC::SctpAssociation*
|
|
371
|
-
#endif
|
|
366
|
+
// TODO: Remove once we only use built-in SCTP stack.
|
|
367
|
+
RTC::SctpAssociation* oldSctpAssociation{ nullptr };
|
|
372
368
|
|
|
373
369
|
private:
|
|
374
370
|
// Passed by argument.
|
|
@@ -39,7 +39,8 @@ public:
|
|
|
39
39
|
std::string dtlsCertificateFile;
|
|
40
40
|
std::string dtlsPrivateKeyFile;
|
|
41
41
|
std::string libwebrtcFieldTrials{ "WebRTC-Bwe-AlrLimitedBackoff/Enabled/" };
|
|
42
|
-
bool
|
|
42
|
+
bool disableLiburing{ false };
|
|
43
|
+
bool useBuiltInSctpStack{ false };
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
public:
|