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
|
@@ -35,7 +35,7 @@ namespace RTC
|
|
|
35
35
|
supportsPartialReliability(supportsPartialReliability),
|
|
36
36
|
dataChunkHeaderLength(
|
|
37
37
|
useMessageInterleaving ? IDataChunk::IDataChunkHeaderLength
|
|
38
|
-
|
|
38
|
+
: DataChunk::DataChunkHeaderLength),
|
|
39
39
|
t3RtxTimer(t3RtxTimer),
|
|
40
40
|
cwnd(sctpOptions.initialCwndMtus * sctpOptions.mtu),
|
|
41
41
|
rwnd(remoteAdvertisedReceiverWindowCredit),
|
|
@@ -62,7 +62,7 @@ namespace RTC
|
|
|
62
62
|
MS_TRACE();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
bool RetransmissionQueue::HandleReceivedSackChunk(
|
|
65
|
+
bool RetransmissionQueue::HandleReceivedSackChunk(int64_t nowUs, const SackChunk* receivedSackChunk)
|
|
66
66
|
{
|
|
67
67
|
MS_TRACE();
|
|
68
68
|
|
|
@@ -82,7 +82,7 @@ namespace RTC
|
|
|
82
82
|
|
|
83
83
|
if (receivedSackChunk->GetValidatedGapAckBlocks().empty())
|
|
84
84
|
{
|
|
85
|
-
|
|
85
|
+
UpdateRttUs(nowUs, cumulativeTsnAck);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Exit fast recovery before continuing processing, in case it needs to go
|
|
@@ -301,7 +301,7 @@ namespace RTC
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
std::vector<std::pair<uint32_t /*tsn*/, UserData>> RetransmissionQueue::GetChunksToSend(
|
|
304
|
-
|
|
304
|
+
int64_t nowUs, size_t maxLength)
|
|
305
305
|
{
|
|
306
306
|
MS_TRACE();
|
|
307
307
|
|
|
@@ -365,7 +365,7 @@ namespace RTC
|
|
|
365
365
|
maxBytes);
|
|
366
366
|
|
|
367
367
|
std::optional<SendQueueInterface::DataToSend> dataToSend =
|
|
368
|
-
this->sendQueue.Produce(
|
|
368
|
+
this->sendQueue.Produce(nowUs, maxBytes - this->dataChunkHeaderLength);
|
|
369
369
|
|
|
370
370
|
if (!dataToSend.has_value())
|
|
371
371
|
{
|
|
@@ -381,10 +381,10 @@ namespace RTC
|
|
|
381
381
|
const std::optional<Types::UnwrappedTsn> tsn = this->outstandingData.Insert(
|
|
382
382
|
dataToSend->outgoingMessageId,
|
|
383
383
|
dataToSend->data,
|
|
384
|
-
|
|
384
|
+
nowUs,
|
|
385
385
|
this->supportsPartialReliability ? dataToSend->maxRetransmissions
|
|
386
|
-
|
|
387
|
-
this->supportsPartialReliability ? dataToSend->
|
|
386
|
+
: Types::MaxRetransmitsNoLimit,
|
|
387
|
+
this->supportsPartialReliability ? dataToSend->expiresAtUs : Types::ExpiresAtUsInfinite,
|
|
388
388
|
dataToSend->lifecycleId);
|
|
389
389
|
|
|
390
390
|
if (tsn.has_value())
|
|
@@ -450,7 +450,7 @@ namespace RTC
|
|
|
450
450
|
return toBeSent;
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
-
bool RetransmissionQueue::ShouldSendForwardTsn(
|
|
453
|
+
bool RetransmissionQueue::ShouldSendForwardTsn(int64_t nowUs)
|
|
454
454
|
{
|
|
455
455
|
MS_TRACE();
|
|
456
456
|
|
|
@@ -459,7 +459,7 @@ namespace RTC
|
|
|
459
459
|
return false;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
-
this->outstandingData.ExpireOutstandingChunks(
|
|
462
|
+
this->outstandingData.ExpireOutstandingChunks(nowUs);
|
|
463
463
|
|
|
464
464
|
return this->outstandingData.ShouldSendForwardTsn();
|
|
465
465
|
}
|
|
@@ -552,11 +552,11 @@ namespace RTC
|
|
|
552
552
|
[&](const auto& block)
|
|
553
553
|
{
|
|
554
554
|
return Types::UnwrappedTsn::AddTo(cumulativeTsnAck, block.end) <=
|
|
555
|
-
|
|
555
|
+
this->outstandingData.GetHighestOutstandingTsn();
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
void RetransmissionQueue::
|
|
559
|
+
void RetransmissionQueue::UpdateRttUs(int64_t nowUs, Types::UnwrappedTsn cumulativeTsnAck)
|
|
560
560
|
{
|
|
561
561
|
MS_TRACE();
|
|
562
562
|
|
|
@@ -571,11 +571,11 @@ namespace RTC
|
|
|
571
571
|
// Consider occasionally sending DATA chunks with I-bit set and use only
|
|
572
572
|
// those packets for measurement.
|
|
573
573
|
|
|
574
|
-
const auto
|
|
574
|
+
const auto rttUs = this->outstandingData.MeasureRttUs(nowUs, cumulativeTsnAck);
|
|
575
575
|
|
|
576
|
-
if (
|
|
576
|
+
if (rttUs.has_value())
|
|
577
577
|
{
|
|
578
|
-
this->listener->
|
|
578
|
+
this->listener->OnRetransmissionQueueNewRttUs(rttUs.value());
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
|
|
@@ -15,7 +15,7 @@ namespace RTC
|
|
|
15
15
|
static constexpr double RtoAlpha{ 1.0 / 8.0 };
|
|
16
16
|
static constexpr double RtoBeta{ 1.0 / 4.0 };
|
|
17
17
|
|
|
18
|
-
// A factor that the `
|
|
18
|
+
// A factor that the `minRttVarianceUs` configuration option will be divided
|
|
19
19
|
// by (before later multiplied with K, which is 4 according to RFC6298). When
|
|
20
20
|
// this value was introduced, it was unintentionally divided by 8 since that
|
|
21
21
|
// code worked with scaled numbers (to avoid floating point math). That
|
|
@@ -26,12 +26,15 @@ namespace RTC
|
|
|
26
26
|
/* Instance methods. */
|
|
27
27
|
|
|
28
28
|
RetransmissionTimeout::RetransmissionTimeout(const SctpOptions& sctpOptions)
|
|
29
|
-
:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
// NOTE: The options are in milliseconds, while this class works in
|
|
30
|
+
// microseconds so that sub-millisecond RTTs are not lost.
|
|
31
|
+
: minRtoUs(sctpOptions.minRtoMs * 1000),
|
|
32
|
+
maxRtoUs(sctpOptions.maxRtoMs * 1000),
|
|
33
|
+
maxRttUs(sctpOptions.maxRttMs * 1000),
|
|
34
|
+
minRttVarianceUs(
|
|
35
|
+
static_cast<int64_t>((sctpOptions.minRttVarianceMs * 1000) / HeuristicVarianceAdjustment)),
|
|
36
|
+
srttUs(sctpOptions.initialRtoMs * 1000),
|
|
37
|
+
rtoUs(sctpOptions.initialRtoMs * 1000),
|
|
35
38
|
firstMeasurement(true)
|
|
36
39
|
{
|
|
37
40
|
MS_TRACE();
|
|
@@ -47,25 +50,25 @@ namespace RTC
|
|
|
47
50
|
MS_TRACE();
|
|
48
51
|
|
|
49
52
|
MS_DUMP_CLEAN(indentation, "<SCTP::RetransmissionTimeout>");
|
|
50
|
-
MS_DUMP_CLEAN(indentation, " min rto (
|
|
51
|
-
MS_DUMP_CLEAN(indentation, " max rto (
|
|
52
|
-
MS_DUMP_CLEAN(indentation, " max rtt (
|
|
53
|
-
MS_DUMP_CLEAN(indentation, " min rtt variance (
|
|
54
|
-
MS_DUMP_CLEAN(indentation, " rto (
|
|
55
|
-
MS_DUMP_CLEAN(indentation, " srtt (
|
|
53
|
+
MS_DUMP_CLEAN(indentation, " min rto (us): %" PRIi64, this->minRtoUs);
|
|
54
|
+
MS_DUMP_CLEAN(indentation, " max rto (us): %" PRIi64, this->maxRtoUs);
|
|
55
|
+
MS_DUMP_CLEAN(indentation, " max rtt (us): %" PRIi64, this->maxRttUs);
|
|
56
|
+
MS_DUMP_CLEAN(indentation, " min rtt variance (us): %" PRIi64, this->minRttVarianceUs);
|
|
57
|
+
MS_DUMP_CLEAN(indentation, " rto (us): %" PRIi64, GetRtoUs());
|
|
58
|
+
MS_DUMP_CLEAN(indentation, " srtt (us): %" PRIi64, GetSrttUs());
|
|
56
59
|
MS_DUMP_CLEAN(indentation, "</SCTP::RetransmissionTimeout>");
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
void RetransmissionTimeout::
|
|
62
|
+
void RetransmissionTimeout::ObserveRttUs(int64_t rttUs)
|
|
60
63
|
{
|
|
61
64
|
MS_TRACE();
|
|
62
65
|
|
|
63
66
|
// Unrealistic values will be skipped. If a wrongly measured (or otherwise
|
|
64
67
|
// corrupt) value was processed, it could change the state in a way that
|
|
65
68
|
// would take a very long time to recover.
|
|
66
|
-
if (
|
|
69
|
+
if (rttUs <= 0 || rttUs > this->maxRttUs)
|
|
67
70
|
{
|
|
68
|
-
MS_WARN_DEV(sctp, "skipping given unrealistic
|
|
71
|
+
MS_WARN_DEV(sctp, "skipping given unrealistic rttUs value %" PRIi64, rttUs);
|
|
69
72
|
|
|
70
73
|
return;
|
|
71
74
|
}
|
|
@@ -73,25 +76,25 @@ namespace RTC
|
|
|
73
76
|
// https://datatracker.ietf.org/doc/html/rfc9260#section-6.3.1
|
|
74
77
|
if (this->firstMeasurement)
|
|
75
78
|
{
|
|
76
|
-
this->
|
|
77
|
-
this->
|
|
79
|
+
this->srttUs = rttUs;
|
|
80
|
+
this->rttVarUs = rttUs / 2.0;
|
|
78
81
|
this->firstMeasurement = false;
|
|
79
82
|
}
|
|
80
83
|
else
|
|
81
84
|
{
|
|
82
|
-
const double
|
|
85
|
+
const double rttDiffUs = std::abs(this->srttUs - static_cast<double>(rttUs));
|
|
83
86
|
|
|
84
|
-
this->
|
|
85
|
-
this->
|
|
87
|
+
this->rttVarUs = ((1.0 - RtoBeta) * this->rttVarUs) + (RtoBeta * rttDiffUs);
|
|
88
|
+
this->srttUs = ((1.0 - RtoAlpha) * this->srttUs) + (RtoAlpha * rttUs);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
this->
|
|
89
|
-
this->
|
|
90
|
-
this->
|
|
91
|
+
this->rttVarUs = std::max(this->rttVarUs, static_cast<double>(this->minRttVarianceUs));
|
|
92
|
+
this->rtoUs = this->srttUs + (4.0 * this->rttVarUs);
|
|
93
|
+
this->rtoUs = std::round(
|
|
91
94
|
std::clamp(
|
|
92
|
-
this->
|
|
95
|
+
this->rtoUs, static_cast<double>(this->minRtoUs), static_cast<double>(this->maxRtoUs)));
|
|
93
96
|
|
|
94
|
-
MS_DEBUG_DEV("new computed RTO: %"
|
|
97
|
+
MS_DEBUG_DEV("new computed RTO: %" PRIi64 " us", static_cast<int64_t>(this->rtoUs));
|
|
95
98
|
}
|
|
96
99
|
} // namespace SCTP
|
|
97
100
|
} // namespace RTC
|
|
@@ -43,7 +43,7 @@ namespace RTC
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
void RoundRobinSendQueue::AddMessage(
|
|
46
|
-
|
|
46
|
+
int64_t nowUs, Message message, const SendMessageOptions& sendMessageOptions)
|
|
47
47
|
{
|
|
48
48
|
MS_TRACE();
|
|
49
49
|
|
|
@@ -51,17 +51,18 @@ namespace RTC
|
|
|
51
51
|
|
|
52
52
|
// Any limited lifetime should start counting from now - when the message
|
|
53
53
|
// has been added to the queue.
|
|
54
|
-
// `
|
|
54
|
+
// `expiresAtUs` is the time when it expires. Which is slightly larger
|
|
55
55
|
// than the message's lifetime, as the message is alive during its entire
|
|
56
56
|
// lifetime (which may be zero).
|
|
57
|
+
// NOTE: `lifetimeMs` is in milliseconds, being it given by the API.
|
|
57
58
|
const MessageAttributes attributes = {
|
|
58
59
|
.isUnordered = sendMessageOptions.unordered,
|
|
59
60
|
.maxRetransmissions = sendMessageOptions.maxRetransmissions.has_value()
|
|
60
61
|
? sendMessageOptions.maxRetransmissions.value()
|
|
61
62
|
: Types::MaxRetransmitsNoLimit,
|
|
62
|
-
.
|
|
63
|
-
?
|
|
64
|
-
: Types::
|
|
63
|
+
.expiresAtUs = sendMessageOptions.lifetimeMs.has_value()
|
|
64
|
+
? nowUs + (sendMessageOptions.lifetimeMs.value() * 1000) + 1
|
|
65
|
+
: Types::ExpiresAtUsInfinite,
|
|
65
66
|
.lifecycleId = sendMessageOptions.lifecycleId,
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -98,11 +99,11 @@ namespace RTC
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
std::optional<SendQueueInterface::DataToSend> RoundRobinSendQueue::Produce(
|
|
101
|
-
|
|
102
|
+
int64_t nowUs, size_t maxLength)
|
|
102
103
|
{
|
|
103
104
|
MS_TRACE();
|
|
104
105
|
|
|
105
|
-
return this->scheduler.Produce(
|
|
106
|
+
return this->scheduler.Produce(nowUs, maxLength);
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
bool RoundRobinSendQueue::Discard(uint16_t streamId, uint32_t outgoingMessageId)
|
|
@@ -418,7 +419,7 @@ namespace RTC
|
|
|
418
419
|
}
|
|
419
420
|
|
|
420
421
|
std::optional<SendQueueInterface::DataToSend> RoundRobinSendQueue::OutgoingStream::Produce(
|
|
421
|
-
|
|
422
|
+
int64_t nowUs, size_t maxLength)
|
|
422
423
|
{
|
|
423
424
|
MS_TRACE();
|
|
424
425
|
|
|
@@ -435,7 +436,7 @@ namespace RTC
|
|
|
435
436
|
if (!item.mid.has_value())
|
|
436
437
|
{
|
|
437
438
|
// This entire message has already expired. Try the next one.
|
|
438
|
-
if (item.attributes.
|
|
439
|
+
if (item.attributes.expiresAtUs != Types::ExpiresAtUsInfinite && item.attributes.expiresAtUs <= nowUs)
|
|
439
440
|
{
|
|
440
441
|
HandleMessageExpired(item);
|
|
441
442
|
|
|
@@ -472,7 +473,7 @@ namespace RTC
|
|
|
472
473
|
// Zero-copy the payload if the message fits in a single chunk.
|
|
473
474
|
std::vector<uint8_t> payload =
|
|
474
475
|
isBeginning && isEnd ? std::move(message).ReleasePayload()
|
|
475
|
-
|
|
476
|
+
: std::vector<uint8_t>(chunkPayload.begin(), chunkPayload.end());
|
|
476
477
|
|
|
477
478
|
const uint32_t fsn = item.currentFsn;
|
|
478
479
|
|
|
@@ -495,7 +496,7 @@ namespace RTC
|
|
|
495
496
|
item.attributes.isUnordered));
|
|
496
497
|
|
|
497
498
|
dataToSend.maxRetransmissions = item.attributes.maxRetransmissions;
|
|
498
|
-
dataToSend.
|
|
499
|
+
dataToSend.expiresAtUs = item.attributes.expiresAtUs;
|
|
499
500
|
dataToSend.lifecycleId = isEnd ? item.attributes.lifecycleId : std::nullopt;
|
|
500
501
|
|
|
501
502
|
if (isEnd)
|
|
@@ -11,7 +11,7 @@ namespace RTC
|
|
|
11
11
|
{
|
|
12
12
|
/* Instance methods. */
|
|
13
13
|
|
|
14
|
-
std::optional<SendQueueInterface::DataToSend> StreamScheduler::Produce(
|
|
14
|
+
std::optional<SendQueueInterface::DataToSend> StreamScheduler::Produce(int64_t nowUs, size_t maxLength)
|
|
15
15
|
{
|
|
16
16
|
MS_TRACE();
|
|
17
17
|
|
|
@@ -56,7 +56,7 @@ namespace RTC
|
|
|
56
56
|
"current stream should be in active streams");
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
dataToSend = this->currentStream->Produce(
|
|
59
|
+
dataToSend = this->currentStream->Produce(nowUs, maxLength);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (!dataToSend.has_value())
|
|
@@ -234,12 +234,12 @@ namespace RTC
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
std::optional<SendQueueInterface::DataToSend> StreamScheduler::Stream::Produce(
|
|
237
|
-
|
|
237
|
+
int64_t nowUs, size_t maxLength)
|
|
238
238
|
{
|
|
239
239
|
MS_TRACE();
|
|
240
240
|
|
|
241
241
|
std::optional<SendQueueInterface::DataToSend> dataToSend =
|
|
242
|
-
this->producer.Produce(
|
|
242
|
+
this->producer.Produce(nowUs, maxLength);
|
|
243
243
|
|
|
244
244
|
if (dataToSend.has_value())
|
|
245
245
|
{
|
|
@@ -66,8 +66,8 @@ namespace RTC
|
|
|
66
66
|
this->streamId,
|
|
67
67
|
this->ordered,
|
|
68
68
|
this->maxPacketLifeTime ? flatbuffers::Optional<uint16_t>(this->maxPacketLifeTime)
|
|
69
|
-
|
|
69
|
+
: flatbuffers::nullopt,
|
|
70
70
|
this->maxRetransmits ? flatbuffers::Optional<uint16_t>(this->maxRetransmits)
|
|
71
|
-
|
|
71
|
+
: flatbuffers::nullopt);
|
|
72
72
|
}
|
|
73
73
|
} // namespace RTC
|
|
@@ -90,8 +90,8 @@ namespace RTC
|
|
|
90
90
|
// Do nothing.
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
int64_t SimpleProducerStreamManager::IncreaseLayer(
|
|
94
|
+
int64_t bitrate, bool /*considerLoss*/, float /*lossPercentage*/, int64_t nowMs)
|
|
95
95
|
{
|
|
96
96
|
MS_TRACE();
|
|
97
97
|
|
|
@@ -103,7 +103,7 @@ namespace RTC
|
|
|
103
103
|
// about this.
|
|
104
104
|
if (this->managingBitrate)
|
|
105
105
|
{
|
|
106
|
-
return
|
|
106
|
+
return 0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
this->managingBitrate = true;
|
|
@@ -112,10 +112,10 @@ namespace RTC
|
|
|
112
112
|
// because Consumer::GetBitratePriority() does not account for the producer
|
|
113
113
|
// stream presence/score, so the Transport may still ask us to increase.
|
|
114
114
|
if (
|
|
115
|
-
!this->producerRtpStream || (this->producerRtpStream->GetScore() ==
|
|
116
|
-
|
|
115
|
+
!this->producerRtpStream || (this->producerRtpStream->GetScore() == 0 &&
|
|
116
|
+
this->producerRtpStream->HasRtpInactivityCheckEnabled()))
|
|
117
117
|
{
|
|
118
|
-
return
|
|
118
|
+
return 0;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// Video Simple consumer does not really play the BWE game. However, let's
|
|
@@ -132,7 +132,7 @@ namespace RTC
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
void SimpleProducerStreamManager::ApplyLayers(
|
|
135
|
+
void SimpleProducerStreamManager::ApplyLayers(int64_t /*rtpStreamActiveMs*/)
|
|
136
136
|
{
|
|
137
137
|
MS_TRACE();
|
|
138
138
|
|
|
@@ -144,7 +144,7 @@ namespace RTC
|
|
|
144
144
|
// Simple does not play the BWE game (even if video kind).
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
int64_t SimpleProducerStreamManager::GetDesiredBitrate(int64_t nowMs) const
|
|
148
148
|
{
|
|
149
149
|
MS_TRACE();
|
|
150
150
|
|
|
@@ -153,12 +153,12 @@ namespace RTC
|
|
|
153
153
|
// Audio does not play the BWE game.
|
|
154
154
|
if (this->kind != RTC::Media::Kind::VIDEO)
|
|
155
155
|
{
|
|
156
|
-
return
|
|
156
|
+
return 0;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
if (!IsActive())
|
|
160
160
|
{
|
|
161
|
-
return
|
|
161
|
+
return 0;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
return this->producerRtpStream->GetBitrate(nowMs);
|
|
@@ -8,10 +8,10 @@ namespace RTC
|
|
|
8
8
|
{
|
|
9
9
|
/* Static. */
|
|
10
10
|
|
|
11
|
-
static constexpr
|
|
12
|
-
static constexpr
|
|
13
|
-
static constexpr
|
|
14
|
-
static constexpr uint16_t MaxSequenceNumberGap{
|
|
11
|
+
static constexpr int64_t StreamMinActiveMs{ 2000 };
|
|
12
|
+
static constexpr int64_t BweDowngradeConservativeMs{ 10000 };
|
|
13
|
+
static constexpr int64_t BweDowngradeMinActiveMs{ 8000 };
|
|
14
|
+
static constexpr uint16_t MaxSequenceNumberGap{ 100 };
|
|
15
15
|
|
|
16
16
|
/* Instance methods. */
|
|
17
17
|
|
|
@@ -200,18 +200,18 @@ namespace RTC
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
int64_t SimulcastProducerStreamManager::IncreaseLayer(
|
|
204
|
+
int64_t bitrate, bool considerLoss, float lossPercentage, int64_t nowMs)
|
|
205
205
|
{
|
|
206
206
|
MS_TRACE();
|
|
207
207
|
|
|
208
208
|
// If already in the preferred layers, do nothing.
|
|
209
209
|
if (this->provisionalTargetLayers == this->preferredLayers)
|
|
210
210
|
{
|
|
211
|
-
return
|
|
211
|
+
return 0;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
int64_t virtualBitrate;
|
|
215
215
|
|
|
216
216
|
if (considerLoss)
|
|
217
217
|
{
|
|
@@ -235,7 +235,7 @@ namespace RTC
|
|
|
235
235
|
virtualBitrate = bitrate;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
int64_t requiredBitrate{ 0 };
|
|
239
239
|
int16_t spatialLayer{ 0 };
|
|
240
240
|
int16_t temporalLayer{ 0 };
|
|
241
241
|
// Whether a usable spatial layer has been found, in which case we must not
|
|
@@ -351,7 +351,7 @@ namespace RTC
|
|
|
351
351
|
// temporal spatial layer if this is the temporal layer 0 of a higher
|
|
352
352
|
// spatial layer.
|
|
353
353
|
if (
|
|
354
|
-
requiredBitrate && temporalLayer == 0 && this->provisionalTargetLayers.spatial > -1 &&
|
|
354
|
+
requiredBitrate > 0 && temporalLayer == 0 && this->provisionalTargetLayers.spatial > -1 &&
|
|
355
355
|
spatialLayer > this->provisionalTargetLayers.spatial)
|
|
356
356
|
{
|
|
357
357
|
auto* provisionalProducerRtpStream =
|
|
@@ -365,13 +365,13 @@ namespace RTC
|
|
|
365
365
|
}
|
|
366
366
|
else
|
|
367
367
|
{
|
|
368
|
-
requiredBitrate =
|
|
368
|
+
requiredBitrate = 1; // Don't set 0 since it would be ignored.
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
MS_DEBUG_DEV(
|
|
373
|
-
"testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%"
|
|
374
|
-
", required bitrate:%"
|
|
373
|
+
"testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
|
|
374
|
+
", required bitrate:%" PRIi64 "]",
|
|
375
375
|
spatialLayer,
|
|
376
376
|
temporalLayer,
|
|
377
377
|
virtualBitrate,
|
|
@@ -379,7 +379,7 @@ namespace RTC
|
|
|
379
379
|
|
|
380
380
|
// If active layer, end iterations here. Otherwise move to next spatial
|
|
381
381
|
// layer.
|
|
382
|
-
if (requiredBitrate)
|
|
382
|
+
if (requiredBitrate > 0)
|
|
383
383
|
{
|
|
384
384
|
goto done;
|
|
385
385
|
}
|
|
@@ -399,15 +399,15 @@ namespace RTC
|
|
|
399
399
|
done:
|
|
400
400
|
|
|
401
401
|
// No higher active layers found.
|
|
402
|
-
if (
|
|
402
|
+
if (requiredBitrate <= 0)
|
|
403
403
|
{
|
|
404
|
-
return
|
|
404
|
+
return 0;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
// No luck.
|
|
408
408
|
if (requiredBitrate > virtualBitrate)
|
|
409
409
|
{
|
|
410
|
-
return
|
|
410
|
+
return 0;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
// Set provisional layers.
|
|
@@ -415,8 +415,8 @@ namespace RTC
|
|
|
415
415
|
this->provisionalTargetLayers.temporal = temporalLayer;
|
|
416
416
|
|
|
417
417
|
MS_DEBUG_DEV(
|
|
418
|
-
"setting provisional layers to %" PRIi16 ":%" PRIi16 " [virtual bitrate:%"
|
|
419
|
-
", required bitrate:%"
|
|
418
|
+
"setting provisional layers to %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
|
|
419
|
+
", required bitrate:%" PRIi64 "]",
|
|
420
420
|
this->provisionalTargetLayers.spatial,
|
|
421
421
|
this->provisionalTargetLayers.temporal,
|
|
422
422
|
virtualBitrate,
|
|
@@ -436,7 +436,7 @@ namespace RTC
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
void SimulcastProducerStreamManager::ApplyLayers(
|
|
439
|
+
void SimulcastProducerStreamManager::ApplyLayers(int64_t rtpStreamActiveMs)
|
|
440
440
|
{
|
|
441
441
|
MS_TRACE();
|
|
442
442
|
|
|
@@ -467,11 +467,11 @@ namespace RTC
|
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
|
|
470
|
+
int64_t SimulcastProducerStreamManager::GetDesiredBitrate(int64_t nowMs) const
|
|
471
471
|
{
|
|
472
472
|
MS_TRACE();
|
|
473
473
|
|
|
474
|
-
|
|
474
|
+
int64_t desiredBitrate{ 0 };
|
|
475
475
|
|
|
476
476
|
// Let's iterate all streams of the Producer (from highest to lowest) and
|
|
477
477
|
// obtain their bitrate. Choose the highest one.
|
|
@@ -673,13 +673,13 @@ namespace RTC
|
|
|
673
673
|
else
|
|
674
674
|
{
|
|
675
675
|
// Calculate capture instant and TS stuff.
|
|
676
|
-
const auto
|
|
677
|
-
const auto ts1
|
|
678
|
-
const auto
|
|
679
|
-
const auto ts2
|
|
680
|
-
const int64_t
|
|
681
|
-
const int64_t diffTs
|
|
682
|
-
const uint32_t newTs2
|
|
676
|
+
const auto captureAtUs1 = tsReferenceCaptureMapping.value().captureAtUs;
|
|
677
|
+
const auto ts1 = tsReferenceCaptureMapping.value().ts;
|
|
678
|
+
const auto captureAtUs2 = captureMapping.value().captureAtUs;
|
|
679
|
+
const auto ts2 = captureMapping.value().ts;
|
|
680
|
+
const int64_t diffUs = captureAtUs2 - captureAtUs1;
|
|
681
|
+
const int64_t diffTs = (diffUs * clockRate) / 1000000;
|
|
682
|
+
const uint32_t newTs2 = ts2 - diffTs;
|
|
683
683
|
|
|
684
684
|
// Apply offset. This is the difference that later must be removed from
|
|
685
685
|
// the sending RTP packet.
|
|
@@ -695,15 +695,17 @@ namespace RTC
|
|
|
695
695
|
{
|
|
696
696
|
// Max delay in ms we allow for the stream when switching.
|
|
697
697
|
// https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
|
|
698
|
-
static constexpr
|
|
698
|
+
static constexpr int64_t MaxExtraOffsetMs{ 75 };
|
|
699
699
|
|
|
700
700
|
// Outgoing packet matches the highest timestamp seen in the previous
|
|
701
701
|
// stream. Apply an expected offset for a new frame in a 30fps stream.
|
|
702
|
-
static constexpr
|
|
702
|
+
static constexpr int64_t OffsetMs{ 33 }; // (1 / 30 * 1000).
|
|
703
703
|
|
|
704
704
|
const int64_t maxTsExtraOffset = MaxExtraOffsetMs * clockRate / 1000;
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
|
|
706
|
+
// NOTE: RTP timestamps wrap around, so the sum is truncated on purpose.
|
|
707
|
+
auto tsExtraOffset = static_cast<uint32_t>(
|
|
708
|
+
maxPacketTs - packet->GetTimestamp() + tsOffset + (OffsetMs * clockRate / 1000));
|
|
707
709
|
|
|
708
710
|
// NOTE: Don't ask for a key frame if already done.
|
|
709
711
|
if (this->keyFrameForTsOffsetRequested)
|
|
@@ -717,7 +719,7 @@ namespace RTC
|
|
|
717
719
|
"which still too high RTP timestamp extra offset is needed (%" PRIu32 ")",
|
|
718
720
|
tsExtraOffset);
|
|
719
721
|
|
|
720
|
-
tsExtraOffset =
|
|
722
|
+
tsExtraOffset = 1;
|
|
721
723
|
}
|
|
722
724
|
}
|
|
723
725
|
else if (std::cmp_greater(tsExtraOffset, maxTsExtraOffset))
|
|
@@ -746,7 +748,7 @@ namespace RTC
|
|
|
746
748
|
return result;
|
|
747
749
|
}
|
|
748
750
|
|
|
749
|
-
if (tsExtraOffset >
|
|
751
|
+
if (tsExtraOffset > 0)
|
|
750
752
|
{
|
|
751
753
|
MS_DEBUG_TAG(
|
|
752
754
|
simulcast,
|
|
@@ -918,7 +920,7 @@ namespace RTC
|
|
|
918
920
|
if (
|
|
919
921
|
newTargetSpatialLayer != -1 &&
|
|
920
922
|
(this->tsReferenceSpatialLayer == -1 ||
|
|
921
|
-
|
|
923
|
+
!GetProducerTsReferenceRtpStream()->GetCaptureMapping().has_value()))
|
|
922
924
|
{
|
|
923
925
|
MS_DEBUG_TAG(
|
|
924
926
|
simulcast, "using spatial layer %" PRIi16 " as RTP timestamp reference", newTargetSpatialLayer);
|
|
@@ -982,7 +984,7 @@ namespace RTC
|
|
|
982
984
|
// Start with no layers.
|
|
983
985
|
newTargetLayers.Reset();
|
|
984
986
|
|
|
985
|
-
|
|
987
|
+
const int64_t nowMs = this->shared->GetTimeMs();
|
|
986
988
|
|
|
987
989
|
for (size_t sIdx{ 0u }; sIdx < this->producerRtpStreams.size(); ++sIdx)
|
|
988
990
|
{
|