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
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
#include "RTC/RTP/RtpStreamRecv.hpp"
|
|
5
5
|
#include "Logger.hpp"
|
|
6
|
+
#include "RTC/RTCP/FeedbackPsFir.hpp"
|
|
7
|
+
#include "RTC/RTCP/FeedbackPsPli.hpp"
|
|
8
|
+
#include "RTC/RTCP/FeedbackRtpNack.hpp"
|
|
6
9
|
#include "RTC/RTP/Codecs/Tools.hpp"
|
|
7
10
|
#include "Utils.hpp"
|
|
8
11
|
|
|
@@ -12,13 +15,18 @@ namespace RTC
|
|
|
12
15
|
{
|
|
13
16
|
/* Static. */
|
|
14
17
|
|
|
15
|
-
static constexpr
|
|
16
|
-
static constexpr
|
|
18
|
+
static constexpr int64_t InactivityCheckIntervalMs{ 1500 };
|
|
19
|
+
static constexpr int64_t InactivityCheckIntervalWithDtxMs{ 5000 };
|
|
20
|
+
// How often the spatial layers of a stream are checked for traffic.
|
|
21
|
+
// NOTE: A layer that stops doesn't report zero bitrate until the window of
|
|
22
|
+
// its counter has fully elapsed, so this interval just adds to that
|
|
23
|
+
// unavoidable detection delay.
|
|
24
|
+
static constexpr int64_t SpatialLayersActivityCheckIntervalMs{ 1500 };
|
|
17
25
|
|
|
18
26
|
/* TransmissionCounter methods. */
|
|
19
27
|
|
|
20
28
|
RtpStreamRecv::TransmissionCounter::TransmissionCounter(
|
|
21
|
-
SharedInterface* shared, uint8_t spatialLayers, uint8_t temporalLayers,
|
|
29
|
+
SharedInterface* shared, uint8_t spatialLayers, uint8_t temporalLayers, int64_t windowSizeMs)
|
|
22
30
|
{
|
|
23
31
|
MS_TRACE();
|
|
24
32
|
|
|
@@ -27,9 +35,9 @@ namespace RTC
|
|
|
27
35
|
|
|
28
36
|
for (auto& spatialLayerCounter : this->spatialLayerCounters)
|
|
29
37
|
{
|
|
30
|
-
for (uint8_t tIdx{
|
|
38
|
+
for (uint8_t tIdx{ 0 }; tIdx < temporalLayers; ++tIdx)
|
|
31
39
|
{
|
|
32
|
-
spatialLayerCounter.emplace_back(shared, /*ignorePaddingOnlyPackets*/ true,
|
|
40
|
+
spatialLayerCounter.emplace_back(shared, /*ignorePaddingOnlyPackets*/ true, windowSizeMs);
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
}
|
|
@@ -54,11 +62,11 @@ namespace RTC
|
|
|
54
62
|
counter.Update(packet);
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
int64_t RtpStreamRecv::TransmissionCounter::GetBitrate(int64_t nowMs)
|
|
58
66
|
{
|
|
59
67
|
MS_TRACE();
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
int64_t rate{ 0 };
|
|
62
70
|
|
|
63
71
|
for (auto& spatialLayerCounter : this->spatialLayerCounters)
|
|
64
72
|
{
|
|
@@ -71,8 +79,8 @@ namespace RTC
|
|
|
71
79
|
return rate;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
int64_t RtpStreamRecv::TransmissionCounter::GetBitrate(
|
|
83
|
+
int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer)
|
|
76
84
|
{
|
|
77
85
|
MS_TRACE();
|
|
78
86
|
|
|
@@ -83,17 +91,17 @@ namespace RTC
|
|
|
83
91
|
// Return 0 if specified layers are not being received.
|
|
84
92
|
auto& counter = this->spatialLayerCounters[spatialLayer][temporalLayer];
|
|
85
93
|
|
|
86
|
-
if (counter.GetBitrate(nowMs)
|
|
94
|
+
if (counter.GetBitrate(nowMs) <= 0)
|
|
87
95
|
{
|
|
88
|
-
return
|
|
96
|
+
return 0;
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
int64_t rate{ 0 };
|
|
92
100
|
|
|
93
101
|
// Iterate all temporal layers of spatial layers previous to the given one.
|
|
94
|
-
for (uint8_t sIdx{
|
|
102
|
+
for (uint8_t sIdx{ 0 }; sIdx < spatialLayer; ++sIdx)
|
|
95
103
|
{
|
|
96
|
-
for (size_t tIdx{
|
|
104
|
+
for (size_t tIdx{ 0 }; tIdx < this->spatialLayerCounters[sIdx].size(); ++tIdx)
|
|
97
105
|
{
|
|
98
106
|
auto& temporalLayerCounter = this->spatialLayerCounters[sIdx][tIdx];
|
|
99
107
|
|
|
@@ -102,7 +110,7 @@ namespace RTC
|
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
// Add the given spatial layer with up to the given temporal layer.
|
|
105
|
-
for (uint8_t tIdx{
|
|
113
|
+
for (uint8_t tIdx{ 0 }; tIdx <= temporalLayer; ++tIdx)
|
|
106
114
|
{
|
|
107
115
|
auto& temporalLayerCounter = this->spatialLayerCounters[spatialLayer][tIdx];
|
|
108
116
|
|
|
@@ -112,16 +120,15 @@ namespace RTC
|
|
|
112
120
|
return rate;
|
|
113
121
|
}
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
uint64_t nowMs, uint8_t spatialLayer)
|
|
123
|
+
int64_t RtpStreamRecv::TransmissionCounter::GetSpatialLayerBitrate(int64_t nowMs, uint8_t spatialLayer)
|
|
117
124
|
{
|
|
118
125
|
MS_TRACE();
|
|
119
126
|
|
|
120
127
|
MS_ASSERT(spatialLayer < this->spatialLayerCounters.size(), "spatialLayer too high");
|
|
121
128
|
|
|
122
|
-
|
|
129
|
+
int64_t rate{ 0 };
|
|
123
130
|
|
|
124
|
-
for (size_t tIdx{
|
|
131
|
+
for (size_t tIdx{ 0 }; tIdx < this->spatialLayerCounters[spatialLayer].size(); ++tIdx)
|
|
125
132
|
{
|
|
126
133
|
auto& temporalLayerCounter = this->spatialLayerCounters[spatialLayer][tIdx];
|
|
127
134
|
|
|
@@ -131,8 +138,8 @@ namespace RTC
|
|
|
131
138
|
return rate;
|
|
132
139
|
}
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
int64_t RtpStreamRecv::TransmissionCounter::GetLayerBitrate(
|
|
142
|
+
int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer)
|
|
136
143
|
{
|
|
137
144
|
MS_TRACE();
|
|
138
145
|
|
|
@@ -149,7 +156,7 @@ namespace RTC
|
|
|
149
156
|
{
|
|
150
157
|
MS_TRACE();
|
|
151
158
|
|
|
152
|
-
size_t packetCount{
|
|
159
|
+
size_t packetCount{ 0 };
|
|
153
160
|
|
|
154
161
|
for (const auto& spatialLayerCounter : this->spatialLayerCounters)
|
|
155
162
|
{
|
|
@@ -166,7 +173,7 @@ namespace RTC
|
|
|
166
173
|
{
|
|
167
174
|
MS_TRACE();
|
|
168
175
|
|
|
169
|
-
size_t bytes{
|
|
176
|
+
size_t bytes{ 0 };
|
|
170
177
|
|
|
171
178
|
for (const auto& spatialLayerCounter : this->spatialLayerCounters)
|
|
172
179
|
{
|
|
@@ -185,7 +192,7 @@ namespace RTC
|
|
|
185
192
|
RTP::RtpStreamRecv::Listener* listener,
|
|
186
193
|
SharedInterface* shared,
|
|
187
194
|
RTP::RtpStream::Params& params,
|
|
188
|
-
|
|
195
|
+
int64_t sendNackDelayMs,
|
|
189
196
|
bool useRtpInactivityCheck)
|
|
190
197
|
: RTP::RtpStream::RtpStream(listener, shared, params, 10),
|
|
191
198
|
sendNackDelayMs(sendNackDelayMs),
|
|
@@ -207,10 +214,25 @@ namespace RTC
|
|
|
207
214
|
{
|
|
208
215
|
// Run the RTP inactivity periodic timer (use a different timeout if DTX is
|
|
209
216
|
// enabled).
|
|
210
|
-
this->inactivityCheckPeriodicTimer =
|
|
217
|
+
this->inactivityCheckPeriodicTimer =
|
|
218
|
+
this->shared->CreateTimer(this, "rtp-stream-recv-inactivity-check");
|
|
211
219
|
|
|
212
220
|
this->inactivityCheckPeriodicTimer->Start(
|
|
213
|
-
this->params.useDtx ?
|
|
221
|
+
this->params.useDtx ? InactivityCheckIntervalWithDtxMs : InactivityCheckIntervalMs);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// A stream with more than a spatial layer carries all of them within the
|
|
225
|
+
// same SSRC, so the inactivity check above cannot tell that just one of
|
|
226
|
+
// them stopped. Watch their traffic separately.
|
|
227
|
+
if (GetSpatialLayers() > 1)
|
|
228
|
+
{
|
|
229
|
+
this->spatialLayersActivity.assign(GetSpatialLayers(), false);
|
|
230
|
+
|
|
231
|
+
this->spatialLayersActivityCheckPeriodicTimer =
|
|
232
|
+
this->shared->CreateTimer(this, "rtp-stream-recv-spatial-layers-activity-check");
|
|
233
|
+
|
|
234
|
+
this->spatialLayersActivityCheckPeriodicTimer->Start(
|
|
235
|
+
SpatialLayersActivityCheckIntervalMs, SpatialLayersActivityCheckIntervalMs);
|
|
214
236
|
}
|
|
215
237
|
}
|
|
216
238
|
|
|
@@ -221,6 +243,10 @@ namespace RTC
|
|
|
221
243
|
// Close the RTP inactivity check periodic timer.
|
|
222
244
|
delete this->inactivityCheckPeriodicTimer;
|
|
223
245
|
this->inactivityCheckPeriodicTimer = nullptr;
|
|
246
|
+
|
|
247
|
+
// Close the spatial layers activity check periodic timer.
|
|
248
|
+
delete this->spatialLayersActivityCheckPeriodicTimer;
|
|
249
|
+
this->spatialLayersActivityCheckPeriodicTimer = nullptr;
|
|
224
250
|
}
|
|
225
251
|
|
|
226
252
|
flatbuffers::Offset<FBS::RtpStream::Stats> RtpStreamRecv::FillBufferStats(
|
|
@@ -228,7 +254,7 @@ namespace RTC
|
|
|
228
254
|
{
|
|
229
255
|
MS_TRACE();
|
|
230
256
|
|
|
231
|
-
const
|
|
257
|
+
const int64_t nowMs = this->shared->GetTimeMs();
|
|
232
258
|
|
|
233
259
|
auto baseStats = RTP::RtpStream::FillBufferStats(builder);
|
|
234
260
|
|
|
@@ -244,7 +270,7 @@ namespace RTC
|
|
|
244
270
|
|
|
245
271
|
bitrateByLayer.emplace_back(
|
|
246
272
|
FBS::RtpStream::CreateBitrateByLayerDirect(
|
|
247
|
-
builder, layer.c_str(), GetBitrate(nowMs, sIdx, tIdx)));
|
|
273
|
+
builder, layer.c_str(), static_cast<uint64_t>(GetBitrate(nowMs, sIdx, tIdx))));
|
|
248
274
|
}
|
|
249
275
|
}
|
|
250
276
|
}
|
|
@@ -254,13 +280,13 @@ namespace RTC
|
|
|
254
280
|
baseStats,
|
|
255
281
|
this->transmissionCounter.GetPacketCount(),
|
|
256
282
|
this->transmissionCounter.GetBytes(),
|
|
257
|
-
this->transmissionCounter.GetBitrate(nowMs),
|
|
283
|
+
static_cast<uint64_t>(this->transmissionCounter.GetBitrate(nowMs)),
|
|
258
284
|
&bitrateByLayer);
|
|
259
285
|
|
|
260
286
|
return FBS::RtpStream::CreateStats(builder, FBS::RtpStream::StatsData::RecvStats, stats.Union());
|
|
261
287
|
}
|
|
262
288
|
|
|
263
|
-
bool RtpStreamRecv::ReceivePacket(RTP::Packet* packet)
|
|
289
|
+
bool RtpStreamRecv::ReceivePacket(RTP::Packet* packet, int64_t receivedAtUs)
|
|
264
290
|
{
|
|
265
291
|
MS_TRACE();
|
|
266
292
|
|
|
@@ -297,7 +323,7 @@ namespace RTC
|
|
|
297
323
|
}
|
|
298
324
|
|
|
299
325
|
// Calculate jitter.
|
|
300
|
-
CalculateJitter(packet->GetTimestamp());
|
|
326
|
+
CalculateJitter(packet->GetTimestamp(), receivedAtUs);
|
|
301
327
|
|
|
302
328
|
// Store the capture instant if the packet carries it.
|
|
303
329
|
{
|
|
@@ -318,16 +344,16 @@ namespace RTC
|
|
|
318
344
|
// of the sender, which is the one this stream is estimated against:
|
|
319
345
|
//
|
|
320
346
|
// capture NTP clock = sender NTP clock + capture clock offset
|
|
321
|
-
const auto
|
|
322
|
-
|
|
347
|
+
const auto captureAtUs =
|
|
348
|
+
Utils::Time::Ntp2TimeUs(ntp) - Utils::Time::Q32x32ToTimeUs(estimatedCaptureClockOffset);
|
|
323
349
|
|
|
324
350
|
// NOTE: A capture instant that is not positive means a capture clock offset
|
|
325
351
|
// that cannot be true, so there is nothing to store.
|
|
326
|
-
if (
|
|
352
|
+
if (captureAtUs > 0)
|
|
327
353
|
{
|
|
328
354
|
this->lastAbsCaptureTime = AbsCaptureTime{
|
|
329
355
|
.ts = packet->GetTimestamp(),
|
|
330
|
-
.
|
|
356
|
+
.ntpUs = captureAtUs,
|
|
331
357
|
};
|
|
332
358
|
}
|
|
333
359
|
}
|
|
@@ -490,7 +516,7 @@ namespace RTC
|
|
|
490
516
|
const uint8_t worstRemoteFractionLost =
|
|
491
517
|
this->params.useInBandFec ? static_cast<RTP::RtpStreamRecv::Listener*>(this->listener)
|
|
492
518
|
->OnRtpStreamNeedWorstRemoteFractionLost(this)
|
|
493
|
-
|
|
519
|
+
: 0;
|
|
494
520
|
|
|
495
521
|
if (worstRemoteFractionLost > 0)
|
|
496
522
|
{
|
|
@@ -562,13 +588,12 @@ namespace RTC
|
|
|
562
588
|
if (this->lastSenderReportTiming.has_value())
|
|
563
589
|
{
|
|
564
590
|
const auto& senderReportTiming = this->lastSenderReportTiming.value();
|
|
565
|
-
// Get delay in
|
|
566
|
-
|
|
567
|
-
static_cast<uint32_t>(this->shared->GetTimeMs() - senderReportTiming.receivedMs);
|
|
591
|
+
// Get delay in microseconds.
|
|
592
|
+
const int64_t delayUs = this->shared->GetTimeUs() - senderReportTiming.receivedAtUs;
|
|
568
593
|
// Express delay in units of 1/65536 seconds.
|
|
569
|
-
|
|
594
|
+
auto dlsr = static_cast<uint32_t>((delayUs / 1000000) << 16);
|
|
570
595
|
|
|
571
|
-
dlsr |= uint32_t
|
|
596
|
+
dlsr |= static_cast<uint32_t>(((delayUs % 1000000) * 65536) / 1000000);
|
|
572
597
|
|
|
573
598
|
report->SetDelaySinceLastSenderReport(dlsr);
|
|
574
599
|
report->SetLastSenderReport(senderReportTiming.compactNtp);
|
|
@@ -594,7 +619,7 @@ namespace RTC
|
|
|
594
619
|
return nullptr;
|
|
595
620
|
}
|
|
596
621
|
|
|
597
|
-
void RtpStreamRecv::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report)
|
|
622
|
+
void RtpStreamRecv::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report, int64_t receivedAtUs)
|
|
598
623
|
{
|
|
599
624
|
MS_TRACE();
|
|
600
625
|
|
|
@@ -609,8 +634,8 @@ namespace RTC
|
|
|
609
634
|
compactNtp += report->GetNtpFrac() >> 16;
|
|
610
635
|
|
|
611
636
|
this->lastSenderReportTiming = SenderReportTiming{
|
|
612
|
-
.compactNtp
|
|
613
|
-
.
|
|
637
|
+
.compactNtp = compactNtp,
|
|
638
|
+
.receivedAtUs = receivedAtUs,
|
|
614
639
|
};
|
|
615
640
|
|
|
616
641
|
Utils::Time::Ntp ntp{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
@@ -619,7 +644,7 @@ namespace RTC
|
|
|
619
644
|
ntp.fractions = report->GetNtpFrac();
|
|
620
645
|
|
|
621
646
|
this->lastSenderReportMapping = RTP::RtpStream::SenderReportMapping{
|
|
622
|
-
.
|
|
647
|
+
.ntpUs = Utils::Time::Ntp2TimeUs(ntp),
|
|
623
648
|
.ts = report->GetRtpTs(),
|
|
624
649
|
};
|
|
625
650
|
}
|
|
@@ -628,27 +653,28 @@ namespace RTC
|
|
|
628
653
|
UpdateScore();
|
|
629
654
|
}
|
|
630
655
|
|
|
631
|
-
void RtpStreamRecv::ReceiveRtxRtcpSenderReport(RTC::RTCP::SenderReport* report)
|
|
656
|
+
void RtpStreamRecv::ReceiveRtxRtcpSenderReport(RTC::RTCP::SenderReport* report, int64_t receivedAtUs)
|
|
632
657
|
{
|
|
633
658
|
MS_TRACE();
|
|
634
659
|
|
|
635
660
|
if (HasRtx())
|
|
636
661
|
{
|
|
637
|
-
this->rtxStream->ReceiveRtcpSenderReport(report);
|
|
662
|
+
this->rtxStream->ReceiveRtcpSenderReport(report, receivedAtUs);
|
|
638
663
|
}
|
|
639
664
|
}
|
|
640
665
|
|
|
641
|
-
void RtpStreamRecv::ReceiveRtcpXrDelaySinceLastRr(
|
|
666
|
+
void RtpStreamRecv::ReceiveRtcpXrDelaySinceLastRr(
|
|
667
|
+
RTC::RTCP::DelaySinceLastRr::SsrcInfo* ssrcInfo, int64_t receivedAtUs)
|
|
642
668
|
{
|
|
643
669
|
MS_TRACE();
|
|
644
670
|
|
|
645
671
|
/* Calculate RTT. */
|
|
646
672
|
|
|
647
|
-
// Get the NTP representation of the
|
|
648
|
-
|
|
649
|
-
auto ntp
|
|
673
|
+
// Get the NTP representation of the time at which the report arrived, which
|
|
674
|
+
// is what the round trip is measured against.
|
|
675
|
+
auto ntp = Utils::Time::TimeUs2Ntp(receivedAtUs + this->shared->GetNtpOffsetUs());
|
|
650
676
|
|
|
651
|
-
// Get the compact NTP representation of the
|
|
677
|
+
// Get the compact NTP representation of the arrival time.
|
|
652
678
|
uint32_t compactNtp = (ntp.seconds & 0x0000FFFF) << 16;
|
|
653
679
|
|
|
654
680
|
compactNtp |= (ntp.fractions & 0xFFFF0000) >> 16;
|
|
@@ -657,30 +683,29 @@ namespace RTC
|
|
|
657
683
|
const uint32_t dlrr = ssrcInfo->GetDelaySinceLastReceiverReport();
|
|
658
684
|
|
|
659
685
|
// RTT in 1/2^16 second fractions.
|
|
660
|
-
uint32_t
|
|
686
|
+
uint32_t rttCompactNtp{ 0 };
|
|
661
687
|
|
|
662
688
|
// If no Receiver Extended Report was received by the remote endpoint yet,
|
|
663
689
|
// ignore lastRr and dlrr values in the Sender Extended Report.
|
|
664
690
|
if (lastRr && dlrr && (compactNtp > dlrr + lastRr))
|
|
665
691
|
{
|
|
666
|
-
|
|
692
|
+
rttCompactNtp = compactNtp - dlrr - lastRr;
|
|
667
693
|
}
|
|
668
694
|
|
|
669
|
-
|
|
670
|
-
this->
|
|
671
|
-
this->rtt += (static_cast<float>(rtt & 0x0000FFFF) / 65536) * 1000;
|
|
695
|
+
this->rttMs = static_cast<float>(rttCompactNtp >> 16) * 1000;
|
|
696
|
+
this->rttMs += (static_cast<float>(rttCompactNtp & 0x0000FFFF) / 65536) * 1000;
|
|
672
697
|
|
|
673
698
|
// Avoid negative RTT value since it doesn't make sense.
|
|
674
|
-
this->
|
|
699
|
+
this->rttMs = std::max(this->rttMs, 0.0f);
|
|
675
700
|
|
|
676
701
|
// Tell it to the NackGenerator.
|
|
677
702
|
if (this->params.useNack)
|
|
678
703
|
{
|
|
679
|
-
this->nackGenerator->
|
|
704
|
+
this->nackGenerator->UpdateRttMs(static_cast<int64_t>(this->rttMs));
|
|
680
705
|
}
|
|
681
706
|
}
|
|
682
707
|
|
|
683
|
-
std::optional<
|
|
708
|
+
std::optional<int64_t> RtpStreamRecv::GetRemoteCaptureAtUsFromAbsCaptureTime(uint32_t ts) const
|
|
684
709
|
{
|
|
685
710
|
MS_TRACE();
|
|
686
711
|
|
|
@@ -691,11 +716,14 @@ namespace RTC
|
|
|
691
716
|
|
|
692
717
|
const auto& absCaptureTime = this->lastAbsCaptureTime.value();
|
|
693
718
|
|
|
694
|
-
return
|
|
695
|
-
absCaptureTime.
|
|
719
|
+
return InterpolateRemoteCaptureAtUs(
|
|
720
|
+
absCaptureTime.ntpUs,
|
|
721
|
+
absCaptureTime.ts,
|
|
722
|
+
ts,
|
|
723
|
+
RtpStreamRecv::MaxAbsCaptureTimeInterpolationMs * 1000);
|
|
696
724
|
}
|
|
697
725
|
|
|
698
|
-
std::optional<
|
|
726
|
+
std::optional<int64_t> RtpStreamRecv::GetRemoteCaptureAtUsFromSenderReport(uint32_t ts) const
|
|
699
727
|
{
|
|
700
728
|
MS_TRACE();
|
|
701
729
|
|
|
@@ -706,15 +734,15 @@ namespace RTC
|
|
|
706
734
|
|
|
707
735
|
const auto& senderReportMapping = this->lastSenderReportMapping.value();
|
|
708
736
|
|
|
709
|
-
return
|
|
710
|
-
senderReportMapping.
|
|
737
|
+
return InterpolateRemoteCaptureAtUs(
|
|
738
|
+
senderReportMapping.ntpUs,
|
|
711
739
|
senderReportMapping.ts,
|
|
712
740
|
ts,
|
|
713
|
-
RtpStreamRecv::MaxSenderReportInterpolationMs);
|
|
741
|
+
RtpStreamRecv::MaxSenderReportInterpolationMs * 1000);
|
|
714
742
|
}
|
|
715
743
|
|
|
716
|
-
std::optional<
|
|
717
|
-
|
|
744
|
+
std::optional<int64_t> RtpStreamRecv::InterpolateRemoteCaptureAtUs(
|
|
745
|
+
int64_t referenceNtpUs, uint32_t referenceTs, uint32_t ts, int64_t maxDistanceUs) const
|
|
718
746
|
{
|
|
719
747
|
MS_TRACE();
|
|
720
748
|
|
|
@@ -727,29 +755,29 @@ namespace RTC
|
|
|
727
755
|
|
|
728
756
|
// Distance in RTP timestamp units, taking wrap around into account.
|
|
729
757
|
const auto distanceTs = static_cast<int64_t>(static_cast<int32_t>(ts - referenceTs));
|
|
730
|
-
const int64_t
|
|
731
|
-
// NOTE: The negation is safe since `
|
|
758
|
+
const int64_t distanceUs = (distanceTs * 1000000) / static_cast<int64_t>(clockRate);
|
|
759
|
+
// NOTE: The negation is safe since `distanceUs` comes from a 32 bits
|
|
732
760
|
// distance scaled down by the clock rate.
|
|
733
|
-
const
|
|
761
|
+
const int64_t absDistanceUs = distanceUs < 0 ? -distanceUs : distanceUs;
|
|
734
762
|
|
|
735
|
-
if (
|
|
763
|
+
if (absDistanceUs > maxDistanceUs)
|
|
736
764
|
{
|
|
737
765
|
return std::nullopt;
|
|
738
766
|
}
|
|
739
767
|
|
|
740
|
-
const int64_t
|
|
768
|
+
const int64_t captureAtUs = referenceNtpUs + distanceUs;
|
|
741
769
|
|
|
742
770
|
// The reference does not map into a valid capture instant, so the remote
|
|
743
771
|
// endpoint is reporting nonsense.
|
|
744
|
-
if (
|
|
772
|
+
if (captureAtUs < 0)
|
|
745
773
|
{
|
|
746
774
|
MS_WARN_2TAGS(
|
|
747
|
-
rtp, rtcp, "invalid interpolated capture instant [
|
|
775
|
+
rtp, rtcp, "invalid interpolated capture instant [distanceUs:%" PRIi64 "]", distanceUs);
|
|
748
776
|
|
|
749
777
|
return std::nullopt;
|
|
750
778
|
}
|
|
751
779
|
|
|
752
|
-
return
|
|
780
|
+
return captureAtUs;
|
|
753
781
|
}
|
|
754
782
|
|
|
755
783
|
void RtpStreamRecv::RequestKeyFrame()
|
|
@@ -821,19 +849,28 @@ namespace RTC
|
|
|
821
849
|
}
|
|
822
850
|
}
|
|
823
851
|
|
|
824
|
-
void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp)
|
|
852
|
+
void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp, int64_t receivedAtUs)
|
|
825
853
|
{
|
|
826
854
|
MS_TRACE();
|
|
827
855
|
|
|
828
|
-
if (GetClockRate() ==
|
|
856
|
+
if (GetClockRate() == 0)
|
|
829
857
|
{
|
|
830
858
|
return;
|
|
831
859
|
}
|
|
832
860
|
|
|
861
|
+
// The arrival time expressed in the clock rate of the stream, which is
|
|
862
|
+
// the R of RFC 3550 section 6.4.1.
|
|
863
|
+
//
|
|
864
|
+
// NOTE: The seconds and the sub-second parts are converted separately
|
|
865
|
+
// because a single multiplication of the whole time by the clock rate
|
|
866
|
+
// would overflow on a long lived host.
|
|
867
|
+
const auto arrivalTs =
|
|
868
|
+
static_cast<uint32_t>((receivedAtUs / 1000000) * GetClockRate()) +
|
|
869
|
+
static_cast<uint32_t>(((receivedAtUs % 1000000) * GetClockRate()) / 1000000);
|
|
870
|
+
|
|
833
871
|
// NOTE: Based on https://github.com/versatica/mediasoup/issues/1018.
|
|
834
|
-
auto transit =
|
|
835
|
-
|
|
836
|
-
int d = transit - this->transit;
|
|
872
|
+
auto transit = static_cast<int>(arrivalTs - rtpTimestamp);
|
|
873
|
+
int d = transit - this->transit;
|
|
837
874
|
|
|
838
875
|
// First transit calculation, save and return.
|
|
839
876
|
if (this->transit == 0)
|
|
@@ -1003,6 +1040,34 @@ namespace RTC
|
|
|
1003
1040
|
|
|
1004
1041
|
ResetScore(0, /*notify*/ true);
|
|
1005
1042
|
}
|
|
1043
|
+
else if (timer == this->spatialLayersActivityCheckPeriodicTimer)
|
|
1044
|
+
{
|
|
1045
|
+
const int64_t nowMs = this->shared->GetTimeMs();
|
|
1046
|
+
|
|
1047
|
+
for (uint8_t spatialLayer{ 0 }; spatialLayer < GetSpatialLayers(); ++spatialLayer)
|
|
1048
|
+
{
|
|
1049
|
+
const bool isActive =
|
|
1050
|
+
this->transmissionCounter.GetSpatialLayerBitrate(nowMs, spatialLayer) > 0;
|
|
1051
|
+
|
|
1052
|
+
if (isActive == this->spatialLayersActivity[spatialLayer])
|
|
1053
|
+
{
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
this->spatialLayersActivity[spatialLayer] = isActive;
|
|
1058
|
+
|
|
1059
|
+
MS_DEBUG_2TAGS(
|
|
1060
|
+
rtp,
|
|
1061
|
+
svc,
|
|
1062
|
+
"spatial layer activity changed [ssrc:%" PRIu32 ", spatialLayer:%" PRIu8 ", isActive:%s]",
|
|
1063
|
+
GetSsrc(),
|
|
1064
|
+
spatialLayer,
|
|
1065
|
+
isActive ? "true" : "false");
|
|
1066
|
+
|
|
1067
|
+
static_cast<RTP::RtpStreamRecv::Listener*>(this->listener)
|
|
1068
|
+
->OnRtpStreamSpatialLayerActivityChanged(this, spatialLayer, isActive);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1006
1071
|
}
|
|
1007
1072
|
|
|
1008
1073
|
inline void RtpStreamRecv::OnNackGeneratorNackRequired(const std::vector<uint16_t>& seqNumbers)
|