werift 0.26.0 → 0.28.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 +182 -8
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/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/log.js +5 -7
- package/lib/common/src/log.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 +12 -5
- package/lib/common/src/transport.js +13 -7
- 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/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/cipher.d.ts +1 -1
- package/lib/dtls/src/context/cipher.js +6 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +11 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +40 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +8 -3
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +6 -1
- package/lib/dtls/src/flight/flight.js +18 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +4 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +6 -2
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +4 -2
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +2 -1
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +4 -2
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +14 -7
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +2 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +6 -3
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +12 -6
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +4 -2
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +16 -8
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +2 -2
- package/lib/dtls/src/handshake/random.js +5 -2
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +52 -33
- package/lib/dtls/src/record/const.js +51 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.js +12 -6
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +10 -5
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +326 -8
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/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 +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +21 -5
- package/lib/ice/src/exceptions.js +58 -13
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/ice.d.ts +254 -58
- package/lib/ice/src/ice.js +979 -945
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +328 -14
- package/lib/ice/src/iceBase.js +254 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- 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/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 +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -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/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/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -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/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +30 -1
- package/lib/ice/src/stun/transaction.js +90 -19
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +31 -10
- package/lib/ice/src/turn/protocol.js +127 -51
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +11 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +44 -17
- package/lib/ice-server/src/stun/const.js +31 -19
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +29 -4
- package/lib/ice-server/src/stun/message.js +115 -24
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +35121 -22337
- package/lib/nonstandard/index.mjs +3169 -1399
- package/lib/polyfill/dom.mjs +24650 -12365
- package/lib/polyfill/index.mjs +24650 -12365
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +6 -3
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +5 -0
- package/lib/rtp/src/extra/processor/depacketizer.js +28 -2
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +6 -3
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.js +4 -2
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtpCallback.js +2 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/webm.js +14 -7
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/index.d.ts +8 -0
- package/lib/rtp/src/index.js +8 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +8 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.js +1 -0
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +49 -0
- package/lib/rtp/src/rtp/continuity.js +120 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/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/rtp/src/srtp/cipher/ctr.js +4 -2
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.js +6 -3
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +34 -10
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +85 -0
- package/lib/sctp/src/sctp.js +707 -126
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +385 -28
- package/lib/webrtc/src/api/peerConfig.js +121 -14
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- 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 +10 -0
- package/lib/webrtc/src/dataChannel.js +24 -4
- 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/index.d.ts +10 -0
- package/lib/webrtc/src/media/index.js +70 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +246 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +241 -40
- package/lib/webrtc/src/media/router.js +676 -205
- 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 +252 -2
- package/lib/webrtc/src/media/rtpReceiver.js +833 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +191 -70
- package/lib/webrtc/src/media/rtpSender.js +631 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +19 -3
- package/lib/webrtc/src/media/rtpTransceiver.js +74 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -33
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -154
- package/lib/webrtc/src/media/sender/senderBWE.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 +101 -0
- package/lib/webrtc/src/media/sender/senderStats.js +317 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +29 -2
- package/lib/webrtc/src/media/track.js +32 -5
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +1 -5
- package/lib/webrtc/src/negotiation/bundleTopology.js +15 -11
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -1
- package/lib/webrtc/src/negotiation/descriptionValidation.js +12 -6
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +2 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +10 -5
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +24 -7
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +67 -27
- 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 +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +40 -8
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +43 -5
- package/lib/webrtc/src/negotiationTransaction.js +129 -13
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +9 -7
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +8 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +108 -6
- package/lib/webrtc/src/peerConnection.js +357 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +46 -14
- package/lib/webrtc/src/sctpManager.js +92 -25
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +151 -20
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -4
- package/lib/webrtc/src/secureTransportManager.js +184 -26
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +239 -41
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +147 -1
- package/lib/webrtc/src/transport/dtls.js +446 -50
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +71 -90
- package/lib/webrtc/src/transport/ice.js +250 -42
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +25 -0
- package/lib/webrtc/src/transport/sctp.js +153 -22
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +69 -3
- package/lib/webrtc/src/utils.js +105 -16
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +9 -6
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeCodecMimeType = normalizeCodecMimeType;
|
|
4
4
|
exports.isCodecCompatible = isCodecCompatible;
|
|
5
|
+
exports.negotiatesAs = negotiatesAs;
|
|
6
|
+
exports.pairCodecs = pairCodecs;
|
|
5
7
|
exports.deliveredTrackCodec = deliveredTrackCodec;
|
|
8
|
+
exports.primaryTrackCodec = primaryTrackCodec;
|
|
6
9
|
exports.hasCommonPrimaryMimeType = hasCommonPrimaryMimeType;
|
|
7
10
|
exports.intersectCodecs = intersectCodecs;
|
|
8
11
|
exports.applyCodecPreferences = applyCodecPreferences;
|
|
9
12
|
exports.resolveCodecs = resolveCodecs;
|
|
10
13
|
exports.assertCodecsSupported = assertCodecsSupported;
|
|
14
|
+
exports.withNegotiatedCodecs = withNegotiatedCodecs;
|
|
15
|
+
exports.keepNegotiatedPayloadTypes = keepNegotiatedPayloadTypes;
|
|
11
16
|
const errors_1 = require("../errors");
|
|
12
17
|
const sdp_1 = require("../sdp");
|
|
18
|
+
const parameters_1 = require("./parameters");
|
|
13
19
|
/**
|
|
14
20
|
* Lower-cased MIME type with the legacy `video/AV1X` name folded into
|
|
15
21
|
* `video/av1`, so both names negotiate with each other.
|
|
@@ -24,13 +30,29 @@ function codecName(codec) {
|
|
|
24
30
|
function optionalEqual(left, right) {
|
|
25
31
|
return left == undefined || right == undefined || left === right;
|
|
26
32
|
}
|
|
27
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The `a=fmtp` parameters that tell the formats of one MIME type apart (a
|
|
35
|
+
* decoder for one cannot take the other): H264 `packetization-mode` and
|
|
36
|
+
* `profile-level-id` (RFC 6184), VP9 `profile-id` (RFC 9628) and AV1
|
|
37
|
+
* `profile` (AV1 RTP payload format). Values are compared case-insensitively.
|
|
38
|
+
*/
|
|
39
|
+
const FORMAT_PARAMETERS = {
|
|
40
|
+
h264: ["packetization-mode", "profile-level-id"],
|
|
41
|
+
vp9: ["profile-id"],
|
|
42
|
+
av1: ["profile"],
|
|
43
|
+
av1x: ["profile"],
|
|
44
|
+
};
|
|
45
|
+
function formatIdentity(codec) {
|
|
28
46
|
const parameters = (0, sdp_1.codecParametersFromString)(codec.parameters ?? "");
|
|
29
|
-
return
|
|
30
|
-
packetizationMode: parameters["packetization-mode"],
|
|
31
|
-
profileLevelId: parameters["profile-level-id"]?.toString().toLowerCase(),
|
|
32
|
-
};
|
|
47
|
+
return (FORMAT_PARAMETERS[codecName(codec)] ?? []).map((name) => parameters[name]?.toString().toLowerCase());
|
|
33
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether `source` (a track's codec or a remote codec) can be carried as
|
|
51
|
+
* `configured`: the same MIME type, clock rate and channels, and the same
|
|
52
|
+
* format-identifying parameters (`FORMAT_PARAMETERS`: H264 mode / profile,
|
|
53
|
+
* VP9 profile, AV1 profile). A parameter omitted on either side matches any
|
|
54
|
+
* value.
|
|
55
|
+
*/
|
|
34
56
|
function isCodecCompatible(source, configured) {
|
|
35
57
|
if (normalizeCodecMimeType(source.mimeType) !==
|
|
36
58
|
normalizeCodecMimeType(configured.mimeType)) {
|
|
@@ -40,14 +62,68 @@ function isCodecCompatible(source, configured) {
|
|
|
40
62
|
return false;
|
|
41
63
|
if (!optionalEqual(source.channels, configured.channels))
|
|
42
64
|
return false;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
const sourceIdentity = formatIdentity(source);
|
|
66
|
+
const configuredIdentity = formatIdentity(configured);
|
|
67
|
+
return sourceIdentity.every((value, index) => optionalEqual(value, configuredIdentity[index]));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The fallback predicate negotiation pairs a configured codec with a remote
|
|
71
|
+
* one by when no remote codec has its format (`pairCodecs`): the same MIME
|
|
72
|
+
* type. The negotiated codec is then in the remote's form (payload type,
|
|
73
|
+
* fmtp, rtcp-fb), which may differ from the configured one, but it is what
|
|
74
|
+
* the configured codec negotiated, so a later offer lists it as it is
|
|
75
|
+
* (RFC 3264 §8.3.2).
|
|
76
|
+
*/
|
|
77
|
+
function negotiatesAs(configured, negotiated) {
|
|
78
|
+
return (normalizeCodecMimeType(configured.mimeType) ===
|
|
79
|
+
normalizeCodecMimeType(negotiated.mimeType));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pair each configured primary codec with at most one of `others` (and each
|
|
83
|
+
* of `others` with at most one configured codec), the rule negotiation
|
|
84
|
+
* (`setRemoteDescription()` / `createAnswer()`) and a later offer share,
|
|
85
|
+
* in three passes over the configured codecs, each pass only for the codecs
|
|
86
|
+
* still unpaired:
|
|
87
|
+
*
|
|
88
|
+
* 1. the codec of exactly the same format (`sameFormat`: MIME type, clock
|
|
89
|
+
* rate, channels and every `a=fmtp` parameter, for any codec: VP9
|
|
90
|
+
* `profile-id`, AV1 `profile`, H264 `packetization-mode` /
|
|
91
|
+
* `profile-level-id`, Opus parameters, ...);
|
|
92
|
+
* 2. a compatible one (`isCodecCompatible`: the same format-identifying
|
|
93
|
+
* parameters, H264 mode / profile, VP9 / AV1 profile, where an omitted
|
|
94
|
+
* one matches any value);
|
|
95
|
+
* 3. one of the same MIME type (`negotiatesAs`, for instance an H264 of
|
|
96
|
+
* another level or a VP9 of another profile).
|
|
97
|
+
*
|
|
98
|
+
* So when the configured codecs hold several formats of one MIME type (H264
|
|
99
|
+
* mode 0 and mode 1, VP9 profile 0 and profile 2), each pairs with its own
|
|
100
|
+
* format whatever the order, and an answer does not switch the format the
|
|
101
|
+
* offer meant. RTX / RED are not paired. `accept` limits the candidates (a
|
|
102
|
+
* fixed track source).
|
|
103
|
+
*/
|
|
104
|
+
function pairCodecs(configured, others, accept = () => true) {
|
|
105
|
+
const pairs = new Map();
|
|
106
|
+
const used = new Set();
|
|
107
|
+
const passes = [
|
|
108
|
+
sameFormat,
|
|
109
|
+
(codec, other) => isCodecCompatible(other, codec),
|
|
110
|
+
negotiatesAs,
|
|
111
|
+
];
|
|
112
|
+
for (const matches of passes) {
|
|
113
|
+
for (const codec of configured) {
|
|
114
|
+
if (isAuxiliary(codec) || pairs.has(codec))
|
|
115
|
+
continue;
|
|
116
|
+
const other = others.find((candidate) => !isAuxiliary(candidate) &&
|
|
117
|
+
!used.has(candidate) &&
|
|
118
|
+
matches(codec, candidate) &&
|
|
119
|
+
accept(codec, candidate));
|
|
120
|
+
if (!other)
|
|
121
|
+
continue;
|
|
122
|
+
pairs.set(codec, other);
|
|
123
|
+
used.add(other);
|
|
124
|
+
}
|
|
49
125
|
}
|
|
50
|
-
return
|
|
126
|
+
return pairs;
|
|
51
127
|
}
|
|
52
128
|
function isAuxiliary(codec) {
|
|
53
129
|
return ["rtx", "red"].includes(codecName(codec));
|
|
@@ -66,6 +142,18 @@ function deliveredTrackCodec(kind, codec, negotiated) {
|
|
|
66
142
|
negotiated.find((candidate) => !isAuxiliary(candidate)) ??
|
|
67
143
|
codec);
|
|
68
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* 交渉済み codec 列から remote track の codec を決める。
|
|
147
|
+
* 先頭の RTX (と video の RED / FEC) は飛ばし、audio の RED は
|
|
148
|
+
* {@link deliveredTrackCodec} と同じく primary へ解決する。
|
|
149
|
+
*/
|
|
150
|
+
function primaryTrackCodec(kind, negotiated) {
|
|
151
|
+
const first = negotiated.find((codec) => kind === "audio"
|
|
152
|
+
? codecName(codec) !== "rtx"
|
|
153
|
+
: !isAuxiliary(codec) &&
|
|
154
|
+
!["ulpfec", "flexfec-03"].includes(codecName(codec))) ?? negotiated[0];
|
|
155
|
+
return deliveredTrackCodec(kind, first, negotiated);
|
|
156
|
+
}
|
|
69
157
|
/**
|
|
70
158
|
* RTX / RED を除く primary codec に MIME 一致が 1 つでもあるか。
|
|
71
159
|
* remote m-line を local capability で扱えるかの判定 (Issue #705) に使う。
|
|
@@ -82,8 +170,10 @@ function referencedPayloadTypes(codec) {
|
|
|
82
170
|
return Number.isNaN(apt) ? [] : [apt];
|
|
83
171
|
}
|
|
84
172
|
if (codecName(codec) === "red") {
|
|
173
|
+
// `Number("")` is 0: a RED without fmtp references nothing.
|
|
85
174
|
return parameters
|
|
86
175
|
.split("/")
|
|
176
|
+
.filter((value) => value.trim() !== "")
|
|
87
177
|
.map(Number)
|
|
88
178
|
.filter((value) => !Number.isNaN(value));
|
|
89
179
|
}
|
|
@@ -146,4 +236,240 @@ function assertCodecsSupported(options) {
|
|
|
146
236
|
}
|
|
147
237
|
return effective;
|
|
148
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Configured codecs a negotiated m-line offers, before payload types are
|
|
241
|
+
* mapped (`keepNegotiatedPayloadTypes`): `capability` plus the configured
|
|
242
|
+
* counterpart (`pairCodecs`, the rule negotiation pairs by) of every
|
|
243
|
+
* negotiated codec that `capability` lacks.
|
|
244
|
+
*
|
|
245
|
+
* `eligible` is every configured codec of the kind with the fixed source and
|
|
246
|
+
* the codec preferences applied but no direction filter, and `capability` is
|
|
247
|
+
* the same for the current direction. A direction change (`direction`,
|
|
248
|
+
* `removeTrack()`) therefore never takes a negotiated codec off the m-line;
|
|
249
|
+
* only an answer does. Preferences and a fixed source still exclude one. An
|
|
250
|
+
* RTX / RED is kept when its primaries are and it is in `capability` or
|
|
251
|
+
* negotiated for the same primaries. The order is that of `eligible`
|
|
252
|
+
* (preferences, then configuration), the order of a first offer.
|
|
253
|
+
*/
|
|
254
|
+
function withNegotiatedCodecs(eligible, capability, negotiated) {
|
|
255
|
+
const candidates = [
|
|
256
|
+
...eligible,
|
|
257
|
+
...capability.filter((codec) => !eligible.includes(codec)),
|
|
258
|
+
];
|
|
259
|
+
const primaryOf = (codecs, payloadType) => codecs.find((codec) => !isAuxiliary(codec) && codec.payloadType === payloadType);
|
|
260
|
+
const pairs = pairCodecs(candidates, negotiated);
|
|
261
|
+
const kept = new Set(candidates.filter((codec) => !isAuxiliary(codec) && (capability.includes(codec) || pairs.has(codec))));
|
|
262
|
+
const negotiatedForSamePrimaries = (codec) => {
|
|
263
|
+
const primaries = referencedPayloadTypes(codec).map((payloadType) => primaryOf(candidates, payloadType));
|
|
264
|
+
return negotiated.some((other) => {
|
|
265
|
+
if (codecName(other) !== codecName(codec))
|
|
266
|
+
return false;
|
|
267
|
+
const otherPrimaries = referencedPayloadTypes(other).map((payloadType) => primaryOf(negotiated, payloadType));
|
|
268
|
+
return (otherPrimaries.length === primaries.length &&
|
|
269
|
+
primaries.every((primary, index) => {
|
|
270
|
+
const otherPrimary = otherPrimaries[index];
|
|
271
|
+
return (primary != undefined &&
|
|
272
|
+
otherPrimary != undefined &&
|
|
273
|
+
pairs.get(primary) === otherPrimary);
|
|
274
|
+
}));
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
return candidates.filter((codec) => {
|
|
278
|
+
if (!isAuxiliary(codec))
|
|
279
|
+
return kept.has(codec);
|
|
280
|
+
const primaries = referencedPayloadTypes(codec).map((payloadType) => primaryOf(candidates, payloadType));
|
|
281
|
+
if (primaries.some((primary) => primary == undefined || !kept.has(primary)))
|
|
282
|
+
return false;
|
|
283
|
+
return capability.includes(codec) || negotiatedForSamePrimaries(codec);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The format parameters (`a=fmtp`) a payload type stands for, in a form that
|
|
288
|
+
* compares equal when the parameters mean the same: parameter names are
|
|
289
|
+
* case-insensitive and unordered, and H264 gets its RFC 6184 §8.1 defaults
|
|
290
|
+
* (`packetization-mode` 0, `profile-level-id` 42000A, case-insensitive), so
|
|
291
|
+
* an omitted parameter and its default are the same format. Anything else
|
|
292
|
+
* (an RTX `apt`, the primaries of a RED `110/110`) is compared as written.
|
|
293
|
+
*/
|
|
294
|
+
function formatParameters(codec) {
|
|
295
|
+
const entries = new Map();
|
|
296
|
+
for (const item of (codec.parameters ?? "").split(";")) {
|
|
297
|
+
const parameter = item.trim();
|
|
298
|
+
if (parameter.length === 0)
|
|
299
|
+
continue;
|
|
300
|
+
const separator = parameter.indexOf("=");
|
|
301
|
+
if (separator < 0) {
|
|
302
|
+
entries.set(parameter, "");
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
entries.set(parameter.slice(0, separator).trim().toLowerCase(), parameter.slice(separator + 1).trim());
|
|
306
|
+
}
|
|
307
|
+
if (codecName(codec) === "h264") {
|
|
308
|
+
entries.set("packetization-mode", entries.get("packetization-mode") ?? "0");
|
|
309
|
+
entries.set("profile-level-id", (entries.get("profile-level-id") ?? "42000a").toLowerCase());
|
|
310
|
+
}
|
|
311
|
+
return [...entries]
|
|
312
|
+
.map(([name, value]) => `${name}=${value}`)
|
|
313
|
+
.sort()
|
|
314
|
+
.join(";");
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The RTCP feedback (`a=rtcp-fb`) a payload type stands for, unordered and
|
|
318
|
+
* without duplicates, with the type and parameter compared case-insensitively.
|
|
319
|
+
*/
|
|
320
|
+
function feedbackTypes(codec) {
|
|
321
|
+
return [
|
|
322
|
+
...new Set(codec.rtcpFeedback.map((feedback) => `${feedback.type} ${feedback.parameter ?? ""}`.trim().toLowerCase())),
|
|
323
|
+
]
|
|
324
|
+
.sort()
|
|
325
|
+
.join(";");
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Whether two codecs can share a payload type in one BUNDLE group (RFC 3264
|
|
329
|
+
* §8.3.2, RFC 8843 §9.1): the same codec with the same format parameters and
|
|
330
|
+
* RTCP feedback, the attributes RFC 8859 puts in the IDENTICAL-PER-PT
|
|
331
|
+
* category (`a=fmtp`, `a=rtcp-fb`). So an H264 format with another
|
|
332
|
+
* `packetization-mode` or `profile-level-id`, an RTX for another `apt`, a RED
|
|
333
|
+
* with other primaries or a VP8 with other feedback is another codec.
|
|
334
|
+
*/
|
|
335
|
+
function samePayloadMapping(left, right) {
|
|
336
|
+
return (sameFormat(left, right) && feedbackTypes(left) === feedbackTypes(right));
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The same media format (`a=rtpmap` and `a=fmtp`, RFC 4566): MIME type,
|
|
340
|
+
* clock rate, channels and the format parameters (`formatParameters`), for
|
|
341
|
+
* every codec. RTCP feedback is not part of the format.
|
|
342
|
+
*/
|
|
343
|
+
function sameFormat(left, right) {
|
|
344
|
+
return (normalizeCodecMimeType(left.mimeType) ===
|
|
345
|
+
normalizeCodecMimeType(right.mimeType) &&
|
|
346
|
+
left.clockRate === right.clockRate &&
|
|
347
|
+
(left.channels ?? 1) === (right.channels ?? 1) &&
|
|
348
|
+
formatParameters(left) === formatParameters(right));
|
|
349
|
+
}
|
|
350
|
+
function withPayloadType(codec, payloadType, parameters = codec.parameters) {
|
|
351
|
+
if (codec.payloadType === payloadType && codec.parameters === parameters) {
|
|
352
|
+
return codec;
|
|
353
|
+
}
|
|
354
|
+
const next = new parameters_1.RTCRtpCodecParameters({
|
|
355
|
+
mimeType: codec.mimeType,
|
|
356
|
+
clockRate: codec.clockRate,
|
|
357
|
+
...(codec.channels != undefined ? { channels: codec.channels } : {}),
|
|
358
|
+
payloadType,
|
|
359
|
+
rtcpFeedback: codec.rtcpFeedback.map((feedback) => ({ ...feedback })),
|
|
360
|
+
...(parameters != undefined ? { parameters } : {}),
|
|
361
|
+
direction: codec.direction,
|
|
362
|
+
});
|
|
363
|
+
return next;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Offer codecs for a negotiated m-line (RFC 8829 §5.2.2, RFC 3264 §8.3.2):
|
|
367
|
+
* `capability` (configured codecs, in offer order) with each configured codec
|
|
368
|
+
* that is already negotiated replaced by the negotiated codec itself, so its
|
|
369
|
+
* payload type, fmtp and rtcp-fb stay as negotiated (also when the remote's
|
|
370
|
+
* form differs from the configured one). Configured and negotiated codecs
|
|
371
|
+
* pair as negotiation pairs them (`pairCodecs`: the same format first, then
|
|
372
|
+
* the same MIME type). Another format of a negotiated MIME type that the
|
|
373
|
+
* answer left out (H264 mode 1 next to a negotiated mode 0) is offered again
|
|
374
|
+
* like any other codec, so a later answer can move to it; an answer that
|
|
375
|
+
* still has the negotiated format pairs with it, since negotiation prefers
|
|
376
|
+
* the same format. A negotiated RTX / RED for the offered primaries is
|
|
377
|
+
* offered as negotiated too.
|
|
378
|
+
*
|
|
379
|
+
* A codec offered again keeps its configured payload type unless that type is
|
|
380
|
+
* already used on this m-line or maps to another codec in `taken` (every
|
|
381
|
+
* payload type the session uses; the same codec with other format parameters
|
|
382
|
+
* or RTCP feedback, such as a RED with other primaries, is another codec);
|
|
383
|
+
* then it takes a free dynamic type (96-127,
|
|
384
|
+
* then 35-63). RTX `apt` and RED references follow their primaries, and an
|
|
385
|
+
* RTX / RED whose primary is not offered is dropped. The order of
|
|
386
|
+
* `capability` is kept.
|
|
387
|
+
*/
|
|
388
|
+
function keepNegotiatedPayloadTypes(capability, negotiated, taken) {
|
|
389
|
+
const offered = capability.map(() => undefined);
|
|
390
|
+
const used = new Set();
|
|
391
|
+
const primaryPayloadType = new Map();
|
|
392
|
+
const matched = new Set();
|
|
393
|
+
const isFree = (payloadType, codec) => {
|
|
394
|
+
if (used.has(payloadType))
|
|
395
|
+
return false;
|
|
396
|
+
const owner = taken.get(payloadType);
|
|
397
|
+
return owner == undefined || samePayloadMapping(owner, codec);
|
|
398
|
+
};
|
|
399
|
+
const pick = (preferred, codec) => {
|
|
400
|
+
if (isFree(preferred, codec))
|
|
401
|
+
return preferred;
|
|
402
|
+
for (const [from, to] of [
|
|
403
|
+
[96, 127],
|
|
404
|
+
[35, 63],
|
|
405
|
+
]) {
|
|
406
|
+
for (let payloadType = from; payloadType <= to; payloadType++) {
|
|
407
|
+
if (isFree(payloadType, codec))
|
|
408
|
+
return payloadType;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return undefined;
|
|
412
|
+
};
|
|
413
|
+
const place = (index, codec) => {
|
|
414
|
+
offered[index] = codec;
|
|
415
|
+
used.add(codec.payloadType);
|
|
416
|
+
};
|
|
417
|
+
// 1. Negotiated primaries are offered as negotiated (payload type, fmtp,
|
|
418
|
+
// rtcp-fb), each in place of the configured codec it pairs with
|
|
419
|
+
// (`pairCodecs`: the same format first, then the same MIME type).
|
|
420
|
+
for (const [codec, match] of pairCodecs(capability, negotiated)) {
|
|
421
|
+
if (used.has(match.payloadType))
|
|
422
|
+
continue;
|
|
423
|
+
matched.add(match);
|
|
424
|
+
primaryPayloadType.set(codec.payloadType, match.payloadType);
|
|
425
|
+
place(capability.indexOf(codec), match);
|
|
426
|
+
}
|
|
427
|
+
// 2. Primaries offered again.
|
|
428
|
+
capability.forEach((codec, index) => {
|
|
429
|
+
if (isAuxiliary(codec) || offered[index])
|
|
430
|
+
return;
|
|
431
|
+
const payloadType = pick(codec.payloadType, codec);
|
|
432
|
+
if (payloadType == undefined)
|
|
433
|
+
return;
|
|
434
|
+
primaryPayloadType.set(codec.payloadType, payloadType);
|
|
435
|
+
place(index, withPayloadType(codec, payloadType));
|
|
436
|
+
});
|
|
437
|
+
// 3. RTX / RED follow their primaries.
|
|
438
|
+
capability.forEach((codec, index) => {
|
|
439
|
+
if (!isAuxiliary(codec))
|
|
440
|
+
return;
|
|
441
|
+
const references = referencedPayloadTypes(codec).map((payloadType) => primaryPayloadType.get(payloadType));
|
|
442
|
+
// A video RED has no fmtp (nothing references a primary): it is offered
|
|
443
|
+
// as configured. An RTX, or a RED that names primaries, needs them offered.
|
|
444
|
+
const standalone = codecName(codec) === "red" && references.length === 0;
|
|
445
|
+
if (!standalone &&
|
|
446
|
+
(references.length === 0 ||
|
|
447
|
+
references.some((payloadType) => payloadType == undefined))) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const parameters = standalone
|
|
451
|
+
? codec.parameters
|
|
452
|
+
: codecName(codec) === "rtx"
|
|
453
|
+
? (codec.parameters ?? "").replace(/(^|;)\s*apt=\d+/, `$1apt=${references[0]}`)
|
|
454
|
+
: references.join("/");
|
|
455
|
+
// The RTX / RED negotiated for these primaries is offered as negotiated.
|
|
456
|
+
const negotiatedAuxiliary = negotiated.find((other) => codecName(other) === codecName(codec) &&
|
|
457
|
+
!matched.has(other) &&
|
|
458
|
+
!used.has(other.payloadType) &&
|
|
459
|
+
(codecName(codec) === "rtx"
|
|
460
|
+
? referencedPayloadTypes(other)[0] === references[0]
|
|
461
|
+
: (other.parameters ?? "") === (parameters ?? "")));
|
|
462
|
+
if (negotiatedAuxiliary) {
|
|
463
|
+
matched.add(negotiatedAuxiliary);
|
|
464
|
+
place(index, negotiatedAuxiliary);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const candidate = withPayloadType(codec, codec.payloadType, parameters);
|
|
468
|
+
const payloadType = pick(codec.payloadType, candidate);
|
|
469
|
+
if (payloadType == undefined)
|
|
470
|
+
return;
|
|
471
|
+
place(index, withPayloadType(candidate, payloadType));
|
|
472
|
+
});
|
|
473
|
+
return offered.filter((codec) => codec != undefined);
|
|
474
|
+
}
|
|
149
475
|
//# sourceMappingURL=codecCompatibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecCompatibility.js","sourceRoot":"","sources":["../../../../src/media/codecCompatibility.ts"],"names":[],"mappings":";;AASA,wDAGC;AAkBD,8CA4BC;AAWD,kDAiBC;AAMD,4DAaC;AAmCD,0CAUC;AAaD,sDA0BC;AAED,sCASC;AAMD,sDAuBC;AArOD,sCAAqD;AACrD,gCAAmD;AAInD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAI,IAAmB,EAAE,KAAoB;IACjE,OAAO,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC;AACnE,CAAC;AAED,SAAS,cAAc,CAAC,KAA4B;IAClD,MAAM,UAAU,GAAG,IAAA,+BAAyB,EAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACrE,OAAO;QACL,iBAAiB,EAAE,UAAU,CAAC,oBAAoB,CAAC;QACnD,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE;KACzE,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAC/B,MAA6B,EAC7B,UAAiC;IAEjC,IACE,sBAAsB,CAAC,MA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codecParametersFromString } from \"../sdp\";\nimport type { Kind } from \"../types/domain\";\nimport type { RTCRtpCodecParameters } from \"./parameters\";\n\n/**\n * Lower-cased MIME type with the legacy `video/AV1X` name folded into\n * `video/av1`, so both names negotiate with each other.\n */\nexport function normalizeCodecMimeType(mimeType: string) {\n const lower = mimeType.toLowerCase();\n return lower === \"video/av1x\" ? \"video/av1\" : lower;\n}\n\nfunction codecName(codec: RTCRtpCodecParameters) {\n return codec.name.toLowerCase();\n}\n\nfunction optionalEqual<T>(left: T | undefined, right: T | undefined) {\n return left == undefined || right == undefined || left === right;\n}\n\nfunction h264Parameters(codec: RTCRtpCodecParameters) {\n const parameters = codecParametersFromString(codec.parameters ?? \"\");\n return {\n packetizationMode: parameters[\"packetization-mode\"],\n profileLevelId: parameters[\"profile-level-id\"]?.toString().toLowerCase(),\n };\n}\n\nexport function isCodecCompatible(\n source: RTCRtpCodecParameters,\n configured: RTCRtpCodecParameters,\n) {\n if (\n normalizeCodecMimeType(source.mimeType) !==\n normalizeCodecMimeType(configured.mimeType)\n ) {\n return false;\n }\n if (source.clockRate !== configured.clockRate) return false;\n if (!optionalEqual(source.channels, configured.channels)) return false;\n if (codecName(source) !== \"h264\") return true;\n\n const sourceParameters = h264Parameters(source);\n const configuredParameters = h264Parameters(configured);\n if (\n !optionalEqual(\n sourceParameters.packetizationMode,\n configuredParameters.packetizationMode,\n )\n ) {\n return false;\n }\n return optionalEqual(\n sourceParameters.profileLevelId,\n configuredParameters.profileLevelId,\n );\n}\n\nfunction isAuxiliary(codec: RTCRtpCodecParameters) {\n return [\"rtx\", \"red\"].includes(codecName(codec));\n}\n\n/**\n * remote track が実際に配信する codec を返す。\n * audio の RED は RTCRtpReceiver が primary へ展開してから track へ渡すため、\n * RED が参照する primary codec (不明なら先頭の primary) を track の codec とする。\n */\nexport function deliveredTrackCodec(\n kind: string,\n codec: RTCRtpCodecParameters | undefined,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n if (kind !== \"audio\" || codec == undefined || codecName(codec) !== \"red\") {\n return codec;\n }\n const [primaryPayloadType] = referencedPayloadTypes(codec);\n return (\n negotiated.find(\n (candidate) =>\n !isAuxiliary(candidate) && candidate.payloadType === primaryPayloadType,\n ) ??\n negotiated.find((candidate) => !isAuxiliary(candidate)) ??\n codec\n );\n}\n\n/**\n * RTX / RED を除く primary codec に MIME 一致が 1 つでもあるか。\n * remote m-line を local capability で扱えるかの判定 (Issue #705) に使う。\n */\nexport function hasCommonPrimaryMimeType(\n local: readonly RTCRtpCodecParameters[],\n remote: readonly RTCRtpCodecParameters[],\n) {\n return local.some(\n (localCodec) =>\n !isAuxiliary(localCodec) &&\n remote.some(\n (remoteCodec) =>\n normalizeCodecMimeType(remoteCodec.mimeType) ===\n normalizeCodecMimeType(localCodec.mimeType),\n ),\n );\n}\n\nfunction referencedPayloadTypes(codec: RTCRtpCodecParameters) {\n const parameters = codec.parameters ?? \"\";\n if (codecName(codec) === \"rtx\") {\n const apt = Number(codecParametersFromString(parameters).apt);\n return Number.isNaN(apt) ? [] : [apt];\n }\n if (codecName(codec) === \"red\") {\n return parameters\n .split(\"/\")\n .map(Number)\n .filter((value) => !Number.isNaN(value));\n }\n return [];\n}\n\nfunction withAuxiliaryCodecs(\n configured: RTCRtpCodecParameters[],\n primary: RTCRtpCodecParameters[],\n) {\n const keptPayloadTypes = new Set(primary.map((codec) => codec.payloadType));\n const auxiliary = configured.filter((codec) => {\n if (!isAuxiliary(codec)) return false;\n const referenced = referencedPayloadTypes(codec);\n return (\n referenced.length > 0 &&\n referenced.every((payloadType) => keptPayloadTypes.has(payloadType))\n );\n });\n return configured.filter(\n (codec) => primary.includes(codec) || auxiliary.includes(codec),\n );\n}\n\nexport function intersectCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[],\n) {\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n source.some((sourceCodec) => isCodecCompatible(sourceCodec, codec)),\n );\n return withAuxiliaryCodecs(configured, primary);\n}\n\nfunction matchesPreference(\n candidate: RTCRtpCodecParameters,\n preference: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(candidate.mimeType) ===\n normalizeCodecMimeType(preference.mimeType) &&\n optionalEqual(candidate.clockRate, preference.clockRate)\n );\n}\n\nexport function applyCodecPreferences(\n configured: RTCRtpCodecParameters[],\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n if (preferences == undefined) return configured;\n const preferred = preferences.flatMap((preference) => {\n const match = configured.find((codec) =>\n matchesPreference(codec, preference),\n );\n return match ? [match] : [];\n });\n const uniquePreferred = [...new Set(preferred)];\n const referencedByPreferredAuxiliary = new Set(\n uniquePreferred.filter(isAuxiliary).flatMap(referencedPayloadTypes),\n );\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n (uniquePreferred.includes(codec) ||\n referencedByPreferredAuxiliary.has(codec.payloadType)),\n );\n const allowed = withAuxiliaryCodecs(configured, primary);\n return [\n ...uniquePreferred.filter((codec) => allowed.includes(codec)),\n ...allowed.filter((codec) => !uniquePreferred.includes(codec)),\n ];\n}\n\nexport function resolveCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[] | undefined,\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n return applyCodecPreferences(\n source == undefined ? configured : intersectCodecs(configured, source),\n preferences,\n );\n}\n\nfunction list(codecs: readonly RTCRtpCodecParameters[] | undefined) {\n return codecs?.map((codec) => codec.mimeType).join(\", \") || \"(none)\";\n}\n\nexport function assertCodecsSupported(options: {\n kind: Kind;\n configured: RTCRtpCodecParameters[];\n source: readonly RTCRtpCodecParameters[] | undefined;\n preferences: readonly RTCRtpCodecParameters[] | undefined;\n}) {\n const { kind, configured, source, preferences } = options;\n const sourceCompatible =\n source == undefined ? configured : intersectCodecs(configured, source);\n if (source != undefined && sourceCompatible.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `Track codec ${list(source)} is not supported by this RTCPeerConnection. Configured ${kind} codecs: ${list(configured)}`,\n );\n }\n const effective = applyCodecPreferences(sourceCompatible, preferences);\n if (effective.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `No codec remains after applying codec preferences. Source codecs: ${list(source)} Configured codecs: ${list(configured)} Preferred codecs: ${list(preferences)}`,\n );\n }\n return effective;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codecCompatibility.js","sourceRoot":"","sources":["../../../../src/media/codecCompatibility.ts"],"names":[],"mappings":";;AASA,wDAGC;AAqCD,8CAiBC;AAUD,oCAQC;AAyBD,gCAgCC;AAWD,kDAiBC;AAOD,8CAYC;AAMD,4DAaC;AAqCD,0CAUC;AAaD,sDA0BC;AAED,sCASC;AAMD,sDAuBC;AAiBD,oDAsDC;AAiID,gEA+FC;AApnBD,sCAAqD;AACrD,gCAAmD;AAEnD,6CAAqD;AAErD;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B;IAC7C,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,aAAa,CAAI,IAAmB,EAAE,KAAoB;IACjE,OAAO,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,IAAI,KAAK,KAAK,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAmD;IACxE,IAAI,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;IAChD,GAAG,EAAE,CAAC,YAAY,CAAC;IACnB,GAAG,EAAE,CAAC,SAAS,CAAC;IAChB,IAAI,EAAE,CAAC,SAAS,CAAC;CAClB,CAAC;AAEF,SAAS,cAAc,CAAC,KAA4B;IAClD,MAAM,U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AAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,WAAW,IAAI,SAAS;YAAE,OAAO;QACrC,KAAK,CAAC,KAAK,EAAE,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,SAAS,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { createWebRtcDomException } from \"../errors\";\nimport { codecParametersFromString } from \"../sdp\";\nimport type { Kind } from \"../types/domain\";\nimport { RTCRtpCodecParameters } from \"./parameters\";\n\n/**\n * Lower-cased MIME type with the legacy `video/AV1X` name folded into\n * `video/av1`, so both names negotiate with each other.\n */\nexport function normalizeCodecMimeType(mimeType: string) {\n const lower = mimeType.toLowerCase();\n return lower === \"video/av1x\" ? \"video/av1\" : lower;\n}\n\nfunction codecName(codec: RTCRtpCodecParameters) {\n return codec.name.toLowerCase();\n}\n\nfunction optionalEqual<T>(left: T | undefined, right: T | undefined) {\n return left == undefined || right == undefined || left === right;\n}\n\n/**\n * The `a=fmtp` parameters that tell the formats of one MIME type apart (a\n * decoder for one cannot take the other): H264 `packetization-mode` and\n * `profile-level-id` (RFC 6184), VP9 `profile-id` (RFC 9628) and AV1\n * `profile` (AV1 RTP payload format). Values are compared case-insensitively.\n */\nconst FORMAT_PARAMETERS: { readonly [name: string]: readonly string[] } = {\n h264: [\"packetization-mode\", \"profile-level-id\"],\n vp9: [\"profile-id\"],\n av1: [\"profile\"],\n av1x: [\"profile\"],\n};\n\nfunction formatIdentity(codec: RTCRtpCodecParameters) {\n const parameters = codecParametersFromString(codec.parameters ?? \"\");\n return (FORMAT_PARAMETERS[codecName(codec)] ?? []).map((name) =>\n parameters[name]?.toString().toLowerCase(),\n );\n}\n\n/**\n * Whether `source` (a track's codec or a remote codec) can be carried as\n * `configured`: the same MIME type, clock rate and channels, and the same\n * format-identifying parameters (`FORMAT_PARAMETERS`: H264 mode / profile,\n * VP9 profile, AV1 profile). A parameter omitted on either side matches any\n * value.\n */\nexport function isCodecCompatible(\n source: RTCRtpCodecParameters,\n configured: RTCRtpCodecParameters,\n) {\n if (\n normalizeCodecMimeType(source.mimeType) !==\n normalizeCodecMimeType(configured.mimeType)\n ) {\n return false;\n }\n if (source.clockRate !== configured.clockRate) return false;\n if (!optionalEqual(source.channels, configured.channels)) return false;\n const sourceIdentity = formatIdentity(source);\n const configuredIdentity = formatIdentity(configured);\n return sourceIdentity.every((value, index) =>\n optionalEqual(value, configuredIdentity[index]),\n );\n}\n\n/**\n * The fallback predicate negotiation pairs a configured codec with a remote\n * one by when no remote codec has its format (`pairCodecs`): the same MIME\n * type. The negotiated codec is then in the remote's form (payload type,\n * fmtp, rtcp-fb), which may differ from the configured one, but it is what\n * the configured codec negotiated, so a later offer lists it as it is\n * (RFC 3264 §8.3.2).\n */\nexport function negotiatesAs(\n configured: RTCRtpCodecParameters,\n negotiated: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(configured.mimeType) ===\n normalizeCodecMimeType(negotiated.mimeType)\n );\n}\n\n/**\n * Pair each configured primary codec with at most one of `others` (and each\n * of `others` with at most one configured codec), the rule negotiation\n * (`setRemoteDescription()` / `createAnswer()`) and a later offer share,\n * in three passes over the configured codecs, each pass only for the codecs\n * still unpaired:\n *\n * 1. the codec of exactly the same format (`sameFormat`: MIME type, clock\n * rate, channels and every `a=fmtp` parameter, for any codec: VP9\n * `profile-id`, AV1 `profile`, H264 `packetization-mode` /\n * `profile-level-id`, Opus parameters, ...);\n * 2. a compatible one (`isCodecCompatible`: the same format-identifying\n * parameters, H264 mode / profile, VP9 / AV1 profile, where an omitted\n * one matches any value);\n * 3. one of the same MIME type (`negotiatesAs`, for instance an H264 of\n * another level or a VP9 of another profile).\n *\n * So when the configured codecs hold several formats of one MIME type (H264\n * mode 0 and mode 1, VP9 profile 0 and profile 2), each pairs with its own\n * format whatever the order, and an answer does not switch the format the\n * offer meant. RTX / RED are not paired. `accept` limits the candidates (a\n * fixed track source).\n */\nexport function pairCodecs(\n configured: readonly RTCRtpCodecParameters[],\n others: readonly RTCRtpCodecParameters[],\n accept: (\n configured: RTCRtpCodecParameters,\n other: RTCRtpCodecParameters,\n ) => boolean = () => true,\n): Map<RTCRtpCodecParameters, RTCRtpCodecParameters> {\n const pairs = new Map<RTCRtpCodecParameters, RTCRtpCodecParameters>();\n const used = new Set<RTCRtpCodecParameters>();\n const passes = [\n sameFormat,\n (codec: RTCRtpCodecParameters, other: RTCRtpCodecParameters) =>\n isCodecCompatible(other, codec),\n negotiatesAs,\n ];\n for (const matches of passes) {\n for (const codec of configured) {\n if (isAuxiliary(codec) || pairs.has(codec)) continue;\n const other = others.find(\n (candidate) =>\n !isAuxiliary(candidate) &&\n !used.has(candidate) &&\n matches(codec, candidate) &&\n accept(codec, candidate),\n );\n if (!other) continue;\n pairs.set(codec, other);\n used.add(other);\n }\n }\n return pairs;\n}\n\nfunction isAuxiliary(codec: RTCRtpCodecParameters) {\n return [\"rtx\", \"red\"].includes(codecName(codec));\n}\n\n/**\n * remote track が実際に配信する codec を返す。\n * audio の RED は RTCRtpReceiver が primary へ展開してから track へ渡すため、\n * RED が参照する primary codec (不明なら先頭の primary) を track の codec とする。\n */\nexport function deliveredTrackCodec(\n kind: string,\n codec: RTCRtpCodecParameters | undefined,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n if (kind !== \"audio\" || codec == undefined || codecName(codec) !== \"red\") {\n return codec;\n }\n const [primaryPayloadType] = referencedPayloadTypes(codec);\n return (\n negotiated.find(\n (candidate) =>\n !isAuxiliary(candidate) && candidate.payloadType === primaryPayloadType,\n ) ??\n negotiated.find((candidate) => !isAuxiliary(candidate)) ??\n codec\n );\n}\n\n/**\n * 交渉済み codec 列から remote track の codec を決める。\n * 先頭の RTX (と video の RED / FEC) は飛ばし、audio の RED は\n * {@link deliveredTrackCodec} と同じく primary へ解決する。\n */\nexport function primaryTrackCodec(\n kind: string,\n negotiated: readonly RTCRtpCodecParameters[],\n) {\n const first =\n negotiated.find((codec) =>\n kind === \"audio\"\n ? codecName(codec) !== \"rtx\"\n : !isAuxiliary(codec) &&\n ![\"ulpfec\", \"flexfec-03\"].includes(codecName(codec)),\n ) ?? negotiated[0];\n return deliveredTrackCodec(kind, first, negotiated);\n}\n\n/**\n * RTX / RED を除く primary codec に MIME 一致が 1 つでもあるか。\n * remote m-line を local capability で扱えるかの判定 (Issue #705) に使う。\n */\nexport function hasCommonPrimaryMimeType(\n local: readonly RTCRtpCodecParameters[],\n remote: readonly RTCRtpCodecParameters[],\n) {\n return local.some(\n (localCodec) =>\n !isAuxiliary(localCodec) &&\n remote.some(\n (remoteCodec) =>\n normalizeCodecMimeType(remoteCodec.mimeType) ===\n normalizeCodecMimeType(localCodec.mimeType),\n ),\n );\n}\n\nfunction referencedPayloadTypes(codec: RTCRtpCodecParameters) {\n const parameters = codec.parameters ?? \"\";\n if (codecName(codec) === \"rtx\") {\n const apt = Number(codecParametersFromString(parameters).apt);\n return Number.isNaN(apt) ? [] : [apt];\n }\n if (codecName(codec) === \"red\") {\n // `Number(\"\")` is 0: a RED without fmtp references nothing.\n return parameters\n .split(\"/\")\n .filter((value) => value.trim() !== \"\")\n .map(Number)\n .filter((value) => !Number.isNaN(value));\n }\n return [];\n}\n\nfunction withAuxiliaryCodecs(\n configured: RTCRtpCodecParameters[],\n primary: RTCRtpCodecParameters[],\n) {\n const keptPayloadTypes = new Set(primary.map((codec) => codec.payloadType));\n const auxiliary = configured.filter((codec) => {\n if (!isAuxiliary(codec)) return false;\n const referenced = referencedPayloadTypes(codec);\n return (\n referenced.length > 0 &&\n referenced.every((payloadType) => keptPayloadTypes.has(payloadType))\n );\n });\n return configured.filter(\n (codec) => primary.includes(codec) || auxiliary.includes(codec),\n );\n}\n\nexport function intersectCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[],\n) {\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n source.some((sourceCodec) => isCodecCompatible(sourceCodec, codec)),\n );\n return withAuxiliaryCodecs(configured, primary);\n}\n\nfunction matchesPreference(\n candidate: RTCRtpCodecParameters,\n preference: RTCRtpCodecParameters,\n) {\n return (\n normalizeCodecMimeType(candidate.mimeType) ===\n normalizeCodecMimeType(preference.mimeType) &&\n optionalEqual(candidate.clockRate, preference.clockRate)\n );\n}\n\nexport function applyCodecPreferences(\n configured: RTCRtpCodecParameters[],\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n if (preferences == undefined) return configured;\n const preferred = preferences.flatMap((preference) => {\n const match = configured.find((codec) =>\n matchesPreference(codec, preference),\n );\n return match ? [match] : [];\n });\n const uniquePreferred = [...new Set(preferred)];\n const referencedByPreferredAuxiliary = new Set(\n uniquePreferred.filter(isAuxiliary).flatMap(referencedPayloadTypes),\n );\n const primary = configured.filter(\n (codec) =>\n !isAuxiliary(codec) &&\n (uniquePreferred.includes(codec) ||\n referencedByPreferredAuxiliary.has(codec.payloadType)),\n );\n const allowed = withAuxiliaryCodecs(configured, primary);\n return [\n ...uniquePreferred.filter((codec) => allowed.includes(codec)),\n ...allowed.filter((codec) => !uniquePreferred.includes(codec)),\n ];\n}\n\nexport function resolveCodecs(\n configured: RTCRtpCodecParameters[],\n source: readonly RTCRtpCodecParameters[] | undefined,\n preferences: readonly RTCRtpCodecParameters[] | undefined,\n) {\n return applyCodecPreferences(\n source == undefined ? configured : intersectCodecs(configured, source),\n preferences,\n );\n}\n\nfunction list(codecs: readonly RTCRtpCodecParameters[] | undefined) {\n return codecs?.map((codec) => codec.mimeType).join(\", \") || \"(none)\";\n}\n\nexport function assertCodecsSupported(options: {\n kind: Kind;\n configured: RTCRtpCodecParameters[];\n source: readonly RTCRtpCodecParameters[] | undefined;\n preferences: readonly RTCRtpCodecParameters[] | undefined;\n}) {\n const { kind, configured, source, preferences } = options;\n const sourceCompatible =\n source == undefined ? configured : intersectCodecs(configured, source);\n if (source != undefined && sourceCompatible.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `Track codec ${list(source)} is not supported by this RTCPeerConnection. Configured ${kind} codecs: ${list(configured)}`,\n );\n }\n const effective = applyCodecPreferences(sourceCompatible, preferences);\n if (effective.length === 0) {\n throw createWebRtcDomException(\n \"NotSupportedError\",\n `No codec remains after applying codec preferences. Source codecs: ${list(source)} Configured codecs: ${list(configured)} Preferred codecs: ${list(preferences)}`,\n );\n }\n return effective;\n}\n\n/**\n * Configured codecs a negotiated m-line offers, before payload types are\n * mapped (`keepNegotiatedPayloadTypes`): `capability` plus the configured\n * counterpart (`pairCodecs`, the rule negotiation pairs by) of every\n * negotiated codec that `capability` lacks.\n *\n * `eligible` is every configured codec of the kind with the fixed source and\n * the codec preferences applied but no direction filter, and `capability` is\n * the same for the current direction. A direction change (`direction`,\n * `removeTrack()`) therefore never takes a negotiated codec off the m-line;\n * only an answer does. Preferences and a fixed source still exclude one. An\n * RTX / RED is kept when its primaries are and it is in `capability` or\n * negotiated for the same primaries. The order is that of `eligible`\n * (preferences, then configuration), the order of a first offer.\n */\nexport function withNegotiatedCodecs(\n eligible: readonly RTCRtpCodecParameters[],\n capability: readonly RTCRtpCodecParameters[],\n negotiated: readonly RTCRtpCodecParameters[],\n): RTCRtpCodecParameters[] {\n const candidates = [\n ...eligible,\n ...capability.filter((codec) => !eligible.includes(codec)),\n ];\n const primaryOf = (\n codecs: readonly RTCRtpCodecParameters[],\n payloadType: number,\n ) =>\n codecs.find(\n (codec) => !isAuxiliary(codec) && codec.payloadType === payloadType,\n );\n const pairs = pairCodecs(candidates, negotiated);\n const kept = new Set(\n candidates.filter(\n (codec) =>\n !isAuxiliary(codec) && (capability.includes(codec) || pairs.has(codec)),\n ),\n );\n const negotiatedForSamePrimaries = (codec: RTCRtpCodecParameters) => {\n const primaries = referencedPayloadTypes(codec).map((payloadType) =>\n primaryOf(candidates, payloadType),\n );\n return negotiated.some((other) => {\n if (codecName(other) !== codecName(codec)) return false;\n const otherPrimaries = referencedPayloadTypes(other).map((payloadType) =>\n primaryOf(negotiated, payloadType),\n );\n return (\n otherPrimaries.length === primaries.length &&\n primaries.every((primary, index) => {\n const otherPrimary = otherPrimaries[index];\n return (\n primary != undefined &&\n otherPrimary != undefined &&\n pairs.get(primary) === otherPrimary\n );\n })\n );\n });\n };\n return candidates.filter((codec) => {\n if (!isAuxiliary(codec)) return kept.has(codec);\n const primaries = referencedPayloadTypes(codec).map((payloadType) =>\n primaryOf(candidates, payloadType),\n );\n if (primaries.some((primary) => primary == undefined || !kept.has(primary)))\n return false;\n return capability.includes(codec) || negotiatedForSamePrimaries(codec);\n });\n}\n\n/**\n * The format parameters (`a=fmtp`) a payload type stands for, in a form that\n * compares equal when the parameters mean the same: parameter names are\n * case-insensitive and unordered, and H264 gets its RFC 6184 §8.1 defaults\n * (`packetization-mode` 0, `profile-level-id` 42000A, case-insensitive), so\n * an omitted parameter and its default are the same format. Anything else\n * (an RTX `apt`, the primaries of a RED `110/110`) is compared as written.\n */\nfunction formatParameters(codec: RTCRtpCodecParameters) {\n const entries = new Map<string, string>();\n for (const item of (codec.parameters ?? \"\").split(\";\")) {\n const parameter = item.trim();\n if (parameter.length === 0) continue;\n const separator = parameter.indexOf(\"=\");\n if (separator < 0) {\n entries.set(parameter, \"\");\n continue;\n }\n entries.set(\n parameter.slice(0, separator).trim().toLowerCase(),\n parameter.slice(separator + 1).trim(),\n );\n }\n if (codecName(codec) === \"h264\") {\n entries.set(\"packetization-mode\", entries.get(\"packetization-mode\") ?? \"0\");\n entries.set(\n \"profile-level-id\",\n (entries.get(\"profile-level-id\") ?? \"42000a\").toLowerCase(),\n );\n }\n return [...entries]\n .map(([name, value]) => `${name}=${value}`)\n .sort()\n .join(\";\");\n}\n\n/**\n * The RTCP feedback (`a=rtcp-fb`) a payload type stands for, unordered and\n * without duplicates, with the type and parameter compared case-insensitively.\n */\nfunction feedbackTypes(codec: RTCRtpCodecParameters) {\n return [\n ...new Set(\n codec.rtcpFeedback.map((feedback) =>\n `${feedback.type} ${feedback.parameter ?? \"\"}`.trim().toLowerCase(),\n ),\n ),\n ]\n .sort()\n .join(\";\");\n}\n\n/**\n * Whether two codecs can share a payload type in one BUNDLE group (RFC 3264\n * §8.3.2, RFC 8843 §9.1): the same codec with the same format parameters and\n * RTCP feedback, the attributes RFC 8859 puts in the IDENTICAL-PER-PT\n * category (`a=fmtp`, `a=rtcp-fb`). So an H264 format with another\n * `packetization-mode` or `profile-level-id`, an RTX for another `apt`, a RED\n * with other primaries or a VP8 with other feedback is another codec.\n */\nfunction samePayloadMapping(\n left: RTCRtpCodecParameters,\n right: RTCRtpCodecParameters,\n) {\n return (\n sameFormat(left, right) && feedbackTypes(left) === feedbackTypes(right)\n );\n}\n\n/**\n * The same media format (`a=rtpmap` and `a=fmtp`, RFC 4566): MIME type,\n * clock rate, channels and the format parameters (`formatParameters`), for\n * every codec. RTCP feedback is not part of the format.\n */\nfunction sameFormat(left: RTCRtpCodecParameters, right: RTCRtpCodecParameters) {\n return (\n normalizeCodecMimeType(left.mimeType) ===\n normalizeCodecMimeType(right.mimeType) &&\n left.clockRate === right.clockRate &&\n (left.channels ?? 1) === (right.channels ?? 1) &&\n formatParameters(left) === formatParameters(right)\n );\n}\n\nfunction withPayloadType(\n codec: RTCRtpCodecParameters,\n payloadType: number,\n parameters = codec.parameters,\n) {\n if (codec.payloadType === payloadType && codec.parameters === parameters) {\n return codec;\n }\n const next = new RTCRtpCodecParameters({\n mimeType: codec.mimeType,\n clockRate: codec.clockRate,\n ...(codec.channels != undefined ? { channels: codec.channels } : {}),\n payloadType,\n rtcpFeedback: codec.rtcpFeedback.map((feedback) => ({ ...feedback })),\n ...(parameters != undefined ? { parameters } : {}),\n direction: codec.direction,\n });\n return next;\n}\n\n/**\n * Offer codecs for a negotiated m-line (RFC 8829 §5.2.2, RFC 3264 §8.3.2):\n * `capability` (configured codecs, in offer order) with each configured codec\n * that is already negotiated replaced by the negotiated codec itself, so its\n * payload type, fmtp and rtcp-fb stay as negotiated (also when the remote's\n * form differs from the configured one). Configured and negotiated codecs\n * pair as negotiation pairs them (`pairCodecs`: the same format first, then\n * the same MIME type). Another format of a negotiated MIME type that the\n * answer left out (H264 mode 1 next to a negotiated mode 0) is offered again\n * like any other codec, so a later answer can move to it; an answer that\n * still has the negotiated format pairs with it, since negotiation prefers\n * the same format. A negotiated RTX / RED for the offered primaries is\n * offered as negotiated too.\n *\n * A codec offered again keeps its configured payload type unless that type is\n * already used on this m-line or maps to another codec in `taken` (every\n * payload type the session uses; the same codec with other format parameters\n * or RTCP feedback, such as a RED with other primaries, is another codec);\n * then it takes a free dynamic type (96-127,\n * then 35-63). RTX `apt` and RED references follow their primaries, and an\n * RTX / RED whose primary is not offered is dropped. The order of\n * `capability` is kept.\n */\nexport function keepNegotiatedPayloadTypes(\n capability: readonly RTCRtpCodecParameters[],\n negotiated: readonly RTCRtpCodecParameters[],\n taken: ReadonlyMap<number, RTCRtpCodecParameters>,\n): RTCRtpCodecParameters[] {\n const offered: (RTCRtpCodecParameters | undefined)[] = capability.map(\n () => undefined,\n );\n const used = new Set<number>();\n const primaryPayloadType = new Map<number, number>();\n const matched = new Set<RTCRtpCodecParameters>();\n const isFree = (payloadType: number, codec: RTCRtpCodecParameters) => {\n if (used.has(payloadType)) return false;\n const owner = taken.get(payloadType);\n return owner == undefined || samePayloadMapping(owner, codec);\n };\n const pick = (preferred: number, codec: RTCRtpCodecParameters) => {\n if (isFree(preferred, codec)) return preferred;\n for (const [from, to] of [\n [96, 127],\n [35, 63],\n ]) {\n for (let payloadType = from; payloadType <= to; payloadType++) {\n if (isFree(payloadType, codec)) return payloadType;\n }\n }\n return undefined;\n };\n const place = (index: number, codec: RTCRtpCodecParameters) => {\n offered[index] = codec;\n used.add(codec.payloadType);\n };\n\n // 1. Negotiated primaries are offered as negotiated (payload type, fmtp,\n // rtcp-fb), each in place of the configured codec it pairs with\n // (`pairCodecs`: the same format first, then the same MIME type).\n for (const [codec, match] of pairCodecs(capability, negotiated)) {\n if (used.has(match.payloadType)) continue;\n matched.add(match);\n primaryPayloadType.set(codec.payloadType, match.payloadType);\n place(capability.indexOf(codec), match);\n }\n // 2. Primaries offered again.\n capability.forEach((codec, index) => {\n if (isAuxiliary(codec) || offered[index]) return;\n const payloadType = pick(codec.payloadType, codec);\n if (payloadType == undefined) return;\n primaryPayloadType.set(codec.payloadType, payloadType);\n place(index, withPayloadType(codec, payloadType));\n });\n // 3. RTX / RED follow their primaries.\n capability.forEach((codec, index) => {\n if (!isAuxiliary(codec)) return;\n const references = referencedPayloadTypes(codec).map((payloadType) =>\n primaryPayloadType.get(payloadType),\n );\n // A video RED has no fmtp (nothing references a primary): it is offered\n // as configured. An RTX, or a RED that names primaries, needs them offered.\n const standalone = codecName(codec) === \"red\" && references.length === 0;\n if (\n !standalone &&\n (references.length === 0 ||\n references.some((payloadType) => payloadType == undefined))\n ) {\n return;\n }\n const parameters = standalone\n ? codec.parameters\n : codecName(codec) === \"rtx\"\n ? (codec.parameters ?? \"\").replace(\n /(^|;)\\s*apt=\\d+/,\n `$1apt=${references[0]}`,\n )\n : references.join(\"/\");\n // The RTX / RED negotiated for these primaries is offered as negotiated.\n const negotiatedAuxiliary = negotiated.find(\n (other) =>\n codecName(other) === codecName(codec) &&\n !matched.has(other) &&\n !used.has(other.payloadType) &&\n (codecName(codec) === \"rtx\"\n ? referencedPayloadTypes(other)[0] === references[0]\n : (other.parameters ?? \"\") === (parameters ?? \"\")),\n );\n if (negotiatedAuxiliary) {\n matched.add(negotiatedAuxiliary);\n place(index, negotiatedAuxiliary);\n return;\n }\n const candidate = withPayloadType(codec, codec.payloadType, parameters);\n const payloadType = pick(codec.payloadType, candidate);\n if (payloadType == undefined) return;\n place(index, withPayloadType(candidate, payloadType));\n });\n return offered.filter((codec) => codec != undefined);\n}\n"]}
|
|
@@ -8,5 +8,15 @@ export * from "./router";
|
|
|
8
8
|
export * from "./rtpReceiver";
|
|
9
9
|
export * from "./rtpSender";
|
|
10
10
|
export * from "./rtpTransceiver";
|
|
11
|
+
export type { BandwidthEstimator, BandwidthEstimatorProcessor, CongestionEventsCompatibility, NetworkAvailabilityConsumer, ProbeClusterConfig, ProbePacingController, ProbeReservation, RoundTripTimeConsumer, SentInfo, } from "./sender/bandwidthEstimator";
|
|
12
|
+
export { BandwidthEstimatorNoopHooks, isBandwidthEstimatorProcessor, isNetworkAvailabilityConsumer, isProbePacingController, isRoundTripTimeConsumer, setAvailableBitrateIfChanged, } from "./sender/bandwidthEstimator";
|
|
13
|
+
export type { BandwidthEstimatorOption, BandwidthEstimatorPreset, } from "./sender/createBandwidthEstimator";
|
|
14
|
+
export { createBandwidthEstimator } from "./sender/createBandwidthEstimator";
|
|
15
|
+
export { DisabledBandwidthEstimator } from "./sender/estimators/disabledBwe";
|
|
16
|
+
export type { AckedPacketSample, BandwidthLimitedCause, BandwidthUsage, GccBandwidthEstimatorOptions, GccClock, LossBasedResult, LossBasedState, ProbeState, } from "./sender/estimators/gcc";
|
|
17
|
+
export { AcknowledgedBitrateEstimator, AimdRateControl, AlrDetector, BitrateEstimator, computeFeedbackRttStats, GCC_KNOWN_DIFFERENCES, GccBandwidthEstimator, getBandwidthLimitedCause, InterArrivalDelta, IntervalBudget, isProbeInitiationAllowed, isRttAboveLimit, kAlrProbeScale, kAlrProbingIntervalMs, kBeta, kDefaultMaxProbingBitrateBps, kDefaultPaceMultiplier, kDefaultPaceMultiplierWithSendSideBwe, kDefaultStartBitrateBps, kGoogCcProcessIntervalMs, kInitialMinProbeDeltaMs, kLossBasedIncreaseFactor, kLossBasedMedianSendingRateFactor, kLossBasedNotUseAckedRateInAlr, kLossBasedPaddingDurationMs, kLossDecreaseThreshold, kLossIncreaseFactor, kLossIncreaseThreshold, kLossLimitedProbeScale, kMaxBitrateBps, kMaxProbeDelayMs, kMinBitrateBps, kMinProbeDeltaMs, kProbeFractionAfterDrop, kProbePaddingPacketBytes, kRttBasedBackOffBandwidthFloorBps, kRttBasedBackOffDropFraction, kRttBasedBackOffDropIntervalMs, kRttBasedBackOffHighRttMs, kSendTimeHistoryWindowMs, kStartPhaseLossReportMinPackets, kStartPhaseMs, kTrendlineWindowSize, LinkCapacityEstimator, LossBasedBwe, maxProbeBitrateBps, ProbeController, RttBasedBackoff, TrendlineEstimator, } from "./sender/estimators/gcc";
|
|
18
|
+
export { isLightweightBandwidthEstimator, LightweightBandwidthEstimator, SenderBandwidthEstimator, } from "./sender/estimators/lightweightBwe";
|
|
19
|
+
export type { TwccPacketFeedback } from "./sender/estimators/twccFeedbackAdapter";
|
|
20
|
+
export { kTwccFeedbackHistoryMaxSeqSpan, TwccFeedbackAdapter, } from "./sender/estimators/twccFeedbackAdapter";
|
|
11
21
|
export * from "./stats";
|
|
12
22
|
export * from "./track";
|
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.kStartPhaseMs = exports.kStartPhaseLossReportMinPackets = exports.kSendTimeHistoryWindowMs = exports.kRttBasedBackOffHighRttMs = exports.kRttBasedBackOffDropIntervalMs = exports.kRttBasedBackOffDropFraction = exports.kRttBasedBackOffBandwidthFloorBps = exports.kProbePaddingPacketBytes = exports.kProbeFractionAfterDrop = exports.kMinProbeDeltaMs = exports.kMinBitrateBps = exports.kMaxProbeDelayMs = exports.kMaxBitrateBps = exports.kLossLimitedProbeScale = exports.kLossIncreaseThreshold = exports.kLossIncreaseFactor = exports.kLossDecreaseThreshold = exports.kLossBasedPaddingDurationMs = exports.kLossBasedNotUseAckedRateInAlr = exports.kLossBasedMedianSendingRateFactor = exports.kLossBasedIncreaseFactor = exports.kInitialMinProbeDeltaMs = exports.kGoogCcProcessIntervalMs = exports.kDefaultStartBitrateBps = exports.kDefaultPaceMultiplierWithSendSideBwe = exports.kDefaultPaceMultiplier = exports.kDefaultMaxProbingBitrateBps = exports.kBeta = exports.kAlrProbingIntervalMs = exports.kAlrProbeScale = exports.isRttAboveLimit = exports.isProbeInitiationAllowed = exports.IntervalBudget = exports.InterArrivalDelta = exports.getBandwidthLimitedCause = exports.GccBandwidthEstimator = exports.GCC_KNOWN_DIFFERENCES = exports.computeFeedbackRttStats = exports.BitrateEstimator = exports.AlrDetector = exports.AimdRateControl = exports.AcknowledgedBitrateEstimator = exports.DisabledBandwidthEstimator = exports.createBandwidthEstimator = exports.setAvailableBitrateIfChanged = exports.isRoundTripTimeConsumer = exports.isProbePacingController = exports.isNetworkAvailabilityConsumer = exports.isBandwidthEstimatorProcessor = exports.BandwidthEstimatorNoopHooks = void 0;
|
|
18
|
+
exports.TwccFeedbackAdapter = exports.kTwccFeedbackHistoryMaxSeqSpan = exports.SenderBandwidthEstimator = exports.LightweightBandwidthEstimator = exports.isLightweightBandwidthEstimator = exports.TrendlineEstimator = exports.RttBasedBackoff = exports.ProbeController = exports.maxProbeBitrateBps = exports.LossBasedBwe = exports.LinkCapacityEstimator = exports.kTrendlineWindowSize = void 0;
|
|
17
19
|
__exportStar(require("../transceiverManager"), exports);
|
|
18
20
|
__exportStar(require("./codec"), exports);
|
|
19
21
|
__exportStar(require("./codecCompatibility"), exports);
|
|
@@ -24,6 +26,74 @@ __exportStar(require("./router"), exports);
|
|
|
24
26
|
__exportStar(require("./rtpReceiver"), exports);
|
|
25
27
|
__exportStar(require("./rtpSender"), exports);
|
|
26
28
|
__exportStar(require("./rtpTransceiver"), exports);
|
|
29
|
+
var bandwidthEstimator_1 = require("./sender/bandwidthEstimator");
|
|
30
|
+
Object.defineProperty(exports, "BandwidthEstimatorNoopHooks", { enumerable: true, get: function () { return bandwidthEstimator_1.BandwidthEstimatorNoopHooks; } });
|
|
31
|
+
Object.defineProperty(exports, "isBandwidthEstimatorProcessor", { enumerable: true, get: function () { return bandwidthEstimator_1.isBandwidthEstimatorProcessor; } });
|
|
32
|
+
Object.defineProperty(exports, "isNetworkAvailabilityConsumer", { enumerable: true, get: function () { return bandwidthEstimator_1.isNetworkAvailabilityConsumer; } });
|
|
33
|
+
Object.defineProperty(exports, "isProbePacingController", { enumerable: true, get: function () { return bandwidthEstimator_1.isProbePacingController; } });
|
|
34
|
+
Object.defineProperty(exports, "isRoundTripTimeConsumer", { enumerable: true, get: function () { return bandwidthEstimator_1.isRoundTripTimeConsumer; } });
|
|
35
|
+
Object.defineProperty(exports, "setAvailableBitrateIfChanged", { enumerable: true, get: function () { return bandwidthEstimator_1.setAvailableBitrateIfChanged; } });
|
|
36
|
+
var createBandwidthEstimator_1 = require("./sender/createBandwidthEstimator");
|
|
37
|
+
Object.defineProperty(exports, "createBandwidthEstimator", { enumerable: true, get: function () { return createBandwidthEstimator_1.createBandwidthEstimator; } });
|
|
38
|
+
var disabledBwe_1 = require("./sender/estimators/disabledBwe");
|
|
39
|
+
Object.defineProperty(exports, "DisabledBandwidthEstimator", { enumerable: true, get: function () { return disabledBwe_1.DisabledBandwidthEstimator; } });
|
|
40
|
+
var gcc_1 = require("./sender/estimators/gcc");
|
|
41
|
+
Object.defineProperty(exports, "AcknowledgedBitrateEstimator", { enumerable: true, get: function () { return gcc_1.AcknowledgedBitrateEstimator; } });
|
|
42
|
+
Object.defineProperty(exports, "AimdRateControl", { enumerable: true, get: function () { return gcc_1.AimdRateControl; } });
|
|
43
|
+
Object.defineProperty(exports, "AlrDetector", { enumerable: true, get: function () { return gcc_1.AlrDetector; } });
|
|
44
|
+
Object.defineProperty(exports, "BitrateEstimator", { enumerable: true, get: function () { return gcc_1.BitrateEstimator; } });
|
|
45
|
+
Object.defineProperty(exports, "computeFeedbackRttStats", { enumerable: true, get: function () { return gcc_1.computeFeedbackRttStats; } });
|
|
46
|
+
Object.defineProperty(exports, "GCC_KNOWN_DIFFERENCES", { enumerable: true, get: function () { return gcc_1.GCC_KNOWN_DIFFERENCES; } });
|
|
47
|
+
Object.defineProperty(exports, "GccBandwidthEstimator", { enumerable: true, get: function () { return gcc_1.GccBandwidthEstimator; } });
|
|
48
|
+
Object.defineProperty(exports, "getBandwidthLimitedCause", { enumerable: true, get: function () { return gcc_1.getBandwidthLimitedCause; } });
|
|
49
|
+
Object.defineProperty(exports, "InterArrivalDelta", { enumerable: true, get: function () { return gcc_1.InterArrivalDelta; } });
|
|
50
|
+
Object.defineProperty(exports, "IntervalBudget", { enumerable: true, get: function () { return gcc_1.IntervalBudget; } });
|
|
51
|
+
Object.defineProperty(exports, "isProbeInitiationAllowed", { enumerable: true, get: function () { return gcc_1.isProbeInitiationAllowed; } });
|
|
52
|
+
Object.defineProperty(exports, "isRttAboveLimit", { enumerable: true, get: function () { return gcc_1.isRttAboveLimit; } });
|
|
53
|
+
Object.defineProperty(exports, "kAlrProbeScale", { enumerable: true, get: function () { return gcc_1.kAlrProbeScale; } });
|
|
54
|
+
Object.defineProperty(exports, "kAlrProbingIntervalMs", { enumerable: true, get: function () { return gcc_1.kAlrProbingIntervalMs; } });
|
|
55
|
+
Object.defineProperty(exports, "kBeta", { enumerable: true, get: function () { return gcc_1.kBeta; } });
|
|
56
|
+
Object.defineProperty(exports, "kDefaultMaxProbingBitrateBps", { enumerable: true, get: function () { return gcc_1.kDefaultMaxProbingBitrateBps; } });
|
|
57
|
+
Object.defineProperty(exports, "kDefaultPaceMultiplier", { enumerable: true, get: function () { return gcc_1.kDefaultPaceMultiplier; } });
|
|
58
|
+
Object.defineProperty(exports, "kDefaultPaceMultiplierWithSendSideBwe", { enumerable: true, get: function () { return gcc_1.kDefaultPaceMultiplierWithSendSideBwe; } });
|
|
59
|
+
Object.defineProperty(exports, "kDefaultStartBitrateBps", { enumerable: true, get: function () { return gcc_1.kDefaultStartBitrateBps; } });
|
|
60
|
+
Object.defineProperty(exports, "kGoogCcProcessIntervalMs", { enumerable: true, get: function () { return gcc_1.kGoogCcProcessIntervalMs; } });
|
|
61
|
+
Object.defineProperty(exports, "kInitialMinProbeDeltaMs", { enumerable: true, get: function () { return gcc_1.kInitialMinProbeDeltaMs; } });
|
|
62
|
+
Object.defineProperty(exports, "kLossBasedIncreaseFactor", { enumerable: true, get: function () { return gcc_1.kLossBasedIncreaseFactor; } });
|
|
63
|
+
Object.defineProperty(exports, "kLossBasedMedianSendingRateFactor", { enumerable: true, get: function () { return gcc_1.kLossBasedMedianSendingRateFactor; } });
|
|
64
|
+
Object.defineProperty(exports, "kLossBasedNotUseAckedRateInAlr", { enumerable: true, get: function () { return gcc_1.kLossBasedNotUseAckedRateInAlr; } });
|
|
65
|
+
Object.defineProperty(exports, "kLossBasedPaddingDurationMs", { enumerable: true, get: function () { return gcc_1.kLossBasedPaddingDurationMs; } });
|
|
66
|
+
Object.defineProperty(exports, "kLossDecreaseThreshold", { enumerable: true, get: function () { return gcc_1.kLossDecreaseThreshold; } });
|
|
67
|
+
Object.defineProperty(exports, "kLossIncreaseFactor", { enumerable: true, get: function () { return gcc_1.kLossIncreaseFactor; } });
|
|
68
|
+
Object.defineProperty(exports, "kLossIncreaseThreshold", { enumerable: true, get: function () { return gcc_1.kLossIncreaseThreshold; } });
|
|
69
|
+
Object.defineProperty(exports, "kLossLimitedProbeScale", { enumerable: true, get: function () { return gcc_1.kLossLimitedProbeScale; } });
|
|
70
|
+
Object.defineProperty(exports, "kMaxBitrateBps", { enumerable: true, get: function () { return gcc_1.kMaxBitrateBps; } });
|
|
71
|
+
Object.defineProperty(exports, "kMaxProbeDelayMs", { enumerable: true, get: function () { return gcc_1.kMaxProbeDelayMs; } });
|
|
72
|
+
Object.defineProperty(exports, "kMinBitrateBps", { enumerable: true, get: function () { return gcc_1.kMinBitrateBps; } });
|
|
73
|
+
Object.defineProperty(exports, "kMinProbeDeltaMs", { enumerable: true, get: function () { return gcc_1.kMinProbeDeltaMs; } });
|
|
74
|
+
Object.defineProperty(exports, "kProbeFractionAfterDrop", { enumerable: true, get: function () { return gcc_1.kProbeFractionAfterDrop; } });
|
|
75
|
+
Object.defineProperty(exports, "kProbePaddingPacketBytes", { enumerable: true, get: function () { return gcc_1.kProbePaddingPacketBytes; } });
|
|
76
|
+
Object.defineProperty(exports, "kRttBasedBackOffBandwidthFloorBps", { enumerable: true, get: function () { return gcc_1.kRttBasedBackOffBandwidthFloorBps; } });
|
|
77
|
+
Object.defineProperty(exports, "kRttBasedBackOffDropFraction", { enumerable: true, get: function () { return gcc_1.kRttBasedBackOffDropFraction; } });
|
|
78
|
+
Object.defineProperty(exports, "kRttBasedBackOffDropIntervalMs", { enumerable: true, get: function () { return gcc_1.kRttBasedBackOffDropIntervalMs; } });
|
|
79
|
+
Object.defineProperty(exports, "kRttBasedBackOffHighRttMs", { enumerable: true, get: function () { return gcc_1.kRttBasedBackOffHighRttMs; } });
|
|
80
|
+
Object.defineProperty(exports, "kSendTimeHistoryWindowMs", { enumerable: true, get: function () { return gcc_1.kSendTimeHistoryWindowMs; } });
|
|
81
|
+
Object.defineProperty(exports, "kStartPhaseLossReportMinPackets", { enumerable: true, get: function () { return gcc_1.kStartPhaseLossReportMinPackets; } });
|
|
82
|
+
Object.defineProperty(exports, "kStartPhaseMs", { enumerable: true, get: function () { return gcc_1.kStartPhaseMs; } });
|
|
83
|
+
Object.defineProperty(exports, "kTrendlineWindowSize", { enumerable: true, get: function () { return gcc_1.kTrendlineWindowSize; } });
|
|
84
|
+
Object.defineProperty(exports, "LinkCapacityEstimator", { enumerable: true, get: function () { return gcc_1.LinkCapacityEstimator; } });
|
|
85
|
+
Object.defineProperty(exports, "LossBasedBwe", { enumerable: true, get: function () { return gcc_1.LossBasedBwe; } });
|
|
86
|
+
Object.defineProperty(exports, "maxProbeBitrateBps", { enumerable: true, get: function () { return gcc_1.maxProbeBitrateBps; } });
|
|
87
|
+
Object.defineProperty(exports, "ProbeController", { enumerable: true, get: function () { return gcc_1.ProbeController; } });
|
|
88
|
+
Object.defineProperty(exports, "RttBasedBackoff", { enumerable: true, get: function () { return gcc_1.RttBasedBackoff; } });
|
|
89
|
+
Object.defineProperty(exports, "TrendlineEstimator", { enumerable: true, get: function () { return gcc_1.TrendlineEstimator; } });
|
|
90
|
+
var lightweightBwe_1 = require("./sender/estimators/lightweightBwe");
|
|
91
|
+
Object.defineProperty(exports, "isLightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.isLightweightBandwidthEstimator; } });
|
|
92
|
+
Object.defineProperty(exports, "LightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.LightweightBandwidthEstimator; } });
|
|
93
|
+
Object.defineProperty(exports, "SenderBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.SenderBandwidthEstimator; } });
|
|
94
|
+
var twccFeedbackAdapter_1 = require("./sender/estimators/twccFeedbackAdapter");
|
|
95
|
+
Object.defineProperty(exports, "kTwccFeedbackHistoryMaxSeqSpan", { enumerable: true, get: function () { return twccFeedbackAdapter_1.kTwccFeedbackHistoryMaxSeqSpan; } });
|
|
96
|
+
Object.defineProperty(exports, "TwccFeedbackAdapter", { enumerable: true, get: function () { return twccFeedbackAdapter_1.TwccFeedbackAdapter; } });
|
|
27
97
|
__exportStar(require("./stats"), exports);
|
|
28
98
|
__exportStar(require("./track"), exports);
|
|
29
99
|
//# sourceMappingURL=index.js.map
|