mediasoup 3.28.0 → 3.29.0
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/CHANGELOG.md +12 -0
- package/node/lib/PipeTransportTypes.d.ts +6 -1
- package/node/lib/PipeTransportTypes.d.ts.map +1 -1
- package/node/lib/PlainTransportTypes.d.ts +6 -1
- package/node/lib/PlainTransportTypes.d.ts.map +1 -1
- package/node/lib/Router.d.ts +4 -4
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +10 -7
- package/node/lib/RouterTypes.d.ts +7 -1
- package/node/lib/RouterTypes.d.ts.map +1 -1
- package/node/lib/Transport.d.ts +2 -1
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +17 -6
- package/node/lib/TransportTypes.d.ts +12 -2
- package/node/lib/TransportTypes.d.ts.map +1 -1
- package/node/lib/WebRtcTransportTypes.d.ts +6 -1
- package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
- package/node/lib/fbs/transport/options.d.ts +6 -2
- package/node/lib/fbs/transport/options.d.ts.map +1 -1
- package/node/lib/fbs/transport/options.js +19 -7
- package/node/lib/fbs/transport/sctp-zero-checksum.d.ts +6 -0
- package/node/lib/fbs/transport/sctp-zero-checksum.d.ts.map +1 -0
- package/node/lib/fbs/transport/sctp-zero-checksum.js +11 -0
- package/node/lib/fbs/transport/stats.d.ts +2 -8
- package/node/lib/fbs/transport/stats.d.ts.map +1 -1
- package/node/lib/fbs/transport/stats.js +5 -29
- package/node/lib/fbs/transport.d.ts +1 -0
- package/node/lib/fbs/transport.d.ts.map +1 -1
- package/node/lib/fbs/transport.js +4 -2
- package/npm-scripts.mjs +35 -44
- package/package.json +10 -6
- package/worker/fbs/transport.fbs +9 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +14 -1
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +17 -4
- package/worker/include/RTC/BWE/AimdRateControl.hpp +9 -9
- package/worker/include/RTC/BWE/BweTypes.hpp +54 -17
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +3 -3
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +2 -2
- package/worker/include/RTC/BWE/LossBasedController.hpp +4 -4
- package/worker/include/RTC/BWE/OveruseDetector.hpp +5 -4
- package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +1 -1
- package/worker/include/RTC/BWE/ProbeController.hpp +6 -6
- package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +2 -6
- package/worker/include/RTC/BWE/ProbingScheduler.hpp +3 -7
- package/worker/include/RTC/BWE/ReceiverTransportCongestionController.hpp +148 -0
- package/worker/include/RTC/BWE/RembGenerator.hpp +4 -3
- package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +1 -1
- package/worker/include/RTC/BWE/SenderTransportCongestionController.hpp +343 -0
- package/worker/include/RTC/BWE/TargetRateController.hpp +4 -1
- package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +5 -4
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +3 -3
- package/worker/include/RTC/Consumer.hpp +8 -1
- package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +36 -10
- package/worker/include/RTC/RTP/RtpStream.hpp +21 -0
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +1 -0
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +122 -9
- package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +12 -3
- package/worker/include/RTC/TransportCongestionControlClient.hpp +0 -5
- package/worker/include/RTC/TransportCongestionControlServer.hpp +0 -5
- package/worker/include/Utils.hpp +9 -2
- package/worker/meson.build +4 -0
- package/worker/src/RTC/BWE/AimdRateControl.cpp +22 -22
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +16 -20
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +1 -1
- package/worker/src/RTC/BWE/OveruseDetector.cpp +8 -8
- package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +2 -2
- package/worker/src/RTC/BWE/ProbeController.cpp +1 -1
- package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +1 -6
- package/worker/src/RTC/BWE/ProbingScheduler.cpp +2 -7
- package/worker/src/RTC/BWE/ReceiverTransportCongestionController.cpp +207 -0
- package/worker/src/RTC/BWE/RembGenerator.cpp +1 -1
- package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +1 -1
- package/worker/src/RTC/BWE/SenderTransportCongestionController.cpp +599 -0
- package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +2 -3
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +5 -5
- package/worker/src/RTC/Consumer.cpp +3 -2
- package/worker/src/RTC/DataConsumer.cpp +2 -2
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +21 -8
- package/worker/src/RTC/RTP/RtpStream.cpp +0 -3
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +57 -71
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +428 -244
- package/worker/src/RTC/RTP/RtxStream.cpp +14 -19
- package/worker/src/RTC/SCTP/association/Association.cpp +3 -2
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +26 -6
- package/worker/src/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.cpp +4 -3
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +4 -2
- package/worker/src/RTC/Transport.cpp +49 -20
- package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -66
- package/worker/src/RTC/TransportCongestionControlServer.cpp +0 -55
- package/worker/src/Utils/Crypto.cpp +114 -98
- package/worker/subprojects/catch2.wrap +6 -6
- package/worker/subprojects/openssl.wrap +11 -12
- package/worker/subprojects/packagefiles/ankerl-unordered-dense/meson.build +1 -1
- package/worker/subprojects/unordered-dense.wrap +4 -4
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +5 -5
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +26 -23
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +8 -8
- package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +4 -4
- package/worker/test/src/RTC/BWE/TestProbeController.cpp +35 -32
- package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +2 -17
- package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +1 -25
- package/worker/test/src/RTC/BWE/TestReceiverTransportCongestionController.cpp +346 -0
- package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +1 -1
- package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +9 -9
- package/worker/test/src/RTC/BWE/TestSenderTransportCongestionController.cpp +510 -0
- package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +16 -14
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +6 -6
- package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +1 -2
- package/worker/test/src/RTC/RTCP/TestBye.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsAfb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsFir.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsLei.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsPli.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRpsi.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsSli.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsTst.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsVbcm.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpEcn.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpNack.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpSrReq.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTllei.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestReceiverReport.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestSenderReport.cpp +1 -1
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +60 -28
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +1 -1
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +746 -24
- package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +42 -0
- package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +54 -5
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +80 -15
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +410 -3
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +37 -5
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +5 -4
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +11 -10
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +1 -1
- package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
- package/worker/test/src/RTC/TestPortManager.cpp +2 -2
- package/worker/test/src/RTC/TestRateCalculator.cpp +1 -1
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +21 -15
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +13 -13
- package/worker/test/src/RTC/TestRtpEncodingParameters.cpp +1 -1
- package/worker/test/src/RTC/TestSubchannelsCodec.cpp +2 -2
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +1 -1
- package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
- package/worker/test/src/Utils/TestCrypto.cpp +71 -2
- package/worker/test/src/Utils/TestTime.cpp +2 -2
|
@@ -131,7 +131,7 @@ SCENARIO("NackGenerator generator", "[rtp][rtcp][nack]")
|
|
|
131
131
|
return 1000 * 1000;
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
auto validate =
|
|
134
|
+
const auto validate =
|
|
135
135
|
[&shared](std::unique_ptr<RTC::RTP::Packet>& packet, std::vector<TestNackGeneratorInput>& inputs)
|
|
136
136
|
{
|
|
137
137
|
TestNackGeneratorListener listener;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
SCENARIO("PortManager", "[portmanager]")
|
|
14
14
|
{
|
|
15
15
|
// Helper: build an IPv4 `sockaddr_storage` from a dotted-quad string + port=0.
|
|
16
|
-
auto makeV4 = [](const char* dottedQuad)
|
|
16
|
+
const auto makeV4 = [](const char* dottedQuad)
|
|
17
17
|
{
|
|
18
18
|
sockaddr_storage ss{};
|
|
19
19
|
auto* in = reinterpret_cast<sockaddr_in*>(std::addressof(ss));
|
|
@@ -27,7 +27,7 @@ SCENARIO("PortManager", "[portmanager]")
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// Helper: build an IPv6 `sockaddr_storage` from a textual address + port=0.
|
|
30
|
-
auto makeV6 = [](const char* literal)
|
|
30
|
+
const auto makeV6 = [](const char* literal)
|
|
31
31
|
{
|
|
32
32
|
sockaddr_storage ss{};
|
|
33
33
|
auto* in6 = reinterpret_cast<sockaddr_in6*>(std::addressof(ss));
|
|
@@ -14,7 +14,7 @@ SCENARIO("RateCalculator", "[rate-calculator]")
|
|
|
14
14
|
std::optional<int64_t> rate;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
auto validate =
|
|
17
|
+
const auto validate =
|
|
18
18
|
[](RTC::RateCalculator& rate, int64_t timeBaseMs, const std::vector<TestRateCalculatorData>& input)
|
|
19
19
|
{
|
|
20
20
|
for (const auto& item : input)
|
|
@@ -69,7 +69,7 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
69
69
|
|
|
70
70
|
// Makes the Sender Report about `RemoteBaseTs` plus `idx` seconds of media reach
|
|
71
71
|
// us with no delay at all, and feeds it to the estimator.
|
|
72
|
-
auto receiveSenderReport = [&nowUs, &shared, &rtpStream, &estimator](uint32_t idx) -> void
|
|
72
|
+
const auto receiveSenderReport = [&nowUs, &shared, &rtpStream, &estimator](uint32_t idx) -> void
|
|
73
73
|
{
|
|
74
74
|
nowUs = LocalBaseUs + (idx * 1000000);
|
|
75
75
|
|
|
@@ -86,7 +86,7 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
86
86
|
|
|
87
87
|
// Makes a packet carrying the 'abs-capture-time' extension reach the stream, which
|
|
88
88
|
// is what tells a sender that does send it from one that only announced it.
|
|
89
|
-
auto receiveAbsCaptureTimePacket = [&nowUs, &rtpStream]() -> void
|
|
89
|
+
const auto receiveAbsCaptureTimePacket = [&nowUs, &rtpStream]() -> void
|
|
90
90
|
{
|
|
91
91
|
// Id the extension is given, which only has to match between what is written
|
|
92
92
|
// and what is read back.
|
|
@@ -124,9 +124,10 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
124
124
|
|
|
125
125
|
SECTION("no source until the first Producer has been taken into account")
|
|
126
126
|
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
127
|
+
REQUIRE(estimator.GetSource().has_value() == false);
|
|
128
|
+
REQUIRE(
|
|
129
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
130
|
+
false);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
SECTION("the first Producer chooses abs-capture-time when it negotiated it")
|
|
@@ -168,23 +169,26 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
168
169
|
// it however long this sender has been around.
|
|
169
170
|
nowUs += 60 * 1000000;
|
|
170
171
|
|
|
171
|
-
|
|
172
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
172
|
+
REQUIRE(
|
|
173
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
174
|
+
false);
|
|
173
175
|
REQUIRE(estimator.GetSource() == RTC::RemoteCaptureTimeEstimator::Source::ABS_CAPTURE_TIME);
|
|
174
176
|
|
|
175
177
|
// Still within the wait, since the extension travels on some packets rather
|
|
176
178
|
// than on every one and may simply not have arrived yet.
|
|
177
179
|
nowUs += 4 * 1000000;
|
|
178
180
|
|
|
179
|
-
|
|
180
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
181
|
+
REQUIRE(
|
|
182
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
183
|
+
false);
|
|
181
184
|
REQUIRE(estimator.GetSource() == RTC::RemoteCaptureTimeEstimator::Source::ABS_CAPTURE_TIME);
|
|
182
185
|
|
|
183
186
|
// Long enough without a single packet carrying it.
|
|
184
187
|
nowUs += 1 * 1000000;
|
|
185
188
|
|
|
186
|
-
|
|
187
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
189
|
+
REQUIRE(
|
|
190
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
191
|
+
false);
|
|
188
192
|
REQUIRE(estimator.GetSource() == RTC::RemoteCaptureTimeEstimator::Source::SENDER_REPORT);
|
|
189
193
|
}
|
|
190
194
|
|
|
@@ -211,8 +215,9 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
211
215
|
// A single Sender Report is not enough for the clock offset to be estimated.
|
|
212
216
|
receiveSenderReport(0);
|
|
213
217
|
|
|
214
|
-
|
|
215
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
218
|
+
REQUIRE(
|
|
219
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
220
|
+
false);
|
|
216
221
|
|
|
217
222
|
for (uint32_t idx{ 1 }; idx < RTC::RemoteClockOffsetEstimator::MinSampleCount; ++idx)
|
|
218
223
|
{
|
|
@@ -251,7 +256,8 @@ SCENARIO("RemoteCaptureTimeEstimator", "[rtp][rtcp][remotecapturetimeestimator]"
|
|
|
251
256
|
|
|
252
257
|
// Sender Reports have been received, but the source in use is not allowed to
|
|
253
258
|
// fall back to them.
|
|
254
|
-
|
|
255
|
-
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value()
|
|
259
|
+
REQUIRE(
|
|
260
|
+
estimator.GetLocalCaptureAtUs(std::addressof(rtpStream), RemoteBaseTs, nowUs).has_value() ==
|
|
261
|
+
false);
|
|
256
262
|
}
|
|
257
263
|
}
|
|
@@ -19,13 +19,13 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
19
19
|
// after having been generated by the sender.
|
|
20
20
|
//
|
|
21
21
|
// NOTE: The RTT is given in milliseconds, being that the unit of the argument.
|
|
22
|
-
auto feed = [](
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const auto feed = [](
|
|
23
|
+
RTC::RemoteClockOffsetEstimator& estimator,
|
|
24
|
+
int64_t remoteNtpUs,
|
|
25
|
+
int64_t localArrivalAtUs,
|
|
26
|
+
size_t count,
|
|
27
|
+
int64_t owdUs,
|
|
28
|
+
int64_t rttMs) -> void
|
|
29
29
|
{
|
|
30
30
|
for (size_t idx{ 0 }; idx < count; ++idx)
|
|
31
31
|
{
|
|
@@ -41,7 +41,7 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
41
41
|
{
|
|
42
42
|
feed(estimator, RemoteBaseUs, LocalBaseUs, minSampleCount - 1, 0, 0);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
REQUIRE(estimator.GetOffsetUs().has_value() == false);
|
|
45
45
|
|
|
46
46
|
// One more Sender Report reaches the minimum.
|
|
47
47
|
const int64_t elapsedUs = static_cast<int64_t>(minSampleCount - 1) * 1000000;
|
|
@@ -181,7 +181,7 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
181
181
|
estimator.AddSenderReport(RemoteBaseUs + 1000, LocalBaseUs, 0);
|
|
182
182
|
estimator.AddSenderReport(RemoteBaseUs + 2000, LocalBaseUs, 0);
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
REQUIRE(estimator.GetOffsetUs().has_value() == false);
|
|
185
185
|
|
|
186
186
|
// Two more compound packets reach the minimum.
|
|
187
187
|
estimator.AddSenderReport(RemoteBaseUs + 1000000, LocalBaseUs + 1000000, 0);
|
|
@@ -200,14 +200,14 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
200
200
|
estimator.AddSenderReport(0, LocalBaseUs + 1000000, 0);
|
|
201
201
|
estimator.AddSenderReport(0, LocalBaseUs + 2000000, 0);
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
REQUIRE(estimator.GetOffsetUs().has_value() == false);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
SECTION("remote times are translated into our clock")
|
|
207
207
|
{
|
|
208
208
|
const RTC::RemoteClockOffsetEstimator untrainedEstimator;
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
REQUIRE(untrainedEstimator.RemoteUsToLocalUs(RemoteBaseUs).has_value() == false);
|
|
211
211
|
|
|
212
212
|
feed(estimator, RemoteBaseUs, LocalBaseUs, minSampleCount, 0, 0);
|
|
213
213
|
|
|
@@ -219,7 +219,7 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
219
219
|
REQUIRE(estimator.RemoteUsToLocalUs(RemoteBaseUs + 500000).value() == LocalBaseUs + 500000);
|
|
220
220
|
|
|
221
221
|
// A remote time older than the origin of our clock cannot be translated.
|
|
222
|
-
|
|
222
|
+
REQUIRE(estimator.RemoteUsToLocalUs(0).has_value() == false);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
SECTION("Reset() clears the estimation")
|
|
@@ -230,7 +230,7 @@ SCENARIO("RemoteClockOffsetEstimator", "[rtp][rtcp][remoteclockoffsetestimator]"
|
|
|
230
230
|
|
|
231
231
|
estimator.Reset();
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
REQUIRE(estimator.GetOffsetUs().has_value() == false);
|
|
234
234
|
|
|
235
235
|
// The last arrival time is forgotten as well, so Sender Reports arriving at
|
|
236
236
|
// the very same times as before the reset are not taken as duplicates.
|
|
@@ -15,7 +15,7 @@ SCENARIO("parseScalabilityMode()")
|
|
|
15
15
|
bool ksvc = false;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
auto parseScalabilityMode = [](const std::string& scalabilityMode)
|
|
18
|
+
const auto parseScalabilityMode = [](const std::string& scalabilityMode)
|
|
19
19
|
{
|
|
20
20
|
struct ScalabilityMode result;
|
|
21
21
|
std::smatch match;
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
SCENARIO("SubchannelsCodec", "[subchannels]")
|
|
9
9
|
{
|
|
10
10
|
// Build a message with the given payload.
|
|
11
|
-
auto makeMessage = [](const std::vector<uint8_t>& payload)
|
|
11
|
+
const auto makeMessage = [](const std::vector<uint8_t>& payload)
|
|
12
12
|
{
|
|
13
13
|
return RTC::SCTP::Message(/*streamId*/ 1, /*ppid*/ 51, payload);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// Copy the current payload of a message into a std::vector.
|
|
17
|
-
auto payloadToVector = [](const RTC::SCTP::Message& message)
|
|
17
|
+
const auto payloadToVector = [](const RTC::SCTP::Message& message)
|
|
18
18
|
{
|
|
19
19
|
const auto payload = message.GetPayload();
|
|
20
20
|
|
|
@@ -101,7 +101,7 @@ SCENARIO("TransportCongestionControlServer", "[rtp]")
|
|
|
101
101
|
};
|
|
102
102
|
// clang-format on
|
|
103
103
|
|
|
104
|
-
auto validate =
|
|
104
|
+
const auto validate =
|
|
105
105
|
[&buffer,
|
|
106
106
|
&shared](std::vector<TestTransportCongestionControlServerInput>& inputs, TestResults& results)
|
|
107
107
|
{
|
|
@@ -31,7 +31,8 @@ SCENARIO("TransportTuple", "[transporttuple]")
|
|
|
31
31
|
return 1000 * 1000;
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
auto makeUdpSocket =
|
|
34
|
+
const auto makeUdpSocket =
|
|
35
|
+
[&listener, &shared](const std::string& ip, uint16_t minPort, uint16_t maxPort)
|
|
35
36
|
{
|
|
36
37
|
auto flags = RTC::Transport::SocketFlags{ .ipv6Only = false, .udpReusePort = false };
|
|
37
38
|
RTC::PortManager::PortRangeKey portRangeKey{};
|
|
@@ -47,7 +48,7 @@ SCENARIO("TransportTuple", "[transporttuple]")
|
|
|
47
48
|
return std::unique_ptr<RTC::UdpSocket>(udpSocket);
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
auto makeUdpSockAddr = [](int family, const std::string& ip, uint16_t port)
|
|
51
|
+
const auto makeUdpSockAddr = [](int family, const std::string& ip, uint16_t port)
|
|
51
52
|
{
|
|
52
53
|
if (family == AF_INET)
|
|
53
54
|
{
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#include "common.hpp"
|
|
2
2
|
#include "Utils.hpp"
|
|
3
3
|
#include <ankerl/unordered_dense.h>
|
|
4
|
+
#include <array>
|
|
4
5
|
#include <catch2/catch_test_macros.hpp>
|
|
5
6
|
#include <limits> // std::numeric_limits()
|
|
7
|
+
#include <random> // std::mt19937
|
|
6
8
|
|
|
7
9
|
SCENARIO("Utils::Crypto", "[utils][crypto]")
|
|
8
10
|
{
|
|
@@ -75,6 +77,73 @@ SCENARIO("Utils::Crypto", "[utils][crypto]")
|
|
|
75
77
|
REQUIRE(Utils::Crypto::GetCRC32c(data32Decrementing, sizeof(data32Decrementing)) == 0x5CDB3F11);
|
|
76
78
|
REQUIRE(Utils::Crypto::GetCRC32c(dataSCSICommandPDU, sizeof(dataSCSICommandPDU)) == 0x563A96D9);
|
|
77
79
|
}
|
|
80
|
+
|
|
81
|
+
SECTION("GetCRC32() and GetCRC32c() match a byte at a time reference")
|
|
82
|
+
{
|
|
83
|
+
// Guards the slice-by-8 implementations against regressions at the 8 byte block
|
|
84
|
+
// boundary and on unaligned input. Deliberately table free so that it shares
|
|
85
|
+
// nothing with the implementations under test.
|
|
86
|
+
const auto reference =
|
|
87
|
+
[](uint32_t polynomial, bool byteSwap, const uint8_t* data, size_t size) -> uint32_t
|
|
88
|
+
{
|
|
89
|
+
uint32_t crc{ 0xFFFFFFFF };
|
|
90
|
+
|
|
91
|
+
for (size_t i{ 0u }; i < size; ++i)
|
|
92
|
+
{
|
|
93
|
+
uint32_t byte{ static_cast<uint32_t>((crc ^ data[i]) & 0xFF) };
|
|
94
|
+
|
|
95
|
+
for (size_t bit{ 0u }; bit < 8u; ++bit)
|
|
96
|
+
{
|
|
97
|
+
byte = (byte & 1u) ? (byte >> 1) ^ polynomial : (byte >> 1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
crc = (crc >> 8) ^ byte;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const uint32_t result{ ~crc };
|
|
104
|
+
|
|
105
|
+
if (!byteSwap)
|
|
106
|
+
{
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return ((result & 0xff) << 24) | (((result >> 8) & 0xff) << 16) |
|
|
111
|
+
(((result >> 16) & 0xff) << 8) | ((result >> 24) & 0xff);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
std::mt19937 rng{ 20240101 };
|
|
115
|
+
std::array<uint8_t, 1024 + 8> buffer{};
|
|
116
|
+
|
|
117
|
+
for (auto& byte : buffer)
|
|
118
|
+
{
|
|
119
|
+
byte = static_cast<uint8_t>(rng());
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
size_t mismatches{ 0u };
|
|
123
|
+
|
|
124
|
+
// Every length up to 1024 bytes at every misalignment within an 8 byte word.
|
|
125
|
+
for (size_t offset{ 0u }; offset < 8u; ++offset)
|
|
126
|
+
{
|
|
127
|
+
for (size_t size{ 0u }; size <= 1024u; ++size)
|
|
128
|
+
{
|
|
129
|
+
const uint8_t* data = buffer.data() + offset;
|
|
130
|
+
|
|
131
|
+
// CRC-32 (IEEE 802.3), no byte swap.
|
|
132
|
+
if (Utils::Crypto::GetCRC32(data, size) != reference(0xEDB88320u, false, data, size))
|
|
133
|
+
{
|
|
134
|
+
++mismatches;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// CRC-32C (Castagnoli), byte swapped.
|
|
138
|
+
if (Utils::Crypto::GetCRC32c(data, size) != reference(0x82F63B78u, true, data, size))
|
|
139
|
+
{
|
|
140
|
+
++mismatches;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
REQUIRE(mismatches == 0u);
|
|
146
|
+
}
|
|
78
147
|
}
|
|
79
148
|
|
|
80
149
|
SCENARIO("Utils::Crypto::GetRandomUInt()", "[utils][crypto]")
|
|
@@ -84,7 +153,7 @@ SCENARIO("Utils::Crypto::GetRandomUInt()", "[utils][crypto]")
|
|
|
84
153
|
|
|
85
154
|
for (size_t i = 0; i < 200; ++i)
|
|
86
155
|
{
|
|
87
|
-
auto randomNumber =
|
|
156
|
+
const auto randomNumber =
|
|
88
157
|
Utils::Crypto::GetRandomUInt<uint32_t>(0, std::numeric_limits<uint32_t>::max());
|
|
89
158
|
|
|
90
159
|
REQUIRE(randomUint32Numbers.find(randomNumber) == randomUint32Numbers.end());
|
|
@@ -94,7 +163,7 @@ SCENARIO("Utils::Crypto::GetRandomUInt()", "[utils][crypto]")
|
|
|
94
163
|
|
|
95
164
|
for (size_t i = 0; i < 200; ++i)
|
|
96
165
|
{
|
|
97
|
-
auto randomNumber =
|
|
166
|
+
const auto randomNumber =
|
|
98
167
|
Utils::Crypto::GetRandomUInt<uint64_t>(0, std::numeric_limits<uint64_t>::max());
|
|
99
168
|
|
|
100
169
|
REQUIRE(randomUint64Numbers.find(randomNumber) == randomUint64Numbers.end());
|
|
@@ -64,12 +64,12 @@ SCENARIO("Utils::Time", "[utils][time]")
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Middle 32 bits of the given NTP timestamp.
|
|
67
|
-
auto toCompactNtp = [](uint32_t seconds, uint32_t fractions) -> uint32_t
|
|
67
|
+
const auto toCompactNtp = [](uint32_t seconds, uint32_t fractions) -> uint32_t
|
|
68
68
|
{
|
|
69
69
|
return (seconds << 16) | (fractions >> 16);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
auto toTimeUs = [](uint32_t seconds, uint32_t fractions) -> int64_t
|
|
72
|
+
const auto toTimeUs = [](uint32_t seconds, uint32_t fractions) -> int64_t
|
|
73
73
|
{
|
|
74
74
|
return Utils::Time::NtpToTimeUs(Utils::Time::Ntp{ .seconds = seconds, .fractions = fractions });
|
|
75
75
|
};
|