mediasoup 3.26.0 → 3.27.1
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 +16 -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/FBS/meson.build +25 -0
- package/worker/fbs/meson.build +15 -18
- 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/LossBasedController.hpp +520 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
- package/worker/include/RTC/BWE/TargetRateController.hpp +306 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +143 -0
- package/worker/include/RTC/BWE/Utils.hpp +39 -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 +38 -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 +6 -6
- package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +10 -0
- 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 +87 -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/LossBasedController.cpp +1046 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
- package/worker/src/RTC/BWE/TargetRateController.cpp +435 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +311 -0
- package/worker/src/RTC/BWE/Utils.cpp +54 -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 +146 -103
- 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 +122 -14
- 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 +2 -2
- 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 +266 -307
- 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 +197 -45
- 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/TestLossBasedController.cpp +1199 -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/TestTargetRateController.cpp +337 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +182 -0
- package/worker/test/src/RTC/BWE/TestUtils.cpp +61 -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 +128 -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,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
|
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_LOSS_BASED_CONTROLLER_HPP
|
|
2
|
+
#define MS_RTC_BWE_LOSS_BASED_CONTROLLER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include <ankerl/unordered_dense.h>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace RTC
|
|
10
|
+
{
|
|
11
|
+
namespace BWE
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* Tells the loss caused by congestion from the loss a link has by itself.
|
|
15
|
+
*
|
|
16
|
+
* A link can lose packets without being congested at all, which is the normal
|
|
17
|
+
* state of Wi-Fi and mobile links, and reacting to that loss by sending less
|
|
18
|
+
* doesn't reduce it: it just gives away capacity that was there. Telling both
|
|
19
|
+
* apart cannot be done by looking at a loss figure, because the very same
|
|
20
|
+
* figure means different things at different sending rates.
|
|
21
|
+
*
|
|
22
|
+
* So instead of a rule on the reported loss, this is an estimator of two
|
|
23
|
+
* values that together describe the link: how much it loses when it is not
|
|
24
|
+
* congested, and how much it can carry. With those two, the loss to expect
|
|
25
|
+
* from an observation is known: the inherent one while sending below the
|
|
26
|
+
* capacity, plus the share of the excess while sending above it. The pair of
|
|
27
|
+
* values that makes the losses actually observed most likely is the estimate,
|
|
28
|
+
* and the bitrate of that pair is the answer.
|
|
29
|
+
*
|
|
30
|
+
* Candidates slightly above, at and below the current estimate are tried on
|
|
31
|
+
* every update, each refined by a step of Newton's method on the inherent
|
|
32
|
+
* loss, and the most likely one wins. A bias towards higher bitrates keeps
|
|
33
|
+
* the estimate from settling low when the observations cannot tell them
|
|
34
|
+
* apart, and fades away as the observed loss grows.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - This class is a port of the LossBasedBweV2 class in libwebrtc (renamed to
|
|
38
|
+
* a better name).
|
|
39
|
+
*/
|
|
40
|
+
class LossBasedController
|
|
41
|
+
{
|
|
42
|
+
public:
|
|
43
|
+
struct LossBasedControllerOptions
|
|
44
|
+
{
|
|
45
|
+
/**
|
|
46
|
+
* Factors applied to the current estimate to build the candidates that
|
|
47
|
+
* are tried on every update.
|
|
48
|
+
*/
|
|
49
|
+
std::vector<double> candidateFactors{ 1.02, 1.0, 0.95 };
|
|
50
|
+
/**
|
|
51
|
+
* How much the estimate may grow over the acknowledged bitrate while
|
|
52
|
+
* the link is loss limited.
|
|
53
|
+
*/
|
|
54
|
+
double bitrateRampupUpperBoundFactor{ 1.5 };
|
|
55
|
+
/**
|
|
56
|
+
* The same while the estimate is being held, which is more conservative
|
|
57
|
+
* because holding means that a higher bitrate already caused loss.
|
|
58
|
+
*/
|
|
59
|
+
double bitrateRampupUpperBoundFactorInHold{ 1.2 };
|
|
60
|
+
/**
|
|
61
|
+
* How far below the held bitrate the acknowledged one has to be for the
|
|
62
|
+
* factor above to be the one applied.
|
|
63
|
+
*/
|
|
64
|
+
double bitrateRampupHoldThreshold{ 1.3 };
|
|
65
|
+
/**
|
|
66
|
+
* How much of the acknowledged bitrate the estimate may grow by on top
|
|
67
|
+
* of its usual bound, the longer the more time has passed since it was
|
|
68
|
+
* last reduced. Zero disables that acceleration.
|
|
69
|
+
*/
|
|
70
|
+
double rampupAccelerationMaxFactor{ 0.0 };
|
|
71
|
+
/**
|
|
72
|
+
* Time since the last reduction at which that acceleration is at its
|
|
73
|
+
* fullest.
|
|
74
|
+
*/
|
|
75
|
+
int64_t rampupAccelerationMaxoutTimeUs{ 60 * 1000 * 1000 };
|
|
76
|
+
/**
|
|
77
|
+
* Weight given to a higher bitrate when choosing among candidates, so
|
|
78
|
+
* that observations which cannot tell them apart don't settle low.
|
|
79
|
+
*/
|
|
80
|
+
double higherBitrateBiasFactor{ 0.0002 };
|
|
81
|
+
/**
|
|
82
|
+
* The same, applied to the logarithm of the bitrate, so that the bias
|
|
83
|
+
* doesn't grow without bound.
|
|
84
|
+
*/
|
|
85
|
+
double higherLogBitrateBiasFactor{ 0.02 };
|
|
86
|
+
/**
|
|
87
|
+
* Observed loss at which the bias above is gone, since at that much loss
|
|
88
|
+
* preferring a higher bitrate is not defensible anymore.
|
|
89
|
+
*/
|
|
90
|
+
double lossThresholdOfHighBitratePreference{ 0.2 };
|
|
91
|
+
/**
|
|
92
|
+
* How abruptly that bias fades as the observed loss approaches the
|
|
93
|
+
* threshold above.
|
|
94
|
+
*/
|
|
95
|
+
double bitratePreferenceSmoothingFactor{ 0.002 };
|
|
96
|
+
/**
|
|
97
|
+
* Lowest inherent loss that may be estimated for a link.
|
|
98
|
+
*/
|
|
99
|
+
double inherentLossLowerBound{ 1.0e-3 };
|
|
100
|
+
/**
|
|
101
|
+
* Inherent loss that may be estimated at an unbounded bitrate, which
|
|
102
|
+
* grows as the bitrate gets lower by the balance below.
|
|
103
|
+
*/
|
|
104
|
+
double inherentLossUpperBoundOffset{ 0.05 };
|
|
105
|
+
/**
|
|
106
|
+
* Bitrate at which the inherent loss upper bound grows by one, so that a
|
|
107
|
+
* low bitrate is allowed to be explained by a lossy link.
|
|
108
|
+
*/
|
|
109
|
+
int64_t inherentLossUpperBoundBitrateBalance{ 100000 };
|
|
110
|
+
/**
|
|
111
|
+
* Inherent loss assumed before anything has been observed.
|
|
112
|
+
*/
|
|
113
|
+
double initialInherentLossEstimate{ 0.01 };
|
|
114
|
+
/**
|
|
115
|
+
* Steps of Newton's method applied to each candidate.
|
|
116
|
+
*/
|
|
117
|
+
int64_t newtonIterations{ 1 };
|
|
118
|
+
/**
|
|
119
|
+
* Fraction of the step that each of those iterations takes.
|
|
120
|
+
*/
|
|
121
|
+
double newtonStepSize{ 0.75 };
|
|
122
|
+
/**
|
|
123
|
+
* Whether the acknowledged bitrate is tried as a candidate of its own.
|
|
124
|
+
*/
|
|
125
|
+
bool appendAcknowledgedRateCandidate{ true };
|
|
126
|
+
/**
|
|
127
|
+
* Whether the delay based estimate is tried as a candidate of its own
|
|
128
|
+
* while it's above the current one.
|
|
129
|
+
*/
|
|
130
|
+
bool appendDelayBasedEstimateCandidate{ true };
|
|
131
|
+
/**
|
|
132
|
+
* Whether the bound that the observed loss puts on the estimate is tried
|
|
133
|
+
* as a candidate while not filling the link, which lets the estimate
|
|
134
|
+
* come down to it in one step instead of gradually.
|
|
135
|
+
*/
|
|
136
|
+
bool appendUpperBoundCandidateInAlr{ false };
|
|
137
|
+
/**
|
|
138
|
+
* Shortest span of send times that an observation may cover.
|
|
139
|
+
*/
|
|
140
|
+
int64_t observationDurationLowerBoundUs{ 250 * 1000 };
|
|
141
|
+
/**
|
|
142
|
+
* Observations kept, which is how far back the estimate looks.
|
|
143
|
+
*/
|
|
144
|
+
int64_t observationWindowSize{ 15 };
|
|
145
|
+
/**
|
|
146
|
+
* Observations needed before this controller may be used at all.
|
|
147
|
+
*/
|
|
148
|
+
int64_t minNumObservations{ 3 };
|
|
149
|
+
/**
|
|
150
|
+
* How much the sending rate of an observation is smoothed with the one
|
|
151
|
+
* of the previous observation.
|
|
152
|
+
*
|
|
153
|
+
* @remarks
|
|
154
|
+
* - Zero means no smoothing at all, which is what libwebrtc does. A
|
|
155
|
+
* sender of a couple of streams has a sending rate that only changes
|
|
156
|
+
* when it decides so, while ours is the sum of many streams whose
|
|
157
|
+
* makeup changes on its own, and those changes are not the network.
|
|
158
|
+
*/
|
|
159
|
+
double sendingRateSmoothingFactor{ 0.0 };
|
|
160
|
+
/**
|
|
161
|
+
* How much weight each observation loses per observation of age when
|
|
162
|
+
* looking for the most likely pair of values.
|
|
163
|
+
*/
|
|
164
|
+
double temporalWeightFactor{ 0.9 };
|
|
165
|
+
/**
|
|
166
|
+
* The same, for the average observed loss that bounds the estimate right
|
|
167
|
+
* away.
|
|
168
|
+
*/
|
|
169
|
+
double immediateUpperBoundTemporalWeightFactor{ 0.9 };
|
|
170
|
+
/**
|
|
171
|
+
* Observed loss under which no immediate upper bound is applied.
|
|
172
|
+
*/
|
|
173
|
+
double immediateUpperBoundLossOffset{ 0.05 };
|
|
174
|
+
/**
|
|
175
|
+
* Bitrate the immediate upper bound allows per unit of observed loss
|
|
176
|
+
* over the offset above.
|
|
177
|
+
*/
|
|
178
|
+
int64_t immediateUpperBoundBitrateBalance{ 100000 };
|
|
179
|
+
/**
|
|
180
|
+
* How much of the acknowledged bitrate the estimate may never go below.
|
|
181
|
+
*/
|
|
182
|
+
double lowerBoundByAckedRateFactor{ 1.0 };
|
|
183
|
+
/**
|
|
184
|
+
* Fraction of the acknowledged bitrate taken as a candidate when backing
|
|
185
|
+
* off.
|
|
186
|
+
*/
|
|
187
|
+
double bitrateBackoffLowerBoundFactor{ 1.0 };
|
|
188
|
+
/**
|
|
189
|
+
* How much the estimate may grow within the window that follows a
|
|
190
|
+
* decrease.
|
|
191
|
+
*/
|
|
192
|
+
double maxIncreaseFactor{ 1.3 };
|
|
193
|
+
/**
|
|
194
|
+
* How long that window lasts.
|
|
195
|
+
*/
|
|
196
|
+
int64_t delayedIncreaseWindowUs{ 300 * 1000 };
|
|
197
|
+
/**
|
|
198
|
+
* Whether the estimate is held back while the loss observed is worse
|
|
199
|
+
* than the one the chosen candidate says the link has by itself, since
|
|
200
|
+
* then the excess is ours to fix.
|
|
201
|
+
*/
|
|
202
|
+
bool notIncreaseIfInherentLossLessThanAverageLoss{ true };
|
|
203
|
+
/**
|
|
204
|
+
* Whether the acknowledged bitrate stops being a candidate while not
|
|
205
|
+
* filling the link, since then what it delivers says nothing about what
|
|
206
|
+
* it could deliver.
|
|
207
|
+
*/
|
|
208
|
+
bool notUseAckedRateInAlr{ true };
|
|
209
|
+
/**
|
|
210
|
+
* Whether this controller may take the estimate over while the target is
|
|
211
|
+
* still in its start phase.
|
|
212
|
+
*/
|
|
213
|
+
bool useInStartPhase{ true };
|
|
214
|
+
/**
|
|
215
|
+
* How much each hold lasts compared to the previous one, which makes
|
|
216
|
+
* repeated failures to increase back off for longer.
|
|
217
|
+
*/
|
|
218
|
+
double holdDurationFactor{ 2.0 };
|
|
219
|
+
/**
|
|
220
|
+
* Whether loss is measured in bytes rather than in packets, which tells
|
|
221
|
+
* a lost packet of a full frame apart from a lost one carrying almost
|
|
222
|
+
* nothing.
|
|
223
|
+
*/
|
|
224
|
+
bool useByteLossRate{ true };
|
|
225
|
+
/**
|
|
226
|
+
* Whether an estimate that had to be brought down to its bounds stops
|
|
227
|
+
* being kept as a description of the link.
|
|
228
|
+
*/
|
|
229
|
+
bool boundBestCandidate{ true };
|
|
230
|
+
/**
|
|
231
|
+
* How much the sending rate of an observation has to exceed the median
|
|
232
|
+
* of the window for its loss to be taken at face value instead of as a
|
|
233
|
+
* spike.
|
|
234
|
+
*/
|
|
235
|
+
double medianSendingRateFactor{ 2.0 };
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* What this controller is doing with the estimate, which the orchestrator
|
|
240
|
+
* needs in order to decide whether to probe.
|
|
241
|
+
*/
|
|
242
|
+
enum class State : uint8_t
|
|
243
|
+
{
|
|
244
|
+
/**
|
|
245
|
+
* The link is loss limited and the estimate is growing back.
|
|
246
|
+
*/
|
|
247
|
+
INCREASING,
|
|
248
|
+
/**
|
|
249
|
+
* The link is loss limited and the estimate is being reduced.
|
|
250
|
+
*/
|
|
251
|
+
DECREASING,
|
|
252
|
+
/**
|
|
253
|
+
* The link is not loss limited, so the delay based estimate rules.
|
|
254
|
+
*/
|
|
255
|
+
DELAY_BASED_ESTIMATE
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
struct Result
|
|
259
|
+
{
|
|
260
|
+
int64_t bitrate{ 0 };
|
|
261
|
+
State state{ State::DELAY_BASED_ESTIMATE };
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
private:
|
|
265
|
+
/**
|
|
266
|
+
* The pair of values that describe a link.
|
|
267
|
+
*/
|
|
268
|
+
struct ChannelParameters
|
|
269
|
+
{
|
|
270
|
+
/**
|
|
271
|
+
* Loss the link has while not congested at all.
|
|
272
|
+
*/
|
|
273
|
+
double inherentLoss{ 0.0 };
|
|
274
|
+
/**
|
|
275
|
+
* Bitrate the link can carry, or zero while it's not known yet.
|
|
276
|
+
*/
|
|
277
|
+
int64_t lossLimitedBitrate{ 0 };
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* First and second derivatives of the likelihood with respect to the
|
|
282
|
+
* inherent loss, which is what Newton's method needs.
|
|
283
|
+
*/
|
|
284
|
+
struct Derivatives
|
|
285
|
+
{
|
|
286
|
+
double first{ 0.0 };
|
|
287
|
+
double second{ 0.0 };
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* What was sent and lost over a span of send times, which is the unit this
|
|
292
|
+
* controller reasons about.
|
|
293
|
+
*/
|
|
294
|
+
struct Observation
|
|
295
|
+
{
|
|
296
|
+
bool IsInitialized() const
|
|
297
|
+
{
|
|
298
|
+
return this->id != -1;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
int64_t numPackets{ 0 };
|
|
302
|
+
int64_t numLostPackets{ 0 };
|
|
303
|
+
int64_t numReceivedPackets{ 0 };
|
|
304
|
+
int64_t sendingRate{ 0 };
|
|
305
|
+
int64_t sizeBytes{ 0 };
|
|
306
|
+
int64_t lostSizeBytes{ 0 };
|
|
307
|
+
int64_t id{ -1 };
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Feedback accumulated so far, which becomes an observation once it covers
|
|
312
|
+
* a long enough span of send times.
|
|
313
|
+
*/
|
|
314
|
+
struct PartialObservation
|
|
315
|
+
{
|
|
316
|
+
/**
|
|
317
|
+
* Size of the packets reported as lost, by sequence number, so that a
|
|
318
|
+
* packet reported lost and received later stops counting.
|
|
319
|
+
*/
|
|
320
|
+
ankerl::unordered_dense::map<int64_t, int64_t> lostPackets;
|
|
321
|
+
int64_t numPackets{ 0 };
|
|
322
|
+
int64_t sizeBytes{ 0 };
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* The bitrate the estimate is not allowed to grow above while holding, and
|
|
327
|
+
* for how long.
|
|
328
|
+
*/
|
|
329
|
+
struct HoldInfo
|
|
330
|
+
{
|
|
331
|
+
int64_t atUs{ 0 };
|
|
332
|
+
int64_t durationUs{ 0 };
|
|
333
|
+
int64_t bitrate{ Types::BitrateInfinite };
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
public:
|
|
337
|
+
LossBasedController();
|
|
338
|
+
|
|
339
|
+
explicit LossBasedController(LossBasedControllerOptions options);
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Whether enough has been observed for this controller to say anything.
|
|
343
|
+
*/
|
|
344
|
+
bool IsReady() const;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Whether this controller may take the estimate over while the target is
|
|
348
|
+
* still in its start phase.
|
|
349
|
+
*/
|
|
350
|
+
bool IsReadyToUseInStartPhase() const;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Whether this controller is allowed to be used during the start phase at
|
|
354
|
+
* all, regardless of whether it has observed enough to say anything.
|
|
355
|
+
*/
|
|
356
|
+
bool IsUsedInStartPhase() const
|
|
357
|
+
{
|
|
358
|
+
return this->options.useInStartPhase;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Forget everything observed so far, which is what a link that is not the
|
|
363
|
+
* same one anymore calls for.
|
|
364
|
+
*/
|
|
365
|
+
void Reset();
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Latest estimate, or the delay based one while this controller cannot say
|
|
369
|
+
* anything yet.
|
|
370
|
+
*/
|
|
371
|
+
Result GetResult() const;
|
|
372
|
+
|
|
373
|
+
void SetAcknowledgedBitrate(int64_t acknowledgedBitrate);
|
|
374
|
+
|
|
375
|
+
void SetBitrateLimits(int64_t minBitrate, int64_t maxBitrate);
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Place the estimate at the given bitrate.
|
|
379
|
+
*/
|
|
380
|
+
void SetBitrateEstimate(int64_t bitrate);
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Feed the results of a feedback message.
|
|
384
|
+
*
|
|
385
|
+
* @param delayBasedEstimate - Estimate of the delay based path, which
|
|
386
|
+
* bounds this one, or `Types::BitrateInfinite` if there is none.
|
|
387
|
+
* @param inAlr - Whether the sender is not sending enough to fill the link,
|
|
388
|
+
* in which case the acknowledged bitrate says nothing about its capacity.
|
|
389
|
+
*/
|
|
390
|
+
void UpdateBitrateEstimate(
|
|
391
|
+
const std::vector<Types::PacketResult>& packetResults, int64_t delayBasedEstimate, bool inAlr);
|
|
392
|
+
|
|
393
|
+
private:
|
|
394
|
+
/**
|
|
395
|
+
* Add the given results to the observation being accumulated, and close it
|
|
396
|
+
* if it already covers a long enough span of send times.
|
|
397
|
+
*
|
|
398
|
+
* @returns Whether an observation was closed, which is when the estimate
|
|
399
|
+
* can be recalculated.
|
|
400
|
+
*/
|
|
401
|
+
bool PushBackObservation(const std::vector<Types::PacketResult>& packetResults);
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Candidates to try on this update, each already within bounds.
|
|
405
|
+
*/
|
|
406
|
+
std::vector<ChannelParameters> GetCandidates(bool inAlr) const;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Highest bitrate a candidate may have.
|
|
410
|
+
*/
|
|
411
|
+
int64_t GetCandidateBitrateUpperBound() const;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* How likely the losses observed are if the link were as the given pair of
|
|
415
|
+
* values says, plus the bias towards higher bitrates.
|
|
416
|
+
*/
|
|
417
|
+
double GetObjective(const ChannelParameters& channelParameters) const;
|
|
418
|
+
|
|
419
|
+
Derivatives GetDerivatives(const ChannelParameters& channelParameters) const;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Refine the inherent loss of the given candidate.
|
|
423
|
+
*/
|
|
424
|
+
void ApplyNewtonsMethod(ChannelParameters& channelParameters) const;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Bring the inherent loss of the given candidate within what a link at its
|
|
428
|
+
* bitrate could plausibly have.
|
|
429
|
+
*/
|
|
430
|
+
double GetFeasibleInherentLoss(const ChannelParameters& channelParameters) const;
|
|
431
|
+
|
|
432
|
+
double GetInherentLossUpperBound(int64_t bitrate) const;
|
|
433
|
+
|
|
434
|
+
double AdjustBiasFactor(double lossRate, double biasFactor) const;
|
|
435
|
+
|
|
436
|
+
double GetHighBitrateBias(int64_t bitrate) const;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Sending rate an observation is taken to have, which is its own smoothed
|
|
440
|
+
* with the one of the previous observation.
|
|
441
|
+
*/
|
|
442
|
+
int64_t GetSendingRate(int64_t instantSendingRate) const;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Average loss observed over the window, leaving out the highest and the
|
|
446
|
+
* lowest so that a single spike doesn't drag it.
|
|
447
|
+
*/
|
|
448
|
+
void UpdateAverageReportedLossRatio();
|
|
449
|
+
|
|
450
|
+
double CalculateAverageReportedPacketLossRatio() const;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The same by bytes, which tells a lost packet carrying a full frame apart
|
|
454
|
+
* from one carrying almost nothing.
|
|
455
|
+
*/
|
|
456
|
+
double CalculateAverageReportedByteLossRatio() const;
|
|
457
|
+
|
|
458
|
+
int64_t GetMedianSendingRate() const;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Bound that the observed loss puts on the estimate right away, without
|
|
462
|
+
* waiting for it to converge.
|
|
463
|
+
*/
|
|
464
|
+
int64_t GetImmediateUpperBoundBitrate() const;
|
|
465
|
+
|
|
466
|
+
void CalculateImmediateUpperBoundBitrate();
|
|
467
|
+
|
|
468
|
+
int64_t GetImmediateLowerBoundBitrate() const;
|
|
469
|
+
|
|
470
|
+
void CalculateImmediateLowerBoundBitrate();
|
|
471
|
+
|
|
472
|
+
void CalculateTemporalWeights();
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Whether the link is loss limited at all, which is what tells this
|
|
476
|
+
* controller's estimate apart from just following the delay based one.
|
|
477
|
+
*/
|
|
478
|
+
bool IsInLossLimitedState() const;
|
|
479
|
+
|
|
480
|
+
bool IsEstimateIncreasingWhenLossLimited(int64_t oldEstimate, int64_t newEstimate) const;
|
|
481
|
+
|
|
482
|
+
private:
|
|
483
|
+
// Passed by argument.
|
|
484
|
+
const LossBasedControllerOptions options;
|
|
485
|
+
// Others.
|
|
486
|
+
// Observations of the window, indexed by their id modulo its size.
|
|
487
|
+
std::vector<Observation> observations;
|
|
488
|
+
// Weight of an observation per observation of age.
|
|
489
|
+
std::vector<double> temporalWeights;
|
|
490
|
+
// The same, for the average observed loss.
|
|
491
|
+
std::vector<double> immediateUpperBoundTemporalWeights;
|
|
492
|
+
struct PartialObservation partialObservation;
|
|
493
|
+
struct ChannelParameters currentBestEstimate;
|
|
494
|
+
struct HoldInfo lastHoldInfo;
|
|
495
|
+
struct Result result;
|
|
496
|
+
// Observations closed so far, which never decreases and hence also gives
|
|
497
|
+
// the id of the next one.
|
|
498
|
+
int64_t numObservations{ 0 };
|
|
499
|
+
// Highest send time of the latest observation, which is the clock this
|
|
500
|
+
// controller runs on. Feedback is the only thing that moves it.
|
|
501
|
+
std::optional<int64_t> lastSendTimeOfLatestObservationUs;
|
|
502
|
+
double averageReportedLossRatio{ 0.0 };
|
|
503
|
+
int64_t acknowledgedBitrate{ Types::BitrateInfinite };
|
|
504
|
+
int64_t delayBasedEstimate{ Types::BitrateInfinite };
|
|
505
|
+
int64_t minBitrate{ 0 };
|
|
506
|
+
int64_t maxBitrate{ Types::BitrateInfinite };
|
|
507
|
+
std::optional<int64_t> immediateUpperBoundBitrate;
|
|
508
|
+
std::optional<int64_t> immediateLowerBoundBitrate;
|
|
509
|
+
// Bitrate the estimate may not grow above until the window that follows a
|
|
510
|
+
// decrease is over.
|
|
511
|
+
int64_t bitrateLimitInCurrentWindow{ Types::BitrateInfinite };
|
|
512
|
+
std::optional<int64_t> recoveringAfterLossAtUs;
|
|
513
|
+
// Instant at which the estimate was last brought down, which is what the
|
|
514
|
+
// rampup acceleration grows from.
|
|
515
|
+
std::optional<int64_t> lastBitrateReducedAtUs;
|
|
516
|
+
};
|
|
517
|
+
} // namespace BWE
|
|
518
|
+
} // namespace RTC
|
|
519
|
+
|
|
520
|
+
#endif
|