werift 0.25.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/asn1.d.ts +42 -0
- package/lib/common/src/asn1.js +163 -0
- package/lib/common/src/asn1.js.map +1 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/index.d.ts +6 -5
- package/lib/common/src/index.js +6 -5
- package/lib/common/src/index.js.map +1 -1
- package/lib/common/src/log.d.ts +12 -1
- package/lib/common/src/log.js +142 -12
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/queue.d.ts +41 -0
- package/lib/common/src/queue.js +146 -0
- package/lib/common/src/queue.js.map +1 -0
- package/lib/common/src/transport.d.ts +15 -2
- package/lib/common/src/transport.js +108 -19
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/cipher/create.js.map +1 -1
- package/lib/dtls/src/cipher/ec.js +8 -8
- package/lib/dtls/src/cipher/ec.js.map +1 -1
- package/lib/dtls/src/cipher/namedCurve.js +6 -7
- package/lib/dtls/src/cipher/namedCurve.js.map +1 -1
- package/lib/dtls/src/cipher/prf.d.ts +2 -2
- package/lib/dtls/src/cipher/prf.js +29 -8
- package/lib/dtls/src/cipher/prf.js.map +1 -1
- package/lib/dtls/src/cipher/suites/aead.d.ts +1 -1
- package/lib/dtls/src/context/certificate.d.ts +32 -0
- package/lib/dtls/src/context/certificate.js +54 -0
- package/lib/dtls/src/context/certificate.js.map +1 -0
- package/lib/dtls/src/context/cipher.d.ts +13 -7
- package/lib/dtls/src/context/cipher.js +58 -106
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.js +4 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +4 -0
- package/lib/dtls/src/context/transport.js +16 -1
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +4 -2
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +1 -1
- package/lib/dtls/src/flight/flight.js +16 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight2.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.d.ts +2 -1
- package/lib/dtls/src/flight/server/flight4.js +12 -4
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +2 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/extensions/signature.d.ts +1 -1
- package/lib/dtls/src/handshake/extensions/signature.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +5 -3
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +3 -2
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +4 -4
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.d.ts +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +5 -3
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +15 -8
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +3 -2
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +7 -4
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +14 -8
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +5 -3
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.d.ts +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +17 -9
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +1 -1
- package/lib/dtls/src/handshake/random.js +7 -4
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/imports/common.d.ts +1 -0
- package/lib/dtls/src/imports/common.js +1 -0
- package/lib/dtls/src/imports/common.js.map +1 -1
- package/lib/dtls/src/index.d.ts +2 -2
- package/lib/dtls/src/index.js +2 -2
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +43 -33
- package/lib/dtls/src/record/const.js +43 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.d.ts +1 -1
- package/lib/dtls/src/record/message/fragment.js +15 -9
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +12 -7
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.js +2 -2
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +1 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +2 -2
- package/lib/dtls/src/socket.js +6 -4
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +46 -0
- package/lib/ice/src/exceptions.js +92 -5
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/helper.d.ts +1 -1
- package/lib/ice/src/ice.d.ts +191 -5
- package/lib/ice/src/ice.js +1048 -156
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +174 -10
- package/lib/ice/src/iceBase.js +165 -12
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +5 -5
- package/lib/ice/src/index.js +5 -5
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +26 -0
- package/lib/ice/src/internal/resolveHostAddresses.js +45 -0
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +3 -1
- package/lib/ice/src/stun/protocol.js +16 -0
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +2 -0
- package/lib/ice/src/stun/tcpProtocol.js +16 -1
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +35 -1
- package/lib/ice/src/stun/transaction.js +93 -18
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +97 -7
- package/lib/ice/src/turn/protocol.js +357 -55
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/utils.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +7 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +24 -16
- package/lib/ice-server/src/stun/const.js +22 -18
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +3 -1
- package/lib/ice-server/src/stun/message.js +41 -6
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/ice-server/src/turn/auth.d.ts +1 -1
- package/lib/index.mjs +25252 -12664
- package/lib/nonstandard/index.mjs +11015 -8906
- package/lib/polyfill/dom.mjs +30779 -18386
- package/lib/polyfill/index.mjs +30779 -18386
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.d.ts +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/container.d.ts +1 -1
- package/lib/rtp/src/extra/container/webm/ebml/ebml.d.ts +6 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +26 -4
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +6 -1
- package/lib/rtp/src/extra/processor/depacketizer.js +29 -3
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizerCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/depacketizerTransformer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtxCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/interface.d.ts +16 -11
- package/lib/rtp/src/extra/processor/interface.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.d.ts +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +7 -4
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.d.ts +1 -1
- package/lib/rtp/src/extra/processor/nack.js +5 -3
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/nackHandlerCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTimeCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtcpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtcpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.d.ts +1 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js +3 -2
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.d.ts +2 -2
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTimeCallback.d.ts +1 -11
- package/lib/rtp/src/extra/processor/webm.d.ts +27 -0
- package/lib/rtp/src/extra/processor/webm.js +57 -23
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js +6 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmStream.js.map +1 -1
- package/lib/rtp/src/helper.d.ts +2 -2
- package/lib/rtp/src/helper.js +2 -6
- package/lib/rtp/src/helper.js.map +1 -1
- package/lib/rtp/src/index.d.ts +10 -2
- package/lib/rtp/src/index.js +10 -2
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +6 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +9 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.d.ts +4 -3
- package/lib/rtp/src/rtcp/sr.js +4 -2
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +36 -0
- package/lib/rtp/src/rtp/continuity.js +100 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.d.ts +2 -2
- package/lib/rtp/src/srtp/cipher/ctr.js +5 -3
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.d.ts +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.js +1 -1
- package/lib/rtp/src/srtp/cipher/gcm.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.d.ts +29 -1
- package/lib/rtp/src/srtp/context/context.js +84 -27
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +36 -4
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/index.d.ts +4 -3
- package/lib/sctp/src/index.js +10 -8
- package/lib/sctp/src/index.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +91 -2
- package/lib/sctp/src/sctp.js +700 -134
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/peerConfig.d.ts +307 -0
- package/lib/webrtc/src/api/peerConfig.js +291 -0
- package/lib/webrtc/src/api/peerConfig.js.map +1 -0
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +36 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js +44 -0
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -0
- package/lib/webrtc/src/dataChannel.d.ts +11 -1
- package/lib/webrtc/src/dataChannel.js +25 -5
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/index.d.ts +2 -2
- package/lib/webrtc/src/index.js +2 -2
- package/lib/webrtc/src/index.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +11 -1
- package/lib/webrtc/src/media/index.js +71 -1
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.js +5 -5
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +130 -6
- package/lib/webrtc/src/media/router.js +325 -29
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +137 -14
- package/lib/webrtc/src/media/rtpReceiver.js +420 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +232 -65
- package/lib/webrtc/src/media/rtpSender.js +784 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +95 -4
- package/lib/webrtc/src/media/rtpTransceiver.js +121 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -32
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -142
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderStats.d.ts +100 -0
- package/lib/webrtc/src/media/sender/senderStats.js +322 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +21 -3
- package/lib/webrtc/src/media/track.js +24 -6
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +103 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js +384 -0
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.d.ts +51 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js +267 -0
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.d.ts +21 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js +61 -0
- package/lib/webrtc/src/negotiation/iceRestartRequest.js.map +1 -0
- package/lib/webrtc/src/negotiation/internalState.d.ts +34 -0
- package/lib/webrtc/src/negotiation/internalState.js +21 -0
- package/lib/webrtc/src/negotiation/internalState.js.map +1 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.d.ts +44 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +119 -0
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.d.ts +86 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js +349 -0
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +71 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +414 -0
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +59 -0
- package/lib/webrtc/src/negotiation/transportActivation.js +356 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -0
- package/lib/webrtc/src/negotiationTransaction.d.ts +240 -0
- package/lib/webrtc/src/negotiationTransaction.js +604 -0
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -0
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/index.d.ts +1 -1
- package/lib/webrtc/src/nonstandard/index.js +1 -1
- package/lib/webrtc/src/nonstandard/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +10 -8
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +10 -3
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia/packetizer.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.d.ts +2 -2
- package/lib/webrtc/src/nonstandard/userMedia.js +4 -3
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +176 -238
- package/lib/webrtc/src/peerConnection.js +1042 -913
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/api.d.ts +5 -5
- package/lib/webrtc/src/polyfill/api.js.map +1 -1
- package/lib/webrtc/src/polyfill/index.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +1 -1
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/polyfill/registers/mp4Webm.js.map +1 -1
- package/lib/webrtc/src/polyfill/registers/rtpRtcp.js.map +1 -1
- package/lib/webrtc/src/polyfill/selectSettings.js.map +1 -1
- package/lib/webrtc/src/polyfill/sourceIo.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +97 -1
- package/lib/webrtc/src/sctpManager.js +189 -9
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.js +12 -6
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +55 -11
- package/lib/webrtc/src/sdpManager.js +364 -87
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -28
- package/lib/webrtc/src/secureTransportManager.js +232 -53
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +62 -18
- package/lib/webrtc/src/transceiverManager.js +272 -107
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +64 -3
- package/lib/webrtc/src/transport/dtls.js +166 -42
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +199 -28
- package/lib/webrtc/src/transport/ice.js +666 -71
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/iceCandidateAttribute.d.ts +98 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js +129 -0
- package/lib/webrtc/src/transport/iceCandidateAttribute.js.map +1 -0
- package/lib/webrtc/src/transport/sctp.d.ts +6 -1
- package/lib/webrtc/src/transport/sctp.js +149 -37
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +39 -6
- package/lib/webrtc/src/utils.js +57 -17
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +16 -15
|
@@ -23,48 +23,65 @@ Figure 2: Example for round-trip time computation
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.RTCRtpSender = void 0;
|
|
25
25
|
const crypto_1 = require("crypto");
|
|
26
|
-
const crypto_2 = require("crypto");
|
|
27
26
|
const promises_1 = require("timers/promises");
|
|
28
|
-
const common_1 = require("../imports/common");
|
|
29
27
|
const __1 = require("..");
|
|
30
28
|
const errors_1 = require("../errors");
|
|
29
|
+
const common_1 = require("../imports/common");
|
|
31
30
|
const rtp_1 = require("../imports/rtp");
|
|
32
31
|
const utils_1 = require("../utils");
|
|
33
32
|
const codecCompatibility_1 = require("./codecCompatibility");
|
|
33
|
+
const bandwidthEstimator_1 = require("./sender/bandwidthEstimator");
|
|
34
|
+
const estimatorBinding_1 = require("./sender/estimatorBinding");
|
|
35
|
+
const outgoingQueue_1 = require("./sender/outgoingQueue");
|
|
36
|
+
const padding_1 = require("./sender/padding");
|
|
37
|
+
const pendingRtp_1 = require("./sender/pendingRtp");
|
|
38
|
+
const rtpWire_1 = require("./sender/rtpWire");
|
|
34
39
|
const senderBWE_1 = require("./sender/senderBWE");
|
|
40
|
+
const senderStats_1 = require("./sender/senderStats");
|
|
41
|
+
const sendPacer_1 = require("./sender/sendPacer");
|
|
35
42
|
const stats_1 = require("./stats");
|
|
36
43
|
const track_1 = require("./track");
|
|
37
44
|
const log = (0, rtp_1.debug)("werift:packages/webrtc/src/media/rtpSender.ts");
|
|
45
|
+
/** NACK history: the last sent media packets by sequence number modulo this. */
|
|
38
46
|
const RTP_HISTORY_SIZE = 128;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
? Math.floor(pendingRtp.maxLength)
|
|
52
|
-
: DEFAULT_PENDING_RTP_MAX_LENGTH;
|
|
53
|
-
return { enabled: pendingRtp.enabled ?? true, maxLength };
|
|
54
|
-
}
|
|
55
|
-
function freezeRtpContinuityOffsets(lastOutputSeq, lastOutputTimestamp, firstInputSeq, firstInputTimestamp, timestampStep) {
|
|
56
|
-
return {
|
|
57
|
-
seqOffset: (0, common_1.uint16Add)((0, common_1.uint16Add)(lastOutputSeq, 1), -firstInputSeq),
|
|
58
|
-
timestampOffset: (0, common_1.uint32Add)((0, common_1.uint32Add)(lastOutputTimestamp, timestampStep), -firstInputTimestamp),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
47
|
+
// RTCRtpSender sends one media stream: negotiation parameters, track binding,
|
|
48
|
+
// the RTP send path, RTCP feedback and stats. Parts with their own state live
|
|
49
|
+
// in ./sender/ (internal, not exported):
|
|
50
|
+
//
|
|
51
|
+
// - estimatorBinding.ts: the bandwidth estimator, its generation and process timer
|
|
52
|
+
// - outgoingQueue.ts / sendPacer.ts: the GCC send FIFO and pacing
|
|
53
|
+
// - padding.ts: probe / loss padding drain on the RTX stream
|
|
54
|
+
// - pendingRtp.ts: RTP held until DTLS connects
|
|
55
|
+
// - senderStats.ts: counters, reception reports, Sender Reports, stats
|
|
56
|
+
// - rtpWire.ts: send FIFO size estimate and the DTLS write
|
|
57
|
+
// Generic RTP pieces (RtpContinuity, header extension rebuild / hop-by-hop
|
|
58
|
+
// stamping, RTX padding packets, RED size estimate) live in werift-rtp.
|
|
61
59
|
class RTCRtpSender {
|
|
60
|
+
/**
|
|
61
|
+
* Active send-side bandwidth estimator (TWCC-driven).
|
|
62
|
+
*
|
|
63
|
+
* Default is {@link LightweightBandwidthEstimator} (lightweight cumulative algorithm).
|
|
64
|
+
* Replace only with {@link setBandwidthEstimator} (e.g. `new GccBandwidthEstimator()`).
|
|
65
|
+
*
|
|
66
|
+
* Prefer {@link onAvailableBitrate} on this sender for bitrate notifications that
|
|
67
|
+
* survive estimator swaps. Algorithm-specific events remain on concrete instances.
|
|
68
|
+
*
|
|
69
|
+
* **TypeScript compatibility:** {@link CongestionEventsCompatibility} fields
|
|
70
|
+
* (`onCongestion` / `onCongestionScore`) are present on every estimator so
|
|
71
|
+
* existing `sender.senderBWE.onCongestion.subscribe(...)` still type-checks.
|
|
72
|
+
* They fire only on {@link LightweightBandwidthEstimator}; GCC / disabled are no-ops.
|
|
73
|
+
* Prefer `sender.senderBWE as LightweightBandwidthEstimator` (or
|
|
74
|
+
* {@link isLightweightBandwidthEstimator}) for lightweight-only APIs.
|
|
75
|
+
*/
|
|
76
|
+
get senderBWE() {
|
|
77
|
+
return this.bwe.estimator;
|
|
78
|
+
}
|
|
62
79
|
constructor(trackOrKind, options = {}) {
|
|
63
80
|
Object.defineProperty(this, "trackOrKind", {
|
|
64
81
|
enumerable: true,
|
|
65
82
|
configurable: true,
|
|
66
83
|
writable: true,
|
|
67
|
-
value:
|
|
84
|
+
value: void 0
|
|
68
85
|
});
|
|
69
86
|
Object.defineProperty(this, "type", {
|
|
70
87
|
enumerable: true,
|
|
@@ -94,7 +111,7 @@ class RTCRtpSender {
|
|
|
94
111
|
enumerable: true,
|
|
95
112
|
configurable: true,
|
|
96
113
|
writable: true,
|
|
97
|
-
value: (0,
|
|
114
|
+
value: (0, crypto_1.randomUUID)().toString()
|
|
98
115
|
});
|
|
99
116
|
Object.defineProperty(this, "onReady", {
|
|
100
117
|
enumerable: true,
|
|
@@ -120,186 +137,205 @@ class RTCRtpSender {
|
|
|
120
137
|
writable: true,
|
|
121
138
|
value: new common_1.Event()
|
|
122
139
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
Object.defineProperty(this, "cname", {
|
|
140
|
+
/**
|
|
141
|
+
* Active send-side bandwidth estimator (TWCC-driven) with its generation
|
|
142
|
+
* and process timer. Replaced only via {@link setBandwidthEstimator}.
|
|
143
|
+
*/
|
|
144
|
+
Object.defineProperty(this, "bwe", {
|
|
130
145
|
enumerable: true,
|
|
131
146
|
configurable: true,
|
|
132
147
|
writable: true,
|
|
133
148
|
value: void 0
|
|
134
149
|
});
|
|
135
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Stable recommended send bitrate event (**bps**, change-only).
|
|
152
|
+
* Bridged from the active {@link BandwidthEstimator}; subscriptions survive
|
|
153
|
+
* {@link setBandwidthEstimator} without re-subscribing.
|
|
154
|
+
*
|
|
155
|
+
* Prefer this over `senderBWE.onAvailableBitrate` for application adaptation.
|
|
156
|
+
*/
|
|
157
|
+
Object.defineProperty(this, "onAvailableBitrate", {
|
|
136
158
|
enumerable: true,
|
|
137
159
|
configurable: true,
|
|
138
160
|
writable: true,
|
|
139
|
-
value:
|
|
161
|
+
value: new common_1.Event()
|
|
140
162
|
});
|
|
141
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Probe cluster configs (target bps / min packets). Bridged from the active
|
|
165
|
+
* {@link BandwidthEstimator}; GCC fires this, lightweight / disabled never do.
|
|
166
|
+
*/
|
|
167
|
+
Object.defineProperty(this, "onProbeClusterConfig", {
|
|
142
168
|
enumerable: true,
|
|
143
169
|
configurable: true,
|
|
144
170
|
writable: true,
|
|
145
|
-
value:
|
|
171
|
+
value: new common_1.Event()
|
|
146
172
|
});
|
|
147
|
-
|
|
173
|
+
/**
|
|
174
|
+
* @internal Sim / test only. When false, skip the **media** token-bucket
|
|
175
|
+
* (pin GetPacingRates). Probe `next_probe_time` waits stay enabled so
|
|
176
|
+
* BitrateProber timing is not disabled by accident.
|
|
177
|
+
*
|
|
178
|
+
* Peer/Chrome sims turn this off during the congestion phase so the
|
|
179
|
+
* synthetic generate rate hits the bottleneck, then turn it back on
|
|
180
|
+
* when the app follows {@link onAvailableBitrate}.
|
|
181
|
+
*/
|
|
182
|
+
Object.defineProperty(this, "mediaPacingEnabled", {
|
|
148
183
|
enumerable: true,
|
|
149
184
|
configurable: true,
|
|
150
185
|
writable: true,
|
|
151
|
-
value:
|
|
186
|
+
value: true
|
|
152
187
|
});
|
|
153
|
-
|
|
188
|
+
/** Token-bucket pacer for **media** (not probe) rate enforcement. */
|
|
189
|
+
Object.defineProperty(this, "pacer", {
|
|
154
190
|
enumerable: true,
|
|
155
191
|
configurable: true,
|
|
156
192
|
writable: true,
|
|
157
|
-
value:
|
|
193
|
+
value: new sendPacer_1.MediaPacer()
|
|
158
194
|
});
|
|
159
|
-
|
|
195
|
+
/**
|
|
196
|
+
* pin `pending_untracked_size_` — bytes sent without TWCC tracking,
|
|
197
|
+
* attached to the next tracked packet as `priorUnackedBytes`.
|
|
198
|
+
*/
|
|
199
|
+
Object.defineProperty(this, "pendingUntrackedBytes", {
|
|
160
200
|
enumerable: true,
|
|
161
201
|
configurable: true,
|
|
162
202
|
writable: true,
|
|
163
|
-
value:
|
|
203
|
+
value: 0
|
|
164
204
|
});
|
|
165
|
-
|
|
205
|
+
/**
|
|
206
|
+
* GCC send FIFO: reservation → pacing wait → seq / TSN assignment → DTLS write.
|
|
207
|
+
* Probe padding may call {@link sendRtpInternal} on this stack only after
|
|
208
|
+
* the current packet's DTLS write ({@link nestOutgoingPadding}); timer /
|
|
209
|
+
* cluster events always enqueue so they cannot share a DTLS write.
|
|
210
|
+
*/
|
|
211
|
+
Object.defineProperty(this, "outgoing", {
|
|
166
212
|
enumerable: true,
|
|
167
213
|
configurable: true,
|
|
168
214
|
writable: true,
|
|
169
215
|
value: void 0
|
|
170
216
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
Object.defineProperty(this, "redEncoder", {
|
|
178
|
-
enumerable: true,
|
|
179
|
-
configurable: true,
|
|
180
|
-
writable: true,
|
|
181
|
-
value: new rtp_1.RedEncoder(this._redDistance)
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(this, "headerExtensions", {
|
|
217
|
+
/**
|
|
218
|
+
* Set only around post-DTLS {@link maybeInjectProbePadding} so padding can
|
|
219
|
+
* drain on the same FIFO task without deadlock. Must stay false during
|
|
220
|
+
* probe/pacing wait, or a cluster event would send in parallel.
|
|
221
|
+
*/
|
|
222
|
+
Object.defineProperty(this, "nestOutgoingPadding", {
|
|
184
223
|
enumerable: true,
|
|
185
224
|
configurable: true,
|
|
186
225
|
writable: true,
|
|
187
|
-
value:
|
|
226
|
+
value: false
|
|
188
227
|
});
|
|
189
|
-
Object.defineProperty(this, "
|
|
228
|
+
Object.defineProperty(this, "padding", {
|
|
190
229
|
enumerable: true,
|
|
191
230
|
configurable: true,
|
|
192
231
|
writable: true,
|
|
193
232
|
value: void 0
|
|
194
233
|
});
|
|
195
|
-
|
|
234
|
+
/** Fires for a FIR addressed to this sender with a new sequence number (RFC 5104 4.3.1). */
|
|
235
|
+
Object.defineProperty(this, "onFullIntraRequest", {
|
|
196
236
|
enumerable: true,
|
|
197
237
|
configurable: true,
|
|
198
238
|
writable: true,
|
|
199
|
-
value:
|
|
239
|
+
value: new common_1.Event()
|
|
200
240
|
});
|
|
201
|
-
|
|
202
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Fires for every key frame request addressed to this sender: each PLI, and each FIR
|
|
243
|
+
* that is not a retransmission. Fires in addition to onPictureLossIndication / onFullIntraRequest.
|
|
244
|
+
*/
|
|
245
|
+
Object.defineProperty(this, "onKeyFrameRequest", {
|
|
203
246
|
enumerable: true,
|
|
204
247
|
configurable: true,
|
|
205
248
|
writable: true,
|
|
206
|
-
value:
|
|
249
|
+
value: new common_1.Event()
|
|
207
250
|
});
|
|
208
|
-
Object.defineProperty(this, "
|
|
251
|
+
Object.defineProperty(this, "cname", {
|
|
209
252
|
enumerable: true,
|
|
210
253
|
configurable: true,
|
|
211
254
|
writable: true,
|
|
212
255
|
value: void 0
|
|
213
256
|
});
|
|
214
|
-
Object.defineProperty(this, "
|
|
215
|
-
enumerable: true,
|
|
216
|
-
configurable: true,
|
|
217
|
-
writable: true,
|
|
218
|
-
value: 0n
|
|
219
|
-
});
|
|
220
|
-
Object.defineProperty(this, "rtpTimestamp", {
|
|
221
|
-
enumerable: true,
|
|
222
|
-
configurable: true,
|
|
223
|
-
writable: true,
|
|
224
|
-
value: 0
|
|
225
|
-
});
|
|
226
|
-
Object.defineProperty(this, "octetCount", {
|
|
257
|
+
Object.defineProperty(this, "mid", {
|
|
227
258
|
enumerable: true,
|
|
228
259
|
configurable: true,
|
|
229
260
|
writable: true,
|
|
230
|
-
value: 0
|
|
261
|
+
value: void 0
|
|
231
262
|
});
|
|
232
|
-
Object.defineProperty(this, "
|
|
263
|
+
Object.defineProperty(this, "rtpStreamId", {
|
|
233
264
|
enumerable: true,
|
|
234
265
|
configurable: true,
|
|
235
266
|
writable: true,
|
|
236
|
-
value: 0
|
|
267
|
+
value: void 0
|
|
237
268
|
});
|
|
238
|
-
Object.defineProperty(this, "
|
|
269
|
+
Object.defineProperty(this, "repairedRtpStreamId", {
|
|
239
270
|
enumerable: true,
|
|
240
271
|
configurable: true,
|
|
241
272
|
writable: true,
|
|
242
|
-
value: 0
|
|
273
|
+
value: void 0
|
|
243
274
|
});
|
|
244
|
-
Object.defineProperty(this, "
|
|
275
|
+
Object.defineProperty(this, "rtxPayloadType", {
|
|
245
276
|
enumerable: true,
|
|
246
277
|
configurable: true,
|
|
247
278
|
writable: true,
|
|
248
279
|
value: void 0
|
|
249
280
|
});
|
|
250
|
-
Object.defineProperty(this, "
|
|
281
|
+
Object.defineProperty(this, "rtxSequenceNumber", {
|
|
251
282
|
enumerable: true,
|
|
252
283
|
configurable: true,
|
|
253
284
|
writable: true,
|
|
254
|
-
value: 0
|
|
285
|
+
value: (0, common_1.random16)()
|
|
255
286
|
});
|
|
256
|
-
Object.defineProperty(this, "
|
|
287
|
+
Object.defineProperty(this, "redRedundantPayloadType", {
|
|
257
288
|
enumerable: true,
|
|
258
289
|
configurable: true,
|
|
259
290
|
writable: true,
|
|
260
|
-
value: 0
|
|
291
|
+
value: void 0
|
|
261
292
|
});
|
|
262
|
-
Object.defineProperty(this, "
|
|
293
|
+
Object.defineProperty(this, "_redDistance", {
|
|
263
294
|
enumerable: true,
|
|
264
295
|
configurable: true,
|
|
265
296
|
writable: true,
|
|
266
|
-
value:
|
|
297
|
+
value: 2
|
|
267
298
|
});
|
|
268
|
-
Object.defineProperty(this, "
|
|
299
|
+
Object.defineProperty(this, "redEncoder", {
|
|
269
300
|
enumerable: true,
|
|
270
301
|
configurable: true,
|
|
271
302
|
writable: true,
|
|
272
|
-
value:
|
|
303
|
+
value: new rtp_1.RedEncoder(this._redDistance)
|
|
273
304
|
});
|
|
274
|
-
Object.defineProperty(this, "
|
|
305
|
+
Object.defineProperty(this, "headerExtensions", {
|
|
275
306
|
enumerable: true,
|
|
276
307
|
configurable: true,
|
|
277
308
|
writable: true,
|
|
278
|
-
value:
|
|
309
|
+
value: []
|
|
279
310
|
});
|
|
280
|
-
Object.defineProperty(this, "
|
|
311
|
+
Object.defineProperty(this, "disposeTrack", {
|
|
281
312
|
enumerable: true,
|
|
282
313
|
configurable: true,
|
|
283
314
|
writable: true,
|
|
284
|
-
value: 0
|
|
315
|
+
value: void 0
|
|
285
316
|
});
|
|
286
|
-
Object.defineProperty(this, "
|
|
317
|
+
Object.defineProperty(this, "sendEncodings", {
|
|
287
318
|
enumerable: true,
|
|
288
319
|
configurable: true,
|
|
289
320
|
writable: true,
|
|
290
|
-
value:
|
|
321
|
+
value: [{}]
|
|
291
322
|
});
|
|
292
|
-
|
|
323
|
+
// # stats
|
|
324
|
+
Object.defineProperty(this, "stats", {
|
|
293
325
|
enumerable: true,
|
|
294
326
|
configurable: true,
|
|
295
327
|
writable: true,
|
|
296
|
-
value:
|
|
328
|
+
value: new senderStats_1.SenderStatistics()
|
|
297
329
|
});
|
|
298
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Last FIR sequence number per (FIR sender SSRC, FCI target SSRC): RFC 5104
|
|
332
|
+
* 4.3.1.1 keeps one sequence number space per pair.
|
|
333
|
+
*/
|
|
334
|
+
Object.defineProperty(this, "lastFirSequenceNumbers", {
|
|
299
335
|
enumerable: true,
|
|
300
336
|
configurable: true,
|
|
301
337
|
writable: true,
|
|
302
|
-
value:
|
|
338
|
+
value: new Map()
|
|
303
339
|
});
|
|
304
340
|
Object.defineProperty(this, "receiverEstimatedMaxBitrate", {
|
|
305
341
|
enumerable: true,
|
|
@@ -308,41 +344,11 @@ class RTCRtpSender {
|
|
|
308
344
|
value: 0n
|
|
309
345
|
});
|
|
310
346
|
// rtp
|
|
311
|
-
Object.defineProperty(this, "
|
|
312
|
-
enumerable: true,
|
|
313
|
-
configurable: true,
|
|
314
|
-
writable: true,
|
|
315
|
-
value: void 0
|
|
316
|
-
});
|
|
317
|
-
Object.defineProperty(this, "timestamp", {
|
|
318
|
-
enumerable: true,
|
|
319
|
-
configurable: true,
|
|
320
|
-
writable: true,
|
|
321
|
-
value: void 0
|
|
322
|
-
});
|
|
323
|
-
Object.defineProperty(this, "timestampOffset", {
|
|
324
|
-
enumerable: true,
|
|
325
|
-
configurable: true,
|
|
326
|
-
writable: true,
|
|
327
|
-
value: 0
|
|
328
|
-
});
|
|
329
|
-
Object.defineProperty(this, "seqOffset", {
|
|
330
|
-
enumerable: true,
|
|
331
|
-
configurable: true,
|
|
332
|
-
writable: true,
|
|
333
|
-
value: 0
|
|
334
|
-
});
|
|
335
|
-
Object.defineProperty(this, "rtpContinuityPending", {
|
|
336
|
-
enumerable: true,
|
|
337
|
-
configurable: true,
|
|
338
|
-
writable: true,
|
|
339
|
-
value: false
|
|
340
|
-
});
|
|
341
|
-
Object.defineProperty(this, "pendingTimestampStep", {
|
|
347
|
+
Object.defineProperty(this, "continuity", {
|
|
342
348
|
enumerable: true,
|
|
343
349
|
configurable: true,
|
|
344
350
|
writable: true,
|
|
345
|
-
value:
|
|
351
|
+
value: new rtp_1.RtpContinuity()
|
|
346
352
|
});
|
|
347
353
|
Object.defineProperty(this, "rtpCache", {
|
|
348
354
|
enumerable: true,
|
|
@@ -354,21 +360,28 @@ class RTCRtpSender {
|
|
|
354
360
|
enumerable: true,
|
|
355
361
|
configurable: true,
|
|
356
362
|
writable: true,
|
|
357
|
-
value:
|
|
363
|
+
value: void 0
|
|
358
364
|
});
|
|
359
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Bumped on replaceTrack / detachTrack / onSourceChanged. Media accepted
|
|
367
|
+
* under an older epoch is dropped before it can allocate seq/timestamp, so
|
|
368
|
+
* it neither consumes the new source's continuity offset nor leaks out
|
|
369
|
+
* after `replaceTrack(null)`.
|
|
370
|
+
*/
|
|
371
|
+
Object.defineProperty(this, "sourceEpoch", {
|
|
360
372
|
enumerable: true,
|
|
361
373
|
configurable: true,
|
|
362
374
|
writable: true,
|
|
363
|
-
value:
|
|
375
|
+
value: 0
|
|
364
376
|
});
|
|
365
|
-
|
|
377
|
+
/** Aborted on every source epoch bump to wake probe / pacing waits. */
|
|
378
|
+
Object.defineProperty(this, "sourceEpochCancel", {
|
|
366
379
|
enumerable: true,
|
|
367
380
|
configurable: true,
|
|
368
381
|
writable: true,
|
|
369
|
-
value:
|
|
382
|
+
value: new AbortController()
|
|
370
383
|
});
|
|
371
|
-
Object.defineProperty(this, "
|
|
384
|
+
Object.defineProperty(this, "pendingRtpEnabled", {
|
|
372
385
|
enumerable: true,
|
|
373
386
|
configurable: true,
|
|
374
387
|
writable: true,
|
|
@@ -392,6 +405,16 @@ class RTCRtpSender {
|
|
|
392
405
|
writable: true,
|
|
393
406
|
value: void 0
|
|
394
407
|
});
|
|
408
|
+
/**
|
|
409
|
+
* Primary codec a pending remote offer's answer would switch this sender to.
|
|
410
|
+
* `replaceTrack()` must fit it too, since the commit sends the track with it.
|
|
411
|
+
*/
|
|
412
|
+
Object.defineProperty(this, "proposedPrimaryCodec", {
|
|
413
|
+
enumerable: true,
|
|
414
|
+
configurable: true,
|
|
415
|
+
writable: true,
|
|
416
|
+
value: void 0
|
|
417
|
+
});
|
|
395
418
|
Object.defineProperty(this, "dtlsTransport", {
|
|
396
419
|
enumerable: true,
|
|
397
420
|
configurable: true,
|
|
@@ -434,16 +457,43 @@ class RTCRtpSender {
|
|
|
434
457
|
writable: true,
|
|
435
458
|
value: new AbortController()
|
|
436
459
|
});
|
|
437
|
-
|
|
460
|
+
/**
|
|
461
|
+
* The negotiated direction in effect (the answer's, or a pranswer's while
|
|
462
|
+
* it is pending) does not include sending: RTP is dropped, not queued.
|
|
463
|
+
* @internal
|
|
464
|
+
*/
|
|
465
|
+
Object.defineProperty(this, "sendSuppressed", {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
configurable: true,
|
|
468
|
+
writable: true,
|
|
469
|
+
value: false
|
|
470
|
+
});
|
|
471
|
+
this.trackOrKind = trackOrKind;
|
|
472
|
+
const pendingRtp = (0, pendingRtp_1.resolvePendingRtpOptions)(options.pendingRtp);
|
|
438
473
|
this.pendingRtpEnabled = pendingRtp.enabled;
|
|
439
|
-
this.
|
|
474
|
+
this.pendingRtp = new pendingRtp_1.PendingRtpQueue(pendingRtp.maxLength);
|
|
440
475
|
this.kind =
|
|
441
476
|
typeof this.trackOrKind === "string"
|
|
442
477
|
? this.trackOrKind
|
|
443
478
|
: this.trackOrKind.kind;
|
|
479
|
+
this.bwe = new estimatorBinding_1.EstimatorBinding(options?.bandwidthEstimator ?? new senderBWE_1.LightweightBandwidthEstimator(), {
|
|
480
|
+
onAvailableBitrate: (bps) => this.onAvailableBitrate.execute(bps),
|
|
481
|
+
onProbeClusterConfig: (cfg) => {
|
|
482
|
+
this.onProbeClusterConfig.execute(cfg);
|
|
483
|
+
// pin BitrateProber: no prepaid token-bucket credit. Probe packets
|
|
484
|
+
// wait on next_probe_time = started_at + sent_bytes / send_bitrate.
|
|
485
|
+
void this.maybeInjectProbePadding();
|
|
486
|
+
},
|
|
487
|
+
// pin GetPacingRates padding_rate while kIncreaseUsingPadding.
|
|
488
|
+
onProcessTick: () => void this.maybeInjectLossPadding(),
|
|
489
|
+
isStopped: () => this.stopped,
|
|
490
|
+
});
|
|
491
|
+
this.outgoing = new outgoingQueue_1.OutgoingQueue(this.kind, () => (0, bandwidthEstimator_1.needsPacedSendPath)(this.bwe.estimator));
|
|
492
|
+
this.padding = this.createPaddingInjector();
|
|
444
493
|
if (typeof trackOrKind !== "string") {
|
|
445
494
|
this.registerTrack(trackOrKind);
|
|
446
495
|
}
|
|
496
|
+
this.bwe.syncProcessTimer();
|
|
447
497
|
}
|
|
448
498
|
get transport() {
|
|
449
499
|
return this.dtlsTransport ?? null;
|
|
@@ -455,18 +505,91 @@ class RTCRtpSender {
|
|
|
455
505
|
this.streamIds = value ? [value] : [];
|
|
456
506
|
}
|
|
457
507
|
setDtlsTransport(dtlsTransport) {
|
|
458
|
-
|
|
508
|
+
const previous = this.dtlsTransport;
|
|
509
|
+
if (previous) {
|
|
459
510
|
this.dtlsDisposer.forEach((dispose) => dispose());
|
|
460
511
|
}
|
|
461
512
|
this.dtlsTransport = dtlsTransport;
|
|
513
|
+
// A stopped sender (also one a rollback binds again) sends nothing and
|
|
514
|
+
// does not subscribe to the transport, which may outlive it.
|
|
515
|
+
if (this.stopped) {
|
|
516
|
+
this.dtlsDisposer = [];
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (previous && previous !== dtlsTransport) {
|
|
520
|
+
this.resetBweForNewTransport();
|
|
521
|
+
}
|
|
462
522
|
this.dtlsDisposer = [
|
|
463
523
|
this.dtlsTransport.onStateChange.subscribe((state) => {
|
|
524
|
+
this.syncNetworkAvailability();
|
|
464
525
|
if (state === "connected") {
|
|
465
526
|
this.onReady.execute();
|
|
466
527
|
void this.drainPendingRtp();
|
|
467
528
|
}
|
|
468
529
|
}).unSubscribe,
|
|
469
530
|
];
|
|
531
|
+
this.syncNetworkAvailability();
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Replace the send-side bandwidth estimator used for TWCC-driven BWE.
|
|
535
|
+
*
|
|
536
|
+
* Default is the lightweight {@link LightweightBandwidthEstimator}. Pass e.g.
|
|
537
|
+
* `new GccBandwidthEstimator()` to use Google Congestion Control.
|
|
538
|
+
*
|
|
539
|
+
* Behavior on swap:
|
|
540
|
+
* 1. Bumps the estimator generation so in-flight sends discard
|
|
541
|
+
* `rtpPacketSent` delivery and in-flight {@link maybeInjectProbePadding}
|
|
542
|
+
* loops exit (cancelled — no packets to disposed / previous estimator).
|
|
543
|
+
* 2. Stops delivering `rtpPacketSent` / `receiveTWCC` to the previous instance.
|
|
544
|
+
* 3. Unbinds the stable {@link onAvailableBitrate} bridge, then `dispose()`/`reset()` the old instance.
|
|
545
|
+
* 4. **Always** `reset()` the injected `impl` so a previously used instance
|
|
546
|
+
* starts clean (no implicit state merge), then rebinds the bridge.
|
|
547
|
+
* 5. Clears {@link pendingUntrackedBytes} and pacing credit so the next
|
|
548
|
+
* estimator's first `SentInfo.priorUnackedBytes` is 0.
|
|
549
|
+
*
|
|
550
|
+
* Subscriptions to {@link onAvailableBitrate} on this sender are preserved.
|
|
551
|
+
* Re-subscribe algorithm-specific events on the new concrete instance.
|
|
552
|
+
*/
|
|
553
|
+
setBandwidthEstimator(impl) {
|
|
554
|
+
// Invalidate in-flight media/padding so they do not touch the next estimator
|
|
555
|
+
// (or revive a disposed probe controller after dispose/reset).
|
|
556
|
+
this.bwe.replace(impl);
|
|
557
|
+
this.resetBweSendTransientState();
|
|
558
|
+
this.syncNetworkAvailability();
|
|
559
|
+
this.bwe.syncProcessTimer();
|
|
560
|
+
// New generation may have missed onProbeClusterConfig while the previous
|
|
561
|
+
// drain still held the same-generation re-entry lock.
|
|
562
|
+
void this.maybeInjectProbePadding();
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* A new DTLS transport has its own transport-wide sequence space and path:
|
|
566
|
+
* drop the estimator's path state ({@link EstimatorBinding.resetForNewRoute},
|
|
567
|
+
* which also bumps the generation so in-flight sends on the old transport
|
|
568
|
+
* do not report their old TSN) and the pacing / unacked leftovers.
|
|
569
|
+
*/
|
|
570
|
+
resetBweForNewTransport() {
|
|
571
|
+
this.bwe.resetForNewRoute();
|
|
572
|
+
this.resetBweSendTransientState();
|
|
573
|
+
this.bwe.syncProcessTimer();
|
|
574
|
+
}
|
|
575
|
+
/** Drop pacing leftover and unacked bytes that belonged to the previous BWE generation. */
|
|
576
|
+
resetBweSendTransientState() {
|
|
577
|
+
this.pacer.reset();
|
|
578
|
+
this.pendingUntrackedBytes = 0;
|
|
579
|
+
}
|
|
580
|
+
/** Initial probes wait until DTLS can send; also on a swap onto a connected sender. */
|
|
581
|
+
syncNetworkAvailability() {
|
|
582
|
+
this.bwe.syncNetworkAvailability(this.dtlsTransport?.state === "connected");
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Effective send pacing rate (bps): estimator estimate, raised to the active
|
|
586
|
+
* probe target while probing. 0 when unknown. Lightweight returns 0 from
|
|
587
|
+
* {@link BandwidthEstimator.getPacingBitrateBps} so media is unpaced.
|
|
588
|
+
*/
|
|
589
|
+
get pacingBitrateBps() {
|
|
590
|
+
const estimator = this.bwe.estimator;
|
|
591
|
+
const paced = estimator.getPacingBitrateBps();
|
|
592
|
+
return paced > 0 ? paced : estimator.availableBitrate;
|
|
470
593
|
}
|
|
471
594
|
get redDistance() {
|
|
472
595
|
return this._redDistance;
|
|
@@ -475,27 +598,67 @@ class RTCRtpSender {
|
|
|
475
598
|
this._redDistance = n;
|
|
476
599
|
this.redEncoder.distance = n;
|
|
477
600
|
}
|
|
601
|
+
/** Internal: the negotiated send parameters, for a negotiation baseline. */
|
|
602
|
+
snapshotSendParams() {
|
|
603
|
+
return {
|
|
604
|
+
cname: this.cname,
|
|
605
|
+
mid: this.mid,
|
|
606
|
+
headerExtensions: [...this.headerExtensions],
|
|
607
|
+
rtpStreamId: this.rtpStreamId,
|
|
608
|
+
repairedRtpStreamId: this.repairedRtpStreamId,
|
|
609
|
+
codec: this.codec,
|
|
610
|
+
negotiatedCodecs: [...this.negotiatedCodecs],
|
|
611
|
+
sendPrimaryCodec: this.sendPrimaryCodec,
|
|
612
|
+
proposedPrimaryCodec: this.proposedPrimaryCodec,
|
|
613
|
+
track: this.track,
|
|
614
|
+
trackCodec: this.track?.codec,
|
|
615
|
+
rtxPayloadType: this.rtxPayloadType,
|
|
616
|
+
redRedundantPayloadType: this.redRedundantPayloadType,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Internal: a pending remote offer proposes `codecs` for the answer while
|
|
621
|
+
* the committed codec keeps sending until the final answer.
|
|
622
|
+
*/
|
|
623
|
+
proposeSend(codecs) {
|
|
624
|
+
this.proposedPrimaryCodec = primarySendCodecOf(codecs);
|
|
625
|
+
}
|
|
626
|
+
/** Internal: return to a negotiation baseline's send parameters. */
|
|
627
|
+
restoreSendParams(snapshot) {
|
|
628
|
+
this.cname = snapshot.cname;
|
|
629
|
+
this.mid = snapshot.mid;
|
|
630
|
+
this.headerExtensions = [...snapshot.headerExtensions];
|
|
631
|
+
this.rtpStreamId = snapshot.rtpStreamId;
|
|
632
|
+
this.repairedRtpStreamId = snapshot.repairedRtpStreamId;
|
|
633
|
+
this.codec = snapshot.codec;
|
|
634
|
+
this.negotiatedCodecs = [...snapshot.negotiatedCodecs];
|
|
635
|
+
this.sendPrimaryCodec = snapshot.sendPrimaryCodec;
|
|
636
|
+
this.proposedPrimaryCodec = snapshot.proposedPrimaryCodec;
|
|
637
|
+
if (this.track) {
|
|
638
|
+
// A track attached during the rolled-back negotiation sends with the
|
|
639
|
+
// restored codec, not the one a pranswer applied.
|
|
640
|
+
this.track.codec =
|
|
641
|
+
this.track === snapshot.track ? snapshot.trackCodec : this.codec;
|
|
642
|
+
}
|
|
643
|
+
this.rtxPayloadType = snapshot.rtxPayloadType;
|
|
644
|
+
this.redRedundantPayloadType = snapshot.redRedundantPayloadType;
|
|
645
|
+
}
|
|
478
646
|
prepareSend(params) {
|
|
479
647
|
this.cname = params.rtcp?.cname;
|
|
480
648
|
this.mid = params.muxId;
|
|
481
649
|
this.headerExtensions = params.headerExtensions;
|
|
650
|
+
// Keep a RID set via sendEncodings/setParameters when SDP carries none.
|
|
482
651
|
this.rtpStreamId = params.rtpStreamId ?? this.rtpStreamId;
|
|
483
652
|
this.repairedRtpStreamId = params.repairedRtpStreamId;
|
|
484
653
|
this.negotiatedCodecs = [...params.codecs];
|
|
485
|
-
this.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const redPrimaryPayloadType = this.codec?.name.toLowerCase() === "red"
|
|
489
|
-
? Number((this.codec.parameters ?? "").split("/")[0])
|
|
490
|
-
: undefined;
|
|
491
|
-
this.sendPrimaryCodec =
|
|
492
|
-
this.codec?.name.toLowerCase() === "red"
|
|
493
|
-
? params.codecs.find((codec) => !["red", "rtx"].includes(codec.name.toLowerCase()) &&
|
|
494
|
-
codec.payloadType === redPrimaryPayloadType)
|
|
495
|
-
: this.codec;
|
|
654
|
+
this.proposedPrimaryCodec = undefined;
|
|
655
|
+
this.codec = sendCodecOf(params.codecs);
|
|
656
|
+
this.sendPrimaryCodec = primarySendCodecOf(params.codecs);
|
|
496
657
|
if (this.track) {
|
|
497
658
|
this.track.codec = this.codec;
|
|
498
659
|
}
|
|
660
|
+
// Derived from these codecs only: a description without RTX/RED turns
|
|
661
|
+
// them off instead of keeping an earlier negotiation's payload type.
|
|
499
662
|
this.rtxPayloadType = undefined;
|
|
500
663
|
this.redRedundantPayloadType = undefined;
|
|
501
664
|
params.codecs.forEach((codec) => {
|
|
@@ -511,69 +674,32 @@ class RTCRtpSender {
|
|
|
511
674
|
}
|
|
512
675
|
void this.drainPendingRtp();
|
|
513
676
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
settlePendingRtp(item, error) {
|
|
518
|
-
if (error == undefined) {
|
|
519
|
-
item.resolve();
|
|
677
|
+
/** @internal Follow the transceiver's currentDirection. */
|
|
678
|
+
setSendSuppressed(suppressed) {
|
|
679
|
+
if (this.sendSuppressed === suppressed)
|
|
520
680
|
return;
|
|
681
|
+
this.sendSuppressed = suppressed;
|
|
682
|
+
if (suppressed) {
|
|
683
|
+
this.pendingRtp.discard();
|
|
684
|
+
// Drop media already accepted into the send FIFO and release a packet
|
|
685
|
+
// parked in a probe / pacing wait (same path as a source switch).
|
|
686
|
+
this.invalidateQueuedSource();
|
|
521
687
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
discardPendingRtp() {
|
|
525
|
-
const dropped = this.pendingRtp.splice(0);
|
|
526
|
-
for (const item of dropped) {
|
|
527
|
-
this.settlePendingRtp(item);
|
|
528
|
-
}
|
|
688
|
+
else
|
|
689
|
+
void this.drainPendingRtp();
|
|
529
690
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
while (this.pendingRtp.length > this.pendingRtpMaxLength) {
|
|
536
|
-
const dropped = this.pendingRtp.shift();
|
|
537
|
-
if (dropped) {
|
|
538
|
-
this.settlePendingRtp(dropped);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
691
|
+
canSendRtp() {
|
|
692
|
+
return (!this.stopped &&
|
|
693
|
+
!this.sendSuppressed &&
|
|
694
|
+
this.dtlsTransport?.state === "connected" &&
|
|
695
|
+
!!this.codec);
|
|
541
696
|
}
|
|
542
697
|
/**
|
|
543
|
-
* Send queued RTP once DTLS is connected and a codec is set.
|
|
544
|
-
*
|
|
545
|
-
* completes; dropping those packets would lose the start of a media source.
|
|
546
|
-
* `drainingPendingRtp` blocks re-entry while `dispatchRtp` is awaited;
|
|
547
|
-
* packets enqueued during that wait are drained by the recursive call after
|
|
548
|
-
* the flag is cleared.
|
|
698
|
+
* Send queued RTP once DTLS is connected and a codec is set.
|
|
699
|
+
* Drain uses {@link sendRtpInternal} so GCC pacing / TWCC stay on the send path.
|
|
549
700
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
this.drainingPendingRtp = true;
|
|
555
|
-
try {
|
|
556
|
-
while (this.pendingRtp.length > 0 && this.canSendRtp()) {
|
|
557
|
-
const item = this.pendingRtp.shift();
|
|
558
|
-
if (!this.canSendRtp()) {
|
|
559
|
-
this.settlePendingRtp(item);
|
|
560
|
-
continue;
|
|
561
|
-
}
|
|
562
|
-
try {
|
|
563
|
-
await this.dispatchRtp(item.packet);
|
|
564
|
-
this.settlePendingRtp(item);
|
|
565
|
-
}
|
|
566
|
-
catch (error) {
|
|
567
|
-
this.settlePendingRtp(item, error);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
finally {
|
|
572
|
-
this.drainingPendingRtp = false;
|
|
573
|
-
}
|
|
574
|
-
if (this.pendingRtp.length > 0 && this.canSendRtp()) {
|
|
575
|
-
await this.drainPendingRtp();
|
|
576
|
-
}
|
|
701
|
+
drainPendingRtp() {
|
|
702
|
+
return this.pendingRtp.drain(() => this.canSendRtp(), (packet, sourceEpoch) => this.dispatchMedia(packet, sourceEpoch));
|
|
577
703
|
}
|
|
578
704
|
registerTrack(track) {
|
|
579
705
|
if (track.stopped)
|
|
@@ -620,14 +746,21 @@ class RTCRtpSender {
|
|
|
620
746
|
throw new Error("track is ended");
|
|
621
747
|
(0, track_1.captureTrackSourceCodecs)(track);
|
|
622
748
|
const sourceCodecs = (0, track_1.getTrackSourceCodecs)(track);
|
|
623
|
-
|
|
749
|
+
const incompatible = [
|
|
750
|
+
this.sendPrimaryCodec,
|
|
751
|
+
this.proposedPrimaryCodec,
|
|
752
|
+
].find((primary) => primary != undefined &&
|
|
624
753
|
sourceCodecs != undefined &&
|
|
625
|
-
!sourceCodecs.some((source) => (0, codecCompatibility_1.isCodecCompatible)(source,
|
|
626
|
-
|
|
754
|
+
!sourceCodecs.some((source) => (0, codecCompatibility_1.isCodecCompatible)(source, primary)));
|
|
755
|
+
if (incompatible) {
|
|
756
|
+
throw (0, errors_1.createWebRtcDomException)("InvalidModificationError", `Track codec ${sourceCodecs.map((codec) => codec.mimeType).join(", ")} is incompatible with negotiated codec ${incompatible.mimeType}`);
|
|
627
757
|
}
|
|
628
|
-
if (this.sequenceNumber != undefined) {
|
|
758
|
+
if (this.continuity.sequenceNumber != undefined) {
|
|
629
759
|
this.scheduleRtpContinuity();
|
|
630
760
|
}
|
|
761
|
+
else {
|
|
762
|
+
this.invalidateQueuedSource();
|
|
763
|
+
}
|
|
631
764
|
this.registerTrack(track);
|
|
632
765
|
log("replaceTrack", "ssrc", track.ssrc, "rid", track.rid);
|
|
633
766
|
}
|
|
@@ -636,8 +769,9 @@ class RTCRtpSender {
|
|
|
636
769
|
* The same sender can resume sending after `replaceTrack(track)`.
|
|
637
770
|
*/
|
|
638
771
|
detachTrack() {
|
|
639
|
-
this.
|
|
640
|
-
this.
|
|
772
|
+
this.continuity.cancel();
|
|
773
|
+
this.pendingRtp.discard();
|
|
774
|
+
this.invalidateQueuedSource();
|
|
641
775
|
if (this.disposeTrack) {
|
|
642
776
|
this.disposeTrack();
|
|
643
777
|
this.disposeTrack = undefined;
|
|
@@ -646,10 +780,19 @@ class RTCRtpSender {
|
|
|
646
780
|
}
|
|
647
781
|
stop({ keepTrack = false } = {}) {
|
|
648
782
|
this.stopped = true;
|
|
649
|
-
|
|
650
|
-
|
|
783
|
+
// A stopped sender sends nothing: release its subscription on the
|
|
784
|
+
// (possibly BUNDLE-shared) DTLS transport, which outlives it.
|
|
785
|
+
for (const dispose of this.dtlsDisposer)
|
|
786
|
+
dispose();
|
|
787
|
+
this.dtlsDisposer = [];
|
|
788
|
+
this.continuity.cancel();
|
|
789
|
+
this.pendingRtp.discard();
|
|
790
|
+
// Invalidate in-flight sendRtp / maybeInjectProbePadding before dispose
|
|
791
|
+
// so they cannot emit padding or revive a disposed estimator.
|
|
792
|
+
this.bwe.bumpGeneration();
|
|
651
793
|
this.rtcpRunning = false;
|
|
652
794
|
this.rtcpCancel.abort();
|
|
795
|
+
this.bwe.close();
|
|
653
796
|
if (this.disposeTrack) {
|
|
654
797
|
this.disposeTrack();
|
|
655
798
|
this.disposeTrack = undefined;
|
|
@@ -657,6 +800,8 @@ class RTCRtpSender {
|
|
|
657
800
|
if (!keepTrack) {
|
|
658
801
|
this.track = null;
|
|
659
802
|
}
|
|
803
|
+
this.dtlsDisposer.forEach((dispose) => dispose());
|
|
804
|
+
this.dtlsDisposer = [];
|
|
660
805
|
}
|
|
661
806
|
async runRtcp() {
|
|
662
807
|
if (this.rtcpRunning || this.stopped)
|
|
@@ -667,19 +812,7 @@ class RTCRtpSender {
|
|
|
667
812
|
await (0, promises_1.setTimeout)(500 + Math.random() * 1000, undefined, {
|
|
668
813
|
signal: this.rtcpCancel.signal,
|
|
669
814
|
});
|
|
670
|
-
const packets = [
|
|
671
|
-
new rtp_1.RtcpSrPacket({
|
|
672
|
-
ssrc: this.ssrc,
|
|
673
|
-
senderInfo: new rtp_1.RtcpSenderInfo({
|
|
674
|
-
ntpTimestamp: this.ntpTimestamp,
|
|
675
|
-
rtpTimestamp: this.rtpTimestamp,
|
|
676
|
-
packetCount: this.packetCount,
|
|
677
|
-
octetCount: this.octetCount,
|
|
678
|
-
}),
|
|
679
|
-
}),
|
|
680
|
-
];
|
|
681
|
-
this.lastSRtimestamp = (0, utils_1.compactNtp)(this.ntpTimestamp);
|
|
682
|
-
this.lastSentSRTimestamp = (0, utils_1.timestampSeconds)();
|
|
815
|
+
const packets = [this.buildSenderReport()];
|
|
683
816
|
if (this.cname) {
|
|
684
817
|
packets.push(new rtp_1.RtcpSourceDescriptionPacket({
|
|
685
818
|
chunks: [
|
|
@@ -703,151 +836,393 @@ class RTCRtpSender {
|
|
|
703
836
|
}
|
|
704
837
|
catch (error) { }
|
|
705
838
|
}
|
|
839
|
+
/** Sender Report for the instant `nowMonotonicMs` ({@link SenderStatistics.buildSenderReport}). */
|
|
840
|
+
buildSenderReport(nowMonotonicMs = performance.now()) {
|
|
841
|
+
return this.stats.buildSenderReport(this.ssrc, nowMonotonicMs);
|
|
842
|
+
}
|
|
706
843
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
*
|
|
844
|
+
* Schedule RTP continuity rewrite for the next packet that is actually sent.
|
|
845
|
+
* The header argument is kept for API compatibility and is not used to compute
|
|
846
|
+
* offsets. `discontinuity` does not change sequence or timestamp mapping.
|
|
847
|
+
* `timestampStep` (default 1) is the only way to choose the timestamp increment
|
|
848
|
+
* at the source-switch boundary.
|
|
849
|
+
*/
|
|
850
|
+
replaceRTP(header, discontinuity = false, timestampStep = 1) {
|
|
851
|
+
this.scheduleRtpContinuity(timestampStep);
|
|
852
|
+
log("replaceRTP", this.continuity.sequenceNumber, header.sequenceNumber, discontinuity, timestampStep);
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Start a new source epoch and drop queued media of the previous source.
|
|
856
|
+
* A packet already past sequence allocation (in its DTLS write) completes;
|
|
857
|
+
* one still waiting on pacing/probe is dropped by {@link sendRtpInternal}.
|
|
858
|
+
*/
|
|
859
|
+
invalidateQueuedSource() {
|
|
860
|
+
this.sourceEpoch++;
|
|
861
|
+
// Release the running FIFO task if it is a stale packet parked in a
|
|
862
|
+
// probe / pacing wait, so new-source media is not held behind it.
|
|
863
|
+
this.sourceEpochCancel.abort();
|
|
864
|
+
this.sourceEpochCancel = new AbortController();
|
|
865
|
+
this.outgoing.dropStaleSource(this.sourceEpoch);
|
|
866
|
+
this.pendingRtp.dropStaleSource(this.sourceEpoch);
|
|
867
|
+
}
|
|
868
|
+
isStaleSource(sourceEpoch) {
|
|
869
|
+
return sourceEpoch !== undefined && sourceEpoch !== this.sourceEpoch;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Abort signal for a send wait: sender stop, estimator swap, plus source
|
|
873
|
+
* switch for media.
|
|
874
|
+
*/
|
|
875
|
+
sendWaitSignal(sourceEpoch) {
|
|
876
|
+
const signals = [this.rtcpCancel.signal, this.bwe.generationSignal];
|
|
877
|
+
if (sourceEpoch !== undefined) {
|
|
878
|
+
signals.push(this.sourceEpochCancel.signal);
|
|
879
|
+
}
|
|
880
|
+
return AbortSignal.any(signals);
|
|
881
|
+
}
|
|
882
|
+
/** A waiting send may still go out: not stopped, same estimator, same source. */
|
|
883
|
+
isSendAlive(generation, sourceEpoch) {
|
|
884
|
+
return (!this.stopped &&
|
|
885
|
+
generation === this.bwe.generation &&
|
|
886
|
+
!this.isStaleSource(sourceEpoch));
|
|
887
|
+
}
|
|
888
|
+
scheduleRtpContinuity(timestampStep = 1) {
|
|
889
|
+
this.invalidateQueuedSource();
|
|
890
|
+
this.continuity.schedule(timestampStep);
|
|
891
|
+
this.rtpCache = [];
|
|
892
|
+
}
|
|
893
|
+
dispatchMedia(packet, sourceEpoch) {
|
|
894
|
+
return this.dispatchOutgoing(() => this.sendRtpInternal(packet, {
|
|
895
|
+
injectProbePadding: true,
|
|
896
|
+
sourceEpoch,
|
|
897
|
+
}), { kind: "media", bytes: (0, rtpWire_1.estimateOutgoingBytes)(packet), sourceEpoch });
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Lightweight / disabled estimators neither pace nor probe, so RTP is written
|
|
901
|
+
* straight through as before the BWE abstraction: no FIFO, no queue limit,
|
|
902
|
+
* and no wait before the DTLS write. Pacing estimators (GCC) go through
|
|
903
|
+
* {@link outgoing}. A FIFO still draining after an estimator swap
|
|
904
|
+
* keeps its order by queuing behind it.
|
|
905
|
+
*/
|
|
906
|
+
dispatchOutgoing(task, meta) {
|
|
907
|
+
if (!this.outgoing.running && !(0, bandwidthEstimator_1.needsPacedSendPath)(this.bwe.estimator)) {
|
|
908
|
+
return task();
|
|
909
|
+
}
|
|
910
|
+
return this.outgoing.enqueue(task, meta);
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Send immediately by default or queue until DTLS is ready when pending RTP
|
|
914
|
+
* is enabled. Each call settles only after its own packet is sent or dropped.
|
|
719
915
|
*/
|
|
720
916
|
async sendRtp(rtp) {
|
|
721
|
-
|
|
917
|
+
// Drop (do not queue) while the negotiated direction does not send, so
|
|
918
|
+
// nothing is flushed in a burst when sending resumes.
|
|
919
|
+
if (this.stopped || this.sendSuppressed) {
|
|
722
920
|
return;
|
|
723
921
|
}
|
|
724
922
|
if (!this.pendingRtpEnabled) {
|
|
725
923
|
if (!this.canSendRtp()) {
|
|
726
924
|
return;
|
|
727
925
|
}
|
|
728
|
-
|
|
926
|
+
// Own the packet before any pacing wait: a track shared by several
|
|
927
|
+
// senders hands every subscriber the same RtpPacket, and header
|
|
928
|
+
// rewrites (SSRC/seq/extensions) must not leak across senders.
|
|
929
|
+
const packet = Buffer.isBuffer(rtp)
|
|
930
|
+
? rtp_1.RtpPacket.deSerialize(rtp)
|
|
931
|
+
: rtp.clone();
|
|
932
|
+
await this.dispatchMedia(packet, this.sourceEpoch);
|
|
729
933
|
return;
|
|
730
934
|
}
|
|
731
935
|
await new Promise((resolve, reject) => {
|
|
732
|
-
this.
|
|
936
|
+
this.pendingRtp.enqueue(rtp, this.sourceEpoch, resolve, reject);
|
|
733
937
|
void this.drainPendingRtp();
|
|
734
938
|
});
|
|
735
939
|
}
|
|
940
|
+
/** True when transport-wide CC header extension is negotiated. */
|
|
941
|
+
isTransportCcNegotiated() {
|
|
942
|
+
return this.headerExtensions.some((e) => e.uri === rtp_1.RTP_EXTENSION_URI.transportWideCC);
|
|
943
|
+
}
|
|
736
944
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* `timestampStep` (default 1) is the only way to choose the timestamp increment
|
|
741
|
-
* at the source-switch boundary.
|
|
945
|
+
* Padding needs an estimator that asks for it, TWCC so feedback can see it,
|
|
946
|
+
* and a negotiated RTX stream to carry it. Without RTX no padding is sent
|
|
947
|
+
* (see `GCC_KNOWN_DIFFERENCES`): media sequence numbers stay untouched.
|
|
742
948
|
*/
|
|
743
|
-
|
|
744
|
-
this.
|
|
745
|
-
|
|
949
|
+
canSendPadding() {
|
|
950
|
+
return (!this.sendSuppressed &&
|
|
951
|
+
(0, bandwidthEstimator_1.isProbePacingController)(this.bwe.estimator) &&
|
|
952
|
+
this.rtxPayloadType !== undefined &&
|
|
953
|
+
this.isTransportCcNegotiated());
|
|
746
954
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
955
|
+
/**
|
|
956
|
+
* Inject RTP padding packets while a GCC probe cluster is active and media
|
|
957
|
+
* alone has not yet filled min packets / min bitrate×duration.
|
|
958
|
+
*
|
|
959
|
+
* Responsibility split:
|
|
960
|
+
* - Estimator (`ProbeController` / `pendingProbePaddingPackets`) decides need
|
|
961
|
+
* - Sender generates padding-only RTP on the RTX SSRC with a TWCC seq +
|
|
962
|
+
* `isProbation` and paces them
|
|
963
|
+
*/
|
|
964
|
+
async maybeInjectProbePadding() {
|
|
965
|
+
if (!this.canSendPadding()) {
|
|
966
|
+
return 0;
|
|
967
|
+
}
|
|
968
|
+
if (this.nestOutgoingPadding) {
|
|
969
|
+
return this.padding.drainProbe();
|
|
970
|
+
}
|
|
971
|
+
return ((await this.outgoing.enqueue(() => this.padding.drainProbe(), {
|
|
972
|
+
kind: "padding",
|
|
973
|
+
bytes: this.bwe.estimator.probePaddingPacketBytes,
|
|
974
|
+
})) ?? 0);
|
|
751
975
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
976
|
+
/**
|
|
977
|
+
* pin padding_rate while LossBased is `kIncreaseUsingPadding`.
|
|
978
|
+
* Regular RTP padding (not probe/probation). Probe padding takes priority.
|
|
979
|
+
*/
|
|
980
|
+
async maybeInjectLossPadding() {
|
|
981
|
+
if (!this.canSendPadding()) {
|
|
982
|
+
return 0;
|
|
755
983
|
}
|
|
756
|
-
|
|
757
|
-
|
|
984
|
+
return ((await this.outgoing.enqueue(() => this.padding.drainLoss(), {
|
|
985
|
+
kind: "padding",
|
|
986
|
+
bytes: this.bwe.estimator.probePaddingPacketBytes,
|
|
987
|
+
})) ?? 0);
|
|
988
|
+
}
|
|
989
|
+
createPaddingInjector() {
|
|
990
|
+
const sender = this;
|
|
991
|
+
return new padding_1.PaddingInjector({
|
|
992
|
+
get estimator() {
|
|
993
|
+
return sender.bwe.estimator;
|
|
994
|
+
},
|
|
995
|
+
get generation() {
|
|
996
|
+
return sender.bwe.generation;
|
|
997
|
+
},
|
|
998
|
+
canDrain: () => !sender.stopped &&
|
|
999
|
+
sender.dtlsTransport?.state === "connected" &&
|
|
1000
|
+
!!sender.codec &&
|
|
1001
|
+
sender.canSendPadding(),
|
|
1002
|
+
isCancelled: (generation) => sender.stopped ||
|
|
1003
|
+
sender.sendSuppressed ||
|
|
1004
|
+
generation !== sender.bwe.generation,
|
|
1005
|
+
hasQueuedRealtimeMedia: () => sender.outgoing.hasQueuedRealtimeMedia(),
|
|
1006
|
+
sendPadding: (packetBytes, probe) => sender.sendRtpInternal(sender.createPaddingRtpPacket(packetBytes), {
|
|
1007
|
+
injectProbePadding: false,
|
|
1008
|
+
forceProbeTag: probe,
|
|
1009
|
+
isProbePadding: true,
|
|
1010
|
+
}),
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
/** Padding-only RTP on the RTX SSRC / payload type ({@link createRtxPaddingPacket}). */
|
|
1014
|
+
createPaddingRtpPacket(paddingSize) {
|
|
1015
|
+
return (0, rtp_1.createRtxPaddingPacket)({
|
|
1016
|
+
paddingSize,
|
|
1017
|
+
timestamp: this.continuity.timestamp ?? 0,
|
|
1018
|
+
payloadType: this.rtxPayloadType,
|
|
1019
|
+
ssrc: this.rtxSsrc,
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
async sendRtpInternal(rtp, opts = {}) {
|
|
1023
|
+
if (this.stopped)
|
|
1024
|
+
return;
|
|
1025
|
+
// Not sending in the negotiated direction: drop media and padding.
|
|
1026
|
+
// NACK retransmissions keep develop's behavior.
|
|
1027
|
+
if (this.sendSuppressed && !opts.isRetransmission)
|
|
1028
|
+
return;
|
|
1029
|
+
if (this.dtlsTransport.state !== "connected" || !this.codec) {
|
|
758
1030
|
return;
|
|
759
1031
|
}
|
|
760
|
-
|
|
1032
|
+
const sendClockRate = (this.sendPrimaryCodec ?? this.codec).clockRate;
|
|
1033
|
+
rtp = Buffer.isBuffer(rtp) ? rtp_1.RtpPacket.deSerialize(rtp) : rtp;
|
|
761
1034
|
const { header, payload } = rtp;
|
|
1035
|
+
// Capture BWE generation at send start. After await sendRtp, only deliver
|
|
1036
|
+
// SentInfo when the generation is unchanged — mid-send setBandwidthEstimator
|
|
1037
|
+
// must not pollute the new clean estimator with packets planned under the old one.
|
|
1038
|
+
const sendGeneration = this.bwe.generation;
|
|
1039
|
+
const estimatorAtStart = this.bwe.estimator;
|
|
1040
|
+
const twccOn = this.isTransportCcNegotiated();
|
|
1041
|
+
// Lightweight / disabled: no probe reservation or pacing wait (direct path).
|
|
1042
|
+
const paced = (0, bandwidthEstimator_1.needsPacedSendPath)(estimatorAtStart);
|
|
1043
|
+
// Stale source: drop before touching probe reservation or pacing budget.
|
|
1044
|
+
if (this.isStaleSource(opts.sourceEpoch)) {
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
// pin CurrentCluster: reserve probe id **before** the async send so a
|
|
1048
|
+
// concurrent completion cannot re-attribute this packet to the next cluster.
|
|
1049
|
+
let reservedClusterId;
|
|
1050
|
+
const wantsProbe = opts.forceProbeTag === true || estimatorAtStart.shouldTagProbePacket();
|
|
1051
|
+
if (paced && twccOn && wantsProbe) {
|
|
1052
|
+
const reservation = estimatorAtStart.reserveOutgoingProbe((0, utils_1.milliTime)());
|
|
1053
|
+
if (reservation) {
|
|
1054
|
+
reservedClusterId = reservation.clusterId;
|
|
1055
|
+
if (!(await this.awaitProbeSendTime(reservation.nextSendTimeMs, sendGeneration, opts.sourceEpoch))) {
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
else if (opts.forceProbeTag) {
|
|
1060
|
+
// Cluster already filled / discarded — do not emit untagged padding.
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
762
1064
|
const inputSequenceNumber = header.sequenceNumber;
|
|
763
1065
|
const inputTimestamp = header.timestamp;
|
|
764
|
-
if (
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
this.rtpContinuityPending = false;
|
|
771
|
-
this.pendingTimestampStep = 1;
|
|
1066
|
+
if (opts.isProbePadding) {
|
|
1067
|
+
// Padding is only ever sent on the negotiated RTX stream.
|
|
1068
|
+
if (this.rtxPayloadType === undefined)
|
|
1069
|
+
return;
|
|
1070
|
+
header.ssrc = this.rtxSsrc;
|
|
1071
|
+
header.payloadType = this.rtxPayloadType;
|
|
772
1072
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
case rtp_1.RTP_EXTENSION_URI.transportWideCC:
|
|
803
|
-
this.dtlsTransport.transportSequenceNumber = (0, common_1.uint16Add)(this.dtlsTransport.transportSequenceNumber, 1);
|
|
804
|
-
return (0, rtp_1.serializeTransportWideCC)(this.dtlsTransport.transportSequenceNumber);
|
|
805
|
-
case rtp_1.RTP_EXTENSION_URI.absSendTime:
|
|
806
|
-
return (0, rtp_1.serializeAbsSendTime)(ntpTimestamp);
|
|
807
|
-
}
|
|
808
|
-
})();
|
|
809
|
-
if (payload)
|
|
810
|
-
return { id: extension.id, payload };
|
|
811
|
-
})
|
|
812
|
-
.filter((v) => v);
|
|
813
|
-
for (const ext of originalHeaderExtensions) {
|
|
814
|
-
const exist = header.extensions.find((v) => v.id === ext.id);
|
|
815
|
-
if (exist) {
|
|
816
|
-
exist.payload = ext.payload;
|
|
1073
|
+
else if (!opts.isRetransmission) {
|
|
1074
|
+
header.ssrc = this.ssrc;
|
|
1075
|
+
header.payloadType = this.codec.payloadType;
|
|
1076
|
+
header.timestamp = this.continuity.mapTimestamp(inputTimestamp);
|
|
1077
|
+
}
|
|
1078
|
+
header.extensions = (0, rtp_1.buildSendHeaderExtensions)(header.extensions, this.headerExtensions, {
|
|
1079
|
+
mid: this.mid,
|
|
1080
|
+
rtpStreamId: this.rtpStreamId,
|
|
1081
|
+
repairedRtpStreamId: this.repairedRtpStreamId,
|
|
1082
|
+
});
|
|
1083
|
+
const useRed = !!this.redRedundantPayloadType &&
|
|
1084
|
+
!opts.isProbePadding &&
|
|
1085
|
+
!opts.isRetransmission;
|
|
1086
|
+
const estimatedPayloadLen = useRed
|
|
1087
|
+
? this.redEncoder.serializedLengthWith({
|
|
1088
|
+
block: payload,
|
|
1089
|
+
timestamp: header.timestamp,
|
|
1090
|
+
blockPT: this.redRedundantPayloadType,
|
|
1091
|
+
})
|
|
1092
|
+
: payload.length;
|
|
1093
|
+
const rfcPaddingLen = header.padding && header.paddingSize > 0 ? header.paddingSize : 0;
|
|
1094
|
+
const constructedBytes = header.serializeSize + estimatedPayloadLen + rfcPaddingLen;
|
|
1095
|
+
if (paced &&
|
|
1096
|
+
reservedClusterId === undefined &&
|
|
1097
|
+
this.mediaPacingEnabled &&
|
|
1098
|
+
twccOn &&
|
|
1099
|
+
estimatorAtStart.getPacingBitrateBps() > 0) {
|
|
1100
|
+
if (!(await this.awaitPacingBudget(constructedBytes, sendGeneration, opts.sourceEpoch))) {
|
|
1101
|
+
return;
|
|
817
1102
|
}
|
|
818
|
-
|
|
819
|
-
|
|
1103
|
+
}
|
|
1104
|
+
if (this.stopped || sendGeneration !== this.bwe.generation) {
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
// Direction changed to not sending while this packet waited.
|
|
1108
|
+
if (this.sendSuppressed && !opts.isRetransmission) {
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
// Accepted under a replaced/detached source: never send it, and never let
|
|
1112
|
+
// it consume the new source's continuity offset.
|
|
1113
|
+
if (this.isStaleSource(opts.sourceEpoch)) {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (opts.isProbePadding) {
|
|
1117
|
+
// RTX owns its sequence space, so padding never shifts media numbers.
|
|
1118
|
+
header.sequenceNumber = this.rtxSequenceNumber;
|
|
1119
|
+
this.rtxSequenceNumber = (0, common_1.uint16Add)(this.rtxSequenceNumber, 1);
|
|
1120
|
+
header.timestamp = this.continuity.timestamp ?? header.timestamp;
|
|
1121
|
+
}
|
|
1122
|
+
else if (!opts.isRetransmission) {
|
|
1123
|
+
if (this.continuity.assign(header, inputSequenceNumber, inputTimestamp)) {
|
|
1124
|
+
// ソース境界を SR の RTP/NTP 基準にも反映する。
|
|
1125
|
+
this.stats.resetClockAnchor();
|
|
820
1126
|
}
|
|
821
1127
|
}
|
|
822
|
-
header.extensions = header.extensions.sort((a, b) => a.id - b.id);
|
|
823
|
-
this.ntpTimestamp = ntpTimestamp;
|
|
824
|
-
this.rtpTimestamp = header.timestamp;
|
|
825
|
-
this.octetCount += payload.length;
|
|
826
|
-
this.headerBytesSent += header.serializeSize;
|
|
827
|
-
this.packetCount = (0, common_1.uint32Add)(this.packetCount, 1);
|
|
828
|
-
this.rtpCache[header.sequenceNumber % RTP_HISTORY_SIZE] = rtp;
|
|
829
1128
|
let rtpPayload = payload;
|
|
830
|
-
if (
|
|
1129
|
+
if (useRed) {
|
|
831
1130
|
this.redEncoder.push({
|
|
832
1131
|
block: rtpPayload,
|
|
833
1132
|
timestamp: header.timestamp,
|
|
834
1133
|
blockPT: this.redRedundantPayloadType,
|
|
835
1134
|
});
|
|
836
|
-
|
|
837
|
-
|
|
1135
|
+
rtpPayload = this.redEncoder.build().serialize();
|
|
1136
|
+
}
|
|
1137
|
+
const payloadOctetsForSr = rtpPayload.length;
|
|
1138
|
+
if (header.padding && header.paddingSize > 0) {
|
|
1139
|
+
rtpPayload = (0, rtp_1.appendRfc3550Padding)(rtpPayload, header.paddingSize);
|
|
1140
|
+
}
|
|
1141
|
+
const packetWideSeq = (0, rtp_1.stampHopByHopExtensions)(header, this.headerExtensions, {
|
|
1142
|
+
twccOn,
|
|
1143
|
+
allocateTransportWideSequence: () => this.dtlsTransport.allocateTransportWideSequence(),
|
|
1144
|
+
ntpTimestamp: (0, utils_1.ntpTime)(),
|
|
1145
|
+
});
|
|
1146
|
+
if (opts.isProbePadding) {
|
|
1147
|
+
// RTX padding: not part of the media SSRC's SR packet / octet counts.
|
|
1148
|
+
}
|
|
1149
|
+
else if (opts.isRetransmission) {
|
|
1150
|
+
this.stats.recordRetransmissionSent(header.serializeSize, payload.length);
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
this.stats.recordMediaSent(header.serializeSize, payloadOctetsForSr);
|
|
1154
|
+
if (!(0, rtp_1.isPaddingOnlyRtpPacket)(rtp)) {
|
|
1155
|
+
this.rtpCache[header.sequenceNumber % RTP_HISTORY_SIZE] = rtp;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const sendingAtMs = (0, utils_1.milliTime)();
|
|
1159
|
+
const { size, sendingAtMs: enqueueAtMs } = await (0, rtpWire_1.sendDtlsRtp)(this.dtlsTransport, rtpPayload, header, sendingAtMs);
|
|
1160
|
+
const sentAtMs = (0, utils_1.milliTime)();
|
|
1161
|
+
if (!opts.isProbePadding &&
|
|
1162
|
+
!opts.isRetransmission &&
|
|
1163
|
+
!(0, rtp_1.isPaddingOnlyRtpPacket)(rtp)) {
|
|
1164
|
+
this.stats.updateClockAnchor(header.timestamp, sendClockRate);
|
|
838
1165
|
}
|
|
839
|
-
const size = await this.dtlsTransport.sendRtp(rtpPayload, header);
|
|
840
1166
|
this.runRtcp();
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
1167
|
+
// BWE / TWCC only when transport-cc is negotiated — otherwise wideSeq would
|
|
1168
|
+
// not advance and probe padding would be useless / harmful.
|
|
1169
|
+
// Generation match: estimator was not swapped (or reset) while this packet
|
|
1170
|
+
// was in flight. Mismatch → discard (do not feed disposed or new clean BWE).
|
|
1171
|
+
if (twccOn &&
|
|
1172
|
+
packetWideSeq !== undefined &&
|
|
1173
|
+
sendGeneration === this.bwe.generation) {
|
|
1174
|
+
const priorUnacked = this.pendingUntrackedBytes;
|
|
1175
|
+
this.pendingUntrackedBytes = 0;
|
|
1176
|
+
const sentInfo = {
|
|
1177
|
+
wideSeq: packetWideSeq,
|
|
1178
|
+
size,
|
|
1179
|
+
sendingAtMs: enqueueAtMs,
|
|
1180
|
+
sentAtMs,
|
|
1181
|
+
isProbation: reservedClusterId !== undefined,
|
|
1182
|
+
probeClusterId: reservedClusterId,
|
|
1183
|
+
priorUnackedBytes: priorUnacked,
|
|
1184
|
+
isRetransmission: opts.isRetransmission === true,
|
|
1185
|
+
};
|
|
1186
|
+
estimatorAtStart.rtpPacketSent(sentInfo);
|
|
1187
|
+
}
|
|
1188
|
+
else if (twccOn && sendGeneration === this.bwe.generation) {
|
|
1189
|
+
// Same generation but no wideSeq (should be rare). Do not fold
|
|
1190
|
+
// previous-generation bytes into the next estimator.
|
|
1191
|
+
this.pendingUntrackedBytes += size;
|
|
1192
|
+
}
|
|
1193
|
+
if (opts.injectProbePadding &&
|
|
1194
|
+
twccOn &&
|
|
1195
|
+
(0, bandwidthEstimator_1.isProbePacingController)(estimatorAtStart) &&
|
|
1196
|
+
sendGeneration === this.bwe.generation) {
|
|
1197
|
+
this.nestOutgoingPadding = true;
|
|
1198
|
+
try {
|
|
1199
|
+
await this.maybeInjectProbePadding();
|
|
1200
|
+
}
|
|
1201
|
+
finally {
|
|
1202
|
+
this.nestOutgoingPadding = false;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
/** pin BitrateProber next_probe_time wait ({@link waitForProbeSendTime}). */
|
|
1207
|
+
awaitProbeSendTime(nextSendTimeMs, generation, sourceEpoch) {
|
|
1208
|
+
return (0, sendPacer_1.waitForProbeSendTime)(nextSendTimeMs, () => this.isSendAlive(generation, sourceEpoch), () => this.sendWaitSignal(sourceEpoch));
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Token-bucket wait against {@link pacingBitrateBps} for **media**.
|
|
1212
|
+
* Probe packets use {@link awaitProbeSendTime} instead.
|
|
1213
|
+
* Returns false if the sender is stopped, the estimator is swapped
|
|
1214
|
+
* (`generation` changes), or the packet's source is replaced/detached while
|
|
1215
|
+
* waiting (budget is not consumed then).
|
|
1216
|
+
*/
|
|
1217
|
+
awaitPacingBudget(packetBytes, generation, sourceEpoch) {
|
|
1218
|
+
return this.pacer.acquire(packetBytes, this.pacingBitrateBps, () => this.isSendAlive(generation, sourceEpoch), () => this.sendWaitSignal(sourceEpoch));
|
|
849
1219
|
}
|
|
850
|
-
|
|
1220
|
+
/**
|
|
1221
|
+
* @param firEntries Internal: the FCI entries of a FIR the router resolved to
|
|
1222
|
+
* this sender (see `KeyFrameRequestRouting`). Defaults to the entries for
|
|
1223
|
+
* the own SSRC.
|
|
1224
|
+
*/
|
|
1225
|
+
handleRtcpPacket(rtcpPacket, firEntries) {
|
|
851
1226
|
switch (rtcpPacket.type) {
|
|
852
1227
|
case rtp_1.RtcpSrPacket.type:
|
|
853
1228
|
case rtp_1.RtcpRrPacket.type:
|
|
@@ -856,22 +1231,12 @@ class RTCRtpSender {
|
|
|
856
1231
|
packet.reports
|
|
857
1232
|
.filter((report) => report.ssrc === this.ssrc)
|
|
858
1233
|
.forEach((report) => {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
report.dlsr / 65536;
|
|
866
|
-
this.totalRoundTripTime += rtt;
|
|
867
|
-
this.roundTripTimeMeasurements++;
|
|
868
|
-
if (this.rtt === undefined) {
|
|
869
|
-
this.rtt = rtt;
|
|
870
|
-
}
|
|
871
|
-
else {
|
|
872
|
-
this.rtt = RTT_ALPHA * this.rtt + (1 - RTT_ALPHA) * rtt;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
1234
|
+
const rawRttSeconds = this.stats.recordReceptionReport(report);
|
|
1235
|
+
// pin OnRoundTripTimeUpdate: only **unsmoothed** RTT goes to
|
|
1236
|
+
// AIMD (smoothed updates are discarded in GoogCc).
|
|
1237
|
+
// Lightweight / disabled no-op setRoundTripTime.
|
|
1238
|
+
if (rawRttSeconds !== undefined && rawRttSeconds > 0) {
|
|
1239
|
+
this.bwe.estimator.setRoundTripTime(rawRttSeconds * 1000);
|
|
875
1240
|
}
|
|
876
1241
|
});
|
|
877
1242
|
}
|
|
@@ -889,21 +1254,30 @@ class RTCRtpSender {
|
|
|
889
1254
|
case rtp_1.GenericNack.count:
|
|
890
1255
|
{
|
|
891
1256
|
const feedback = packet.feedback;
|
|
892
|
-
this.nackCount++;
|
|
1257
|
+
this.stats.nackCount++;
|
|
893
1258
|
feedback.lost.forEach(async (seqNum) => {
|
|
894
1259
|
let packet = this.rtpCache[seqNum % RTP_HISTORY_SIZE];
|
|
895
1260
|
if (packet && packet.header.sequenceNumber !== seqNum) {
|
|
896
1261
|
packet = undefined;
|
|
897
1262
|
}
|
|
1263
|
+
if (packet && (0, rtp_1.isPaddingOnlyRtpPacket)(packet)) {
|
|
1264
|
+
packet = undefined;
|
|
1265
|
+
}
|
|
898
1266
|
if (packet) {
|
|
899
1267
|
if (this.rtxPayloadType != undefined) {
|
|
900
1268
|
packet = (0, rtp_1.wrapRtx)(packet, this.rtxPayloadType, this.rtxSequenceNumber, this.rtxSsrc);
|
|
901
1269
|
this.rtxSequenceNumber = (0, common_1.uint16Add)(this.rtxSequenceNumber, 1);
|
|
902
1270
|
}
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
await this.
|
|
1271
|
+
const retransmission = packet;
|
|
1272
|
+
// Route through sendRtpInternal: new TWCC seq, pacing,
|
|
1273
|
+
// BWE SentInfo. Do not reuse the original transport-wide seq.
|
|
1274
|
+
await this.dispatchOutgoing(() => this.sendRtpInternal(retransmission, {
|
|
1275
|
+
injectProbePadding: false,
|
|
1276
|
+
isRetransmission: true,
|
|
1277
|
+
}), {
|
|
1278
|
+
kind: "rtx",
|
|
1279
|
+
bytes: (0, rtpWire_1.estimateOutgoingBytes)(retransmission),
|
|
1280
|
+
});
|
|
907
1281
|
}
|
|
908
1282
|
});
|
|
909
1283
|
this.onGenericNack.execute(feedback);
|
|
@@ -915,7 +1289,7 @@ class RTCRtpSender {
|
|
|
915
1289
|
case rtp_1.RtcpPayloadSpecificFeedback.type:
|
|
916
1290
|
{
|
|
917
1291
|
const packet = rtcpPacket;
|
|
918
|
-
switch (packet.feedback
|
|
1292
|
+
switch (packet.feedback?.count) {
|
|
919
1293
|
case rtp_1.ReceiverEstimatedMaxBitrate.count:
|
|
920
1294
|
{
|
|
921
1295
|
const feedback = packet.feedback;
|
|
@@ -924,8 +1298,35 @@ class RTCRtpSender {
|
|
|
924
1298
|
break;
|
|
925
1299
|
case rtp_1.PictureLossIndication.count:
|
|
926
1300
|
{
|
|
927
|
-
this.pliCount++;
|
|
1301
|
+
this.stats.pliCount++;
|
|
928
1302
|
this.onPictureLossIndication.execute();
|
|
1303
|
+
this.onKeyFrameRequest.execute("pli");
|
|
1304
|
+
}
|
|
1305
|
+
break;
|
|
1306
|
+
case rtp_1.FullIntraRequest.count:
|
|
1307
|
+
{
|
|
1308
|
+
const feedback = packet.feedback;
|
|
1309
|
+
const entries = firEntries ??
|
|
1310
|
+
feedback.fir.filter(({ ssrc }) => ssrc === this.ssrc);
|
|
1311
|
+
if (entries.length === 0)
|
|
1312
|
+
break;
|
|
1313
|
+
// W3C webrtc-stats: firCount is the number of FIR packets received,
|
|
1314
|
+
// however many FCI entries of the packet resolve to this sender
|
|
1315
|
+
this.stats.firCount++;
|
|
1316
|
+
// an entry with the same sequence number as the last one for its
|
|
1317
|
+
// (sender, target) pair is a retransmission (RFC 5104 4.3.1.1)
|
|
1318
|
+
let isNew = false;
|
|
1319
|
+
for (const { ssrc, sequenceNumber } of entries) {
|
|
1320
|
+
const key = `${feedback.senderSsrc}:${ssrc}`;
|
|
1321
|
+
if (this.lastFirSequenceNumbers.get(key) !== sequenceNumber) {
|
|
1322
|
+
isNew = true;
|
|
1323
|
+
}
|
|
1324
|
+
this.lastFirSequenceNumbers.set(key, sequenceNumber);
|
|
1325
|
+
}
|
|
1326
|
+
if (isNew) {
|
|
1327
|
+
this.onFullIntraRequest.execute(feedback);
|
|
1328
|
+
this.onKeyFrameRequest.execute("fir");
|
|
1329
|
+
}
|
|
929
1330
|
}
|
|
930
1331
|
break;
|
|
931
1332
|
}
|
|
@@ -946,100 +1347,22 @@ class RTCRtpSender {
|
|
|
946
1347
|
this.setSendEncodings(params.encodings);
|
|
947
1348
|
}
|
|
948
1349
|
}
|
|
949
|
-
get outboundRtpStatsId() {
|
|
950
|
-
return (0, stats_1.generateStatsId)("outbound-rtp", this.trackId);
|
|
951
|
-
}
|
|
952
|
-
get mediaSourceStatsId() {
|
|
953
|
-
return (0, stats_1.generateStatsId)("media-source", this.trackId);
|
|
954
|
-
}
|
|
955
|
-
get remoteInboundRtpStatsId() {
|
|
956
|
-
return (0, stats_1.generateStatsId)("remote-inbound-rtp", this.trackId);
|
|
957
|
-
}
|
|
958
1350
|
getStatsRootIds() {
|
|
959
|
-
return [this.
|
|
1351
|
+
return [(0, senderStats_1.senderStatsIds)(this.trackId).outboundRtp];
|
|
960
1352
|
}
|
|
961
1353
|
collectStats(timestamp) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
? (0, stats_1.generateStatsId)("transport", this.dtlsTransport.id)
|
|
965
|
-
: undefined;
|
|
966
|
-
const codecId = this.codec && transportId
|
|
967
|
-
? (0, stats_1.generateCodecStatsId)(transportId, this.codec.payloadType, this.trackId)
|
|
968
|
-
: undefined;
|
|
969
|
-
// Outbound RTP stats
|
|
970
|
-
const outboundRtpStats = {
|
|
971
|
-
type: "outbound-rtp",
|
|
972
|
-
id: this.outboundRtpStatsId,
|
|
973
|
-
timestamp,
|
|
1354
|
+
return this.stats.collect({
|
|
1355
|
+
trackId: this.trackId,
|
|
974
1356
|
ssrc: this.ssrc,
|
|
975
1357
|
kind: this.kind,
|
|
976
|
-
transportId,
|
|
977
|
-
codecId,
|
|
978
1358
|
mid: this.mid,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
headerBytesSent: this.headerBytesSent,
|
|
982
|
-
retransmittedPacketsSent: this.retransmittedPacketsSent || undefined,
|
|
983
|
-
retransmittedBytesSent: this.retransmittedBytesSent || undefined,
|
|
1359
|
+
dtlsTransport: this.dtlsTransport,
|
|
1360
|
+
codec: this.codec,
|
|
984
1361
|
rtxSsrc: this.rtxPayloadType ? this.rtxSsrc : undefined,
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
this.remotePacketsLost !== undefined ||
|
|
988
|
-
this.remoteFractionLost !== undefined
|
|
989
|
-
? this.remoteInboundRtpStatsId
|
|
1362
|
+
trackIdentifier: this.track
|
|
1363
|
+
? (this.track.id ?? this.trackId)
|
|
990
1364
|
: undefined,
|
|
991
|
-
|
|
992
|
-
pliCount: this.pliCount || undefined,
|
|
993
|
-
firCount: this.firCount || undefined,
|
|
994
|
-
};
|
|
995
|
-
stats.push(outboundRtpStats);
|
|
996
|
-
// Media source stats
|
|
997
|
-
if (this.track) {
|
|
998
|
-
const mediaSourceStats = {
|
|
999
|
-
type: "media-source",
|
|
1000
|
-
id: this.mediaSourceStatsId,
|
|
1001
|
-
timestamp,
|
|
1002
|
-
trackIdentifier: this.track.id ?? this.trackId,
|
|
1003
|
-
kind: this.kind,
|
|
1004
|
-
};
|
|
1005
|
-
stats.push(mediaSourceStats);
|
|
1006
|
-
}
|
|
1007
|
-
if (this.codec && transportId) {
|
|
1008
|
-
const codecStats = {
|
|
1009
|
-
type: "codec",
|
|
1010
|
-
id: codecId,
|
|
1011
|
-
timestamp,
|
|
1012
|
-
payloadType: this.codec.payloadType,
|
|
1013
|
-
transportId,
|
|
1014
|
-
mimeType: this.codec.mimeType,
|
|
1015
|
-
clockRate: this.codec.clockRate,
|
|
1016
|
-
channels: this.codec.channels,
|
|
1017
|
-
sdpFmtpLine: this.codec.parameters,
|
|
1018
|
-
};
|
|
1019
|
-
stats.push(codecStats);
|
|
1020
|
-
}
|
|
1021
|
-
// Remote inbound RTP stats (if we have RTT)
|
|
1022
|
-
if (this.rtt !== undefined ||
|
|
1023
|
-
this.remotePacketsLost !== undefined ||
|
|
1024
|
-
this.remoteFractionLost !== undefined) {
|
|
1025
|
-
const remoteInboundStats = {
|
|
1026
|
-
type: "remote-inbound-rtp",
|
|
1027
|
-
id: this.remoteInboundRtpStatsId,
|
|
1028
|
-
timestamp,
|
|
1029
|
-
ssrc: this.ssrc,
|
|
1030
|
-
kind: this.kind,
|
|
1031
|
-
transportId,
|
|
1032
|
-
codecId: outboundRtpStats.codecId,
|
|
1033
|
-
localId: outboundRtpStats.id,
|
|
1034
|
-
roundTripTime: this.rtt,
|
|
1035
|
-
totalRoundTripTime: this.totalRoundTripTime,
|
|
1036
|
-
roundTripTimeMeasurements: this.roundTripTimeMeasurements,
|
|
1037
|
-
packetsLost: this.remotePacketsLost,
|
|
1038
|
-
fractionLost: this.remoteFractionLost,
|
|
1039
|
-
};
|
|
1040
|
-
stats.push(remoteInboundStats);
|
|
1041
|
-
}
|
|
1042
|
-
return stats;
|
|
1365
|
+
}, timestamp);
|
|
1043
1366
|
}
|
|
1044
1367
|
async getStats() {
|
|
1045
1368
|
const timestamp = (0, stats_1.getStatsTimestamp)();
|
|
@@ -1051,4 +1374,17 @@ class RTCRtpSender {
|
|
|
1051
1374
|
}
|
|
1052
1375
|
}
|
|
1053
1376
|
exports.RTCRtpSender = RTCRtpSender;
|
|
1377
|
+
/** The codec RTP is sent with: the first non-RTX codec. */
|
|
1378
|
+
function sendCodecOf(codecs) {
|
|
1379
|
+
return (codecs.find((codec) => codec.name.toLowerCase() !== "rtx") ?? codecs[0]);
|
|
1380
|
+
}
|
|
1381
|
+
/** The media codec RTP carries: RED's primary payload, else the send codec. */
|
|
1382
|
+
function primarySendCodecOf(codecs) {
|
|
1383
|
+
const codec = sendCodecOf(codecs);
|
|
1384
|
+
if (codec?.name.toLowerCase() !== "red")
|
|
1385
|
+
return codec;
|
|
1386
|
+
const primaryPayloadType = Number((codec.parameters ?? "").split("/")[0]);
|
|
1387
|
+
return codecs.find((candidate) => !["red", "rtx"].includes(candidate.name.toLowerCase()) &&
|
|
1388
|
+
candidate.payloadType === primaryPayloadType);
|
|
1389
|
+
}
|
|
1054
1390
|
//# sourceMappingURL=rtpSender.js.map
|