mediasoup 3.26.0 → 3.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/node/lib/DataConsumer.js +1 -1
- package/node/lib/Router.js +1 -1
- package/node/lib/Transport.js +15 -15
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts +2 -6
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts.map +1 -1
- package/node/lib/fbs/rtp-parameters/encoding-mapping.js +7 -19
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.d.ts +4 -4
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +2 -2
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +3 -3
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/recv-stats.js +3 -3
- package/node/lib/fbs/rtp-stream/send-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/send-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/send-stats.js +3 -3
- package/node/lib/fbs/transport/bwe-trace-info.d.ts +23 -23
- package/node/lib/fbs/transport/bwe-trace-info.d.ts.map +1 -1
- package/node/lib/fbs/transport/bwe-trace-info.js +15 -15
- package/node/lib/fbs/transport/options.d.ts +5 -5
- package/node/lib/fbs/transport/options.js +2 -2
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/stats.d.ts +38 -38
- package/node/lib/fbs/transport/stats.d.ts.map +1 -1
- package/node/lib/fbs/transport/stats.js +25 -25
- package/node/lib/ortc.d.ts +0 -1
- package/node/lib/ortc.d.ts.map +1 -1
- package/node/lib/ortc.js +1 -2
- package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/rtpParametersFbsUtils.js +2 -2
- package/package.json +9 -9
- package/worker/deps/libwebrtc/libwebrtc/call/rtp_transport_controller_send.cc +10 -10
- package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +6 -6
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc +7 -7
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +1 -1
- package/worker/fbs/rtpParameters.fbs +1 -2
- package/worker/fbs/rtpStream.fbs +3 -3
- package/worker/fbs/transport.fbs +23 -23
- package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
- package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
- package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
- package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
- package/worker/fuzzer/src/fuzzer.cpp +4 -0
- package/worker/include/Channel/ChannelNotification.hpp +3 -3
- package/worker/include/Channel/ChannelRequest.hpp +1 -1
- package/worker/include/Channel/ChannelSocket.hpp +11 -0
- package/worker/include/DepLibUV.hpp +16 -33
- package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
- package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
- package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
- package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
- package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
- package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
- package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +101 -0
- package/worker/include/RTC/Consts.hpp +6 -6
- package/worker/include/RTC/Consumer.hpp +14 -12
- package/worker/include/RTC/DataConsumer.hpp +3 -3
- package/worker/include/RTC/DataProducer.hpp +3 -3
- package/worker/include/RTC/DtlsTransport.hpp +5 -2
- package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
- package/worker/include/RTC/ICE/IceServer.hpp +3 -3
- package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
- package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
- package/worker/include/RTC/NackGenerator.hpp +12 -12
- package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/PipeTransport.hpp +18 -5
- package/worker/include/RTC/PlainTransport.hpp +18 -5
- package/worker/include/RTC/PortManager.hpp +4 -4
- package/worker/include/RTC/Producer.hpp +21 -12
- package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
- package/worker/include/RTC/RTCP/Bye.hpp +2 -2
- package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
- package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
- package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
- package/worker/include/RTC/RTCP/Packet.hpp +3 -3
- package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
- package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
- package/worker/include/RTC/RTCP/XR.hpp +2 -2
- package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
- package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
- package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
- package/worker/include/RTC/RTP/Packet.hpp +13 -13
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
- package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
- package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
- package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
- package/worker/include/RTC/RateCalculator.hpp +50 -44
- package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
- package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
- package/worker/include/RTC/Router.hpp +6 -0
- package/worker/include/RTC/RtcLogger.hpp +1 -1
- package/worker/include/RTC/RtpDictionaries.hpp +10 -10
- package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +2 -2
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
- package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
- package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
- package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +1 -1
- package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
- package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
- package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
- package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
- package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
- package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
- package/worker/include/RTC/SctpDictionaries.hpp +3 -3
- package/worker/include/RTC/Serializable.hpp +1 -1
- package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
- package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
- package/worker/include/RTC/TcpConnection.hpp +9 -3
- package/worker/include/RTC/TcpServer.hpp +3 -0
- package/worker/include/RTC/Transport.hpp +52 -45
- package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
- package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
- package/worker/include/RTC/TrendCalculator.hpp +5 -5
- package/worker/include/RTC/UdpSocket.hpp +11 -2
- package/worker/include/RTC/WebRtcServer.hpp +20 -5
- package/worker/include/RTC/WebRtcTransport.hpp +35 -10
- package/worker/include/Settings.hpp +4 -2
- package/worker/include/Shared.hpp +5 -20
- package/worker/include/SharedInterface.hpp +6 -28
- package/worker/include/Utils.hpp +40 -21
- package/worker/include/common.hpp +4 -0
- package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
- package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
- package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
- package/worker/include/handles/TcpServerHandle.hpp +1 -1
- package/worker/include/handles/TimerHandle.hpp +15 -9
- package/worker/include/handles/TimerHandleInterface.hpp +10 -4
- package/worker/include/handles/UdpSocketHandle.hpp +3 -3
- package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
- package/worker/meson.build +81 -36
- package/worker/meson_options.txt +1 -0
- package/worker/mocks/include/MockShared.hpp +24 -23
- package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
- package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
- package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
- package/worker/mocks/src/MockShared.cpp +51 -5
- package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
- package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
- package/worker/scripts/clang-scripts.mjs +2 -2
- package/worker/src/Channel/ChannelNotification.cpp +5 -6
- package/worker/src/Channel/ChannelSocket.cpp +20 -2
- package/worker/src/DepLibUV.cpp +4 -5
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
- package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
- package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
- package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
- package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
- package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +233 -0
- package/worker/src/RTC/Consumer.cpp +48 -35
- package/worker/src/RTC/DataConsumer.cpp +4 -4
- package/worker/src/RTC/DataProducer.cpp +3 -3
- package/worker/src/RTC/DirectTransport.cpp +2 -2
- package/worker/src/RTC/DtlsTransport.cpp +14 -11
- package/worker/src/RTC/ICE/IceServer.cpp +2 -2
- package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
- package/worker/src/RTC/NackGenerator.cpp +12 -12
- package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
- package/worker/src/RTC/PipeTransport.cpp +16 -13
- package/worker/src/RTC/PlainTransport.cpp +25 -16
- package/worker/src/RTC/Producer.cpp +50 -36
- package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
- package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
- package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
- package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
- package/worker/src/RTC/RTP/Packet.cpp +9 -10
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
- package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
- package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
- package/worker/src/RTC/RateCalculator.cpp +99 -136
- package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
- package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
- package/worker/src/RTC/Router.cpp +18 -1
- package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
- package/worker/src/RTC/SCTP/association/Association.cpp +131 -102
- package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
- package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +16 -13
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
- package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
- package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
- package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
- package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
- package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
- package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
- package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
- package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
- package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
- package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
- package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
- package/worker/src/RTC/TcpConnection.cpp +9 -3
- package/worker/src/RTC/TcpServer.cpp +7 -2
- package/worker/src/RTC/Transport.cpp +242 -302
- package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
- package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
- package/worker/src/RTC/TrendCalculator.cpp +3 -3
- package/worker/src/RTC/UdpSocket.cpp +14 -3
- package/worker/src/RTC/WebRtcServer.cpp +20 -14
- package/worker/src/RTC/WebRtcTransport.cpp +35 -30
- package/worker/src/Settings.cpp +10 -0
- package/worker/src/Shared.cpp +2 -2
- package/worker/src/Utils/Crypto.cpp +2 -2
- package/worker/src/Worker.cpp +5 -1
- package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
- package/worker/src/handles/TimerHandle.cpp +74 -25
- package/worker/src/lib.cpp +6 -0
- package/worker/tasks.py +171 -44
- package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
- package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
- package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
- package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
- package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +137 -0
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
- package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
- package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +17 -13
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
- package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
- package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
- package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
- package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
- package/worker/test/src/RTC/TestConsumer.cpp +8 -3
- package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
- package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
- package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
- package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
- package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
- package/worker/test/src/TestDepLibUV.cpp +19 -0
- package/worker/test/src/Utils/TestTime.cpp +57 -26
- package/worker/test/src/testHelpers.cpp +1 -1
- package/worker/test/src/tests.cpp +6 -0
- package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
- package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::BWE::DelayBasedBwe"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/BWE/DelayBasedBwe.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
namespace BWE
|
|
10
|
+
{
|
|
11
|
+
/* Static. */
|
|
12
|
+
|
|
13
|
+
// Time without any packet after which everything learnt about the stream is
|
|
14
|
+
// dropped.
|
|
15
|
+
static constexpr int64_t StreamTimeOutUs{ 2 * 1000 * 1000 };
|
|
16
|
+
// A send time group holds every packet sent within this time of the first
|
|
17
|
+
// packet of the group.
|
|
18
|
+
static constexpr int64_t SendTimeGroupLengthUs{ 5 * 1000 };
|
|
19
|
+
|
|
20
|
+
/* Instance methods. */
|
|
21
|
+
|
|
22
|
+
DelayBasedBwe::DelayBasedBwe() : DelayBasedBwe(DelayBasedBweOptions{})
|
|
23
|
+
{
|
|
24
|
+
MS_TRACE();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
DelayBasedBwe::DelayBasedBwe(DelayBasedBweOptions options)
|
|
28
|
+
: options(options),
|
|
29
|
+
videoDelayDetector(std::in_place),
|
|
30
|
+
audioDelayDetector(std::in_place),
|
|
31
|
+
activeDelayDetector(std::addressof(this->videoDelayDetector.value())),
|
|
32
|
+
rateControl(AimdRateControl::AimdRateControlOptions{ .sendSide = true })
|
|
33
|
+
{
|
|
34
|
+
MS_TRACE();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector(
|
|
38
|
+
const Types::TransportPacketsFeedback& feedback,
|
|
39
|
+
std::optional<int64_t> ackedBitrate,
|
|
40
|
+
std::optional<int64_t> probeBitrate,
|
|
41
|
+
const std::optional<Types::NetworkStateEstimate>& networkEstimate,
|
|
42
|
+
bool inAlr)
|
|
43
|
+
{
|
|
44
|
+
MS_TRACE();
|
|
45
|
+
|
|
46
|
+
const auto packetResults = feedback.SortedByReceiveTime();
|
|
47
|
+
|
|
48
|
+
// NOTE: An empty vector here likely means that every ack arrived too late
|
|
49
|
+
// and that the send time history had already timed out.
|
|
50
|
+
if (packetResults.empty())
|
|
51
|
+
{
|
|
52
|
+
MS_WARN_TAG(bwe, "very late feedback received");
|
|
53
|
+
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bool recoveredFromOveruse{ false };
|
|
58
|
+
auto prevDetectorState = this->activeDelayDetector->GetState();
|
|
59
|
+
|
|
60
|
+
for (const auto& packetResult : packetResults)
|
|
61
|
+
{
|
|
62
|
+
IncomingPacketFeedback(packetResult, feedback.feedbackTimeUs);
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
prevDetectorState == Types::BandwidthUsage::UNDERUSING &&
|
|
66
|
+
this->activeDelayDetector->GetState() == Types::BandwidthUsage::NORMAL)
|
|
67
|
+
{
|
|
68
|
+
recoveredFromOveruse = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
prevDetectorState = this->activeDelayDetector->GetState();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this->rateControl.SetInApplicationLimitedRegion(inAlr);
|
|
75
|
+
this->rateControl.SetNetworkStateEstimate(networkEstimate);
|
|
76
|
+
|
|
77
|
+
return MaybeUpdateEstimate(
|
|
78
|
+
ackedBitrate, probeBitrate, recoveredFromOveruse, feedback.feedbackTimeUs);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void DelayBasedBwe::IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t atTimeUs)
|
|
82
|
+
{
|
|
83
|
+
MS_TRACE();
|
|
84
|
+
|
|
85
|
+
// NOTE: Safe since only the packets that were received reach this method,
|
|
86
|
+
// as the caller iterates over `SortedByReceiveTime()`.
|
|
87
|
+
MS_ASSERT(packetResult.IsReceived(), "packet was not received");
|
|
88
|
+
|
|
89
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
90
|
+
const int64_t receiveTimeUs = packetResult.receiveTimeUs.value();
|
|
91
|
+
|
|
92
|
+
// Reset if the stream has timed out, since nothing measured before such a
|
|
93
|
+
// silence still describes this link.
|
|
94
|
+
if (!this->lastSeenPacketUs.has_value() || atTimeUs - this->lastSeenPacketUs.value() > StreamTimeOutUs)
|
|
95
|
+
{
|
|
96
|
+
this->videoInterArrivalDelta.emplace(SendTimeGroupLengthUs);
|
|
97
|
+
this->audioInterArrivalDelta.emplace(SendTimeGroupLengthUs);
|
|
98
|
+
this->videoDelayDetector.emplace();
|
|
99
|
+
this->audioDelayDetector.emplace();
|
|
100
|
+
|
|
101
|
+
this->activeDelayDetector = std::addressof(this->videoDelayDetector.value());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this->lastSeenPacketUs = atTimeUs;
|
|
105
|
+
|
|
106
|
+
// As an alternative to ignoring small packets, audio and video can be given
|
|
107
|
+
// a delay detector of their own.
|
|
108
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
109
|
+
auto* delayDetectorForPacket = std::addressof(this->videoDelayDetector.value());
|
|
110
|
+
|
|
111
|
+
if (this->options.separateAudioPackets)
|
|
112
|
+
{
|
|
113
|
+
if (packetResult.sentPacket.audio)
|
|
114
|
+
{
|
|
115
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
116
|
+
delayDetectorForPacket = std::addressof(this->audioDelayDetector.value());
|
|
117
|
+
|
|
118
|
+
this->audioPacketsSinceLastVideo++;
|
|
119
|
+
|
|
120
|
+
// Video has been silent for long enough that the audio detector is a
|
|
121
|
+
// better description of the network than the stale video one.
|
|
122
|
+
if (
|
|
123
|
+
this->audioPacketsSinceLastVideo > this->options.separateAudioPacketThreshold &&
|
|
124
|
+
(!this->lastVideoPacketRecvTimeUs.has_value() ||
|
|
125
|
+
receiveTimeUs - this->lastVideoPacketRecvTimeUs.value() >
|
|
126
|
+
this->options.separateAudioTimeThresholdUs))
|
|
127
|
+
{
|
|
128
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
129
|
+
this->activeDelayDetector = std::addressof(this->audioDelayDetector.value());
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
{
|
|
134
|
+
this->audioPacketsSinceLastVideo = 0;
|
|
135
|
+
|
|
136
|
+
this->lastVideoPacketRecvTimeUs =
|
|
137
|
+
std::max(this->lastVideoPacketRecvTimeUs.value_or(receiveTimeUs), receiveTimeUs);
|
|
138
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
139
|
+
this->activeDelayDetector = std::addressof(this->videoDelayDetector.value());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
auto& interArrivalForPacket =
|
|
144
|
+
(this->options.separateAudioPackets && packetResult.sentPacket.audio)
|
|
145
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
146
|
+
? this->audioInterArrivalDelta.value()
|
|
147
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
148
|
+
: this->videoInterArrivalDelta.value();
|
|
149
|
+
|
|
150
|
+
const auto deltas = interArrivalForPacket.ComputeDeltas(
|
|
151
|
+
packetResult.sentPacket.sendTimeUs, receiveTimeUs, atTimeUs, packetResult.sentPacket.size);
|
|
152
|
+
|
|
153
|
+
if (deltas.has_value())
|
|
154
|
+
{
|
|
155
|
+
delayDetectorForPacket->Update(
|
|
156
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
157
|
+
deltas.value().sendDeltaUs,
|
|
158
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
159
|
+
deltas.value().arrivalDeltaUs,
|
|
160
|
+
receiveTimeUs);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate(
|
|
165
|
+
std::optional<int64_t> ackedBitrate,
|
|
166
|
+
std::optional<int64_t> probeBitrate,
|
|
167
|
+
bool recoveredFromOveruse,
|
|
168
|
+
int64_t atTimeUs)
|
|
169
|
+
{
|
|
170
|
+
MS_TRACE();
|
|
171
|
+
|
|
172
|
+
Result result;
|
|
173
|
+
|
|
174
|
+
if (this->activeDelayDetector->GetState() == Types::BandwidthUsage::OVERUSING)
|
|
175
|
+
{
|
|
176
|
+
if (
|
|
177
|
+
ackedBitrate.has_value() &&
|
|
178
|
+
this->rateControl.IsTimeToReduceFurther(atTimeUs, ackedBitrate.value()))
|
|
179
|
+
{
|
|
180
|
+
result.updated = UpdateEstimate(atTimeUs, ackedBitrate, result.targetBitrate);
|
|
181
|
+
}
|
|
182
|
+
else if (
|
|
183
|
+
!ackedBitrate.has_value() && this->rateControl.IsValidEstimate() &&
|
|
184
|
+
this->rateControl.IsInitialTimeToReduceFurther(atTimeUs))
|
|
185
|
+
{
|
|
186
|
+
// Overusing before any throughput has been measured, so halve the
|
|
187
|
+
// bitrate instead of aiming at a measurement we don't have.
|
|
188
|
+
this->rateControl.SetEstimate(this->rateControl.GetLatestEstimate() / 2, atTimeUs);
|
|
189
|
+
|
|
190
|
+
result.updated = true;
|
|
191
|
+
result.probe = false;
|
|
192
|
+
result.targetBitrate = this->rateControl.GetLatestEstimate();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
{
|
|
197
|
+
if (probeBitrate.has_value())
|
|
198
|
+
{
|
|
199
|
+
result.probe = true;
|
|
200
|
+
result.updated = true;
|
|
201
|
+
|
|
202
|
+
this->rateControl.SetEstimate(probeBitrate.value(), atTimeUs);
|
|
203
|
+
|
|
204
|
+
result.targetBitrate = this->rateControl.GetLatestEstimate();
|
|
205
|
+
}
|
|
206
|
+
else
|
|
207
|
+
{
|
|
208
|
+
result.updated = UpdateEstimate(atTimeUs, ackedBitrate, result.targetBitrate);
|
|
209
|
+
result.recoveredFromOveruse = recoveredFromOveruse;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const auto detectorState = this->activeDelayDetector->GetState();
|
|
214
|
+
|
|
215
|
+
if ((result.updated && this->prevBitrate != result.targetBitrate) || detectorState != this->prevState)
|
|
216
|
+
{
|
|
217
|
+
this->prevBitrate = result.updated ? result.targetBitrate : this->prevBitrate;
|
|
218
|
+
this->prevState = detectorState;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
result.delayDetectorState = detectorState;
|
|
222
|
+
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
bool DelayBasedBwe::UpdateEstimate(
|
|
227
|
+
int64_t atTimeUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate)
|
|
228
|
+
{
|
|
229
|
+
MS_TRACE();
|
|
230
|
+
|
|
231
|
+
const Types::RateControlInput input{ .bandwidthUsage = this->activeDelayDetector->GetState(),
|
|
232
|
+
.estimatedThroughput = ackedBitrate };
|
|
233
|
+
|
|
234
|
+
targetBitrate = this->rateControl.Update(input, atTimeUs);
|
|
235
|
+
|
|
236
|
+
return this->rateControl.IsValidEstimate();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
std::optional<int64_t> DelayBasedBwe::GetLatestEstimate() const
|
|
240
|
+
{
|
|
241
|
+
MS_TRACE();
|
|
242
|
+
|
|
243
|
+
if (!this->rateControl.IsValidEstimate())
|
|
244
|
+
{
|
|
245
|
+
return std::nullopt;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return this->rateControl.GetLatestEstimate();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void DelayBasedBwe::OnRttUpdate(int64_t avgRttUs)
|
|
252
|
+
{
|
|
253
|
+
MS_TRACE();
|
|
254
|
+
|
|
255
|
+
this->rateControl.SetRttUs(avgRttUs);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void DelayBasedBwe::SetStartBitrate(int64_t startBitrate)
|
|
259
|
+
{
|
|
260
|
+
MS_TRACE();
|
|
261
|
+
|
|
262
|
+
MS_DEBUG_TAG(bwe, "setting start bitrate [bitrate:%" PRIi64 "]", startBitrate);
|
|
263
|
+
|
|
264
|
+
this->rateControl.SetStartBitrate(startBitrate);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
void DelayBasedBwe::SetMinBitrate(int64_t minBitrate)
|
|
268
|
+
{
|
|
269
|
+
MS_TRACE();
|
|
270
|
+
|
|
271
|
+
this->rateControl.SetMinBitrate(minBitrate);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
} // namespace BWE
|
|
275
|
+
} // namespace RTC
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::BWE::FeedbackAdapter"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/BWE/FeedbackAdapter.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
namespace BWE
|
|
10
|
+
{
|
|
11
|
+
/* Instance methods. */
|
|
12
|
+
|
|
13
|
+
FeedbackAdapter::FeedbackAdapter(SendPacketHistory* sendPacketHistory)
|
|
14
|
+
: sendPacketHistory(sendPacketHistory)
|
|
15
|
+
{
|
|
16
|
+
MS_TRACE();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
std::optional<Types::TransportPacketsFeedback> FeedbackAdapter::ProcessTransportFeedback(
|
|
20
|
+
const RTCP::FeedbackRtpTransportPacket* feedback, int64_t receivedAtUs)
|
|
21
|
+
{
|
|
22
|
+
MS_TRACE();
|
|
23
|
+
|
|
24
|
+
if (feedback->GetPacketStatusCount() == 0)
|
|
25
|
+
{
|
|
26
|
+
MS_DEBUG_TAG(bwe, "feedback reports on no packet at all");
|
|
27
|
+
|
|
28
|
+
return std::nullopt;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const auto lastSequenceNumber = this->sendPacketHistory->GetLastSequenceNumber();
|
|
32
|
+
|
|
33
|
+
if (!lastSequenceNumber.has_value())
|
|
34
|
+
{
|
|
35
|
+
MS_DEBUG_TAG(bwe, "feedback received before any packet was sent");
|
|
36
|
+
|
|
37
|
+
return std::nullopt;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const int64_t lastSentSequenceNumber = lastSequenceNumber.value();
|
|
41
|
+
|
|
42
|
+
const int64_t baseTimeUs = feedback->GetReferenceTimestampUs();
|
|
43
|
+
|
|
44
|
+
if (!this->lastFeedbackBaseTimeUs.has_value())
|
|
45
|
+
{
|
|
46
|
+
this->currentOffsetUs = receivedAtUs;
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
{
|
|
50
|
+
const int64_t baseDeltaUs = feedback->GetBaseDeltaUs(this->lastFeedbackBaseTimeUs.value());
|
|
51
|
+
|
|
52
|
+
if (baseDeltaUs < -this->currentOffsetUs)
|
|
53
|
+
{
|
|
54
|
+
MS_DEBUG_TAG(
|
|
55
|
+
bwe,
|
|
56
|
+
"base time of the feedback moved too far back, anchoring it again"
|
|
57
|
+
" [baseDelta:%" PRIi64 " us]",
|
|
58
|
+
baseDeltaUs);
|
|
59
|
+
|
|
60
|
+
this->currentOffsetUs = receivedAtUs;
|
|
61
|
+
}
|
|
62
|
+
else
|
|
63
|
+
{
|
|
64
|
+
this->currentOffsetUs += baseDeltaUs;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this->lastFeedbackBaseTimeUs = baseTimeUs;
|
|
69
|
+
|
|
70
|
+
const auto packetStatuses = feedback->GetPacketStatuses();
|
|
71
|
+
|
|
72
|
+
Types::TransportPacketsFeedback transportPacketsFeedback;
|
|
73
|
+
|
|
74
|
+
transportPacketsFeedback.feedbackTimeUs = receivedAtUs;
|
|
75
|
+
transportPacketsFeedback.packetFeedbacks.reserve(packetStatuses.size());
|
|
76
|
+
|
|
77
|
+
size_t failedLookups{ 0 };
|
|
78
|
+
|
|
79
|
+
// Each packet is resolved against the one reported before it, since the
|
|
80
|
+
// packets being sent may be far ahead of the ones the feedbacks report on.
|
|
81
|
+
// The latest packet sent seeds it, and bounds it as well, since no report
|
|
82
|
+
// can stand for a packet that was never sent.
|
|
83
|
+
int64_t sequenceNumber = std::min(
|
|
84
|
+
this->lastUnwrappedSequenceNumber.value_or(lastSentSequenceNumber), lastSentSequenceNumber);
|
|
85
|
+
|
|
86
|
+
for (const auto& packetStatus : packetStatuses)
|
|
87
|
+
{
|
|
88
|
+
sequenceNumber = UnwrapSequenceNumber(packetStatus.sequenceNumber, sequenceNumber);
|
|
89
|
+
|
|
90
|
+
const auto sentPacket =
|
|
91
|
+
this->sendPacketHistory->RetrievePacket(sequenceNumber, packetStatus.received);
|
|
92
|
+
|
|
93
|
+
if (!sentPacket.has_value())
|
|
94
|
+
{
|
|
95
|
+
++failedLookups;
|
|
96
|
+
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Types::PacketResult packetResult;
|
|
101
|
+
|
|
102
|
+
packetResult.sentPacket = sentPacket.value();
|
|
103
|
+
|
|
104
|
+
if (packetStatus.received)
|
|
105
|
+
{
|
|
106
|
+
packetResult.receiveTimeUs =
|
|
107
|
+
this->currentOffsetUs + (packetStatus.receivedAtUs - baseTimeUs);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
transportPacketsFeedback.packetFeedbacks.push_back(packetResult);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this->lastUnwrappedSequenceNumber = sequenceNumber;
|
|
114
|
+
|
|
115
|
+
if (failedLookups > 0)
|
|
116
|
+
{
|
|
117
|
+
MS_DEBUG_TAG(
|
|
118
|
+
bwe,
|
|
119
|
+
"could not resolve %zu of the %zu reported packets, packets reordered or history too small",
|
|
120
|
+
failedLookups,
|
|
121
|
+
packetStatuses.size());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (transportPacketsFeedback.packetFeedbacks.empty())
|
|
125
|
+
{
|
|
126
|
+
return std::nullopt;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
transportPacketsFeedback.dataInFlight = this->sendPacketHistory->GetOutstandingBytes();
|
|
130
|
+
|
|
131
|
+
return transportPacketsFeedback;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
int64_t FeedbackAdapter::UnwrapSequenceNumber(
|
|
135
|
+
uint16_t wideSequenceNumber, int64_t previousSequenceNumber)
|
|
136
|
+
{
|
|
137
|
+
MS_TRACE();
|
|
138
|
+
|
|
139
|
+
// The wire carries the sequence number of the history truncated to 16 bits,
|
|
140
|
+
// so the closest value to the previous one ending in those very same bits
|
|
141
|
+
// is the one it stands for.
|
|
142
|
+
const auto deltaSequenceNumber = static_cast<int16_t>(
|
|
143
|
+
static_cast<uint16_t>(wideSequenceNumber - static_cast<uint16_t>(previousSequenceNumber)));
|
|
144
|
+
|
|
145
|
+
return previousSequenceNumber + deltaSequenceNumber;
|
|
146
|
+
}
|
|
147
|
+
} // namespace BWE
|
|
148
|
+
} // namespace RTC
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::BWE::InterArrivalDelta"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/BWE/InterArrivalDelta.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
namespace BWE
|
|
10
|
+
{
|
|
11
|
+
/* Static. */
|
|
12
|
+
|
|
13
|
+
// Maximum arrival time delta for a packet to be absorbed into the ongoing
|
|
14
|
+
// burst.
|
|
15
|
+
static constexpr int64_t BurstDeltaThresholdUs{ 5000 };
|
|
16
|
+
// Maximum duration of a burst.
|
|
17
|
+
static constexpr int64_t MaxBurstDurationUs{ 100000 };
|
|
18
|
+
// Number of consecutive reordered groups after which the state is reset.
|
|
19
|
+
static constexpr size_t ReorderedResetThreshold{ 3 };
|
|
20
|
+
// Difference between the arrival time delta and our own time delta after
|
|
21
|
+
// which the state is reset, assuming that the remote clock has jumped.
|
|
22
|
+
static constexpr int64_t ArrivalTimeOffsetThresholdUs{ 3000000 };
|
|
23
|
+
|
|
24
|
+
/* Instance methods. */
|
|
25
|
+
|
|
26
|
+
InterArrivalDelta::InterArrivalDelta(int64_t sendTimeGroupLengthUs)
|
|
27
|
+
: sendTimeGroupLengthUs(sendTimeGroupLengthUs)
|
|
28
|
+
{
|
|
29
|
+
MS_TRACE();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
std::optional<InterArrivalDelta::Deltas> InterArrivalDelta::ComputeDeltas(
|
|
33
|
+
int64_t sendTimeUs, int64_t arrivalTimeUs, int64_t feedbackAtUs, size_t packetSize)
|
|
34
|
+
{
|
|
35
|
+
MS_TRACE();
|
|
36
|
+
|
|
37
|
+
std::optional<Deltas> deltas;
|
|
38
|
+
|
|
39
|
+
if (this->currentGroup.IsFirstPacket())
|
|
40
|
+
{
|
|
41
|
+
// Not enough data to compute deltas yet, so just store the packet until
|
|
42
|
+
// there are two groups to compare.
|
|
43
|
+
this->currentGroup.firstSendTimeUs = sendTimeUs;
|
|
44
|
+
this->currentGroup.sendTimeUs = sendTimeUs;
|
|
45
|
+
this->currentGroup.firstArrivalTimeUs = arrivalTimeUs;
|
|
46
|
+
}
|
|
47
|
+
else if (this->currentGroup.firstSendTimeUs > sendTimeUs)
|
|
48
|
+
{
|
|
49
|
+
// Reordered packet.
|
|
50
|
+
return std::nullopt;
|
|
51
|
+
}
|
|
52
|
+
else if (IsNewSendTimeGroup(arrivalTimeUs, sendTimeUs))
|
|
53
|
+
{
|
|
54
|
+
// This is the first packet of a later send burst, so the sample of the
|
|
55
|
+
// ongoing group is ready.
|
|
56
|
+
if (!this->prevGroup.IsFirstPacket())
|
|
57
|
+
{
|
|
58
|
+
const int64_t sendDeltaUs = this->currentGroup.sendTimeUs - this->prevGroup.sendTimeUs;
|
|
59
|
+
const int64_t arrivalDeltaUs =
|
|
60
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
61
|
+
this->currentGroup.completeTimeUs.value() -
|
|
62
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
63
|
+
this->prevGroup.completeTimeUs.value();
|
|
64
|
+
const int64_t ownDeltaUs =
|
|
65
|
+
this->currentGroup.lastFeedbackAtUs - this->prevGroup.lastFeedbackAtUs;
|
|
66
|
+
|
|
67
|
+
if (arrivalDeltaUs - ownDeltaUs >= ArrivalTimeOffsetThresholdUs)
|
|
68
|
+
{
|
|
69
|
+
MS_WARN_TAG(
|
|
70
|
+
bwe,
|
|
71
|
+
"arrival time clock offset has changed, resetting [diff:%" PRIi64 " us]",
|
|
72
|
+
arrivalDeltaUs - ownDeltaUs);
|
|
73
|
+
|
|
74
|
+
Reset();
|
|
75
|
+
|
|
76
|
+
return std::nullopt;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (arrivalDeltaUs < 0)
|
|
80
|
+
{
|
|
81
|
+
// The groups have been reordered after their arrival time was taken.
|
|
82
|
+
++this->numConsecutiveReorderedGroups;
|
|
83
|
+
|
|
84
|
+
if (this->numConsecutiveReorderedGroups >= ReorderedResetThreshold)
|
|
85
|
+
{
|
|
86
|
+
MS_WARN_TAG(
|
|
87
|
+
bwe,
|
|
88
|
+
"packets between send bursts arrived out of order, resetting [arrivalDelta:%" PRIi64
|
|
89
|
+
" us, sendDelta:%" PRIi64 " us]",
|
|
90
|
+
arrivalDeltaUs,
|
|
91
|
+
sendDeltaUs);
|
|
92
|
+
|
|
93
|
+
Reset();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return std::nullopt;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this->numConsecutiveReorderedGroups = 0;
|
|
100
|
+
|
|
101
|
+
deltas = Deltas{ .sendDeltaUs = sendDeltaUs,
|
|
102
|
+
.arrivalDeltaUs = arrivalDeltaUs,
|
|
103
|
+
.sizeDelta = static_cast<int64_t>(this->currentGroup.size) -
|
|
104
|
+
static_cast<int64_t>(this->prevGroup.size) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this->prevGroup = this->currentGroup;
|
|
108
|
+
|
|
109
|
+
// The new packet starts the current group.
|
|
110
|
+
this->currentGroup.firstSendTimeUs = sendTimeUs;
|
|
111
|
+
this->currentGroup.sendTimeUs = sendTimeUs;
|
|
112
|
+
this->currentGroup.firstArrivalTimeUs = arrivalTimeUs;
|
|
113
|
+
this->currentGroup.size = 0;
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
{
|
|
117
|
+
this->currentGroup.sendTimeUs = std::max(this->currentGroup.sendTimeUs, sendTimeUs);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Accumulate the group size.
|
|
121
|
+
this->currentGroup.size += packetSize;
|
|
122
|
+
this->currentGroup.completeTimeUs = arrivalTimeUs;
|
|
123
|
+
this->currentGroup.lastFeedbackAtUs = feedbackAtUs;
|
|
124
|
+
|
|
125
|
+
return deltas;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
bool InterArrivalDelta::IsNewSendTimeGroup(int64_t arrivalTimeUs, int64_t sendTimeUs) const
|
|
129
|
+
{
|
|
130
|
+
MS_TRACE();
|
|
131
|
+
|
|
132
|
+
if (this->currentGroup.IsFirstPacket())
|
|
133
|
+
{
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
else if (BelongsToBurst(arrivalTimeUs, sendTimeUs))
|
|
137
|
+
{
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
else
|
|
141
|
+
{
|
|
142
|
+
return sendTimeUs - this->currentGroup.firstSendTimeUs > this->sendTimeGroupLengthUs;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
bool InterArrivalDelta::BelongsToBurst(int64_t arrivalTimeUs, int64_t sendTimeUs) const
|
|
147
|
+
{
|
|
148
|
+
MS_TRACE();
|
|
149
|
+
|
|
150
|
+
MS_ASSERT(!this->currentGroup.IsFirstPacket(), "current group is empty");
|
|
151
|
+
|
|
152
|
+
const int64_t arrivalDeltaUs =
|
|
153
|
+
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
|
154
|
+
arrivalTimeUs - this->currentGroup.completeTimeUs.value();
|
|
155
|
+
const int64_t sendDeltaUs = sendTimeUs - this->currentGroup.sendTimeUs;
|
|
156
|
+
|
|
157
|
+
// Packets sent at the very same time always belong to the same burst.
|
|
158
|
+
if (sendDeltaUs == 0)
|
|
159
|
+
{
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const int64_t propagationDeltaUs = arrivalDeltaUs - sendDeltaUs;
|
|
164
|
+
const int64_t burstDurationUs = arrivalTimeUs - this->currentGroup.firstArrivalTimeUs;
|
|
165
|
+
|
|
166
|
+
// The packet arrived earlier than its send time gap would suggest, meaning
|
|
167
|
+
// that it was serialized by the network together with the ongoing group.
|
|
168
|
+
return propagationDeltaUs < 0 && arrivalDeltaUs <= BurstDeltaThresholdUs &&
|
|
169
|
+
burstDurationUs < MaxBurstDurationUs;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void InterArrivalDelta::Reset()
|
|
173
|
+
{
|
|
174
|
+
MS_TRACE();
|
|
175
|
+
|
|
176
|
+
this->numConsecutiveReorderedGroups = 0;
|
|
177
|
+
this->currentGroup = SendTimeGroup();
|
|
178
|
+
this->prevGroup = SendTimeGroup();
|
|
179
|
+
}
|
|
180
|
+
} // namespace BWE
|
|
181
|
+
} // namespace RTC
|