mediasoup 3.27.1 → 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 +26 -0
- package/node/lib/Consumer.d.ts.map +1 -1
- package/node/lib/Consumer.js +4 -51
- 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/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 +4 -4
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +14 -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 +24 -16
- 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/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/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/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/npm-scripts.mjs +35 -44
- package/package.json +14 -10
- package/worker/fbs/rtpParameters.fbs +0 -1
- package/worker/fbs/transport.fbs +9 -2
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +16 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +14 -1
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +17 -4
- package/worker/include/DepLibUV.hpp +13 -0
- package/worker/include/RTC/BWE/AimdRateControl.hpp +9 -9
- package/worker/include/RTC/BWE/AlrDetector.hpp +97 -0
- package/worker/include/RTC/BWE/BitrateProber.hpp +217 -0
- package/worker/include/RTC/BWE/{Utils.hpp → BitrateUtils.hpp} +3 -3
- package/worker/include/RTC/BWE/BweTypes.hpp +207 -2
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +3 -3
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +2 -16
- 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 +109 -4
- package/worker/include/RTC/BWE/OveruseDetector.hpp +72 -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 +126 -0
- package/worker/include/RTC/BWE/ProbingScheduler.hpp +183 -0
- package/worker/include/RTC/BWE/ReceiverTransportCongestionController.hpp +148 -0
- package/worker/include/RTC/BWE/RembGenerator.hpp +97 -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/SenderTransportCongestionController.hpp +343 -0
- package/worker/include/RTC/BWE/TargetRateController.hpp +4 -1
- package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +147 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +18 -3
- package/worker/include/RTC/Consts.hpp +70 -0
- package/worker/include/RTC/Consumer.hpp +8 -1
- 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/RetransmissionBuffer.hpp +36 -10
- package/worker/include/RTC/RTP/RtpStream.hpp +33 -9
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +23 -4
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +126 -11
- 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/packet/parameters/ZeroChecksumAcceptableParameter.hpp +12 -3
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +0 -1
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +4 -4
- package/worker/include/RTC/SCTP/rx/DataTracker.hpp +1 -1
- package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +1 -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/TransportCongestionControlClient.hpp +0 -5
- package/worker/include/RTC/TransportCongestionControlServer.hpp +0 -5
- 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 +81 -5
- 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 -3
- 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 +26 -27
- package/worker/src/RTC/BWE/AlrDetector.cpp +80 -0
- package/worker/src/RTC/BWE/BitrateProber.cpp +256 -0
- package/worker/src/RTC/BWE/{Utils.cpp → BitrateUtils.cpp} +4 -4
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +18 -22
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +21 -38
- 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 +189 -41
- 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 +135 -0
- package/worker/src/RTC/BWE/ProbingScheduler.cpp +191 -0
- package/worker/src/RTC/BWE/ReceiverTransportCongestionController.cpp +207 -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/SenderTransportCongestionController.cpp +599 -0
- package/worker/src/RTC/BWE/TargetRateController.cpp +12 -14
- package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +376 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +24 -5
- package/worker/src/RTC/Consumer.cpp +10 -7
- package/worker/src/RTC/DataConsumer.cpp +10 -12
- 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/RetransmissionBuffer.cpp +21 -8
- package/worker/src/RTC/RTP/RtpStream.cpp +1 -4
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +109 -102
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +442 -258
- package/worker/src/RTC/RTP/RtxStream.cpp +32 -22
- 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 +4 -3
- 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/InterleavedReassemblyStreams.cpp +3 -3
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +4 -2
- package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +4 -4
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +4 -2
- 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 +160 -113
- package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -66
- package/worker/src/RTC/TransportCongestionControlServer.cpp +0 -55
- 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/Utils/Crypto.cpp +114 -98
- 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/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/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 +9 -9
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +79 -60
- package/worker/test/src/RTC/BWE/TestInterArrival.cpp +643 -0
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +8 -8
- package/worker/test/src/RTC/BWE/TestIntervalBudget.cpp +130 -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 +1685 -0
- package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +250 -0
- package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +236 -0
- package/worker/test/src/RTC/BWE/TestReceiverTransportCongestionController.cpp +346 -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/TestSenderTransportCongestionController.cpp +510 -0
- package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +580 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +6 -6
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +133 -29
- package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +624 -0
- 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 +20 -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/TestPacket.cpp +58 -4
- package/worker/test/src/RTC/RTP/TestProbationGenerator.cpp +3 -2
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +60 -28
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +50 -0
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +804 -23
- 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 +323 -61
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +103 -9
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +13 -13
- package/worker/test/src/RTC/TestRtpEncodingParameters.cpp +1 -1
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +34 -16
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +31 -13
- package/worker/test/src/RTC/TestSubchannelsCodec.cpp +2 -2
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +37 -19
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +11 -11
- 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 +120 -21
- package/worker/test/src/RTC/BWE/TestUtils.cpp +0 -61
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_PROBE_BITRATE_ESTIMATOR_HPP
|
|
2
|
+
#define MS_RTC_BWE_PROBE_BITRATE_ESTIMATOR_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include <ankerl/unordered_dense.h>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace BWE
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Measures what a probe actually achieved.
|
|
14
|
+
*
|
|
15
|
+
* A probe is a burst of packets sent on purpose above the current estimate,
|
|
16
|
+
* and the point of it is to learn the capacity of the link directly instead
|
|
17
|
+
* of inferring it from the delay. This class gathers the feedback of the
|
|
18
|
+
* packets of each burst and, once enough of the burst has come back, says at
|
|
19
|
+
* what bitrate it was delivered.
|
|
20
|
+
*
|
|
21
|
+
* The answer is the lower of the rate it was sent at and the rate it
|
|
22
|
+
* arrived at, because a burst that arrives faster than it was sent measures
|
|
23
|
+
* the sender and not the link. And when it arrives clearly slower than it
|
|
24
|
+
* was sent, that means the burst found the real capacity, so the answer is
|
|
25
|
+
* taken slightly below what arrived in order not to overuse it right away.
|
|
26
|
+
*
|
|
27
|
+
* A burst that too little of came back, that was sent or received over too
|
|
28
|
+
* long a span, or that arrived far faster than it was sent, is discarded
|
|
29
|
+
* rather than believed.
|
|
30
|
+
*/
|
|
31
|
+
class ProbeBitrateEstimator
|
|
32
|
+
{
|
|
33
|
+
private:
|
|
34
|
+
/**
|
|
35
|
+
* What has been gathered so far about a burst.
|
|
36
|
+
*/
|
|
37
|
+
struct AggregatedCluster
|
|
38
|
+
{
|
|
39
|
+
int64_t numProbes{ 0 };
|
|
40
|
+
std::optional<int64_t> firstSendTimeUs;
|
|
41
|
+
std::optional<int64_t> lastSendTimeUs;
|
|
42
|
+
std::optional<int64_t> firstReceiveTimeUs;
|
|
43
|
+
std::optional<int64_t> lastReceiveTimeUs;
|
|
44
|
+
// Size of the packet sent last, which the span of send times doesn't
|
|
45
|
+
// cover.
|
|
46
|
+
int64_t sizeLastSend{ 0 };
|
|
47
|
+
// Size of the packet received first, which the span of receive times
|
|
48
|
+
// doesn't cover.
|
|
49
|
+
int64_t sizeFirstReceive{ 0 };
|
|
50
|
+
int64_t sizeTotal{ 0 };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
/**
|
|
55
|
+
* Feed the feedback of a packet that belongs to a probe.
|
|
56
|
+
*
|
|
57
|
+
* @returns The bitrate the probe achieved (bps), or no value while its
|
|
58
|
+
* burst cannot be trusted yet or at all.
|
|
59
|
+
*/
|
|
60
|
+
std::optional<int64_t> HandleProbeAndEstimateBitrate(const Types::PacketResult& packetResult);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Take the latest measured bitrate (bps), leaving none behind, so that a
|
|
64
|
+
* probe is never acted upon twice.
|
|
65
|
+
*/
|
|
66
|
+
std::optional<int64_t> FetchAndResetLastEstimatedBitrate();
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
/**
|
|
70
|
+
* Forget the bursts whose last packet arrived long enough ago that they
|
|
71
|
+
* cannot receive anything else.
|
|
72
|
+
*/
|
|
73
|
+
void EraseOldClusters(int64_t arrivalTimeUs);
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
// Bursts being gathered, by their id. Nothing looks at them in any
|
|
77
|
+
// particular order.
|
|
78
|
+
ankerl::unordered_dense::map<int64_t, AggregatedCluster> clusters;
|
|
79
|
+
std::optional<int64_t> estimatedBitrate;
|
|
80
|
+
};
|
|
81
|
+
} // namespace BWE
|
|
82
|
+
} // namespace RTC
|
|
83
|
+
|
|
84
|
+
#endif
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_PROBE_CONTROLLER_HPP
|
|
2
|
+
#define MS_RTC_BWE_PROBE_CONTROLLER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace BWE
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Decides when to probe and at what bitrate.
|
|
14
|
+
*
|
|
15
|
+
* Probing is the only way to discover capacity that is not being used,
|
|
16
|
+
* because nothing measured while sending below the link's capacity says
|
|
17
|
+
* anything about how much more it could carry. So this asks for bursts: at
|
|
18
|
+
* the start of a connection to climb fast instead of waiting for the slow
|
|
19
|
+
* ramp, periodically while the sender isn't filling the link, when the
|
|
20
|
+
* application asks for more than is being sent, and after a large drop to
|
|
21
|
+
* check whether it was real.
|
|
22
|
+
*
|
|
23
|
+
* It decides nothing else: every method returns the bursts to launch, and
|
|
24
|
+
* emitting them is somebody else's job. And it refuses to probe whenever
|
|
25
|
+
* something is already known to be holding the estimate back, since a burst
|
|
26
|
+
* then measures that limit rather than the link.
|
|
27
|
+
*/
|
|
28
|
+
class ProbeController
|
|
29
|
+
{
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Why the estimate is not free to grow, which decides whether probing
|
|
33
|
+
* makes sense at all.
|
|
34
|
+
*/
|
|
35
|
+
enum class BandwidthLimitedCause : uint8_t
|
|
36
|
+
{
|
|
37
|
+
/**
|
|
38
|
+
* Loss is what limits the estimate, and it's growing back.
|
|
39
|
+
*/
|
|
40
|
+
LOSS_LIMITED_BWE_INCREASING = 0,
|
|
41
|
+
/**
|
|
42
|
+
* Loss is what limits the estimate and it isn't growing.
|
|
43
|
+
*/
|
|
44
|
+
LOSS_LIMITED_BWE,
|
|
45
|
+
/**
|
|
46
|
+
* The delay based path is what limits the estimate.
|
|
47
|
+
*/
|
|
48
|
+
DELAY_BASED_LIMITED,
|
|
49
|
+
/**
|
|
50
|
+
* The same, with the delay growing right now.
|
|
51
|
+
*/
|
|
52
|
+
DELAY_BASED_LIMITED_DELAY_INCREASED,
|
|
53
|
+
/**
|
|
54
|
+
* A round trip time long enough to mean that the queues are full.
|
|
55
|
+
*/
|
|
56
|
+
RTT_BASED_BACK_OFF_HIGH_RTT
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @remarks
|
|
61
|
+
* - Every constraint documented below is checked by the constructor and
|
|
62
|
+
* aborts when it doesn't hold. These options are set from C++ alone,
|
|
63
|
+
* never from the network nor from the API, so breaking one of them is a
|
|
64
|
+
* programming error.
|
|
65
|
+
*/
|
|
66
|
+
struct ProbeControllerOptions
|
|
67
|
+
{
|
|
68
|
+
/**
|
|
69
|
+
* Factor applied to the start bitrate for the first burst of the
|
|
70
|
+
* connection.
|
|
71
|
+
*/
|
|
72
|
+
double firstExponentialProbeScale{ 3.0 };
|
|
73
|
+
/**
|
|
74
|
+
* The same for the second one, or no value to send just one.
|
|
75
|
+
*/
|
|
76
|
+
std::optional<double> secondExponentialProbeScale{ 6.0 };
|
|
77
|
+
/**
|
|
78
|
+
* Factor applied to the measured bitrate for each burst that follows one
|
|
79
|
+
* whose result was good enough to keep climbing.
|
|
80
|
+
*/
|
|
81
|
+
double furtherExponentialProbeScale{ 2.0 };
|
|
82
|
+
/**
|
|
83
|
+
* Fraction of the bitrate a burst was sent at that its result has to
|
|
84
|
+
* exceed for another one to follow it.
|
|
85
|
+
*/
|
|
86
|
+
double furtherProbeThreshold{ 0.7 };
|
|
87
|
+
/**
|
|
88
|
+
* Whether to stop climbing as soon as the measured bitrate is already
|
|
89
|
+
* above what the application asked for.
|
|
90
|
+
*/
|
|
91
|
+
bool abortFurtherProbeIfMaxLowerThanCurrent{ false };
|
|
92
|
+
/**
|
|
93
|
+
* How long after the first burst the initial ones keep being repeated,
|
|
94
|
+
* while repeated initial probing is enabled.
|
|
95
|
+
*/
|
|
96
|
+
int64_t repeatedInitialProbingTimePeriodUs{ 5 * 1000 * 1000 };
|
|
97
|
+
/**
|
|
98
|
+
* How long each of those initial bursts lasts. It's longer than a usual
|
|
99
|
+
* one because there is no traffic yet to measure against.
|
|
100
|
+
*/
|
|
101
|
+
int64_t initialProbeDurationUs{ 100 * 1000 };
|
|
102
|
+
/**
|
|
103
|
+
* Time between two consecutive bursts of packets within one of those
|
|
104
|
+
* initial probes.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* - It cannot be zero, since it's what the bitrate of a burst is held
|
|
108
|
+
* over to decide how many bytes each of its shots carries.
|
|
109
|
+
*/
|
|
110
|
+
int64_t initialMinProbeDeltaUs{ 20 * 1000 };
|
|
111
|
+
/**
|
|
112
|
+
* Whether bursts keep being sent while the sender is not filling the
|
|
113
|
+
* link, which is the only way the estimate grows when the traffic
|
|
114
|
+
* itself is not enough to measure with.
|
|
115
|
+
*/
|
|
116
|
+
bool enablePeriodicAlrProbing{ false };
|
|
117
|
+
/**
|
|
118
|
+
* How often to probe while the sender is not filling the link.
|
|
119
|
+
*/
|
|
120
|
+
int64_t alrProbingIntervalUs{ 5 * 1000 * 1000 };
|
|
121
|
+
/**
|
|
122
|
+
* Factor applied to the estimate for those bursts.
|
|
123
|
+
*/
|
|
124
|
+
double alrProbeScale{ 2.0 };
|
|
125
|
+
/**
|
|
126
|
+
* How often to probe while an upper bound of the link capacity is known,
|
|
127
|
+
* or no limit at all to never do it, which is what turns that whole path
|
|
128
|
+
* off.
|
|
129
|
+
*/
|
|
130
|
+
int64_t networkStateEstimateProbingIntervalUs{ Types::TimeUsInfinite };
|
|
131
|
+
/**
|
|
132
|
+
* Fraction of that upper bound below which the estimate is low enough to
|
|
133
|
+
* keep probing periodically.
|
|
134
|
+
*/
|
|
135
|
+
double probeIfEstimateLowerThanNetworkStateEstimateRatio{ 0.0 };
|
|
136
|
+
/**
|
|
137
|
+
* How often to probe while the estimate is that low.
|
|
138
|
+
*/
|
|
139
|
+
int64_t estimateLowerThanNetworkStateEstimateProbingIntervalUs{ 3 * 1000 * 1000 };
|
|
140
|
+
/**
|
|
141
|
+
* Factor applied to that upper bound when it's what bounds the burst.
|
|
142
|
+
*/
|
|
143
|
+
double networkStateProbeScale{ 1.0 };
|
|
144
|
+
/**
|
|
145
|
+
* How long a burst lasts when that upper bound is known and is above
|
|
146
|
+
* what the burst aims for.
|
|
147
|
+
*/
|
|
148
|
+
int64_t networkStateProbeDurationUs{ 15 * 1000 };
|
|
149
|
+
/**
|
|
150
|
+
* Time between two consecutive bursts of packets in that case.
|
|
151
|
+
*
|
|
152
|
+
* @remarks
|
|
153
|
+
* - It cannot be zero, since it's what the bitrate of a burst is held
|
|
154
|
+
* over to decide how many bytes each of its shots carries.
|
|
155
|
+
*/
|
|
156
|
+
int64_t networkStateMinProbeDeltaUs{ 20 * 1000 };
|
|
157
|
+
/**
|
|
158
|
+
* Whether to probe when the application raises how much it wants to
|
|
159
|
+
* send.
|
|
160
|
+
*/
|
|
161
|
+
bool probeOnMaxAllocatedBitrateChange{ true };
|
|
162
|
+
/**
|
|
163
|
+
* Whether to do it also while the sender is filling the link.
|
|
164
|
+
*/
|
|
165
|
+
bool probeOnMaxAllocatedBitrateChangeWithoutAlr{ true };
|
|
166
|
+
/**
|
|
167
|
+
* Factor applied to what the application asks for, for the first of
|
|
168
|
+
* those bursts, or no value to send none.
|
|
169
|
+
*/
|
|
170
|
+
std::optional<double> firstAllocationProbeScale{ 1.0 };
|
|
171
|
+
/**
|
|
172
|
+
* The same for the second one, or no value to send just one.
|
|
173
|
+
*/
|
|
174
|
+
std::optional<double> secondAllocationProbeScale{ 2.0 };
|
|
175
|
+
/**
|
|
176
|
+
* Factor applied to the current estimate, which is how far above it
|
|
177
|
+
* those bursts are allowed to aim.
|
|
178
|
+
*/
|
|
179
|
+
double allocationProbeLimitByCurrentScale{ 2.0 };
|
|
180
|
+
/**
|
|
181
|
+
* Packets a burst is meant to be made of.
|
|
182
|
+
*/
|
|
183
|
+
int64_t minProbePacketsSent{ 5 };
|
|
184
|
+
/**
|
|
185
|
+
* How long a burst lasts.
|
|
186
|
+
*/
|
|
187
|
+
int64_t minProbeDurationUs{ 15 * 1000 };
|
|
188
|
+
/**
|
|
189
|
+
* Time between two consecutive bursts of packets within a probe.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* - It cannot be zero, since it's what the bitrate of a burst is held
|
|
193
|
+
* over to decide how many bytes each of its shots carries.
|
|
194
|
+
*/
|
|
195
|
+
int64_t minProbeDeltaUs{ 2 * 1000 };
|
|
196
|
+
/**
|
|
197
|
+
* Factor applied to the estimate that bounds a burst while loss is what
|
|
198
|
+
* limits it and it's growing back.
|
|
199
|
+
*/
|
|
200
|
+
double lossLimitedProbeScale{ 1.5 };
|
|
201
|
+
/**
|
|
202
|
+
* Fraction of the maximum above which the estimate is already high
|
|
203
|
+
* enough for a burst to be pointless. Zero never skips one.
|
|
204
|
+
*/
|
|
205
|
+
double skipIfEstimateLargerThanFractionOfMax{ 0.0 };
|
|
206
|
+
/**
|
|
207
|
+
* Factor applied to what the application asks for when deciding that.
|
|
208
|
+
*/
|
|
209
|
+
double skipProbeMaxAllocatedScale{ 1.0 };
|
|
210
|
+
/**
|
|
211
|
+
* Whether a large drop may be probed even while the sender is filling
|
|
212
|
+
* the link.
|
|
213
|
+
*/
|
|
214
|
+
bool rapidRecoveryExperiment{ false };
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
private:
|
|
218
|
+
/**
|
|
219
|
+
* Where the climbing that follows the first burst of a connection is.
|
|
220
|
+
*/
|
|
221
|
+
enum class State : uint8_t
|
|
222
|
+
{
|
|
223
|
+
/**
|
|
224
|
+
* Nothing has been probed yet.
|
|
225
|
+
*/
|
|
226
|
+
INIT,
|
|
227
|
+
/**
|
|
228
|
+
* A burst went out and its result decides whether another one follows.
|
|
229
|
+
*/
|
|
230
|
+
WAITING_FOR_PROBING_RESULT,
|
|
231
|
+
/**
|
|
232
|
+
* There is nothing left to climb.
|
|
233
|
+
*/
|
|
234
|
+
PROBING_COMPLETE
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
public:
|
|
238
|
+
ProbeController();
|
|
239
|
+
|
|
240
|
+
explicit ProbeController(ProbeControllerOptions options);
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Bounds set by the application, plus the bitrate to start from.
|
|
244
|
+
*
|
|
245
|
+
* @param maxBitrate - `Types::BitrateInfinite` for no limit, in which case
|
|
246
|
+
* the highest bitrate that may be probed applies instead.
|
|
247
|
+
*/
|
|
248
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> SetBitrates(
|
|
249
|
+
int64_t minBitrate, int64_t startBitrate, int64_t maxBitrate, int64_t nowUs);
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Total of what the application wants to send, which is not the same as
|
|
253
|
+
* the maximum it allows: it's the sum over the streams being sent.
|
|
254
|
+
*/
|
|
255
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> OnMaxTotalAllocatedBitrate(
|
|
256
|
+
int64_t maxTotalAllocatedBitrate, int64_t nowUs);
|
|
257
|
+
|
|
258
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> OnNetworkAvailability(
|
|
259
|
+
bool networkAvailable, int64_t nowUs);
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Feed the current estimate and what is holding it back.
|
|
263
|
+
*/
|
|
264
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> SetEstimatedBitrate(
|
|
265
|
+
int64_t bitrate, BandwidthLimitedCause bandwidthLimitedCause, int64_t nowUs);
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Whether the initial bursts keep being repeated for a while, which only
|
|
269
|
+
* makes sense until there is traffic of its own to measure.
|
|
270
|
+
*/
|
|
271
|
+
void EnableRepeatedInitialProbing(bool enable)
|
|
272
|
+
{
|
|
273
|
+
this->repeatedInitialProbingEnabled = enable;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
void SetAlrStartTimeUs(std::optional<int64_t> alrStartTimeUs)
|
|
277
|
+
{
|
|
278
|
+
this->alrStartTimeUs = alrStartTimeUs;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void SetAlrEndedTimeUs(int64_t alrEndedTimeUs)
|
|
282
|
+
{
|
|
283
|
+
this->alrEndedTimeUs = alrEndedTimeUs;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Ask for a burst after the estimate has come back up from a large drop,
|
|
288
|
+
* to tell a real drop from a passing one.
|
|
289
|
+
*/
|
|
290
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> RequestProbe(int64_t nowUs);
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Upper bound of the link capacity as measured elsewhere (bps), which
|
|
294
|
+
* bounds what a burst may aim for.
|
|
295
|
+
*
|
|
296
|
+
* @remarks
|
|
297
|
+
* - `Types::BitrateInfinite` means that nothing measured it, which is what
|
|
298
|
+
* the link capacity estimator answers while it has no estimate, and is
|
|
299
|
+
* kept as no bound at all rather than as an enormous one.
|
|
300
|
+
*/
|
|
301
|
+
void SetLinkCapacityUpperBound(int64_t linkCapacityUpperBound)
|
|
302
|
+
{
|
|
303
|
+
this->linkCapacityUpperBound = linkCapacityUpperBound != Types::BitrateInfinite
|
|
304
|
+
? std::optional<int64_t>(linkCapacityUpperBound)
|
|
305
|
+
: std::nullopt;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Forget what was probed, leaving the settings alone, so that the climbing
|
|
310
|
+
* of a new connection starts over.
|
|
311
|
+
*/
|
|
312
|
+
void Reset(int64_t nowUs);
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Reconsider whether a burst is due, which is what drives the periodic
|
|
316
|
+
* ones.
|
|
317
|
+
*/
|
|
318
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> Process(int64_t nowUs);
|
|
319
|
+
|
|
320
|
+
private:
|
|
321
|
+
void UpdateState(State newState);
|
|
322
|
+
|
|
323
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> InitiateExponentialProbing(int64_t nowUs);
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Turn the given bitrates into bursts, bounding them by everything that
|
|
327
|
+
* applies and refusing them altogether while something is known to be
|
|
328
|
+
* holding the estimate back.
|
|
329
|
+
*
|
|
330
|
+
* @param probeFurther - Whether the result of these bursts may lead to
|
|
331
|
+
* another one.
|
|
332
|
+
*/
|
|
333
|
+
[[nodiscard]] std::vector<Types::ProbeClusterConfig> InitiateProbing(
|
|
334
|
+
int64_t nowUs, const std::vector<int64_t>& bitratesToProbe, bool probeFurther);
|
|
335
|
+
|
|
336
|
+
bool IsTimeForAlrProbe(int64_t nowUs) const;
|
|
337
|
+
|
|
338
|
+
bool IsTimeForNetworkStateProbe(int64_t nowUs) const;
|
|
339
|
+
|
|
340
|
+
bool IsTimeForNextRepeatedInitialProbe(int64_t nowUs) const;
|
|
341
|
+
|
|
342
|
+
Types::ProbeClusterConfig CreateProbeClusterConfig(int64_t nowUs, int64_t bitrate);
|
|
343
|
+
|
|
344
|
+
private:
|
|
345
|
+
// Passed by argument.
|
|
346
|
+
const ProbeControllerOptions options;
|
|
347
|
+
// Others.
|
|
348
|
+
State state{ State::INIT };
|
|
349
|
+
bool networkAvailable{ false };
|
|
350
|
+
bool repeatedInitialProbingEnabled{ false };
|
|
351
|
+
BandwidthLimitedCause bandwidthLimitedCause{ BandwidthLimitedCause::DELAY_BASED_LIMITED };
|
|
352
|
+
// Instant until which the initial bursts keep being repeated.
|
|
353
|
+
std::optional<int64_t> lastAllowedRepeatedInitialProbeAtUs;
|
|
354
|
+
// Bitrate a burst has to beat for another one to follow it, or
|
|
355
|
+
// `Types::BitrateInfinite` while nothing is to follow.
|
|
356
|
+
int64_t minBitrateToProbeFurther{ Types::BitrateInfinite };
|
|
357
|
+
std::optional<int64_t> lastProbingInitiatedAtUs;
|
|
358
|
+
int64_t estimatedBitrate{ 0 };
|
|
359
|
+
// Upper bound of the link capacity as measured elsewhere, or no value
|
|
360
|
+
// while nothing measured it.
|
|
361
|
+
std::optional<int64_t> linkCapacityUpperBound;
|
|
362
|
+
int64_t startBitrate{ 0 };
|
|
363
|
+
int64_t maxBitrate{ Types::BitrateInfinite };
|
|
364
|
+
std::optional<int64_t> lastBweDropProbingAtUs;
|
|
365
|
+
std::optional<int64_t> alrStartTimeUs;
|
|
366
|
+
std::optional<int64_t> alrEndedTimeUs;
|
|
367
|
+
// Instant of the latest large drop of the estimate, and what it was worth
|
|
368
|
+
// just before it.
|
|
369
|
+
std::optional<int64_t> lastLargeDropAtUs;
|
|
370
|
+
int64_t bitrateBeforeLastLargeDrop{ 0 };
|
|
371
|
+
// Total of what the application wants to send.
|
|
372
|
+
int64_t maxTotalAllocatedBitrate{ 0 };
|
|
373
|
+
// Id given to the next burst, which never repeats.
|
|
374
|
+
int64_t nextProbeClusterId{ 1 };
|
|
375
|
+
};
|
|
376
|
+
} // namespace BWE
|
|
377
|
+
} // namespace RTC
|
|
378
|
+
|
|
379
|
+
#endif
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_PROBE_PACKET_GENERATOR_HPP
|
|
2
|
+
#define MS_RTC_BWE_PROBE_PACKET_GENERATOR_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/RTP/Packet.hpp"
|
|
6
|
+
#include <array>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace BWE
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Makes the RTP packets a probing burst is made of.
|
|
14
|
+
*
|
|
15
|
+
* A burst asks for a number of bytes to be put on the wire over a few
|
|
16
|
+
* milliseconds, and those bytes have to travel as RTP so that the receiver
|
|
17
|
+
* reports when each of them arrived. This turns the bytes into packets and
|
|
18
|
+
* hands them over one by one.
|
|
19
|
+
*
|
|
20
|
+
* What it produces is a stream of its own that carries nothing: a fixed SSRC
|
|
21
|
+
* the receiver has negotiated, a payload of zeroes that nothing decodes, and
|
|
22
|
+
* the header extensions that make the packets reportable. The only thing ever
|
|
23
|
+
* read back from them is when each one arrived.
|
|
24
|
+
*/
|
|
25
|
+
class ProbePacketGenerator
|
|
26
|
+
{
|
|
27
|
+
public:
|
|
28
|
+
class Listener
|
|
29
|
+
{
|
|
30
|
+
public:
|
|
31
|
+
virtual ~Listener() = default;
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* A packet of the burst is ready.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - The packet must be sent before returning, since the next one is
|
|
39
|
+
* built over the very same instance.
|
|
40
|
+
* - It carries room for the abs-send-time and for the transport wide
|
|
41
|
+
* sequence number but no value for either, so both have to be written
|
|
42
|
+
* here.
|
|
43
|
+
* - Whoever measures the burst has to be told how much of it went out,
|
|
44
|
+
* so the length of the packet is reported from here as well.
|
|
45
|
+
* - This must not destroy the `ProbePacketGenerator`, not even
|
|
46
|
+
* indirectly. It goes on reading its own members after this returns.
|
|
47
|
+
*/
|
|
48
|
+
virtual void OnProbePacketGeneratorSendRtpPacket(
|
|
49
|
+
ProbePacketGenerator* probePacketGenerator, RTC::RTP::Packet* packet) = 0;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
#ifdef MS_TEST
|
|
53
|
+
public:
|
|
54
|
+
#else
|
|
55
|
+
private:
|
|
56
|
+
#endif
|
|
57
|
+
/**
|
|
58
|
+
* Largest a packet of a burst may be (bytes), which leaves room below the
|
|
59
|
+
* MTU for the overhead that encrypting it adds on the way out.
|
|
60
|
+
*/
|
|
61
|
+
static constexpr size_t MaxPacketLength{ 1400 };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Most bytes a single burst may be asked for (bytes), so 2.5 MB, which is
|
|
65
|
+
* 1 Gbps held for 20 ms.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* - A burst larger than this is taken as one that cannot be real, and
|
|
69
|
+
* asking for it would have this handing packets over for a very long
|
|
70
|
+
* while, all within a single iteration of the event loop.
|
|
71
|
+
* - Those two are the highest bitrate the bandwidth estimation deals in
|
|
72
|
+
* and the longest time whoever asks for a burst leaves between two of
|
|
73
|
+
* its shots, neither of which this can enforce.
|
|
74
|
+
*/
|
|
75
|
+
static constexpr size_t MaxGeneratePacketsSize{ 2500000 };
|
|
76
|
+
|
|
77
|
+
public:
|
|
78
|
+
explicit ProbePacketGenerator(Listener* listener);
|
|
79
|
+
|
|
80
|
+
~ProbePacketGenerator() = default;
|
|
81
|
+
|
|
82
|
+
// NOTE: The packet is written over a buffer of this very instance, so one
|
|
83
|
+
// that was copied or moved would keep writing over the buffer of the one
|
|
84
|
+
// it came from.
|
|
85
|
+
ProbePacketGenerator(const ProbePacketGenerator&) = delete;
|
|
86
|
+
ProbePacketGenerator& operator=(const ProbePacketGenerator&) = delete;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Smallest packet this can make (bytes), which is its header and its
|
|
90
|
+
* extensions and no payload at all.
|
|
91
|
+
*/
|
|
92
|
+
size_t GetMinPacketLength() const
|
|
93
|
+
{
|
|
94
|
+
return this->minPacketLength;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Hand over the packets that carry the given count of bytes.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* - What goes out is at least what was asked for, since a burst falling
|
|
102
|
+
* short of the bytes it was meant to carry measures something else, and
|
|
103
|
+
* the last packet can't be smaller than a header.
|
|
104
|
+
*/
|
|
105
|
+
void GeneratePackets(size_t size);
|
|
106
|
+
|
|
107
|
+
private:
|
|
108
|
+
// Passed by argument.
|
|
109
|
+
Listener* listener{ nullptr };
|
|
110
|
+
// Others.
|
|
111
|
+
// Bytes the packet is written over. It belongs to this instance rather
|
|
112
|
+
// than being shared, since the packet's header lives in it and the
|
|
113
|
+
// sequence number of the next packet is read back from there. The empty
|
|
114
|
+
// braces zero it, so the payload never carries whatever was in that
|
|
115
|
+
// memory before.
|
|
116
|
+
std::array<uint8_t, MaxPacketLength> packetBuffer{};
|
|
117
|
+
// Allocated by this.
|
|
118
|
+
std::unique_ptr<RTC::RTP::Packet> packet;
|
|
119
|
+
// Length of the packet with no payload at all, so its header and its
|
|
120
|
+
// extensions.
|
|
121
|
+
size_t minPacketLength{ 0 };
|
|
122
|
+
};
|
|
123
|
+
} // namespace BWE
|
|
124
|
+
} // namespace RTC
|
|
125
|
+
|
|
126
|
+
#endif
|