mediasoup 3.26.0 → 3.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/node/lib/DataConsumer.js +1 -1
- package/node/lib/Router.js +1 -1
- package/node/lib/Transport.js +15 -15
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts +2 -6
- package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts.map +1 -1
- package/node/lib/fbs/rtp-parameters/encoding-mapping.js +7 -19
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.d.ts +4 -4
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +2 -2
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +3 -3
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/recv-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/recv-stats.js +3 -3
- package/node/lib/fbs/rtp-stream/send-stats.d.ts +5 -5
- package/node/lib/fbs/rtp-stream/send-stats.d.ts.map +1 -1
- package/node/lib/fbs/rtp-stream/send-stats.js +3 -3
- package/node/lib/fbs/transport/bwe-trace-info.d.ts +23 -23
- package/node/lib/fbs/transport/bwe-trace-info.d.ts.map +1 -1
- package/node/lib/fbs/transport/bwe-trace-info.js +15 -15
- package/node/lib/fbs/transport/options.d.ts +5 -5
- package/node/lib/fbs/transport/options.js +2 -2
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts +5 -5
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts.map +1 -1
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +3 -3
- package/node/lib/fbs/transport/stats.d.ts +38 -38
- package/node/lib/fbs/transport/stats.d.ts.map +1 -1
- package/node/lib/fbs/transport/stats.js +25 -25
- package/node/lib/ortc.d.ts +0 -1
- package/node/lib/ortc.d.ts.map +1 -1
- package/node/lib/ortc.js +1 -2
- package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/rtpParametersFbsUtils.js +2 -2
- package/package.json +9 -9
- package/worker/deps/libwebrtc/libwebrtc/call/rtp_transport_controller_send.cc +10 -10
- package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +6 -6
- package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc +7 -7
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +1 -1
- package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +1 -1
- package/worker/fbs/rtpParameters.fbs +1 -2
- package/worker/fbs/rtpStream.fbs +3 -3
- package/worker/fbs/transport.fbs +23 -23
- package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
- package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
- package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
- package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
- package/worker/fuzzer/src/fuzzer.cpp +4 -0
- package/worker/include/Channel/ChannelNotification.hpp +3 -3
- package/worker/include/Channel/ChannelRequest.hpp +1 -1
- package/worker/include/Channel/ChannelSocket.hpp +11 -0
- package/worker/include/DepLibUV.hpp +16 -33
- package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
- package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
- package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
- package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
- package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
- package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
- package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +101 -0
- package/worker/include/RTC/Consts.hpp +6 -6
- package/worker/include/RTC/Consumer.hpp +14 -12
- package/worker/include/RTC/DataConsumer.hpp +3 -3
- package/worker/include/RTC/DataProducer.hpp +3 -3
- package/worker/include/RTC/DtlsTransport.hpp +5 -2
- package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
- package/worker/include/RTC/ICE/IceServer.hpp +3 -3
- package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
- package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
- package/worker/include/RTC/NackGenerator.hpp +12 -12
- package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/PipeTransport.hpp +18 -5
- package/worker/include/RTC/PlainTransport.hpp +18 -5
- package/worker/include/RTC/PortManager.hpp +4 -4
- package/worker/include/RTC/Producer.hpp +21 -12
- package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
- package/worker/include/RTC/RTCP/Bye.hpp +2 -2
- package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
- package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
- package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
- package/worker/include/RTC/RTCP/Packet.hpp +3 -3
- package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
- package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
- package/worker/include/RTC/RTCP/XR.hpp +2 -2
- package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
- package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
- package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
- package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
- package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
- package/worker/include/RTC/RTP/Packet.hpp +13 -13
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
- package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
- package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
- package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
- package/worker/include/RTC/RateCalculator.hpp +50 -44
- package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
- package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
- package/worker/include/RTC/Router.hpp +6 -0
- package/worker/include/RTC/RtcLogger.hpp +1 -1
- package/worker/include/RTC/RtpDictionaries.hpp +10 -10
- package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +2 -2
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
- package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
- package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
- package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +1 -1
- package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
- package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
- package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
- package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
- package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
- package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
- package/worker/include/RTC/SctpDictionaries.hpp +3 -3
- package/worker/include/RTC/Serializable.hpp +1 -1
- package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
- package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
- package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
- package/worker/include/RTC/TcpConnection.hpp +9 -3
- package/worker/include/RTC/TcpServer.hpp +3 -0
- package/worker/include/RTC/Transport.hpp +52 -45
- package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
- package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
- package/worker/include/RTC/TrendCalculator.hpp +5 -5
- package/worker/include/RTC/UdpSocket.hpp +11 -2
- package/worker/include/RTC/WebRtcServer.hpp +20 -5
- package/worker/include/RTC/WebRtcTransport.hpp +35 -10
- package/worker/include/Settings.hpp +4 -2
- package/worker/include/Shared.hpp +5 -20
- package/worker/include/SharedInterface.hpp +6 -28
- package/worker/include/Utils.hpp +40 -21
- package/worker/include/common.hpp +4 -0
- package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
- package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
- package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
- package/worker/include/handles/TcpServerHandle.hpp +1 -1
- package/worker/include/handles/TimerHandle.hpp +15 -9
- package/worker/include/handles/TimerHandleInterface.hpp +10 -4
- package/worker/include/handles/UdpSocketHandle.hpp +3 -3
- package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
- package/worker/meson.build +81 -36
- package/worker/meson_options.txt +1 -0
- package/worker/mocks/include/MockShared.hpp +24 -23
- package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
- package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
- package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
- package/worker/mocks/src/MockShared.cpp +51 -5
- package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
- package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
- package/worker/scripts/clang-scripts.mjs +2 -2
- package/worker/src/Channel/ChannelNotification.cpp +5 -6
- package/worker/src/Channel/ChannelSocket.cpp +20 -2
- package/worker/src/DepLibUV.cpp +4 -5
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
- package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
- package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
- package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
- package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
- package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +233 -0
- package/worker/src/RTC/Consumer.cpp +48 -35
- package/worker/src/RTC/DataConsumer.cpp +4 -4
- package/worker/src/RTC/DataProducer.cpp +3 -3
- package/worker/src/RTC/DirectTransport.cpp +2 -2
- package/worker/src/RTC/DtlsTransport.cpp +14 -11
- package/worker/src/RTC/ICE/IceServer.cpp +2 -2
- package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
- package/worker/src/RTC/NackGenerator.cpp +12 -12
- package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
- package/worker/src/RTC/PipeTransport.cpp +16 -13
- package/worker/src/RTC/PlainTransport.cpp +25 -16
- package/worker/src/RTC/Producer.cpp +50 -36
- package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
- package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
- package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
- package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
- package/worker/src/RTC/RTP/Packet.cpp +9 -10
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
- package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
- package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
- package/worker/src/RTC/RateCalculator.cpp +99 -136
- package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
- package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
- package/worker/src/RTC/Router.cpp +18 -1
- package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
- package/worker/src/RTC/SCTP/association/Association.cpp +131 -102
- package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
- package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +16 -13
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
- package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
- package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
- package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
- package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
- package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
- package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
- package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
- package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
- package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
- package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
- package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
- package/worker/src/RTC/TcpConnection.cpp +9 -3
- package/worker/src/RTC/TcpServer.cpp +7 -2
- package/worker/src/RTC/Transport.cpp +242 -302
- package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
- package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
- package/worker/src/RTC/TrendCalculator.cpp +3 -3
- package/worker/src/RTC/UdpSocket.cpp +14 -3
- package/worker/src/RTC/WebRtcServer.cpp +20 -14
- package/worker/src/RTC/WebRtcTransport.cpp +35 -30
- package/worker/src/Settings.cpp +10 -0
- package/worker/src/Shared.cpp +2 -2
- package/worker/src/Utils/Crypto.cpp +2 -2
- package/worker/src/Worker.cpp +5 -1
- package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
- package/worker/src/handles/TimerHandle.cpp +74 -25
- package/worker/src/lib.cpp +6 -0
- package/worker/tasks.py +171 -44
- package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
- package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
- package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
- package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
- package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +137 -0
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
- package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
- package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +17 -13
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
- package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
- package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
- package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
- package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
- package/worker/test/src/RTC/TestConsumer.cpp +8 -3
- package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
- package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
- package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
- package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
- package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
- package/worker/test/src/TestDepLibUV.cpp +19 -0
- package/worker/test/src/Utils/TestTime.cpp +57 -26
- package/worker/test/src/testHelpers.cpp +1 -1
- package/worker/test/src/tests.cpp +6 -0
- package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
- package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::BWE::TrendlineEstimator"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/BWE/TrendlineEstimator.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
#include <cmath>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace BWE
|
|
11
|
+
{
|
|
12
|
+
/* Static. */
|
|
13
|
+
|
|
14
|
+
// Coefficient of the exponential filter applied to the accumulated delay.
|
|
15
|
+
static constexpr double SmoothingCoef{ 0.9 };
|
|
16
|
+
// Gain applied to the slope before comparing it against the threshold.
|
|
17
|
+
static constexpr double ThresholdGain{ 4.0 };
|
|
18
|
+
// Number of deltas at which the modified trend stops being scaled down.
|
|
19
|
+
static constexpr int MinNumDeltas{ 60 };
|
|
20
|
+
// Maximum value of the delta counter.
|
|
21
|
+
static constexpr int DeltaCounterMax{ 1000 };
|
|
22
|
+
// Time the trend must stay above the threshold before declaring overuse.
|
|
23
|
+
static constexpr double OverusingTimeThresholdMs{ 10 };
|
|
24
|
+
// Rates at which the threshold adapts upwards and downwards, per millisecond.
|
|
25
|
+
static constexpr double ThresholdUpCoef{ 0.0087 };
|
|
26
|
+
static constexpr double ThresholdDownCoef{ 0.039 };
|
|
27
|
+
// Bounds of the adaptive threshold.
|
|
28
|
+
static constexpr double ThresholdMin{ 6.0 };
|
|
29
|
+
static constexpr double ThresholdMax{ 600.0 };
|
|
30
|
+
// Distance from the threshold beyond which it stops adapting, so that a
|
|
31
|
+
// sudden capacity drop doesn't drag it along.
|
|
32
|
+
//
|
|
33
|
+
// NOTE: It is not a time, being compared against the trend, which is a slope
|
|
34
|
+
// and hence dimensionless.
|
|
35
|
+
static constexpr double MaxAdaptOffset{ 15.0 };
|
|
36
|
+
// Maximum time step used when adapting the threshold.
|
|
37
|
+
static constexpr int64_t MaxThresholdUpdateDeltaMs{ 100 };
|
|
38
|
+
|
|
39
|
+
/* Instance methods. */
|
|
40
|
+
|
|
41
|
+
TrendlineEstimator::TrendlineEstimator(size_t windowSize) : windowSize(windowSize)
|
|
42
|
+
{
|
|
43
|
+
MS_TRACE();
|
|
44
|
+
|
|
45
|
+
MS_ASSERT(windowSize >= 2, "window size must be at least 2 [windowSize:%zu]", windowSize);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void TrendlineEstimator::Update(int64_t sendDeltaUs, int64_t arrivalDeltaUs, int64_t arrivalTimeUs)
|
|
49
|
+
{
|
|
50
|
+
MS_TRACE();
|
|
51
|
+
|
|
52
|
+
const auto deltaUs = static_cast<double>(arrivalDeltaUs - sendDeltaUs);
|
|
53
|
+
|
|
54
|
+
this->numOfDeltas = std::min(this->numOfDeltas + 1, DeltaCounterMax);
|
|
55
|
+
|
|
56
|
+
if (!this->firstArrivalTimeUs.has_value())
|
|
57
|
+
{
|
|
58
|
+
this->firstArrivalTimeUs = arrivalTimeUs;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Exponential backoff filter.
|
|
62
|
+
this->accumulatedDelayUs += deltaUs;
|
|
63
|
+
this->smoothedDelayUs =
|
|
64
|
+
(SmoothingCoef * this->smoothedDelayUs) + ((1 - SmoothingCoef) * this->accumulatedDelayUs);
|
|
65
|
+
|
|
66
|
+
// Maintain the samples window. A group may arrive before the first one of
|
|
67
|
+
// the window did, in which case the regression just gets a negative x.
|
|
68
|
+
const auto elapsedUs = static_cast<double>(arrivalTimeUs - this->firstArrivalTimeUs.value());
|
|
69
|
+
|
|
70
|
+
this->delayHist.push_back({ elapsedUs, this->smoothedDelayUs });
|
|
71
|
+
|
|
72
|
+
if (this->delayHist.size() > this->windowSize)
|
|
73
|
+
{
|
|
74
|
+
this->delayHist.pop_front();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Simple linear regression. The slope can be seen as an estimate of
|
|
78
|
+
// (sendRate - capacity) / capacity:
|
|
79
|
+
// 0 < trend < 1 -> the delay increases, queues are filling up.
|
|
80
|
+
// trend == 0 -> the delay does not change.
|
|
81
|
+
// trend < 0 -> the delay decreases, queues are being emptied.
|
|
82
|
+
double trend = this->prevTrend;
|
|
83
|
+
|
|
84
|
+
if (this->delayHist.size() == this->windowSize)
|
|
85
|
+
{
|
|
86
|
+
// Keep the previous trend if the line cannot be fitted.
|
|
87
|
+
trend = GetLinearFitSlope().value_or(trend);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
Detect(trend, static_cast<double>(sendDeltaUs), arrivalTimeUs);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
std::optional<double> TrendlineEstimator::GetLinearFitSlope() const
|
|
94
|
+
{
|
|
95
|
+
MS_TRACE();
|
|
96
|
+
|
|
97
|
+
MS_ASSERT(
|
|
98
|
+
this->delayHist.size() >= 2,
|
|
99
|
+
"not enough samples to fit a line [samples:%zu]",
|
|
100
|
+
this->delayHist.size());
|
|
101
|
+
|
|
102
|
+
// Compute the "center of mass".
|
|
103
|
+
double sumX{ 0 };
|
|
104
|
+
double sumY{ 0 };
|
|
105
|
+
|
|
106
|
+
for (const auto& sample : this->delayHist)
|
|
107
|
+
{
|
|
108
|
+
sumX += sample.arrivalTimeUs;
|
|
109
|
+
sumY += sample.smoothedDelayUs;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const double avgX = sumX / this->delayHist.size();
|
|
113
|
+
const double avgY = sumY / this->delayHist.size();
|
|
114
|
+
|
|
115
|
+
// Compute the slope as sum((x - avgX) * (y - avgY)) / sum((x - avgX)^2).
|
|
116
|
+
double numerator{ 0 };
|
|
117
|
+
double denominator{ 0 };
|
|
118
|
+
|
|
119
|
+
for (const auto& sample : this->delayHist)
|
|
120
|
+
{
|
|
121
|
+
const double x = sample.arrivalTimeUs - avgX;
|
|
122
|
+
const double y = sample.smoothedDelayUs - avgY;
|
|
123
|
+
|
|
124
|
+
numerator += x * y;
|
|
125
|
+
denominator += x * x;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// The line cannot be fitted when every sample arrived at the very same
|
|
129
|
+
// time.
|
|
130
|
+
if (denominator == 0)
|
|
131
|
+
{
|
|
132
|
+
return std::nullopt;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return numerator / denominator;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void TrendlineEstimator::Detect(double trend, double sendDeltaUs, int64_t arrivalTimeUs)
|
|
139
|
+
{
|
|
140
|
+
MS_TRACE();
|
|
141
|
+
|
|
142
|
+
if (this->numOfDeltas < 2)
|
|
143
|
+
{
|
|
144
|
+
this->state = Types::BandwidthUsage::NORMAL;
|
|
145
|
+
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Scale the trend down while there are few deltas, so that the estimator
|
|
150
|
+
// doesn't react to a couple of samples.
|
|
151
|
+
const double modifiedTrend = std::min(this->numOfDeltas, MinNumDeltas) * trend * ThresholdGain;
|
|
152
|
+
|
|
153
|
+
if (modifiedTrend > this->threshold)
|
|
154
|
+
{
|
|
155
|
+
if (!this->timeOverUsingUs.has_value())
|
|
156
|
+
{
|
|
157
|
+
// Initialize the timer assuming that we have been over-using half of
|
|
158
|
+
// the time since the previous sample.
|
|
159
|
+
this->timeOverUsingUs = sendDeltaUs / 2;
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
{
|
|
163
|
+
this->timeOverUsingUs = this->timeOverUsingUs.value() + sendDeltaUs;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this->overuseCounter++;
|
|
167
|
+
|
|
168
|
+
// Only declare overuse once the condition has persisted for long enough,
|
|
169
|
+
// over more than a single sample, and while the trend is not decreasing
|
|
170
|
+
// already. This is what filters out isolated jitter spikes.
|
|
171
|
+
if (this->timeOverUsingUs.value() / 1000.0 > OverusingTimeThresholdMs && this->overuseCounter > 1)
|
|
172
|
+
{
|
|
173
|
+
if (trend >= this->prevTrend)
|
|
174
|
+
{
|
|
175
|
+
this->timeOverUsingUs = 0;
|
|
176
|
+
this->overuseCounter = 0;
|
|
177
|
+
this->state = Types::BandwidthUsage::OVERUSING;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (modifiedTrend < -this->threshold)
|
|
182
|
+
{
|
|
183
|
+
this->timeOverUsingUs.reset();
|
|
184
|
+
this->overuseCounter = 0;
|
|
185
|
+
this->state = Types::BandwidthUsage::UNDERUSING;
|
|
186
|
+
}
|
|
187
|
+
else
|
|
188
|
+
{
|
|
189
|
+
this->timeOverUsingUs.reset();
|
|
190
|
+
this->overuseCounter = 0;
|
|
191
|
+
this->state = Types::BandwidthUsage::NORMAL;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this->prevTrend = trend;
|
|
195
|
+
|
|
196
|
+
UpdateThreshold(modifiedTrend, arrivalTimeUs);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
void TrendlineEstimator::UpdateThreshold(double modifiedTrend, int64_t arrivalTimeUs)
|
|
200
|
+
{
|
|
201
|
+
MS_TRACE();
|
|
202
|
+
|
|
203
|
+
if (!this->lastThresholdUpdateAtUs.has_value())
|
|
204
|
+
{
|
|
205
|
+
this->lastThresholdUpdateAtUs = arrivalTimeUs;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Avoid adapting the threshold to big latency spikes, caused for instance
|
|
209
|
+
// by a sudden capacity drop.
|
|
210
|
+
if (std::fabs(modifiedTrend) > this->threshold + MaxAdaptOffset)
|
|
211
|
+
{
|
|
212
|
+
this->lastThresholdUpdateAtUs = arrivalTimeUs;
|
|
213
|
+
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// The threshold falls faster than it rises, so that it recovers quickly
|
|
218
|
+
// once the network calms down.
|
|
219
|
+
const double coef =
|
|
220
|
+
std::fabs(modifiedTrend) < this->threshold ? ThresholdDownCoef : ThresholdUpCoef;
|
|
221
|
+
// NOTE: The coefficients above are rates per millisecond, so the step is
|
|
222
|
+
// expressed in those units no matter that the instants are microseconds.
|
|
223
|
+
const double elapsedMs = std::min(
|
|
224
|
+
static_cast<double>(arrivalTimeUs - this->lastThresholdUpdateAtUs.value()) / 1000.0,
|
|
225
|
+
static_cast<double>(MaxThresholdUpdateDeltaMs));
|
|
226
|
+
|
|
227
|
+
this->threshold += coef * (std::fabs(modifiedTrend) - this->threshold) * elapsedMs;
|
|
228
|
+
this->threshold = std::clamp(this->threshold, ThresholdMin, ThresholdMax);
|
|
229
|
+
|
|
230
|
+
this->lastThresholdUpdateAtUs = arrivalTimeUs;
|
|
231
|
+
}
|
|
232
|
+
} // namespace BWE
|
|
233
|
+
} // namespace RTC
|
|
@@ -186,11 +186,11 @@ namespace RTC
|
|
|
186
186
|
// Set the RTCP report generation interval.
|
|
187
187
|
if (this->kind == RTC::Media::Kind::AUDIO)
|
|
188
188
|
{
|
|
189
|
-
this->
|
|
189
|
+
this->maxRtcpIntervalMs = RTC::RTCP::MaxAudioIntervalMs;
|
|
190
190
|
}
|
|
191
191
|
else
|
|
192
192
|
{
|
|
193
|
-
this->
|
|
193
|
+
this->maxRtcpIntervalMs = RTC::RTCP::MaxVideoIntervalMs;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
auto& encoding = this->rtpParameters.encodings[0];
|
|
@@ -238,7 +238,7 @@ namespace RTC
|
|
|
238
238
|
if (
|
|
239
239
|
mediaCodec->mimeType.type == RTC::RtpCodecMimeType::Type::AUDIO &&
|
|
240
240
|
(mediaCodec->mimeType.subtype == RTC::RtpCodecMimeType::Subtype::OPUS ||
|
|
241
|
-
|
|
241
|
+
mediaCodec->mimeType.subtype == RTC::RtpCodecMimeType::Subtype::MULTIOPUS))
|
|
242
242
|
{
|
|
243
243
|
RTC::RTP::Codecs::EncodingContext::Params params;
|
|
244
244
|
|
|
@@ -556,7 +556,7 @@ namespace RTC
|
|
|
556
556
|
RTC::RtpParameters::TypeToFbs(this->type),
|
|
557
557
|
this->producerId.c_str(),
|
|
558
558
|
this->kind == RTC::Media::Kind::AUDIO ? FBS::RtpParameters::MediaKind::AUDIO
|
|
559
|
-
|
|
559
|
+
: FBS::RtpParameters::MediaKind::VIDEO,
|
|
560
560
|
rtpParameters,
|
|
561
561
|
&consumableRtpEncodings,
|
|
562
562
|
&supportedCodecPayloadTypes,
|
|
@@ -984,6 +984,15 @@ namespace RTC
|
|
|
984
984
|
this->producerStreamManager->ProducerRtcpSenderReport(rtpStream, first);
|
|
985
985
|
}
|
|
986
986
|
|
|
987
|
+
void Consumer::ProducerSpatialLayerActivityChanged(
|
|
988
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint8_t spatialLayer, bool isActive)
|
|
989
|
+
{
|
|
990
|
+
MS_TRACE();
|
|
991
|
+
|
|
992
|
+
this->producerStreamManager->ProducerSpatialLayerActivityChanged(
|
|
993
|
+
rtpStream, spatialLayer, isActive);
|
|
994
|
+
}
|
|
995
|
+
|
|
987
996
|
// The caller (Router) is supposed to proceed with the deletion of this Consumer
|
|
988
997
|
// right after calling this method. Otherwise ugly things may happen.
|
|
989
998
|
void Consumer::ProducerClosed()
|
|
@@ -1020,7 +1029,7 @@ namespace RTC
|
|
|
1020
1029
|
return this->priority;
|
|
1021
1030
|
}
|
|
1022
1031
|
|
|
1023
|
-
|
|
1032
|
+
int64_t Consumer::IncreaseLayer(int64_t bitrate, bool considerLoss)
|
|
1024
1033
|
{
|
|
1025
1034
|
MS_TRACE();
|
|
1026
1035
|
|
|
@@ -1030,7 +1039,7 @@ namespace RTC
|
|
|
1030
1039
|
// Pipe does not play the BWE game.
|
|
1031
1040
|
if (this->pipe)
|
|
1032
1041
|
{
|
|
1033
|
-
return
|
|
1042
|
+
return 0;
|
|
1034
1043
|
}
|
|
1035
1044
|
|
|
1036
1045
|
float lossPercentage{ 0.0f };
|
|
@@ -1042,7 +1051,7 @@ namespace RTC
|
|
|
1042
1051
|
lossPercentage = rtpStream->GetLossPercentage();
|
|
1043
1052
|
}
|
|
1044
1053
|
|
|
1045
|
-
|
|
1054
|
+
const int64_t nowMs = this->shared->GetTimeMs();
|
|
1046
1055
|
|
|
1047
1056
|
return this->producerStreamManager->IncreaseLayer(bitrate, considerLoss, lossPercentage, nowMs);
|
|
1048
1057
|
}
|
|
@@ -1065,7 +1074,7 @@ namespace RTC
|
|
|
1065
1074
|
this->producerStreamManager->ApplyLayers(rtpStream->GetActiveMs());
|
|
1066
1075
|
}
|
|
1067
1076
|
|
|
1068
|
-
|
|
1077
|
+
int64_t Consumer::GetDesiredBitrate() const
|
|
1069
1078
|
{
|
|
1070
1079
|
MS_TRACE();
|
|
1071
1080
|
|
|
@@ -1074,21 +1083,22 @@ namespace RTC
|
|
|
1074
1083
|
// Pipe does not play the BWE game.
|
|
1075
1084
|
if (this->pipe)
|
|
1076
1085
|
{
|
|
1077
|
-
return
|
|
1086
|
+
return 0;
|
|
1078
1087
|
}
|
|
1079
1088
|
|
|
1080
1089
|
// Audio does not play the BWE game.
|
|
1081
1090
|
if (this->kind != RTC::Media::Kind::VIDEO)
|
|
1082
1091
|
{
|
|
1083
|
-
return
|
|
1092
|
+
return 0;
|
|
1084
1093
|
}
|
|
1085
1094
|
|
|
1086
1095
|
if (!IsActive())
|
|
1087
1096
|
{
|
|
1088
|
-
return
|
|
1097
|
+
return 0;
|
|
1089
1098
|
}
|
|
1090
1099
|
|
|
1091
|
-
|
|
1100
|
+
const int64_t nowMs = this->shared->GetTimeMs();
|
|
1101
|
+
|
|
1092
1102
|
auto desiredBitrate = this->producerStreamManager->GetDesiredBitrate(nowMs);
|
|
1093
1103
|
|
|
1094
1104
|
// If consumer.rtpParameters.encodings[0].maxBitrate was given and it's
|
|
@@ -1356,22 +1366,24 @@ namespace RTC
|
|
|
1356
1366
|
}
|
|
1357
1367
|
}
|
|
1358
1368
|
|
|
1359
|
-
bool Consumer::GetRtcp(RTC::RTCP::CompoundPacket* packet,
|
|
1369
|
+
bool Consumer::GetRtcp(RTC::RTCP::CompoundPacket* packet, int64_t nowUs)
|
|
1360
1370
|
{
|
|
1361
1371
|
MS_TRACE();
|
|
1362
1372
|
|
|
1373
|
+
// NOTE: The interval is in milliseconds, being it given to a timer, so the
|
|
1374
|
+
// elapsed time is truncated here.
|
|
1375
|
+
const int64_t elapsedMs = (nowUs - this->lastRtcpSentAtUs) / 1000;
|
|
1376
|
+
|
|
1363
1377
|
// Special condition for pipe consumer since this method will be called in a
|
|
1364
1378
|
// loop for each stream.
|
|
1365
1379
|
if (this->pipe)
|
|
1366
1380
|
{
|
|
1367
|
-
if (
|
|
1368
|
-
nowMs != this->lastRtcpSentTime &&
|
|
1369
|
-
static_cast<float>((nowMs - this->lastRtcpSentTime) * 1.15) < this->maxRtcpInterval)
|
|
1381
|
+
if (nowUs != this->lastRtcpSentAtUs && static_cast<float>(elapsedMs * 1.15) < this->maxRtcpIntervalMs)
|
|
1370
1382
|
{
|
|
1371
1383
|
return true;
|
|
1372
1384
|
}
|
|
1373
1385
|
}
|
|
1374
|
-
else if (static_cast<float>(
|
|
1386
|
+
else if (static_cast<float>(elapsedMs * 1.15) < this->maxRtcpIntervalMs)
|
|
1375
1387
|
{
|
|
1376
1388
|
return true;
|
|
1377
1389
|
}
|
|
@@ -1382,7 +1394,7 @@ namespace RTC
|
|
|
1382
1394
|
|
|
1383
1395
|
for (auto* rtpStream : this->rtpStreams)
|
|
1384
1396
|
{
|
|
1385
|
-
auto* report = rtpStream->GetRtcpSenderReport(
|
|
1397
|
+
auto* report = rtpStream->GetRtcpSenderReport(nowUs);
|
|
1386
1398
|
|
|
1387
1399
|
if (!report)
|
|
1388
1400
|
{
|
|
@@ -1395,7 +1407,7 @@ namespace RTC
|
|
|
1395
1407
|
auto* sdesChunk = rtpStream->GetRtcpSdesChunk();
|
|
1396
1408
|
sdesChunks.push_back(sdesChunk);
|
|
1397
1409
|
|
|
1398
|
-
auto* delaySinceLastRrSsrcInfo = rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(
|
|
1410
|
+
auto* delaySinceLastRrSsrcInfo = rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowUs);
|
|
1399
1411
|
|
|
1400
1412
|
if (delaySinceLastRrSsrcInfo)
|
|
1401
1413
|
{
|
|
@@ -1409,7 +1421,7 @@ namespace RTC
|
|
|
1409
1421
|
return false;
|
|
1410
1422
|
}
|
|
1411
1423
|
|
|
1412
|
-
this->
|
|
1424
|
+
this->lastRtcpSentAtUs = nowUs;
|
|
1413
1425
|
|
|
1414
1426
|
return true;
|
|
1415
1427
|
}
|
|
@@ -1512,26 +1524,27 @@ namespace RTC
|
|
|
1512
1524
|
}
|
|
1513
1525
|
}
|
|
1514
1526
|
|
|
1515
|
-
void Consumer::ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report)
|
|
1527
|
+
void Consumer::ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report, int64_t receivedAtUs)
|
|
1516
1528
|
{
|
|
1517
1529
|
MS_TRACE();
|
|
1518
1530
|
|
|
1519
1531
|
auto* rtpStream = this->mapSsrcRtpStream.at(report->GetSsrc());
|
|
1520
1532
|
|
|
1521
|
-
rtpStream->ReceiveRtcpReceiverReport(report);
|
|
1533
|
+
rtpStream->ReceiveRtcpReceiverReport(report, receivedAtUs);
|
|
1522
1534
|
}
|
|
1523
1535
|
|
|
1524
|
-
void Consumer::ReceiveRtcpXrReceiverReferenceTime(
|
|
1536
|
+
void Consumer::ReceiveRtcpXrReceiverReferenceTime(
|
|
1537
|
+
RTC::RTCP::ReceiverReferenceTime* report, int64_t receivedAtUs)
|
|
1525
1538
|
{
|
|
1526
1539
|
MS_TRACE();
|
|
1527
1540
|
|
|
1528
1541
|
for (auto* rtpStream : this->rtpStreams)
|
|
1529
1542
|
{
|
|
1530
|
-
rtpStream->ReceiveRtcpXrReceiverReferenceTime(report);
|
|
1543
|
+
rtpStream->ReceiveRtcpXrReceiverReferenceTime(report, receivedAtUs);
|
|
1531
1544
|
}
|
|
1532
1545
|
}
|
|
1533
1546
|
|
|
1534
|
-
|
|
1547
|
+
int64_t Consumer::GetTransmissionRate(int64_t nowMs)
|
|
1535
1548
|
{
|
|
1536
1549
|
MS_TRACE();
|
|
1537
1550
|
|
|
@@ -1540,7 +1553,7 @@ namespace RTC
|
|
|
1540
1553
|
return 0u;
|
|
1541
1554
|
}
|
|
1542
1555
|
|
|
1543
|
-
|
|
1556
|
+
int64_t rate{ 0 };
|
|
1544
1557
|
|
|
1545
1558
|
for (auto* rtpStream : this->rtpStreams)
|
|
1546
1559
|
{
|
|
@@ -1550,18 +1563,18 @@ namespace RTC
|
|
|
1550
1563
|
return rate;
|
|
1551
1564
|
}
|
|
1552
1565
|
|
|
1553
|
-
float Consumer::
|
|
1566
|
+
float Consumer::GetRttMs() const
|
|
1554
1567
|
{
|
|
1555
1568
|
MS_TRACE();
|
|
1556
1569
|
|
|
1557
|
-
float
|
|
1570
|
+
float rttMs{ 0 };
|
|
1558
1571
|
|
|
1559
1572
|
for (auto* rtpStream : this->rtpStreams)
|
|
1560
1573
|
{
|
|
1561
|
-
|
|
1574
|
+
rttMs = std::max(rtpStream->GetRttMs(), rttMs);
|
|
1562
1575
|
}
|
|
1563
1576
|
|
|
1564
|
-
return
|
|
1577
|
+
return rttMs;
|
|
1565
1578
|
}
|
|
1566
1579
|
|
|
1567
1580
|
void Consumer::UserOnTransportConnected()
|
|
@@ -1837,7 +1850,7 @@ namespace RTC
|
|
|
1837
1850
|
auto notification = FBS::Consumer::CreateTraceNotification(
|
|
1838
1851
|
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
1839
1852
|
FBS::Consumer::TraceEventType::KEYFRAME,
|
|
1840
|
-
this->shared->GetTimeMs(),
|
|
1853
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
1841
1854
|
FBS::Common::TraceDirection::DIRECTION_OUT,
|
|
1842
1855
|
FBS::Consumer::TraceInfo::KeyFrameTraceInfo,
|
|
1843
1856
|
traceInfo.Union());
|
|
@@ -1853,7 +1866,7 @@ namespace RTC
|
|
|
1853
1866
|
auto notification = FBS::Consumer::CreateTraceNotification(
|
|
1854
1867
|
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
1855
1868
|
FBS::Consumer::TraceEventType::RTP,
|
|
1856
|
-
this->shared->GetTimeMs(),
|
|
1869
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
1857
1870
|
FBS::Common::TraceDirection::DIRECTION_OUT,
|
|
1858
1871
|
FBS::Consumer::TraceInfo::RtpTraceInfo,
|
|
1859
1872
|
traceInfo.Union());
|
|
@@ -1877,7 +1890,7 @@ namespace RTC
|
|
|
1877
1890
|
auto notification = FBS::Consumer::CreateTraceNotification(
|
|
1878
1891
|
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
1879
1892
|
FBS::Consumer::TraceEventType::PLI,
|
|
1880
|
-
this->shared->GetTimeMs(),
|
|
1893
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
1881
1894
|
FBS::Common::TraceDirection::DIRECTION_IN,
|
|
1882
1895
|
FBS::Consumer::TraceInfo::PliTraceInfo,
|
|
1883
1896
|
traceInfo.Union());
|
|
@@ -1900,7 +1913,7 @@ namespace RTC
|
|
|
1900
1913
|
auto notification = FBS::Consumer::CreateTraceNotification(
|
|
1901
1914
|
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
1902
1915
|
FBS::Consumer::TraceEventType::FIR,
|
|
1903
|
-
this->shared->GetTimeMs(),
|
|
1916
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
1904
1917
|
FBS::Common::TraceDirection::DIRECTION_IN,
|
|
1905
1918
|
FBS::Consumer::TraceInfo::FirTraceInfo,
|
|
1906
1919
|
traceInfo.Union());
|
|
@@ -1920,7 +1933,7 @@ namespace RTC
|
|
|
1920
1933
|
auto notification = FBS::Consumer::CreateTraceNotification(
|
|
1921
1934
|
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
1922
1935
|
FBS::Consumer::TraceEventType::NACK,
|
|
1923
|
-
this->shared->GetTimeMs(),
|
|
1936
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
1924
1937
|
FBS::Common::TraceDirection::DIRECTION_IN);
|
|
1925
1938
|
|
|
1926
1939
|
EmitTraceEvent(notification);
|
|
@@ -129,7 +129,7 @@ namespace RTC
|
|
|
129
129
|
this->id.c_str(),
|
|
130
130
|
this->dataProducerId.c_str(),
|
|
131
131
|
this->type == DataConsumer::Type::SCTP ? FBS::DataConsumer::Type::SCTP
|
|
132
|
-
|
|
132
|
+
: FBS::DataConsumer::Type::DIRECT,
|
|
133
133
|
sctpStreamParameters,
|
|
134
134
|
this->label.c_str(),
|
|
135
135
|
this->protocol.c_str(),
|
|
@@ -152,7 +152,7 @@ namespace RTC
|
|
|
152
152
|
return FBS::DataConsumer::CreateGetStatsResponseDirect(
|
|
153
153
|
builder,
|
|
154
154
|
// timestamp.
|
|
155
|
-
this->shared->GetTimeMs(),
|
|
155
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
156
156
|
// label.
|
|
157
157
|
this->label.c_str(),
|
|
158
158
|
// protocol.
|
|
@@ -293,8 +293,8 @@ namespace RTC
|
|
|
293
293
|
|
|
294
294
|
this->listener->OnDataConsumerNeedBufferedAmount(this, bufferedAmount);
|
|
295
295
|
|
|
296
|
-
auto responseOffset =
|
|
297
|
-
request->GetBufferBuilder(), bufferedAmount);
|
|
296
|
+
auto responseOffset =
|
|
297
|
+
FBS::DataConsumer::CreateSendResponse(request->GetBufferBuilder(), bufferedAmount);
|
|
298
298
|
|
|
299
299
|
request->Accept(FBS::Response::Body::DataConsumer_SendResponse, responseOffset);
|
|
300
300
|
}
|
|
@@ -92,7 +92,7 @@ namespace RTC
|
|
|
92
92
|
builder,
|
|
93
93
|
this->id.c_str(),
|
|
94
94
|
this->type == DataProducer::Type::SCTP ? FBS::DataProducer::Type::SCTP
|
|
95
|
-
|
|
95
|
+
: FBS::DataProducer::Type::DIRECT,
|
|
96
96
|
sctpStreamParametersOffset,
|
|
97
97
|
this->label.c_str(),
|
|
98
98
|
this->protocol.c_str(),
|
|
@@ -107,7 +107,7 @@ namespace RTC
|
|
|
107
107
|
return FBS::DataProducer::CreateGetStatsResponseDirect(
|
|
108
108
|
builder,
|
|
109
109
|
// timestamp.
|
|
110
|
-
this->shared->GetTimeMs(),
|
|
110
|
+
static_cast<uint64_t>(this->shared->GetTimeMs()),
|
|
111
111
|
// label.
|
|
112
112
|
this->label.c_str(),
|
|
113
113
|
// protocol.
|
|
@@ -193,7 +193,7 @@ namespace RTC
|
|
|
193
193
|
{
|
|
194
194
|
MS_TRACE();
|
|
195
195
|
|
|
196
|
-
switch (notification->event)
|
|
196
|
+
switch (notification->data->event())
|
|
197
197
|
{
|
|
198
198
|
case Channel::ChannelNotification::Event::DATAPRODUCER_SEND:
|
|
199
199
|
{
|
|
@@ -98,7 +98,7 @@ namespace RTC
|
|
|
98
98
|
{
|
|
99
99
|
MS_TRACE();
|
|
100
100
|
|
|
101
|
-
switch (notification->event)
|
|
101
|
+
switch (notification->data->event())
|
|
102
102
|
{
|
|
103
103
|
case Channel::ChannelNotification::Event::TRANSPORT_SEND_RTCP:
|
|
104
104
|
{
|
|
@@ -125,7 +125,7 @@ namespace RTC
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// Pass the packet to the parent transport.
|
|
128
|
-
RTC::Transport::ReceiveRtcpPacket(packet);
|
|
128
|
+
RTC::Transport::ReceiveRtcpPacket(packet, notification->receivedAtUs);
|
|
129
129
|
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
@@ -118,11 +118,11 @@ namespace RTC
|
|
|
118
118
|
static constexpr size_t SrtpAesGcm256MasterKeyLength{ 32u };
|
|
119
119
|
static constexpr size_t SrtpAesGcm256MasterSaltLength{ 12u };
|
|
120
120
|
static constexpr size_t SrtpAesGcm256MasterLength{ SrtpAesGcm256MasterKeyLength +
|
|
121
|
-
|
|
121
|
+
SrtpAesGcm256MasterSaltLength };
|
|
122
122
|
static constexpr size_t SrtpAesGcm128MasterKeyLength{ 16u };
|
|
123
123
|
static constexpr size_t SrtpAesGcm128MasterSaltLength{ 12u };
|
|
124
124
|
static constexpr size_t SrtpAesGcm128MasterLength{ SrtpAesGcm128MasterKeyLength +
|
|
125
|
-
|
|
125
|
+
SrtpAesGcm128MasterSaltLength };
|
|
126
126
|
|
|
127
127
|
/* Class variables. */
|
|
128
128
|
|
|
@@ -137,7 +137,7 @@ namespace RTC
|
|
|
137
137
|
{ "sha-256", DtlsTransport::FingerprintAlgorithm::SHA256 },
|
|
138
138
|
{ "sha-384", DtlsTransport::FingerprintAlgorithm::SHA384 },
|
|
139
139
|
{ "sha-512", DtlsTransport::FingerprintAlgorithm::SHA512 }
|
|
140
|
-
|
|
140
|
+
};
|
|
141
141
|
const ankerl::unordered_dense::map<DtlsTransport::FingerprintAlgorithm, std::string>
|
|
142
142
|
DtlsTransport::FingerprintAlgorithm2String = {
|
|
143
143
|
{ DtlsTransport::FingerprintAlgorithm::SHA1, "sha-1" },
|
|
@@ -145,7 +145,7 @@ namespace RTC
|
|
|
145
145
|
{ DtlsTransport::FingerprintAlgorithm::SHA256, "sha-256" },
|
|
146
146
|
{ DtlsTransport::FingerprintAlgorithm::SHA384, "sha-384" },
|
|
147
147
|
{ DtlsTransport::FingerprintAlgorithm::SHA512, "sha-512" }
|
|
148
|
-
|
|
148
|
+
};
|
|
149
149
|
const ankerl::unordered_dense::map<std::string, DtlsTransport::Role> DtlsTransport::String2Role = {
|
|
150
150
|
{ "auto", DtlsTransport::Role::AUTO },
|
|
151
151
|
{ "client", DtlsTransport::Role::CLIENT },
|
|
@@ -780,7 +780,7 @@ namespace RTC
|
|
|
780
780
|
DTLS_set_timer_cb(this->ssl, onSslDtlsTimer);
|
|
781
781
|
|
|
782
782
|
// Set the DTLS timer.
|
|
783
|
-
this->timer = this->shared->CreateTimer(this);
|
|
783
|
+
this->timer = this->shared->CreateTimer(this, "dtls-transport");
|
|
784
784
|
|
|
785
785
|
return;
|
|
786
786
|
|
|
@@ -978,7 +978,7 @@ namespace RTC
|
|
|
978
978
|
return true;
|
|
979
979
|
}
|
|
980
980
|
|
|
981
|
-
void DtlsTransport::ProcessDtlsData(const uint8_t* data, size_t len)
|
|
981
|
+
void DtlsTransport::ProcessDtlsData(const uint8_t* data, size_t len, int64_t receivedAtUs)
|
|
982
982
|
{
|
|
983
983
|
MS_TRACE();
|
|
984
984
|
|
|
@@ -1034,7 +1034,10 @@ namespace RTC
|
|
|
1034
1034
|
|
|
1035
1035
|
// Notify the listener.
|
|
1036
1036
|
this->listener->OnDtlsTransportApplicationDataReceived(
|
|
1037
|
-
this,
|
|
1037
|
+
this,
|
|
1038
|
+
static_cast<const uint8_t*>(DtlsTransport::sslReadBuffer),
|
|
1039
|
+
static_cast<size_t>(read),
|
|
1040
|
+
receivedAtUs);
|
|
1038
1041
|
}
|
|
1039
1042
|
}
|
|
1040
1043
|
|
|
@@ -1270,14 +1273,14 @@ namespace RTC
|
|
|
1270
1273
|
"invalid DTLS state");
|
|
1271
1274
|
|
|
1272
1275
|
uv_timeval_t dtlsTimeout{ 0, 0 };
|
|
1273
|
-
|
|
1276
|
+
int64_t timeoutMs;
|
|
1274
1277
|
|
|
1275
1278
|
// DTLSv1_get_timeout queries the next DTLS handshake timeout. If there is
|
|
1276
1279
|
// a timeout in progress, it sets *out to the time remaining and returns
|
|
1277
1280
|
// one. Otherwise, it returns zero.
|
|
1278
1281
|
DTLSv1_get_timeout(this->ssl, static_cast<void*>(std::addressof(dtlsTimeout)));
|
|
1279
1282
|
|
|
1280
|
-
timeoutMs = (dtlsTimeout.tv_sec * static_cast<
|
|
1283
|
+
timeoutMs = (dtlsTimeout.tv_sec * static_cast<int64_t>(1000)) + (dtlsTimeout.tv_usec / 1000);
|
|
1281
1284
|
|
|
1282
1285
|
if (timeoutMs == 0)
|
|
1283
1286
|
{
|
|
@@ -1289,7 +1292,7 @@ namespace RTC
|
|
|
1289
1292
|
}
|
|
1290
1293
|
else if (timeoutMs < 30000)
|
|
1291
1294
|
{
|
|
1292
|
-
MS_DEBUG_DEV("DTLS timer set in %"
|
|
1295
|
+
MS_DEBUG_DEV("DTLS timer set in %" PRIi64 "ms", timeoutMs);
|
|
1293
1296
|
|
|
1294
1297
|
this->timer->Start(timeoutMs);
|
|
1295
1298
|
|
|
@@ -1299,7 +1302,7 @@ namespace RTC
|
|
|
1299
1302
|
// seconds.
|
|
1300
1303
|
else
|
|
1301
1304
|
{
|
|
1302
|
-
MS_WARN_TAG(dtls, "DTLS timeout too high (%"
|
|
1305
|
+
MS_WARN_TAG(dtls, "DTLS timeout too high (%" PRIi64 "ms), resetting DLTS", timeoutMs);
|
|
1303
1306
|
|
|
1304
1307
|
Reset();
|
|
1305
1308
|
|
|
@@ -165,7 +165,7 @@ namespace RTC
|
|
|
165
165
|
MS_DUMP_CLEAN(indentation, " selected tuple:");
|
|
166
166
|
this->selectedTuple->Dump(indentation + 2);
|
|
167
167
|
}
|
|
168
|
-
MS_DUMP_CLEAN(indentation, " consent timeout (ms): %"
|
|
168
|
+
MS_DUMP_CLEAN(indentation, " consent timeout (ms): %" PRIi64, this->consentTimeoutMs);
|
|
169
169
|
MS_DUMP_CLEAN(indentation, " remote nomination: %" PRIu32, this->remoteNomination);
|
|
170
170
|
MS_DUMP_CLEAN(indentation, "</IceServer>");
|
|
171
171
|
}
|
|
@@ -937,7 +937,7 @@ namespace RTC
|
|
|
937
937
|
// Create the ICE consent check timer if it doesn't exist.
|
|
938
938
|
if (!this->consentCheckTimer)
|
|
939
939
|
{
|
|
940
|
-
this->consentCheckTimer = this->shared->CreateTimer(this);
|
|
940
|
+
this->consentCheckTimer = this->shared->CreateTimer(this, "ice-server-consent-check");
|
|
941
941
|
}
|
|
942
942
|
|
|
943
943
|
this->consentCheckTimer->Start(this->consentTimeoutMs);
|