werift 0.25.2 → 0.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/README.md +63 -0
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/asn1.d.ts +42 -0
- package/lib/common/src/asn1.js +163 -0
- package/lib/common/src/asn1.js.map +1 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/index.d.ts +6 -5
- package/lib/common/src/index.js +6 -5
- package/lib/common/src/index.js.map +1 -1
- package/lib/common/src/log.d.ts +12 -1
- package/lib/common/src/log.js +142 -12
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/queue.d.ts +41 -0
- package/lib/common/src/queue.js +146 -0
- package/lib/common/src/queue.js.map +1 -0
- package/lib/common/src/transport.d.ts +15 -2
- package/lib/common/src/transport.js +108 -19
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/cipher/create.js.map +1 -1
- package/lib/dtls/src/cipher/ec.js +8 -8
- package/lib/dtls/src/cipher/ec.js.map +1 -1
- package/lib/dtls/src/cipher/namedCurve.js +6 -7
- package/lib/dtls/src/cipher/namedCurve.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +2 -2
- package/lib/dtls/src/cipher/prf.js +29 -8
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/suites/aead.d.ts +1 -1
- package/lib/dtls/src/context/certificate.d.ts +32 -0
- package/lib/dtls/src/context/certificate.js +54 -0
- package/lib/dtls/src/context/certificate.js.map +1 -0
- package/lib/dtls/src/context/cipher.d.ts +13 -7
- package/lib/dtls/src/context/cipher.js +58 -106
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.js +4 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +4 -0
- package/lib/dtls/src/context/transport.js +16 -1
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +4 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +1 -1
- package/lib/dtls/src/flight/flight.js +16 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.d.ts +2 -1
- package/lib/dtls/src/flight/server/flight4.js +12 -4
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +2 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/signature.d.ts +1 -1
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +5 -3
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +3 -2
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +4 -4
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +5 -3
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +15 -8
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +3 -2
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -4
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +14 -8
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -3
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +17 -9
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +1 -1
- package/lib/dtls/src/handshake/random.js +7 -4
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/imports/common.d.ts +1 -0
- package/lib/dtls/src/imports/common.js +1 -0
- package/lib/dtls/src/imports/common.js.map +1 -1
- package/lib/dtls/src/index.d.ts +2 -2
- package/lib/dtls/src/index.js +2 -2
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +43 -33
- package/lib/dtls/src/record/const.js +43 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +1 -1
- package/lib/dtls/src/record/message/fragment.js +15 -9
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +12 -7
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.js +2 -2
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +1 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +2 -2
- package/lib/dtls/src/socket.js +6 -4
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +46 -0
- package/lib/ice/src/exceptions.js +92 -5
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/helper.d.ts +1 -1
- package/lib/ice/src/ice.d.ts +191 -5
- package/lib/ice/src/ice.js +1048 -156
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +174 -10
- package/lib/ice/src/iceBase.js +165 -12
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +5 -5
- package/lib/ice/src/index.js +5 -5
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +26 -0
- package/lib/ice/src/internal/resolveHostAddresses.js +45 -0
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +3 -1
- package/lib/ice/src/stun/protocol.js +16 -0
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -0
- package/lib/ice/src/stun/tcpProtocol.js +16 -1
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +35 -1
- package/lib/ice/src/stun/transaction.js +93 -18
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +97 -7
- package/lib/ice/src/turn/protocol.js +357 -55
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +7 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +24 -16
- package/lib/ice-server/src/stun/const.js +22 -18
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +3 -1
- package/lib/ice-server/src/stun/message.js +41 -6
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/turn/auth.d.ts +1 -1
- package/lib/index.mjs +25252 -12664
- package/lib/nonstandard/index.mjs +11015 -8906
- package/lib/polyfill/dom.mjs +30779 -18386
- package/lib/polyfill/index.mjs +30779 -18386
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.d.ts +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/container.d.ts +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +6 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +26 -4
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +6 -1
- package/lib/rtp/src/extra/processor/depacketizer.js +29 -3
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtxCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/interface.d.ts +16 -11
- package/lib/rtp/src/extra/processor/interface.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +7 -4
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
- package/lib/rtp/src/extra/processor/nack.js +5 -3
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js +3 -2
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.d.ts +2 -2
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTimeCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/webm.d.ts +27 -0
- package/lib/rtp/src/extra/processor/webm.js +57 -23
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js +6 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmStream.js.map +1 -1
- package/lib/rtp/src/helper.d.ts +2 -2
- package/lib/rtp/src/helper.js +2 -6
- package/lib/rtp/src/helper.js.map +1 -1
- package/lib/rtp/src/index.d.ts +10 -2
- package/lib/rtp/src/index.js +10 -2
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +6 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +9 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.d.ts +4 -3
- package/lib/rtp/src/rtcp/sr.js +4 -2
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +36 -0
- package/lib/rtp/src/rtp/continuity.js +100 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.d.ts +2 -2
- package/lib/rtp/src/srtp/cipher/ctr.js +5 -3
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.d.ts +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.js +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.d.ts +29 -1
- package/lib/rtp/src/srtp/context/context.js +84 -27
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +36 -4
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/index.d.ts +4 -3
- package/lib/sctp/src/index.js +10 -8
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +91 -2
- package/lib/sctp/src/sctp.js +700 -134
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/peerConfig.d.ts +307 -0
- package/lib/webrtc/src/api/peerConfig.js +291 -0
- package/lib/webrtc/src/api/peerConfig.js.map +1 -0
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +36 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js +44 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -0
- package/lib/webrtc/src/dataChannel.d.ts +11 -1
- package/lib/webrtc/src/dataChannel.js +25 -5
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/index.d.ts +2 -2
- package/lib/webrtc/src/index.js +2 -2
- package/lib/webrtc/src/index.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +11 -1
- package/lib/webrtc/src/media/index.js +71 -1
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.js +5 -5
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +130 -6
- package/lib/webrtc/src/media/router.js +325 -29
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +137 -14
- package/lib/webrtc/src/media/rtpReceiver.js +420 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +232 -65
- package/lib/webrtc/src/media/rtpSender.js +784 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +95 -4
- package/lib/webrtc/src/media/rtpTransceiver.js +121 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -32
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -142
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderStats.d.ts +100 -0
- package/lib/webrtc/src/media/sender/senderStats.js +322 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +21 -3
- package/lib/webrtc/src/media/track.js +24 -6
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +103 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js +384 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.d.ts +51 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js +267 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.d.ts +21 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js +61 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +34 -0
- package/lib/webrtc/src/negotiation/internalState.js +21 -0
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.d.ts +44 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +119 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +86 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js +349 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +71 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +414 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +59 -0
- package/lib/webrtc/src/negotiation/transportActivation.js +356 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
- package/lib/webrtc/src/negotiationTransaction.d.ts +240 -0
- package/lib/webrtc/src/negotiationTransaction.js +604 -0
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/index.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/index.js +1 -1
- package/lib/webrtc/src/nonstandard/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +10 -8
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +10 -3
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia.js +4 -3
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +176 -238
- package/lib/webrtc/src/peerConnection.js +1042 -913
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +5 -5
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +1 -1
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/registers/mp4Webm.js.map +1 -1
- package/lib/webrtc/src/polyfill/registers/rtpRtcp.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +97 -1
- package/lib/webrtc/src/sctpManager.js +189 -9
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.js +12 -6
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +55 -11
- package/lib/webrtc/src/sdpManager.js +364 -87
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -28
- package/lib/webrtc/src/secureTransportManager.js +232 -53
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +62 -18
- package/lib/webrtc/src/transceiverManager.js +272 -107
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +64 -3
- package/lib/webrtc/src/transport/dtls.js +166 -42
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +199 -28
- package/lib/webrtc/src/transport/ice.js +666 -71
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +98 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js +129 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -0
- package/lib/webrtc/src/transport/sctp.d.ts +6 -1
- package/lib/webrtc/src/transport/sctp.js +149 -37
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +39 -6
- package/lib/webrtc/src/utils.js +57 -17
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +16 -15
|
@@ -1,15 +1,66 @@
|
|
|
1
1
|
import type { SCTPOptions } from "../../sctp/src";
|
|
2
|
-
import { Event } from "./imports/common";
|
|
3
2
|
import { RTCDataChannel } from "./dataChannel";
|
|
3
|
+
import { Event } from "./imports/common";
|
|
4
4
|
import { type RTCStats } from "./media/stats";
|
|
5
5
|
import type { MediaDescription } from "./sdp";
|
|
6
|
+
import type { RTCDtlsTransport } from "./transport/dtls";
|
|
6
7
|
import { RTCSctpTransport } from "./transport/sctp";
|
|
8
|
+
/** The SCTP binding of a PeerConnection, for a negotiation rollback baseline. */
|
|
9
|
+
export type SctpNegotiationState = ReturnType<SctpTransportManager["snapshotNegotiationState"]>;
|
|
10
|
+
/**
|
|
11
|
+
* The SCTP transport of a PeerConnection and its application m-line.
|
|
12
|
+
*
|
|
13
|
+
* - Rejection of the application m-line (port 0) keeps the SCTP transport:
|
|
14
|
+
* it stays bound to its MID and the next offer offers the application again
|
|
15
|
+
* with that MID (W3C would set `sctpTransport` to null). A rejecting remote
|
|
16
|
+
* offer or pranswer is provisional and leaves the association alone, and
|
|
17
|
+
* so does any rejection of an association the rollback baseline negotiated.
|
|
18
|
+
* A final answer with port 0 (RFC 8841 section 10.4), local or remote,
|
|
19
|
+
* aborts an association the proposal started (a pranswer or the remote
|
|
20
|
+
* INIT) and releases the remote port on that peer (`rejectApplication`).
|
|
21
|
+
* Channels on it close; the other peer closes its own when it applies the
|
|
22
|
+
* same answer. The commit does not move the transport to
|
|
23
|
+
* a transport the answer did not negotiate for it. An answer to an offer
|
|
24
|
+
* whose application m-line has port 0 has port 0 (RFC 3264 section 6).
|
|
25
|
+
* - The position (MID, index, rejected) is recorded by the current
|
|
26
|
+
* description, not by this object. An unbound transport takes a rejected
|
|
27
|
+
* position with a new MID; an offer that does so moves the transport to that
|
|
28
|
+
* MID (restored by rollback). A MID only an unapplied `createOffer`
|
|
29
|
+
* reserved follows the MID of the peer's offer.
|
|
30
|
+
* - At the final answer SCTP moves straight to its owner's DTLS transport in
|
|
31
|
+
* the answer. SCTP starts after every answer or pranswer that negotiates the
|
|
32
|
+
* application m-line (JSEP 5.11), also on an already connected DTLS
|
|
33
|
+
* transport: an `m=application` a renegotiation adds to a connected session
|
|
34
|
+
* starts without touching ICE or DTLS and without moving `connectionState`.
|
|
35
|
+
* Its client / server side follows the ICE role at the DTLS start. Starting
|
|
36
|
+
* is idempotent (`RTCSctpTransport.ensureStarted`): an established
|
|
37
|
+
* association, also one the remote INIT established first, a handshaking
|
|
38
|
+
* one and a closed one never start again, so a final answer keeping the
|
|
39
|
+
* pranswer's sctp-port continues it. A final answer changing the sctp-port
|
|
40
|
+
* is rejected in validation.
|
|
41
|
+
* - Rollback keeps an application-owned transport (`detachFromDescription`
|
|
42
|
+
* clears what the description set), whether it is in the baseline or was
|
|
43
|
+
* added during the transaction, and stops one a description created. When
|
|
44
|
+
* the baseline has no negotiated remote port, an association that left its
|
|
45
|
+
* initial state under the proposal (started by a pranswer, or established
|
|
46
|
+
* from the remote INIT) is pending-only: it is aborted and an
|
|
47
|
+
* application-owned transport gets a new, unstarted association on the same
|
|
48
|
+
* DTLS transport. Its channels with a stream ID close; channels still
|
|
49
|
+
* waiting for one stay `connecting` for the next negotiation.
|
|
50
|
+
* - `sctp.mtu` is configuration: every transport, also a pending one, is built
|
|
51
|
+
* with it, and moving to another DTLS transport keeps it.
|
|
52
|
+
*/
|
|
7
53
|
export declare class SctpTransportManager {
|
|
8
54
|
sctpTransport?: RTCSctpTransport;
|
|
9
55
|
sctpRemotePort?: number;
|
|
10
56
|
dataChannelsOpened: number;
|
|
11
57
|
dataChannelsClosed: number;
|
|
12
58
|
private dataChannels;
|
|
59
|
+
/**
|
|
60
|
+
* SCTP transports that carry a `createDataChannel` call. They are
|
|
61
|
+
* application state: negotiation rollback keeps them instead of stopping.
|
|
62
|
+
*/
|
|
63
|
+
private readonly applicationOwned;
|
|
13
64
|
readonly onDataChannel: Event<[RTCDataChannel]>;
|
|
14
65
|
constructor();
|
|
15
66
|
createSctpTransport(maxMessageSize?: number, sctpOptions?: SCTPOptions): RTCSctpTransport;
|
|
@@ -21,7 +72,52 @@ export declare class SctpTransportManager {
|
|
|
21
72
|
negotiated: boolean;
|
|
22
73
|
id?: number;
|
|
23
74
|
}>): RTCDataChannel;
|
|
75
|
+
/**
|
|
76
|
+
* Count a channel (created here or announced by the remote peer) and keep
|
|
77
|
+
* it for getStats until it closes. The listener goes with it: a closed
|
|
78
|
+
* channel the application still holds must not keep the manager reachable.
|
|
79
|
+
*/
|
|
80
|
+
private track;
|
|
81
|
+
isApplicationOwned(transport: RTCSctpTransport): boolean;
|
|
82
|
+
/** Internal: the SCTP binding a negotiation may change, for a rollback baseline. */
|
|
83
|
+
snapshotNegotiationState(): {
|
|
84
|
+
transport: RTCSctpTransport | undefined;
|
|
85
|
+
dtlsTransport: RTCDtlsTransport | undefined;
|
|
86
|
+
remotePort: number | undefined;
|
|
87
|
+
mid: string | undefined;
|
|
88
|
+
mLineIndex: number | undefined;
|
|
89
|
+
remoteMaxMessageSize: number | undefined;
|
|
90
|
+
};
|
|
91
|
+
/** Internal: return to a negotiation baseline taken by `snapshotNegotiationState`. */
|
|
92
|
+
restoreNegotiationState(state: SctpNegotiationState): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Internal: a final answer rejected the application m-line (port 0, RFC
|
|
95
|
+
* 8841 section 10.4). The association a pranswer started closes; the
|
|
96
|
+
* transport waits unbound for a later negotiation.
|
|
97
|
+
*/
|
|
98
|
+
rejectApplication(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Internal: an SCTP transport that no description bound yet goes back to
|
|
101
|
+
* the MID / m-line index of `state` (see TransceiverManager's
|
|
102
|
+
* `revertUnappliedAssociations`).
|
|
103
|
+
*/
|
|
104
|
+
revertUnappliedAssociation(state: SctpNegotiationState): void;
|
|
105
|
+
/** Drop what a rolled-back description set on a kept SCTP transport. */
|
|
106
|
+
detachFromDescription(transport: RTCSctpTransport): void;
|
|
107
|
+
/**
|
|
108
|
+
* Start the association of the negotiated application m-line and wait
|
|
109
|
+
* until it is established. Safe to call any number of times: an
|
|
110
|
+
* established (also passively established) or handshaking association is
|
|
111
|
+
* not started again, and a closed one is not waited for. The wait is
|
|
112
|
+
* bounded even if the remote never answers: the INIT retries (T1) give up
|
|
113
|
+
* and the association emits `closed`.
|
|
114
|
+
*/
|
|
24
115
|
connectSctp(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* A renegotiation pranswer / answer keeps the association (and its port)
|
|
118
|
+
* but updates the data max message size it negotiates.
|
|
119
|
+
*/
|
|
120
|
+
updateRemoteMaxMessageSize(remoteMedia: MediaDescription): void;
|
|
25
121
|
setRemoteSCTP(remoteMedia: MediaDescription, mLineIndex: number): void;
|
|
26
122
|
close(): Promise<void>;
|
|
27
123
|
getStats(timestamp?: number): Promise<RTCStats[]>;
|
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SctpTransportManager = void 0;
|
|
4
|
+
const dataChannel_1 = require("./dataChannel");
|
|
4
5
|
const errors_1 = require("./errors");
|
|
5
6
|
const common_1 = require("./imports/common");
|
|
6
|
-
const dataChannel_1 = require("./dataChannel");
|
|
7
7
|
const stats_1 = require("./media/stats");
|
|
8
8
|
const sctp_1 = require("./transport/sctp");
|
|
9
9
|
const log = (0, common_1.debug)("werift:packages/webrtc/src/transport/sctpManager.ts");
|
|
10
|
+
/**
|
|
11
|
+
* The SCTP transport of a PeerConnection and its application m-line.
|
|
12
|
+
*
|
|
13
|
+
* - Rejection of the application m-line (port 0) keeps the SCTP transport:
|
|
14
|
+
* it stays bound to its MID and the next offer offers the application again
|
|
15
|
+
* with that MID (W3C would set `sctpTransport` to null). A rejecting remote
|
|
16
|
+
* offer or pranswer is provisional and leaves the association alone, and
|
|
17
|
+
* so does any rejection of an association the rollback baseline negotiated.
|
|
18
|
+
* A final answer with port 0 (RFC 8841 section 10.4), local or remote,
|
|
19
|
+
* aborts an association the proposal started (a pranswer or the remote
|
|
20
|
+
* INIT) and releases the remote port on that peer (`rejectApplication`).
|
|
21
|
+
* Channels on it close; the other peer closes its own when it applies the
|
|
22
|
+
* same answer. The commit does not move the transport to
|
|
23
|
+
* a transport the answer did not negotiate for it. An answer to an offer
|
|
24
|
+
* whose application m-line has port 0 has port 0 (RFC 3264 section 6).
|
|
25
|
+
* - The position (MID, index, rejected) is recorded by the current
|
|
26
|
+
* description, not by this object. An unbound transport takes a rejected
|
|
27
|
+
* position with a new MID; an offer that does so moves the transport to that
|
|
28
|
+
* MID (restored by rollback). A MID only an unapplied `createOffer`
|
|
29
|
+
* reserved follows the MID of the peer's offer.
|
|
30
|
+
* - At the final answer SCTP moves straight to its owner's DTLS transport in
|
|
31
|
+
* the answer. SCTP starts after every answer or pranswer that negotiates the
|
|
32
|
+
* application m-line (JSEP 5.11), also on an already connected DTLS
|
|
33
|
+
* transport: an `m=application` a renegotiation adds to a connected session
|
|
34
|
+
* starts without touching ICE or DTLS and without moving `connectionState`.
|
|
35
|
+
* Its client / server side follows the ICE role at the DTLS start. Starting
|
|
36
|
+
* is idempotent (`RTCSctpTransport.ensureStarted`): an established
|
|
37
|
+
* association, also one the remote INIT established first, a handshaking
|
|
38
|
+
* one and a closed one never start again, so a final answer keeping the
|
|
39
|
+
* pranswer's sctp-port continues it. A final answer changing the sctp-port
|
|
40
|
+
* is rejected in validation.
|
|
41
|
+
* - Rollback keeps an application-owned transport (`detachFromDescription`
|
|
42
|
+
* clears what the description set), whether it is in the baseline or was
|
|
43
|
+
* added during the transaction, and stops one a description created. When
|
|
44
|
+
* the baseline has no negotiated remote port, an association that left its
|
|
45
|
+
* initial state under the proposal (started by a pranswer, or established
|
|
46
|
+
* from the remote INIT) is pending-only: it is aborted and an
|
|
47
|
+
* application-owned transport gets a new, unstarted association on the same
|
|
48
|
+
* DTLS transport. Its channels with a stream ID close; channels still
|
|
49
|
+
* waiting for one stay `connecting` for the next negotiation.
|
|
50
|
+
* - `sctp.mtu` is configuration: every transport, also a pending one, is built
|
|
51
|
+
* with it, and moving to another DTLS transport keeps it.
|
|
52
|
+
*/
|
|
10
53
|
class SctpTransportManager {
|
|
11
54
|
constructor() {
|
|
12
55
|
Object.defineProperty(this, "sctpTransport", {
|
|
@@ -39,6 +82,16 @@ class SctpTransportManager {
|
|
|
39
82
|
writable: true,
|
|
40
83
|
value: []
|
|
41
84
|
});
|
|
85
|
+
/**
|
|
86
|
+
* SCTP transports that carry a `createDataChannel` call. They are
|
|
87
|
+
* application state: negotiation rollback keeps them instead of stopping.
|
|
88
|
+
*/
|
|
89
|
+
Object.defineProperty(this, "applicationOwned", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: new WeakSet()
|
|
94
|
+
});
|
|
42
95
|
Object.defineProperty(this, "onDataChannel", {
|
|
43
96
|
enumerable: true,
|
|
44
97
|
configurable: true,
|
|
@@ -50,8 +103,7 @@ class SctpTransportManager {
|
|
|
50
103
|
const sctp = new sctp_1.RTCSctpTransport(5000, maxMessageSize, sctpOptions);
|
|
51
104
|
sctp.mid = undefined;
|
|
52
105
|
sctp.onDataChannel.subscribe((channel) => {
|
|
53
|
-
this.
|
|
54
|
-
this.dataChannels.push(channel);
|
|
106
|
+
this.track(channel);
|
|
55
107
|
this.onDataChannel.execute(channel);
|
|
56
108
|
});
|
|
57
109
|
this.sctpTransport = sctp;
|
|
@@ -77,6 +129,7 @@ class SctpTransportManager {
|
|
|
77
129
|
if (!this.sctpTransport) {
|
|
78
130
|
this.sctpTransport = this.createSctpTransport();
|
|
79
131
|
}
|
|
132
|
+
this.applicationOwned.add(this.sctpTransport);
|
|
80
133
|
const parameters = new dataChannel_1.RTCDataChannelParameters({
|
|
81
134
|
id: settings.id,
|
|
82
135
|
label,
|
|
@@ -87,10 +140,20 @@ class SctpTransportManager {
|
|
|
87
140
|
protocol: settings.protocol,
|
|
88
141
|
});
|
|
89
142
|
const channel = new dataChannel_1.RTCDataChannel(this.sctpTransport, parameters);
|
|
143
|
+
this.track(channel);
|
|
144
|
+
return channel;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Count a channel (created here or announced by the remote peer) and keep
|
|
148
|
+
* it for getStats until it closes. The listener goes with it: a closed
|
|
149
|
+
* channel the application still holds must not keep the manager reachable.
|
|
150
|
+
*/
|
|
151
|
+
track(channel) {
|
|
90
152
|
this.dataChannelsOpened++;
|
|
91
153
|
this.dataChannels.push(channel);
|
|
92
|
-
channel.stateChange.subscribe((state) => {
|
|
154
|
+
const { unSubscribe } = channel.stateChange.subscribe((state) => {
|
|
93
155
|
if (state === "closed") {
|
|
156
|
+
unSubscribe();
|
|
94
157
|
this.dataChannelsClosed++;
|
|
95
158
|
const index = this.dataChannels.indexOf(channel);
|
|
96
159
|
if (index !== -1) {
|
|
@@ -98,15 +161,132 @@ class SctpTransportManager {
|
|
|
98
161
|
}
|
|
99
162
|
}
|
|
100
163
|
});
|
|
101
|
-
return channel;
|
|
102
164
|
}
|
|
165
|
+
isApplicationOwned(transport) {
|
|
166
|
+
return this.applicationOwned.has(transport);
|
|
167
|
+
}
|
|
168
|
+
/** Internal: the SCTP binding a negotiation may change, for a rollback baseline. */
|
|
169
|
+
snapshotNegotiationState() {
|
|
170
|
+
const transport = this.sctpTransport;
|
|
171
|
+
return {
|
|
172
|
+
transport,
|
|
173
|
+
dtlsTransport: transport?.dtlsTransport,
|
|
174
|
+
remotePort: this.sctpRemotePort,
|
|
175
|
+
mid: transport?.mid,
|
|
176
|
+
mLineIndex: transport?.mLineIndex,
|
|
177
|
+
remoteMaxMessageSize: transport?.remoteMaxMessageSize,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** Internal: return to a negotiation baseline taken by `snapshotNegotiationState`. */
|
|
181
|
+
async restoreNegotiationState(state) {
|
|
182
|
+
const current = this.sctpTransport;
|
|
183
|
+
const added = current !== state.transport ? current : undefined;
|
|
184
|
+
// createDataChannel is an application operation: its SCTP transport
|
|
185
|
+
// survives rollback, unbound from the rolled-back m-line, so the next
|
|
186
|
+
// offer carries m=application again. A transport a description created
|
|
187
|
+
// is description state and is torn down.
|
|
188
|
+
const keepAdded = !!added && this.isApplicationOwned(added);
|
|
189
|
+
if (added && !keepAdded) {
|
|
190
|
+
await added.stop();
|
|
191
|
+
}
|
|
192
|
+
// Without a negotiated binding in the baseline, an association that ran
|
|
193
|
+
// under the pending description (started by a pranswer, or established
|
|
194
|
+
// passively from the remote INIT) is pending-only: it is discarded and a
|
|
195
|
+
// new, unstarted one waits for the next negotiation. Attached channels
|
|
196
|
+
// close; unattached ones stay queued.
|
|
197
|
+
const kept = keepAdded ? added : state.transport;
|
|
198
|
+
if (kept && state.remotePort === undefined && kept.associationActive) {
|
|
199
|
+
await kept.resetAssociation(kept === state.transport ? state.dtlsTransport : undefined);
|
|
200
|
+
}
|
|
201
|
+
this.sctpTransport = kept;
|
|
202
|
+
if (state.transport &&
|
|
203
|
+
state.dtlsTransport &&
|
|
204
|
+
state.transport.dtlsTransport !== state.dtlsTransport) {
|
|
205
|
+
state.transport.setDtlsTransport(state.dtlsTransport);
|
|
206
|
+
}
|
|
207
|
+
if (added && keepAdded)
|
|
208
|
+
this.detachFromDescription(added);
|
|
209
|
+
this.sctpRemotePort = state.remotePort;
|
|
210
|
+
if (state.transport) {
|
|
211
|
+
state.transport.mid = state.mid;
|
|
212
|
+
state.transport.mLineIndex = state.mLineIndex;
|
|
213
|
+
if (state.remoteMaxMessageSize !== undefined) {
|
|
214
|
+
state.transport.remoteMaxMessageSize = state.remoteMaxMessageSize;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Internal: a final answer rejected the application m-line (port 0, RFC
|
|
220
|
+
* 8841 section 10.4). The association a pranswer started closes; the
|
|
221
|
+
* transport waits unbound for a later negotiation.
|
|
222
|
+
*/
|
|
223
|
+
async rejectApplication() {
|
|
224
|
+
const transport = this.sctpTransport;
|
|
225
|
+
if (!transport)
|
|
226
|
+
return;
|
|
227
|
+
if (transport.associationActive)
|
|
228
|
+
await transport.resetAssociation();
|
|
229
|
+
this.sctpRemotePort = undefined;
|
|
230
|
+
this.detachFromDescription(transport);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Internal: an SCTP transport that no description bound yet goes back to
|
|
234
|
+
* the MID / m-line index of `state` (see TransceiverManager's
|
|
235
|
+
* `revertUnappliedAssociations`).
|
|
236
|
+
*/
|
|
237
|
+
revertUnappliedAssociation(state) {
|
|
238
|
+
const transport = this.sctpTransport;
|
|
239
|
+
if (transport &&
|
|
240
|
+
transport === state.transport &&
|
|
241
|
+
this.sctpRemotePort === undefined) {
|
|
242
|
+
transport.mid = state.mid;
|
|
243
|
+
transport.mLineIndex = state.mLineIndex;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/** Drop what a rolled-back description set on a kept SCTP transport. */
|
|
247
|
+
detachFromDescription(transport) {
|
|
248
|
+
transport.mid = undefined;
|
|
249
|
+
transport.mLineIndex = undefined;
|
|
250
|
+
transport.remoteMaxMessageSize = sctp_1.DEFAULT_MAX_MESSAGE_SIZE;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Start the association of the negotiated application m-line and wait
|
|
254
|
+
* until it is established. Safe to call any number of times: an
|
|
255
|
+
* established (also passively established) or handshaking association is
|
|
256
|
+
* not started again, and a closed one is not waited for. The wait is
|
|
257
|
+
* bounded even if the remote never answers: the INIT retries (T1) give up
|
|
258
|
+
* and the association emits `closed`.
|
|
259
|
+
*/
|
|
103
260
|
async connectSctp() {
|
|
104
|
-
|
|
261
|
+
const transport = this.sctpTransport;
|
|
262
|
+
if (!transport || !this.sctpRemotePort) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const { sctp } = transport;
|
|
266
|
+
if (sctp.state === "closed") {
|
|
267
|
+
log("sctp closed");
|
|
105
268
|
return;
|
|
106
269
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
270
|
+
// Subscribe before starting so a transition during start is not missed.
|
|
271
|
+
const settled = sctp.state === "connected"
|
|
272
|
+
? undefined
|
|
273
|
+
: Promise.race([
|
|
274
|
+
sctp.stateChanged.connected.asPromise(),
|
|
275
|
+
sctp.stateChanged.closed.asPromise(),
|
|
276
|
+
]);
|
|
277
|
+
await transport.ensureStarted(this.sctpRemotePort);
|
|
278
|
+
// The state may have settled while starting.
|
|
279
|
+
if (settled && !["connected", "closed"].includes(sctp.state)) {
|
|
280
|
+
await settled;
|
|
281
|
+
}
|
|
282
|
+
log("sctp", sctp.state);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A renegotiation pranswer / answer keeps the association (and its port)
|
|
286
|
+
* but updates the data max message size it negotiates.
|
|
287
|
+
*/
|
|
288
|
+
updateRemoteMaxMessageSize(remoteMedia) {
|
|
289
|
+
this.sctpTransport?.setRemoteMaxMessageSize(remoteMedia.sctpCapabilities?.maxMessageSize);
|
|
110
290
|
}
|
|
111
291
|
setRemoteSCTP(remoteMedia, mLineIndex) {
|
|
112
292
|
if (!this.sctpTransport) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sctpManager.js","sourceRoot":"","sources":["../../../src/sctpManager.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AACjD,6CAAgD;AAEhD,+CAAyE;AACzE,yCAKuB;AAEvB,2CAAoD;AAEpD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,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { SCTPOptions } from \"../../sctp/src\";\nimport { createWebRtcTypeError } from \"./errors\";\nimport { Event, debug } from \"./imports/common\";\n\nimport { RTCDataChannel, RTCDataChannelParameters } from \"./dataChannel\";\nimport {\n type RTCDataChannelStats,\n type RTCStats,\n generateStatsId,\n getStatsTimestamp,\n} from \"./media/stats\";\nimport type { MediaDescription } from \"./sdp\";\nimport { RTCSctpTransport } from \"./transport/sctp\";\n\nconst log = debug(\"werift:packages/webrtc/src/transport/sctpManager.ts\");\n\nexport class SctpTransportManager {\n sctpTransport?: RTCSctpTransport;\n sctpRemotePort?: number;\n dataChannelsOpened = 0;\n dataChannelsClosed = 0;\n private dataChannels: RTCDataChannel[] = [];\n\n readonly onDataChannel = new Event<[RTCDataChannel]>();\n\n constructor() {}\n\n createSctpTransport(maxMessageSize?: number, sctpOptions?: SCTPOptions) {\n const sctp = new RTCSctpTransport(5000, maxMessageSize, sctpOptions);\n sctp.mid = undefined;\n sctp.onDataChannel.subscribe((channel) => {\n this.dataChannelsOpened++;\n this.dataChannels.push(channel);\n this.onDataChannel.execute(channel);\n });\n\n this.sctpTransport = sctp;\n\n return sctp;\n }\n\n createDataChannel(\n label: string,\n options: Partial<{\n maxPacketLifeTime?: number;\n protocol: string;\n maxRetransmits?: number;\n ordered: boolean;\n negotiated: boolean;\n id?: number;\n }> = {},\n ): RTCDataChannel {\n const maxPacketLifeTime = coerceUnsignedShortOption(\n options.maxPacketLifeTime,\n \"maxPacketLifeTime\",\n );\n const maxRetransmits = coerceUnsignedShortOption(\n options.maxRetransmits,\n \"maxRetransmits\",\n );\n const base: typeof options = {\n protocol: \"\",\n ordered: true,\n negotiated: false,\n };\n const settings: Required<typeof base> = {\n ...base,\n ...options,\n maxPacketLifeTime,\n maxRetransmits,\n } as any;\n\n if (settings.maxPacketLifeTime != null && settings.maxRetransmits != null) {\n throw createWebRtcTypeError(\n \"maxPacketLifeTime and maxRetransmits cannot both be set\",\n );\n }\n\n if (!this.sctpTransport) {\n this.sctpTransport = this.createSctpTransport();\n }\n\n const parameters = new RTCDataChannelParameters({\n id: settings.id,\n label,\n maxPacketLifeTime: settings.maxPacketLifeTime,\n maxRetransmits: settings.maxRetransmits,\n negotiated: settings.negotiated,\n ordered: settings.ordered,\n protocol: settings.protocol,\n });\n\n const channel = new RTCDataChannel(this.sctpTransport, parameters);\n this.dataChannelsOpened++;\n this.dataChannels.push(channel);\n channel.stateChange.subscribe((state) => {\n if (state === \"closed\") {\n this.dataChannelsClosed++;\n const index = this.dataChannels.indexOf(channel);\n if (index !== -1) {\n this.dataChannels.splice(index, 1);\n }\n }\n });\n return channel;\n }\n\n async connectSctp() {\n if (!this.sctpTransport || !this.sctpRemotePort) {\n return;\n }\n\n await this.sctpTransport.start(this.sctpRemotePort);\n await this.sctpTransport.sctp.stateChanged.connected.asPromise();\n log(\"sctp connected\");\n }\n\n setRemoteSCTP(remoteMedia: MediaDescription, mLineIndex: number) {\n if (!this.sctpTransport) {\n return;\n }\n\n // # configure sctp\n this.sctpTransport.setRemoteMaxMessageSize(\n remoteMedia.sctpCapabilities?.maxMessageSize,\n );\n this.sctpRemotePort = remoteMedia.sctpPort;\n if (!this.sctpRemotePort) {\n throw new Error(\"sctpRemotePort not exist\");\n }\n\n this.sctpTransport.setRemotePort(this.sctpRemotePort);\n this.sctpTransport.mLineIndex = mLineIndex;\n if (!this.sctpTransport.mid) {\n this.sctpTransport.mid = remoteMedia.rtp.muxId;\n }\n }\n\n async close() {\n if (this.sctpTransport) {\n await this.sctpTransport.stop();\n // UdpTransport.send は既知アドレスでは callback を待たない。呼び出し側が\n // 直後に ICE ソケットを閉じると queued な AbortChunk が落ちるので、1 tick 譲る。\n await new Promise<void>((resolve) => setImmediate(resolve));\n }\n\n this.onDataChannel.allUnsubscribe();\n }\n\n async getStats(timestamp = getStatsTimestamp()): Promise<RTCStats[]> {\n const stats: RTCStats[] = [];\n\n for (const channel of this.dataChannels) {\n const channelStats: RTCDataChannelStats = {\n type: \"data-channel\",\n id: generateStatsId(\"data-channel\", channel.id ?? channel.statsId),\n timestamp,\n label: channel.label,\n protocol: channel.protocol,\n dataChannelIdentifier: channel.id ?? undefined,\n state: channel.readyState,\n messagesSent: channel.messagesSent || 0,\n bytesSent: channel.bytesSent || 0,\n messagesReceived: channel.messagesReceived || 0,\n bytesReceived: channel.bytesReceived || 0,\n };\n stats.push(channelStats);\n }\n\n return stats;\n }\n}\n\nfunction coerceUnsignedShortOption(\n value: unknown,\n name: string,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n const coerced = Number(value);\n if (\n !Number.isFinite(coerced) ||\n !Number.isInteger(coerced) ||\n coerced < 0 ||\n coerced > 65535\n ) {\n throw createWebRtcTypeError(`${name} must be an unsigned short`);\n }\n\n return coerced;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sctpManager.js","sourceRoot":"","sources":["../../../src/sctpManager.ts"],"names":[],"mappings":";;;AACA,+CAAyE;AACzE,qCAAiD;AACjD,6CAAgD;AAChD,yCAKuB;AAGvB,2CAA8E;AAE9E,MAAM,GAAG,GAAG,IAAA,cAAK,EAAC,qDAAqD,CAAC,CAAC;AAOzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,oBAAoB;IAc/B;QAbA;;;;;WAAiC;QACjC;;;;;WAAwB;QACxB;;;;mBAAqB,CAAC;WAAC;QACvB;;;;mBAAqB,CAAC;WAAC;QACf;;;;mBAAiC,EAAE;WAAC;QAC5C;;;WAGG;QACc;;;;mBAAmB,IAAI,OAAO,EAAoB;WAAC;QAE3D;;;;mBAAgB,IAAI,cAAK,EAAoB;WAAC;IAExC,CAAC;IAEhB,mBAAmB,CAAC,cAAuB,EAAE,WAAyB;QACpE,MAAM,IAAI,GAAG,IAAI,uBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;QACrE,IA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AAK;gBACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,qBAAqB,EAAE,OAAO,CAAC,EAAE,IAAI,SAAS;gBAC9C,KAAK,EAAE,OAAO,CAAC,UAAU;gBACzB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,CAAC;gBACvC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;gBACjC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,CAAC;gBAC/C,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,CAAC;aAC1C,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA7SD,oDA6SC;AAED,SAAS,yBAAyB,CAChC,KAAc,EACd,IAAY;IAEZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QAC1B,OAAO,GAAG,CAAC;QACX,OAAO,GAAG,KAAK,EACf,CAAC;QACD,MAAM,IAAA,8BAAqB,EAAC,GAAG,IAAI,4BAA4B,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { SCTPOptions } from \"../../sctp/src\";\nimport { RTCDataChannel, RTCDataChannelParameters } from \"./dataChannel\";\nimport { createWebRtcTypeError } from \"./errors\";\nimport { debug, Event } from \"./imports/common\";\nimport {\n generateStatsId,\n getStatsTimestamp,\n type RTCDataChannelStats,\n type RTCStats,\n} from \"./media/stats\";\nimport type { MediaDescription } from \"./sdp\";\nimport type { RTCDtlsTransport } from \"./transport/dtls\";\nimport { DEFAULT_MAX_MESSAGE_SIZE, RTCSctpTransport } from \"./transport/sctp\";\n\nconst log = debug(\"werift:packages/webrtc/src/transport/sctpManager.ts\");\n\n/** The SCTP binding of a PeerConnection, for a negotiation rollback baseline. */\nexport type SctpNegotiationState = ReturnType<\n SctpTransportManager[\"snapshotNegotiationState\"]\n>;\n\n/**\n * The SCTP transport of a PeerConnection and its application m-line.\n *\n * - Rejection of the application m-line (port 0) keeps the SCTP transport:\n * it stays bound to its MID and the next offer offers the application again\n * with that MID (W3C would set `sctpTransport` to null). A rejecting remote\n * offer or pranswer is provisional and leaves the association alone, and\n * so does any rejection of an association the rollback baseline negotiated.\n * A final answer with port 0 (RFC 8841 section 10.4), local or remote,\n * aborts an association the proposal started (a pranswer or the remote\n * INIT) and releases the remote port on that peer (`rejectApplication`).\n * Channels on it close; the other peer closes its own when it applies the\n * same answer. The commit does not move the transport to\n * a transport the answer did not negotiate for it. An answer to an offer\n * whose application m-line has port 0 has port 0 (RFC 3264 section 6).\n * - The position (MID, index, rejected) is recorded by the current\n * description, not by this object. An unbound transport takes a rejected\n * position with a new MID; an offer that does so moves the transport to that\n * MID (restored by rollback). A MID only an unapplied `createOffer`\n * reserved follows the MID of the peer's offer.\n * - At the final answer SCTP moves straight to its owner's DTLS transport in\n * the answer. SCTP starts after every answer or pranswer that negotiates the\n * application m-line (JSEP 5.11), also on an already connected DTLS\n * transport: an `m=application` a renegotiation adds to a connected session\n * starts without touching ICE or DTLS and without moving `connectionState`.\n * Its client / server side follows the ICE role at the DTLS start. Starting\n * is idempotent (`RTCSctpTransport.ensureStarted`): an established\n * association, also one the remote INIT established first, a handshaking\n * one and a closed one never start again, so a final answer keeping the\n * pranswer's sctp-port continues it. A final answer changing the sctp-port\n * is rejected in validation.\n * - Rollback keeps an application-owned transport (`detachFromDescription`\n * clears what the description set), whether it is in the baseline or was\n * added during the transaction, and stops one a description created. When\n * the baseline has no negotiated remote port, an association that left its\n * initial state under the proposal (started by a pranswer, or established\n * from the remote INIT) is pending-only: it is aborted and an\n * application-owned transport gets a new, unstarted association on the same\n * DTLS transport. Its channels with a stream ID close; channels still\n * waiting for one stay `connecting` for the next negotiation.\n * - `sctp.mtu` is configuration: every transport, also a pending one, is built\n * with it, and moving to another DTLS transport keeps it.\n */\nexport class SctpTransportManager {\n sctpTransport?: RTCSctpTransport;\n sctpRemotePort?: number;\n dataChannelsOpened = 0;\n dataChannelsClosed = 0;\n private dataChannels: RTCDataChannel[] = [];\n /**\n * SCTP transports that carry a `createDataChannel` call. They are\n * application state: negotiation rollback keeps them instead of stopping.\n */\n private readonly applicationOwned = new WeakSet<RTCSctpTransport>();\n\n readonly onDataChannel = new Event<[RTCDataChannel]>();\n\n constructor() {}\n\n createSctpTransport(maxMessageSize?: number, sctpOptions?: SCTPOptions) {\n const sctp = new RTCSctpTransport(5000, maxMessageSize, sctpOptions);\n sctp.mid = undefined;\n sctp.onDataChannel.subscribe((channel) => {\n this.track(channel);\n this.onDataChannel.execute(channel);\n });\n\n this.sctpTransport = sctp;\n\n return sctp;\n }\n\n createDataChannel(\n label: string,\n options: Partial<{\n maxPacketLifeTime?: number;\n protocol: string;\n maxRetransmits?: number;\n ordered: boolean;\n negotiated: boolean;\n id?: number;\n }> = {},\n ): RTCDataChannel {\n const maxPacketLifeTime = coerceUnsignedShortOption(\n options.maxPacketLifeTime,\n \"maxPacketLifeTime\",\n );\n const maxRetransmits = coerceUnsignedShortOption(\n options.maxRetransmits,\n \"maxRetransmits\",\n );\n const base: typeof options = {\n protocol: \"\",\n ordered: true,\n negotiated: false,\n };\n const settings: Required<typeof base> = {\n ...base,\n ...options,\n maxPacketLifeTime,\n maxRetransmits,\n } as any;\n\n if (settings.maxPacketLifeTime != null && settings.maxRetransmits != null) {\n throw createWebRtcTypeError(\n \"maxPacketLifeTime and maxRetransmits cannot both be set\",\n );\n }\n\n if (!this.sctpTransport) {\n this.sctpTransport = this.createSctpTransport();\n }\n this.applicationOwned.add(this.sctpTransport);\n\n const parameters = new RTCDataChannelParameters({\n id: settings.id,\n label,\n maxPacketLifeTime: settings.maxPacketLifeTime,\n maxRetransmits: settings.maxRetransmits,\n negotiated: settings.negotiated,\n ordered: settings.ordered,\n protocol: settings.protocol,\n });\n\n const channel = new RTCDataChannel(this.sctpTransport, parameters);\n this.track(channel);\n return channel;\n }\n\n /**\n * Count a channel (created here or announced by the remote peer) and keep\n * it for getStats until it closes. The listener goes with it: a closed\n * channel the application still holds must not keep the manager reachable.\n */\n private track(channel: RTCDataChannel) {\n this.dataChannelsOpened++;\n this.dataChannels.push(channel);\n const { unSubscribe } = channel.stateChange.subscribe((state) => {\n if (state === \"closed\") {\n unSubscribe();\n this.dataChannelsClosed++;\n const index = this.dataChannels.indexOf(channel);\n if (index !== -1) {\n this.dataChannels.splice(index, 1);\n }\n }\n });\n }\n\n isApplicationOwned(transport: RTCSctpTransport) {\n return this.applicationOwned.has(transport);\n }\n\n /** Internal: the SCTP binding a negotiation may change, for a rollback baseline. */\n snapshotNegotiationState() {\n const transport = this.sctpTransport;\n return {\n transport,\n dtlsTransport: transport?.dtlsTransport as RTCDtlsTransport | undefined,\n remotePort: this.sctpRemotePort,\n mid: transport?.mid,\n mLineIndex: transport?.mLineIndex,\n remoteMaxMessageSize: transport?.remoteMaxMessageSize,\n };\n }\n\n /** Internal: return to a negotiation baseline taken by `snapshotNegotiationState`. */\n async restoreNegotiationState(state: SctpNegotiationState) {\n const current = this.sctpTransport;\n const added = current !== state.transport ? current : undefined;\n // createDataChannel is an application operation: its SCTP transport\n // survives rollback, unbound from the rolled-back m-line, so the next\n // offer carries m=application again. A transport a description created\n // is description state and is torn down.\n const keepAdded = !!added && this.isApplicationOwned(added);\n if (added && !keepAdded) {\n await added.stop();\n }\n // Without a negotiated binding in the baseline, an association that ran\n // under the pending description (started by a pranswer, or established\n // passively from the remote INIT) is pending-only: it is discarded and a\n // new, unstarted one waits for the next negotiation. Attached channels\n // close; unattached ones stay queued.\n const kept = keepAdded ? added : state.transport;\n if (kept && state.remotePort === undefined && kept.associationActive) {\n await kept.resetAssociation(\n kept === state.transport ? state.dtlsTransport : undefined,\n );\n }\n this.sctpTransport = kept;\n if (\n state.transport &&\n state.dtlsTransport &&\n state.transport.dtlsTransport !== state.dtlsTransport\n ) {\n state.transport.setDtlsTransport(state.dtlsTransport);\n }\n if (added && keepAdded) this.detachFromDescription(added);\n this.sctpRemotePort = state.remotePort;\n if (state.transport) {\n state.transport.mid = state.mid;\n state.transport.mLineIndex = state.mLineIndex;\n if (state.remoteMaxMessageSize !== undefined) {\n state.transport.remoteMaxMessageSize = state.remoteMaxMessageSize;\n }\n }\n }\n\n /**\n * Internal: a final answer rejected the application m-line (port 0, RFC\n * 8841 section 10.4). The association a pranswer started closes; the\n * transport waits unbound for a later negotiation.\n */\n async rejectApplication() {\n const transport = this.sctpTransport;\n if (!transport) return;\n if (transport.associationActive) await transport.resetAssociation();\n this.sctpRemotePort = undefined;\n this.detachFromDescription(transport);\n }\n\n /**\n * Internal: an SCTP transport that no description bound yet goes back to\n * the MID / m-line index of `state` (see TransceiverManager's\n * `revertUnappliedAssociations`).\n */\n revertUnappliedAssociation(state: SctpNegotiationState) {\n const transport = this.sctpTransport;\n if (\n transport &&\n transport === state.transport &&\n this.sctpRemotePort === undefined\n ) {\n transport.mid = state.mid;\n transport.mLineIndex = state.mLineIndex;\n }\n }\n\n /** Drop what a rolled-back description set on a kept SCTP transport. */\n detachFromDescription(transport: RTCSctpTransport) {\n transport.mid = undefined;\n transport.mLineIndex = undefined;\n transport.remoteMaxMessageSize = DEFAULT_MAX_MESSAGE_SIZE;\n }\n\n /**\n * Start the association of the negotiated application m-line and wait\n * until it is established. Safe to call any number of times: an\n * established (also passively established) or handshaking association is\n * not started again, and a closed one is not waited for. The wait is\n * bounded even if the remote never answers: the INIT retries (T1) give up\n * and the association emits `closed`.\n */\n async connectSctp() {\n const transport = this.sctpTransport;\n if (!transport || !this.sctpRemotePort) {\n return;\n }\n const { sctp } = transport;\n if (sctp.state === \"closed\") {\n log(\"sctp closed\");\n return;\n }\n // Subscribe before starting so a transition during start is not missed.\n const settled =\n sctp.state === \"connected\"\n ? undefined\n : Promise.race([\n sctp.stateChanged.connected.asPromise(),\n sctp.stateChanged.closed.asPromise(),\n ]);\n\n await transport.ensureStarted(this.sctpRemotePort);\n // The state may have settled while starting.\n if (settled && ![\"connected\", \"closed\"].includes(sctp.state)) {\n await settled;\n }\n log(\"sctp\", sctp.state);\n }\n\n /**\n * A renegotiation pranswer / answer keeps the association (and its port)\n * but updates the data max message size it negotiates.\n */\n updateRemoteMaxMessageSize(remoteMedia: MediaDescription) {\n this.sctpTransport?.setRemoteMaxMessageSize(\n remoteMedia.sctpCapabilities?.maxMessageSize,\n );\n }\n\n setRemoteSCTP(remoteMedia: MediaDescription, mLineIndex: number) {\n if (!this.sctpTransport) {\n return;\n }\n\n // # configure sctp\n this.sctpTransport.setRemoteMaxMessageSize(\n remoteMedia.sctpCapabilities?.maxMessageSize,\n );\n this.sctpRemotePort = remoteMedia.sctpPort;\n if (!this.sctpRemotePort) {\n throw new Error(\"sctpRemotePort not exist\");\n }\n\n this.sctpTransport.setRemotePort(this.sctpRemotePort);\n this.sctpTransport.mLineIndex = mLineIndex;\n if (!this.sctpTransport.mid) {\n this.sctpTransport.mid = remoteMedia.rtp.muxId;\n }\n }\n\n async close() {\n if (this.sctpTransport) {\n await this.sctpTransport.stop();\n // UdpTransport.send は既知アドレスでは callback を待たない。呼び出し側が\n // 直後に ICE ソケットを閉じると queued な AbortChunk が落ちるので、1 tick 譲る。\n await new Promise<void>((resolve) => setImmediate(resolve));\n }\n\n this.onDataChannel.allUnsubscribe();\n }\n\n async getStats(timestamp = getStatsTimestamp()): Promise<RTCStats[]> {\n const stats: RTCStats[] = [];\n\n for (const channel of this.dataChannels) {\n const channelStats: RTCDataChannelStats = {\n type: \"data-channel\",\n id: generateStatsId(\"data-channel\", channel.id ?? channel.statsId),\n timestamp,\n label: channel.label,\n protocol: channel.protocol,\n dataChannelIdentifier: channel.id ?? undefined,\n state: channel.readyState,\n messagesSent: channel.messagesSent || 0,\n bytesSent: channel.bytesSent || 0,\n messagesReceived: channel.messagesReceived || 0,\n bytesReceived: channel.bytesReceived || 0,\n };\n stats.push(channelStats);\n }\n\n return stats;\n }\n}\n\nfunction coerceUnsignedShortOption(\n value: unknown,\n name: string,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n const coerced = Number(value);\n if (\n !Number.isFinite(coerced) ||\n !Number.isInteger(coerced) ||\n coerced < 0 ||\n coerced > 65535\n ) {\n throw createWebRtcTypeError(`${name} must be an unsigned short`);\n }\n\n return coerced;\n}\n"]}
|
package/lib/webrtc/src/sdp.js
CHANGED
|
@@ -431,25 +431,25 @@ class MediaDescription {
|
|
|
431
431
|
enumerable: true,
|
|
432
432
|
configurable: true,
|
|
433
433
|
writable: true,
|
|
434
|
-
value:
|
|
434
|
+
value: void 0
|
|
435
435
|
});
|
|
436
436
|
Object.defineProperty(this, "port", {
|
|
437
437
|
enumerable: true,
|
|
438
438
|
configurable: true,
|
|
439
439
|
writable: true,
|
|
440
|
-
value:
|
|
440
|
+
value: void 0
|
|
441
441
|
});
|
|
442
442
|
Object.defineProperty(this, "profile", {
|
|
443
443
|
enumerable: true,
|
|
444
444
|
configurable: true,
|
|
445
445
|
writable: true,
|
|
446
|
-
value:
|
|
446
|
+
value: void 0
|
|
447
447
|
});
|
|
448
448
|
Object.defineProperty(this, "fmt", {
|
|
449
449
|
enumerable: true,
|
|
450
450
|
configurable: true,
|
|
451
451
|
writable: true,
|
|
452
|
-
value:
|
|
452
|
+
value: void 0
|
|
453
453
|
});
|
|
454
454
|
// rtp
|
|
455
455
|
Object.defineProperty(this, "host", {
|
|
@@ -567,6 +567,10 @@ class MediaDescription {
|
|
|
567
567
|
writable: true,
|
|
568
568
|
value: []
|
|
569
569
|
});
|
|
570
|
+
this.kind = kind;
|
|
571
|
+
this.port = port;
|
|
572
|
+
this.profile = profile;
|
|
573
|
+
this.fmt = fmt;
|
|
570
574
|
}
|
|
571
575
|
get msid() {
|
|
572
576
|
return this.msids[0];
|
|
@@ -682,14 +686,16 @@ class GroupDescription {
|
|
|
682
686
|
enumerable: true,
|
|
683
687
|
configurable: true,
|
|
684
688
|
writable: true,
|
|
685
|
-
value:
|
|
689
|
+
value: void 0
|
|
686
690
|
});
|
|
687
691
|
Object.defineProperty(this, "items", {
|
|
688
692
|
enumerable: true,
|
|
689
693
|
configurable: true,
|
|
690
694
|
writable: true,
|
|
691
|
-
value:
|
|
695
|
+
value: void 0
|
|
692
696
|
});
|
|
697
|
+
this.semantic = semantic;
|
|
698
|
+
this.items = items;
|
|
693
699
|
}
|
|
694
700
|
get str() {
|
|
695
701
|
return `${this.semantic} ${this.items.join(" ")}`;
|