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,337 @@
|
|
|
1
|
+
#include "common.hpp"
|
|
2
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
3
|
+
#include "RTC/BWE/TargetRateController.hpp"
|
|
4
|
+
#include <catch2/catch_test_macros.hpp>
|
|
5
|
+
|
|
6
|
+
SCENARIO("BWE TargetRateController", "[bwe][targetratecontroller]")
|
|
7
|
+
{
|
|
8
|
+
constexpr int64_t InitialTimeUs{ 123456 * 1000 };
|
|
9
|
+
// Shortest span of send times that closes an observation of the loss
|
|
10
|
+
// controller, and hence the pace at which it can be fed.
|
|
11
|
+
constexpr int64_t ObservationDurationLowerBoundUs{ 250 * 1000 };
|
|
12
|
+
constexpr int64_t PacketSizeBytes{ 15000 };
|
|
13
|
+
|
|
14
|
+
int64_t sequenceNumber{ 0 };
|
|
15
|
+
|
|
16
|
+
// Results of a feedback closing one observation of the loss controller, with
|
|
17
|
+
// every packet reported as lost or as received.
|
|
18
|
+
const auto createResults = [&sequenceNumber](
|
|
19
|
+
int64_t firstSendTimeUs,
|
|
20
|
+
bool received) -> std::vector<RTC::BWE::Types::PacketResult>
|
|
21
|
+
{
|
|
22
|
+
std::vector<RTC::BWE::Types::PacketResult> packetResults(2);
|
|
23
|
+
|
|
24
|
+
for (size_t idx{ 0 }; idx < packetResults.size(); ++idx)
|
|
25
|
+
{
|
|
26
|
+
auto& packetResult = packetResults[idx];
|
|
27
|
+
|
|
28
|
+
packetResult.sentPacket.sequenceNumber = sequenceNumber++;
|
|
29
|
+
packetResult.sentPacket.size = PacketSizeBytes;
|
|
30
|
+
packetResult.sentPacket.sendTimeUs =
|
|
31
|
+
firstSendTimeUs + (static_cast<int64_t>(idx) * ObservationDurationLowerBoundUs);
|
|
32
|
+
|
|
33
|
+
if (received)
|
|
34
|
+
{
|
|
35
|
+
packetResult.receiveTimeUs =
|
|
36
|
+
firstSendTimeUs + (static_cast<int64_t>(idx + 1) * ObservationDurationLowerBoundUs);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return packetResults;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Feed a bound of the given kind and let the controller act on it.
|
|
44
|
+
const auto feedLimit = [](
|
|
45
|
+
RTC::BWE::TargetRateController& targetRateController,
|
|
46
|
+
bool delayBased,
|
|
47
|
+
int64_t bitrate,
|
|
48
|
+
int64_t nowUs) -> void
|
|
49
|
+
{
|
|
50
|
+
if (delayBased)
|
|
51
|
+
{
|
|
52
|
+
targetRateController.SetDelayBasedEstimate(bitrate);
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
{
|
|
56
|
+
targetRateController.SetReceiverEstimate(bitrate);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
targetRateController.Update(nowUs);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
SECTION("the first bound applies at once but a later one has to wait")
|
|
63
|
+
{
|
|
64
|
+
// Both bounds behave the same here, so the very same case is run twice.
|
|
65
|
+
for (const bool delayBased : { false, true })
|
|
66
|
+
{
|
|
67
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
68
|
+
int64_t nowUs{ InitialTimeUs };
|
|
69
|
+
|
|
70
|
+
targetRateController.SetBitrateLimits(100000, 1500000);
|
|
71
|
+
targetRateController.SetSendBitrate(200000);
|
|
72
|
+
|
|
73
|
+
targetRateController.UpdatePacketsLost(/*lostPackets*/ 0, /*totalPackets*/ 1, nowUs);
|
|
74
|
+
targetRateController.UpdateRtt(50 * 1000);
|
|
75
|
+
|
|
76
|
+
constexpr int64_t FirstBitrate{ 1000000 };
|
|
77
|
+
constexpr int64_t SecondBitrate{ FirstBitrate + 500000 };
|
|
78
|
+
|
|
79
|
+
feedLimit(targetRateController, delayBased, FirstBitrate, nowUs);
|
|
80
|
+
|
|
81
|
+
REQUIRE(targetRateController.GetTargetBitrate() == FirstBitrate);
|
|
82
|
+
|
|
83
|
+
// Once the start phase is over the target no longer just follows its
|
|
84
|
+
// bounds, so the second one only raises the ceiling.
|
|
85
|
+
nowUs += 2001 * 1000;
|
|
86
|
+
|
|
87
|
+
feedLimit(targetRateController, delayBased, SecondBitrate, nowUs);
|
|
88
|
+
|
|
89
|
+
REQUIRE(targetRateController.GetTargetBitrate() == FirstBitrate);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
SECTION("a decrease is not reapplied while no further loss is reported")
|
|
94
|
+
{
|
|
95
|
+
constexpr int64_t MinBitrate{ 100000 };
|
|
96
|
+
constexpr int64_t InitialBitrate{ 1000000 };
|
|
97
|
+
constexpr uint8_t FractionLost{ 128 };
|
|
98
|
+
constexpr int64_t RttUs{ 50 * 1000 };
|
|
99
|
+
|
|
100
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
101
|
+
int64_t nowUs{ InitialTimeUs };
|
|
102
|
+
|
|
103
|
+
targetRateController.SetBitrateLimits(MinBitrate, 1500000);
|
|
104
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
105
|
+
|
|
106
|
+
nowUs += 10000 * 1000;
|
|
107
|
+
|
|
108
|
+
REQUIRE(targetRateController.GetTargetBitrate() == InitialBitrate);
|
|
109
|
+
REQUIRE(targetRateController.GetFractionLost() == 0);
|
|
110
|
+
REQUIRE(targetRateController.GetRttUs() == 0);
|
|
111
|
+
|
|
112
|
+
// Report heavy loss so that the target goes down.
|
|
113
|
+
targetRateController.UpdatePacketsLost(/*lostPackets*/ 50, /*totalPackets*/ 100, nowUs);
|
|
114
|
+
targetRateController.UpdateRtt(RttUs);
|
|
115
|
+
|
|
116
|
+
nowUs += 1000 * 1000;
|
|
117
|
+
|
|
118
|
+
targetRateController.Update(nowUs);
|
|
119
|
+
|
|
120
|
+
const int64_t decreasedBitrate = targetRateController.GetTargetBitrate();
|
|
121
|
+
|
|
122
|
+
REQUIRE(decreasedBitrate < InitialBitrate);
|
|
123
|
+
// A single decrease must not reach the minimum, or this case would prove
|
|
124
|
+
// nothing.
|
|
125
|
+
REQUIRE(decreasedBitrate > MinBitrate);
|
|
126
|
+
REQUIRE(targetRateController.GetFractionLost() == FractionLost);
|
|
127
|
+
REQUIRE(targetRateController.GetRttUs() == RttUs);
|
|
128
|
+
|
|
129
|
+
// Without a new report there is nothing saying whether the decrease was
|
|
130
|
+
// enough, so the target must not move again in either direction.
|
|
131
|
+
nowUs += 1000 * 1000;
|
|
132
|
+
|
|
133
|
+
targetRateController.Update(nowUs);
|
|
134
|
+
|
|
135
|
+
REQUIRE(targetRateController.GetTargetBitrate() == decreasedBitrate);
|
|
136
|
+
REQUIRE(targetRateController.GetFractionLost() == FractionLost);
|
|
137
|
+
REQUIRE(targetRateController.GetRttUs() == RttUs);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
SECTION("setting the send bitrate overrides the bound of the delay based path")
|
|
141
|
+
{
|
|
142
|
+
constexpr int64_t InitialBitrate{ 300000 };
|
|
143
|
+
constexpr int64_t DelayBasedBitrate{ 350000 };
|
|
144
|
+
constexpr int64_t ForcedHighBitrate{ 2500000 };
|
|
145
|
+
|
|
146
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
147
|
+
const int64_t nowUs{ InitialTimeUs };
|
|
148
|
+
|
|
149
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
150
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
151
|
+
|
|
152
|
+
targetRateController.SetDelayBasedEstimate(DelayBasedBitrate);
|
|
153
|
+
targetRateController.Update(nowUs);
|
|
154
|
+
|
|
155
|
+
REQUIRE(targetRateController.GetTargetBitrate() >= InitialBitrate);
|
|
156
|
+
REQUIRE(targetRateController.GetTargetBitrate() <= DelayBasedBitrate);
|
|
157
|
+
|
|
158
|
+
targetRateController.SetSendBitrate(ForcedHighBitrate);
|
|
159
|
+
|
|
160
|
+
REQUIRE(targetRateController.GetTargetBitrate() == ForcedHighBitrate);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
SECTION("a negative number of lost packets doesn't overflow the reported fraction")
|
|
164
|
+
{
|
|
165
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
166
|
+
int64_t nowUs{ InitialTimeUs };
|
|
167
|
+
|
|
168
|
+
targetRateController.SetBitrateLimits(100000, 1500000);
|
|
169
|
+
targetRateController.SetSendBitrate(1000000);
|
|
170
|
+
|
|
171
|
+
nowUs += 10000 * 1000;
|
|
172
|
+
|
|
173
|
+
REQUIRE(targetRateController.GetFractionLost() == 0);
|
|
174
|
+
|
|
175
|
+
targetRateController.UpdatePacketsLost(/*lostPackets*/ -1, /*totalPackets*/ 100, nowUs);
|
|
176
|
+
|
|
177
|
+
REQUIRE(targetRateController.GetFractionLost() == 0);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
SECTION("the round trip time is above the limit once it exceeds it")
|
|
181
|
+
{
|
|
182
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
183
|
+
const int64_t nowUs{ InitialTimeUs };
|
|
184
|
+
|
|
185
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
186
|
+
targetRateController.SetSendBitrate(300000);
|
|
187
|
+
|
|
188
|
+
targetRateController.UpdatePropagationRtt(/*propagationRttUs*/ 5000 * 1000, nowUs);
|
|
189
|
+
|
|
190
|
+
REQUIRE(targetRateController.IsRttAboveLimit());
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
SECTION("the round trip time is below the limit while it doesn't reach it")
|
|
194
|
+
{
|
|
195
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
196
|
+
const int64_t nowUs{ InitialTimeUs };
|
|
197
|
+
|
|
198
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
199
|
+
targetRateController.SetSendBitrate(300000);
|
|
200
|
+
|
|
201
|
+
targetRateController.UpdatePropagationRtt(/*propagationRttUs*/ 1000 * 1000, nowUs);
|
|
202
|
+
|
|
203
|
+
REQUIRE(!targetRateController.IsRttAboveLimit());
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
SECTION("the round trip time backoff can be disabled")
|
|
207
|
+
{
|
|
208
|
+
// A limit that no round trip time can reach disables the backoff, which is
|
|
209
|
+
// what the sender of a link known to be slow would want.
|
|
210
|
+
const RTC::BWE::TargetRateController::TargetRateControllerOptions options{
|
|
211
|
+
.maxRttUs = RTC::BWE::Types::TimeUsInfinite
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
RTC::BWE::TargetRateController targetRateController(options);
|
|
215
|
+
const int64_t nowUs{ InitialTimeUs };
|
|
216
|
+
|
|
217
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
218
|
+
targetRateController.SetSendBitrate(300000);
|
|
219
|
+
|
|
220
|
+
targetRateController.UpdatePropagationRtt(/*propagationRttUs*/ 5000 * 1000, nowUs);
|
|
221
|
+
|
|
222
|
+
REQUIRE(!targetRateController.IsRttAboveLimit());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
SECTION("a round trip time above the limit drops the target")
|
|
226
|
+
{
|
|
227
|
+
constexpr int64_t InitialBitrate{ 300000 };
|
|
228
|
+
|
|
229
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
230
|
+
int64_t nowUs{ InitialTimeUs };
|
|
231
|
+
|
|
232
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
233
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
234
|
+
|
|
235
|
+
targetRateController.UpdatePropagationRtt(/*propagationRttUs*/ 5000 * 1000, nowUs);
|
|
236
|
+
targetRateController.Update(nowUs);
|
|
237
|
+
|
|
238
|
+
// Four fifths of 300000.
|
|
239
|
+
REQUIRE(targetRateController.GetTargetBitrate() == 240000);
|
|
240
|
+
|
|
241
|
+
// The drop happens at most once per interval.
|
|
242
|
+
nowUs += 500 * 1000;
|
|
243
|
+
|
|
244
|
+
targetRateController.Update(nowUs);
|
|
245
|
+
|
|
246
|
+
REQUIRE(targetRateController.GetTargetBitrate() == 240000);
|
|
247
|
+
|
|
248
|
+
nowUs += 500 * 1000;
|
|
249
|
+
|
|
250
|
+
targetRateController.Update(nowUs);
|
|
251
|
+
|
|
252
|
+
// And four fifths of that.
|
|
253
|
+
REQUIRE(targetRateController.GetTargetBitrate() == 192000);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
SECTION("a report telling no loss increases the target by 8% plus a bit")
|
|
257
|
+
{
|
|
258
|
+
constexpr int64_t InitialBitrate{ 300000 };
|
|
259
|
+
|
|
260
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
261
|
+
int64_t nowUs{ InitialTimeUs };
|
|
262
|
+
|
|
263
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
264
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
265
|
+
|
|
266
|
+
// A report covering enough packets reconsiders the target by itself.
|
|
267
|
+
targetRateController.UpdatePacketsLost(/*lostPackets*/ 0, /*totalPackets*/ 100, nowUs);
|
|
268
|
+
|
|
269
|
+
// 8% over 300000 is 324000, plus the extra 1000.
|
|
270
|
+
REQUIRE(targetRateController.GetTargetBitrate() == 325000);
|
|
271
|
+
|
|
272
|
+
// Long enough for the value grown from to have left the window, so the next
|
|
273
|
+
// increase grows from the current target.
|
|
274
|
+
nowUs += 2001 * 1000;
|
|
275
|
+
|
|
276
|
+
targetRateController.Update(nowUs);
|
|
277
|
+
|
|
278
|
+
// And 8% over 325000 is 351000, plus the extra 1000.
|
|
279
|
+
REQUIRE(targetRateController.GetTargetBitrate() == 352000);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
SECTION("the loss rules drive the target until the loss controller is ready")
|
|
283
|
+
{
|
|
284
|
+
constexpr int64_t InitialBitrate{ 600000 };
|
|
285
|
+
|
|
286
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
287
|
+
int64_t nowUs{ InitialTimeUs };
|
|
288
|
+
|
|
289
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
290
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
291
|
+
// NOTE: After SetSendBitrate(), which drops it on purpose, so that the loss
|
|
292
|
+
// controller has a bitrate to start its estimate from.
|
|
293
|
+
targetRateController.SetDelayBasedEstimate(InitialBitrate);
|
|
294
|
+
|
|
295
|
+
// Two observations, one short of what the loss controller needs.
|
|
296
|
+
for (int64_t i{ 0 }; i < 2; ++i)
|
|
297
|
+
{
|
|
298
|
+
targetRateController.UpdateLossBasedController(
|
|
299
|
+
createResults(nowUs, /*received*/ false), /*inAlr*/ false, nowUs);
|
|
300
|
+
|
|
301
|
+
nowUs += 2 * ObservationDurationLowerBoundUs;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Losing every packet would have brought the estimate down, so the target
|
|
305
|
+
// staying put shows that nothing of it is being used yet.
|
|
306
|
+
REQUIRE(
|
|
307
|
+
targetRateController.GetLossBasedState() ==
|
|
308
|
+
RTC::BWE::LossBasedController::State::DELAY_BASED_ESTIMATE);
|
|
309
|
+
REQUIRE(targetRateController.GetTargetBitrate() == InitialBitrate);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
SECTION("the loss controller takes the target over once it is ready")
|
|
313
|
+
{
|
|
314
|
+
constexpr int64_t InitialBitrate{ 600000 };
|
|
315
|
+
|
|
316
|
+
RTC::BWE::TargetRateController targetRateController;
|
|
317
|
+
int64_t nowUs{ InitialTimeUs };
|
|
318
|
+
|
|
319
|
+
targetRateController.SetBitrateLimits(10000, 10000000);
|
|
320
|
+
targetRateController.SetSendBitrate(InitialBitrate);
|
|
321
|
+
// NOTE: After SetSendBitrate(), which drops it on purpose, so that the loss
|
|
322
|
+
// controller has a bitrate to start its estimate from.
|
|
323
|
+
targetRateController.SetDelayBasedEstimate(InitialBitrate);
|
|
324
|
+
|
|
325
|
+
for (int64_t i{ 0 }; i < 3; ++i)
|
|
326
|
+
{
|
|
327
|
+
targetRateController.UpdateLossBasedController(
|
|
328
|
+
createResults(nowUs, /*received*/ false), /*inAlr*/ false, nowUs);
|
|
329
|
+
|
|
330
|
+
nowUs += 2 * ObservationDurationLowerBoundUs;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
REQUIRE(
|
|
334
|
+
targetRateController.GetLossBasedState() == RTC::BWE::LossBasedController::State::DECREASING);
|
|
335
|
+
REQUIRE(targetRateController.GetTargetBitrate() < InitialBitrate);
|
|
336
|
+
}
|
|
337
|
+
}
|