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,190 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_AIMD_RATE_CONTROL_HPP
|
|
2
|
+
#define MS_RTC_BWE_AIMD_RATE_CONTROL_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include "RTC/BWE/LinkCapacityEstimator.hpp"
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace BWE
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Decides the target bitrate out of what the delay based detector says about
|
|
14
|
+
* the network.
|
|
15
|
+
*
|
|
16
|
+
* While no overuse is detected the bitrate is increased, multiplicatively
|
|
17
|
+
* when the capacity of the link is still unknown and additively once it has
|
|
18
|
+
* been estimated, since being close to the capacity makes a big step
|
|
19
|
+
* expensive. On overuse it is decreased to slightly below the measured
|
|
20
|
+
* throughput and held there until the queues of the network drain.
|
|
21
|
+
*/
|
|
22
|
+
class AimdRateControl
|
|
23
|
+
{
|
|
24
|
+
public:
|
|
25
|
+
struct AimdRateControlOptions
|
|
26
|
+
{
|
|
27
|
+
/**
|
|
28
|
+
* Fraction of the measured throughput the bitrate is dropped to when
|
|
29
|
+
* overuse is detected.
|
|
30
|
+
*/
|
|
31
|
+
double backoffFactor{ 0.85 };
|
|
32
|
+
/**
|
|
33
|
+
* Whether the bitrate is not allowed to increase while the sender is in
|
|
34
|
+
* an application limited region. In that region the network gives no
|
|
35
|
+
* feedback about whether a higher bitrate would have worked, so an
|
|
36
|
+
* increase cannot be validated.
|
|
37
|
+
*/
|
|
38
|
+
bool noBitrateIncreaseInAlr{ false };
|
|
39
|
+
/**
|
|
40
|
+
* Whether the estimate of the link capacity is used as an upper bound.
|
|
41
|
+
*/
|
|
42
|
+
bool estimateBoundedIncrease{ true };
|
|
43
|
+
/**
|
|
44
|
+
* Whether the current bitrate is taken as the lowest possible upper
|
|
45
|
+
* bound, so that an estimate of the link capacity below it does not
|
|
46
|
+
* drag the bitrate down.
|
|
47
|
+
*/
|
|
48
|
+
bool useCurrentEstimateAsMinUpperBound{ true };
|
|
49
|
+
/**
|
|
50
|
+
* Whether this rate control runs in the endpoint that sends the media
|
|
51
|
+
* whose capacity is being estimated, rather than in the one that
|
|
52
|
+
* receives it. Only the sender can know that it's in an application
|
|
53
|
+
* limited region, so `noBitrateIncreaseInAlr` has no effect otherwise.
|
|
54
|
+
*/
|
|
55
|
+
bool sendSide{ false };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
enum class RateControlState : uint8_t
|
|
60
|
+
{
|
|
61
|
+
HOLD,
|
|
62
|
+
INCREASE,
|
|
63
|
+
DECREASE
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
AimdRateControl();
|
|
68
|
+
|
|
69
|
+
explicit AimdRateControl(AimdRateControlOptions options);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether the target bitrate has been initialized, which happens either
|
|
73
|
+
* when it's explicitly set or once a throughput has been measured for long
|
|
74
|
+
* enough.
|
|
75
|
+
*/
|
|
76
|
+
bool IsValidEstimate() const
|
|
77
|
+
{
|
|
78
|
+
return this->bitrateIsInitialized;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Current target bitrate (bps).
|
|
83
|
+
*/
|
|
84
|
+
int64_t GetLatestEstimate() const
|
|
85
|
+
{
|
|
86
|
+
return this->currentBitrate;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Feed what the delay based detector says about the network.
|
|
91
|
+
*
|
|
92
|
+
* @param input - State of the network plus the acknowledged bitrate.
|
|
93
|
+
* @param atTimeUs - Time at which the input was produced.
|
|
94
|
+
*
|
|
95
|
+
* @returns The new target bitrate (bps).
|
|
96
|
+
*/
|
|
97
|
+
int64_t Update(const Types::RateControlInput& input, int64_t atTimeUs);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Set the target bitrate from outside the rate control, for instance out of
|
|
101
|
+
* the bitrate measured by a probe.
|
|
102
|
+
*
|
|
103
|
+
* @param bitrate - New target bitrate (bps).
|
|
104
|
+
*/
|
|
105
|
+
void SetEstimate(int64_t bitrate, int64_t atTimeUs);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param startBitrate - Bitrate to start from (bps).
|
|
109
|
+
*/
|
|
110
|
+
void SetStartBitrate(int64_t startBitrate);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param minBitrate - Bitrate the target is never taken below (bps).
|
|
114
|
+
*/
|
|
115
|
+
void SetMinBitrate(int64_t minBitrate);
|
|
116
|
+
|
|
117
|
+
void SetRttUs(int64_t rttUs);
|
|
118
|
+
|
|
119
|
+
void SetInApplicationLimitedRegion(bool inAlr);
|
|
120
|
+
|
|
121
|
+
void SetNetworkStateEstimate(const std::optional<Types::NetworkStateEstimate>& estimate);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Whether the bitrate can be reduced again, which requires that it has not
|
|
125
|
+
* been changed for more than an RTT or that the throughput has fallen well
|
|
126
|
+
* below the current target. It's what keeps a single overuse from
|
|
127
|
+
* collapsing the bitrate in a few milliseconds.
|
|
128
|
+
*/
|
|
129
|
+
bool IsTimeToReduceFurther(int64_t atTimeUs, int64_t estimatedThroughput) const;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* As above, to be used when overusing before any throughput has been
|
|
133
|
+
* measured.
|
|
134
|
+
*/
|
|
135
|
+
bool IsInitialTimeToReduceFurther(int64_t atTimeUs) const;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Rate at which the bitrate is increased once it's close to the capacity of
|
|
139
|
+
* the link (bps per second).
|
|
140
|
+
*/
|
|
141
|
+
double GetNearMaxIncreaseRateBpsPerSecond() const;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* How often feedback can be sent while devoting no more than 5% of the
|
|
145
|
+
* current bitrate to it.
|
|
146
|
+
*/
|
|
147
|
+
int64_t GetFeedbackIntervalUs() const;
|
|
148
|
+
|
|
149
|
+
private:
|
|
150
|
+
void ChangeBitrate(const Types::RateControlInput& input, int64_t atTimeUs);
|
|
151
|
+
|
|
152
|
+
void ChangeState(const Types::RateControlInput& input, int64_t atTimeUs);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Apply the configured bounds to a candidate bitrate.
|
|
156
|
+
*/
|
|
157
|
+
int64_t ClampBitrate(int64_t newBitrate) const;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Increase used while the capacity of the link is unknown, which ramps up
|
|
161
|
+
* fast to discover it.
|
|
162
|
+
*/
|
|
163
|
+
int64_t MultiplicativeRateIncrease(
|
|
164
|
+
int64_t atTimeUs, std::optional<int64_t> lastTimeUs, int64_t currentBitrate) const;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Increase used once the capacity of the link has been estimated, which
|
|
168
|
+
* approaches it in small steps.
|
|
169
|
+
*/
|
|
170
|
+
int64_t AdditiveRateIncrease(int64_t atTimeUs, int64_t lastTimeUs) const;
|
|
171
|
+
|
|
172
|
+
private:
|
|
173
|
+
const AimdRateControlOptions options;
|
|
174
|
+
int64_t minConfiguredBitrate;
|
|
175
|
+
int64_t maxConfiguredBitrate;
|
|
176
|
+
int64_t currentBitrate;
|
|
177
|
+
int64_t latestEstimatedThroughput;
|
|
178
|
+
LinkCapacityEstimator linkCapacity;
|
|
179
|
+
std::optional<Types::NetworkStateEstimate> networkEstimate;
|
|
180
|
+
RateControlState rateControlState{ RateControlState::HOLD };
|
|
181
|
+
std::optional<int64_t> timeLastBitrateChangeUs;
|
|
182
|
+
std::optional<int64_t> timeFirstThroughputEstimateUs;
|
|
183
|
+
bool bitrateIsInitialized{ false };
|
|
184
|
+
bool inAlr{ false };
|
|
185
|
+
int64_t rttUs;
|
|
186
|
+
};
|
|
187
|
+
} // namespace BWE
|
|
188
|
+
} // namespace RTC
|
|
189
|
+
|
|
190
|
+
#endif
|
|
@@ -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
|