mediasoup 3.27.0 → 3.28.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 +19 -0
- package/node/lib/Consumer.d.ts.map +1 -1
- package/node/lib/Consumer.js +4 -51
- package/node/lib/Producer.d.ts.map +1 -1
- package/node/lib/Producer.js +4 -8
- package/node/lib/ProducerTypes.d.ts +4 -2
- package/node/lib/ProducerTypes.d.ts.map +1 -1
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +4 -0
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +7 -10
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts +3 -4
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts.map +1 -1
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.js +3 -4
- package/node/lib/ortc.d.ts +0 -2
- package/node/lib/ortc.d.ts.map +1 -1
- package/node/lib/ortc.js +11 -21
- package/node/lib/rtpMappingFbsUtils.d.ts +6 -0
- package/node/lib/rtpMappingFbsUtils.d.ts.map +1 -0
- package/node/lib/rtpMappingFbsUtils.js +65 -0
- package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/rtpParametersFbsUtils.js +0 -6
- package/node/lib/rtpParametersTypes.d.ts +1 -1
- package/node/lib/rtpParametersTypes.d.ts.map +1 -1
- package/node/lib/rtpStreamFbsUtils.d.ts +4 -0
- package/node/lib/rtpStreamFbsUtils.d.ts.map +1 -0
- package/node/lib/rtpStreamFbsUtils.js +51 -0
- package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
- package/node/lib/supportedRtpCapabilities.js +6 -13
- package/node/lib/test/test-Consumer.js +1 -13
- package/node/lib/test/test-DataConsumer.js +9 -0
- package/node/lib/test/test-DataProducer.js +38 -0
- package/node/lib/test/test-PipeTransport.js +27 -29
- package/node/lib/test/test-Producer.js +97 -0
- package/node/lib/test/test-ortc.js +34 -14
- package/package.json +10 -10
- package/worker/fbs/FBS/meson.build +25 -0
- package/worker/fbs/meson.build +15 -18
- package/worker/fbs/rtpParameters.fbs +0 -1
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +16 -2
- package/worker/include/DepLibUV.hpp +13 -0
- package/worker/include/RTC/BWE/AlrDetector.hpp +97 -0
- package/worker/include/RTC/BWE/BitrateProber.hpp +217 -0
- package/worker/include/RTC/BWE/BitrateUtils.hpp +39 -0
- package/worker/include/RTC/BWE/BweTypes.hpp +171 -3
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +0 -14
- package/worker/include/RTC/BWE/InterArrival.hpp +117 -0
- package/worker/include/RTC/BWE/IntervalBudget.hpp +81 -0
- package/worker/include/RTC/BWE/LossBasedController.hpp +625 -0
- package/worker/include/RTC/BWE/OveruseDetector.hpp +71 -0
- package/worker/include/RTC/BWE/OveruseEstimator.hpp +115 -0
- package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +84 -0
- package/worker/include/RTC/BWE/ProbeController.hpp +379 -0
- package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +130 -0
- package/worker/include/RTC/BWE/ProbingScheduler.hpp +187 -0
- package/worker/include/RTC/BWE/RembGenerator.hpp +96 -0
- package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +237 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +26 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +161 -25
- package/worker/include/RTC/BWE/TargetRateController.hpp +306 -0
- package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +146 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +73 -16
- package/worker/include/RTC/Consts.hpp +70 -0
- package/worker/include/RTC/DataConsumer.hpp +3 -5
- package/worker/include/RTC/DirectTransport.hpp +4 -5
- package/worker/include/RTC/PipeTransport.hpp +4 -5
- package/worker/include/RTC/PlainTransport.hpp +4 -5
- package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +6 -7
- package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +3 -1
- package/worker/include/RTC/RTP/Codecs/Tools.hpp +1 -1
- package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +0 -1
- package/worker/include/RTC/RTP/Packet.hpp +16 -4
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +0 -8
- package/worker/include/RTC/RTP/RtpStream.hpp +12 -9
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +22 -4
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -2
- package/worker/include/RTC/RTP/RtxStream.hpp +10 -4
- package/worker/include/RTC/RateCalculator.hpp +103 -24
- package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +33 -3
- package/worker/include/RTC/{RtcLogger.hpp → RtcLogger/RtpPacket.hpp} +5 -3
- package/worker/include/RTC/RtcLogger/SendBurst.hpp +88 -0
- package/worker/include/RTC/RtpDictionaries.hpp +3 -4
- package/worker/include/RTC/SCTP/association/Association.hpp +1 -1
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +36 -0
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +0 -1
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +9 -9
- package/worker/include/RTC/SCTP/rx/DataTracker.hpp +1 -1
- package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +11 -1
- package/worker/include/RTC/SctpDictionaries.hpp +2 -2
- package/worker/include/RTC/TcpConnection.hpp +2 -1
- package/worker/include/RTC/Transport.hpp +23 -8
- package/worker/include/RTC/TransportTuple.hpp +61 -6
- package/worker/include/RTC/WebRtcTransport.hpp +4 -5
- package/worker/include/Shared.hpp +5 -0
- package/worker/include/SharedInterface.hpp +10 -0
- package/worker/include/Utils.hpp +72 -3
- package/worker/include/common.hpp +12 -4
- package/worker/include/handles/SendCallbacks.hpp +34 -0
- package/worker/include/handles/TcpConnectionHandle.hpp +4 -12
- package/worker/include/handles/UdpSocketHandle.hpp +4 -8
- package/worker/meson.build +45 -1
- package/worker/meson_options.txt +1 -0
- package/worker/mocks/include/MockShared.hpp +16 -2
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +1 -1
- package/worker/scripts/package-lock.json +6 -6
- package/worker/src/RTC/BWE/AimdRateControl.cpp +4 -5
- package/worker/src/RTC/BWE/AlrDetector.cpp +80 -0
- package/worker/src/RTC/BWE/BitrateProber.cpp +256 -0
- package/worker/src/RTC/BWE/BitrateUtils.cpp +54 -0
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +2 -2
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +20 -37
- package/worker/src/RTC/BWE/InterArrival.cpp +216 -0
- package/worker/src/RTC/BWE/IntervalBudget.cpp +93 -0
- package/worker/src/RTC/BWE/LossBasedController.cpp +1194 -0
- package/worker/src/RTC/BWE/OveruseDetector.cpp +128 -0
- package/worker/src/RTC/BWE/OveruseEstimator.cpp +166 -0
- package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +222 -0
- package/worker/src/RTC/BWE/ProbeController.cpp +645 -0
- package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +140 -0
- package/worker/src/RTC/BWE/ProbingScheduler.cpp +196 -0
- package/worker/src/RTC/BWE/RembGenerator.cpp +169 -0
- package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +497 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +47 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +173 -50
- package/worker/src/RTC/BWE/TargetRateController.cpp +433 -0
- package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +377 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +102 -5
- package/worker/src/RTC/Consumer.cpp +7 -5
- package/worker/src/RTC/DataConsumer.cpp +8 -10
- package/worker/src/RTC/DirectTransport.cpp +14 -8
- package/worker/src/RTC/DtlsTransport.cpp +8 -8
- package/worker/src/RTC/ICE/IceCandidate.cpp +4 -4
- package/worker/src/RTC/ICE/IceServer.cpp +1 -1
- package/worker/src/RTC/PipeTransport.cpp +13 -8
- package/worker/src/RTC/PlainTransport.cpp +13 -8
- package/worker/src/RTC/Producer.cpp +14 -31
- package/worker/src/RTC/RTCP/Bye.cpp +1 -1
- package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +18 -0
- package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +2 -2
- package/worker/src/RTC/RTCP/FeedbackPsVbcm.cpp +2 -1
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +2 -2
- package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
- package/worker/src/RTC/RTP/Codecs/DependencyDescriptor.cpp +2 -1
- package/worker/src/RTC/RTP/Packet.cpp +26 -11
- package/worker/src/RTC/RTP/ProbationGenerator.cpp +5 -6
- package/worker/src/RTC/RTP/RtpStream.cpp +1 -1
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +69 -48
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +31 -31
- package/worker/src/RTC/RTP/RtxStream.cpp +22 -7
- package/worker/src/RTC/RateCalculator.cpp +133 -28
- package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +56 -1
- package/worker/src/RTC/{RtcLogger.cpp → RtcLogger/RtpPacket.cpp} +2 -2
- package/worker/src/RTC/RtcLogger/SendBurst.cpp +124 -0
- package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +2 -12
- package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +1 -1
- package/worker/src/RTC/SCTP/association/Association.cpp +16 -2
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +106 -1
- package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
- package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +3 -3
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
- package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +4 -4
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +4 -4
- package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +6 -10
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +2 -2
- package/worker/src/RTC/SrtpSession.cpp +2 -2
- package/worker/src/RTC/SvcProducerStreamManager.cpp +2 -2
- package/worker/src/RTC/TcpConnection.cpp +2 -2
- package/worker/src/RTC/Transport.cpp +112 -75
- package/worker/src/RTC/TransportTuple.cpp +4 -4
- package/worker/src/RTC/WebRtcServer.cpp +4 -3
- package/worker/src/RTC/WebRtcTransport.cpp +20 -13
- package/worker/src/Utils/BitStream.cpp +24 -0
- package/worker/src/handles/BackoffTimerHandle.cpp +1 -1
- package/worker/src/handles/TcpConnectionHandle.cpp +13 -23
- package/worker/src/handles/UdpSocketHandle.cpp +14 -21
- package/worker/tasks.py +43 -18
- package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +68 -14
- package/worker/test/include/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.hpp +125 -0
- package/worker/test/src/RTC/BWE/TestAlrDetector.cpp +110 -0
- package/worker/test/src/RTC/BWE/TestBitrateProber.cpp +418 -0
- package/worker/test/src/RTC/BWE/TestBitrateUtils.cpp +61 -0
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +4 -4
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +53 -37
- package/worker/test/src/RTC/BWE/TestInterArrival.cpp +643 -0
- package/worker/test/src/RTC/BWE/TestIntervalBudget.cpp +130 -0
- package/worker/test/src/RTC/BWE/TestLossBasedController.cpp +1199 -0
- package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +519 -0
- package/worker/test/src/RTC/BWE/TestProbeBitrateEstimator.cpp +266 -0
- package/worker/test/src/RTC/BWE/TestProbeController.cpp +1682 -0
- package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +265 -0
- package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +260 -0
- package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +285 -0
- package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +414 -0
- package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +296 -77
- package/worker/test/src/RTC/BWE/TestTargetRateController.cpp +337 -0
- package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +578 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +45 -0
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +133 -29
- package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +625 -0
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +19 -0
- package/worker/test/src/RTC/RTP/TestPacket.cpp +58 -4
- package/worker/test/src/RTC/RTP/TestProbationGenerator.cpp +3 -2
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +50 -0
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +59 -0
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +111 -0
- package/worker/test/src/RTC/TestRateCalculator.cpp +322 -60
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +95 -7
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +34 -16
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +31 -13
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +37 -19
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +10 -10
- package/worker/test/src/Utils/TestTime.cpp +120 -21
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#include "common.hpp"
|
|
2
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
3
|
+
#include "RTC/BWE/ProbeBitrateEstimator.hpp"
|
|
4
|
+
#include <catch2/catch_test_macros.hpp>
|
|
5
|
+
|
|
6
|
+
SCENARIO("BWE ProbeBitrateEstimator", "[bwe][probebitrateestimator]")
|
|
7
|
+
{
|
|
8
|
+
constexpr int64_t ReferenceTimeUs{ 1000 * 1000 * 1000 };
|
|
9
|
+
constexpr int64_t DefaultMinProbes{ 5 };
|
|
10
|
+
constexpr int64_t DefaultMinBytes{ 5000 };
|
|
11
|
+
// Fraction of the capacity found that is aimed for once a burst arrives
|
|
12
|
+
// clearly slower than it was sent.
|
|
13
|
+
constexpr double TargetUtilizationFraction{ 0.95 };
|
|
14
|
+
|
|
15
|
+
RTC::BWE::ProbeBitrateEstimator probeBitrateEstimator;
|
|
16
|
+
std::optional<int64_t> measuredBitrate;
|
|
17
|
+
|
|
18
|
+
// Feed the feedback of one packet of a burst that was meant to be made of the
|
|
19
|
+
// given number of packets and bytes, with times given in milliseconds from an
|
|
20
|
+
// arbitrary instant.
|
|
21
|
+
//
|
|
22
|
+
// NOTE: Split in two instead of taking the two limits by default argument,
|
|
23
|
+
// since a default argument may not name a variable of the enclosing function.
|
|
24
|
+
const auto addPacketFeedbackWithLimits = [&probeBitrateEstimator, &measuredBitrate](
|
|
25
|
+
int64_t clusterId,
|
|
26
|
+
int64_t sizeBytes,
|
|
27
|
+
int64_t sendTimeMs,
|
|
28
|
+
int64_t receiveTimeMs,
|
|
29
|
+
int64_t minProbes,
|
|
30
|
+
int64_t minBytes) -> void
|
|
31
|
+
{
|
|
32
|
+
RTC::BWE::Types::PacketResult packetResult;
|
|
33
|
+
|
|
34
|
+
packetResult.sentPacket.sendTimeUs = ReferenceTimeUs + (sendTimeMs * 1000);
|
|
35
|
+
packetResult.sentPacket.size = static_cast<size_t>(sizeBytes);
|
|
36
|
+
packetResult.sentPacket.probeCluster =
|
|
37
|
+
RTC::BWE::Types::ProbeCluster{ .id = clusterId, .minProbes = minProbes, .minBytes = minBytes };
|
|
38
|
+
packetResult.receiveTimeUs = ReferenceTimeUs + (receiveTimeMs * 1000);
|
|
39
|
+
|
|
40
|
+
measuredBitrate = probeBitrateEstimator.HandleProbeAndEstimateBitrate(packetResult);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// The same for a burst of the size that bursts usually are.
|
|
44
|
+
const auto addPacketFeedback =
|
|
45
|
+
[&addPacketFeedbackWithLimits](
|
|
46
|
+
int64_t clusterId, int64_t sizeBytes, int64_t sendTimeMs, int64_t receiveTimeMs) -> void
|
|
47
|
+
{
|
|
48
|
+
addPacketFeedbackWithLimits(
|
|
49
|
+
clusterId, sizeBytes, sendTimeMs, receiveTimeMs, DefaultMinProbes, DefaultMinBytes);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
SECTION("a burst delivered at the pace it was sent measures that pace")
|
|
53
|
+
{
|
|
54
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
55
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
56
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
57
|
+
addPacketFeedback(0, 1000, 30, 40);
|
|
58
|
+
|
|
59
|
+
REQUIRE(measuredBitrate.has_value());
|
|
60
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
61
|
+
REQUIRE(measuredBitrate.value() == 800000);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
SECTION("a burst of too few packets measures nothing")
|
|
65
|
+
{
|
|
66
|
+
addPacketFeedback(0, 2000, 0, 10);
|
|
67
|
+
addPacketFeedback(0, 2000, 10, 20);
|
|
68
|
+
addPacketFeedback(0, 2000, 20, 30);
|
|
69
|
+
|
|
70
|
+
REQUIRE(!measuredBitrate.has_value());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
SECTION("a burst of too few bytes measures nothing")
|
|
74
|
+
{
|
|
75
|
+
constexpr int64_t MinBytes{ 6000 };
|
|
76
|
+
|
|
77
|
+
addPacketFeedbackWithLimits(0, 800, 0, 10, DefaultMinProbes, MinBytes);
|
|
78
|
+
addPacketFeedbackWithLimits(0, 800, 10, 20, DefaultMinProbes, MinBytes);
|
|
79
|
+
addPacketFeedbackWithLimits(0, 800, 20, 30, DefaultMinProbes, MinBytes);
|
|
80
|
+
addPacketFeedbackWithLimits(0, 800, 30, 40, DefaultMinProbes, MinBytes);
|
|
81
|
+
addPacketFeedbackWithLimits(0, 800, 40, 50, DefaultMinProbes, MinBytes);
|
|
82
|
+
|
|
83
|
+
REQUIRE(!measuredBitrate.has_value());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
SECTION("a small burst is measured all the same")
|
|
87
|
+
{
|
|
88
|
+
constexpr int64_t MinBytes{ 1000 };
|
|
89
|
+
|
|
90
|
+
addPacketFeedbackWithLimits(0, 150, 0, 10, DefaultMinProbes, MinBytes);
|
|
91
|
+
addPacketFeedbackWithLimits(0, 150, 10, 20, DefaultMinProbes, MinBytes);
|
|
92
|
+
addPacketFeedbackWithLimits(0, 150, 20, 30, DefaultMinProbes, MinBytes);
|
|
93
|
+
addPacketFeedbackWithLimits(0, 150, 30, 40, DefaultMinProbes, MinBytes);
|
|
94
|
+
addPacketFeedbackWithLimits(0, 150, 40, 50, DefaultMinProbes, MinBytes);
|
|
95
|
+
addPacketFeedbackWithLimits(0, 150, 50, 60, DefaultMinProbes, MinBytes);
|
|
96
|
+
|
|
97
|
+
REQUIRE(measuredBitrate.has_value());
|
|
98
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
99
|
+
REQUIRE(measuredBitrate.value() == 120000);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
SECTION("a large burst is measured all the same")
|
|
103
|
+
{
|
|
104
|
+
constexpr int64_t MinProbes{ 30 };
|
|
105
|
+
constexpr int64_t MinBytes{ 312500 };
|
|
106
|
+
|
|
107
|
+
int64_t sendTimeMs{ 0 };
|
|
108
|
+
int64_t receiveTimeMs{ 5 };
|
|
109
|
+
|
|
110
|
+
for (int64_t i{ 0 }; i < 25; ++i)
|
|
111
|
+
{
|
|
112
|
+
addPacketFeedbackWithLimits(0, 12500, sendTimeMs, receiveTimeMs, MinProbes, MinBytes);
|
|
113
|
+
|
|
114
|
+
++sendTimeMs;
|
|
115
|
+
++receiveTimeMs;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
REQUIRE(measuredBitrate.has_value());
|
|
119
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
120
|
+
REQUIRE(measuredBitrate.value() == 100000000);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
SECTION("a burst arriving somewhat faster than it was sent measures the pace it was sent at")
|
|
124
|
+
{
|
|
125
|
+
addPacketFeedback(0, 1000, 0, 15);
|
|
126
|
+
addPacketFeedback(0, 1000, 10, 30);
|
|
127
|
+
addPacketFeedback(0, 1000, 20, 35);
|
|
128
|
+
addPacketFeedback(0, 1000, 30, 40);
|
|
129
|
+
|
|
130
|
+
REQUIRE(measuredBitrate.has_value());
|
|
131
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
132
|
+
REQUIRE(measuredBitrate.value() == 800000);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
SECTION("a burst arriving far faster than it was sent measures nothing")
|
|
136
|
+
{
|
|
137
|
+
addPacketFeedback(0, 1000, 0, 19);
|
|
138
|
+
addPacketFeedback(0, 1000, 10, 22);
|
|
139
|
+
addPacketFeedback(0, 1000, 20, 25);
|
|
140
|
+
addPacketFeedback(0, 1000, 40, 27);
|
|
141
|
+
|
|
142
|
+
REQUIRE(!measuredBitrate.has_value());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
SECTION("a burst arriving clearly slower than it was sent aims below what arrived")
|
|
146
|
+
{
|
|
147
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
148
|
+
addPacketFeedback(0, 1000, 10, 40);
|
|
149
|
+
addPacketFeedback(0, 1000, 20, 70);
|
|
150
|
+
addPacketFeedback(0, 1000, 30, 85);
|
|
151
|
+
|
|
152
|
+
// It was sent at 800 kbps and arrived at 320 kbps.
|
|
153
|
+
REQUIRE(measuredBitrate.has_value());
|
|
154
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
155
|
+
REQUIRE(measuredBitrate.value() == static_cast<int64_t>(TargetUtilizationFraction * 320000));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
SECTION("a burst that arrives all at once measures nothing")
|
|
159
|
+
{
|
|
160
|
+
addPacketFeedback(0, 1000, 0, 50);
|
|
161
|
+
addPacketFeedback(0, 1000, 10, 50);
|
|
162
|
+
addPacketFeedback(0, 1000, 20, 50);
|
|
163
|
+
addPacketFeedback(0, 1000, 40, 50);
|
|
164
|
+
|
|
165
|
+
REQUIRE(!measuredBitrate.has_value());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
SECTION("bursts are measured apart from each other")
|
|
169
|
+
{
|
|
170
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
171
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
172
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
173
|
+
addPacketFeedback(0, 1000, 40, 60);
|
|
174
|
+
|
|
175
|
+
// Sent at 600 kbps, arrived at 480 kbps.
|
|
176
|
+
REQUIRE(measuredBitrate.has_value());
|
|
177
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
178
|
+
REQUIRE(measuredBitrate.value() == static_cast<int64_t>(TargetUtilizationFraction * 480000));
|
|
179
|
+
|
|
180
|
+
addPacketFeedback(0, 1000, 50, 60);
|
|
181
|
+
|
|
182
|
+
// Sent at 640 kbps, arrived at 640 kbps.
|
|
183
|
+
REQUIRE(measuredBitrate.has_value());
|
|
184
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
185
|
+
REQUIRE(measuredBitrate.value() == 640000);
|
|
186
|
+
|
|
187
|
+
addPacketFeedback(1, 1000, 60, 70);
|
|
188
|
+
addPacketFeedback(1, 1000, 65, 77);
|
|
189
|
+
addPacketFeedback(1, 1000, 70, 84);
|
|
190
|
+
addPacketFeedback(1, 1000, 75, 90);
|
|
191
|
+
|
|
192
|
+
// Sent at 1600 kbps, arrived at 1200 kbps.
|
|
193
|
+
REQUIRE(measuredBitrate.has_value());
|
|
194
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
195
|
+
REQUIRE(measuredBitrate.value() == static_cast<int64_t>(TargetUtilizationFraction * 1200000));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
SECTION("a burst is forgotten once it can receive nothing else")
|
|
199
|
+
{
|
|
200
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
201
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
202
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
203
|
+
|
|
204
|
+
addPacketFeedback(1, 1000, 60, 70);
|
|
205
|
+
addPacketFeedback(1, 1000, 65, 77);
|
|
206
|
+
addPacketFeedback(1, 1000, 70, 84);
|
|
207
|
+
addPacketFeedback(1, 1000, 75, 90);
|
|
208
|
+
|
|
209
|
+
REQUIRE(measuredBitrate.has_value());
|
|
210
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
211
|
+
REQUIRE(measuredBitrate.value() == static_cast<int64_t>(TargetUtilizationFraction * 1200000));
|
|
212
|
+
|
|
213
|
+
// The packet that the first burst was missing, arriving six seconds later.
|
|
214
|
+
addPacketFeedback(0, 1000, 40 + 6000, 60 + 6000);
|
|
215
|
+
|
|
216
|
+
REQUIRE(!measuredBitrate.has_value());
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
SECTION("the packet sent last doesn't count towards the pace it was sent at")
|
|
220
|
+
{
|
|
221
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
222
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
223
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
224
|
+
addPacketFeedback(0, 1000, 30, 40);
|
|
225
|
+
addPacketFeedback(0, 1500, 40, 50);
|
|
226
|
+
|
|
227
|
+
// Sent at 800 kbps and arrived at 900 kbps, so the pace it was sent at is
|
|
228
|
+
// what the bigger last packet doesn't inflate.
|
|
229
|
+
REQUIRE(measuredBitrate.has_value());
|
|
230
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
231
|
+
REQUIRE(measuredBitrate.value() == 800000);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
SECTION("the packet received first doesn't count towards the pace it arrived at")
|
|
235
|
+
{
|
|
236
|
+
addPacketFeedback(0, 1500, 0, 10);
|
|
237
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
238
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
239
|
+
addPacketFeedback(0, 1000, 30, 40);
|
|
240
|
+
|
|
241
|
+
// Sent at 933 kbps and arrived at 800 kbps.
|
|
242
|
+
REQUIRE(measuredBitrate.has_value());
|
|
243
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
244
|
+
REQUIRE(measuredBitrate.value() == static_cast<int64_t>(TargetUtilizationFraction * 800000));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
SECTION("there is nothing to take before any burst has been measured")
|
|
248
|
+
{
|
|
249
|
+
REQUIRE(!probeBitrateEstimator.FetchAndResetLastEstimatedBitrate().has_value());
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
SECTION("what has been measured is only taken once")
|
|
253
|
+
{
|
|
254
|
+
addPacketFeedback(0, 1000, 0, 10);
|
|
255
|
+
addPacketFeedback(0, 1000, 10, 20);
|
|
256
|
+
addPacketFeedback(0, 1000, 20, 30);
|
|
257
|
+
addPacketFeedback(0, 1000, 30, 40);
|
|
258
|
+
|
|
259
|
+
const auto estimatedBitrate = probeBitrateEstimator.FetchAndResetLastEstimatedBitrate();
|
|
260
|
+
|
|
261
|
+
REQUIRE(estimatedBitrate.has_value());
|
|
262
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
263
|
+
REQUIRE(estimatedBitrate.value() == 800000);
|
|
264
|
+
REQUIRE(!probeBitrateEstimator.FetchAndResetLastEstimatedBitrate().has_value());
|
|
265
|
+
}
|
|
266
|
+
}
|