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
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
namespace
|
|
10
10
|
{
|
|
11
11
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
12
|
-
thread_local mocks::MockShared shared(/*
|
|
13
|
-
[]()
|
|
12
|
+
thread_local mocks::MockShared shared(/*getTimeUs*/
|
|
13
|
+
[]() -> int64_t
|
|
14
14
|
{
|
|
15
|
-
return 1000;
|
|
15
|
+
return 1000 * 1000;
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
// DtlsTransport instance. It's reset every time DTLS handshake fails or DTLS
|
|
@@ -70,7 +70,7 @@ void FuzzerRtcDtlsTransport::Fuzz(const uint8_t* data, size_t len)
|
|
|
70
70
|
dtlsTransportSingleton->SetRemoteFingerprint(dtlsRemoteFingerprint);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
dtlsTransportSingleton->ProcessDtlsData(data, len);
|
|
73
|
+
dtlsTransportSingleton->ProcessDtlsData(data, len, shared.GetTimeUs());
|
|
74
74
|
|
|
75
75
|
// DTLS may have failed or closed after ProcessDtlsData(). If so, unset it.
|
|
76
76
|
if (
|
|
@@ -125,7 +125,10 @@ void FuzzerRtcDtlsTransport::DtlsTransportListener::OnDtlsTransportSendData(
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
void FuzzerRtcDtlsTransport::DtlsTransportListener::OnDtlsTransportApplicationDataReceived(
|
|
128
|
-
const RTC::DtlsTransport* /*dtlsTransport*/,
|
|
128
|
+
const RTC::DtlsTransport* /*dtlsTransport*/,
|
|
129
|
+
const uint8_t* /*data*/,
|
|
130
|
+
size_t /*len*/,
|
|
131
|
+
int64_t /*receivedAtUs*/)
|
|
129
132
|
{
|
|
130
133
|
MS_DEBUG_DEV("DtlsTransport singleton received application data");
|
|
131
134
|
}
|
|
@@ -8,7 +8,7 @@ namespace
|
|
|
8
8
|
{
|
|
9
9
|
// NOLINTBEGIN(readability-identifier-naming)
|
|
10
10
|
RTC::RateCalculator rateCalculator;
|
|
11
|
-
|
|
11
|
+
int64_t nowMs;
|
|
12
12
|
// NOLINTEND(readability-identifier-naming)
|
|
13
13
|
|
|
14
14
|
int init()
|
|
@@ -34,9 +34,9 @@ void FuzzerRtcRateCalculator::Fuzz(const uint8_t* data, size_t len)
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
auto size = Utils::Crypto::GetRandomUInt<size_t>(
|
|
37
|
+
auto size = Utils::Crypto::GetRandomUInt<size_t>(0, static_cast<uint32_t>(RTC::Consts::MtuSize));
|
|
38
38
|
|
|
39
|
-
nowMs += Utils::Crypto::GetRandomUInt<uint64_t>(
|
|
39
|
+
nowMs += static_cast<int64_t>(Utils::Crypto::GetRandomUInt<uint64_t>(0, 1000));
|
|
40
40
|
|
|
41
41
|
rateCalculator.Update(size, nowMs);
|
|
42
42
|
|
|
@@ -6,20 +6,20 @@
|
|
|
6
6
|
void FuzzerRtcTrendCalculator::Fuzz(const uint8_t* data, size_t len)
|
|
7
7
|
{
|
|
8
8
|
RTC::TrendCalculator trend;
|
|
9
|
-
|
|
10
|
-
size_t offset{
|
|
9
|
+
int64_t nowMs = DepLibUV::GetTimeMs();
|
|
10
|
+
size_t offset{ 0 };
|
|
11
11
|
|
|
12
|
-
while (len >=
|
|
12
|
+
while (len >= 4)
|
|
13
13
|
{
|
|
14
14
|
const auto value = Utils::Byte::Get4Bytes(data, offset);
|
|
15
15
|
|
|
16
16
|
trend.Update(value, nowMs);
|
|
17
17
|
trend.GetValue();
|
|
18
|
-
trend.Update(value, nowMs -
|
|
18
|
+
trend.Update(value, nowMs - 1000);
|
|
19
19
|
trend.GetValue();
|
|
20
20
|
|
|
21
|
-
len -=
|
|
21
|
+
len -= 4;
|
|
22
22
|
offset += 4;
|
|
23
|
-
nowMs +=
|
|
23
|
+
nowMs += 500;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -10,11 +10,11 @@ void FuzzerRtcRtcpFeedbackRtpTransport::Fuzz(RTC::RTCP::FeedbackRtpTransportPack
|
|
|
10
10
|
packet->GetBaseSequenceNumber();
|
|
11
11
|
packet->GetPacketStatusCount();
|
|
12
12
|
packet->GetReferenceTime();
|
|
13
|
-
packet->
|
|
13
|
+
packet->GetReferenceTimestampUs();
|
|
14
14
|
packet->GetFeedbackPacketCount();
|
|
15
15
|
packet->GetLatestSequenceNumber();
|
|
16
|
-
packet->
|
|
17
|
-
packet->
|
|
16
|
+
packet->GetLatestTimestampUs();
|
|
17
|
+
packet->GetPacketStatuses();
|
|
18
18
|
packet->GetPacketFractionLost();
|
|
19
19
|
packet->Serialize(RTC::RTCP::SerializationBuffer);
|
|
20
20
|
}
|
|
@@ -91,7 +91,7 @@ void FuzzerRtcRtcPacket::Fuzz(const uint8_t* data, size_t len)
|
|
|
91
91
|
packet->HasExtension(3);
|
|
92
92
|
packet->GetExtensionValue(3, extenLen);
|
|
93
93
|
packet->ReadAbsSendTime(absSendTime);
|
|
94
|
-
packet->UpdateAbsSendTime(
|
|
94
|
+
packet->UpdateAbsSendTime(12345678);
|
|
95
95
|
|
|
96
96
|
packet->HasExtension(4);
|
|
97
97
|
packet->GetExtensionValue(4, extenLen);
|
|
@@ -150,7 +150,7 @@ void FuzzerRtcRtcPacket::Fuzz(const uint8_t* data, size_t len)
|
|
|
150
150
|
packet->SetExtensions(RTC::RTP::Packet::ExtensionsType::Auto, extensions);
|
|
151
151
|
|
|
152
152
|
uint8_t value3[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
|
|
153
|
-
|
|
153
|
+
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18 };
|
|
154
154
|
|
|
155
155
|
extensions.emplace_back(
|
|
156
156
|
RTC::RtpHeaderExtensionUri::Type::MID, // type
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
void FuzzerRtcRtpRetransmissionBuffer::Fuzz(const uint8_t* data, size_t len)
|
|
8
8
|
{
|
|
9
|
-
const uint16_t maxItems{
|
|
10
|
-
const
|
|
9
|
+
const uint16_t maxItems{ 2500 };
|
|
10
|
+
const int64_t maxRetransmissionDelayMs{ 2000 };
|
|
11
11
|
const uint32_t clockRate{ 90000 };
|
|
12
12
|
|
|
13
13
|
// Trick to initialize our stuff just once (use static).
|
|
@@ -25,9 +25,9 @@ void FuzzerRtcRtpRetransmissionBuffer::Fuzz(const uint8_t* data, size_t len)
|
|
|
25
25
|
|
|
26
26
|
// Create base RtpPacket instance.
|
|
27
27
|
auto* packet = RTC::RTP::Packet::Parse(buffer, 12);
|
|
28
|
-
size_t offset{
|
|
28
|
+
size_t offset{ 0 };
|
|
29
29
|
|
|
30
|
-
while (len >=
|
|
30
|
+
while (len >= 4)
|
|
31
31
|
{
|
|
32
32
|
const RTC::RTP::SharedPacket sharedPacket;
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ void FuzzerRtcRtpRetransmissionBuffer::Fuzz(const uint8_t* data, size_t len)
|
|
|
37
37
|
|
|
38
38
|
retransmissionBuffer.Insert(packet, sharedPacket);
|
|
39
39
|
|
|
40
|
-
len -=
|
|
40
|
+
len -= 4;
|
|
41
41
|
offset += 4;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
namespace
|
|
7
7
|
{
|
|
8
8
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
9
|
-
thread_local mocks::MockShared shared(/*
|
|
10
|
-
[]()
|
|
9
|
+
thread_local mocks::MockShared shared(/*getTimeUs*/
|
|
10
|
+
[]() -> int64_t
|
|
11
11
|
{
|
|
12
|
-
return 1000;
|
|
12
|
+
return 1000 * 1000;
|
|
13
13
|
});
|
|
14
14
|
} // namespace
|
|
15
15
|
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
#include "common.hpp"
|
|
4
4
|
#include "DepLibSRTP.hpp"
|
|
5
5
|
#include "DepLibUV.hpp"
|
|
6
|
+
#ifndef MS_USE_BUILTIN_BWE
|
|
6
7
|
#include "DepLibWebRTC.hpp"
|
|
8
|
+
#endif
|
|
7
9
|
#include "DepOpenSSL.hpp"
|
|
8
10
|
#include "FuzzerUtils.hpp"
|
|
9
11
|
#include "RTC/DtlsTransport.hpp"
|
|
@@ -144,7 +146,9 @@ namespace
|
|
|
144
146
|
DepLibUV::ClassInit();
|
|
145
147
|
DepOpenSSL::ClassInit();
|
|
146
148
|
DepLibSRTP::ClassInit();
|
|
149
|
+
#ifndef MS_USE_BUILTIN_BWE
|
|
147
150
|
DepLibWebRTC::ClassInit();
|
|
151
|
+
#endif
|
|
148
152
|
Utils::Crypto::ClassInit();
|
|
149
153
|
RTC::DtlsTransport::ClassInit();
|
|
150
154
|
|
|
@@ -12,16 +12,16 @@ namespace Channel
|
|
|
12
12
|
using Event = FBS::Notification::Event;
|
|
13
13
|
|
|
14
14
|
public:
|
|
15
|
-
|
|
15
|
+
ChannelNotification(const FBS::Notification::Notification* notification, int64_t receivedAtUs);
|
|
16
16
|
~ChannelNotification() = default;
|
|
17
17
|
|
|
18
18
|
public:
|
|
19
19
|
// Passed by argument.
|
|
20
|
-
|
|
20
|
+
const FBS::Notification::Notification* data{ nullptr };
|
|
21
|
+
int64_t receivedAtUs{ 0 };
|
|
21
22
|
// Others.
|
|
22
23
|
const char* eventCStr;
|
|
23
24
|
std::string handlerId;
|
|
24
|
-
const FBS::Notification::Notification* data{ nullptr };
|
|
25
25
|
};
|
|
26
26
|
} // namespace Channel
|
|
27
27
|
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
#include "Channel/ChannelRequest.hpp"
|
|
7
7
|
#include "handles/UnixStreamSocketHandle.hpp"
|
|
8
8
|
|
|
9
|
+
// Avoid cyclic #include problem by declaring the class instead of including the
|
|
10
|
+
// corresponding header file.
|
|
11
|
+
class SharedInterface;
|
|
12
|
+
|
|
9
13
|
namespace Channel
|
|
10
14
|
{
|
|
11
15
|
class ConsumerSocket : public UnixStreamSocketHandle
|
|
@@ -96,6 +100,12 @@ namespace Channel
|
|
|
96
100
|
public:
|
|
97
101
|
void Close();
|
|
98
102
|
void SetListener(Listener* listener);
|
|
103
|
+
/**
|
|
104
|
+
* @remarks
|
|
105
|
+
* - Must be called before the libuv loop runs, since notifications take
|
|
106
|
+
* their arrival time from it.
|
|
107
|
+
*/
|
|
108
|
+
void SetShared(SharedInterface* shared);
|
|
99
109
|
void Send(const uint8_t* data, uint32_t dataLen);
|
|
100
110
|
void SendLog(const char* data, uint32_t dataLen);
|
|
101
111
|
bool CallbackRead();
|
|
@@ -111,6 +121,7 @@ namespace Channel
|
|
|
111
121
|
private:
|
|
112
122
|
// Passed by argument.
|
|
113
123
|
Listener* listener{ nullptr };
|
|
124
|
+
SharedInterface* shared{ nullptr };
|
|
114
125
|
// Others.
|
|
115
126
|
bool closed{ false };
|
|
116
127
|
ConsumerSocket* consumerSocket{ nullptr };
|
|
@@ -20,57 +20,40 @@ public:
|
|
|
20
20
|
return DepLibUV::loop;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
static uint64_t GetTimeMs()
|
|
24
|
-
{
|
|
25
|
-
return static_cast<uint64_t>(uv_hrtime() / 1000000u);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* - It is taken just once, in ClassInit(), so that the NTP timestamps we generate
|
|
33
|
-
* never step when the system clock is adjusted. They just drift away from the real
|
|
34
|
-
* wall clock as much as our monotonic clock does.
|
|
24
|
+
* Current value of the monotonic clock (ms).
|
|
35
25
|
*/
|
|
36
|
-
static
|
|
26
|
+
static int64_t GetTimeMs()
|
|
37
27
|
{
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static uint64_t GetTimeUs()
|
|
42
|
-
{
|
|
43
|
-
return static_cast<uint64_t>(uv_hrtime() / 1000u);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static uint64_t GetTimeNs()
|
|
47
|
-
{
|
|
48
|
-
return uv_hrtime();
|
|
28
|
+
return static_cast<int64_t>(uv_hrtime() / 1000000);
|
|
49
29
|
}
|
|
50
30
|
|
|
51
31
|
/**
|
|
52
|
-
*
|
|
53
|
-
* representation.
|
|
32
|
+
* Current value of the monotonic clock (us).
|
|
54
33
|
*/
|
|
55
|
-
static int64_t
|
|
34
|
+
static int64_t GetTimeUs()
|
|
56
35
|
{
|
|
57
|
-
return static_cast<int64_t>(
|
|
36
|
+
return static_cast<int64_t>(uv_hrtime() / 1000);
|
|
58
37
|
}
|
|
59
38
|
|
|
60
39
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
40
|
+
* Offset between our own monotonic clock and the NTP epoch (us).
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* - It is taken just once, in ClassInit(), so that the NTP timestamps we generate
|
|
44
|
+
* never step when the system clock is adjusted. They just drift away from the real
|
|
45
|
+
* wall clock as much as our monotonic clock does.
|
|
63
46
|
*/
|
|
64
|
-
static int64_t
|
|
47
|
+
static int64_t GetNtpOffsetUs()
|
|
65
48
|
{
|
|
66
|
-
return
|
|
49
|
+
return DepLibUV::ntpOffsetUs;
|
|
67
50
|
}
|
|
68
51
|
|
|
69
52
|
private:
|
|
70
53
|
static thread_local uv_loop_t* loop;
|
|
71
|
-
// Distance from our own monotonic clock to the NTP epoch (
|
|
54
|
+
// Distance from our own monotonic clock to the NTP epoch (us), taken at
|
|
72
55
|
// ClassInit().
|
|
73
|
-
static thread_local
|
|
56
|
+
static thread_local int64_t ntpOffsetUs;
|
|
74
57
|
};
|
|
75
58
|
|
|
76
59
|
#endif
|
|
@@ -25,8 +25,8 @@ namespace RTC
|
|
|
25
25
|
public:
|
|
26
26
|
void EvalActivityScores();
|
|
27
27
|
double GetActivityScore(uint8_t interval) const;
|
|
28
|
-
void LevelChanged(uint32_t level,
|
|
29
|
-
void LevelTimedOut(
|
|
28
|
+
void LevelChanged(uint32_t level, int64_t nowMs);
|
|
29
|
+
void LevelTimedOut(int64_t nowMs);
|
|
30
30
|
|
|
31
31
|
private:
|
|
32
32
|
bool ComputeImmediates();
|
|
@@ -42,17 +42,17 @@ namespace RTC
|
|
|
42
42
|
double immediateActivityScore{ 0 };
|
|
43
43
|
double mediumActivityScore{ 0 };
|
|
44
44
|
double longActivityScore{ 0 };
|
|
45
|
-
|
|
45
|
+
int64_t lastLevelChangeAtMs{ 0 };
|
|
46
46
|
|
|
47
47
|
private:
|
|
48
|
-
uint8_t minLevel{
|
|
49
|
-
uint8_t nextMinLevel{
|
|
50
|
-
uint32_t nextMinLevelWindowLen{
|
|
48
|
+
uint8_t minLevel{ 0 };
|
|
49
|
+
uint8_t nextMinLevel{ 0 };
|
|
50
|
+
uint32_t nextMinLevelWindowLen{ 0 };
|
|
51
51
|
std::vector<uint8_t> immediates;
|
|
52
52
|
std::vector<uint8_t> mediums;
|
|
53
53
|
std::vector<uint8_t> longs;
|
|
54
54
|
std::vector<uint8_t> levels;
|
|
55
|
-
size_t nextLevelIndex{
|
|
55
|
+
size_t nextLevelIndex{ 0 };
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
class ProducerSpeaker
|
|
@@ -67,7 +67,7 @@ namespace RTC
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
private:
|
|
70
|
-
static const uint8_t RelativeSpeachActivitiesLen{
|
|
70
|
+
static const uint8_t RelativeSpeachActivitiesLen{ 3 };
|
|
71
71
|
|
|
72
72
|
public:
|
|
73
73
|
ActiveSpeakerObserver(
|
|
@@ -89,7 +89,7 @@ namespace RTC
|
|
|
89
89
|
void Resumed() override;
|
|
90
90
|
void Update();
|
|
91
91
|
bool CalculateActiveSpeaker();
|
|
92
|
-
void TimeoutIdleLevels(
|
|
92
|
+
void TimeoutIdleLevels(int64_t nowMs);
|
|
93
93
|
|
|
94
94
|
/* Pure virtual methods inherited from TimerHandleInterface. */
|
|
95
95
|
protected:
|
|
@@ -99,10 +99,10 @@ namespace RTC
|
|
|
99
99
|
double relativeSpeachActivities[RelativeSpeachActivitiesLen]{};
|
|
100
100
|
std::string dominantId;
|
|
101
101
|
TimerHandleInterface* periodicTimer{ nullptr };
|
|
102
|
-
|
|
102
|
+
int64_t intervalMs{ 300 };
|
|
103
103
|
// Map of ProducerSpeakers indexed by Producer id.
|
|
104
104
|
ankerl::unordered_dense::map<std::string, ProducerSpeaker*> mapProducerSpeakers;
|
|
105
|
-
|
|
105
|
+
int64_t lastLevelIdleAtMs{ 0 };
|
|
106
106
|
};
|
|
107
107
|
} // namespace RTC
|
|
108
108
|
|
|
@@ -13,8 +13,8 @@ namespace RTC
|
|
|
13
13
|
private:
|
|
14
14
|
struct DBovs
|
|
15
15
|
{
|
|
16
|
-
uint16_t totalSum{
|
|
17
|
-
size_t count{
|
|
16
|
+
uint16_t totalSum{ 0 }; // Sum of dBvos (positive integer).
|
|
17
|
+
size_t count{ 0 }; // Number of dBvos entries in totalSum.
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
public:
|
|
@@ -44,9 +44,9 @@ namespace RTC
|
|
|
44
44
|
|
|
45
45
|
private:
|
|
46
46
|
// Passed by argument.
|
|
47
|
-
uint16_t maxEntries{
|
|
47
|
+
uint16_t maxEntries{ 1 };
|
|
48
48
|
int8_t threshold{ -80 };
|
|
49
|
-
|
|
49
|
+
int64_t intervalMs{ 1000 };
|
|
50
50
|
// Allocated by this.
|
|
51
51
|
TimerHandleInterface* periodicTimer{ nullptr };
|
|
52
52
|
// Others.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_HPP
|
|
2
|
+
#define MS_RTC_BWE_ACKNOWLEDGED_BITRATE_ESTIMATOR_INTERFACE_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
namespace BWE
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* Measures the bitrate the receiver is acknowledging, which is what the rate
|
|
13
|
+
* control compares its target against.
|
|
14
|
+
*/
|
|
15
|
+
class AcknowledgedBitrateEstimatorInterface
|
|
16
|
+
{
|
|
17
|
+
public:
|
|
18
|
+
AcknowledgedBitrateEstimatorInterface() = default;
|
|
19
|
+
|
|
20
|
+
AcknowledgedBitrateEstimatorInterface& operator=(
|
|
21
|
+
const AcknowledgedBitrateEstimatorInterface&) = delete;
|
|
22
|
+
|
|
23
|
+
AcknowledgedBitrateEstimatorInterface(const AcknowledgedBitrateEstimatorInterface&) = delete;
|
|
24
|
+
|
|
25
|
+
virtual ~AcknowledgedBitrateEstimatorInterface() = default;
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Feed the packets a feedback reported as received.
|
|
30
|
+
*
|
|
31
|
+
* @param packetResults - The reported packets, ordered by arrival time.
|
|
32
|
+
*/
|
|
33
|
+
virtual void IncomingPacketFeedbackVector(
|
|
34
|
+
const std::vector<Types::PacketResult>& packetResults) = 0;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Acknowledged bitrate (bps), or no value if it cannot be measured yet.
|
|
38
|
+
*/
|
|
39
|
+
virtual std::optional<int64_t> GetBitrate() const = 0;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param inAlr - Whether the sender is in an application limited region.
|
|
43
|
+
*/
|
|
44
|
+
virtual void SetAlr(bool inAlr) = 0;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param alrEndedTimeUs - Time at which the sender stopped being in an
|
|
48
|
+
* application limited region.
|
|
49
|
+
*/
|
|
50
|
+
virtual void SetAlrEndedTimeUs(int64_t alrEndedTimeUs) = 0;
|
|
51
|
+
};
|
|
52
|
+
} // namespace BWE
|
|
53
|
+
} // namespace RTC
|
|
54
|
+
|
|
55
|
+
#endif
|
|
@@ -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
|