mediasoup 3.26.0 → 3.27.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 +11 -0
- package/node/lib/DataConsumer.js +1 -1
- package/node/lib/Router.js +1 -1
- package/node/lib/Transport.js +15 -15
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts +2 -6
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts.map +1 -1
- package/node/lib/fbs/rtp-parameters/encoding-mapping.js +7 -19
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.d.ts +4 -4
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +2 -2
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +3 -3
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/recv-stats.js +3 -3
- package/node/lib/fbs/rtp-stream/send-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/send-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/send-stats.js +3 -3
- package/node/lib/fbs/transport/bwe-trace-info.d.ts +23 -23
- package/node/lib/fbs/transport/bwe-trace-info.d.ts.map +1 -1
- package/node/lib/fbs/transport/bwe-trace-info.js +15 -15
- package/node/lib/fbs/transport/options.d.ts +5 -5
- package/node/lib/fbs/transport/options.js +2 -2
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/stats.d.ts +38 -38
- package/node/lib/fbs/transport/stats.d.ts.map +1 -1
- package/node/lib/fbs/transport/stats.js +25 -25
- package/node/lib/ortc.d.ts +0 -1
- package/node/lib/ortc.d.ts.map +1 -1
- package/node/lib/ortc.js +1 -2
- package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/rtpParametersFbsUtils.js +2 -2
- package/package.json +9 -9
- package/worker/deps/libwebrtc/libwebrtc/call/rtp_transport_controller_send.cc +10 -10
- package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +6 -6
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc +7 -7
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +1 -1
- package/worker/fbs/rtpParameters.fbs +1 -2
- package/worker/fbs/rtpStream.fbs +3 -3
- package/worker/fbs/transport.fbs +23 -23
- package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
- package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
- package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
- package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
- package/worker/fuzzer/src/fuzzer.cpp +4 -0
- package/worker/include/Channel/ChannelNotification.hpp +3 -3
- package/worker/include/Channel/ChannelRequest.hpp +1 -1
- package/worker/include/Channel/ChannelSocket.hpp +11 -0
- package/worker/include/DepLibUV.hpp +16 -33
- package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
- package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
- package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
- package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
- package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
- package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
- package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +101 -0
- package/worker/include/RTC/Consts.hpp +6 -6
- package/worker/include/RTC/Consumer.hpp +14 -12
- package/worker/include/RTC/DataConsumer.hpp +3 -3
- package/worker/include/RTC/DataProducer.hpp +3 -3
- package/worker/include/RTC/DtlsTransport.hpp +5 -2
- package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
- package/worker/include/RTC/ICE/IceServer.hpp +3 -3
- package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
- package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
- package/worker/include/RTC/NackGenerator.hpp +12 -12
- package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/PipeTransport.hpp +18 -5
- package/worker/include/RTC/PlainTransport.hpp +18 -5
- package/worker/include/RTC/PortManager.hpp +4 -4
- package/worker/include/RTC/Producer.hpp +21 -12
- package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
- package/worker/include/RTC/RTCP/Bye.hpp +2 -2
- package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
- package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
- package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
- package/worker/include/RTC/RTCP/Packet.hpp +3 -3
- package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
- package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
- package/worker/include/RTC/RTCP/XR.hpp +2 -2
- package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
- package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
- package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
- package/worker/include/RTC/RTP/Packet.hpp +13 -13
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
- package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
- package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
- package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
- package/worker/include/RTC/RateCalculator.hpp +50 -44
- package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
- package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
- package/worker/include/RTC/Router.hpp +6 -0
- package/worker/include/RTC/RtcLogger.hpp +1 -1
- package/worker/include/RTC/RtpDictionaries.hpp +10 -10
- package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +2 -2
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
- package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
- package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
- package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +1 -1
- package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
- package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
- package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
- package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
- package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
- package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
- package/worker/include/RTC/SctpDictionaries.hpp +3 -3
- package/worker/include/RTC/Serializable.hpp +1 -1
- package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
- package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
- package/worker/include/RTC/TcpConnection.hpp +9 -3
- package/worker/include/RTC/TcpServer.hpp +3 -0
- package/worker/include/RTC/Transport.hpp +52 -45
- package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
- package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
- package/worker/include/RTC/TrendCalculator.hpp +5 -5
- package/worker/include/RTC/UdpSocket.hpp +11 -2
- package/worker/include/RTC/WebRtcServer.hpp +20 -5
- package/worker/include/RTC/WebRtcTransport.hpp +35 -10
- package/worker/include/Settings.hpp +4 -2
- package/worker/include/Shared.hpp +5 -20
- package/worker/include/SharedInterface.hpp +6 -28
- package/worker/include/Utils.hpp +40 -21
- package/worker/include/common.hpp +4 -0
- package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
- package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
- package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
- package/worker/include/handles/TcpServerHandle.hpp +1 -1
- package/worker/include/handles/TimerHandle.hpp +15 -9
- package/worker/include/handles/TimerHandleInterface.hpp +10 -4
- package/worker/include/handles/UdpSocketHandle.hpp +3 -3
- package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
- package/worker/meson.build +81 -36
- package/worker/meson_options.txt +1 -0
- package/worker/mocks/include/MockShared.hpp +24 -23
- package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
- package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
- package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
- package/worker/mocks/src/MockShared.cpp +51 -5
- package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
- package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
- package/worker/scripts/clang-scripts.mjs +2 -2
- package/worker/src/Channel/ChannelNotification.cpp +5 -6
- package/worker/src/Channel/ChannelSocket.cpp +20 -2
- package/worker/src/DepLibUV.cpp +4 -5
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
- package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
- package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
- package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
- package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
- package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +233 -0
- package/worker/src/RTC/Consumer.cpp +48 -35
- package/worker/src/RTC/DataConsumer.cpp +4 -4
- package/worker/src/RTC/DataProducer.cpp +3 -3
- package/worker/src/RTC/DirectTransport.cpp +2 -2
- package/worker/src/RTC/DtlsTransport.cpp +14 -11
- package/worker/src/RTC/ICE/IceServer.cpp +2 -2
- package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
- package/worker/src/RTC/NackGenerator.cpp +12 -12
- package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
- package/worker/src/RTC/PipeTransport.cpp +16 -13
- package/worker/src/RTC/PlainTransport.cpp +25 -16
- package/worker/src/RTC/Producer.cpp +50 -36
- package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
- package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
- package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
- package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
- package/worker/src/RTC/RTP/Packet.cpp +9 -10
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
- package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
- package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
- package/worker/src/RTC/RateCalculator.cpp +99 -136
- package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
- package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
- package/worker/src/RTC/Router.cpp +18 -1
- package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
- package/worker/src/RTC/SCTP/association/Association.cpp +131 -102
- package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
- package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +16 -13
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
- package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
- package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
- package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
- package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
- package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
- package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
- package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
- package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
- package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
- package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
- package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
- package/worker/src/RTC/TcpConnection.cpp +9 -3
- package/worker/src/RTC/TcpServer.cpp +7 -2
- package/worker/src/RTC/Transport.cpp +242 -302
- package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
- package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
- package/worker/src/RTC/TrendCalculator.cpp +3 -3
- package/worker/src/RTC/UdpSocket.cpp +14 -3
- package/worker/src/RTC/WebRtcServer.cpp +20 -14
- package/worker/src/RTC/WebRtcTransport.cpp +35 -30
- package/worker/src/Settings.cpp +10 -0
- package/worker/src/Shared.cpp +2 -2
- package/worker/src/Utils/Crypto.cpp +2 -2
- package/worker/src/Worker.cpp +5 -1
- package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
- package/worker/src/handles/TimerHandle.cpp +74 -25
- package/worker/src/lib.cpp +6 -0
- package/worker/tasks.py +171 -44
- package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
- package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
- package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
- package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
- package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +137 -0
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
- package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
- package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +17 -13
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
- package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
- package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
- package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
- package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
- package/worker/test/src/RTC/TestConsumer.cpp +8 -3
- package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
- package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
- package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
- package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
- package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
- package/worker/test/src/TestDepLibUV.cpp +19 -0
- package/worker/test/src/Utils/TestTime.cpp +57 -26
- package/worker/test/src/testHelpers.cpp +1 -1
- package/worker/test/src/tests.cpp +6 -0
- package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
- package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_BWE_TYPES_HPP
|
|
2
|
+
#define MS_RTC_BWE_BWE_TYPES_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include <limits>
|
|
6
|
+
#include <string_view>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace RTC
|
|
10
|
+
{
|
|
11
|
+
namespace BWE
|
|
12
|
+
{
|
|
13
|
+
namespace Types
|
|
14
|
+
{
|
|
15
|
+
/**
|
|
16
|
+
* Bitrate meaning that there is no limit at all (bps).
|
|
17
|
+
*/
|
|
18
|
+
constexpr int64_t BitrateInfinite{ std::numeric_limits<int64_t>::max() };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Time meaning that no time was ever assigned.
|
|
22
|
+
*/
|
|
23
|
+
constexpr int64_t TimeUsInfinite{ std::numeric_limits<int64_t>::max() };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* How the network is behaving according to the delay based detector.
|
|
27
|
+
*/
|
|
28
|
+
enum class BandwidthUsage : uint8_t
|
|
29
|
+
{
|
|
30
|
+
/**
|
|
31
|
+
* Queues are not growing.
|
|
32
|
+
*/
|
|
33
|
+
NORMAL,
|
|
34
|
+
/**
|
|
35
|
+
* Queues are being emptied, so we are sending below the link capacity.
|
|
36
|
+
*/
|
|
37
|
+
UNDERUSING,
|
|
38
|
+
/**
|
|
39
|
+
* Queues are filling up, so we are sending above the link capacity.
|
|
40
|
+
*/
|
|
41
|
+
OVERUSING
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
constexpr std::string_view BandwidthUsageToString(BandwidthUsage bandwidthUsage)
|
|
45
|
+
{
|
|
46
|
+
switch (bandwidthUsage)
|
|
47
|
+
{
|
|
48
|
+
case BandwidthUsage::NORMAL:
|
|
49
|
+
{
|
|
50
|
+
return "NORMAL";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case BandwidthUsage::UNDERUSING:
|
|
54
|
+
{
|
|
55
|
+
return "UNDERUSING";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case BandwidthUsage::OVERUSING:
|
|
59
|
+
{
|
|
60
|
+
return "OVERUSING";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
NO_DEFAULT_GCC();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Estimate of the capacity of the link, used to bound the rate control.
|
|
69
|
+
*/
|
|
70
|
+
struct NetworkStateEstimate
|
|
71
|
+
{
|
|
72
|
+
/**
|
|
73
|
+
* Safe measure of the available capacity (bps).
|
|
74
|
+
*/
|
|
75
|
+
std::optional<int64_t> linkCapacityLower;
|
|
76
|
+
/**
|
|
77
|
+
* Limit applied when increasing the bitrate (bps).
|
|
78
|
+
*/
|
|
79
|
+
std::optional<int64_t> linkCapacityUpper;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Input given to the rate control on every update.
|
|
84
|
+
*/
|
|
85
|
+
struct RateControlInput
|
|
86
|
+
{
|
|
87
|
+
/**
|
|
88
|
+
* How the network is behaving according to the delay based detector.
|
|
89
|
+
*/
|
|
90
|
+
BandwidthUsage bandwidthUsage;
|
|
91
|
+
/**
|
|
92
|
+
* Bitrate acknowledged by the receiver (bps), or no value if it could
|
|
93
|
+
* not be measured.
|
|
94
|
+
*/
|
|
95
|
+
std::optional<int64_t> estimatedThroughput;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A packet that was sent and is being tracked until its feedback arrives.
|
|
100
|
+
*/
|
|
101
|
+
struct SentPacket
|
|
102
|
+
{
|
|
103
|
+
/**
|
|
104
|
+
* Sequence number of the packet within the transport, unique over the
|
|
105
|
+
* whole transport and increasing by one per tracked packet.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* - It's independent of the feedback format. With transport-cc it
|
|
109
|
+
* matches the wide sequence number carried in the header extension,
|
|
110
|
+
* while with RFC 8888 the feedback identifies packets by SSRC and RTP
|
|
111
|
+
* sequence number and the adapter resolves them against this one.
|
|
112
|
+
*/
|
|
113
|
+
int64_t sequenceNumber;
|
|
114
|
+
/**
|
|
115
|
+
* Time at which the packet was sent, or `Types::TimeUsInfinite` if it was
|
|
116
|
+
* never assigned one.
|
|
117
|
+
*/
|
|
118
|
+
int64_t sendTimeUs{ TimeUsInfinite };
|
|
119
|
+
/**
|
|
120
|
+
* Size of the packet including overhead up to the IP layer (bytes).
|
|
121
|
+
*/
|
|
122
|
+
size_t size{ 0 };
|
|
123
|
+
/**
|
|
124
|
+
* Size of the preceding packets that are not part of any feedback
|
|
125
|
+
* (bytes).
|
|
126
|
+
*/
|
|
127
|
+
size_t priorUnackedData{ 0 };
|
|
128
|
+
/**
|
|
129
|
+
* Data that was in flight when the packet was sent, itself included and
|
|
130
|
+
* the data that no feedback covers excluded (bytes).
|
|
131
|
+
*/
|
|
132
|
+
size_t dataInFlight{ 0 };
|
|
133
|
+
/**
|
|
134
|
+
* Whether it's an audio packet. False for video, padding and RTX.
|
|
135
|
+
*/
|
|
136
|
+
bool audio{ false };
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* What a feedback reported about a single sent packet.
|
|
141
|
+
*/
|
|
142
|
+
struct PacketResult
|
|
143
|
+
{
|
|
144
|
+
/**
|
|
145
|
+
* Orders packets by the time at which they arrived.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* - Send time and sequence number break the ties, which are common
|
|
149
|
+
* because the arrival times within a burst are reported with a coarse
|
|
150
|
+
* resolution.
|
|
151
|
+
*/
|
|
152
|
+
struct ReceiveTimeOrder
|
|
153
|
+
{
|
|
154
|
+
bool operator()(const PacketResult& lhs, const PacketResult& rhs) const;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Whether the packet reached the receiver at all.
|
|
159
|
+
*/
|
|
160
|
+
bool IsReceived() const
|
|
161
|
+
{
|
|
162
|
+
return this->receiveTimeUs.has_value();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
SentPacket sentPacket;
|
|
166
|
+
/**
|
|
167
|
+
* Time at which the packet arrived, in the remote clock reference, or no
|
|
168
|
+
* value if it was reported as lost.
|
|
169
|
+
*/
|
|
170
|
+
std::optional<int64_t> receiveTimeUs;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A whole feedback message, reporting on the packets sent so far.
|
|
175
|
+
*/
|
|
176
|
+
struct TransportPacketsFeedback
|
|
177
|
+
{
|
|
178
|
+
/**
|
|
179
|
+
* The packets that reached the receiver, ordered by arrival time.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* - Send time and sequence number break the ties, which are common
|
|
183
|
+
* because the arrival times within a burst are reported with a coarse
|
|
184
|
+
* resolution.
|
|
185
|
+
*/
|
|
186
|
+
std::vector<PacketResult> SortedByReceiveTime() const;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The packets that reached the receiver, in the order they were
|
|
190
|
+
* reported.
|
|
191
|
+
*/
|
|
192
|
+
std::vector<PacketResult> ReceivedWithSendInfo() const;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Time at which this feedback was received, in our own clock reference.
|
|
196
|
+
*/
|
|
197
|
+
int64_t feedbackTimeUs;
|
|
198
|
+
/**
|
|
199
|
+
* Data that was sent and no feedback has reported on yet (bytes).
|
|
200
|
+
*/
|
|
201
|
+
size_t dataInFlight{ 0 };
|
|
202
|
+
/**
|
|
203
|
+
* Every packet the feedback reports on, received and lost alike.
|
|
204
|
+
*/
|
|
205
|
+
std::vector<PacketResult> packetFeedbacks;
|
|
206
|
+
};
|
|
207
|
+
} // namespace Types
|
|
208
|
+
} // namespace BWE
|
|
209
|
+
} // namespace RTC
|
|
210
|
+
|
|
211
|
+
#endif
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_DELAY_BASED_BWE_HPP
|
|
2
|
+
#define MS_RTC_BWE_DELAY_BASED_BWE_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/AimdRateControl.hpp"
|
|
6
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
7
|
+
#include "RTC/BWE/InterArrivalDelta.hpp"
|
|
8
|
+
#include "RTC/BWE/TrendlineEstimator.hpp"
|
|
9
|
+
|
|
10
|
+
namespace RTC
|
|
11
|
+
{
|
|
12
|
+
namespace BWE
|
|
13
|
+
{
|
|
14
|
+
/**
|
|
15
|
+
* Estimates the available bitrate out of the delay between the packets that
|
|
16
|
+
* were sent and the feedback reporting when they arrived.
|
|
17
|
+
*
|
|
18
|
+
* It's the glue of the delay based path: the packets of each feedback are
|
|
19
|
+
* grouped into send bursts, the delay between consecutive groups feeds the
|
|
20
|
+
* trendline detector, and what the detector says about the network drives
|
|
21
|
+
* the rate control.
|
|
22
|
+
*/
|
|
23
|
+
class DelayBasedBwe
|
|
24
|
+
{
|
|
25
|
+
public:
|
|
26
|
+
struct DelayBasedBweOptions
|
|
27
|
+
{
|
|
28
|
+
/**
|
|
29
|
+
* Whether audio and video get a delay detector of their own instead of
|
|
30
|
+
* sharing one.
|
|
31
|
+
*/
|
|
32
|
+
bool separateAudioPackets{ false };
|
|
33
|
+
/**
|
|
34
|
+
* Number of audio packets without a video one after which the audio
|
|
35
|
+
* detector becomes the active one.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* - Only used when `separateAudioPackets` is set.
|
|
39
|
+
*/
|
|
40
|
+
int64_t separateAudioPacketThreshold{ 10 };
|
|
41
|
+
/**
|
|
42
|
+
* Time without a video packet after which the audio detector becomes
|
|
43
|
+
* the active one.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* - Only used when `separateAudioPackets` is set.
|
|
47
|
+
*/
|
|
48
|
+
int64_t separateAudioTimeThresholdUs{ 1000 * 1000 };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
struct Result
|
|
52
|
+
{
|
|
53
|
+
/**
|
|
54
|
+
* Whether the target bitrate was recomputed.
|
|
55
|
+
*/
|
|
56
|
+
bool updated{ false };
|
|
57
|
+
/**
|
|
58
|
+
* Whether the target bitrate comes from the bitrate measured by a
|
|
59
|
+
* probe.
|
|
60
|
+
*/
|
|
61
|
+
bool probe{ false };
|
|
62
|
+
/**
|
|
63
|
+
* Target bitrate (bps).
|
|
64
|
+
*/
|
|
65
|
+
int64_t targetBitrate{ 0 };
|
|
66
|
+
/**
|
|
67
|
+
* Whether the detector went back to normal after having been
|
|
68
|
+
* underusing.
|
|
69
|
+
*/
|
|
70
|
+
bool recoveredFromOveruse{ false };
|
|
71
|
+
/**
|
|
72
|
+
* What the delay based detector says about the network.
|
|
73
|
+
*/
|
|
74
|
+
Types::BandwidthUsage delayDetectorState{ Types::BandwidthUsage::NORMAL };
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
public:
|
|
78
|
+
DelayBasedBwe();
|
|
79
|
+
|
|
80
|
+
explicit DelayBasedBwe(DelayBasedBweOptions options);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Feed a whole feedback message.
|
|
84
|
+
*
|
|
85
|
+
* @param feedback - What the receiver reported about the packets sent so
|
|
86
|
+
* far.
|
|
87
|
+
* @param ackedBitrate - Bitrate acknowledged by the receiver (bps), or no
|
|
88
|
+
* value if it could not be measured.
|
|
89
|
+
* @param probeBitrate - Bitrate measured by a probe (bps), or no value if
|
|
90
|
+
* no probe was completed.
|
|
91
|
+
* @param networkEstimate - Estimate of the capacity of the link, used to
|
|
92
|
+
* bound the rate control.
|
|
93
|
+
* @param inAlr - Whether the sender is in an application limited region.
|
|
94
|
+
*/
|
|
95
|
+
Result IncomingPacketFeedbackVector(
|
|
96
|
+
const Types::TransportPacketsFeedback& feedback,
|
|
97
|
+
std::optional<int64_t> ackedBitrate,
|
|
98
|
+
std::optional<int64_t> probeBitrate,
|
|
99
|
+
const std::optional<Types::NetworkStateEstimate>& networkEstimate,
|
|
100
|
+
bool inAlr);
|
|
101
|
+
|
|
102
|
+
void OnRttUpdate(int64_t avgRttUs);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param startBitrate - Bitrate to start from (bps).
|
|
106
|
+
*/
|
|
107
|
+
void SetStartBitrate(int64_t startBitrate);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param minBitrate - Bitrate the target is never taken below (bps).
|
|
111
|
+
*/
|
|
112
|
+
void SetMinBitrate(int64_t minBitrate);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Current target bitrate of the rate control (bps), or no value if there
|
|
116
|
+
* is no valid estimate yet.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* - Unlike `GetLastEstimate()`, this is what the rate control holds right
|
|
120
|
+
* now rather than the latest value that was reported.
|
|
121
|
+
*/
|
|
122
|
+
std::optional<int64_t> GetLatestEstimate() const;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Latest target bitrate that was reported (bps).
|
|
126
|
+
*/
|
|
127
|
+
int64_t GetLastEstimate() const
|
|
128
|
+
{
|
|
129
|
+
return this->prevBitrate;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Latest state of the delay based detector that was reported.
|
|
134
|
+
*/
|
|
135
|
+
Types::BandwidthUsage GetLastState() const
|
|
136
|
+
{
|
|
137
|
+
return this->prevState;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private:
|
|
141
|
+
void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t atTimeUs);
|
|
142
|
+
|
|
143
|
+
Result MaybeUpdateEstimate(
|
|
144
|
+
std::optional<int64_t> ackedBitrate,
|
|
145
|
+
std::optional<int64_t> probeBitrate,
|
|
146
|
+
bool recoveredFromOveruse,
|
|
147
|
+
int64_t atTimeUs);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Recompute the target bitrate.
|
|
151
|
+
*
|
|
152
|
+
* @returns Whether there is a valid estimate.
|
|
153
|
+
*/
|
|
154
|
+
bool UpdateEstimate(int64_t atTimeUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate);
|
|
155
|
+
|
|
156
|
+
private:
|
|
157
|
+
const DelayBasedBweOptions options;
|
|
158
|
+
int64_t audioPacketsSinceLastVideo{ 0 };
|
|
159
|
+
std::optional<int64_t> lastVideoPacketRecvTimeUs;
|
|
160
|
+
std::optional<InterArrivalDelta> videoInterArrivalDelta;
|
|
161
|
+
std::optional<InterArrivalDelta> audioInterArrivalDelta;
|
|
162
|
+
std::optional<TrendlineEstimator> videoDelayDetector;
|
|
163
|
+
std::optional<TrendlineEstimator> audioDelayDetector;
|
|
164
|
+
TrendlineEstimator* activeDelayDetector{ nullptr };
|
|
165
|
+
std::optional<int64_t> lastSeenPacketUs;
|
|
166
|
+
AimdRateControl rateControl;
|
|
167
|
+
int64_t prevBitrate{ 0 };
|
|
168
|
+
Types::BandwidthUsage prevState{ Types::BandwidthUsage::NORMAL };
|
|
169
|
+
};
|
|
170
|
+
} // namespace BWE
|
|
171
|
+
} // namespace RTC
|
|
172
|
+
|
|
173
|
+
#endif
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_FEEDBACK_ADAPTER_HPP
|
|
2
|
+
#define MS_RTC_BWE_FEEDBACK_ADAPTER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include "RTC/BWE/SendPacketHistory.hpp"
|
|
7
|
+
#include "RTC/RTCP/FeedbackRtpTransport.hpp"
|
|
8
|
+
|
|
9
|
+
namespace RTC
|
|
10
|
+
{
|
|
11
|
+
namespace BWE
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* Turns a feedback message into what it reports about the packets that were
|
|
15
|
+
* sent, resolved against the history of sent packets.
|
|
16
|
+
*
|
|
17
|
+
* It's the only place that knows what a feedback looks like, so that
|
|
18
|
+
* supporting another format is a matter of adding another method here.
|
|
19
|
+
*
|
|
20
|
+
* The arrival times a feedback carries come from the remote clock, against
|
|
21
|
+
* a base time that wraps around, so they are unusable as they are. The
|
|
22
|
+
* first feedback is anchored on the time it was received and every later
|
|
23
|
+
* one advances that anchor by the elapsed base time, which puts the arrival
|
|
24
|
+
* times of all of them on a single timeline. Only their differences matter
|
|
25
|
+
* downstream.
|
|
26
|
+
*
|
|
27
|
+
* @see https://datatracker.ietf.org/doc/html/draft-holmer-rmcat-transport-wide-cc-extensions
|
|
28
|
+
* @see https://datatracker.ietf.org/doc/html/rfc8888
|
|
29
|
+
*/
|
|
30
|
+
class FeedbackAdapter
|
|
31
|
+
{
|
|
32
|
+
public:
|
|
33
|
+
explicit FeedbackAdapter(SendPacketHistory* sendPacketHistory);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Process a transport-cc feedback.
|
|
37
|
+
*
|
|
38
|
+
* @param receivedAtUs - Time at which the feedback was received.
|
|
39
|
+
* @returns What the feedback reports about the packets that were sent, in
|
|
40
|
+
* the order it reports them, or no value if it reports on no packet the
|
|
41
|
+
* history still holds.
|
|
42
|
+
*/
|
|
43
|
+
std::optional<Types::TransportPacketsFeedback> ProcessTransportFeedback(
|
|
44
|
+
const RTCP::FeedbackRtpTransportPacket* feedback, int64_t receivedAtUs);
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
/**
|
|
48
|
+
* Recover the sequence number the history gave to a packet out of the
|
|
49
|
+
* lowest bits of it that the wire carries.
|
|
50
|
+
*
|
|
51
|
+
* @param previousSequenceNumber - Sequence number the previous packet the
|
|
52
|
+
* feedback reported on resolved into, which the returned one is the
|
|
53
|
+
* closest to.
|
|
54
|
+
*/
|
|
55
|
+
static int64_t UnwrapSequenceNumber(uint16_t wideSequenceNumber, int64_t previousSequenceNumber);
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
SendPacketHistory* const sendPacketHistory;
|
|
59
|
+
// Our own time the arrival times of the current feedback are given
|
|
60
|
+
// against.
|
|
61
|
+
int64_t currentOffsetUs{ 0 };
|
|
62
|
+
// Base time of the latest feedback processed, in the remote clock, or no
|
|
63
|
+
// value if no feedback was ever processed.
|
|
64
|
+
std::optional<int64_t> lastFeedbackBaseTimeUs;
|
|
65
|
+
// Sequence number the latest packet reported on resolved into, or no
|
|
66
|
+
// value if no feedback was ever processed.
|
|
67
|
+
std::optional<int64_t> lastUnwrappedSequenceNumber;
|
|
68
|
+
};
|
|
69
|
+
} // namespace BWE
|
|
70
|
+
} // namespace RTC
|
|
71
|
+
|
|
72
|
+
#endif
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_INTER_ARRIVAL_DELTA_HPP
|
|
2
|
+
#define MS_RTC_BWE_INTER_ARRIVAL_DELTA_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
|
|
6
|
+
namespace RTC
|
|
7
|
+
{
|
|
8
|
+
namespace BWE
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Groups sent packets into send bursts and computes the deltas between two
|
|
12
|
+
* consecutive bursts.
|
|
13
|
+
*
|
|
14
|
+
* All packets sent within `sendTimeGroupLengthUs` of the first packet of a
|
|
15
|
+
* group belong to that group. This means that a burst of packets written
|
|
16
|
+
* into the socket at once produces a single sample rather than one per
|
|
17
|
+
* packet, which is what prevents a key frame being forwarded as a burst from
|
|
18
|
+
* being read as network congestion.
|
|
19
|
+
*
|
|
20
|
+
* The computed deltas are the input of the trendline estimator: if the
|
|
21
|
+
* arrival delta grows faster than the send delta then queues are building up
|
|
22
|
+
* somewhere in the network.
|
|
23
|
+
*/
|
|
24
|
+
class InterArrivalDelta
|
|
25
|
+
{
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Deltas between two consecutive groups of packets sent in a burst.
|
|
29
|
+
*/
|
|
30
|
+
struct Deltas
|
|
31
|
+
{
|
|
32
|
+
/**
|
|
33
|
+
* Time elapsed between the send times of both groups (us).
|
|
34
|
+
*/
|
|
35
|
+
int64_t sendDeltaUs;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Time elapsed between the arrival times of both groups (us).
|
|
39
|
+
*/
|
|
40
|
+
int64_t arrivalDeltaUs;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Difference of size between both groups (bytes).
|
|
44
|
+
*/
|
|
45
|
+
int64_t sizeDelta;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
struct SendTimeGroup
|
|
50
|
+
{
|
|
51
|
+
bool IsFirstPacket() const
|
|
52
|
+
{
|
|
53
|
+
return !this->completeTimeUs.has_value();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
size_t size{ 0 };
|
|
57
|
+
int64_t firstSendTimeUs{ 0 };
|
|
58
|
+
int64_t sendTimeUs{ 0 };
|
|
59
|
+
int64_t firstArrivalTimeUs{ 0 };
|
|
60
|
+
std::optional<int64_t> completeTimeUs;
|
|
61
|
+
int64_t lastFeedbackAtUs{ 0 };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
/**
|
|
66
|
+
* @param sendTimeGroupLengthUs - Every packet sent within this time of the
|
|
67
|
+
* first packet of a group belongs to that group.
|
|
68
|
+
*/
|
|
69
|
+
explicit InterArrivalDelta(int64_t sendTimeGroupLengthUs);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Feed a sent packet whose arrival time is already known.
|
|
73
|
+
*
|
|
74
|
+
* @param sendTimeUs - Time at which the packet was sent.
|
|
75
|
+
* @param arrivalTimeUs - Time at which the packet arrived, in the remote
|
|
76
|
+
* clock reference.
|
|
77
|
+
* @param feedbackAtUs - Time, in our own clock reference, at which the
|
|
78
|
+
* RTCP feedback reporting this packet was received. It's the very same
|
|
79
|
+
* value for every packet within a given feedback, and it's used to
|
|
80
|
+
* detect that the remote clock has jumped by comparing how much it
|
|
81
|
+
* advanced against how much ours did.
|
|
82
|
+
* @param packetSize - Size of the packet (bytes).
|
|
83
|
+
*
|
|
84
|
+
* @returns The deltas between the two latest complete groups, or no value
|
|
85
|
+
* if they cannot be computed yet.
|
|
86
|
+
*/
|
|
87
|
+
std::optional<Deltas> ComputeDeltas(
|
|
88
|
+
int64_t sendTimeUs, int64_t arrivalTimeUs, int64_t feedbackAtUs, size_t packetSize);
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
bool IsNewSendTimeGroup(int64_t arrivalTimeUs, int64_t sendTimeUs) const;
|
|
92
|
+
|
|
93
|
+
bool BelongsToBurst(int64_t arrivalTimeUs, int64_t sendTimeUs) const;
|
|
94
|
+
|
|
95
|
+
void Reset();
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
const int64_t sendTimeGroupLengthUs;
|
|
99
|
+
SendTimeGroup currentGroup;
|
|
100
|
+
SendTimeGroup prevGroup;
|
|
101
|
+
size_t numConsecutiveReorderedGroups{ 0 };
|
|
102
|
+
};
|
|
103
|
+
} // namespace BWE
|
|
104
|
+
} // namespace RTC
|
|
105
|
+
|
|
106
|
+
#endif
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_LINK_CAPACITY_ESTIMATOR_HPP
|
|
2
|
+
#define MS_RTC_BWE_LINK_CAPACITY_ESTIMATOR_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
|
|
6
|
+
namespace RTC
|
|
7
|
+
{
|
|
8
|
+
namespace BWE
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* Estimates the capacity of the link out of the bitrates at which
|
|
12
|
+
* congestion was observed.
|
|
13
|
+
*
|
|
14
|
+
* Every sample is fed into an exponential filter, and the variance of the
|
|
15
|
+
* estimate is tracked along with it so that a confidence interval can be
|
|
16
|
+
* derived. The rate control uses that interval to tell whether the measured
|
|
17
|
+
* throughput still has anything to do with the capacity it had estimated: a
|
|
18
|
+
* throughput outside of it means that the link changed, so the estimate is
|
|
19
|
+
* dropped instead of being slowly filtered towards the new reality.
|
|
20
|
+
*/
|
|
21
|
+
class LinkCapacityEstimator
|
|
22
|
+
{
|
|
23
|
+
public:
|
|
24
|
+
/**
|
|
25
|
+
* Feed the bitrate at which the network started to be overused, which is
|
|
26
|
+
* an observation of where the capacity of the link is.
|
|
27
|
+
*
|
|
28
|
+
* @param ackedBitrate - Acknowledged bitrate when overuse was detected
|
|
29
|
+
* (bps).
|
|
30
|
+
*/
|
|
31
|
+
void OnOveruseDetected(int64_t ackedBitrate);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Feed the bitrate measured by a probe. It's given far more weight than an
|
|
35
|
+
* overuse, since a probe measures the capacity of the link directly rather
|
|
36
|
+
* than inferring it from the delay.
|
|
37
|
+
*
|
|
38
|
+
* @param probeBitrate - Bitrate measured by the probe (bps).
|
|
39
|
+
*/
|
|
40
|
+
void OnProbeRate(int64_t probeBitrate);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Current estimate of the capacity of the link (bps), or no value if
|
|
44
|
+
* nothing has been observed yet.
|
|
45
|
+
*/
|
|
46
|
+
std::optional<int64_t> GetEstimate() const;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Upper end of the confidence interval of the estimate (bps), or
|
|
50
|
+
* `Types::BitrateInfinite` if there is no estimate yet.
|
|
51
|
+
*/
|
|
52
|
+
int64_t GetUpperBound() const;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Lower end of the confidence interval of the estimate (bps), or 0 if
|
|
56
|
+
* there is no estimate yet.
|
|
57
|
+
*/
|
|
58
|
+
int64_t GetLowerBound() const;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Drop the estimate, so that the next sample is taken as is instead of
|
|
62
|
+
* being filtered against a value that no longer holds.
|
|
63
|
+
*/
|
|
64
|
+
void Reset();
|
|
65
|
+
|
|
66
|
+
private:
|
|
67
|
+
void Update(int64_t bitrate, double alpha);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Standard deviation of the estimate, derived from the normalized variance
|
|
71
|
+
* being tracked. Only meaningful once there is an estimate.
|
|
72
|
+
*/
|
|
73
|
+
double GetDeviationEstimateKbps() const;
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
// NOTE: The filter works in kbps as double since the bounds applied to the
|
|
77
|
+
// variance are calibrated in those units.
|
|
78
|
+
std::optional<double> estimateKbps;
|
|
79
|
+
double deviationKbps{ 0.4 };
|
|
80
|
+
};
|
|
81
|
+
} // namespace BWE
|
|
82
|
+
} // namespace RTC
|
|
83
|
+
|
|
84
|
+
#endif
|