werift 0.27.0 → 0.29.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 +299 -8
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +51 -10
- package/lib/common/src/transport.js +35 -9
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/carrier/direct.d.ts +67 -0
- package/lib/dtls/src/carrier/direct.js +226 -0
- package/lib/dtls/src/carrier/direct.js.map +1 -0
- package/lib/dtls/src/carrier/types.d.ts +81 -0
- package/lib/dtls/src/carrier/types.js +7 -0
- package/lib/dtls/src/carrier/types.js.map +1 -0
- package/lib/dtls/src/cipher/const.d.ts +6 -0
- package/lib/dtls/src/cipher/const.js +13 -2
- package/lib/dtls/src/cipher/const.js.map +1 -1
- package/lib/dtls/src/cipher/prf.js +11 -2
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/tls13/aead.d.ts +41 -0
- package/lib/dtls/src/cipher/tls13/aead.js +128 -0
- package/lib/dtls/src/cipher/tls13/aead.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/hkdf.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js +76 -0
- package/lib/dtls/src/cipher/tls13/hkdf.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.d.ts +70 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js +114 -0
- package/lib/dtls/src/cipher/tls13/keySchedule.js.map +1 -0
- package/lib/dtls/src/cipher/tls13/signature.d.ts +30 -0
- package/lib/dtls/src/cipher/tls13/signature.js +149 -0
- package/lib/dtls/src/cipher/tls13/signature.js.map +1 -0
- package/lib/dtls/src/client.d.ts +253 -0
- package/lib/dtls/src/client.js +1269 -14
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +47 -0
- package/lib/dtls/src/context/dtls.js +121 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +30 -1
- package/lib/dtls/src/context/transport.js +67 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/engine/v1_3/connection-base.d.ts +520 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js +1644 -0
- package/lib/dtls/src/engine/v1_3/connection-base.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/connection.d.ts +181 -0
- package/lib/dtls/src/engine/v1_3/connection.js +680 -0
- package/lib/dtls/src/engine/v1_3/connection.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.d.ts +38 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js +166 -0
- package/lib/dtls/src/engine/v1_3/early-data-buffer.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.d.ts +4 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js +62 -0
- package/lib/dtls/src/engine/v1_3/flight/certificate.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js +119 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight1.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.d.ts +8 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js +251 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js +99 -0
- package/lib/dtls/src/engine/v1_3/flight/client/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js +138 -0
- package/lib/dtls/src/engine/v1_3/flight/dispatch.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.d.ts +13 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js +46 -0
- package/lib/dtls/src/engine/v1_3/flight/extensions.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js +16 -0
- package/lib/dtls/src/engine/v1_3/flight/finished.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.d.ts +12 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js +94 -0
- package/lib/dtls/src/engine/v1_3/flight/post-hs.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.d.ts +21 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js +227 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight2.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.d.ts +6 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js +455 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight4.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.d.ts +5 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js +48 -0
- package/lib/dtls/src/engine/v1_3/flight/server/flight5.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.d.ts +119 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js +782 -0
- package/lib/dtls/src/engine/v1_3/flight-tx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/host.d.ts +86 -0
- package/lib/dtls/src/engine/v1_3/host.js +11 -0
- package/lib/dtls/src/engine/v1_3/host.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/record-rx.d.ts +77 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js +818 -0
- package/lib/dtls/src/engine/v1_3/record-rx.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/transcript.d.ts +22 -0
- package/lib/dtls/src/engine/v1_3/transcript.js +65 -0
- package/lib/dtls/src/engine/v1_3/transcript.js.map +1 -0
- package/lib/dtls/src/engine/v1_3/types.d.ts +169 -0
- package/lib/dtls/src/engine/v1_3/types.js +113 -0
- package/lib/dtls/src/engine/v1_3/types.js.map +1 -0
- package/lib/dtls/src/flight/client/flight1.d.ts +7 -1
- package/lib/dtls/src/flight/client/flight1.js +9 -3
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight3.d.ts +8 -0
- package/lib/dtls/src/flight/client/flight3.js +24 -4
- package/lib/dtls/src/flight/client/flight3.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +17 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +21 -0
- package/lib/dtls/src/flight/flight.js +119 -9
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/commitClientHello.d.ts +35 -0
- package/lib/dtls/src/flight/server/commitClientHello.js +149 -0
- package/lib/dtls/src/flight/server/commitClientHello.js.map +1 -0
- package/lib/dtls/src/flight/server/flight2.d.ts +12 -3
- package/lib/dtls/src/flight/server/flight2.js +29 -105
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +14 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +12 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +10 -0
- package/lib/dtls/src/handshake/const.js +10 -0
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/cookie.d.ts +113 -0
- package/lib/dtls/src/handshake/extensions/cookie.js +326 -0
- package/lib/dtls/src/handshake/extensions/cookie.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/ids.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/ids.js +11 -0
- package/lib/dtls/src/handshake/extensions/ids.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/keyShare.d.ts +28 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js +156 -0
- package/lib/dtls/src/handshake/extensions/keyShare.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.d.ts +27 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js +67 -0
- package/lib/dtls/src/handshake/extensions/signatureAlgorithms.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.d.ts +20 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js +90 -0
- package/lib/dtls/src/handshake/extensions/supportedVersions.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/unique.d.ts +7 -0
- package/lib/dtls/src/handshake/extensions/unique.js +19 -0
- package/lib/dtls/src/handshake/extensions/unique.js.map +1 -0
- package/lib/dtls/src/handshake/extensions/useSrtp.d.ts +26 -3
- package/lib/dtls/src/handshake/extensions/useSrtp.js +68 -12
- package/lib/dtls/src/handshake/extensions/useSrtp.js.map +1 -1
- package/lib/dtls/src/handshake/message/tls13/ack.d.ts +50 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js +107 -0
- package/lib/dtls/src/handshake/message/tls13/ack.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js +112 -0
- package/lib/dtls/src/handshake/message/tls13/certificate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.d.ts +17 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js +99 -0
- package/lib/dtls/src/handshake/message/tls13/certificateRequest.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.d.ts +21 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js +77 -0
- package/lib/dtls/src/handshake/message/tls13/certificateVerify.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.d.ts +19 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js +56 -0
- package/lib/dtls/src/handshake/message/tls13/encryptedExtensions.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.d.ts +13 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js +54 -0
- package/lib/dtls/src/handshake/message/tls13/keyUpdate.js.map +1 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.d.ts +33 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js +158 -0
- package/lib/dtls/src/handshake/message/tls13/newSessionTicket.js.map +1 -0
- package/lib/dtls/src/handshake/random.d.ts +14 -0
- package/lib/dtls/src/handshake/random.js +24 -0
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/handshake/validation.d.ts +26 -0
- package/lib/dtls/src/handshake/validation.js +32 -0
- package/lib/dtls/src/handshake/validation.js.map +1 -0
- package/lib/dtls/src/index.d.ts +8 -1
- package/lib/dtls/src/index.js +125 -44
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/internal.d.ts +7 -0
- package/lib/dtls/src/internal.js +57 -0
- package/lib/dtls/src/internal.js.map +1 -0
- package/lib/dtls/src/peer.d.ts +49 -0
- package/lib/dtls/src/peer.js +54 -0
- package/lib/dtls/src/peer.js.map +1 -0
- package/lib/dtls/src/record/antiReplayWindow.d.ts +33 -0
- package/lib/dtls/src/record/antiReplayWindow.js +119 -0
- package/lib/dtls/src/record/antiReplayWindow.js.map +1 -0
- package/lib/dtls/src/record/const.d.ts +15 -0
- package/lib/dtls/src/record/const.js +15 -1
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +0 -2
- package/lib/dtls/src/record/message/fragment.js +36 -17
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/reassembler.d.ts +62 -0
- package/lib/dtls/src/record/message/reassembler.js +249 -0
- package/lib/dtls/src/record/message/reassembler.js.map +1 -0
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +58 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/record/v1_3/header.d.ts +34 -0
- package/lib/dtls/src/record/v1_3/header.js +95 -0
- package/lib/dtls/src/record/v1_3/header.js.map +1 -0
- package/lib/dtls/src/record/v1_3/record.d.ts +133 -0
- package/lib/dtls/src/record/v1_3/record.js +370 -0
- package/lib/dtls/src/record/v1_3/record.js.map +1 -0
- package/lib/dtls/src/retransmission.d.ts +26 -0
- package/lib/dtls/src/retransmission.js +39 -0
- package/lib/dtls/src/retransmission.js.map +1 -0
- package/lib/dtls/src/server.d.ts +38 -0
- package/lib/dtls/src/server.js +382 -17
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +487 -11
- package/lib/dtls/src/socket.js +1359 -70
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/dtls/src/version.d.ts +89 -0
- package/lib/dtls/src/version.js +204 -0
- package/lib/dtls/src/version.js.map +1 -0
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +126 -0
- package/lib/ice/src/consent.js +470 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -0
- package/lib/ice/src/dns/lookup.js +130 -3
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +9 -0
- package/lib/ice/src/exceptions.js +14 -1
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/failover.d.ts +270 -0
- package/lib/ice/src/failover.js +674 -0
- package/lib/ice/src/failover.js.map +1 -0
- package/lib/ice/src/gatheringError.d.ts +28 -0
- package/lib/ice/src/gatheringError.js +17 -0
- package/lib/ice/src/gatheringError.js.map +1 -0
- package/lib/ice/src/ice.d.ts +486 -78
- package/lib/ice/src/ice.js +2415 -1129
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +404 -14
- package/lib/ice/src/iceBase.js +251 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +3 -0
- package/lib/ice/src/index.js +5 -1
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/datagram.d.ts +37 -0
- package/lib/ice/src/internal/datagram.js +45 -0
- package/lib/ice/src/internal/datagram.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +28 -0
- package/lib/ice/src/internal/hostInterfaces.js +89 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/internal/sped-bind.d.ts +44 -0
- package/lib/ice/src/internal/sped-bind.js +53 -0
- package/lib/ice/src/internal/sped-bind.js.map +1 -0
- package/lib/ice/src/internal/sped-binding-cache.d.ts +27 -0
- package/lib/ice/src/internal/sped-binding-cache.js +102 -0
- package/lib/ice/src/internal/sped-binding-cache.js.map +1 -0
- package/lib/ice/src/internal/sped.d.ts +15 -0
- package/lib/ice/src/internal/sped.js +62 -0
- package/lib/ice/src/internal/sped.js.map +1 -0
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionController.d.ts +111 -0
- package/lib/ice/src/nomination/selectionController.js +172 -0
- package/lib/ice/src/nomination/selectionController.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +178 -0
- package/lib/ice/src/nomination/selectionReplacement.js +429 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/sped/draft00/codec.d.ts +20 -0
- package/lib/ice/src/sped/draft00/codec.js +59 -0
- package/lib/ice/src/sped/draft00/codec.js.map +1 -0
- package/lib/ice/src/sped/draft00/constants.d.ts +14 -0
- package/lib/ice/src/sped/draft00/constants.js +18 -0
- package/lib/ice/src/sped/draft00/constants.js.map +1 -0
- package/lib/ice/src/sped/draft00/index.d.ts +6 -0
- package/lib/ice/src/sped/draft00/index.js +26 -0
- package/lib/ice/src/sped/draft00/index.js.map +1 -0
- package/lib/ice/src/sped/draft00/mtu.d.ts +38 -0
- package/lib/ice/src/sped/draft00/mtu.js +96 -0
- package/lib/ice/src/sped/draft00/mtu.js.map +1 -0
- package/lib/ice/src/sped/draft00/session.d.ts +86 -0
- package/lib/ice/src/sped/draft00/session.js +353 -0
- package/lib/ice/src/sped/draft00/session.js.map +1 -0
- package/lib/ice/src/sped/draft00/types.d.ts +16 -0
- package/lib/ice/src/sped/draft00/types.js +3 -0
- package/lib/ice/src/sped/draft00/types.js.map +1 -0
- package/lib/ice/src/sped/runtime.d.ts +188 -0
- package/lib/ice/src/sped/runtime.js +643 -0
- package/lib/ice/src/sped/runtime.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +38 -2
- package/lib/ice/src/stun/protocol.js +107 -21
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/rawAttributeValue.d.ts +1 -0
- package/lib/ice/src/stun/rawAttributeValue.js +6 -0
- package/lib/ice/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -1
- package/lib/ice/src/stun/tcpProtocol.js +21 -9
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +4 -0
- package/lib/ice/src/stun/transaction.js +27 -2
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +23 -4
- package/lib/ice/src/turn/protocol.js +99 -11
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +25 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice/src/utils.d.ts +13 -0
- package/lib/ice/src/utils.js +13 -0
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.js +4 -0
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +20 -1
- package/lib/ice-server/src/stun/const.js +9 -1
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +43 -3
- package/lib/ice-server/src/stun/message.js +258 -40
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/stun/rawAttributeValue.d.ts +6 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js +12 -0
- package/lib/ice-server/src/stun/rawAttributeValue.js.map +1 -0
- package/lib/index.mjs +47427 -25303
- package/lib/nonstandard/index.mjs +3076 -1318
- package/lib/polyfill/dom.mjs +40430 -18730
- package/lib/polyfill/index.mjs +40333 -18639
- package/lib/rtp/src/extra/processor/fsRetry.d.ts +20 -0
- package/lib/rtp/src/extra/processor/fsRetry.js +73 -0
- package/lib/rtp/src/extra/processor/fsRetry.js.map +1 -0
- package/lib/rtp/src/extra/processor/webm.d.ts +6 -0
- package/lib/rtp/src/extra/processor/webm.js +6 -2
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.d.ts +11 -0
- package/lib/rtp/src/extra/processor/webmCallback.js +23 -31
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmFileWriter.d.ts +24 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js +94 -0
- package/lib/rtp/src/extra/processor/webmFileWriter.js.map +1 -0
- package/lib/rtp/src/index.d.ts +1 -0
- package/lib/rtp/src/index.js +1 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +14 -1
- package/lib/rtp/src/rtp/continuity.js +24 -4
- package/lib/rtp/src/rtp/continuity.js.map +1 -1
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +10 -0
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/index.d.ts +1 -1
- package/lib/sctp/src/index.js +4 -1
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +86 -5
- package/lib/sctp/src/sctp.js +354 -75
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +43 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +547 -36
- package/lib/webrtc/src/api/peerConfig.js +187 -26
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +87 -2
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +122 -10
- package/lib/webrtc/src/dataChannel.js +214 -20
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/domEventTarget.d.ts +55 -0
- package/lib/webrtc/src/media/domEventTarget.js +216 -0
- package/lib/webrtc/src/media/domEventTarget.js.map +1 -0
- package/lib/webrtc/src/media/index.d.ts +2 -0
- package/lib/webrtc/src/media/index.js +1 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/parameters.d.ts +5 -0
- package/lib/webrtc/src/media/parameters.js +10 -0
- package/lib/webrtc/src/media/parameters.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +245 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +10 -0
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +4 -10
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +245 -51
- package/lib/webrtc/src/media/router.js +702 -237
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +277 -5
- package/lib/webrtc/src/media/rtpReceiver.js +826 -36
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +8 -1
- package/lib/webrtc/src/media/rtpSender.js +13 -6
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +47 -11
- package/lib/webrtc/src/media/rtpTransceiver.js +95 -11
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
- package/lib/webrtc/src/media/sender/senderStats.js +14 -19
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
- package/lib/webrtc/src/media/stats.d.ts +13 -0
- package/lib/webrtc/src/media/stats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +112 -11
- package/lib/webrtc/src/media/track.js +250 -19
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/media/trackConstraints.d.ts +80 -0
- package/lib/webrtc/src/media/trackConstraints.js +141 -0
- package/lib/webrtc/src/media/trackConstraints.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +0 -4
- package/lib/webrtc/src/negotiation/internalState.js +0 -11
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +20 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +29 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +12 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +133 -11
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +57 -5
- package/lib/webrtc/src/negotiationTransaction.js +134 -10
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.d.ts +6 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +14 -19
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js +5 -1
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +6 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +31 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +16 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js +25 -0
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +6 -13
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +106 -11
- package/lib/webrtc/src/peerConnection.js +370 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +2 -1
- package/lib/webrtc/src/polyfill/api.js +3 -3
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/dom.d.ts +21 -7
- package/lib/webrtc/src/polyfill/dom.js +15 -0
- package/lib/webrtc/src/polyfill/dom.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +8 -3
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.d.ts +1 -1
- package/lib/webrtc/src/polyfill/index.js +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.d.ts +5 -1
- package/lib/webrtc/src/polyfill/install.js +4 -2
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +28 -4
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/peerConnectionConfig.d.ts +6 -0
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js +15 -4
- package/lib/webrtc/src/polyfill/peerConnectionConfig.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.d.ts +4 -14
- package/lib/webrtc/src/polyfill/selectSettings.js +10 -106
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.d.ts +1 -2
- package/lib/webrtc/src/polyfill/sourceIo.js +6 -6
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +31 -18
- package/lib/webrtc/src/sctpManager.js +162 -38
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +107 -2
- package/lib/webrtc/src/sdp.js +223 -17
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +101 -10
- package/lib/webrtc/src/sdpManager.js +236 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +49 -3
- package/lib/webrtc/src/secureTransportManager.js +166 -12
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +87 -6
- package/lib/webrtc/src/transceiverManager.js +272 -51
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls-application-gate.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js +143 -0
- package/lib/webrtc/src/transport/dtls-application-gate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-attempt.js +79 -0
- package/lib/webrtc/src/transport/dtls-attempt.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-certificate.d.ts +24 -0
- package/lib/webrtc/src/transport/dtls-certificate.js +98 -0
- package/lib/webrtc/src/transport/dtls-certificate.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.d.ts +7 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js +66 -0
- package/lib/webrtc/src/transport/dtls-fingerprint.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js +123 -0
- package/lib/webrtc/src/transport/dtls-ice-transport.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js +95 -0
- package/lib/webrtc/src/transport/dtls-media-queue.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-readiness.js +173 -0
- package/lib/webrtc/src/transport/dtls-readiness.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js +146 -0
- package/lib/webrtc/src/transport/dtls-sped-handshake.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-srtp.js +133 -0
- package/lib/webrtc/src/transport/dtls-srtp.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-stats.d.ts +1 -0
- package/lib/webrtc/src/transport/dtls-stats.js +134 -0
- package/lib/webrtc/src/transport/dtls-stats.js.map +1 -0
- package/lib/webrtc/src/transport/dtls-types.d.ts +23 -0
- package/lib/webrtc/src/transport/dtls-types.js +11 -0
- package/lib/webrtc/src/transport/dtls-types.js.map +1 -0
- package/lib/webrtc/src/transport/dtls.d.ts +236 -47
- package/lib/webrtc/src/transport/dtls.js +1198 -441
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +95 -5
- package/lib/webrtc/src/transport/ice.js +323 -21
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +4 -2
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +149 -2
- package/lib/webrtc/src/transport/sctp.js +826 -128
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/transport/sped.d.ts +139 -0
- package/lib/webrtc/src/transport/sped.js +757 -0
- package/lib/webrtc/src/transport/sped.js.map +1 -0
- package/lib/webrtc/src/types/util.d.ts +6 -0
- package/lib/webrtc/src/types/util.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +34 -1
- package/lib/webrtc/src/utils.js +52 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/lib/webrtc/src/webidl.d.ts +15 -0
- package/lib/webrtc/src/webidl.js +34 -0
- package/lib/webrtc/src/webidl.js.map +1 -0
- package/package.json +8 -3
- package/lib/webrtc/src/polyfill/rtcSessionDescription.d.ts +0 -18
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js +0 -36
- package/lib/webrtc/src/polyfill/rtcSessionDescription.js.map +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Structural, DOM-independent counterparts of the DOM `MediaTrackSettings` /
|
|
4
|
+
* `MediaTrackConstraints` / `MediaTrackCapabilities` dictionaries, and the
|
|
5
|
+
* constraint evaluation shared by {@link MediaStreamTrack.applyConstraints}
|
|
6
|
+
* and the polyfill's `getUserMedia` device selection.
|
|
7
|
+
*
|
|
8
|
+
* werift is built without `lib.dom`, so these types do not reference the DOM
|
|
9
|
+
* dictionaries; they are written so that each one is assignable to its DOM
|
|
10
|
+
* counterpart (DOM `MediaStreamTrack.getSettings()` and friends).
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.weriftConstraintNames = void 0;
|
|
14
|
+
exports.stripUnsupportedConstraints = stripUnsupportedConstraints;
|
|
15
|
+
exports.findUnsupportedRequiredConstraint = findUnsupportedRequiredConstraint;
|
|
16
|
+
exports.constraintFitnessDistance = constraintFitnessDistance;
|
|
17
|
+
exports.findFailedRequiredConstraint = findFailedRequiredConstraint;
|
|
18
|
+
exports.weriftConstraintNames = [
|
|
19
|
+
"deviceId",
|
|
20
|
+
"groupId",
|
|
21
|
+
"mimeType",
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Keep only the constraints werift understands (Media Capture and Streams
|
|
25
|
+
* ignores unknown constraint names). Returns a fresh object.
|
|
26
|
+
*/
|
|
27
|
+
function stripUnsupportedConstraints(constraints) {
|
|
28
|
+
const next = { ...pickSupported(constraints) };
|
|
29
|
+
const advanced = constraints?.advanced;
|
|
30
|
+
if (Array.isArray(advanced)) {
|
|
31
|
+
next.advanced = advanced.map((entry) => pickSupported(entry));
|
|
32
|
+
}
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
function pickSupported(constraintSet) {
|
|
36
|
+
const next = {};
|
|
37
|
+
for (const name of exports.weriftConstraintNames) {
|
|
38
|
+
const value = constraintSet?.[name];
|
|
39
|
+
if (value != undefined) {
|
|
40
|
+
// 呼び出し元の後からの変更が保存済み制約に影響しないよう、入れ子まで複製する。
|
|
41
|
+
next[name] = structuredClone(value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return next;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The first constraint werift cannot honor (a name outside
|
|
48
|
+
* {@link weriftConstraintNames}, such as `width`) that is required
|
|
49
|
+
* (`exact`, `min` or `max`). `advanced` is not looked at.
|
|
50
|
+
*/
|
|
51
|
+
function findUnsupportedRequiredConstraint(constraints) {
|
|
52
|
+
for (const [name, value] of Object.entries(constraints ?? {})) {
|
|
53
|
+
if (name === "advanced" ||
|
|
54
|
+
exports.weriftConstraintNames.includes(name) ||
|
|
55
|
+
typeof value !== "object" ||
|
|
56
|
+
value == null ||
|
|
57
|
+
Array.isArray(value)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const { exact, min, max } = value;
|
|
61
|
+
if (exact != undefined || min != undefined || max != undefined) {
|
|
62
|
+
return name;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The fitness distance of Media Capture and Streams' SelectSettings: `0` for
|
|
69
|
+
* a perfect match, `Infinity` when a required (`exact`) constraint fails.
|
|
70
|
+
* A bare value is `ideal` in the basic set and `exact` in an advanced set
|
|
71
|
+
* (`bareMode`).
|
|
72
|
+
*/
|
|
73
|
+
function constraintFitnessDistance(settings, constraintSet, bareMode) {
|
|
74
|
+
let distance = 0;
|
|
75
|
+
for (const name of exports.weriftConstraintNames) {
|
|
76
|
+
const constraint = constraintSet[name];
|
|
77
|
+
if (constraint == undefined) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const next = constrainDomStringDistance(settings[name], constraint, bareMode);
|
|
81
|
+
if (next === Number.POSITIVE_INFINITY) {
|
|
82
|
+
return Number.POSITIVE_INFINITY;
|
|
83
|
+
}
|
|
84
|
+
distance += next;
|
|
85
|
+
}
|
|
86
|
+
return distance;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The first required constraint of the basic set no candidate satisfies
|
|
90
|
+
* (the `constraint` of the `OverconstrainedError`), or `undefined`.
|
|
91
|
+
*/
|
|
92
|
+
function findFailedRequiredConstraint(candidates, basic) {
|
|
93
|
+
for (const name of exports.weriftConstraintNames) {
|
|
94
|
+
const constraint = basic[name];
|
|
95
|
+
if (!isRequired(constraint)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const anyFinite = candidates.some((candidate) => constraintFitnessDistance(candidate, { [name]: constraint }, "ideal") <
|
|
99
|
+
Number.POSITIVE_INFINITY);
|
|
100
|
+
if (!anyFinite) {
|
|
101
|
+
return name;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
function constrainDomStringDistance(actual, constraint, bareMode) {
|
|
107
|
+
const { exact, ideal } = normalizeConstrainDomString(constraint, bareMode);
|
|
108
|
+
if (exact && !matchesDomString(actual, exact)) {
|
|
109
|
+
return Number.POSITIVE_INFINITY;
|
|
110
|
+
}
|
|
111
|
+
if (!ideal) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
return matchesDomString(actual, ideal) ? 0 : 1;
|
|
115
|
+
}
|
|
116
|
+
function normalizeConstrainDomString(constraint, bareMode) {
|
|
117
|
+
if (typeof constraint === "string" || Array.isArray(constraint)) {
|
|
118
|
+
const values = toStringList(constraint);
|
|
119
|
+
return bareMode === "exact" ? { exact: values } : { ideal: values };
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
exact: constraint.exact ? toStringList(constraint.exact) : undefined,
|
|
123
|
+
ideal: constraint.ideal ? toStringList(constraint.ideal) : undefined,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function toStringList(value) {
|
|
127
|
+
return Array.isArray(value) ? value : [value];
|
|
128
|
+
}
|
|
129
|
+
function matchesDomString(actual, expected) {
|
|
130
|
+
return actual != undefined && expected.includes(actual);
|
|
131
|
+
}
|
|
132
|
+
function isRequired(constraint) {
|
|
133
|
+
if (constraint == undefined) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (typeof constraint === "string" || Array.isArray(constraint)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return constraint.exact != undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=trackConstraints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackConstraints.js","sourceRoot":"","sources":["../../../../src/media/trackConstraints.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAmEH,kEASC;AAqBD,8EAmBC;AAQD,8DAsBC;AAMD,oEAmBC;AAvHY,QAAA,qBAAqB,GAAoC;IACpE,UAAU;IACV,SAAS;IACT,UAAU;CACX,CAAC;AAOF;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,WAAmD;IAEnD,MAAM,IAAI,GAAgC,EAAE,GAAG,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;IAC5E,MAAM,QAAQ,GAAG,WAAW,EAAE,QAAQ,CAAC;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA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AC;IACf,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,IAAI,SAAS,CAAC;AACvC,CAAC","sourcesContent":["/**\n * Structural, DOM-independent counterparts of the DOM `MediaTrackSettings` /\n * `MediaTrackConstraints` / `MediaTrackCapabilities` dictionaries, and the\n * constraint evaluation shared by {@link MediaStreamTrack.applyConstraints}\n * and the polyfill's `getUserMedia` device selection.\n *\n * werift is built without `lib.dom`, so these types do not reference the DOM\n * dictionaries; they are written so that each one is assignable to its DOM\n * counterpart (DOM `MediaStreamTrack.getSettings()` and friends).\n */\n\n/** `ConstrainDOMString` of Media Capture and Streams. */\nexport type WeriftConstrainDOMString =\n | string\n | string[]\n | {\n exact?: string | string[];\n ideal?: string | string[];\n };\n\n/**\n * The constraints werift evaluates. `mimeType` is a werift extension that\n * selects a polyfill media register by the media it produces.\n */\nexport interface WeriftMediaTrackConstraintSet {\n deviceId?: WeriftConstrainDOMString;\n groupId?: WeriftConstrainDOMString;\n /** werift extension: the MIME type the source produces. */\n mimeType?: WeriftConstrainDOMString;\n}\n\nexport interface WeriftMediaTrackConstraints\n extends WeriftMediaTrackConstraintSet {\n advanced?: WeriftMediaTrackConstraintSet[];\n /**\n * Constraints werift cannot honor (`width`, `frameRate`, ...), as in the DOM\n * `MediaTrackConstraints`. A required one rejects `applyConstraints()`\n * with `OverconstrainedError`; an optional one is kept.\n */\n [name: string]: unknown;\n}\n\n/** Assignable to the DOM `MediaTrackSettings`. */\nexport interface WeriftMediaTrackSettings {\n deviceId?: string;\n groupId?: string;\n /** werift extension: the MIME type the source produces. */\n mimeType?: string;\n sampleRate?: number;\n channelCount?: number;\n}\n\n/** Assignable to the DOM `MediaTrackCapabilities`. */\nexport interface WeriftMediaTrackCapabilities {\n deviceId?: string;\n groupId?: string;\n}\n\n/** The constraint names werift understands; the others are ignored. */\nexport type WeriftConstraintName = keyof WeriftMediaTrackConstraintSet;\n\nexport const weriftConstraintNames: readonly WeriftConstraintName[] = [\n \"deviceId\",\n \"groupId\",\n \"mimeType\",\n];\n\n/** The values a constraint set is evaluated against. */\nexport type WeriftConstrainableSettings = Partial<\n Record<WeriftConstraintName, string>\n>;\n\n/**\n * Keep only the constraints werift understands (Media Capture and Streams\n * ignores unknown constraint names). Returns a fresh object.\n */\nexport function stripUnsupportedConstraints(\n constraints: { [key: string]: unknown } | undefined,\n): WeriftMediaTrackConstraints {\n const next: WeriftMediaTrackConstraints = { ...pickSupported(constraints) };\n const advanced = constraints?.advanced;\n if (Array.isArray(advanced)) {\n next.advanced = advanced.map((entry) => pickSupported(entry));\n }\n return next;\n}\n\nfunction pickSupported(\n constraintSet: { [key: string]: unknown } | undefined,\n): WeriftMediaTrackConstraintSet {\n const next: WeriftMediaTrackConstraintSet = {};\n for (const name of weriftConstraintNames) {\n const value = constraintSet?.[name];\n if (value != undefined) {\n // 呼び出し元の後からの変更が保存済み制約に影響しないよう、入れ子まで複製する。\n next[name] = structuredClone(value) as WeriftConstrainDOMString;\n }\n }\n return next;\n}\n\n/**\n * The first constraint werift cannot honor (a name outside\n * {@link weriftConstraintNames}, such as `width`) that is required\n * (`exact`, `min` or `max`). `advanced` is not looked at.\n */\nexport function findUnsupportedRequiredConstraint(\n constraints: { [key: string]: unknown } | undefined,\n): string | undefined {\n for (const [name, value] of Object.entries(constraints ?? {})) {\n if (\n name === \"advanced\" ||\n (weriftConstraintNames as readonly string[]).includes(name) ||\n typeof value !== \"object\" ||\n value == null ||\n Array.isArray(value)\n ) {\n continue;\n }\n const { exact, min, max } = value as Record<string, unknown>;\n if (exact != undefined || min != undefined || max != undefined) {\n return name;\n }\n }\n return undefined;\n}\n\n/**\n * The fitness distance of Media Capture and Streams' SelectSettings: `0` for\n * a perfect match, `Infinity` when a required (`exact`) constraint fails.\n * A bare value is `ideal` in the basic set and `exact` in an advanced set\n * (`bareMode`).\n */\nexport function constraintFitnessDistance(\n settings: WeriftConstrainableSettings,\n constraintSet: WeriftMediaTrackConstraintSet,\n bareMode: \"ideal\" | \"exact\",\n): number {\n let distance = 0;\n for (const name of weriftConstraintNames) {\n const constraint = constraintSet[name];\n if (constraint == undefined) {\n continue;\n }\n const next = constrainDomStringDistance(\n settings[name],\n constraint,\n bareMode,\n );\n if (next === Number.POSITIVE_INFINITY) {\n return Number.POSITIVE_INFINITY;\n }\n distance += next;\n }\n return distance;\n}\n\n/**\n * The first required constraint of the basic set no candidate satisfies\n * (the `constraint` of the `OverconstrainedError`), or `undefined`.\n */\nexport function findFailedRequiredConstraint(\n candidates: readonly WeriftConstrainableSettings[],\n basic: WeriftMediaTrackConstraintSet,\n): WeriftConstraintName | undefined {\n for (const name of weriftConstraintNames) {\n const constraint = basic[name];\n if (!isRequired(constraint)) {\n continue;\n }\n const anyFinite = candidates.some(\n (candidate) =>\n constraintFitnessDistance(candidate, { [name]: constraint }, \"ideal\") <\n Number.POSITIVE_INFINITY,\n );\n if (!anyFinite) {\n return name;\n }\n }\n return undefined;\n}\n\nfunction constrainDomStringDistance(\n actual: string | undefined,\n constraint: WeriftConstrainDOMString,\n bareMode: \"ideal\" | \"exact\",\n): number {\n const { exact, ideal } = normalizeConstrainDomString(constraint, bareMode);\n if (exact && !matchesDomString(actual, exact)) {\n return Number.POSITIVE_INFINITY;\n }\n if (!ideal) {\n return 0;\n }\n return matchesDomString(actual, ideal) ? 0 : 1;\n}\n\nfunction normalizeConstrainDomString(\n constraint: WeriftConstrainDOMString,\n bareMode: \"ideal\" | \"exact\",\n): { exact?: string[]; ideal?: string[] } {\n if (typeof constraint === \"string\" || Array.isArray(constraint)) {\n const values = toStringList(constraint);\n return bareMode === \"exact\" ? { exact: values } : { ideal: values };\n }\n return {\n exact: constraint.exact ? toStringList(constraint.exact) : undefined,\n ideal: constraint.ideal ? toStringList(constraint.ideal) : undefined,\n };\n}\n\nfunction toStringList(value: string | string[]): string[] {\n return Array.isArray(value) ? value : [value];\n}\n\nfunction matchesDomString(actual: string | undefined, expected: string[]) {\n return actual != undefined && expected.includes(actual);\n}\n\nfunction isRequired(constraint: WeriftConstrainDOMString | undefined) {\n if (constraint == undefined) {\n return false;\n }\n if (typeof constraint === \"string\" || Array.isArray(constraint)) {\n return false;\n }\n return constraint.exact != undefined;\n}\n"]}
|
|
@@ -28,7 +28,3 @@ export type TransceiversNegotiationState = {
|
|
|
28
28
|
* by MID and RID: two m-lines may reuse the same RID names.
|
|
29
29
|
*/
|
|
30
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;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ridRouteKey = void 0;
|
|
4
|
-
exports.getApplicationStopRevision = getApplicationStopRevision;
|
|
5
|
-
exports.noteApplicationStop = noteApplicationStop;
|
|
6
4
|
/**
|
|
7
5
|
* RIDs are scoped to their m-line (RFC 8851), so simulcast routes are keyed
|
|
8
6
|
* by MID and RID: two m-lines may reuse the same RID names.
|
|
9
7
|
*/
|
|
10
8
|
const ridRouteKey = (mid, rid) => `${mid}\u0000${rid}`;
|
|
11
9
|
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
10
|
//# sourceMappingURL=internalState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalState.js","sourceRoot":"","sources":["../../../../src/negotiation/internalState.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"internalState.js","sourceRoot":"","sources":["../../../../src/negotiation/internalState.ts"],"names":[],"mappings":";;;AAkCA;;;GAGG;AACI,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,SAAS,GAAG,EAAE,CAAC;AAAjE,QAAA,WAAW,eAAsD","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"]}
|
|
@@ -11,6 +11,21 @@ import type { BundleTopology } from "./bundleTopology";
|
|
|
11
11
|
* string. Both forms route the same way; conflicting values are rejected.
|
|
12
12
|
*/
|
|
13
13
|
export declare function normalizeCandidateUfrag(message: RTCIceCandidate | RTCIceCandidateInit | null): RTCIceCandidate | RTCIceCandidateInit | null;
|
|
14
|
+
/**
|
|
15
|
+
* Pion (`ICECandidate.ToJSON()`) and SFUs built on it can send a candidate
|
|
16
|
+
* without a recorded MID as `sdpMid: ""` with a numeric `sdpMLineIndex`. An empty
|
|
17
|
+
* MID names no m-line (an RFC 5888 identification-tag is a non-empty token),
|
|
18
|
+
* so werift resolves such a candidate by its `sdpMLineIndex`, as libwebrtc and
|
|
19
|
+
* Firefox do for an empty MID. The W3C steps reject it with OperationError (a
|
|
20
|
+
* non-null `sdpMid` that matches no m-line); werift keeps the
|
|
21
|
+
* interoperable behavior and no upstream WPT subtest covers it (add a strict
|
|
22
|
+
* wrapper in `tools/wpt-runner` if one appears).
|
|
23
|
+
*
|
|
24
|
+
* Only `""` with a numeric index is normalized: `""` without an index stays
|
|
25
|
+
* an error, and a non-empty MID (even whitespace) is looked up as given. The
|
|
26
|
+
* caller's object is not modified.
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeEmptyCandidateMid(message: RTCIceCandidate | RTCIceCandidateInit | null): RTCIceCandidate | RTCIceCandidateInit | null;
|
|
14
29
|
/**
|
|
15
30
|
* Trickle ICE for remote candidates: routes each candidate or
|
|
16
31
|
* end-of-candidates to the ICE generation (current or pending) of the m-line
|
|
@@ -20,7 +35,11 @@ export declare function normalizeCandidateUfrag(message: RTCIceCandidate | RTCIc
|
|
|
20
35
|
*
|
|
21
36
|
* - The generation is chosen by the ufrag of the m-line the candidate targets
|
|
22
37
|
* (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can
|
|
23
|
-
* keep the current ufrag while another moves to a new one.
|
|
38
|
+
* keep the current ufrag while another moves to a new one. An empty
|
|
39
|
+
* `sdpMid` with a numeric `sdpMLineIndex` (Pion) targets the m-line of the
|
|
40
|
+
* index; `addIceCandidate()` normalizes it with
|
|
41
|
+
* {@link normalizeEmptyCandidateMid} before queueing, so this choice and
|
|
42
|
+
* the m-line `SecureTransportManager` resolves always agree.
|
|
24
43
|
* - During a remote re-offer, a candidate for an m-line whose ufrag is
|
|
25
44
|
* unchanged belongs to both the pending proposal and the live generation:
|
|
26
45
|
* it is recorded in both SDPs and handed to the live checklist once, and a
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoteCandidates = void 0;
|
|
4
4
|
exports.normalizeCandidateUfrag = normalizeCandidateUfrag;
|
|
5
|
+
exports.normalizeEmptyCandidateMid = normalizeEmptyCandidateMid;
|
|
5
6
|
const errors_1 = require("../errors");
|
|
6
7
|
/**
|
|
7
8
|
* The ICE generation of a candidate is its ufrag, given either as the
|
|
@@ -21,6 +22,29 @@ function normalizeCandidateUfrag(message) {
|
|
|
21
22
|
const init = "toJSON" in message ? message.toJSON() : { ...message };
|
|
22
23
|
return { ...init, usernameFragment: fromString };
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Pion (`ICECandidate.ToJSON()`) and SFUs built on it can send a candidate
|
|
27
|
+
* without a recorded MID as `sdpMid: ""` with a numeric `sdpMLineIndex`. An empty
|
|
28
|
+
* MID names no m-line (an RFC 5888 identification-tag is a non-empty token),
|
|
29
|
+
* so werift resolves such a candidate by its `sdpMLineIndex`, as libwebrtc and
|
|
30
|
+
* Firefox do for an empty MID. The W3C steps reject it with OperationError (a
|
|
31
|
+
* non-null `sdpMid` that matches no m-line); werift keeps the
|
|
32
|
+
* interoperable behavior and no upstream WPT subtest covers it (add a strict
|
|
33
|
+
* wrapper in `tools/wpt-runner` if one appears).
|
|
34
|
+
*
|
|
35
|
+
* Only `""` with a numeric index is normalized: `""` without an index stays
|
|
36
|
+
* an error, and a non-empty MID (even whitespace) is looked up as given. The
|
|
37
|
+
* caller's object is not modified.
|
|
38
|
+
*/
|
|
39
|
+
function normalizeEmptyCandidateMid(message) {
|
|
40
|
+
if (!message ||
|
|
41
|
+
message.sdpMid !== "" ||
|
|
42
|
+
typeof message.sdpMLineIndex !== "number") {
|
|
43
|
+
return message;
|
|
44
|
+
}
|
|
45
|
+
const init = "toJSON" in message ? message.toJSON() : { ...message };
|
|
46
|
+
return { ...init, sdpMid: null };
|
|
47
|
+
}
|
|
24
48
|
/**
|
|
25
49
|
* Trickle ICE for remote candidates: routes each candidate or
|
|
26
50
|
* end-of-candidates to the ICE generation (current or pending) of the m-line
|
|
@@ -30,7 +54,11 @@ function normalizeCandidateUfrag(message) {
|
|
|
30
54
|
*
|
|
31
55
|
* - The generation is chosen by the ufrag of the m-line the candidate targets
|
|
32
56
|
* (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can
|
|
33
|
-
* keep the current ufrag while another moves to a new one.
|
|
57
|
+
* keep the current ufrag while another moves to a new one. An empty
|
|
58
|
+
* `sdpMid` with a numeric `sdpMLineIndex` (Pion) targets the m-line of the
|
|
59
|
+
* index; `addIceCandidate()` normalizes it with
|
|
60
|
+
* {@link normalizeEmptyCandidateMid} before queueing, so this choice and
|
|
61
|
+
* the m-line `SecureTransportManager` resolves always agree.
|
|
34
62
|
* - During a remote re-offer, a candidate for an m-line whose ufrag is
|
|
35
63
|
* unchanged belongs to both the pending proposal and the live generation:
|
|
36
64
|
* it is recorded in both SDPs and handed to the live checklist once, and a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteCandidates.js","sourceRoot":"","sources":["../../../../src/negotiation/remoteCandidates.ts"],"names":[],"mappings":";;;AAmBA,0DAeC;AAlCD,sCAAqD;AAcrD;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,OAAqD;IAErD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,IAAI,SAAS,CAAC;IAC3D,I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E,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YAAE,MAAM,UAAU,CAAC;IACnC,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAClE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF;AAhWD,4CAgWC","sourcesContent":["import { createWebRtcDomException } from \"../errors\";\nimport type { NegotiationTransaction } from \"../negotiationTransaction\";\nimport type { SessionDescription } from \"../sdp\";\nimport type { SDPManager } from \"../sdpManager\";\nimport type { SecureTransportManager } from \"../secureTransportManager\";\nimport type { RTCDtlsTransport } from \"../transport/dtls\";\nimport type {\n RTCIceCandidate,\n RTCIceCandidateInit,\n RTCIceTransport,\n} from \"../transport/ice\";\nimport type { RTCSignalingState } from \"../types/domain\";\nimport type { BundleTopology } from \"./bundleTopology\";\n\n/**\n * The ICE generation of a candidate is its ufrag, given either as the\n * `usernameFragment` property or as the `ufrag` token of the candidate\n * string. Both forms route the same way; conflicting values are rejected.\n */\nexport function normalizeCandidateUfrag(\n message: RTCIceCandidate | RTCIceCandidateInit | null,\n): RTCIceCandidate | RTCIceCandidateInit | null {\n if (!message) return message;\n const fromString = message.candidate?.match(/\\bufrag\\s+(\\S+)/)?.[1];\n const fromProperty = message.usernameFragment ?? undefined;\n if (fromString && fromProperty && fromString !== fromProperty) {\n throw createWebRtcDomException(\n \"OperationError\",\n \"Candidate ufrag does not match usernameFragment\",\n );\n }\n if (!fromString || fromProperty) return message;\n const init = \"toJSON\" in message ? message.toJSON() : { ...message };\n return { ...init, usernameFragment: fromString };\n}\n\n/**\n * Trickle ICE for remote candidates: routes each candidate or\n * end-of-candidates to the ICE generation (current or pending) of the m-line\n * it targets, records it in that SDP and hands it to the live, pending-only or\n * provisional checklist. Candidates added before any remote description wait\n * in a queue (werift convenience; the WPT runner keeps the strict rejection).\n *\n * - The generation is chosen by the ufrag of the m-line the candidate targets\n * (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can\n * keep the current ufrag while another moves to a new one.\n * - During a remote re-offer, a candidate for an m-line whose ufrag is\n * unchanged belongs to both the pending proposal and the live generation:\n * it is recorded in both SDPs and handed to the live checklist once, and a\n * rollback keeps it.\n * - End-of-candidates ends one generation (RFC 8838): every m-line sharing\n * its transport and ufrag is marked complete, in the current or pending SDP,\n * and a later candidate of it reaches neither an SDP nor a checklist. A\n * pending restart ufrag on the same transport stays open; an m-line a\n * proposal splits off stays open even with the same credentials (RFC 8839\n * section 5.4).\n * - Queued candidates are checked against an incoming remote description\n * before any state change; one it cannot place rejects\n * setRemoteDescription and stays queued for a retry.\n * - Duplicates within a generation are idempotent; a callback of a retired\n * generation cannot reach its replacement.\n */\nexport class RemoteCandidates {\n private readonly sdp: SDPManager;\n private readonly secure: SecureTransportManager;\n private readonly negotiation: NegotiationTransaction;\n private readonly topology: BundleTopology;\n private readonly host: {\n signalingState: () => RTCSignalingState;\n hasRemoteDescription: () => boolean;\n };\n\n /** Candidates added before a remote description was applied. */\n readonly queued: Array<RTCIceCandidate | RTCIceCandidateInit | null> = [];\n\n constructor(\n sdp: SDPManager,\n secure: SecureTransportManager,\n negotiation: NegotiationTransaction,\n topology: BundleTopology,\n host: {\n signalingState: () => RTCSignalingState;\n hasRemoteDescription: () => boolean;\n },\n ) {\n this.sdp = sdp;\n this.secure = secure;\n this.negotiation = negotiation;\n this.topology = topology;\n this.host = host;\n }\n\n /** Route a trickled candidate or end-of-candidates to its ICE generation. */\n async apply(candidateMessage: RTCIceCandidate | RTCIceCandidateInit | null) {\n const current = this.sdp.currentRemoteDescription;\n const pending = this.sdp.pendingRemoteDescription;\n const ufrag = candidateMessage?.usernameFragment;\n // The generation is decided by the m-line the candidate targets: with a\n // partial BUNDLE split one m-line may keep the current ufrag while another\n // moves to a new one within the same pending description.\n const sdpMid = candidateMessage?.sdpMid;\n const sdpMLineIndex = candidateMessage?.sdpMLineIndex;\n const targetMedia = (description: SessionDescription) =>\n typeof sdpMid === \"string\"\n ? description.media.filter((media) => media.rtp.muxId === sdpMid)\n : typeof sdpMLineIndex === \"number\"\n ? description.media.slice(sdpMLineIndex, sdpMLineIndex + 1)\n : description.media;\n const matchesUfrag = (description: SessionDescription) =>\n targetMedia(description).some(\n (media) => media.iceParams?.usernameFragment === ufrag,\n );\n const sdp =\n ufrag &&\n current &&\n matchesUfrag(current) &&\n (!pending || !matchesUfrag(pending))\n ? current\n : (pending ?? current);\n if (!sdp) {\n return;\n }\n // A new remote generation is only a proposal during a re-offer. Keep its\n // trickle data in the pending SDP until the final answer activates it.\n const stageOnly =\n sdp === pending &&\n !!current &&\n (pending?.type === \"offer\" || pending?.type === \"pranswer\");\n const appliedCandidate = await this.secure.addIceCandidate(\n sdp,\n candidateMessage,\n !stageOnly,\n );\n const remoteDescription = sdp;\n if (!remoteDescription || !appliedCandidate) {\n return;\n }\n if (stageOnly) {\n const targets = new Set(\n appliedCandidate.mediaIndices\n .map((index) =>\n this.negotiation.transportByMid.get(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n ),\n )\n .filter(\n (transport): transport is RTCDtlsTransport =>\n !!transport &&\n this.negotiation.isPendingOnlyTransport(\n transport.iceTransport.id,\n ),\n ),\n );\n for (const transport of targets) {\n transport.iceTransport.deliverRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n if (current) {\n await this.deliverSameGenerationCandidate(\n remoteDescription,\n current,\n appliedCandidate,\n );\n }\n if (\n this.host.signalingState() === \"have-local-pranswer\" ||\n this.host.signalingState() === \"have-remote-pranswer\"\n ) {\n const provisional = new Set(\n appliedCandidate.mediaIndices\n .map(\n (index) =>\n this.topology.currentTransportForMid(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n )?.iceTransport,\n )\n .filter(\n (transport): transport is RTCIceTransport =>\n !!transport?.hasStagedRestart &&\n !this.negotiation.isPendingOnlyTransport(transport.id),\n ),\n );\n for (const transport of provisional) {\n transport.deliverProvisionalRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n }\n }\n\n if (appliedCandidate.kind === \"end-of-candidates\") {\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (media) {\n media.iceCandidatesComplete = true;\n }\n }\n // A pending SDP becomes current at the answer, so it is aligned too.\n this.completeSharedTransportMedia(\n remoteDescription,\n appliedCandidate.mediaIndices,\n );\n return;\n }\n\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (!media) {\n continue;\n }\n media.iceCandidates.push(appliedCandidate.candidate);\n }\n }\n\n /**\n * A re-offer or pranswer that keeps the current transports may still carry\n * new candidates or end-of-candidates for an m-line whose ufrag is\n * unchanged. They belong to the live generation too, so they reach the live\n * checklist and the current SDP (once, and not after its end-of-candidates),\n * exactly like trickled ones. A pending-only transport receives its own.\n */\n async deliverSameGenerationDescription(proposal: SessionDescription) {\n const current = this.sdp.currentRemoteDescription;\n if (!current) return;\n const shared = [...proposal.media.entries()].filter(([, media]) => {\n if (media.port === 0) return false;\n const prepared = this.negotiation.transportByMid.get(\n media.rtp.muxId ?? \"\",\n );\n return !(\n prepared &&\n this.negotiation.isPendingOnlyTransport(prepared.iceTransport.id)\n );\n });\n // Candidates first (a non-tag BUNDLE member carries none of its own),\n // then end-of-candidates from any m-line, since it ends the shared\n // generation for the whole group.\n for (const [index, media] of shared) {\n if (this.topology.isBundledNonTag(proposal, media.rtp.muxId)) continue;\n for (const candidate of media.iceCandidates) {\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"candidate\",\n candidate,\n mediaIndices: [index],\n });\n }\n }\n for (const [index, media] of shared) {\n if (!media.iceCandidatesComplete) continue;\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"end-of-candidates\",\n mediaIndices: [index],\n });\n }\n }\n\n /**\n * End-of-candidates ends an ICE generation on its transport, not one\n * m-line: every m-line of `sdp` on the same finished transport with the\n * same ufrag as `completed` (the rest of its BUNDLE group) is marked\n * complete, so the SDP never promises more candidates to it.\n */\n completeSharedTransportMedia(sdp: SessionDescription, completed: number[]) {\n const current = this.sdp.currentRemoteDescription;\n if (sdp === current) {\n // The current description is laid out on the committed transports:\n // only the live generation that ended on a transport counts (a pending\n // restart ufrag on the same transport is still open).\n const transportFor = (mid: string) =>\n this.topology.liveTransportForMid(mid)?.iceTransport;\n const ended = completed.flatMap((index) => {\n const media = sdp.media[index];\n const transport = transportFor(media?.rtp.muxId ?? \"\");\n const ufrag = media?.iceParams?.usernameFragment;\n return transport?.connection.remoteCandidatesEnd &&\n transport.connection.remoteUsername === ufrag\n ? [{ transport, ufrag }]\n : [];\n });\n for (const media of sdp.media) {\n const transport = transportFor(media.rtp.muxId ?? \"\");\n if (\n ended.some(\n (generation) =>\n generation.transport === transport &&\n generation.ufrag === media.iceParams?.usernameFragment,\n )\n ) {\n media.iceCandidatesComplete = true;\n }\n }\n return;\n }\n // A pending proposal: a generation is identified by the proposal's own\n // BUNDLE ownership (the group tag, or the m-line itself) and ufrag, so an\n // m-line the proposal splits off stays open even with the same\n // credentials (RFC 8839 section 5.4), before any transport is prepared.\n const ownerIn = (description: SessionDescription, mid: string) =>\n this.topology.bundleTagOf(description, mid) ?? mid;\n const keyOf = (media: SessionDescription[\"media\"][number]) =>\n `${ownerIn(sdp, media.rtp.muxId ?? \"\")}\\u0000${media.iceParams?.usernameFragment ?? \"\"}`;\n const ended = new Set<string>();\n for (const index of completed) {\n const media = sdp.media[index];\n const mid = media?.rtp.muxId;\n const ufrag = media?.iceParams?.usernameFragment;\n if (!media || !mid || !ufrag) continue;\n // Its end-of-candidates arrived for this proposal, or the proposal\n // repeats a live generation that already ended, on an m-line it keeps\n // with the same owner.\n const live = this.topology.liveTransportForMid(mid)?.iceTransport;\n const repeatsEndedLive =\n !!current &&\n ownerIn(current, mid) === ownerIn(sdp, mid) &&\n !!live?.connection.remoteCandidatesEnd &&\n live.connection.remoteUsername === ufrag;\n if (media.iceCandidatesComplete || repeatsEndedLive) {\n ended.add(keyOf(media));\n }\n }\n for (const media of sdp.media) {\n if (ended.has(keyOf(media))) media.iceCandidatesComplete = true;\n }\n }\n\n /**\n * A candidate trickled for a pending re-offer whose m-line keeps the current\n * ufrag belongs to the live ICE generation as well. Besides the pending SDP,\n * it is recorded in the current SDP and handed to the live checklist once,\n * so the committed session can use it while the proposal is pending.\n */\n private async deliverSameGenerationCandidate(\n pending: SessionDescription,\n current: SessionDescription,\n applied: NonNullable<\n Awaited<ReturnType<SecureTransportManager[\"addIceCandidate\"]>>\n >,\n ) {\n for (const index of applied.mediaIndices) {\n const mid = pending.media[index]?.rtp.muxId;\n const ufrag = pending.media[index]?.iceParams?.usernameFragment;\n const currentMedia = current.media.find(\n (media) => media.rtp.muxId === mid,\n );\n const iceTransport = mid\n ? this.topology.currentTransportForMid(mid)?.iceTransport\n : undefined;\n if (\n !ufrag ||\n !currentMedia ||\n currentMedia.iceParams?.usernameFragment !== ufrag ||\n !iceTransport ||\n this.negotiation.isPendingOnlyTransport(iceTransport.id) ||\n iceTransport.connection.remoteUsername !== ufrag ||\n // RFC 8838: a generation that signalled end-of-candidates is complete,\n // whichever BUNDLE m-line of the shared transport carried it.\n currentMedia.iceCandidatesComplete ||\n iceTransport.connection.remoteCandidatesEnd\n ) {\n continue;\n }\n if (applied.kind === \"end-of-candidates\") {\n currentMedia.iceCandidatesComplete = true;\n iceTransport.deliverRemoteCandidate(undefined);\n this.completeSharedTransportMedia(current, [\n current.media.indexOf(currentMedia),\n ]);\n continue;\n }\n const text = applied.candidate.toJSON().candidate;\n if (\n currentMedia.iceCandidates.some(\n (existing) => existing.toJSON().candidate === text,\n )\n ) {\n continue;\n }\n currentMedia.iceCandidates.push(applied.candidate);\n iceTransport.deliverRemoteCandidate(applied.candidate);\n }\n }\n\n /**\n * Candidates queued before any remote description are checked against the\n * description during validation, so a bad one rejects setRemoteDescription\n * before any state changes and before any application event fires. The rejected\n * candidates leave the queue: their addIceCandidate already resolved, and a\n * retry of the same description must not fail on them again.\n */\n async validateQueued(sdp: SessionDescription) {\n let firstError: unknown;\n for (const candidate of [...this.queued]) {\n try {\n await this.secure.addIceCandidate(sdp, candidate ?? null, false);\n } catch (error) {\n firstError ??= error;\n this.queued.splice(this.queued.indexOf(candidate), 1);\n }\n }\n if (firstError) throw firstError;\n }\n\n /** Apply the queued candidates once a remote description exists. */\n async flushQueued() {\n while (this.queued.length > 0 && this.host.hasRemoteDescription()) {\n const candidate = this.queued.shift();\n await this.apply(candidate ?? null);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remoteCandidates.js","sourceRoot":"","sources":["../../../../src/negotiation/remoteCandidates.ts"],"names":[],"mappings":";;;AAmBA,0DAeC;AAgBD,gEAYC;AA9DD,sCAAqD;AAcrD;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,OAAqD;IAErD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,IAAI,SAAS,CAAC;IAC3D,IAAI,UAAU,IAAI,YAAY,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAC9D,MAAM,IAAA,iCAAwB,EAC5B,gBAAgB,EAChB,iDAAiD,CAClD,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,UAAU,IAAI,YAAY;QAAE,OAAO,OAAO,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,IA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AC,CAAC;YACnE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,UAAU,KAAV,UAAU,GAAK,KAAK,EAAC;gBACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QACD,IAAI,UAAU;YAAE,MAAM,UAAU,CAAC;IACnC,CAAC;IAED,oEAAoE;IACpE,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAClE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF;AAhWD,4CAgWC","sourcesContent":["import { createWebRtcDomException } from \"../errors\";\nimport type { NegotiationTransaction } from \"../negotiationTransaction\";\nimport type { SessionDescription } from \"../sdp\";\nimport type { SDPManager } from \"../sdpManager\";\nimport type { SecureTransportManager } from \"../secureTransportManager\";\nimport type { RTCDtlsTransport } from \"../transport/dtls\";\nimport type {\n RTCIceCandidate,\n RTCIceCandidateInit,\n RTCIceTransport,\n} from \"../transport/ice\";\nimport type { RTCSignalingState } from \"../types/domain\";\nimport type { BundleTopology } from \"./bundleTopology\";\n\n/**\n * The ICE generation of a candidate is its ufrag, given either as the\n * `usernameFragment` property or as the `ufrag` token of the candidate\n * string. Both forms route the same way; conflicting values are rejected.\n */\nexport function normalizeCandidateUfrag(\n message: RTCIceCandidate | RTCIceCandidateInit | null,\n): RTCIceCandidate | RTCIceCandidateInit | null {\n if (!message) return message;\n const fromString = message.candidate?.match(/\\bufrag\\s+(\\S+)/)?.[1];\n const fromProperty = message.usernameFragment ?? undefined;\n if (fromString && fromProperty && fromString !== fromProperty) {\n throw createWebRtcDomException(\n \"OperationError\",\n \"Candidate ufrag does not match usernameFragment\",\n );\n }\n if (!fromString || fromProperty) return message;\n const init = \"toJSON\" in message ? message.toJSON() : { ...message };\n return { ...init, usernameFragment: fromString };\n}\n\n/**\n * Pion (`ICECandidate.ToJSON()`) and SFUs built on it can send a candidate\n * without a recorded MID as `sdpMid: \"\"` with a numeric `sdpMLineIndex`. An empty\n * MID names no m-line (an RFC 5888 identification-tag is a non-empty token),\n * so werift resolves such a candidate by its `sdpMLineIndex`, as libwebrtc and\n * Firefox do for an empty MID. The W3C steps reject it with OperationError (a\n * non-null `sdpMid` that matches no m-line); werift keeps the\n * interoperable behavior and no upstream WPT subtest covers it (add a strict\n * wrapper in `tools/wpt-runner` if one appears).\n *\n * Only `\"\"` with a numeric index is normalized: `\"\"` without an index stays\n * an error, and a non-empty MID (even whitespace) is looked up as given. The\n * caller's object is not modified.\n */\nexport function normalizeEmptyCandidateMid(\n message: RTCIceCandidate | RTCIceCandidateInit | null,\n): RTCIceCandidate | RTCIceCandidateInit | null {\n if (\n !message ||\n message.sdpMid !== \"\" ||\n typeof message.sdpMLineIndex !== \"number\"\n ) {\n return message;\n }\n const init = \"toJSON\" in message ? message.toJSON() : { ...message };\n return { ...init, sdpMid: null };\n}\n\n/**\n * Trickle ICE for remote candidates: routes each candidate or\n * end-of-candidates to the ICE generation (current or pending) of the m-line\n * it targets, records it in that SDP and hands it to the live, pending-only or\n * provisional checklist. Candidates added before any remote description wait\n * in a queue (werift convenience; the WPT runner keeps the strict rejection).\n *\n * - The generation is chosen by the ufrag of the m-line the candidate targets\n * (`sdpMid`, else `sdpMLineIndex`): in a partial BUNDLE split one m-line can\n * keep the current ufrag while another moves to a new one. An empty\n * `sdpMid` with a numeric `sdpMLineIndex` (Pion) targets the m-line of the\n * index; `addIceCandidate()` normalizes it with\n * {@link normalizeEmptyCandidateMid} before queueing, so this choice and\n * the m-line `SecureTransportManager` resolves always agree.\n * - During a remote re-offer, a candidate for an m-line whose ufrag is\n * unchanged belongs to both the pending proposal and the live generation:\n * it is recorded in both SDPs and handed to the live checklist once, and a\n * rollback keeps it.\n * - End-of-candidates ends one generation (RFC 8838): every m-line sharing\n * its transport and ufrag is marked complete, in the current or pending SDP,\n * and a later candidate of it reaches neither an SDP nor a checklist. A\n * pending restart ufrag on the same transport stays open; an m-line a\n * proposal splits off stays open even with the same credentials (RFC 8839\n * section 5.4).\n * - Queued candidates are checked against an incoming remote description\n * before any state change; one it cannot place rejects\n * setRemoteDescription and stays queued for a retry.\n * - Duplicates within a generation are idempotent; a callback of a retired\n * generation cannot reach its replacement.\n */\nexport class RemoteCandidates {\n private readonly sdp: SDPManager;\n private readonly secure: SecureTransportManager;\n private readonly negotiation: NegotiationTransaction;\n private readonly topology: BundleTopology;\n private readonly host: {\n signalingState: () => RTCSignalingState;\n hasRemoteDescription: () => boolean;\n };\n\n /** Candidates added before a remote description was applied. */\n readonly queued: Array<RTCIceCandidate | RTCIceCandidateInit | null> = [];\n\n constructor(\n sdp: SDPManager,\n secure: SecureTransportManager,\n negotiation: NegotiationTransaction,\n topology: BundleTopology,\n host: {\n signalingState: () => RTCSignalingState;\n hasRemoteDescription: () => boolean;\n },\n ) {\n this.sdp = sdp;\n this.secure = secure;\n this.negotiation = negotiation;\n this.topology = topology;\n this.host = host;\n }\n\n /** Route a trickled candidate or end-of-candidates to its ICE generation. */\n async apply(candidateMessage: RTCIceCandidate | RTCIceCandidateInit | null) {\n const current = this.sdp.currentRemoteDescription;\n const pending = this.sdp.pendingRemoteDescription;\n const ufrag = candidateMessage?.usernameFragment;\n // The generation is decided by the m-line the candidate targets: with a\n // partial BUNDLE split one m-line may keep the current ufrag while another\n // moves to a new one within the same pending description.\n const sdpMid = candidateMessage?.sdpMid;\n const sdpMLineIndex = candidateMessage?.sdpMLineIndex;\n const targetMedia = (description: SessionDescription) =>\n typeof sdpMid === \"string\"\n ? description.media.filter((media) => media.rtp.muxId === sdpMid)\n : typeof sdpMLineIndex === \"number\"\n ? description.media.slice(sdpMLineIndex, sdpMLineIndex + 1)\n : description.media;\n const matchesUfrag = (description: SessionDescription) =>\n targetMedia(description).some(\n (media) => media.iceParams?.usernameFragment === ufrag,\n );\n const sdp =\n ufrag &&\n current &&\n matchesUfrag(current) &&\n (!pending || !matchesUfrag(pending))\n ? current\n : (pending ?? current);\n if (!sdp) {\n return;\n }\n // A new remote generation is only a proposal during a re-offer. Keep its\n // trickle data in the pending SDP until the final answer activates it.\n const stageOnly =\n sdp === pending &&\n !!current &&\n (pending?.type === \"offer\" || pending?.type === \"pranswer\");\n const appliedCandidate = await this.secure.addIceCandidate(\n sdp,\n candidateMessage,\n !stageOnly,\n );\n const remoteDescription = sdp;\n if (!remoteDescription || !appliedCandidate) {\n return;\n }\n if (stageOnly) {\n const targets = new Set(\n appliedCandidate.mediaIndices\n .map((index) =>\n this.negotiation.transportByMid.get(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n ),\n )\n .filter(\n (transport): transport is RTCDtlsTransport =>\n !!transport &&\n this.negotiation.isPendingOnlyTransport(\n transport.iceTransport.id,\n ),\n ),\n );\n for (const transport of targets) {\n transport.iceTransport.deliverRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n if (current) {\n await this.deliverSameGenerationCandidate(\n remoteDescription,\n current,\n appliedCandidate,\n );\n }\n if (\n this.host.signalingState() === \"have-local-pranswer\" ||\n this.host.signalingState() === \"have-remote-pranswer\"\n ) {\n const provisional = new Set(\n appliedCandidate.mediaIndices\n .map(\n (index) =>\n this.topology.currentTransportForMid(\n remoteDescription.media[index]?.rtp.muxId ?? \"\",\n )?.iceTransport,\n )\n .filter(\n (transport): transport is RTCIceTransport =>\n !!transport?.hasStagedRestart &&\n !this.negotiation.isPendingOnlyTransport(transport.id),\n ),\n );\n for (const transport of provisional) {\n transport.deliverProvisionalRemoteCandidate(\n appliedCandidate.kind === \"end-of-candidates\"\n ? undefined\n : appliedCandidate.candidate,\n );\n }\n }\n }\n\n if (appliedCandidate.kind === \"end-of-candidates\") {\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (media) {\n media.iceCandidatesComplete = true;\n }\n }\n // A pending SDP becomes current at the answer, so it is aligned too.\n this.completeSharedTransportMedia(\n remoteDescription,\n appliedCandidate.mediaIndices,\n );\n return;\n }\n\n for (const mediaIndex of appliedCandidate.mediaIndices) {\n const media = remoteDescription.media[mediaIndex];\n if (!media) {\n continue;\n }\n media.iceCandidates.push(appliedCandidate.candidate);\n }\n }\n\n /**\n * A re-offer or pranswer that keeps the current transports may still carry\n * new candidates or end-of-candidates for an m-line whose ufrag is\n * unchanged. They belong to the live generation too, so they reach the live\n * checklist and the current SDP (once, and not after its end-of-candidates),\n * exactly like trickled ones. A pending-only transport receives its own.\n */\n async deliverSameGenerationDescription(proposal: SessionDescription) {\n const current = this.sdp.currentRemoteDescription;\n if (!current) return;\n const shared = [...proposal.media.entries()].filter(([, media]) => {\n if (media.port === 0) return false;\n const prepared = this.negotiation.transportByMid.get(\n media.rtp.muxId ?? \"\",\n );\n return !(\n prepared &&\n this.negotiation.isPendingOnlyTransport(prepared.iceTransport.id)\n );\n });\n // Candidates first (a non-tag BUNDLE member carries none of its own),\n // then end-of-candidates from any m-line, since it ends the shared\n // generation for the whole group.\n for (const [index, media] of shared) {\n if (this.topology.isBundledNonTag(proposal, media.rtp.muxId)) continue;\n for (const candidate of media.iceCandidates) {\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"candidate\",\n candidate,\n mediaIndices: [index],\n });\n }\n }\n for (const [index, media] of shared) {\n if (!media.iceCandidatesComplete) continue;\n await this.deliverSameGenerationCandidate(proposal, current, {\n kind: \"end-of-candidates\",\n mediaIndices: [index],\n });\n }\n }\n\n /**\n * End-of-candidates ends an ICE generation on its transport, not one\n * m-line: every m-line of `sdp` on the same finished transport with the\n * same ufrag as `completed` (the rest of its BUNDLE group) is marked\n * complete, so the SDP never promises more candidates to it.\n */\n completeSharedTransportMedia(sdp: SessionDescription, completed: number[]) {\n const current = this.sdp.currentRemoteDescription;\n if (sdp === current) {\n // The current description is laid out on the committed transports:\n // only the live generation that ended on a transport counts (a pending\n // restart ufrag on the same transport is still open).\n const transportFor = (mid: string) =>\n this.topology.liveTransportForMid(mid)?.iceTransport;\n const ended = completed.flatMap((index) => {\n const media = sdp.media[index];\n const transport = transportFor(media?.rtp.muxId ?? \"\");\n const ufrag = media?.iceParams?.usernameFragment;\n return transport?.connection.remoteCandidatesEnd &&\n transport.connection.remoteUsername === ufrag\n ? [{ transport, ufrag }]\n : [];\n });\n for (const media of sdp.media) {\n const transport = transportFor(media.rtp.muxId ?? \"\");\n if (\n ended.some(\n (generation) =>\n generation.transport === transport &&\n generation.ufrag === media.iceParams?.usernameFragment,\n )\n ) {\n media.iceCandidatesComplete = true;\n }\n }\n return;\n }\n // A pending proposal: a generation is identified by the proposal's own\n // BUNDLE ownership (the group tag, or the m-line itself) and ufrag, so an\n // m-line the proposal splits off stays open even with the same\n // credentials (RFC 8839 section 5.4), before any transport is prepared.\n const ownerIn = (description: SessionDescription, mid: string) =>\n this.topology.bundleTagOf(description, mid) ?? mid;\n const keyOf = (media: SessionDescription[\"media\"][number]) =>\n `${ownerIn(sdp, media.rtp.muxId ?? \"\")}\\u0000${media.iceParams?.usernameFragment ?? \"\"}`;\n const ended = new Set<string>();\n for (const index of completed) {\n const media = sdp.media[index];\n const mid = media?.rtp.muxId;\n const ufrag = media?.iceParams?.usernameFragment;\n if (!media || !mid || !ufrag) continue;\n // Its end-of-candidates arrived for this proposal, or the proposal\n // repeats a live generation that already ended, on an m-line it keeps\n // with the same owner.\n const live = this.topology.liveTransportForMid(mid)?.iceTransport;\n const repeatsEndedLive =\n !!current &&\n ownerIn(current, mid) === ownerIn(sdp, mid) &&\n !!live?.connection.remoteCandidatesEnd &&\n live.connection.remoteUsername === ufrag;\n if (media.iceCandidatesComplete || repeatsEndedLive) {\n ended.add(keyOf(media));\n }\n }\n for (const media of sdp.media) {\n if (ended.has(keyOf(media))) media.iceCandidatesComplete = true;\n }\n }\n\n /**\n * A candidate trickled for a pending re-offer whose m-line keeps the current\n * ufrag belongs to the live ICE generation as well. Besides the pending SDP,\n * it is recorded in the current SDP and handed to the live checklist once,\n * so the committed session can use it while the proposal is pending.\n */\n private async deliverSameGenerationCandidate(\n pending: SessionDescription,\n current: SessionDescription,\n applied: NonNullable<\n Awaited<ReturnType<SecureTransportManager[\"addIceCandidate\"]>>\n >,\n ) {\n for (const index of applied.mediaIndices) {\n const mid = pending.media[index]?.rtp.muxId;\n const ufrag = pending.media[index]?.iceParams?.usernameFragment;\n const currentMedia = current.media.find(\n (media) => media.rtp.muxId === mid,\n );\n const iceTransport = mid\n ? this.topology.currentTransportForMid(mid)?.iceTransport\n : undefined;\n if (\n !ufrag ||\n !currentMedia ||\n currentMedia.iceParams?.usernameFragment !== ufrag ||\n !iceTransport ||\n this.negotiation.isPendingOnlyTransport(iceTransport.id) ||\n iceTransport.connection.remoteUsername !== ufrag ||\n // RFC 8838: a generation that signalled end-of-candidates is complete,\n // whichever BUNDLE m-line of the shared transport carried it.\n currentMedia.iceCandidatesComplete ||\n iceTransport.connection.remoteCandidatesEnd\n ) {\n continue;\n }\n if (applied.kind === \"end-of-candidates\") {\n currentMedia.iceCandidatesComplete = true;\n iceTransport.deliverRemoteCandidate(undefined);\n this.completeSharedTransportMedia(current, [\n current.media.indexOf(currentMedia),\n ]);\n continue;\n }\n const text = applied.candidate.toJSON().candidate;\n if (\n currentMedia.iceCandidates.some(\n (existing) => existing.toJSON().candidate === text,\n )\n ) {\n continue;\n }\n currentMedia.iceCandidates.push(applied.candidate);\n iceTransport.deliverRemoteCandidate(applied.candidate);\n }\n }\n\n /**\n * Candidates queued before any remote description are checked against the\n * description during validation, so a bad one rejects setRemoteDescription\n * before any state changes and before any application event fires. The rejected\n * candidates leave the queue: their addIceCandidate already resolved, and a\n * retry of the same description must not fail on them again.\n */\n async validateQueued(sdp: SessionDescription) {\n let firstError: unknown;\n for (const candidate of [...this.queued]) {\n try {\n await this.secure.addIceCandidate(sdp, candidate ?? null, false);\n } catch (error) {\n firstError ??= error;\n this.queued.splice(this.queued.indexOf(candidate), 1);\n }\n }\n if (firstError) throw firstError;\n }\n\n /** Apply the queued candidates once a remote description exists. */\n async flushQueued() {\n while (this.queued.length > 0 && this.host.hasRemoteDescription()) {\n const candidate = this.queued.shift();\n await this.apply(candidate ?? null);\n }\n }\n}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { TransceiverPairing } from "../api/peerConfig";
|
|
1
2
|
import type { RTCRtpCodecParameters, RTCRtpTransceiver, RtpRouter, TransceiverManager } from "../media";
|
|
2
3
|
import type { NegotiationTransaction } from "../negotiationTransaction";
|
|
3
4
|
import type { SctpTransportManager } from "../sctpManager";
|
|
4
|
-
import type
|
|
5
|
+
import { type MediaDescription, type SessionDescription } from "../sdp";
|
|
5
6
|
import type { SDPManager } from "../sdpManager";
|
|
6
7
|
import type { RTCDtlsTransport } from "../transport/dtls";
|
|
7
8
|
import type { RTCIceTransport } from "../transport/ice";
|
|
8
9
|
import type { RTCSctpTransport } from "../transport/sctp";
|
|
10
|
+
import { type PairingView } from "./transceiverPairing";
|
|
9
11
|
/** What applying the m-lines of a remote description left for the caller. */
|
|
10
12
|
export type RemoteMediaPlan = {
|
|
11
13
|
/** A re-offer or pranswer on a live session keeps the current transports. */
|
|
@@ -29,6 +31,16 @@ export type RemoteMediaPlan = {
|
|
|
29
31
|
* transport, decides the BUNDLE transport ownership, applies RTP / SCTP
|
|
30
32
|
* parameters (accept or mark rejected), and plans the transport parameter
|
|
31
33
|
* updates the caller runs after every fallible step.
|
|
34
|
+
*
|
|
35
|
+
* m-line association (`matchRemoteTransceiver`): the MID first, then, under
|
|
36
|
+
* `transceiverPairing: "standard"`, only an unassociated transceiver
|
|
37
|
+
* `addTrack()` created (RFC 8829 5.10); a transceiver `addTransceiver()`
|
|
38
|
+
* created keeps its direction and `mid === null`, and the offer gets a new
|
|
39
|
+
* transceiver. `planCodecs` and `apply` pair through the same function and
|
|
40
|
+
* the same state: `planCodecs` runs before the implicit rollback, the
|
|
41
|
+
* replacement or the unapplied-createOffer revert of the remote offer, so it
|
|
42
|
+
* takes the view of the state after them (`NegotiationTransaction.
|
|
43
|
+
* pairingViewForRemoteOffer`).
|
|
32
44
|
*/
|
|
33
45
|
export declare class RemoteMediaApplication {
|
|
34
46
|
private readonly sdp;
|
|
@@ -36,6 +48,7 @@ export declare class RemoteMediaApplication {
|
|
|
36
48
|
private readonly sctp;
|
|
37
49
|
private readonly router;
|
|
38
50
|
private readonly negotiation;
|
|
51
|
+
private readonly pairing;
|
|
39
52
|
private readonly host;
|
|
40
53
|
constructor(sdp: SDPManager, transceivers: TransceiverManager, sctp: SctpTransportManager, router: RtpRouter, negotiation: NegotiationTransaction, host: {
|
|
41
54
|
createSctpTransport: () => RTCSctpTransport;
|
|
@@ -44,9 +57,13 @@ export declare class RemoteMediaApplication {
|
|
|
44
57
|
/** An independent transport (own ICE credentials) for ownership. */
|
|
45
58
|
createOwnerTransport: () => RTCDtlsTransport;
|
|
46
59
|
onRemoteTransceiverAdded: (transceiver: RTCRtpTransceiver) => void;
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
|
|
60
|
+
}, pairing?: TransceiverPairing);
|
|
61
|
+
/**
|
|
62
|
+
* Resolve all m-line codecs without mutating the current transaction.
|
|
63
|
+
* `view` is the transceiver state `apply` will associate with (see
|
|
64
|
+
* {@link PairingView}), so both pair every m-line with the same transceiver.
|
|
65
|
+
*/
|
|
66
|
+
planCodecs(remoteSdp: SessionDescription, view?: PairingView): Map<number, RTCRtpCodecParameters[]>;
|
|
50
67
|
apply(remoteSdp: SessionDescription, codecPlan?: Map<number, RTCRtpCodecParameters[]>): RemoteMediaPlan;
|
|
51
68
|
private associate;
|
|
52
69
|
/** Whether a current description has an m-line with `mid`. */
|
|
@@ -54,8 +71,8 @@ export declare class RemoteMediaApplication {
|
|
|
54
71
|
/** Whether the current session rejected (port 0) the m-line `mid`. */
|
|
55
72
|
private rejectedInCurrent;
|
|
56
73
|
/**
|
|
57
|
-
* remote m-line に対応する transceiver
|
|
58
|
-
*
|
|
74
|
+
* remote m-line に対応する transceiver を探す ({@link matchRemoteTransceiver})。
|
|
75
|
+
* MID の一致を優先し、未関連付け transceiver は同じ offer 内で異なる m-line に割り当てる。
|
|
59
76
|
*/
|
|
60
77
|
private findTransceiver;
|
|
61
78
|
/**
|