werift 0.25.1 → 0.26.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/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/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 +137 -5
- 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 +98 -14
- 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 +12 -6
- package/lib/dtls/src/context/cipher.js +52 -103
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +4 -0
- package/lib/dtls/src/context/transport.js +14 -0
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.js +8 -1
- 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 +8 -2
- package/lib/dtls/src/flight/server/flight4.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 +1 -1
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +1 -1
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -3
- 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 +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.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 +1 -1
- 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 +2 -2
- 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 +1 -1
- 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 +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +2 -2
- package/lib/dtls/src/handshake/random.js +2 -2
- 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/message/fragment.d.ts +1 -1
- package/lib/dtls/src/record/message/fragment.js +3 -3
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +2 -2
- package/lib/dtls/src/record/message/header.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 +2 -2
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +30 -0
- package/lib/ice/src/exceptions.js +43 -1
- 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 +142 -0
- package/lib/ice/src/ice.js +809 -53
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +49 -0
- 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 +5 -0
- package/lib/ice/src/stun/transaction.js +7 -1
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +73 -4
- package/lib/ice/src/turn/protocol.js +241 -12
- 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/message.d.ts +5 -1
- package/lib/ice-server/src/stun/message.js +33 -2
- 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 +24263 -16477
- package/lib/nonstandard/index.mjs +9272 -6178
- package/lib/polyfill/dom.mjs +24872 -20543
- package/lib/polyfill/index.mjs +24872 -20543
- package/lib/rtp/src/codec/av1.d.ts +61 -1
- package/lib/rtp/src/codec/av1.js +332 -33
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/base.d.ts +49 -1
- package/lib/rtp/src/codec/base.js +81 -1
- package/lib/rtp/src/codec/base.js.map +1 -1
- package/lib/rtp/src/codec/g711.d.ts +37 -0
- package/lib/rtp/src/codec/g711.js +109 -0
- package/lib/rtp/src/codec/g711.js.map +1 -0
- package/lib/rtp/src/codec/g722.d.ts +31 -0
- package/lib/rtp/src/codec/g722.js +82 -0
- package/lib/rtp/src/codec/g722.js.map +1 -0
- package/lib/rtp/src/codec/h264.d.ts +81 -7
- package/lib/rtp/src/codec/h264.js +382 -21
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/h265.d.ts +101 -0
- package/lib/rtp/src/codec/h265.js +615 -0
- package/lib/rtp/src/codec/h265.js.map +1 -0
- package/lib/rtp/src/codec/index.d.ts +6 -1
- package/lib/rtp/src/codec/index.js +25 -0
- package/lib/rtp/src/codec/index.js.map +1 -1
- package/lib/rtp/src/codec/mp4a.d.ts +88 -0
- package/lib/rtp/src/codec/mp4a.js +386 -0
- package/lib/rtp/src/codec/mp4a.js.map +1 -0
- package/lib/rtp/src/codec/opus.d.ts +14 -2
- package/lib/rtp/src/codec/opus.js +32 -2
- package/lib/rtp/src/codec/opus.js.map +1 -1
- package/lib/rtp/src/codec/telephoneEvent.d.ts +102 -0
- package/lib/rtp/src/codec/telephoneEvent.js +176 -0
- package/lib/rtp/src/codec/telephoneEvent.js.map +1 -0
- package/lib/rtp/src/codec/vp8.d.ts +26 -1
- package/lib/rtp/src/codec/vp8.js +76 -2
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.d.ts +25 -1
- package/lib/rtp/src/codec/vp9.js +64 -2
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/const.d.ts +1 -0
- package/lib/rtp/src/const.js +5 -0
- package/lib/rtp/src/const.js.map +1 -0
- package/lib/rtp/src/extra/container/mp4/container.js +4 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +26 -0
- package/lib/rtp/src/extra/container/mp4/h264.js +54 -0
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- 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 +20 -1
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.js +1 -1
- 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/dtxCallback.d.ts +1 -11
- 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/jitterBufferCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +16 -0
- package/lib/rtp/src/extra/processor/mp4.js +55 -21
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
- package/lib/rtp/src/extra/processor/nack.js +1 -1
- 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.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -11
- 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 +1 -1
- 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.map +1 -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 +43 -16
- 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 +4 -2
- package/lib/rtp/src/index.js +4 -2
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +2 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +2 -1
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/sr.d.ts +4 -3
- package/lib/rtp/src/rtcp/sr.js +3 -2
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/mediaClock.d.ts +283 -0
- package/lib/rtp/src/rtp/mediaClock.js +655 -0
- package/lib/rtp/src/rtp/mediaClock.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.d.ts +2 -2
- package/lib/rtp/src/srtp/cipher/ctr.js +1 -1
- 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/context/context.d.ts +29 -1
- package/lib/rtp/src/srtp/context/context.js +78 -24
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +23 -15
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/util.d.ts +59 -6
- package/lib/rtp/src/util.js +88 -10
- package/lib/rtp/src/util.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/sctp.d.ts +11 -2
- package/lib/sctp/src/sctp.js +47 -28
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/peerConfig.d.ts +264 -0
- package/lib/webrtc/src/api/peerConfig.js +250 -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 +1 -1
- package/lib/webrtc/src/dataChannel.js +1 -1
- 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/codec.d.ts +18 -0
- package/lib/webrtc/src/media/codec.js +43 -2
- package/lib/webrtc/src/media/codec.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +5 -0
- package/lib/webrtc/src/media/codecCompatibility.js +15 -4
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +1 -1
- package/lib/webrtc/src/media/index.js +1 -1
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.js +3 -4
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +116 -5
- package/lib/webrtc/src/media/router.js +281 -29
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +107 -12
- package/lib/webrtc/src/media/rtpReceiver.js +255 -28
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +56 -3
- package/lib/webrtc/src/media/rtpSender.js +180 -21
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +94 -1
- package/lib/webrtc/src/media/rtpTransceiver.js +111 -2
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +2 -1
- package/lib/webrtc/src/media/sender/senderBWE.js +22 -10
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +1 -1
- package/lib/webrtc/src/media/track.js +1 -1
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +107 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js +380 -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 +261 -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 +118 -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 +344 -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 +398 -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 +345 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
- package/lib/webrtc/src/negotiationTransaction.d.ts +233 -0
- package/lib/webrtc/src/negotiationTransaction.js +591 -0
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +20 -6
- 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.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +4 -4
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +61 -306
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.d.ts +4 -2
- package/lib/webrtc/src/nonstandard/userMedia.js +43 -9
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +132 -237
- package/lib/webrtc/src/peerConnection.js +971 -906
- 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.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 +66 -2
- package/lib/webrtc/src/sctpManager.js +122 -5
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +55 -11
- package/lib/webrtc/src/sdpManager.js +367 -89
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +38 -25
- package/lib/webrtc/src/secureTransportManager.js +130 -34
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +62 -18
- package/lib/webrtc/src/transceiverManager.js +266 -105
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +11 -2
- package/lib/webrtc/src/transport/dtls.js +37 -13
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +254 -7
- package/lib/webrtc/src/transport/ice.js +608 -52
- 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 +4 -1
- package/lib/webrtc/src/transport/sctp.js +83 -17
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +3 -3
- package/lib/webrtc/src/utils.js +1 -1
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +13 -14
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DescriptionValidation = void 0;
|
|
4
|
+
const src_1 = require("../../../sctp/src");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
const media_1 = require("../media");
|
|
7
|
+
function fingerprintKey(params) {
|
|
8
|
+
return params.fingerprints
|
|
9
|
+
.map(({ algorithm, value }) => `${algorithm.toLowerCase()}:${value.replaceAll(":", "").toLowerCase()}`)
|
|
10
|
+
.sort()
|
|
11
|
+
.join("|");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validation of a description before any transaction or live state changes.
|
|
15
|
+
* A description that fails here leaves the signaling state, both
|
|
16
|
+
* descriptions and every transport as they were.
|
|
17
|
+
*/
|
|
18
|
+
class DescriptionValidation {
|
|
19
|
+
constructor(config, sdp, transceivers, sctp, negotiation, topology) {
|
|
20
|
+
Object.defineProperty(this, "config", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: config
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "sdp", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: sdp
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "transceivers", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: transceivers
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "sctp", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: sctp
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "negotiation", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: negotiation
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "topology", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: topology
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A local description must use the ICE credentials of the transports
|
|
59
|
+
* prepared for it and keep the DTLS role of a live association.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Validate a local description without changing anything. `transportForMid`
|
|
63
|
+
* resolves the transport of an m-line the description associates with a
|
|
64
|
+
* transceiver that is not associated yet.
|
|
65
|
+
*/
|
|
66
|
+
validateLocal(description, transportForMid = () => undefined) {
|
|
67
|
+
for (const media of description.media) {
|
|
68
|
+
if (media.port === 0 || !media.iceParams)
|
|
69
|
+
continue;
|
|
70
|
+
const prepared = media.rtp.muxId && this.negotiation.transportByMid.get(media.rtp.muxId);
|
|
71
|
+
const live = (media.kind === "application"
|
|
72
|
+
? this.sctp.sctpTransport?.dtlsTransport
|
|
73
|
+
: this.transceivers
|
|
74
|
+
.getTransceivers()
|
|
75
|
+
.find((transceiver) => transceiver.mid === media.rtp.muxId)
|
|
76
|
+
?.dtlsTransport) ?? transportForMid(media.rtp.muxId ?? "");
|
|
77
|
+
// The credentials are the transport's live ones, or a restart
|
|
78
|
+
// generation a created description carries that is still valid.
|
|
79
|
+
const matches = (transport) => !!transport?.iceTransport.localGenerationFor(media.iceParams.usernameFragment, media.iceParams.password);
|
|
80
|
+
// An answer must use the transport prepared for it. A (replacement)
|
|
81
|
+
// offer is built from the live transports; re-applying the previous
|
|
82
|
+
// pending offer may carry its prepared credentials instead.
|
|
83
|
+
const acceptable = description.type === "offer"
|
|
84
|
+
? [prepared, live].filter(Boolean)
|
|
85
|
+
: [prepared || live].filter(Boolean);
|
|
86
|
+
if (acceptable.length > 0 &&
|
|
87
|
+
!acceptable.some((transport) => matches(transport || undefined))) {
|
|
88
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Local SDP must use prepared ICE credentials");
|
|
89
|
+
}
|
|
90
|
+
// Like a remote one, a local answer or pranswer keeps the DTLS role
|
|
91
|
+
// of a live association (RFC 8842 section 5.5); an edited a=setup is
|
|
92
|
+
// refused before it can change the running transport.
|
|
93
|
+
const bundledNonTag = this.topology.isBundledNonTag(description, media.rtp.muxId);
|
|
94
|
+
const localRole = media.dtlsParams?.role;
|
|
95
|
+
if (description.type !== "offer" &&
|
|
96
|
+
!bundledNonTag &&
|
|
97
|
+
localRole &&
|
|
98
|
+
localRole !== "auto" &&
|
|
99
|
+
live &&
|
|
100
|
+
(!prepared || prepared === live) &&
|
|
101
|
+
["connecting", "connected"].includes(live.state) &&
|
|
102
|
+
live.role !== "auto" &&
|
|
103
|
+
live.role !== localRole) {
|
|
104
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Changing the DTLS role of a connected association is unsupported");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A remote description: common codecs with the pending local offer, shared
|
|
110
|
+
* transports, media kinds, SCTP port, codecs, DTLS fingerprint and role, and
|
|
111
|
+
* SCTP binding are all checked before any state changes.
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* A new MID on an existing m-line recycles it (JSEP 5.2.2). An m-line the
|
|
115
|
+
* current session did not reject belongs to a local transceiver; only a
|
|
116
|
+
* stopped one gives its slot up, an inactive one the application keeps
|
|
117
|
+
* does not.
|
|
118
|
+
*/
|
|
119
|
+
assertRecyclesOnlyStoppedMLines(remoteSdp) {
|
|
120
|
+
const current = this.sdp.currentRemoteDescription;
|
|
121
|
+
if (remoteSdp.type !== "offer" || !current)
|
|
122
|
+
return;
|
|
123
|
+
for (const [index, media] of remoteSdp.media.entries()) {
|
|
124
|
+
const previous = current.media[index];
|
|
125
|
+
const committedLocal = this.sdp.currentLocalDescription?.media[index];
|
|
126
|
+
if (!previous?.rtp.muxId ||
|
|
127
|
+
media.rtp.muxId === previous.rtp.muxId ||
|
|
128
|
+
previous.port === 0 ||
|
|
129
|
+
committedLocal?.port === 0) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const owner = this.transceivers
|
|
133
|
+
.getTransceivers()
|
|
134
|
+
.find((t) => t.mid === previous.rtp.muxId);
|
|
135
|
+
if (owner && !owner.stopped && !owner.stopping) {
|
|
136
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "An m-line of a transceiver that is not stopped cannot be recycled");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
validateRemote(remoteSdp, signalingState) {
|
|
141
|
+
this.sdp.validateRemoteDescription(remoteSdp);
|
|
142
|
+
this.topology.assertAnswerKeepsSharedTransports(remoteSdp, signalingState);
|
|
143
|
+
this.assertRecyclesOnlyStoppedMLines(remoteSdp);
|
|
144
|
+
for (const [mediaIndex, media] of remoteSdp.media.entries()) {
|
|
145
|
+
if (!["audio", "video", "application"].includes(media.kind)) {
|
|
146
|
+
throw (0, errors_1.createWebRtcDomException)("OperationError", "Unsupported media kind");
|
|
147
|
+
}
|
|
148
|
+
if (media.kind === "application" && media.port !== 0) {
|
|
149
|
+
if (!media.sctpPort || media.sctpPort < 1 || media.sctpPort > 65535) {
|
|
150
|
+
throw (0, errors_1.createWebRtcDomException)("OperationError", "Invalid SCTP port");
|
|
151
|
+
}
|
|
152
|
+
if (this.sctp.sctpRemotePort &&
|
|
153
|
+
this.sctp.sctpRemotePort !== media.sctpPort) {
|
|
154
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Changing the port of an existing SCTP association is unsupported");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (remoteSdp.type !== "offer" &&
|
|
158
|
+
media.port !== 0 &&
|
|
159
|
+
media.kind !== "application" &&
|
|
160
|
+
(0, media_1.negotiateRemoteCodecs)(this.transceivers
|
|
161
|
+
.getTransceivers()
|
|
162
|
+
.find((transceiver) => transceiver.mid === media.rtp.muxId)
|
|
163
|
+
?.pendingLocalOfferCodecs ?? this.localCodecsFor(media), media).length === 0) {
|
|
164
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidAccessError", "No supported codec in answer");
|
|
165
|
+
}
|
|
166
|
+
if (media.port !== 0 && this.sdp.currentRemoteDescription) {
|
|
167
|
+
const currentMedia = this.sdp.currentRemoteDescription.media[mediaIndex];
|
|
168
|
+
const transport = media.kind === "application"
|
|
169
|
+
? this.sctp.sctpTransport?.dtlsTransport
|
|
170
|
+
: this.transceivers
|
|
171
|
+
.getTransceivers()
|
|
172
|
+
.find((t) => t.mid === media.rtp.muxId)?.dtlsTransport;
|
|
173
|
+
if (transport?.state === "connected" &&
|
|
174
|
+
currentMedia?.dtlsParams &&
|
|
175
|
+
media.dtlsParams) {
|
|
176
|
+
if (fingerprintKey(currentMedia.dtlsParams) !==
|
|
177
|
+
fingerprintKey(media.dtlsParams)) {
|
|
178
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Changing the fingerprint of a connected DTLS association is unsupported");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// An answer or pranswer keeps the DTLS role of a live association
|
|
183
|
+
// (RFC 8842 section 5.5), including one a first negotiation connected
|
|
184
|
+
// at its pranswer; only a new association, such as a BUNDLE split owner
|
|
185
|
+
// prepared for this proposal, may take another role. A non-tag BUNDLE
|
|
186
|
+
// member never sets a role, so it is not checked.
|
|
187
|
+
if (media.port !== 0 && remoteSdp.type !== "offer") {
|
|
188
|
+
const transport = media.kind === "application"
|
|
189
|
+
? this.sctp.sctpTransport?.dtlsTransport
|
|
190
|
+
: this.transceivers
|
|
191
|
+
.getTransceivers()
|
|
192
|
+
.find((t) => t.mid === media.rtp.muxId)?.dtlsTransport;
|
|
193
|
+
const prepared = this.negotiation.transportByMid.get(media.rtp.muxId ?? "");
|
|
194
|
+
const bundledNonTag = this.topology.isBundledNonTag(remoteSdp, media.rtp.muxId);
|
|
195
|
+
const remoteRole = media.dtlsParams?.role;
|
|
196
|
+
// An answer's `actpass` (invalid per RFC 5763 section 5) names no role;
|
|
197
|
+
// werift keeps the role of a live association for it.
|
|
198
|
+
if (!bundledNonTag &&
|
|
199
|
+
remoteRole &&
|
|
200
|
+
remoteRole !== "auto" &&
|
|
201
|
+
transport &&
|
|
202
|
+
["connecting", "connected"].includes(transport.state) &&
|
|
203
|
+
transport.role !== "auto" &&
|
|
204
|
+
(!prepared || prepared === transport) &&
|
|
205
|
+
(remoteRole === "client" ? "server" : "client") !== transport.role) {
|
|
206
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Changing the DTLS role of a connected association is unsupported");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (media.port !== 0 &&
|
|
210
|
+
this.sdp.pendingRemoteDescription?.type === "pranswer" &&
|
|
211
|
+
!this.sdp.currentRemoteDescription) {
|
|
212
|
+
const provisional = this.sdp.pendingRemoteDescription.media[mediaIndex];
|
|
213
|
+
const transport = media.kind === "application"
|
|
214
|
+
? this.sctp.sctpTransport?.dtlsTransport
|
|
215
|
+
: this.transceivers
|
|
216
|
+
.getTransceivers()
|
|
217
|
+
.find((transceiver) => transceiver.mid === media.rtp.muxId)
|
|
218
|
+
?.dtlsTransport;
|
|
219
|
+
if (transport?.state === "connected" &&
|
|
220
|
+
provisional?.dtlsParams &&
|
|
221
|
+
media.dtlsParams &&
|
|
222
|
+
fingerprintKey(provisional.dtlsParams) !==
|
|
223
|
+
fingerprintKey(media.dtlsParams)) {
|
|
224
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Changing the fingerprint of a provisional DTLS association is unsupported");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (remoteSdp.type === "answer" &&
|
|
229
|
+
this.sctp.sctpTransport?.sctp?.associationState === src_1.SCTP_STATE.ESTABLISHED) {
|
|
230
|
+
const application = remoteSdp.media.find((media) => media.kind === "application" && media.port !== 0);
|
|
231
|
+
if (application?.rtp.muxId) {
|
|
232
|
+
const bundle = remoteSdp.group.find((group) => group.semantic === "BUNDLE" &&
|
|
233
|
+
group.items.includes(application.rtp.muxId));
|
|
234
|
+
const owner = bundle?.items[0] ?? application.rtp.muxId;
|
|
235
|
+
const desired = this.negotiation.transportByMid.get(owner) ??
|
|
236
|
+
this.transceivers
|
|
237
|
+
.getTransceivers()
|
|
238
|
+
.find((transceiver) => transceiver.mid === owner)?.dtlsTransport ??
|
|
239
|
+
(this.sctp.sctpTransport.mid === owner
|
|
240
|
+
? this.sctp.sctpTransport.dtlsTransport
|
|
241
|
+
: undefined);
|
|
242
|
+
if (desired && desired !== this.sctp.sctpTransport.dtlsTransport) {
|
|
243
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", "Moving a connected SCTP association to another DTLS transport is unsupported");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (remoteSdp.type === "offer") {
|
|
248
|
+
// Checked before a replacement retires the previous pending offer.
|
|
249
|
+
this.topology.assertPendingSctpBinding(remoteSdp);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Local codecs an answer m-line without a recorded local offer is checked
|
|
254
|
+
* against: the configured codecs (a sender track's codec is not adopted).
|
|
255
|
+
*/
|
|
256
|
+
localCodecsFor(media) {
|
|
257
|
+
return this.config.codecs[media.kind] ?? [];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.DescriptionValidation = DescriptionValidation;
|
|
261
|
+
//# sourceMappingURL=descriptionValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptionValidation.js","sourceRoot":"","sources":["../../../../src/negotiation/descriptionValidation.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,sCAAqD;AACrD,oCAA0E;AAS1E,SAAS,cAAc,CAAC,MAAmD;IACzE,OAAO,MAAM,CAAC,YAAY;SACvB,GAAG,CACF,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CACvB,GAAG,SAAS,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAC1E;SACA,IAAI,EAAE;SACN,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAa,qBAAqB;IAChC,YACmB,MAAkB,EAClB,GAAe,EACf,YAAgC,EAChC,IAA0B,EAC1B,WAAmC,EACnC,QAAwB;QALzC;;;;mBAAiB,MAAM;WAAY;QACnC;;;;mBAAiB,GAAG;WAAY;Q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Ae,EAAE;yBACjB,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE,aAAa;oBAClE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,KAAK;wBACpC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa;wBACvC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACjB,IAAI,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;oBACjE,MAAM,IAAA,iCAAwB,EAC5B,0BAA0B,EAC1B,8EAA8E,CAC/E,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,SAAS,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC/B,mEAAmE;YACnE,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,KAAuB;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAyB,CAAC,IAAI,EAAE,CAAC;IACnE,CAAC;CACF;AA7SD,sDA6SC","sourcesContent":["import { SCTP_STATE } from \"../../../sctp/src\";\nimport type { PeerConfig } from \"../api/peerConfig\";\nimport { createWebRtcDomException } from \"../errors\";\nimport { negotiateRemoteCodecs, type TransceiverManager } from \"../media\";\nimport type { NegotiationTransaction } from \"../negotiationTransaction\";\nimport type { SctpTransportManager } from \"../sctpManager\";\nimport type { MediaDescription, SessionDescription } from \"../sdp\";\nimport type { SDPManager } from \"../sdpManager\";\nimport type { RTCDtlsTransport } from \"../transport/dtls\";\nimport type { RTCSignalingState } from \"../types/domain\";\nimport type { BundleTopology } from \"./bundleTopology\";\n\nfunction fingerprintKey(params: NonNullable<MediaDescription[\"dtlsParams\"]>) {\n return params.fingerprints\n .map(\n ({ algorithm, value }) =>\n `${algorithm.toLowerCase()}:${value.replaceAll(\":\", \"\").toLowerCase()}`,\n )\n .sort()\n .join(\"|\");\n}\n\n/**\n * Validation of a description before any transaction or live state changes.\n * A description that fails here leaves the signaling state, both\n * descriptions and every transport as they were.\n */\nexport class DescriptionValidation {\n constructor(\n private readonly config: PeerConfig,\n private readonly sdp: SDPManager,\n private readonly transceivers: TransceiverManager,\n private readonly sctp: SctpTransportManager,\n private readonly negotiation: NegotiationTransaction,\n private readonly topology: BundleTopology,\n ) {}\n\n /**\n * A local description must use the ICE credentials of the transports\n * prepared for it and keep the DTLS role of a live association.\n */\n /**\n * Validate a local description without changing anything. `transportForMid`\n * resolves the transport of an m-line the description associates with a\n * transceiver that is not associated yet.\n */\n validateLocal(\n description: SessionDescription,\n transportForMid: (mid: string) => RTCDtlsTransport | undefined = () =>\n undefined,\n ) {\n for (const media of description.media) {\n if (media.port === 0 || !media.iceParams) continue;\n const prepared =\n media.rtp.muxId && this.negotiation.transportByMid.get(media.rtp.muxId);\n const live =\n (media.kind === \"application\"\n ? this.sctp.sctpTransport?.dtlsTransport\n : this.transceivers\n .getTransceivers()\n .find((transceiver) => transceiver.mid === media.rtp.muxId)\n ?.dtlsTransport) ?? transportForMid(media.rtp.muxId ?? \"\");\n // The credentials are the transport's live ones, or a restart\n // generation a created description carries that is still valid.\n const matches = (transport?: RTCDtlsTransport) =>\n !!transport?.iceTransport.localGenerationFor(\n media.iceParams!.usernameFragment,\n media.iceParams!.password,\n );\n // An answer must use the transport prepared for it. A (replacement)\n // offer is built from the live transports; re-applying the previous\n // pending offer may carry its prepared credentials instead.\n const acceptable =\n description.type === \"offer\"\n ? [prepared, live].filter(Boolean)\n : [prepared || live].filter(Boolean);\n if (\n acceptable.length > 0 &&\n !acceptable.some((transport) => matches(transport || undefined))\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Local SDP must use prepared ICE credentials\",\n );\n }\n // Like a remote one, a local answer or pranswer keeps the DTLS role\n // of a live association (RFC 8842 section 5.5); an edited a=setup is\n // refused before it can change the running transport.\n const bundledNonTag = this.topology.isBundledNonTag(\n description,\n media.rtp.muxId,\n );\n const localRole = media.dtlsParams?.role;\n if (\n description.type !== \"offer\" &&\n !bundledNonTag &&\n localRole &&\n localRole !== \"auto\" &&\n live &&\n (!prepared || prepared === live) &&\n [\"connecting\", \"connected\"].includes(live.state) &&\n live.role !== \"auto\" &&\n live.role !== localRole\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Changing the DTLS role of a connected association is unsupported\",\n );\n }\n }\n }\n\n /**\n * A remote description: common codecs with the pending local offer, shared\n * transports, media kinds, SCTP port, codecs, DTLS fingerprint and role, and\n * SCTP binding are all checked before any state changes.\n */\n /**\n * A new MID on an existing m-line recycles it (JSEP 5.2.2). An m-line the\n * current session did not reject belongs to a local transceiver; only a\n * stopped one gives its slot up, an inactive one the application keeps\n * does not.\n */\n private assertRecyclesOnlyStoppedMLines(remoteSdp: SessionDescription) {\n const current = this.sdp.currentRemoteDescription;\n if (remoteSdp.type !== \"offer\" || !current) return;\n for (const [index, media] of remoteSdp.media.entries()) {\n const previous = current.media[index];\n const committedLocal = this.sdp.currentLocalDescription?.media[index];\n if (\n !previous?.rtp.muxId ||\n media.rtp.muxId === previous.rtp.muxId ||\n previous.port === 0 ||\n committedLocal?.port === 0\n ) {\n continue;\n }\n const owner = this.transceivers\n .getTransceivers()\n .find((t) => t.mid === previous.rtp.muxId);\n if (owner && !owner.stopped && !owner.stopping) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"An m-line of a transceiver that is not stopped cannot be recycled\",\n );\n }\n }\n }\n\n validateRemote(\n remoteSdp: SessionDescription,\n signalingState: RTCSignalingState,\n ) {\n this.sdp.validateRemoteDescription(remoteSdp);\n this.topology.assertAnswerKeepsSharedTransports(remoteSdp, signalingState);\n this.assertRecyclesOnlyStoppedMLines(remoteSdp);\n for (const [mediaIndex, media] of remoteSdp.media.entries()) {\n if (![\"audio\", \"video\", \"application\"].includes(media.kind)) {\n throw createWebRtcDomException(\n \"OperationError\",\n \"Unsupported media kind\",\n );\n }\n if (media.kind === \"application\" && media.port !== 0) {\n if (!media.sctpPort || media.sctpPort < 1 || media.sctpPort > 65535) {\n throw createWebRtcDomException(\"OperationError\", \"Invalid SCTP port\");\n }\n if (\n this.sctp.sctpRemotePort &&\n this.sctp.sctpRemotePort !== media.sctpPort\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Changing the port of an existing SCTP association is unsupported\",\n );\n }\n }\n if (\n remoteSdp.type !== \"offer\" &&\n media.port !== 0 &&\n media.kind !== \"application\" &&\n negotiateRemoteCodecs(\n this.transceivers\n .getTransceivers()\n .find((transceiver) => transceiver.mid === media.rtp.muxId)\n ?.pendingLocalOfferCodecs ?? this.localCodecsFor(media),\n media,\n ).length === 0\n ) {\n throw createWebRtcDomException(\n \"InvalidAccessError\",\n \"No supported codec in answer\",\n );\n }\n if (media.port !== 0 && this.sdp.currentRemoteDescription) {\n const currentMedia =\n this.sdp.currentRemoteDescription.media[mediaIndex];\n const transport =\n media.kind === \"application\"\n ? this.sctp.sctpTransport?.dtlsTransport\n : this.transceivers\n .getTransceivers()\n .find((t) => t.mid === media.rtp.muxId)?.dtlsTransport;\n if (\n transport?.state === \"connected\" &&\n currentMedia?.dtlsParams &&\n media.dtlsParams\n ) {\n if (\n fingerprintKey(currentMedia.dtlsParams) !==\n fingerprintKey(media.dtlsParams)\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Changing the fingerprint of a connected DTLS association is unsupported\",\n );\n }\n }\n }\n // An answer or pranswer keeps the DTLS role of a live association\n // (RFC 8842 section 5.5), including one a first negotiation connected\n // at its pranswer; only a new association, such as a BUNDLE split owner\n // prepared for this proposal, may take another role. A non-tag BUNDLE\n // member never sets a role, so it is not checked.\n if (media.port !== 0 && remoteSdp.type !== \"offer\") {\n const transport =\n media.kind === \"application\"\n ? this.sctp.sctpTransport?.dtlsTransport\n : this.transceivers\n .getTransceivers()\n .find((t) => t.mid === media.rtp.muxId)?.dtlsTransport;\n const prepared = this.negotiation.transportByMid.get(\n media.rtp.muxId ?? \"\",\n );\n const bundledNonTag = this.topology.isBundledNonTag(\n remoteSdp,\n media.rtp.muxId,\n );\n const remoteRole = media.dtlsParams?.role;\n // An answer's `actpass` (invalid per RFC 5763 section 5) names no role;\n // werift keeps the role of a live association for it.\n if (\n !bundledNonTag &&\n remoteRole &&\n remoteRole !== \"auto\" &&\n transport &&\n [\"connecting\", \"connected\"].includes(transport.state) &&\n transport.role !== \"auto\" &&\n (!prepared || prepared === transport) &&\n (remoteRole === \"client\" ? \"server\" : \"client\") !== transport.role\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Changing the DTLS role of a connected association is unsupported\",\n );\n }\n }\n if (\n media.port !== 0 &&\n this.sdp.pendingRemoteDescription?.type === \"pranswer\" &&\n !this.sdp.currentRemoteDescription\n ) {\n const provisional = this.sdp.pendingRemoteDescription.media[mediaIndex];\n const transport =\n media.kind === \"application\"\n ? this.sctp.sctpTransport?.dtlsTransport\n : this.transceivers\n .getTransceivers()\n .find((transceiver) => transceiver.mid === media.rtp.muxId)\n ?.dtlsTransport;\n if (\n transport?.state === \"connected\" &&\n provisional?.dtlsParams &&\n media.dtlsParams &&\n fingerprintKey(provisional.dtlsParams) !==\n fingerprintKey(media.dtlsParams)\n ) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Changing the fingerprint of a provisional DTLS association is unsupported\",\n );\n }\n }\n }\n if (\n remoteSdp.type === \"answer\" &&\n this.sctp.sctpTransport?.sctp?.associationState === SCTP_STATE.ESTABLISHED\n ) {\n const application = remoteSdp.media.find(\n (media) => media.kind === \"application\" && media.port !== 0,\n );\n if (application?.rtp.muxId) {\n const bundle = remoteSdp.group.find(\n (group) =>\n group.semantic === \"BUNDLE\" &&\n group.items.includes(application.rtp.muxId!),\n );\n const owner = bundle?.items[0] ?? application.rtp.muxId;\n const desired =\n this.negotiation.transportByMid.get(owner) ??\n this.transceivers\n .getTransceivers()\n .find((transceiver) => transceiver.mid === owner)?.dtlsTransport ??\n (this.sctp.sctpTransport.mid === owner\n ? this.sctp.sctpTransport.dtlsTransport\n : undefined);\n if (desired && desired !== this.sctp.sctpTransport.dtlsTransport) {\n throw createWebRtcDomException(\n \"InvalidModificationError\",\n \"Moving a connected SCTP association to another DTLS transport is unsupported\",\n );\n }\n }\n }\n\n if (remoteSdp.type === \"offer\") {\n // Checked before a replacement retires the previous pending offer.\n this.topology.assertPendingSctpBinding(remoteSdp);\n }\n }\n\n /**\n * Local codecs an answer m-line without a recorded local offer is checked\n * against: the configured codecs (a sender track's codec is not adopted).\n */\n private localCodecsFor(media: MediaDescription) {\n return this.config.codecs[media.kind as \"audio\" | \"video\"] ?? [];\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SessionDescription } from "../sdp";
|
|
2
|
+
/** Local ICE ufrags of the accepted m-lines of `description`. */
|
|
3
|
+
export declare function localIceUfrags(description?: SessionDescription): string[];
|
|
4
|
+
/**
|
|
5
|
+
* A `restartIce()` request (W3C). It records the local ufrags of the current
|
|
6
|
+
* and the pending local description to replace
|
|
7
|
+
* ([[LocalIceCredentialsToReplace]]). Every offer restarts ICE while the
|
|
8
|
+
* request stands; a rollback or glare keeps it, and it clears only when an
|
|
9
|
+
* answer commits local credentials outside that set.
|
|
10
|
+
*/
|
|
11
|
+
export declare class IceRestartRequest {
|
|
12
|
+
requested: boolean;
|
|
13
|
+
private toReplace;
|
|
14
|
+
request(current?: SessionDescription, pending?: SessionDescription): void;
|
|
15
|
+
/** The local ufrags the next offer must not carry again. */
|
|
16
|
+
get replacing(): ReadonlySet<string>;
|
|
17
|
+
/** Nothing current to replace: fresh credentials satisfy the request. */
|
|
18
|
+
clear(): void;
|
|
19
|
+
/** An answer committed `current`: settle the request if it replaced them all. */
|
|
20
|
+
settle(current?: SessionDescription): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IceRestartRequest = void 0;
|
|
4
|
+
exports.localIceUfrags = localIceUfrags;
|
|
5
|
+
/** Local ICE ufrags of the accepted m-lines of `description`. */
|
|
6
|
+
function localIceUfrags(description) {
|
|
7
|
+
return (description?.media ?? [])
|
|
8
|
+
.filter((media) => media.port !== 0)
|
|
9
|
+
.map((media) => media.iceParams?.usernameFragment)
|
|
10
|
+
.filter((ufrag) => !!ufrag);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A `restartIce()` request (W3C). It records the local ufrags of the current
|
|
14
|
+
* and the pending local description to replace
|
|
15
|
+
* ([[LocalIceCredentialsToReplace]]). Every offer restarts ICE while the
|
|
16
|
+
* request stands; a rollback or glare keeps it, and it clears only when an
|
|
17
|
+
* answer commits local credentials outside that set.
|
|
18
|
+
*/
|
|
19
|
+
class IceRestartRequest {
|
|
20
|
+
constructor() {
|
|
21
|
+
Object.defineProperty(this, "requested", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: false
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "toReplace", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: new Set()
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
request(current, pending) {
|
|
35
|
+
this.requested = true;
|
|
36
|
+
this.toReplace = new Set([
|
|
37
|
+
...localIceUfrags(current),
|
|
38
|
+
...localIceUfrags(pending),
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
/** The local ufrags the next offer must not carry again. */
|
|
42
|
+
get replacing() {
|
|
43
|
+
return this.toReplace;
|
|
44
|
+
}
|
|
45
|
+
/** Nothing current to replace: fresh credentials satisfy the request. */
|
|
46
|
+
clear() {
|
|
47
|
+
this.requested = false;
|
|
48
|
+
this.toReplace.clear();
|
|
49
|
+
}
|
|
50
|
+
/** An answer committed `current`: settle the request if it replaced them all. */
|
|
51
|
+
settle(current) {
|
|
52
|
+
if (!this.requested)
|
|
53
|
+
return;
|
|
54
|
+
if (localIceUfrags(current).some((ufrag) => this.toReplace.has(ufrag))) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.clear();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.IceRestartRequest = IceRestartRequest;
|
|
61
|
+
//# sourceMappingURL=iceRestartRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iceRestartRequest.js","sourceRoot":"","sources":["../../../../src/negotiation/iceRestartRequest.ts"],"names":[],"mappings":";;;AAGA,wCAKC;AAND,iEAAiE;AACjE,SAAgB,cAAc,CAAC,WAAgC;IAC7D,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;SAC9B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;SACnC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC;SACjD,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,MAAa,iBAAiB;IAA9B;QACE;;;;mBAAY,KAAK;WAAC;QACV;;;;mBAAY,IAAI,GAAG,EAAU;WAAC;IA6BxC,CAAC;IA3BC,OAAO,CAAC,OAA4B,EAAE,OAA4B;QAChE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC;YACvB,GAAG,cAAc,CAAC,OAAO,CAAC;YAC1B,GAAG,cAAc,CAAC,OAAO,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,4DAA4D;IAC5D,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,yEAAyE;IACzE,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,iFAAiF;IACjF,MAAM,CAAC,OAA4B;QACjC,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAC5B,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AA/BD,8CA+BC","sourcesContent":["import type { SessionDescription } from \"../sdp\";\n\n/** Local ICE ufrags of the accepted m-lines of `description`. */\nexport function localIceUfrags(description?: SessionDescription) {\n return (description?.media ?? [])\n .filter((media) => media.port !== 0)\n .map((media) => media.iceParams?.usernameFragment)\n .filter((ufrag): ufrag is string => !!ufrag);\n}\n\n/**\n * A `restartIce()` request (W3C). It records the local ufrags of the current\n * and the pending local description to replace\n * ([[LocalIceCredentialsToReplace]]). Every offer restarts ICE while the\n * request stands; a rollback or glare keeps it, and it clears only when an\n * answer commits local credentials outside that set.\n */\nexport class IceRestartRequest {\n requested = false;\n private toReplace = new Set<string>();\n\n request(current?: SessionDescription, pending?: SessionDescription) {\n this.requested = true;\n this.toReplace = new Set([\n ...localIceUfrags(current),\n ...localIceUfrags(pending),\n ]);\n }\n\n /** The local ufrags the next offer must not carry again. */\n get replacing(): ReadonlySet<string> {\n return this.toReplace;\n }\n\n /** Nothing current to replace: fresh credentials satisfy the request. */\n clear() {\n this.requested = false;\n this.toReplace.clear();\n }\n\n /** An answer committed `current`: settle the request if it replaced them all. */\n settle(current?: SessionDescription) {\n if (!this.requested) return;\n if (localIceUfrags(current).some((ufrag) => this.toReplace.has(ufrag))) {\n return;\n }\n this.clear();\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiation state shapes and helpers shared between the media components
|
|
3
|
+
* and the negotiation transaction. Internal: not re-exported by the package.
|
|
4
|
+
*/
|
|
5
|
+
import type { RtpRouter } from "../media/router";
|
|
6
|
+
import type { RTCRtpReceiver } from "../media/rtpReceiver";
|
|
7
|
+
import type { RTCRtpTransceiver } from "../media/rtpTransceiver";
|
|
8
|
+
import type { MediaStreamTrack } from "../media/track";
|
|
9
|
+
/** A transceiver's negotiation state, for a rollback baseline. */
|
|
10
|
+
export type TransceiverNegotiationState = ReturnType<RTCRtpTransceiver["snapshotNegotiationState"]>;
|
|
11
|
+
/** A receiver's negotiation state, for a rollback baseline. */
|
|
12
|
+
export type ReceiverNegotiationState = ReturnType<RTCRtpReceiver["snapshotNegotiationState"]>;
|
|
13
|
+
/** The routes of a router, for a negotiation rollback baseline. */
|
|
14
|
+
export type RouterSnapshot = ReturnType<RtpRouter["snapshotRoutes"]>;
|
|
15
|
+
/** The transceivers of a PeerConnection and their negotiation state. */
|
|
16
|
+
export type TransceiversNegotiationState = {
|
|
17
|
+
order: RTCRtpTransceiver[];
|
|
18
|
+
states: Map<RTCRtpTransceiver, {
|
|
19
|
+
transceiver: TransceiverNegotiationState;
|
|
20
|
+
notifiedRemoteTrack?: {
|
|
21
|
+
track: MediaStreamTrack;
|
|
22
|
+
streams: string[];
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* RIDs are scoped to their m-line (RFC 8851), so simulcast routes are keyed
|
|
28
|
+
* by MID and RID: two m-lines may reuse the same RID names.
|
|
29
|
+
*/
|
|
30
|
+
export declare const ridRouteKey: (mid: string, rid: string) => string;
|
|
31
|
+
/** How many times the application called `stop()` on `transceiver`. */
|
|
32
|
+
export declare function getApplicationStopRevision(transceiver: RTCRtpTransceiver): number;
|
|
33
|
+
/** Record an application `stop()`; a rollback keeps it. */
|
|
34
|
+
export declare function noteApplicationStop(transceiver: RTCRtpTransceiver): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ridRouteKey = void 0;
|
|
4
|
+
exports.getApplicationStopRevision = getApplicationStopRevision;
|
|
5
|
+
exports.noteApplicationStop = noteApplicationStop;
|
|
6
|
+
/**
|
|
7
|
+
* RIDs are scoped to their m-line (RFC 8851), so simulcast routes are keyed
|
|
8
|
+
* by MID and RID: two m-lines may reuse the same RID names.
|
|
9
|
+
*/
|
|
10
|
+
const ridRouteKey = (mid, rid) => `${mid}\u0000${rid}`;
|
|
11
|
+
exports.ridRouteKey = ridRouteKey;
|
|
12
|
+
const applicationStops = new WeakMap();
|
|
13
|
+
/** How many times the application called `stop()` on `transceiver`. */
|
|
14
|
+
function getApplicationStopRevision(transceiver) {
|
|
15
|
+
return applicationStops.get(transceiver) ?? 0;
|
|
16
|
+
}
|
|
17
|
+
/** Record an application `stop()`; a rollback keeps it. */
|
|
18
|
+
function noteApplicationStop(transceiver) {
|
|
19
|
+
applicationStops.set(transceiver, getApplicationStopRevision(transceiver) + 1);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=internalState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalState.js","sourceRoot":"","sources":["../../../../src/negotiation/internalState.ts"],"names":[],"mappings":";;;AA2CA,gEAEC;AAGD,kDAKC;AAnBD;;;GAGG;AACI,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,SAAS,GAAG,EAAE,CAAC;AAAjE,QAAA,WAAW,eAAsD;AAE9E,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA6B,CAAC;AAElE,uEAAuE;AACvE,SAAgB,0BAA0B,CAAC,WAA8B;IACvE,OAAO,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,2DAA2D;AAC3D,SAAgB,mBAAmB,CAAC,WAA8B;IAChE,gBAAgB,CAAC,GAAG,CAClB,WAAW,EACX,0BAA0B,CAAC,WAAW,CAAC,GAAG,CAAC,CAC5C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Negotiation state shapes and helpers shared between the media components\n * and the negotiation transaction. Internal: not re-exported by the package.\n */\nimport type { RtpRouter } from \"../media/router\";\nimport type { RTCRtpReceiver } from \"../media/rtpReceiver\";\nimport type { RTCRtpTransceiver } from \"../media/rtpTransceiver\";\nimport type { MediaStreamTrack } from \"../media/track\";\n\n/** A transceiver's negotiation state, for a rollback baseline. */\nexport type TransceiverNegotiationState = ReturnType<\n RTCRtpTransceiver[\"snapshotNegotiationState\"]\n>;\n\n/** A receiver's negotiation state, for a rollback baseline. */\nexport type ReceiverNegotiationState = ReturnType<\n RTCRtpReceiver[\"snapshotNegotiationState\"]\n>;\n\n/** The routes of a router, for a negotiation rollback baseline. */\nexport type RouterSnapshot = ReturnType<RtpRouter[\"snapshotRoutes\"]>;\n\n/** The transceivers of a PeerConnection and their negotiation state. */\nexport type TransceiversNegotiationState = {\n order: RTCRtpTransceiver[];\n states: Map<\n RTCRtpTransceiver,\n {\n transceiver: TransceiverNegotiationState;\n notifiedRemoteTrack?: { track: MediaStreamTrack; streams: string[] };\n }\n >;\n};\n\n/**\n * RIDs are scoped to their m-line (RFC 8851), so simulcast routes are keyed\n * by MID and RID: two m-lines may reuse the same RID names.\n */\nexport const ridRouteKey = (mid: string, rid: string) => `${mid}\\u0000${rid}`;\n\nconst applicationStops = new WeakMap<RTCRtpTransceiver, number>();\n\n/** How many times the application called `stop()` on `transceiver`. */\nexport function getApplicationStopRevision(transceiver: RTCRtpTransceiver) {\n return applicationStops.get(transceiver) ?? 0;\n}\n\n/** Record an application `stop()`; a rollback keeps it. */\nexport function noteApplicationStop(transceiver: RTCRtpTransceiver) {\n applicationStops.set(\n transceiver,\n getApplicationStopRevision(transceiver) + 1,\n );\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RTCSignalingState } from "../types/domain";
|
|
2
|
+
/**
|
|
3
|
+
* W3C negotiation-needed bookkeeping for one RTCPeerConnection.
|
|
4
|
+
*
|
|
5
|
+
* Every change that needs negotiation gets a sequence number. A local offer
|
|
6
|
+
* carries the changes made before it was created, and those count as
|
|
7
|
+
* negotiated once its answer commits (a rollback discards them). The event
|
|
8
|
+
* fires at most once per task, only in `stable`, and only for changes no
|
|
9
|
+
* committed offer carried.
|
|
10
|
+
*/
|
|
11
|
+
export declare class NegotiationNeeded {
|
|
12
|
+
private readonly host;
|
|
13
|
+
/** W3C [[NegotiationNeeded]]. */
|
|
14
|
+
flag: boolean;
|
|
15
|
+
/** A change arrived outside `stable`: re-evaluate when it returns there. */
|
|
16
|
+
recheck: boolean;
|
|
17
|
+
/** Coalesces the changes of one task into a single event. */
|
|
18
|
+
private scheduled;
|
|
19
|
+
/** Sequence number of the latest change that needs negotiation. */
|
|
20
|
+
private changeSeq;
|
|
21
|
+
/** Changes carried by a local offer whose answer committed. */
|
|
22
|
+
private negotiatedSeq;
|
|
23
|
+
/** Changes carried by the applied local offer (discarded on rollback). */
|
|
24
|
+
private pendingOfferSeq?;
|
|
25
|
+
constructor(host: {
|
|
26
|
+
signalingState: () => RTCSignalingState;
|
|
27
|
+
isClosed: () => boolean;
|
|
28
|
+
/** Created offers/answers no longer reflect the state. */
|
|
29
|
+
invalidate: () => void;
|
|
30
|
+
fire: () => void;
|
|
31
|
+
});
|
|
32
|
+
/** Record a change that needs negotiation and schedule the event. */
|
|
33
|
+
change(): void;
|
|
34
|
+
/** Schedule the event if unnegotiated changes remain (also on return to stable). */
|
|
35
|
+
schedule(): void;
|
|
36
|
+
/** The change sequence a created offer includes (kept in its record). */
|
|
37
|
+
noteCreatedOffer(): number;
|
|
38
|
+
/** A created offer, including changes up to `changeSeq`, was applied. */
|
|
39
|
+
noteAppliedOffer(changeSeq: number): void;
|
|
40
|
+
/** The pending local offer was rolled back (explicitly or implicitly). */
|
|
41
|
+
discardPendingOffer(): void;
|
|
42
|
+
/** The answer to the pending local offer committed its changes. */
|
|
43
|
+
commitPendingOffer(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NegotiationNeeded = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* W3C negotiation-needed bookkeeping for one RTCPeerConnection.
|
|
6
|
+
*
|
|
7
|
+
* Every change that needs negotiation gets a sequence number. A local offer
|
|
8
|
+
* carries the changes made before it was created, and those count as
|
|
9
|
+
* negotiated once its answer commits (a rollback discards them). The event
|
|
10
|
+
* fires at most once per task, only in `stable`, and only for changes no
|
|
11
|
+
* committed offer carried.
|
|
12
|
+
*/
|
|
13
|
+
class NegotiationNeeded {
|
|
14
|
+
constructor(host) {
|
|
15
|
+
Object.defineProperty(this, "host", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: host
|
|
20
|
+
});
|
|
21
|
+
/** W3C [[NegotiationNeeded]]. */
|
|
22
|
+
Object.defineProperty(this, "flag", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: false
|
|
27
|
+
});
|
|
28
|
+
/** A change arrived outside `stable`: re-evaluate when it returns there. */
|
|
29
|
+
Object.defineProperty(this, "recheck", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: false
|
|
34
|
+
});
|
|
35
|
+
/** Coalesces the changes of one task into a single event. */
|
|
36
|
+
Object.defineProperty(this, "scheduled", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: false
|
|
41
|
+
});
|
|
42
|
+
/** Sequence number of the latest change that needs negotiation. */
|
|
43
|
+
Object.defineProperty(this, "changeSeq", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: 0
|
|
48
|
+
});
|
|
49
|
+
/** Changes carried by a local offer whose answer committed. */
|
|
50
|
+
Object.defineProperty(this, "negotiatedSeq", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: 0
|
|
55
|
+
});
|
|
56
|
+
/** Changes carried by the applied local offer (discarded on rollback). */
|
|
57
|
+
Object.defineProperty(this, "pendingOfferSeq", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Record a change that needs negotiation and schedule the event. */
|
|
65
|
+
change() {
|
|
66
|
+
this.changeSeq++;
|
|
67
|
+
this.schedule();
|
|
68
|
+
}
|
|
69
|
+
/** Schedule the event if unnegotiated changes remain (also on return to stable). */
|
|
70
|
+
schedule() {
|
|
71
|
+
this.host.invalidate();
|
|
72
|
+
this.recheck = true;
|
|
73
|
+
if (this.flag ||
|
|
74
|
+
this.scheduled ||
|
|
75
|
+
this.host.signalingState() !== "stable") {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.recheck = false;
|
|
79
|
+
this.scheduled = true;
|
|
80
|
+
setImmediate(() => {
|
|
81
|
+
this.scheduled = false;
|
|
82
|
+
if (this.host.isClosed())
|
|
83
|
+
return;
|
|
84
|
+
if (this.negotiatedSeq >= this.changeSeq) {
|
|
85
|
+
// 発火前に適用された local offer が変更をすべて含んでいる
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.host.signalingState() !== "stable") {
|
|
89
|
+
// stable に戻った時点で改めて判定する
|
|
90
|
+
this.recheck = true;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.flag = true;
|
|
94
|
+
this.host.fire();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** The change sequence a created offer includes (kept in its record). */
|
|
98
|
+
noteCreatedOffer() {
|
|
99
|
+
return this.changeSeq;
|
|
100
|
+
}
|
|
101
|
+
/** A created offer, including changes up to `changeSeq`, was applied. */
|
|
102
|
+
noteAppliedOffer(changeSeq) {
|
|
103
|
+
this.pendingOfferSeq = changeSeq;
|
|
104
|
+
}
|
|
105
|
+
/** The pending local offer was rolled back (explicitly or implicitly). */
|
|
106
|
+
discardPendingOffer() {
|
|
107
|
+
this.pendingOfferSeq = undefined;
|
|
108
|
+
}
|
|
109
|
+
/** The answer to the pending local offer committed its changes. */
|
|
110
|
+
commitPendingOffer() {
|
|
111
|
+
if (this.pendingOfferSeq == undefined)
|
|
112
|
+
return;
|
|
113
|
+
this.negotiatedSeq = Math.max(this.negotiatedSeq, this.pendingOfferSeq);
|
|
114
|
+
this.pendingOfferSeq = undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.NegotiationNeeded = NegotiationNeeded;
|
|
118
|
+
//# sourceMappingURL=negotiationNeeded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiationNeeded.js","sourceRoot":"","sources":["../../../../src/negotiation/negotiationNeeded.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;GAQG;AACH,MAAa,iBAAiB;IAc5B,YACmB,IAMhB;QAND;;;;mBAAiB,IAAI;WAMpB;QApBH,iCAAiC;QACjC;;;;mBAAO,KAAK;WAAC;QACb,4EAA4E;QAC5E;;;;mBAAU,KAAK;WAAC;QAChB,6DAA6D;QACrD;;;;mBAAY,KAAK;WAAC;QAC1B,mEAAmE;QAC3D;;;;mBAAY,CAAC;WAAC;QACtB,+DAA+D;QACvD;;;;mBAAgB,CAAC;WAAC;QAC1B,0EAA0E;QAClE;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CAAC;IACnC,CAAC;IAED,mEAAmE;IACnE,kBAAkB;QAChB,IAAI,IAAI,CAAC,eAAe,IAAI,SAAS;YAAE,OAAO;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACxE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;IACnC,CAAC;CACF;AAjFD,8CAiFC","sourcesContent":["import type { RTCSignalingState } from \"../types/domain\";\n\n/**\n * W3C negotiation-needed bookkeeping for one RTCPeerConnection.\n *\n * Every change that needs negotiation gets a sequence number. A local offer\n * carries the changes made before it was created, and those count as\n * negotiated once its answer commits (a rollback discards them). The event\n * fires at most once per task, only in `stable`, and only for changes no\n * committed offer carried.\n */\nexport class NegotiationNeeded {\n /** W3C [[NegotiationNeeded]]. */\n flag = false;\n /** A change arrived outside `stable`: re-evaluate when it returns there. */\n recheck = false;\n /** Coalesces the changes of one task into a single event. */\n private scheduled = false;\n /** Sequence number of the latest change that needs negotiation. */\n private changeSeq = 0;\n /** Changes carried by a local offer whose answer committed. */\n private negotiatedSeq = 0;\n /** Changes carried by the applied local offer (discarded on rollback). */\n private pendingOfferSeq?: number;\n\n constructor(\n private readonly host: {\n signalingState: () => RTCSignalingState;\n isClosed: () => boolean;\n /** Created offers/answers no longer reflect the state. */\n invalidate: () => void;\n fire: () => void;\n },\n ) {}\n\n /** Record a change that needs negotiation and schedule the event. */\n change() {\n this.changeSeq++;\n this.schedule();\n }\n\n /** Schedule the event if unnegotiated changes remain (also on return to stable). */\n schedule() {\n this.host.invalidate();\n this.recheck = true;\n if (\n this.flag ||\n this.scheduled ||\n this.host.signalingState() !== \"stable\"\n ) {\n return;\n }\n this.recheck = false;\n this.scheduled = true;\n setImmediate(() => {\n this.scheduled = false;\n if (this.host.isClosed()) return;\n if (this.negotiatedSeq >= this.changeSeq) {\n // 発火前に適用された local offer が変更をすべて含んでいる\n return;\n }\n if (this.host.signalingState() !== \"stable\") {\n // stable に戻った時点で改めて判定する\n this.recheck = true;\n return;\n }\n this.flag = true;\n this.host.fire();\n });\n }\n\n /** The change sequence a created offer includes (kept in its record). */\n noteCreatedOffer() {\n return this.changeSeq;\n }\n\n /** A created offer, including changes up to `changeSeq`, was applied. */\n noteAppliedOffer(changeSeq: number) {\n this.pendingOfferSeq = changeSeq;\n }\n\n /** The pending local offer was rolled back (explicitly or implicitly). */\n discardPendingOffer() {\n this.pendingOfferSeq = undefined;\n }\n\n /** The answer to the pending local offer committed its changes. */\n commitPendingOffer() {\n if (this.pendingOfferSeq == undefined) return;\n this.negotiatedSeq = Math.max(this.negotiatedSeq, this.pendingOfferSeq);\n this.pendingOfferSeq = undefined;\n }\n}\n"]}
|