mediasoup 3.19.21 → 3.20.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/node/lib/ActiveSpeakerObserver.js +34 -1
- package/node/lib/AudioLevelObserver.js +35 -2
- package/node/lib/Channel.d.ts.map +1 -1
- package/node/lib/Channel.js +37 -5
- package/node/lib/Consumer.js +39 -6
- package/node/lib/DataConsumer.d.ts.map +1 -1
- package/node/lib/DataConsumer.js +39 -5
- package/node/lib/DataConsumerTypes.d.ts +1 -0
- package/node/lib/DataConsumerTypes.d.ts.map +1 -1
- package/node/lib/DataProducer.js +37 -4
- package/node/lib/DirectTransport.js +37 -4
- package/node/lib/DirectTransportTypes.d.ts +7 -2
- package/node/lib/DirectTransportTypes.d.ts.map +1 -1
- package/node/lib/Logger.js +4 -1
- package/node/lib/PipeTransport.d.ts +3 -1
- package/node/lib/PipeTransport.d.ts.map +1 -1
- package/node/lib/PipeTransport.js +56 -5
- package/node/lib/PipeTransportTypes.d.ts +28 -8
- package/node/lib/PipeTransportTypes.d.ts.map +1 -1
- package/node/lib/PlainTransport.d.ts +3 -1
- package/node/lib/PlainTransport.d.ts.map +1 -1
- package/node/lib/PlainTransport.js +54 -3
- package/node/lib/PlainTransportTypes.d.ts +27 -7
- package/node/lib/PlainTransportTypes.d.ts.map +1 -1
- package/node/lib/Producer.js +40 -7
- package/node/lib/Router.d.ts +5 -5
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +81 -36
- package/node/lib/RouterTypes.d.ts +25 -3
- package/node/lib/RouterTypes.d.ts.map +1 -1
- package/node/lib/RtpObserver.js +36 -3
- package/node/lib/Transport.d.ts +3 -1
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +74 -22
- package/node/lib/TransportTypes.d.ts +2 -1
- package/node/lib/TransportTypes.d.ts.map +1 -1
- package/node/lib/WebRtcServer.js +36 -3
- package/node/lib/WebRtcTransport.d.ts +3 -1
- package/node/lib/WebRtcTransport.d.ts.map +1 -1
- package/node/lib/WebRtcTransport.js +55 -4
- package/node/lib/WebRtcTransportTypes.d.ts +27 -7
- package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
- package/node/lib/Worker.d.ts +2 -1
- package/node/lib/Worker.d.ts.map +1 -1
- package/node/lib/Worker.js +71 -25
- package/node/lib/WorkerTypes.d.ts +0 -4
- package/node/lib/WorkerTypes.d.ts.map +1 -1
- package/node/lib/enhancedEvents.d.ts +2 -2
- package/node/lib/enhancedEvents.d.ts.map +1 -1
- package/node/lib/enhancedEvents.js +0 -2
- package/node/lib/fbs/active-speaker-observer/active-speaker-observer-options.js +34 -1
- package/node/lib/fbs/active-speaker-observer/dominant-speaker-notification.js +34 -1
- package/node/lib/fbs/audio-level-observer/audio-level-observer-options.js +34 -1
- package/node/lib/fbs/audio-level-observer/volume.js +34 -1
- package/node/lib/fbs/audio-level-observer/volumes-notification.js +34 -1
- package/node/lib/fbs/common/string-string-array.js +34 -1
- package/node/lib/fbs/common/string-string.js +34 -1
- package/node/lib/fbs/common/string-uint8.js +34 -1
- package/node/lib/fbs/common/uint16-string.js +34 -1
- package/node/lib/fbs/common/uint32-string.js +34 -1
- package/node/lib/fbs/consumer/base-consumer-dump.js +34 -1
- package/node/lib/fbs/consumer/consumer-dump.js +34 -1
- package/node/lib/fbs/consumer/consumer-layers.js +34 -1
- package/node/lib/fbs/consumer/consumer-score.js +34 -1
- package/node/lib/fbs/consumer/dump-response.js +34 -1
- package/node/lib/fbs/consumer/enable-trace-event-request.js +34 -1
- package/node/lib/fbs/consumer/fir-trace-info.js +34 -1
- package/node/lib/fbs/consumer/get-stats-response.js +34 -1
- package/node/lib/fbs/consumer/key-frame-trace-info.js +34 -1
- package/node/lib/fbs/consumer/layers-change-notification.js +34 -1
- package/node/lib/fbs/consumer/pli-trace-info.js +34 -1
- package/node/lib/fbs/consumer/rtp-notification.js +34 -1
- package/node/lib/fbs/consumer/rtp-trace-info.js +34 -1
- package/node/lib/fbs/consumer/score-notification.js +34 -1
- package/node/lib/fbs/consumer/set-preferred-layers-request.js +34 -1
- package/node/lib/fbs/consumer/set-preferred-layers-response.js +34 -1
- package/node/lib/fbs/consumer/set-priority-request.js +34 -1
- package/node/lib/fbs/consumer/set-priority-response.js +34 -1
- package/node/lib/fbs/consumer/trace-notification.js +34 -1
- package/node/lib/fbs/data-consumer/add-subchannel-request.js +34 -1
- package/node/lib/fbs/data-consumer/add-subchannel-response.js +34 -1
- package/node/lib/fbs/data-consumer/buffered-amount-low-notification.js +34 -1
- package/node/lib/fbs/data-consumer/dump-response.d.ts +5 -2
- package/node/lib/fbs/data-consumer/dump-response.d.ts.map +1 -1
- package/node/lib/fbs/data-consumer/dump-response.js +60 -16
- package/node/lib/fbs/data-consumer/get-buffered-amount-response.js +34 -1
- package/node/lib/fbs/data-consumer/get-stats-response.js +34 -1
- package/node/lib/fbs/data-consumer/message-notification.js +34 -1
- package/node/lib/fbs/data-consumer/remove-subchannel-request.js +34 -1
- package/node/lib/fbs/data-consumer/remove-subchannel-response.js +34 -1
- package/node/lib/fbs/data-consumer/send-request.js +34 -1
- package/node/lib/fbs/data-consumer/set-buffered-amount-low-threshold-request.js +34 -1
- package/node/lib/fbs/data-consumer/set-subchannels-request.js +34 -1
- package/node/lib/fbs/data-consumer/set-subchannels-response.js +34 -1
- package/node/lib/fbs/data-consumer/type.d.ts +5 -0
- package/node/lib/fbs/data-consumer/type.d.ts.map +1 -0
- package/node/lib/fbs/data-consumer/type.js +10 -0
- package/node/lib/fbs/data-consumer.d.ts +1 -0
- package/node/lib/fbs/data-consumer.d.ts.map +1 -1
- package/node/lib/fbs/data-consumer.js +3 -1
- package/node/lib/fbs/data-producer/dump-response.js +34 -1
- package/node/lib/fbs/data-producer/get-stats-response.js +34 -1
- package/node/lib/fbs/data-producer/send-notification.js +34 -1
- package/node/lib/fbs/direct-transport/direct-transport-options.js +34 -1
- package/node/lib/fbs/direct-transport/dump-response.js +34 -1
- package/node/lib/fbs/direct-transport/get-stats-response.js +34 -1
- package/node/lib/fbs/direct-transport/rtcp-notification.js +34 -1
- package/node/lib/fbs/lib-uring/dump.js +34 -1
- package/node/lib/fbs/log/log.js +34 -1
- package/node/lib/fbs/message/message.js +34 -1
- package/node/lib/fbs/notification/body.d.ts +24 -22
- package/node/lib/fbs/notification/body.d.ts.map +1 -1
- package/node/lib/fbs/notification/body.js +24 -20
- package/node/lib/fbs/notification/event.d.ts +27 -26
- package/node/lib/fbs/notification/event.d.ts.map +1 -1
- package/node/lib/fbs/notification/event.js +27 -26
- package/node/lib/fbs/notification/notification.d.ts +3 -2
- package/node/lib/fbs/notification/notification.d.ts.map +1 -1
- package/node/lib/fbs/notification/notification.js +34 -1
- package/node/lib/fbs/pipe-transport/connect-request.js +34 -1
- package/node/lib/fbs/pipe-transport/connect-response.js +34 -1
- package/node/lib/fbs/pipe-transport/dump-response.js +34 -1
- package/node/lib/fbs/pipe-transport/get-stats-response.js +34 -1
- package/node/lib/fbs/pipe-transport/pipe-transport-options.js +34 -1
- package/node/lib/fbs/plain-transport/connect-request.js +34 -1
- package/node/lib/fbs/plain-transport/connect-response.js +34 -1
- package/node/lib/fbs/plain-transport/dump-response.js +34 -1
- package/node/lib/fbs/plain-transport/get-stats-response.js +34 -1
- package/node/lib/fbs/plain-transport/plain-transport-options.js +34 -1
- package/node/lib/fbs/plain-transport/rtcp-tuple-notification.js +34 -1
- package/node/lib/fbs/plain-transport/tuple-notification.js +34 -1
- package/node/lib/fbs/producer/dump-response.js +34 -1
- package/node/lib/fbs/producer/enable-trace-event-request.js +34 -1
- package/node/lib/fbs/producer/fir-trace-info.js +34 -1
- package/node/lib/fbs/producer/get-stats-response.js +34 -1
- package/node/lib/fbs/producer/key-frame-trace-info.js +34 -1
- package/node/lib/fbs/producer/pli-trace-info.js +34 -1
- package/node/lib/fbs/producer/rtp-trace-info.js +34 -1
- package/node/lib/fbs/producer/score-notification.js +34 -1
- package/node/lib/fbs/producer/score.js +34 -1
- package/node/lib/fbs/producer/send-notification.js +34 -1
- package/node/lib/fbs/producer/sr-trace-info.js +34 -1
- package/node/lib/fbs/producer/trace-notification.js +34 -1
- package/node/lib/fbs/producer/video-orientation-change-notification.js +34 -1
- package/node/lib/fbs/request/request.js +34 -1
- package/node/lib/fbs/response/response.js +34 -1
- package/node/lib/fbs/router/close-rtp-observer-request.js +34 -1
- package/node/lib/fbs/router/close-transport-request.js +34 -1
- package/node/lib/fbs/router/create-active-speaker-observer-request.js +34 -1
- package/node/lib/fbs/router/create-audio-level-observer-request.js +34 -1
- package/node/lib/fbs/router/create-direct-transport-request.js +34 -1
- package/node/lib/fbs/router/create-pipe-transport-request.js +34 -1
- package/node/lib/fbs/router/create-plain-transport-request.js +34 -1
- package/node/lib/fbs/router/create-web-rtc-transport-request.js +34 -1
- package/node/lib/fbs/router/dump-response.js +34 -1
- package/node/lib/fbs/rtp-observer/add-producer-request.js +34 -1
- package/node/lib/fbs/rtp-observer/remove-producer-request.js +34 -1
- package/node/lib/fbs/rtp-packet/dump.js +34 -1
- package/node/lib/fbs/rtp-parameters/boolean.js +34 -1
- package/node/lib/fbs/rtp-parameters/codec-mapping.js +34 -1
- package/node/lib/fbs/rtp-parameters/double.js +34 -1
- package/node/lib/fbs/rtp-parameters/encoding-mapping.js +34 -1
- package/node/lib/fbs/rtp-parameters/integer32-array.js +34 -1
- package/node/lib/fbs/rtp-parameters/integer32.js +34 -1
- package/node/lib/fbs/rtp-parameters/parameter.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtcp-feedback.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtcp-parameters.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtp-codec-parameters.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-parameters.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtp-mapping.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtp-parameters.js +34 -1
- package/node/lib/fbs/rtp-parameters/rtx.js +34 -1
- package/node/lib/fbs/rtp-parameters/string.js +34 -1
- package/node/lib/fbs/rtp-stream/base-stats.js +34 -1
- package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +34 -1
- package/node/lib/fbs/rtp-stream/dump.js +34 -1
- package/node/lib/fbs/rtp-stream/params.js +34 -1
- package/node/lib/fbs/rtp-stream/recv-stats.js +34 -1
- package/node/lib/fbs/rtp-stream/send-stats.js +34 -1
- package/node/lib/fbs/rtp-stream/stats.js +34 -1
- package/node/lib/fbs/rtx-stream/params.js +34 -1
- package/node/lib/fbs/rtx-stream/rtx-dump.js +34 -1
- package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.d.ts +24 -0
- package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.d.ts.map +1 -0
- package/node/lib/fbs/sctp-association/sctp-negotiated-capabilities.js +102 -0
- package/node/lib/fbs/sctp-association.d.ts +1 -0
- package/node/lib/fbs/sctp-association.d.ts.map +1 -1
- package/node/lib/fbs/sctp-association.js +4 -1
- package/node/lib/fbs/sctp-parameters/num-sctp-streams.js +34 -1
- package/node/lib/fbs/sctp-parameters/sctp-parameters.d.ts +14 -14
- package/node/lib/fbs/sctp-parameters/sctp-parameters.d.ts.map +1 -1
- package/node/lib/fbs/sctp-parameters/sctp-parameters.js +73 -40
- package/node/lib/fbs/sctp-parameters/sctp-stream-parameters.js +34 -1
- package/node/lib/fbs/sctp-parameters.d.ts +0 -1
- package/node/lib/fbs/sctp-parameters.d.ts.map +1 -1
- package/node/lib/fbs/sctp-parameters.js +1 -4
- package/node/lib/fbs/srtp-parameters/srtp-parameters.js +34 -1
- package/node/lib/fbs/transport/bwe-trace-info.js +34 -1
- package/node/lib/fbs/transport/close-consumer-request.js +34 -1
- package/node/lib/fbs/transport/close-data-consumer-request.js +34 -1
- package/node/lib/fbs/transport/close-data-producer-request.js +34 -1
- package/node/lib/fbs/transport/close-producer-request.js +34 -1
- package/node/lib/fbs/transport/consume-data-request.d.ts +1 -1
- package/node/lib/fbs/transport/consume-data-request.js +35 -2
- package/node/lib/fbs/transport/consume-request.js +34 -1
- package/node/lib/fbs/transport/consume-response.js +34 -1
- package/node/lib/fbs/transport/dump.d.ts +7 -4
- package/node/lib/fbs/transport/dump.d.ts.map +1 -1
- package/node/lib/fbs/transport/dump.js +66 -22
- package/node/lib/fbs/transport/enable-trace-event-request.js +34 -1
- package/node/lib/fbs/transport/listen-info.js +34 -1
- package/node/lib/fbs/transport/options.d.ts +14 -14
- package/node/lib/fbs/transport/options.d.ts.map +1 -1
- package/node/lib/fbs/transport/options.js +92 -51
- package/node/lib/fbs/transport/port-range.js +34 -1
- package/node/lib/fbs/transport/produce-data-request.js +34 -1
- package/node/lib/fbs/transport/produce-request.js +34 -1
- package/node/lib/fbs/transport/produce-response.js +34 -1
- package/node/lib/fbs/transport/recv-rtp-header-extensions.js +34 -1
- package/node/lib/fbs/transport/restart-ice-response.js +34 -1
- package/node/lib/fbs/transport/rtp-listener.js +34 -1
- package/node/lib/fbs/transport/sctp-listener.js +34 -1
- package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.d.ts +22 -0
- package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.d.ts.map +1 -0
- package/node/lib/fbs/transport/sctp-negotiated-capabilities-notification.js +93 -0
- package/node/lib/fbs/transport/sctp-state-change-notification.js +34 -1
- package/node/lib/fbs/transport/send-rtcp-notification.js +34 -1
- package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +34 -1
- package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +34 -1
- package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +34 -1
- package/node/lib/fbs/transport/socket-flags.js +34 -1
- package/node/lib/fbs/transport/stats.js +34 -1
- package/node/lib/fbs/transport/trace-notification.js +34 -1
- package/node/lib/fbs/transport/tuple.js +34 -1
- package/node/lib/fbs/transport.d.ts +1 -0
- package/node/lib/fbs/transport.d.ts.map +1 -1
- package/node/lib/fbs/transport.js +5 -2
- package/node/lib/fbs/web-rtc-server/dump-response.js +34 -1
- package/node/lib/fbs/web-rtc-server/ice-user-name-fragment.js +34 -1
- package/node/lib/fbs/web-rtc-server/ip-port.js +34 -1
- package/node/lib/fbs/web-rtc-server/tuple-hash.js +34 -1
- package/node/lib/fbs/web-rtc-transport/connect-request.js +34 -1
- package/node/lib/fbs/web-rtc-transport/connect-response.js +34 -1
- package/node/lib/fbs/web-rtc-transport/dtls-parameters.js +34 -1
- package/node/lib/fbs/web-rtc-transport/dtls-state-change-notification.js +34 -1
- package/node/lib/fbs/web-rtc-transport/dump-response.js +34 -1
- package/node/lib/fbs/web-rtc-transport/fingerprint.js +34 -1
- package/node/lib/fbs/web-rtc-transport/get-stats-response.js +34 -1
- package/node/lib/fbs/web-rtc-transport/ice-candidate.js +34 -1
- package/node/lib/fbs/web-rtc-transport/ice-parameters.js +34 -1
- package/node/lib/fbs/web-rtc-transport/ice-selected-tuple-change-notification.js +34 -1
- package/node/lib/fbs/web-rtc-transport/ice-state-change-notification.js +34 -1
- package/node/lib/fbs/web-rtc-transport/listen-individual.js +34 -1
- package/node/lib/fbs/web-rtc-transport/listen-server.js +34 -1
- package/node/lib/fbs/web-rtc-transport/web-rtc-transport-options.js +34 -1
- package/node/lib/fbs/worker/channel-message-handlers.js +34 -1
- package/node/lib/fbs/worker/close-router-request.js +34 -1
- package/node/lib/fbs/worker/close-web-rtc-server-request.js +34 -1
- package/node/lib/fbs/worker/create-router-request.js +34 -1
- package/node/lib/fbs/worker/create-web-rtc-server-request.js +34 -1
- package/node/lib/fbs/worker/dump-response.js +34 -1
- package/node/lib/fbs/worker/resource-usage-response.js +34 -1
- package/node/lib/fbs/worker/update-settings-request.js +34 -1
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.d.ts.map +1 -1
- package/node/lib/index.js +37 -5
- package/node/lib/ortc.js +36 -3
- package/node/lib/rtpParametersFbsUtils.js +34 -1
- package/node/lib/rtpStreamStatsFbsUtils.js +35 -2
- package/node/lib/sctpParametersFbsUtils.d.ts +2 -2
- package/node/lib/sctpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/sctpParametersFbsUtils.js +44 -7
- package/node/lib/sctpParametersTypes.d.ts +10 -46
- package/node/lib/sctpParametersTypes.d.ts.map +1 -1
- package/node/lib/srtpParametersFbsUtils.js +34 -1
- package/node/lib/test/test-ActiveSpeakerObserver.js +35 -2
- package/node/lib/test/test-AudioLevelObserver.js +35 -2
- package/node/lib/test/test-Consumer.js +37 -4
- package/node/lib/test/test-DataConsumer.js +35 -2
- package/node/lib/test/test-DataProducer.js +35 -2
- package/node/lib/test/test-DirectTransport.js +36 -8
- package/node/lib/test/test-PipeTransport.js +35 -2
- package/node/lib/test/test-PlainTransport.js +45 -12
- package/node/lib/test/test-Producer.js +37 -4
- package/node/lib/test/test-Router.js +35 -2
- package/node/lib/test/test-WebRtcServer.js +34 -1
- package/node/lib/test/test-WebRtcTransport.js +51 -22
- package/node/lib/test/test-Worker.js +37 -4
- package/node/lib/test/test-mediasoup.js +36 -3
- package/node/lib/test/test-multiopus.js +35 -2
- package/node/lib/test/test-ortc.js +34 -1
- package/node/lib/test/test-werift-sctp.js +39 -5
- package/npm-scripts.mjs +2 -2
- package/package.json +13 -11
- package/worker/deps/libwebrtc/LICENSE +5 -0
- package/worker/deps/libwebrtc/README.md +3 -3
- package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +13 -10
- package/worker/fbs/dataConsumer.fbs +7 -2
- package/worker/fbs/dataProducer.fbs +1 -0
- package/worker/fbs/notification.fbs +2 -0
- package/worker/fbs/sctpAssociation.fbs +4 -0
- package/worker/fbs/sctpParameters.fbs +5 -12
- package/worker/fbs/transport.fbs +12 -8
- package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +13 -3
- package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +2 -2
- package/worker/fuzzer/src/RTC/FuzzerSeqManager.cpp +1 -1
- package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +5 -5
- package/worker/fuzzer/src/RTC/ICE/FuzzerStunPacket.cpp +9 -6
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +1 -1
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +14 -2
- package/worker/fuzzer/src/RTC/SCTP/association/FuzzerStateCookie.cpp +1 -1
- package/worker/fuzzer/src/RTC/SCTP/packet/FuzzerPacket.cpp +5 -2
- package/worker/fuzzer/src/fuzzer.cpp +3 -10
- package/worker/include/Channel/ChannelMessageRegistrator.hpp +39 -0
- package/worker/include/Channel/ChannelMessageRegistratorInterface.hpp +32 -0
- package/worker/include/Channel/ChannelRequest.hpp +1 -1
- package/worker/include/Channel/ChannelSocket.hpp +1 -1
- package/worker/include/DepLibUV.hpp +1 -1
- package/worker/include/DepLibUring.hpp +3 -3
- package/worker/include/Logger.hpp +4 -4
- package/worker/include/MediaSoupErrors.hpp +1 -1
- package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -9
- package/worker/include/RTC/AudioLevelObserver.hpp +7 -7
- package/worker/include/RTC/Consumer.hpp +3 -3
- package/worker/include/RTC/DataConsumer.hpp +13 -17
- package/worker/include/RTC/DataProducer.hpp +6 -9
- package/worker/include/RTC/DirectTransport.hpp +4 -6
- package/worker/include/RTC/DtlsTransport.hpp +13 -11
- package/worker/include/RTC/ICE/IceServer.hpp +8 -5
- package/worker/include/RTC/ICE/StunPacket.hpp +1 -1
- package/worker/include/RTC/KeyFrameRequestManager.hpp +15 -12
- package/worker/include/RTC/NackGenerator.hpp +8 -6
- package/worker/include/RTC/PipeConsumer.hpp +1 -2
- package/worker/include/RTC/PipeTransport.hpp +4 -6
- package/worker/include/RTC/PlainTransport.hpp +4 -6
- package/worker/include/RTC/PortManager.hpp +1 -1
- package/worker/include/RTC/Producer.hpp +3 -3
- package/worker/include/RTC/RTCP/FeedbackPs.hpp +1 -1
- package/worker/include/RTC/RTCP/FeedbackRtp.hpp +1 -1
- package/worker/include/RTC/RTCP/FeedbackRtpNack.hpp +1 -1
- package/worker/include/RTC/RTCP/ReceiverReport.hpp +1 -1
- package/worker/include/RTC/RTP/Packet.hpp +2 -2
- package/worker/include/RTC/RTP/RtpStream.hpp +17 -12
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +8 -6
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -1
- package/worker/include/RTC/RTP/RtxStream.hpp +3 -1
- package/worker/include/RTC/RTP/SharedPacket.hpp +1 -1
- package/worker/include/RTC/RateCalculator.hpp +5 -2
- package/worker/include/RTC/Router.hpp +7 -8
- package/worker/include/RTC/RtpObserver.hpp +3 -3
- package/worker/include/RTC/SCTP/association/Association.hpp +53 -19
- package/worker/include/RTC/SCTP/association/AssociationListenerDeferrer.hpp +14 -6
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +18 -14
- package/worker/include/RTC/SCTP/association/PacketSender.hpp +3 -3
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +1 -1
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +49 -35
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +114 -31
- package/worker/include/RTC/SCTP/association/{TCBContext.hpp → TransmissionControlBlockContextInterface.hpp} +14 -8
- package/worker/include/RTC/SCTP/packet/Chunk.hpp +3 -3
- package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/UserData.hpp +61 -17
- package/worker/include/RTC/SCTP/packet/chunks/AnyDataChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/AnyForwardTsnChunk.hpp +9 -9
- package/worker/include/RTC/SCTP/packet/chunks/AnyInitChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/DataChunk.hpp +4 -2
- package/worker/include/RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp +3 -3
- package/worker/include/RTC/SCTP/packet/chunks/IDataChunk.hpp +4 -2
- package/worker/include/RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp +3 -3
- package/worker/include/RTC/SCTP/packet/chunks/InitAckChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/InitChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/SackChunk.hpp +10 -3
- package/worker/include/RTC/SCTP/packet/chunks/ShutdownChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/InvalidStreamIdentifierErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/MissingMandatoryParameterErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/NoUserDataErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/StaleCookieErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/AddIncomingStreamsRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/AddOutgoingStreamsRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/CookiePreservativeParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/ReconfigurationResponseParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/SsnTsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/SupportedAddressTypesParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/SupportedExtensionsParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +22 -2
- package/worker/include/RTC/SCTP/public/{AssociationListener.hpp → AssociationListenerInterface.hpp} +5 -5
- package/worker/include/RTC/SCTP/public/Message.hpp +26 -10
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +28 -19
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +21 -0
- package/worker/include/RTC/SCTP/rx/DataTracker.hpp +277 -0
- package/worker/include/RTC/SCTP/rx/InterleavedReassemblyStreams.hpp +116 -0
- package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +202 -0
- package/worker/include/RTC/SCTP/rx/ReassemblyStreamsInterface.hpp +83 -0
- package/worker/include/RTC/SCTP/rx/TraditionalReassemblyStreams.hpp +183 -0
- package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +595 -0
- package/worker/include/RTC/SCTP/tx/RetransmissionErrorCounter.hpp +3 -3
- package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +329 -0
- package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +11 -10
- package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +356 -0
- package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +180 -0
- package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +235 -0
- package/worker/include/RTC/SenderBandwidthEstimator.hpp +5 -1
- package/worker/include/RTC/Serializable.hpp +11 -3
- package/worker/include/RTC/SimpleConsumer.hpp +1 -2
- package/worker/include/RTC/SimulcastConsumer.hpp +1 -2
- package/worker/include/RTC/SvcConsumer.hpp +1 -2
- package/worker/include/RTC/TcpServer.hpp +2 -2
- package/worker/include/RTC/Transport.hpp +65 -86
- package/worker/include/RTC/TransportCongestionControlClient.hpp +8 -5
- package/worker/include/RTC/TransportCongestionControlServer.hpp +8 -5
- package/worker/include/RTC/TransportTuple.hpp +1 -1
- package/worker/include/RTC/UdpSocket.hpp +1 -1
- package/worker/include/RTC/WebRtcServer.hpp +3 -3
- package/worker/include/RTC/WebRtcTransport.hpp +5 -7
- package/worker/include/Settings.hpp +2 -3
- package/worker/include/Shared.hpp +64 -0
- package/worker/include/SharedInterface.hpp +77 -0
- package/worker/include/Utils/UnwrappedSequenceNumber.hpp +270 -0
- package/worker/include/Utils.hpp +10 -4
- package/worker/include/Worker.hpp +6 -6
- package/worker/include/common.hpp +12 -12
- package/worker/include/handles/BackoffTimerHandle.hpp +28 -67
- package/worker/include/handles/BackoffTimerHandleInterface.hpp +123 -0
- package/worker/include/handles/TimerHandle.hpp +29 -20
- package/worker/include/handles/TimerHandleInterface.hpp +43 -0
- package/worker/meson.build +45 -29
- package/worker/meson_options.txt +2 -1
- package/worker/mocks/include/Channel/MockChannelMessageRegistrator.hpp +45 -0
- package/worker/mocks/include/MockShared.hpp +90 -0
- package/worker/mocks/include/RTC/SCTP/association/MockAssociationListener.hpp +308 -0
- package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +183 -0
- package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +262 -0
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +153 -0
- package/worker/mocks/include/handles/MockTimerHandle.hpp +74 -0
- package/worker/mocks/include/mockTypes.hpp +15 -0
- package/worker/mocks/src/Channel/MockChannelMessageRegistrator.cpp +128 -0
- package/worker/mocks/src/MockShared.cpp +46 -0
- package/worker/mocks/src/RTC/SCTP/association/MockTransmissionControlBlockContext.cpp +39 -0
- package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +127 -0
- package/worker/scripts/clang-scripts.mjs +5 -1
- package/worker/scripts/package-lock.json +6 -7
- package/worker/src/Channel/ChannelMessageRegistrator.cpp +125 -0
- package/worker/src/Channel/ChannelSocket.cpp +3 -4
- package/worker/src/DepLibUV.cpp +1 -1
- package/worker/src/DepLibUring.cpp +3 -1
- package/worker/src/Logger.cpp +1 -1
- package/worker/src/MediaSoupErrors.cpp +2 -0
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +14 -14
- package/worker/src/RTC/AudioLevelObserver.cpp +12 -10
- package/worker/src/RTC/Consumer.cpp +28 -26
- package/worker/src/RTC/DataConsumer.cpp +61 -71
- package/worker/src/RTC/DataProducer.cpp +16 -11
- package/worker/src/RTC/DirectTransport.cpp +21 -20
- package/worker/src/RTC/DtlsTransport.cpp +4 -4
- package/worker/src/RTC/ICE/IceServer.cpp +6 -5
- package/worker/src/RTC/ICE/StunPacket.cpp +1 -1
- package/worker/src/RTC/KeyFrameRequestManager.cpp +15 -15
- package/worker/src/RTC/NackGenerator.cpp +6 -6
- package/worker/src/RTC/PipeConsumer.cpp +6 -5
- package/worker/src/RTC/PipeTransport.cpp +9 -22
- package/worker/src/RTC/PlainTransport.cpp +16 -28
- package/worker/src/RTC/Producer.cpp +40 -39
- package/worker/src/RTC/RTCP/FeedbackPsAfb.cpp +1 -1
- package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +1 -2
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +1 -1
- package/worker/src/RTC/RTCP/XR.cpp +1 -1
- package/worker/src/RTC/RTP/Packet.cpp +3 -1
- package/worker/src/RTC/RTP/ProbationGenerator.cpp +4 -4
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +1 -1
- package/worker/src/RTC/RTP/RtpStream.cpp +17 -10
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +16 -14
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +12 -9
- package/worker/src/RTC/RTP/RtxStream.cpp +7 -7
- package/worker/src/RTC/RTP/SharedPacket.cpp +3 -3
- package/worker/src/RTC/RateCalculator.cpp +1 -2
- package/worker/src/RTC/Router.cpp +61 -38
- package/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +1 -1
- package/worker/src/RTC/RtpObserver.cpp +2 -1
- package/worker/src/RTC/SCTP/LICENSE +44 -0
- package/worker/src/RTC/SCTP/association/Association.cpp +417 -411
- package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +46 -13
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +47 -43
- package/worker/src/RTC/SCTP/association/PacketSender.cpp +8 -8
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +113 -101
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +291 -62
- package/worker/src/RTC/SCTP/packet/Chunk.cpp +5 -1
- package/worker/src/RTC/SCTP/packet/Packet.cpp +8 -1
- package/worker/src/RTC/SCTP/packet/chunks/DataChunk.cpp +17 -0
- package/worker/src/RTC/SCTP/packet/chunks/ForwardTsnChunk.cpp +4 -4
- package/worker/src/RTC/SCTP/packet/chunks/IDataChunk.cpp +25 -0
- package/worker/src/RTC/SCTP/packet/chunks/IForwardTsnChunk.cpp +10 -7
- package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +21 -4
- package/worker/src/RTC/SCTP/packet/chunks/ShutdownCompleteChunk.cpp +1 -1
- package/worker/src/RTC/SCTP/packet/errorCauses/NoUserDataErrorCause.cpp +1 -1
- package/worker/src/RTC/SCTP/packet/errorCauses/ProtocolViolationErrorCause.cpp +2 -2
- package/worker/src/RTC/SCTP/packet/errorCauses/UserInitiatedAbortErrorCause.cpp +1 -1
- package/worker/src/RTC/SCTP/public/Message.cpp +8 -0
- package/worker/src/RTC/SCTP/public/SctpOptions.cpp +90 -0
- package/worker/src/RTC/SCTP/rx/DataTracker.cpp +471 -0
- package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +327 -0
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +288 -0
- package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +453 -0
- package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +912 -0
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +786 -0
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +2 -2
- package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +752 -0
- package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +257 -0
- package/worker/src/RTC/SenderBandwidthEstimator.cpp +7 -5
- package/worker/src/RTC/SimpleConsumer.cpp +11 -11
- package/worker/src/RTC/SimulcastConsumer.cpp +16 -16
- package/worker/src/RTC/SrtpSession.cpp +1 -1
- package/worker/src/RTC/SvcConsumer.cpp +16 -16
- package/worker/src/RTC/TcpConnection.cpp +1 -1
- package/worker/src/RTC/Transport.cpp +497 -563
- package/worker/src/RTC/TransportCongestionControlClient.cpp +9 -8
- package/worker/src/RTC/TransportCongestionControlServer.cpp +5 -5
- package/worker/src/RTC/WebRtcServer.cpp +5 -4
- package/worker/src/RTC/WebRtcTransport.cpp +44 -39
- package/worker/src/Settings.cpp +9 -28
- package/worker/src/Shared.cpp +35 -0
- package/worker/src/Utils/Crypto.cpp +1 -1
- package/worker/src/Utils/String.cpp +1 -1
- package/worker/src/Worker.cpp +19 -48
- package/worker/src/handles/BackoffTimerHandle.cpp +34 -21
- package/worker/src/handles/TimerHandle.cpp +5 -4
- package/worker/src/handles/UdpSocketHandle.cpp +1 -1
- package/worker/src/lib.cpp +17 -16
- package/worker/subprojects/catch2.wrap +6 -6
- package/worker/tasks.py +1 -1
- package/worker/test/include/RTC/ICE/iceCommon.hpp +8 -7
- package/worker/test/include/RTC/RTP/rtpCommon.hpp +7 -6
- package/worker/test/include/RTC/SCTP/sctpCommon.hpp +16 -10
- package/worker/test/include/catch2Macros.hpp +31 -0
- package/worker/test/src/RTC/ICE/TestStunPacket.cpp +3 -3
- package/worker/test/src/RTC/ICE/iceCommon.cpp +2 -2
- package/worker/test/src/RTC/RTP/Codecs/TestVP8.cpp +1 -1
- package/worker/test/src/RTC/RTP/Codecs/TestVP9.cpp +1 -1
- package/worker/test/src/RTC/RTP/TestPacket.cpp +3 -3
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +16 -9
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +38 -23
- package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
- package/worker/test/src/RTC/RTP/rtpCommon.cpp +2 -2
- package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +292 -0
- package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +1 -1
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +1 -1
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +99 -0
- package/worker/test/src/RTC/SCTP/packet/TestChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/TestPacket.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestAbortAssociationChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestCookieAckChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestCookieEchoChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestDataChunk.cpp +77 -7
- package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +35 -26
- package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatAckChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatRequestChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestIDataChunk.cpp +77 -7
- package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +59 -27
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitAckChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestOperationErrorChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestReConfigChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +73 -35
- package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownAckChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestShutdownCompleteChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/chunks/TestUnknownChunk.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestCookieReceivedWhileShuttingDownErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestInvalidMandatoryParameterErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestInvalidStreamIdentifierErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestMissingMandatoryParameterErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestNoUserDataErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestOutOfResourceErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestProtocolViolationErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestRestartOfAnAssociationWithNewAddressesErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestStaleCookieErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnknownErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnrecognizedChunkTypeErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnrecognizedParametersErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnresolvableAddressErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUserInitiatedAbortErrorCause.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestAddIncomingStreamsRequestParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestAddOutgoingStreamsRequestParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestCookiePreservativeParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestForwardTsnSupportedParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestHeartbeatInfoParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv4AddressParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestIncomingSsnResetRequestParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestOutgoingSsnResetRequestParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestReconfigurationResponseParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestSsnTsnResetRequestParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedAddressTypesParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedExtensionsParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestUnknownParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestUnrecognizedParameterParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +1117 -0
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +565 -0
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +557 -0
- package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +555 -0
- package/worker/test/src/RTC/SCTP/sctpCommon.cpp +2 -2
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1248 -0
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionErrorCounter.cpp +4 -0
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +2218 -0
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +33 -33
- package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +1130 -0
- package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +721 -0
- package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +20 -30
- package/worker/test/src/RTC/TestNackGenerator.cpp +11 -8
- package/worker/test/src/RTC/TestRateCalculator.cpp +6 -7
- package/worker/test/src/RTC/TestSimpleConsumer.cpp +11 -11
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +15 -3
- package/worker/test/src/Utils/TestByte.cpp +98 -0
- package/worker/test/src/{RTC/SCTP/common → Utils}/TestUnwrappedSequenceNumber.cpp +2 -2
- package/worker/test/src/testHelpers.cpp +1 -1
- package/worker/test/src/tests.cpp +0 -12
- package/node/lib/fbs/consumer/degrade-request.d.ts +0 -30
- package/node/lib/fbs/consumer/degrade-request.d.ts.map +0 -1
- package/node/lib/fbs/consumer/degrade-request.js +0 -91
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts +0 -24
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts.map +0 -1
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.js +0 -69
- package/node/lib/fbs/producer/degrade-request.d.ts +0 -30
- package/node/lib/fbs/producer/degrade-request.d.ts.map +0 -1
- package/node/lib/fbs/producer/degrade-request.js +0 -91
- package/node/lib/fbs/worker/close-notification.d.ts +0 -18
- package/node/lib/fbs/worker/close-notification.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-notification.js +0 -45
- package/node/lib/fbs/worker/close-request.d.ts +0 -18
- package/node/lib/fbs/worker/close-request.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-request.js +0 -45
- package/node/lib/fbs/worker/close-worker-notification.d.ts +0 -18
- package/node/lib/fbs/worker/close-worker-notification.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-worker-notification.js +0 -45
- package/worker/include/ChannelMessageRegistrator.hpp +0 -30
- package/worker/include/DepUsrSCTP.hpp +0 -48
- package/worker/include/RTC/SCTP/TODO_SCTP.md +0 -43
- package/worker/include/RTC/SCTP/common/UnwrappedSequenceNumber.hpp +0 -274
- package/worker/include/RTC/SctpAssociation.hpp +0 -147
- package/worker/include/RTC/Shared.hpp +0 -23
- package/worker/src/ChannelMessageRegistrator.cpp +0 -119
- package/worker/src/DepUsrSCTP.cpp +0 -277
- package/worker/src/RTC/SctpAssociation.cpp +0 -1175
- package/worker/src/RTC/Shared.cpp +0 -23
- package/worker/subprojects/usrsctp.wrap +0 -8
|
@@ -1,1175 +0,0 @@
|
|
|
1
|
-
#define MS_CLASS "RTC::SctpAssociation"
|
|
2
|
-
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
-
|
|
4
|
-
#include "RTC/SctpAssociation.hpp"
|
|
5
|
-
#include "DepUsrSCTP.hpp"
|
|
6
|
-
#include "Logger.hpp"
|
|
7
|
-
#include "MediaSoupErrors.hpp"
|
|
8
|
-
#include <cstdio> // std::snprintf()
|
|
9
|
-
#include <cstdlib> // std::malloc(), std::free()
|
|
10
|
-
#include <cstring> // std::memset(), std::memcpy()
|
|
11
|
-
#include <string>
|
|
12
|
-
|
|
13
|
-
// Free send buffer threshold (in bytes) upon which send_cb will be executed.
|
|
14
|
-
static const uint32_t SendBufferThreshold{ 256u };
|
|
15
|
-
|
|
16
|
-
/* SCTP events to which we are subscribing. */
|
|
17
|
-
|
|
18
|
-
// clang-format off
|
|
19
|
-
const uint16_t EventTypes[] =
|
|
20
|
-
{
|
|
21
|
-
SCTP_ADAPTATION_INDICATION,
|
|
22
|
-
SCTP_ASSOC_CHANGE,
|
|
23
|
-
SCTP_ASSOC_RESET_EVENT,
|
|
24
|
-
SCTP_REMOTE_ERROR,
|
|
25
|
-
SCTP_SHUTDOWN_EVENT,
|
|
26
|
-
SCTP_SEND_FAILED_EVENT,
|
|
27
|
-
SCTP_STREAM_RESET_EVENT,
|
|
28
|
-
SCTP_STREAM_CHANGE_EVENT
|
|
29
|
-
};
|
|
30
|
-
// clang-format on
|
|
31
|
-
|
|
32
|
-
/* Static methods for usrsctp callbacks. */
|
|
33
|
-
|
|
34
|
-
inline static int onRecvSctpData(
|
|
35
|
-
struct socket* /*sock*/,
|
|
36
|
-
union sctp_sockstore /*addr*/,
|
|
37
|
-
void* data,
|
|
38
|
-
size_t len,
|
|
39
|
-
struct sctp_rcvinfo rcv,
|
|
40
|
-
int flags,
|
|
41
|
-
void* ulpInfo)
|
|
42
|
-
{
|
|
43
|
-
auto* sctpAssociation = DepUsrSCTP::RetrieveSctpAssociation(reinterpret_cast<uintptr_t>(ulpInfo));
|
|
44
|
-
|
|
45
|
-
if (!sctpAssociation)
|
|
46
|
-
{
|
|
47
|
-
MS_WARN_TAG(sctp, "no SctpAssociation found");
|
|
48
|
-
|
|
49
|
-
std::free(data);
|
|
50
|
-
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (flags & MSG_NOTIFICATION)
|
|
55
|
-
{
|
|
56
|
-
sctpAssociation->OnUsrSctpReceiveSctpNotification(
|
|
57
|
-
static_cast<union sctp_notification*>(data), len);
|
|
58
|
-
}
|
|
59
|
-
else
|
|
60
|
-
{
|
|
61
|
-
const uint16_t streamId = rcv.rcv_sid;
|
|
62
|
-
const uint32_t ppid = ntohl(rcv.rcv_ppid);
|
|
63
|
-
const uint16_t ssn = rcv.rcv_ssn;
|
|
64
|
-
|
|
65
|
-
MS_DEBUG_TAG(
|
|
66
|
-
sctp,
|
|
67
|
-
"data chunk received [length:%zu, streamId:%" PRIu16 ", SSN:%" PRIu16 ", TSN:%" PRIu32
|
|
68
|
-
", PPID:%" PRIu32 ", context:%" PRIu32 ", flags:%d]",
|
|
69
|
-
len,
|
|
70
|
-
rcv.rcv_sid,
|
|
71
|
-
rcv.rcv_ssn,
|
|
72
|
-
rcv.rcv_tsn,
|
|
73
|
-
ntohl(rcv.rcv_ppid),
|
|
74
|
-
rcv.rcv_context,
|
|
75
|
-
flags);
|
|
76
|
-
|
|
77
|
-
sctpAssociation->OnUsrSctpReceiveSctpData(
|
|
78
|
-
streamId, ssn, ppid, flags, static_cast<uint8_t*>(data), len);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
std::free(data);
|
|
82
|
-
|
|
83
|
-
return 1;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
inline static int onSendSctpData(struct socket* /*sock*/, uint32_t freeBuffer, void* ulpInfo)
|
|
87
|
-
{
|
|
88
|
-
auto* sctpAssociation = DepUsrSCTP::RetrieveSctpAssociation(reinterpret_cast<uintptr_t>(ulpInfo));
|
|
89
|
-
|
|
90
|
-
if (!sctpAssociation)
|
|
91
|
-
{
|
|
92
|
-
MS_WARN_TAG(sctp, "no SctpAssociation found");
|
|
93
|
-
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
sctpAssociation->OnUsrSctpSentData(freeBuffer);
|
|
98
|
-
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
namespace RTC
|
|
103
|
-
{
|
|
104
|
-
/* Static. */
|
|
105
|
-
|
|
106
|
-
static constexpr size_t SctpMtu{ 1200 };
|
|
107
|
-
static constexpr uint16_t MaxSctpStreams{ 65535 };
|
|
108
|
-
|
|
109
|
-
/* Instance methods. */
|
|
110
|
-
|
|
111
|
-
SctpAssociation::SctpAssociation(
|
|
112
|
-
Listener* listener,
|
|
113
|
-
uint16_t os,
|
|
114
|
-
uint16_t mis,
|
|
115
|
-
size_t maxSctpMessageSize,
|
|
116
|
-
size_t sctpSendBufferSize,
|
|
117
|
-
bool isDataChannel)
|
|
118
|
-
: id(DepUsrSCTP::GetNextSctpAssociationId()),
|
|
119
|
-
listener(listener),
|
|
120
|
-
os(os),
|
|
121
|
-
mis(mis),
|
|
122
|
-
maxSctpMessageSize(maxSctpMessageSize),
|
|
123
|
-
sctpSendBufferSize(sctpSendBufferSize),
|
|
124
|
-
isDataChannel(isDataChannel)
|
|
125
|
-
{
|
|
126
|
-
MS_TRACE();
|
|
127
|
-
|
|
128
|
-
// Register ourselves in usrsctp.
|
|
129
|
-
// NOTE: This must be done before calling usrsctp_bind().
|
|
130
|
-
usrsctp_register_address(reinterpret_cast<void*>(this->id));
|
|
131
|
-
|
|
132
|
-
int ret;
|
|
133
|
-
|
|
134
|
-
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
|
135
|
-
this->socket = usrsctp_socket(
|
|
136
|
-
AF_CONN,
|
|
137
|
-
SOCK_STREAM,
|
|
138
|
-
IPPROTO_SCTP,
|
|
139
|
-
onRecvSctpData,
|
|
140
|
-
onSendSctpData,
|
|
141
|
-
SendBufferThreshold,
|
|
142
|
-
reinterpret_cast<void*>(this->id));
|
|
143
|
-
|
|
144
|
-
if (!this->socket)
|
|
145
|
-
{
|
|
146
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
147
|
-
|
|
148
|
-
MS_THROW_ERROR("usrsctp_socket() failed: %s", std::strerror(errno));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
usrsctp_set_ulpinfo(this->socket, reinterpret_cast<void*>(this->id));
|
|
152
|
-
|
|
153
|
-
// Make the socket non-blocking.
|
|
154
|
-
ret = usrsctp_set_non_blocking(this->socket, 1);
|
|
155
|
-
|
|
156
|
-
if (ret < 0)
|
|
157
|
-
{
|
|
158
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
159
|
-
|
|
160
|
-
MS_THROW_ERROR("usrsctp_set_non_blocking() failed: %s", std::strerror(errno));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Set SO_LINGER.
|
|
164
|
-
// This ensures that the usrsctp close call deletes the association. This
|
|
165
|
-
// prevents usrsctp from calling the global send callback with references to
|
|
166
|
-
// this class as the address.
|
|
167
|
-
struct linger lingerOpt{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
168
|
-
|
|
169
|
-
lingerOpt.l_onoff = 1;
|
|
170
|
-
lingerOpt.l_linger = 0;
|
|
171
|
-
|
|
172
|
-
ret = usrsctp_setsockopt(this->socket, SOL_SOCKET, SO_LINGER, &lingerOpt, sizeof(lingerOpt));
|
|
173
|
-
|
|
174
|
-
if (ret < 0)
|
|
175
|
-
{
|
|
176
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
177
|
-
|
|
178
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SO_LINGER) failed: %s", std::strerror(errno));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Set SCTP_ENABLE_STREAM_RESET.
|
|
182
|
-
struct sctp_assoc_value av{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
183
|
-
|
|
184
|
-
av.assoc_value =
|
|
185
|
-
SCTP_ENABLE_RESET_STREAM_REQ | SCTP_ENABLE_RESET_ASSOC_REQ | SCTP_ENABLE_CHANGE_ASSOC_REQ;
|
|
186
|
-
|
|
187
|
-
ret = usrsctp_setsockopt(this->socket, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, &av, sizeof(av));
|
|
188
|
-
|
|
189
|
-
if (ret < 0)
|
|
190
|
-
{
|
|
191
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
192
|
-
|
|
193
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SCTP_ENABLE_STREAM_RESET) failed: %s", std::strerror(errno));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Set SCTP_NODELAY.
|
|
197
|
-
const uint32_t noDelay = 1;
|
|
198
|
-
|
|
199
|
-
ret = usrsctp_setsockopt(this->socket, IPPROTO_SCTP, SCTP_NODELAY, &noDelay, sizeof(noDelay));
|
|
200
|
-
|
|
201
|
-
if (ret < 0)
|
|
202
|
-
{
|
|
203
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
204
|
-
|
|
205
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SCTP_NODELAY) failed: %s", std::strerror(errno));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Enable events.
|
|
209
|
-
struct sctp_event event{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
210
|
-
|
|
211
|
-
std::memset(&event, 0, sizeof(event));
|
|
212
|
-
event.se_on = 1;
|
|
213
|
-
|
|
214
|
-
for (size_t i{ 0 }; i < sizeof(EventTypes) / sizeof(uint16_t); ++i)
|
|
215
|
-
{
|
|
216
|
-
event.se_type = EventTypes[i];
|
|
217
|
-
|
|
218
|
-
ret = usrsctp_setsockopt(this->socket, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event));
|
|
219
|
-
|
|
220
|
-
if (ret < 0)
|
|
221
|
-
{
|
|
222
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
223
|
-
|
|
224
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SCTP_EVENT) failed: %s", std::strerror(errno));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Init message.
|
|
229
|
-
struct sctp_initmsg initmsg{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
230
|
-
|
|
231
|
-
std::memset(&initmsg, 0, sizeof(initmsg));
|
|
232
|
-
initmsg.sinit_num_ostreams = this->os;
|
|
233
|
-
initmsg.sinit_max_instreams = this->mis;
|
|
234
|
-
|
|
235
|
-
ret = usrsctp_setsockopt(this->socket, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(initmsg));
|
|
236
|
-
|
|
237
|
-
if (ret < 0)
|
|
238
|
-
{
|
|
239
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
240
|
-
|
|
241
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SCTP_INITMSG) failed: %s", std::strerror(errno));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Server side.
|
|
245
|
-
struct sockaddr_conn sconn{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
246
|
-
|
|
247
|
-
std::memset(&sconn, 0, sizeof(sconn));
|
|
248
|
-
sconn.sconn_family = AF_CONN;
|
|
249
|
-
sconn.sconn_port = htons(5000);
|
|
250
|
-
sconn.sconn_addr = reinterpret_cast<void*>(this->id);
|
|
251
|
-
#ifdef HAVE_SCONN_LEN
|
|
252
|
-
sconn.sconn_len = sizeof(sconn);
|
|
253
|
-
#endif
|
|
254
|
-
|
|
255
|
-
ret = usrsctp_bind(this->socket, reinterpret_cast<struct sockaddr*>(&sconn), sizeof(sconn));
|
|
256
|
-
|
|
257
|
-
if (ret < 0)
|
|
258
|
-
{
|
|
259
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
260
|
-
|
|
261
|
-
MS_THROW_ERROR("usrsctp_bind() failed: %s", std::strerror(errno));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
auto bufferSize = static_cast<int>(sctpSendBufferSize);
|
|
265
|
-
|
|
266
|
-
if (usrsctp_setsockopt(this->socket, SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(int)) < 0)
|
|
267
|
-
{
|
|
268
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
269
|
-
|
|
270
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SO_SNDBUF) failed: %s", std::strerror(errno));
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Register the SctpAssociation into the global map.
|
|
274
|
-
DepUsrSCTP::RegisterSctpAssociation(this);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
SctpAssociation::~SctpAssociation()
|
|
278
|
-
{
|
|
279
|
-
MS_TRACE();
|
|
280
|
-
|
|
281
|
-
usrsctp_set_ulpinfo(this->socket, nullptr);
|
|
282
|
-
usrsctp_close(this->socket);
|
|
283
|
-
|
|
284
|
-
// Deregister ourselves from usrsctp.
|
|
285
|
-
usrsctp_deregister_address(reinterpret_cast<void*>(this->id));
|
|
286
|
-
|
|
287
|
-
// Register the SctpAssociation from the global map.
|
|
288
|
-
DepUsrSCTP::DeregisterSctpAssociation(this);
|
|
289
|
-
|
|
290
|
-
delete[] this->messageBuffer;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
void SctpAssociation::TransportConnected()
|
|
294
|
-
{
|
|
295
|
-
MS_TRACE();
|
|
296
|
-
|
|
297
|
-
this->transportConnected = true;
|
|
298
|
-
|
|
299
|
-
MayConnect();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
void SctpAssociation::TransportDisconnected()
|
|
303
|
-
{
|
|
304
|
-
MS_TRACE();
|
|
305
|
-
|
|
306
|
-
this->transportConnected = false;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
flatbuffers::Offset<FBS::SctpParameters::SctpParameters> SctpAssociation::FillBuffer(
|
|
310
|
-
flatbuffers::FlatBufferBuilder& builder) const
|
|
311
|
-
{
|
|
312
|
-
MS_TRACE();
|
|
313
|
-
|
|
314
|
-
return FBS::SctpParameters::CreateSctpParameters(
|
|
315
|
-
builder,
|
|
316
|
-
// Add port (always 5000).
|
|
317
|
-
5000,
|
|
318
|
-
// Add OS.
|
|
319
|
-
this->os,
|
|
320
|
-
// Add MIS.
|
|
321
|
-
this->mis,
|
|
322
|
-
// Add maxMessageSize.
|
|
323
|
-
this->maxSctpMessageSize,
|
|
324
|
-
// Add sendBufferSize.
|
|
325
|
-
this->sctpSendBufferSize,
|
|
326
|
-
// Add sctpBufferedAmountLowThreshold.
|
|
327
|
-
this->sctpBufferedAmount,
|
|
328
|
-
// Add isDataChannel.
|
|
329
|
-
this->isDataChannel);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
void SctpAssociation::ProcessSctpData(const uint8_t* data, size_t len)
|
|
333
|
-
{
|
|
334
|
-
MS_TRACE();
|
|
335
|
-
|
|
336
|
-
this->sctpDataReceived = true;
|
|
337
|
-
|
|
338
|
-
MayConnect();
|
|
339
|
-
|
|
340
|
-
#if MS_LOG_DEV_LEVEL == 3
|
|
341
|
-
// NOTE: Only uncomment this during local debugging if needed.
|
|
342
|
-
// MS_DUMP_DATA(data, len);
|
|
343
|
-
#endif
|
|
344
|
-
|
|
345
|
-
usrsctp_conninput(reinterpret_cast<void*>(this->id), data, len, 0);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
void SctpAssociation::SendSctpMessage(
|
|
349
|
-
RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb)
|
|
350
|
-
{
|
|
351
|
-
MS_TRACE();
|
|
352
|
-
|
|
353
|
-
// This must be controlled by the DataConsumer.
|
|
354
|
-
MS_ASSERT(
|
|
355
|
-
len <= this->maxSctpMessageSize,
|
|
356
|
-
"given message exceeds max allowed message size [message size:%zu, max message size:%zu]",
|
|
357
|
-
len,
|
|
358
|
-
this->maxSctpMessageSize);
|
|
359
|
-
|
|
360
|
-
const auto& parameters = dataConsumer->GetSctpStreamParameters();
|
|
361
|
-
|
|
362
|
-
// Fill sctp_sendv_spa.
|
|
363
|
-
struct sctp_sendv_spa spa{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
364
|
-
|
|
365
|
-
std::memset(&spa, 0, sizeof(spa));
|
|
366
|
-
spa.sendv_flags = SCTP_SEND_SNDINFO_VALID;
|
|
367
|
-
spa.sendv_sndinfo.snd_sid = parameters.streamId;
|
|
368
|
-
spa.sendv_sndinfo.snd_ppid = htonl(ppid);
|
|
369
|
-
spa.sendv_sndinfo.snd_flags = SCTP_EOR;
|
|
370
|
-
|
|
371
|
-
// If ordered it must be reliable.
|
|
372
|
-
if (parameters.ordered)
|
|
373
|
-
{
|
|
374
|
-
spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_NONE;
|
|
375
|
-
spa.sendv_prinfo.pr_value = 0;
|
|
376
|
-
}
|
|
377
|
-
// Configure reliability: https://tools.ietf.org/html/rfc3758
|
|
378
|
-
else
|
|
379
|
-
{
|
|
380
|
-
spa.sendv_flags |= SCTP_SEND_PRINFO_VALID;
|
|
381
|
-
spa.sendv_sndinfo.snd_flags |= SCTP_UNORDERED;
|
|
382
|
-
|
|
383
|
-
if (parameters.maxPacketLifeTime != 0)
|
|
384
|
-
{
|
|
385
|
-
spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_TTL;
|
|
386
|
-
spa.sendv_prinfo.pr_value = parameters.maxPacketLifeTime;
|
|
387
|
-
}
|
|
388
|
-
else if (parameters.maxRetransmits != 0)
|
|
389
|
-
{
|
|
390
|
-
spa.sendv_prinfo.pr_policy = SCTP_PR_SCTP_RTX;
|
|
391
|
-
spa.sendv_prinfo.pr_value = parameters.maxRetransmits;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
this->sctpBufferedAmount += len;
|
|
396
|
-
|
|
397
|
-
// Notify the listener about the buffered amount increase regardless
|
|
398
|
-
// usrsctp_sendv result.
|
|
399
|
-
// In case of failure the correct value will be later provided by usrsctp
|
|
400
|
-
// via onSendSctpData.
|
|
401
|
-
this->listener->OnSctpAssociationBufferedAmount(this, this->sctpBufferedAmount);
|
|
402
|
-
|
|
403
|
-
const ssize_t ret = usrsctp_sendv(
|
|
404
|
-
this->socket, msg, len, nullptr, 0, &spa, static_cast<socklen_t>(sizeof(spa)), SCTP_SENDV_SPA, 0);
|
|
405
|
-
|
|
406
|
-
if (ret < 0)
|
|
407
|
-
{
|
|
408
|
-
const bool sctpSendBufferFull = errno == EWOULDBLOCK || errno == EAGAIN;
|
|
409
|
-
|
|
410
|
-
// SCTP send buffer being full is legit, not an error.
|
|
411
|
-
if (sctpSendBufferFull)
|
|
412
|
-
{
|
|
413
|
-
MS_WARN_DEV(
|
|
414
|
-
"error sending SCTP message [sid:%" PRIu16 ", ppid:%" PRIu32 ", message size:%zu]: %s",
|
|
415
|
-
parameters.streamId,
|
|
416
|
-
ppid,
|
|
417
|
-
len,
|
|
418
|
-
std::strerror(errno));
|
|
419
|
-
}
|
|
420
|
-
else
|
|
421
|
-
{
|
|
422
|
-
MS_WARN_TAG(
|
|
423
|
-
sctp,
|
|
424
|
-
"error sending SCTP message [sid:%" PRIu16 ", ppid:%" PRIu32 ", message size:%zu]: %s",
|
|
425
|
-
parameters.streamId,
|
|
426
|
-
ppid,
|
|
427
|
-
len,
|
|
428
|
-
std::strerror(errno));
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (cb)
|
|
432
|
-
{
|
|
433
|
-
(*cb)(false, sctpSendBufferFull);
|
|
434
|
-
delete cb;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (sctpSendBufferFull)
|
|
438
|
-
{
|
|
439
|
-
dataConsumer->SctpAssociationSendBufferFull();
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
else if (cb)
|
|
443
|
-
{
|
|
444
|
-
(*cb)(true, false);
|
|
445
|
-
delete cb;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
void SctpAssociation::HandleDataProducer(RTC::DataProducer* /*dataProducer*/)
|
|
450
|
-
{
|
|
451
|
-
MS_TRACE();
|
|
452
|
-
|
|
453
|
-
this->firstStreamCreated = true;
|
|
454
|
-
|
|
455
|
-
MayConnect();
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
void SctpAssociation::HandleDataConsumer(RTC::DataConsumer* dataConsumer)
|
|
459
|
-
{
|
|
460
|
-
MS_TRACE();
|
|
461
|
-
|
|
462
|
-
this->firstStreamCreated = true;
|
|
463
|
-
|
|
464
|
-
MayConnect();
|
|
465
|
-
|
|
466
|
-
auto streamId = dataConsumer->GetSctpStreamParameters().streamId;
|
|
467
|
-
|
|
468
|
-
// We need more OS.
|
|
469
|
-
if (streamId > this->os - 1)
|
|
470
|
-
{
|
|
471
|
-
AddOutgoingStreams(/*force*/ false);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
void SctpAssociation::DataProducerClosed(RTC::DataProducer* dataProducer)
|
|
476
|
-
{
|
|
477
|
-
MS_TRACE();
|
|
478
|
-
|
|
479
|
-
auto streamId = dataProducer->GetSctpStreamParameters().streamId;
|
|
480
|
-
|
|
481
|
-
// Send SCTP_RESET_STREAMS to the remote.
|
|
482
|
-
// https://tools.ietf.org/html/rfc8831#section-6.7
|
|
483
|
-
if (this->isDataChannel)
|
|
484
|
-
{
|
|
485
|
-
ResetSctpStream(streamId, StreamDirection::OUTGOING);
|
|
486
|
-
}
|
|
487
|
-
else
|
|
488
|
-
{
|
|
489
|
-
ResetSctpStream(streamId, StreamDirection::INCOMING);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
void SctpAssociation::DataConsumerClosed(RTC::DataConsumer* dataConsumer)
|
|
494
|
-
{
|
|
495
|
-
MS_TRACE();
|
|
496
|
-
|
|
497
|
-
auto streamId = dataConsumer->GetSctpStreamParameters().streamId;
|
|
498
|
-
|
|
499
|
-
// Send SCTP_RESET_STREAMS to the remote.
|
|
500
|
-
ResetSctpStream(streamId, StreamDirection::OUTGOING);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
void SctpAssociation::MayConnect()
|
|
504
|
-
{
|
|
505
|
-
MS_TRACE();
|
|
506
|
-
|
|
507
|
-
// Just run the SCTP stack if our state is 'new'.
|
|
508
|
-
// Notice that once MayConnect() is called (and the code below is executed),
|
|
509
|
-
// SCTP state will no longer be "NEW".
|
|
510
|
-
if (this->state != SctpState::NEW)
|
|
511
|
-
{
|
|
512
|
-
MS_DEBUG_DEV("SCTP state is not NEW, ignoring");
|
|
513
|
-
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
// If the transport is not connected, don't do anything.
|
|
517
|
-
else if (!this->transportConnected)
|
|
518
|
-
{
|
|
519
|
-
MS_DEBUG_DEV("transport is not connected, ignoring");
|
|
520
|
-
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
// If there are no SCTP streams yet and no SCTP data has been yet received
|
|
524
|
-
// from the remote peer, don't do anything.
|
|
525
|
-
// This is because the peer may never create a DataChannel so we shouldn't
|
|
526
|
-
// try to connect SCTP (SCTP INIT chunk, etc) since it will timeout and
|
|
527
|
-
// trigger "SCTP failed".
|
|
528
|
-
else if (!this->firstStreamCreated && !this->sctpDataReceived)
|
|
529
|
-
{
|
|
530
|
-
MS_DEBUG_DEV(
|
|
531
|
-
"no SCTP stream has been created yet and no SCTP data has been received yet, ignoring");
|
|
532
|
-
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
MS_DEBUG_TAG(sctp, "connecting SCTP");
|
|
537
|
-
|
|
538
|
-
try
|
|
539
|
-
{
|
|
540
|
-
int ret;
|
|
541
|
-
struct sockaddr_conn rconn{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
542
|
-
|
|
543
|
-
std::memset(&rconn, 0, sizeof(rconn));
|
|
544
|
-
rconn.sconn_family = AF_CONN;
|
|
545
|
-
rconn.sconn_port = htons(5000);
|
|
546
|
-
rconn.sconn_addr = reinterpret_cast<void*>(this->id);
|
|
547
|
-
#ifdef HAVE_SCONN_LEN
|
|
548
|
-
rconn.sconn_len = sizeof(rconn);
|
|
549
|
-
#endif
|
|
550
|
-
|
|
551
|
-
ret = usrsctp_connect(this->socket, reinterpret_cast<struct sockaddr*>(&rconn), sizeof(rconn));
|
|
552
|
-
|
|
553
|
-
if (ret < 0 && errno != EINPROGRESS)
|
|
554
|
-
{
|
|
555
|
-
MS_THROW_ERROR("usrsctp_connect() failed: %s", std::strerror(errno));
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// Disable MTU discovery.
|
|
559
|
-
sctp_paddrparams peerAddrParams{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
560
|
-
|
|
561
|
-
std::memset(&peerAddrParams, 0, sizeof(peerAddrParams));
|
|
562
|
-
std::memcpy(&peerAddrParams.spp_address, &rconn, sizeof(rconn));
|
|
563
|
-
peerAddrParams.spp_flags = SPP_PMTUD_DISABLE;
|
|
564
|
-
|
|
565
|
-
// The MTU value provided specifies the space available for chunks in the
|
|
566
|
-
// packet, so let's subtract the SCTP header size.
|
|
567
|
-
peerAddrParams.spp_pathmtu = SctpMtu - sizeof(struct sctp_common_header);
|
|
568
|
-
|
|
569
|
-
ret = usrsctp_setsockopt(
|
|
570
|
-
this->socket, IPPROTO_SCTP, SCTP_PEER_ADDR_PARAMS, &peerAddrParams, sizeof(peerAddrParams));
|
|
571
|
-
|
|
572
|
-
if (ret < 0)
|
|
573
|
-
{
|
|
574
|
-
MS_THROW_ERROR("usrsctp_setsockopt(SCTP_PEER_ADDR_PARAMS) failed: %s", std::strerror(errno));
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
// Announce connecting state.
|
|
578
|
-
MS_DEBUG_DEV("SCTP state switched to CONNECTING (in MayConnect())");
|
|
579
|
-
|
|
580
|
-
this->state = SctpState::CONNECTING;
|
|
581
|
-
this->listener->OnSctpAssociationConnecting(this);
|
|
582
|
-
}
|
|
583
|
-
catch (const MediaSoupError& /*error*/)
|
|
584
|
-
{
|
|
585
|
-
MS_DEBUG_DEV("SCTP state switched to FAILED (in MayConnect())");
|
|
586
|
-
|
|
587
|
-
this->state = SctpState::FAILED;
|
|
588
|
-
this->listener->OnSctpAssociationFailed(this);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
void SctpAssociation::ResetSctpStream(uint16_t streamId, StreamDirection direction) const
|
|
593
|
-
{
|
|
594
|
-
MS_TRACE();
|
|
595
|
-
|
|
596
|
-
// Do nothing if an outgoing stream that could not be allocated by us.
|
|
597
|
-
if (direction == StreamDirection::OUTGOING && streamId > this->os - 1)
|
|
598
|
-
{
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
int ret;
|
|
603
|
-
struct sctp_assoc_value av{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
604
|
-
socklen_t len = sizeof(av);
|
|
605
|
-
|
|
606
|
-
ret = usrsctp_getsockopt(this->socket, IPPROTO_SCTP, SCTP_RECONFIG_SUPPORTED, &av, &len);
|
|
607
|
-
|
|
608
|
-
if (ret == 0)
|
|
609
|
-
{
|
|
610
|
-
if (av.assoc_value != 1)
|
|
611
|
-
{
|
|
612
|
-
MS_DEBUG_TAG(sctp, "stream reconfiguration not negotiated");
|
|
613
|
-
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
else
|
|
618
|
-
{
|
|
619
|
-
MS_WARN_TAG(
|
|
620
|
-
sctp,
|
|
621
|
-
"could not retrieve whether stream reconfiguration has been negotiated: %s\n",
|
|
622
|
-
std::strerror(errno));
|
|
623
|
-
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
// As per spec: https://tools.ietf.org/html/rfc6525#section-4.1
|
|
628
|
-
len = sizeof(sctp_assoc_t) + ((2 + 1) * sizeof(uint16_t));
|
|
629
|
-
|
|
630
|
-
auto* srs = static_cast<struct sctp_reset_streams*>(std::malloc(len));
|
|
631
|
-
|
|
632
|
-
switch (direction)
|
|
633
|
-
{
|
|
634
|
-
case StreamDirection::INCOMING:
|
|
635
|
-
srs->srs_flags = SCTP_STREAM_RESET_INCOMING;
|
|
636
|
-
break;
|
|
637
|
-
|
|
638
|
-
case StreamDirection::OUTGOING:
|
|
639
|
-
srs->srs_flags = SCTP_STREAM_RESET_OUTGOING;
|
|
640
|
-
break;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
srs->srs_number_streams = 1;
|
|
644
|
-
srs->srs_stream_list[0] = streamId; // No need for htonl().
|
|
645
|
-
|
|
646
|
-
ret = usrsctp_setsockopt(this->socket, IPPROTO_SCTP, SCTP_RESET_STREAMS, srs, len);
|
|
647
|
-
|
|
648
|
-
if (ret == 0)
|
|
649
|
-
{
|
|
650
|
-
MS_DEBUG_TAG(sctp, "SCTP_RESET_STREAMS sent [streamId:%" PRIu16 "]", streamId);
|
|
651
|
-
}
|
|
652
|
-
else
|
|
653
|
-
{
|
|
654
|
-
MS_WARN_TAG(sctp, "usrsctp_setsockopt(SCTP_RESET_STREAMS) failed: %s", std::strerror(errno));
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
std::free(srs);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
void SctpAssociation::AddOutgoingStreams(bool force)
|
|
661
|
-
{
|
|
662
|
-
MS_TRACE();
|
|
663
|
-
|
|
664
|
-
uint16_t additionalOs{ 0 };
|
|
665
|
-
|
|
666
|
-
if (MaxSctpStreams - this->os >= 32)
|
|
667
|
-
{
|
|
668
|
-
additionalOs = 32;
|
|
669
|
-
}
|
|
670
|
-
else
|
|
671
|
-
{
|
|
672
|
-
additionalOs = MaxSctpStreams - this->os;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (additionalOs == 0)
|
|
676
|
-
{
|
|
677
|
-
MS_WARN_TAG(sctp, "cannot add more outgoing streams [OS:%" PRIu16 "]", this->os);
|
|
678
|
-
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
auto nextDesiredOs = this->os + additionalOs;
|
|
683
|
-
|
|
684
|
-
// Already in progress, ignore (unless forced).
|
|
685
|
-
if (!force && nextDesiredOs == this->desiredOs)
|
|
686
|
-
{
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
// Update desired value.
|
|
691
|
-
this->desiredOs = nextDesiredOs;
|
|
692
|
-
|
|
693
|
-
// If not connected, defer it.
|
|
694
|
-
if (this->state != SctpState::CONNECTED)
|
|
695
|
-
{
|
|
696
|
-
MS_DEBUG_TAG(sctp, "SCTP not connected, deferring OS increase");
|
|
697
|
-
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
struct sctp_add_streams sas{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
|
|
702
|
-
|
|
703
|
-
std::memset(&sas, 0, sizeof(sas));
|
|
704
|
-
sas.sas_instrms = 0;
|
|
705
|
-
sas.sas_outstrms = additionalOs;
|
|
706
|
-
|
|
707
|
-
MS_DEBUG_TAG(sctp, "adding %" PRIu16 " outgoing streams", additionalOs);
|
|
708
|
-
|
|
709
|
-
const int ret = usrsctp_setsockopt(
|
|
710
|
-
this->socket, IPPROTO_SCTP, SCTP_ADD_STREAMS, &sas, static_cast<socklen_t>(sizeof(sas)));
|
|
711
|
-
|
|
712
|
-
if (ret < 0)
|
|
713
|
-
{
|
|
714
|
-
MS_WARN_TAG(sctp, "usrsctp_setsockopt(SCTP_ADD_STREAMS) failed: %s", std::strerror(errno));
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
void SctpAssociation::OnUsrSctpSendSctpData(void* buffer, size_t len)
|
|
719
|
-
{
|
|
720
|
-
MS_TRACE();
|
|
721
|
-
|
|
722
|
-
const uint8_t* data = static_cast<uint8_t*>(buffer);
|
|
723
|
-
|
|
724
|
-
#if MS_LOG_DEV_LEVEL == 3
|
|
725
|
-
// NOTE: Only uncomment this during local debugging if needed.
|
|
726
|
-
// MS_DUMP_DATA(data, len);
|
|
727
|
-
#endif
|
|
728
|
-
|
|
729
|
-
this->listener->OnSctpAssociationSendData(this, data, len);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
void SctpAssociation::OnUsrSctpReceiveSctpData(
|
|
733
|
-
uint16_t streamId, uint16_t ssn, uint32_t ppid, int flags, const uint8_t* data, size_t len)
|
|
734
|
-
{
|
|
735
|
-
// Ignore WebRTC DataChannel Control DATA chunks.
|
|
736
|
-
if (ppid == 50)
|
|
737
|
-
{
|
|
738
|
-
MS_WARN_TAG(sctp, "ignoring SCTP data with ppid:50 (WebRTC DataChannel Control)");
|
|
739
|
-
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
if (this->messageBufferLen != 0 && ssn != this->lastSsnReceived)
|
|
744
|
-
{
|
|
745
|
-
MS_WARN_TAG(
|
|
746
|
-
sctp,
|
|
747
|
-
"message chunk received with different SSN while buffer not empty, buffer discarded [ssn:%" PRIu16
|
|
748
|
-
", last ssn received:%" PRIu16 "]",
|
|
749
|
-
ssn,
|
|
750
|
-
this->lastSsnReceived);
|
|
751
|
-
|
|
752
|
-
this->messageBufferLen = 0;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
// Update last SSN received.
|
|
756
|
-
this->lastSsnReceived = ssn;
|
|
757
|
-
|
|
758
|
-
auto eor = static_cast<bool>(flags & MSG_EOR);
|
|
759
|
-
|
|
760
|
-
if (this->messageBufferLen + len > this->maxSctpMessageSize)
|
|
761
|
-
{
|
|
762
|
-
MS_WARN_TAG(
|
|
763
|
-
sctp,
|
|
764
|
-
"ongoing received message exceeds max allowed message size [message size:%zu, max message size:%zu, eor:%u]",
|
|
765
|
-
this->messageBufferLen + len,
|
|
766
|
-
this->maxSctpMessageSize,
|
|
767
|
-
eor ? 1 : 0);
|
|
768
|
-
|
|
769
|
-
this->lastSsnReceived = 0;
|
|
770
|
-
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// If end of message and there is no buffered data, notify it directly.
|
|
775
|
-
if (eor && this->messageBufferLen == 0)
|
|
776
|
-
{
|
|
777
|
-
MS_DEBUG_DEV("directly notifying listener [eor:1, buffer len:0]");
|
|
778
|
-
|
|
779
|
-
this->listener->OnSctpAssociationMessageReceived(this, streamId, data, len, ppid);
|
|
780
|
-
}
|
|
781
|
-
// If end of message and there is buffered data, append data and notify buffer.
|
|
782
|
-
else if (eor && this->messageBufferLen != 0)
|
|
783
|
-
{
|
|
784
|
-
std::memcpy(this->messageBuffer + this->messageBufferLen, data, len);
|
|
785
|
-
this->messageBufferLen += len;
|
|
786
|
-
|
|
787
|
-
MS_DEBUG_DEV("notifying listener [eor:1, buffer len:%zu]", this->messageBufferLen);
|
|
788
|
-
|
|
789
|
-
this->listener->OnSctpAssociationMessageReceived(
|
|
790
|
-
this, streamId, this->messageBuffer, this->messageBufferLen, ppid);
|
|
791
|
-
|
|
792
|
-
this->messageBufferLen = 0;
|
|
793
|
-
}
|
|
794
|
-
// If non end of message, append data to the buffer.
|
|
795
|
-
else if (!eor)
|
|
796
|
-
{
|
|
797
|
-
// Allocate the buffer if not already done.
|
|
798
|
-
if (!this->messageBuffer)
|
|
799
|
-
{
|
|
800
|
-
this->messageBuffer = new uint8_t[this->maxSctpMessageSize];
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
std::memcpy(this->messageBuffer + this->messageBufferLen, data, len);
|
|
804
|
-
this->messageBufferLen += len;
|
|
805
|
-
|
|
806
|
-
MS_DEBUG_DEV("data buffered [eor:0, buffer len:%zu]", this->messageBufferLen);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
void SctpAssociation::OnUsrSctpReceiveSctpNotification(union sctp_notification* notification, size_t len)
|
|
811
|
-
{
|
|
812
|
-
if (notification->sn_header.sn_length != (uint32_t)len)
|
|
813
|
-
{
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
switch (notification->sn_header.sn_type)
|
|
818
|
-
{
|
|
819
|
-
case SCTP_ADAPTATION_INDICATION:
|
|
820
|
-
{
|
|
821
|
-
MS_DEBUG_TAG(
|
|
822
|
-
sctp,
|
|
823
|
-
"SCTP adaptation indication [%x]",
|
|
824
|
-
notification->sn_adaptation_event.sai_adaptation_ind);
|
|
825
|
-
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
case SCTP_ASSOC_CHANGE:
|
|
830
|
-
{
|
|
831
|
-
switch (notification->sn_assoc_change.sac_state)
|
|
832
|
-
{
|
|
833
|
-
case SCTP_COMM_UP:
|
|
834
|
-
{
|
|
835
|
-
MS_DEBUG_TAG(
|
|
836
|
-
sctp,
|
|
837
|
-
"SCTP association connected, streams [out:%" PRIu16 ", in:%" PRIu16 "]",
|
|
838
|
-
notification->sn_assoc_change.sac_outbound_streams,
|
|
839
|
-
notification->sn_assoc_change.sac_inbound_streams);
|
|
840
|
-
|
|
841
|
-
// Update our OS.
|
|
842
|
-
this->os = notification->sn_assoc_change.sac_outbound_streams;
|
|
843
|
-
|
|
844
|
-
// Increase if requested before connected.
|
|
845
|
-
if (this->desiredOs > this->os)
|
|
846
|
-
{
|
|
847
|
-
AddOutgoingStreams(/*force*/ true);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
if (this->state != SctpState::CONNECTED)
|
|
851
|
-
{
|
|
852
|
-
MS_DEBUG_DEV("SCTP state switched to CONNECTED (in SCTP_ASSOC_CHANGE)");
|
|
853
|
-
|
|
854
|
-
this->state = SctpState::CONNECTED;
|
|
855
|
-
this->listener->OnSctpAssociationConnected(this);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
break;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
case SCTP_COMM_LOST:
|
|
862
|
-
{
|
|
863
|
-
if (notification->sn_header.sn_length > 0)
|
|
864
|
-
{
|
|
865
|
-
static const size_t BufferSize{ 1024 };
|
|
866
|
-
thread_local char buffer[BufferSize];
|
|
867
|
-
|
|
868
|
-
const uint32_t len =
|
|
869
|
-
notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change);
|
|
870
|
-
|
|
871
|
-
for (uint32_t i{ 0 }; i < len; ++i)
|
|
872
|
-
{
|
|
873
|
-
std::snprintf(
|
|
874
|
-
buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]);
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
MS_DEBUG_TAG(sctp, "SCTP communication lost [info:%s]", buffer);
|
|
878
|
-
}
|
|
879
|
-
else
|
|
880
|
-
{
|
|
881
|
-
MS_DEBUG_TAG(sctp, "SCTP communication lost");
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
if (this->state != SctpState::CLOSED)
|
|
885
|
-
{
|
|
886
|
-
MS_DEBUG_DEV("SCTP state switched to CLOSED (in SCTP_COMM_LOST)");
|
|
887
|
-
|
|
888
|
-
this->state = SctpState::CLOSED;
|
|
889
|
-
this->listener->OnSctpAssociationClosed(this);
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
case SCTP_RESTART:
|
|
896
|
-
{
|
|
897
|
-
MS_DEBUG_TAG(
|
|
898
|
-
sctp,
|
|
899
|
-
"SCTP remote association restarted, streams [out:%" PRIu16 ", int:%" PRIu16 "]",
|
|
900
|
-
notification->sn_assoc_change.sac_outbound_streams,
|
|
901
|
-
notification->sn_assoc_change.sac_inbound_streams);
|
|
902
|
-
|
|
903
|
-
// Update our OS.
|
|
904
|
-
this->os = notification->sn_assoc_change.sac_outbound_streams;
|
|
905
|
-
|
|
906
|
-
// Increase if requested before connected.
|
|
907
|
-
if (this->desiredOs > this->os)
|
|
908
|
-
{
|
|
909
|
-
AddOutgoingStreams(/*force*/ true);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
if (this->state != SctpState::CONNECTED)
|
|
913
|
-
{
|
|
914
|
-
MS_DEBUG_DEV("SCTP state switched to CONNECTED (in SCTP_RESTART)");
|
|
915
|
-
|
|
916
|
-
this->state = SctpState::CONNECTED;
|
|
917
|
-
this->listener->OnSctpAssociationConnected(this);
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
break;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
case SCTP_SHUTDOWN_COMP:
|
|
924
|
-
{
|
|
925
|
-
MS_DEBUG_TAG(sctp, "SCTP association gracefully closed");
|
|
926
|
-
|
|
927
|
-
if (this->state != SctpState::CLOSED)
|
|
928
|
-
{
|
|
929
|
-
MS_DEBUG_DEV("SCTP state switched to CLOSED (in SCTP_SHUTDOWN_COMP)");
|
|
930
|
-
|
|
931
|
-
this->state = SctpState::CLOSED;
|
|
932
|
-
this->listener->OnSctpAssociationClosed(this);
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
break;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
case SCTP_CANT_STR_ASSOC:
|
|
939
|
-
{
|
|
940
|
-
if (notification->sn_header.sn_length > 0)
|
|
941
|
-
{
|
|
942
|
-
static const size_t BufferSize{ 1024 };
|
|
943
|
-
thread_local char buffer[BufferSize];
|
|
944
|
-
|
|
945
|
-
const uint32_t len =
|
|
946
|
-
notification->sn_assoc_change.sac_length - sizeof(struct sctp_assoc_change);
|
|
947
|
-
|
|
948
|
-
for (uint32_t i{ 0 }; i < len; ++i)
|
|
949
|
-
{
|
|
950
|
-
std::snprintf(
|
|
951
|
-
buffer, BufferSize, " 0x%02x", notification->sn_assoc_change.sac_info[i]);
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
MS_WARN_TAG(sctp, "SCTP setup failed: %s", buffer);
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
if (this->state != SctpState::FAILED)
|
|
958
|
-
{
|
|
959
|
-
MS_DEBUG_DEV("SCTP state switched to FAILED (in SCTP_CANT_STR_ASSOC)");
|
|
960
|
-
|
|
961
|
-
this->state = SctpState::FAILED;
|
|
962
|
-
this->listener->OnSctpAssociationFailed(this);
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
break;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
default:;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
break;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// https://tools.ietf.org/html/rfc6525#section-6.1.2.
|
|
975
|
-
case SCTP_ASSOC_RESET_EVENT:
|
|
976
|
-
{
|
|
977
|
-
MS_DEBUG_TAG(sctp, "SCTP association reset event received");
|
|
978
|
-
|
|
979
|
-
break;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
// An Operation Error is not considered fatal in and of itself, but may be
|
|
983
|
-
// used with an ABORT chunk to report a fatal condition.
|
|
984
|
-
case SCTP_REMOTE_ERROR:
|
|
985
|
-
{
|
|
986
|
-
static const size_t BufferSize{ 1024 };
|
|
987
|
-
thread_local char buffer[BufferSize];
|
|
988
|
-
|
|
989
|
-
const uint32_t len =
|
|
990
|
-
notification->sn_remote_error.sre_length - sizeof(struct sctp_remote_error);
|
|
991
|
-
|
|
992
|
-
for (uint32_t i{ 0 }; i < len; i++)
|
|
993
|
-
{
|
|
994
|
-
std::snprintf(buffer, BufferSize, "0x%02x", notification->sn_remote_error.sre_data[i]);
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
MS_WARN_TAG(
|
|
998
|
-
sctp,
|
|
999
|
-
"remote SCTP association error [type:0x%04x, data:%s]",
|
|
1000
|
-
notification->sn_remote_error.sre_error,
|
|
1001
|
-
buffer);
|
|
1002
|
-
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
// When a peer sends a SHUTDOWN, SCTP delivers this notification to
|
|
1007
|
-
// inform the application that it should cease sending data.
|
|
1008
|
-
case SCTP_SHUTDOWN_EVENT:
|
|
1009
|
-
{
|
|
1010
|
-
MS_DEBUG_TAG(sctp, "remote SCTP association shutdown");
|
|
1011
|
-
|
|
1012
|
-
if (this->state != SctpState::CLOSED)
|
|
1013
|
-
{
|
|
1014
|
-
MS_DEBUG_DEV("SCTP state switched to CLOSED (in SCTP_SHUTDOWN_EVENT)");
|
|
1015
|
-
|
|
1016
|
-
this->state = SctpState::CLOSED;
|
|
1017
|
-
this->listener->OnSctpAssociationClosed(this);
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
break;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
case SCTP_SEND_FAILED_EVENT:
|
|
1024
|
-
{
|
|
1025
|
-
static const size_t BufferSize{ 1024 };
|
|
1026
|
-
thread_local char buffer[BufferSize];
|
|
1027
|
-
|
|
1028
|
-
const uint32_t len =
|
|
1029
|
-
notification->sn_send_failed_event.ssfe_length - sizeof(struct sctp_send_failed_event);
|
|
1030
|
-
|
|
1031
|
-
for (uint32_t i{ 0 }; i < len; ++i)
|
|
1032
|
-
{
|
|
1033
|
-
std::snprintf(buffer, BufferSize, "0x%02x", notification->sn_send_failed_event.ssfe_data[i]);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
MS_WARN_TAG(
|
|
1037
|
-
sctp,
|
|
1038
|
-
"SCTP message sent failure [streamId:%" PRIu16 ", ppid:%" PRIu32
|
|
1039
|
-
", sent:%s, error:0x%08x, info:%s]",
|
|
1040
|
-
notification->sn_send_failed_event.ssfe_info.snd_sid,
|
|
1041
|
-
ntohl(notification->sn_send_failed_event.ssfe_info.snd_ppid),
|
|
1042
|
-
(notification->sn_send_failed_event.ssfe_flags & SCTP_DATA_SENT) ? "yes" : "no",
|
|
1043
|
-
notification->sn_send_failed_event.ssfe_error,
|
|
1044
|
-
buffer);
|
|
1045
|
-
|
|
1046
|
-
break;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
case SCTP_STREAM_RESET_EVENT:
|
|
1050
|
-
{
|
|
1051
|
-
bool incoming{ false };
|
|
1052
|
-
bool outgoing{ false };
|
|
1053
|
-
const uint16_t numStreams =
|
|
1054
|
-
(notification->sn_strreset_event.strreset_length - sizeof(struct sctp_stream_reset_event)) /
|
|
1055
|
-
sizeof(uint16_t);
|
|
1056
|
-
|
|
1057
|
-
if (notification->sn_strreset_event.strreset_flags & SCTP_STREAM_RESET_INCOMING_SSN)
|
|
1058
|
-
{
|
|
1059
|
-
incoming = true;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
if (notification->sn_strreset_event.strreset_flags & SCTP_STREAM_RESET_OUTGOING_SSN)
|
|
1063
|
-
{
|
|
1064
|
-
outgoing = true;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
if (MS_HAS_DEBUG_TAG(sctp))
|
|
1068
|
-
{
|
|
1069
|
-
std::string streamIds;
|
|
1070
|
-
|
|
1071
|
-
for (uint16_t i{ 0 }; i < numStreams; ++i)
|
|
1072
|
-
{
|
|
1073
|
-
auto streamId = notification->sn_strreset_event.strreset_stream_list[i];
|
|
1074
|
-
|
|
1075
|
-
// Don't log more than 5 stream ids.
|
|
1076
|
-
if (i > 4)
|
|
1077
|
-
{
|
|
1078
|
-
streamIds.append("...");
|
|
1079
|
-
|
|
1080
|
-
break;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
if (i > 0)
|
|
1084
|
-
{
|
|
1085
|
-
streamIds.append(",");
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
streamIds.append(std::to_string(streamId));
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
MS_DEBUG_TAG(
|
|
1092
|
-
sctp,
|
|
1093
|
-
"SCTP stream reset event [flags:%x, i|o:%s|%s, num streams:%" PRIu16 ", stream ids:%s]",
|
|
1094
|
-
notification->sn_strreset_event.strreset_flags,
|
|
1095
|
-
incoming ? "true" : "false",
|
|
1096
|
-
outgoing ? "true" : "false",
|
|
1097
|
-
numStreams,
|
|
1098
|
-
streamIds.c_str());
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// Special case for WebRTC DataChannels in which we must also reset our
|
|
1102
|
-
// outgoing SCTP stream.
|
|
1103
|
-
if (incoming && !outgoing && this->isDataChannel)
|
|
1104
|
-
{
|
|
1105
|
-
for (uint16_t i{ 0 }; i < numStreams; ++i)
|
|
1106
|
-
{
|
|
1107
|
-
auto streamId = notification->sn_strreset_event.strreset_stream_list[i];
|
|
1108
|
-
|
|
1109
|
-
ResetSctpStream(streamId, StreamDirection::OUTGOING);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
break;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
case SCTP_STREAM_CHANGE_EVENT:
|
|
1117
|
-
{
|
|
1118
|
-
if (notification->sn_strchange_event.strchange_flags == 0)
|
|
1119
|
-
{
|
|
1120
|
-
MS_DEBUG_TAG(
|
|
1121
|
-
sctp,
|
|
1122
|
-
"SCTP stream changed, streams [out:%" PRIu16 ", in:%" PRIu16 ", flags:%x]",
|
|
1123
|
-
notification->sn_strchange_event.strchange_outstrms,
|
|
1124
|
-
notification->sn_strchange_event.strchange_instrms,
|
|
1125
|
-
notification->sn_strchange_event.strchange_flags);
|
|
1126
|
-
}
|
|
1127
|
-
else if (notification->sn_strchange_event.strchange_flags & SCTP_STREAM_RESET_DENIED)
|
|
1128
|
-
{
|
|
1129
|
-
MS_WARN_TAG(
|
|
1130
|
-
sctp,
|
|
1131
|
-
"SCTP stream change denied, streams [out:%" PRIu16 ", in:%" PRIu16 ", flags:%x]",
|
|
1132
|
-
notification->sn_strchange_event.strchange_outstrms,
|
|
1133
|
-
notification->sn_strchange_event.strchange_instrms,
|
|
1134
|
-
notification->sn_strchange_event.strchange_flags);
|
|
1135
|
-
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
else if (notification->sn_strchange_event.strchange_flags & SCTP_STREAM_RESET_FAILED)
|
|
1139
|
-
{
|
|
1140
|
-
MS_WARN_TAG(
|
|
1141
|
-
sctp,
|
|
1142
|
-
"SCTP stream change failed, streams [out:%" PRIu16 ", in:%" PRIu16 ", flags:%x]",
|
|
1143
|
-
notification->sn_strchange_event.strchange_outstrms,
|
|
1144
|
-
notification->sn_strchange_event.strchange_instrms,
|
|
1145
|
-
notification->sn_strchange_event.strchange_flags);
|
|
1146
|
-
|
|
1147
|
-
break;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// Update OS.
|
|
1151
|
-
this->os = notification->sn_strchange_event.strchange_outstrms;
|
|
1152
|
-
|
|
1153
|
-
break;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
default:
|
|
1157
|
-
{
|
|
1158
|
-
MS_WARN_TAG(
|
|
1159
|
-
sctp, "unhandled SCTP event received [type:%" PRIu16 "]", notification->sn_header.sn_type);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
void SctpAssociation::OnUsrSctpSentData(uint32_t freeBuffer)
|
|
1165
|
-
{
|
|
1166
|
-
auto previousSctpBufferedAmount = this->sctpBufferedAmount;
|
|
1167
|
-
|
|
1168
|
-
this->sctpBufferedAmount = this->sctpSendBufferSize - freeBuffer;
|
|
1169
|
-
|
|
1170
|
-
if (this->sctpBufferedAmount != previousSctpBufferedAmount)
|
|
1171
|
-
{
|
|
1172
|
-
this->listener->OnSctpAssociationBufferedAmount(this, this->sctpBufferedAmount);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
} // namespace RTC
|