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
|
@@ -0,0 +1,1391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GccBandwidthEstimator = void 0;
|
|
4
|
+
/*!
|
|
5
|
+
* Portions of this file are ported from libwebrtc
|
|
6
|
+
* (https://webrtc.googlesource.com/src, commit 0fda16159e33adf59c71a7ad1173dcbe5a632102).
|
|
7
|
+
* Copyright (c) 2011, The WebRTC project authors. All rights reserved.
|
|
8
|
+
* Use of that source is governed by a BSD-style license and an additional
|
|
9
|
+
* patent grant; both are reproduced in THIRD_PARTY_LICENSES_LIBWEBRTC.txt
|
|
10
|
+
* (shipped with this package).
|
|
11
|
+
*/
|
|
12
|
+
const common_1 = require("../../../../imports/common");
|
|
13
|
+
const utils_1 = require("../../../../utils");
|
|
14
|
+
const bandwidthEstimator_1 = require("../../bandwidthEstimator");
|
|
15
|
+
const twccFeedbackAdapter_1 = require("../twccFeedbackAdapter");
|
|
16
|
+
const acknowledgedBitrateEstimator_1 = require("./acknowledgedBitrateEstimator");
|
|
17
|
+
const aimdRateControl_1 = require("./aimdRateControl");
|
|
18
|
+
const alrDetector_1 = require("./alrDetector");
|
|
19
|
+
const bandwidthLimitedCause_1 = require("./bandwidthLimitedCause");
|
|
20
|
+
const constants_1 = require("./constants");
|
|
21
|
+
const interArrivalDelta_1 = require("./interArrivalDelta");
|
|
22
|
+
const lossBasedBwe_1 = require("./lossBasedBwe");
|
|
23
|
+
const probeController_1 = require("./probeController");
|
|
24
|
+
const rttBasedBackoff_1 = require("./rttBasedBackoff");
|
|
25
|
+
const trendlineEstimator_1 = require("./trendlineEstimator");
|
|
26
|
+
/**
|
|
27
|
+
* Google Congestion Control send-side bandwidth estimator (libwebrtc-aligned).
|
|
28
|
+
*
|
|
29
|
+
* - {@link TrendlineEstimator}: delay gradient + overuse hypothesis
|
|
30
|
+
* - {@link AimdRateControl}: delay-based A_hat
|
|
31
|
+
* - {@link LossBasedBwe}: loss path
|
|
32
|
+
* - {@link ProbeController}: exponential / further probes
|
|
33
|
+
*
|
|
34
|
+
* Bitrate is published only after at least one **known** sent sequence is
|
|
35
|
+
* observed in TWCC (empty / unmatched feedback does not notify).
|
|
36
|
+
*/
|
|
37
|
+
class GccBandwidthEstimator {
|
|
38
|
+
get availableBitrate() {
|
|
39
|
+
return this._availableBitrate;
|
|
40
|
+
}
|
|
41
|
+
get usageState() {
|
|
42
|
+
return this.trendline.state;
|
|
43
|
+
}
|
|
44
|
+
get probeState() {
|
|
45
|
+
return this.probe.probeState;
|
|
46
|
+
}
|
|
47
|
+
get suggestedProbeBitrateBps() {
|
|
48
|
+
return this.probe.suggestedProbeBitrateBps;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* pin CorrectedRtt = timeout_correction + last propagation RTT.
|
|
52
|
+
* Grows while packets are sent without TWCC (feedback stall).
|
|
53
|
+
*/
|
|
54
|
+
get correctedRttMs() {
|
|
55
|
+
return this.rttBackoff.correctedRttMs();
|
|
56
|
+
}
|
|
57
|
+
/** pin `RttBasedBackoff::IsRttAboveLimit` (CorrectedRtt > 3s). */
|
|
58
|
+
get rttAboveLimit() {
|
|
59
|
+
return this.rttBackoff.isRttAboveLimit();
|
|
60
|
+
}
|
|
61
|
+
getPacingBitrateBps() {
|
|
62
|
+
const target = this._availableBitrate > 0
|
|
63
|
+
? this._availableBitrate
|
|
64
|
+
: this.currentTargetBps > 0
|
|
65
|
+
? this.currentTargetBps
|
|
66
|
+
: this.startBitrateBps;
|
|
67
|
+
// pin GetPacingRates: 2.5× until first transport feedback, then 1.1×.
|
|
68
|
+
const factor = this.hasValidSample
|
|
69
|
+
? constants_1.kDefaultPaceMultiplierWithSendSideBwe
|
|
70
|
+
: constants_1.kDefaultPaceMultiplier;
|
|
71
|
+
const probeTarget = this.probe.currentProbeTargetBps;
|
|
72
|
+
return Math.max(target * factor, probeTarget);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* pin `BitrateProber::CurrentCluster` — must be called **before** send.
|
|
76
|
+
*/
|
|
77
|
+
reserveOutgoingProbe(nowMs) {
|
|
78
|
+
if (this.disposed)
|
|
79
|
+
return undefined;
|
|
80
|
+
return this.probe.reserveOutgoingProbe(nowMs);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* pin `GetPacingRates` padding_rate when loss state is
|
|
84
|
+
* `kIncreaseUsingPadding`: last loss-based target (current target).
|
|
85
|
+
*/
|
|
86
|
+
getPaddingBitrateBps() {
|
|
87
|
+
if (this.disposed)
|
|
88
|
+
return 0;
|
|
89
|
+
if (this.lossBwe.lossState !== "increase_using_padding")
|
|
90
|
+
return 0;
|
|
91
|
+
if (this.currentTargetBps > 0)
|
|
92
|
+
return this.currentTargetBps;
|
|
93
|
+
return this.lossBasedBps > 0 ? this.lossBasedBps : 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Padding packets to send so the token-bucket approaches
|
|
97
|
+
* {@link getPaddingBitrateBps} when media is sparse. 0 while probing.
|
|
98
|
+
*/
|
|
99
|
+
pendingLossPaddingPackets(packetBytes = constants_1.kProbePaddingPacketBytes) {
|
|
100
|
+
if (this.disposed)
|
|
101
|
+
return 0;
|
|
102
|
+
if (this.probe.shouldTagProbePacket())
|
|
103
|
+
return 0;
|
|
104
|
+
this.accrueLossPadding(this.clock());
|
|
105
|
+
if (this.paddingDueBytes <= 0)
|
|
106
|
+
return 0;
|
|
107
|
+
return Math.ceil(this.paddingDueBytes / Math.max(1, packetBytes));
|
|
108
|
+
}
|
|
109
|
+
shouldTagProbePacket() {
|
|
110
|
+
if (this.disposed)
|
|
111
|
+
return false;
|
|
112
|
+
return this.probe.shouldTagProbePacket();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* How many padding packets the sender should inject to progress the active
|
|
116
|
+
* probe cluster when media is sparse. 0 if not probing or cluster is full.
|
|
117
|
+
*/
|
|
118
|
+
pendingProbePaddingPackets(packetBytes = constants_1.kProbePaddingPacketBytes) {
|
|
119
|
+
if (this.disposed)
|
|
120
|
+
return 0;
|
|
121
|
+
if (!this.probe.shouldTagProbePacket())
|
|
122
|
+
return 0;
|
|
123
|
+
const remaining = this.probe.remainingProbeBytes(packetBytes);
|
|
124
|
+
if (remaining <= 0)
|
|
125
|
+
return 0;
|
|
126
|
+
return Math.ceil(remaining / Math.max(1, packetBytes));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* pin GoogCcNetworkController::OnProcessInterval order:
|
|
130
|
+
* ResetConstraints / SetBitrates (first interval → {@link ensureProbing})
|
|
131
|
+
* → UpdateEstimate
|
|
132
|
+
* → SetAlrStartTime
|
|
133
|
+
* → ProbeController::Process
|
|
134
|
+
* → MaybeTriggerOnNetworkChanged
|
|
135
|
+
*
|
|
136
|
+
* Process still sees the **previous** BandwidthLimitedCause. A tick that
|
|
137
|
+
* first crosses the RTT limit can therefore emit a due ALR probe, and only
|
|
138
|
+
* afterwards publish `kRttBasedBackOffHighRtt`. Does **not** call
|
|
139
|
+
* {@link RttBasedBackoff.onSentPacket}.
|
|
140
|
+
*/
|
|
141
|
+
process(nowMs) {
|
|
142
|
+
if (this.disposed || !Number.isFinite(nowMs))
|
|
143
|
+
return;
|
|
144
|
+
// Age-out send history even when media is idle (pin 60s window).
|
|
145
|
+
// rtpPacketSent-only prune would leak after send stop.
|
|
146
|
+
this.feedbackAdapter.prune(nowMs);
|
|
147
|
+
this.accrueLossPadding(nowMs);
|
|
148
|
+
// pin first OnProcessInterval ResetConstraints → ProbeController::SetBitrates
|
|
149
|
+
this.ensureProbing(nowMs);
|
|
150
|
+
// 1) bandwidth_estimation_.UpdateEstimate
|
|
151
|
+
this.updateEstimateOnProcessInterval(nowMs);
|
|
152
|
+
// 2) ProbeController::SetAlrStartTime
|
|
153
|
+
this.syncAlr(nowMs);
|
|
154
|
+
// 3) ProbeController::Process (still previous cause)
|
|
155
|
+
for (const cfg of this.probe.process(nowMs)) {
|
|
156
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
157
|
+
}
|
|
158
|
+
// 4) MaybeTriggerOnNetworkChanged — ALR budget + estimated/cause
|
|
159
|
+
this.propagateTarget(nowMs);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* pin `EnablePeriodicAlrProbing` / later `OnStreamsConfig`.
|
|
163
|
+
* Default remains false until the caller opts in.
|
|
164
|
+
*/
|
|
165
|
+
enablePeriodicAlrProbing(enable) {
|
|
166
|
+
this.periodicAlrProbing = enable;
|
|
167
|
+
this.probe.enablePeriodicAlrProbing(enable);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* pin `OnNetworkStateEstimate` / `SetNetworkStateEstimate`.
|
|
171
|
+
* `linkCapacityUpperBps <= 0` clears the estimate on ProbeController and AIMD.
|
|
172
|
+
*/
|
|
173
|
+
setNetworkStateEstimate(linkCapacityUpperBps, linkCapacityLowerBps = 0) {
|
|
174
|
+
if (this.disposed)
|
|
175
|
+
return;
|
|
176
|
+
this.networkLowerBps =
|
|
177
|
+
Number.isFinite(linkCapacityLowerBps) && linkCapacityLowerBps > 0
|
|
178
|
+
? linkCapacityLowerBps
|
|
179
|
+
: 0;
|
|
180
|
+
this.probe.setNetworkStateEstimate(linkCapacityUpperBps);
|
|
181
|
+
this.aimd.setNetworkStateEstimate(linkCapacityUpperBps, linkCapacityLowerBps);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* pin `OnTargetRateConstraints` / `ResetConstraints` / `ClampConstraints`
|
|
185
|
+
* then `ProbeController::SetBitrates`.
|
|
186
|
+
*
|
|
187
|
+
* Constraints are **replaced** (pin `ResetConstraints`), not merged
|
|
188
|
+
* with the previous min/max. `min = 0` floors at {@link kMinBitrateBps};
|
|
189
|
+
* non-finite / non-positive max clears the app cap (target 1 Gbps,
|
|
190
|
+
* probe 5 Mbps). `start = 0` does not overwrite current_target.
|
|
191
|
+
*
|
|
192
|
+
* Normalization (pin order): min floored at {@link kMinBitrateBps} →
|
|
193
|
+
* max raised to min → start raised to min when `start > 0`. The same
|
|
194
|
+
* triple is then applied to AIMD, LossBasedBwe, ProbeController, and
|
|
195
|
+
* {@link applyTargetLimits}.
|
|
196
|
+
*
|
|
197
|
+
* While probing is `complete`, a **higher** max than the previous max
|
|
198
|
+
* (and than the current estimate) starts a single probe at the new max
|
|
199
|
+
* (`probe_further=false`, pin `SetBitrates` / `kProbingComplete`).
|
|
200
|
+
*/
|
|
201
|
+
setBitrates(minBps, startBps, maxBps) {
|
|
202
|
+
if (this.disposed)
|
|
203
|
+
return;
|
|
204
|
+
const nowMs = this.clock();
|
|
205
|
+
const clamped = this.clampConstraints(minBps, startBps, maxBps);
|
|
206
|
+
this.minConfiguredBps = clamped.minBps;
|
|
207
|
+
this.aimd.setMinBitrate(clamped.minBps);
|
|
208
|
+
if (clamped.startBps > 0) {
|
|
209
|
+
this.startBitrateBps = clamped.startBps;
|
|
210
|
+
this.aimd.setStartBitrate(clamped.startBps);
|
|
211
|
+
// pin SetSendBitrate: delay_based_limit_ = +∞ so the new start is
|
|
212
|
+
// not capped by a stale delay estimate, then current_target = start.
|
|
213
|
+
this.delayBasedLimitBps = Number.POSITIVE_INFINITY;
|
|
214
|
+
this.currentTargetBps = clamped.startBps;
|
|
215
|
+
}
|
|
216
|
+
// pin ResetConstraints: always replace max (PlusInfinity → unset app
|
|
217
|
+
// cap). start=0 must not overwrite estimated_bitrate_ / current_target_
|
|
218
|
+
// (pin SetBitrates skips SetSendBitrate).
|
|
219
|
+
this.appMaxBps = clamped.maxBps;
|
|
220
|
+
this.lossBwe.setMinMaxBitrate(this.minConfiguredBps, this.targetMaxBps());
|
|
221
|
+
this.probingConfigured = true;
|
|
222
|
+
for (const cfg of this.probe.setBitrates(this.minConfiguredBps, clamped.startBps, this.probeMaxBps(), nowMs)) {
|
|
223
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
224
|
+
}
|
|
225
|
+
this.applyTargetLimits();
|
|
226
|
+
if (this.hasValidSample || this._availableBitrate > 0) {
|
|
227
|
+
(0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, this.currentTargetBps);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* pin OnRoundTripTimeUpdate → DelayBasedBwe::OnRttUpdate → AimdRateControl::SetRtt.
|
|
232
|
+
* Callers must pass **raw** (unsmoothed) RTCP RR RTT in milliseconds — pin
|
|
233
|
+
* GoogCc discards smoothed RTT updates. Independent of TWCC propagation RTT
|
|
234
|
+
* used by {@link RttBasedBackoff}.
|
|
235
|
+
*/
|
|
236
|
+
setRoundTripTime(rttMs) {
|
|
237
|
+
this.aimd.setRtt(rttMs);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* pin `OnTransportLossReport` → `UpdatePacketsLost`.
|
|
241
|
+
*
|
|
242
|
+
* Feeds `last_fraction_loss_` / `first_report_time_` for the UpdateEstimate
|
|
243
|
+
* **startup** gate. Does not adopt LossBasedV2 (that stays on TWCC).
|
|
244
|
+
* Fraction-loss is published only after
|
|
245
|
+
* {@link kStartPhaseLossReportMinPackets} packets accumulate.
|
|
246
|
+
*
|
|
247
|
+
* Not on the thin {@link BandwidthEstimator} interface — RTCP RR / XR
|
|
248
|
+
* wiring is GCC-specific (same pattern as {@link setRoundTripTime}).
|
|
249
|
+
*/
|
|
250
|
+
updatePacketsLost(packetsLost, numberOfPackets, atTimeMs) {
|
|
251
|
+
if (this.disposed)
|
|
252
|
+
return;
|
|
253
|
+
const nowMs = atTimeMs ?? this.clock();
|
|
254
|
+
if (!Number.isFinite(nowMs))
|
|
255
|
+
return;
|
|
256
|
+
if (!Number.isFinite(this.firstReportTimeMs) ||
|
|
257
|
+
this.firstReportTimeMs < 0) {
|
|
258
|
+
this.firstReportTimeMs = nowMs;
|
|
259
|
+
}
|
|
260
|
+
if (!(numberOfPackets > 0))
|
|
261
|
+
return;
|
|
262
|
+
const expected = this.expectedPacketsSinceLastLossUpdate + numberOfPackets;
|
|
263
|
+
if (expected < constants_1.kStartPhaseLossReportMinPackets) {
|
|
264
|
+
this.expectedPacketsSinceLastLossUpdate = expected;
|
|
265
|
+
this.lostPacketsSinceLastLossUpdate += packetsLost;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const lostQ8 = Math.max(this.lostPacketsSinceLastLossUpdate + packetsLost, 0) << 8;
|
|
269
|
+
this.lastFractionLoss = Math.min(Math.floor(lostQ8 / expected), 255);
|
|
270
|
+
this.lostPacketsSinceLastLossUpdate = 0;
|
|
271
|
+
this.expectedPacketsSinceLastLossUpdate = 0;
|
|
272
|
+
this.updateEstimate(nowMs);
|
|
273
|
+
if (this.hasValidSample || this._availableBitrate > 0) {
|
|
274
|
+
(0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, this.currentTargetBps);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* pin `OnNetworkAvailability`. Initial 3x/6x probing starts only after the
|
|
279
|
+
* transport is send-ready (and SetBitrates / first ProcessInterval has
|
|
280
|
+
* stored a start bitrate).
|
|
281
|
+
*/
|
|
282
|
+
setNetworkAvailable(available) {
|
|
283
|
+
if (this.disposed)
|
|
284
|
+
return;
|
|
285
|
+
const nowMs = this.clock();
|
|
286
|
+
for (const cfg of this.probe.onNetworkAvailability(available, nowMs)) {
|
|
287
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @param startBitrateBps Initial target / AIMD start (bps).
|
|
292
|
+
* @param options.clock Optional sender clock for unit tests. Must match the
|
|
293
|
+
* domain of {@link SentInfo.sendingAtMs} used with this instance.
|
|
294
|
+
* Production omits this (defaults to {@link milliTime}).
|
|
295
|
+
* @param options.periodicAlrProbing pin `requests_alr_probing` (default false).
|
|
296
|
+
*/
|
|
297
|
+
constructor(startBitrateBps = constants_1.kDefaultStartBitrateBps, options) {
|
|
298
|
+
/** @internal */
|
|
299
|
+
Object.defineProperty(this, "_availableBitrate", {
|
|
300
|
+
enumerable: true,
|
|
301
|
+
configurable: true,
|
|
302
|
+
writable: true,
|
|
303
|
+
value: 0
|
|
304
|
+
});
|
|
305
|
+
Object.defineProperty(this, "processIntervalMs", {
|
|
306
|
+
enumerable: true,
|
|
307
|
+
configurable: true,
|
|
308
|
+
writable: true,
|
|
309
|
+
value: constants_1.kGoogCcProcessIntervalMs
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(this, "probePaddingPacketBytes", {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
configurable: true,
|
|
314
|
+
writable: true,
|
|
315
|
+
value: constants_1.kProbePaddingPacketBytes
|
|
316
|
+
});
|
|
317
|
+
Object.defineProperty(this, "probePaddingMaxBurst", {
|
|
318
|
+
enumerable: true,
|
|
319
|
+
configurable: true,
|
|
320
|
+
writable: true,
|
|
321
|
+
value: constants_1.kProbePaddingMaxBurst
|
|
322
|
+
});
|
|
323
|
+
Object.defineProperty(this, "onAvailableBitrate", {
|
|
324
|
+
enumerable: true,
|
|
325
|
+
configurable: true,
|
|
326
|
+
writable: true,
|
|
327
|
+
value: new common_1.Event()
|
|
328
|
+
});
|
|
329
|
+
Object.defineProperty(this, "onOveruseDetected", {
|
|
330
|
+
enumerable: true,
|
|
331
|
+
configurable: true,
|
|
332
|
+
writable: true,
|
|
333
|
+
value: new common_1.Event()
|
|
334
|
+
});
|
|
335
|
+
Object.defineProperty(this, "onProbeClusterConfig", {
|
|
336
|
+
enumerable: true,
|
|
337
|
+
configurable: true,
|
|
338
|
+
writable: true,
|
|
339
|
+
value: new common_1.Event()
|
|
340
|
+
});
|
|
341
|
+
/**
|
|
342
|
+
* @deprecated No-op compatibility with LightweightBandwidthEstimator.
|
|
343
|
+
* Never fires.
|
|
344
|
+
*/
|
|
345
|
+
Object.defineProperty(this, "onCongestion", {
|
|
346
|
+
enumerable: true,
|
|
347
|
+
configurable: true,
|
|
348
|
+
writable: true,
|
|
349
|
+
value: new common_1.Event()
|
|
350
|
+
});
|
|
351
|
+
/**
|
|
352
|
+
* @deprecated No-op compatibility with LightweightBandwidthEstimator.
|
|
353
|
+
* Never fires.
|
|
354
|
+
*/
|
|
355
|
+
Object.defineProperty(this, "onCongestionScore", {
|
|
356
|
+
enumerable: true,
|
|
357
|
+
configurable: true,
|
|
358
|
+
writable: true,
|
|
359
|
+
value: new common_1.Event()
|
|
360
|
+
});
|
|
361
|
+
/** @deprecated Always false on GCC. */
|
|
362
|
+
Object.defineProperty(this, "congestion", {
|
|
363
|
+
enumerable: true,
|
|
364
|
+
configurable: true,
|
|
365
|
+
writable: true,
|
|
366
|
+
value: false
|
|
367
|
+
});
|
|
368
|
+
/** @deprecated Always 1 on GCC. */
|
|
369
|
+
Object.defineProperty(this, "congestionScore", {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
configurable: true,
|
|
372
|
+
writable: true,
|
|
373
|
+
value: 1
|
|
374
|
+
});
|
|
375
|
+
Object.defineProperty(this, "trendline", {
|
|
376
|
+
enumerable: true,
|
|
377
|
+
configurable: true,
|
|
378
|
+
writable: true,
|
|
379
|
+
value: new trendlineEstimator_1.TrendlineEstimator()
|
|
380
|
+
});
|
|
381
|
+
Object.defineProperty(this, "aimd", {
|
|
382
|
+
enumerable: true,
|
|
383
|
+
configurable: true,
|
|
384
|
+
writable: true,
|
|
385
|
+
value: new aimdRateControl_1.AimdRateControl()
|
|
386
|
+
});
|
|
387
|
+
Object.defineProperty(this, "lossBwe", {
|
|
388
|
+
enumerable: true,
|
|
389
|
+
configurable: true,
|
|
390
|
+
writable: true,
|
|
391
|
+
value: new lossBasedBwe_1.LossBasedBwe()
|
|
392
|
+
});
|
|
393
|
+
Object.defineProperty(this, "probe", {
|
|
394
|
+
enumerable: true,
|
|
395
|
+
configurable: true,
|
|
396
|
+
writable: true,
|
|
397
|
+
value: new probeController_1.ProbeController()
|
|
398
|
+
});
|
|
399
|
+
/** pin `AlrDetector` — send vs estimate budget. */
|
|
400
|
+
Object.defineProperty(this, "alr", {
|
|
401
|
+
enumerable: true,
|
|
402
|
+
configurable: true,
|
|
403
|
+
writable: true,
|
|
404
|
+
value: new alrDetector_1.AlrDetector()
|
|
405
|
+
});
|
|
406
|
+
Object.defineProperty(this, "previouslyInAlr", {
|
|
407
|
+
enumerable: true,
|
|
408
|
+
configurable: true,
|
|
409
|
+
writable: true,
|
|
410
|
+
value: false
|
|
411
|
+
});
|
|
412
|
+
/** After dispose(), public I/O is a no-op so a leftover padding loop cannot revive state. */
|
|
413
|
+
Object.defineProperty(this, "disposed", {
|
|
414
|
+
enumerable: true,
|
|
415
|
+
configurable: true,
|
|
416
|
+
writable: true,
|
|
417
|
+
value: false
|
|
418
|
+
});
|
|
419
|
+
Object.defineProperty(this, "interArrival", {
|
|
420
|
+
enumerable: true,
|
|
421
|
+
configurable: true,
|
|
422
|
+
writable: true,
|
|
423
|
+
value: new interArrivalDelta_1.InterArrivalDelta()
|
|
424
|
+
});
|
|
425
|
+
/** Unwraps 24-bit TWCC reference_time across feedbacks. */
|
|
426
|
+
/**
|
|
427
|
+
* Sender clock. Production: {@link milliTime}. Tests may inject a synthetic
|
|
428
|
+
* clock so send / feedback stay in one domain (no production clock heuristic).
|
|
429
|
+
*/
|
|
430
|
+
Object.defineProperty(this, "clock", {
|
|
431
|
+
enumerable: true,
|
|
432
|
+
configurable: true,
|
|
433
|
+
writable: true,
|
|
434
|
+
value: void 0
|
|
435
|
+
});
|
|
436
|
+
/**
|
|
437
|
+
* Send history + feedback normalization (pin TransportFeedbackAdapter
|
|
438
|
+
* `history_`). Received packets leave history, so duplicate / corrective
|
|
439
|
+
* reports are dropped before any subsystem sees them. Not-received packets
|
|
440
|
+
* stay so a later feedback can still report them as received.
|
|
441
|
+
*/
|
|
442
|
+
Object.defineProperty(this, "feedbackAdapter", {
|
|
443
|
+
enumerable: true,
|
|
444
|
+
configurable: true,
|
|
445
|
+
writable: true,
|
|
446
|
+
value: new twccFeedbackAdapter_1.TwccFeedbackAdapter(constants_1.kSendTimeHistoryWindowMs)
|
|
447
|
+
});
|
|
448
|
+
Object.defineProperty(this, "lastUsage", {
|
|
449
|
+
enumerable: true,
|
|
450
|
+
configurable: true,
|
|
451
|
+
writable: true,
|
|
452
|
+
value: "normal"
|
|
453
|
+
});
|
|
454
|
+
/**
|
|
455
|
+
* libwebrtc RobustThroughputEstimator (default acked bitrate path).
|
|
456
|
+
* Fed receive-time-ordered ACKs; does not mix sender wall clock.
|
|
457
|
+
*/
|
|
458
|
+
Object.defineProperty(this, "ackedBitrate", {
|
|
459
|
+
enumerable: true,
|
|
460
|
+
configurable: true,
|
|
461
|
+
writable: true,
|
|
462
|
+
value: new acknowledgedBitrateEstimator_1.AcknowledgedBitrateEstimator()
|
|
463
|
+
});
|
|
464
|
+
Object.defineProperty(this, "delayBasedBps", {
|
|
465
|
+
enumerable: true,
|
|
466
|
+
configurable: true,
|
|
467
|
+
writable: true,
|
|
468
|
+
value: constants_1.kDefaultStartBitrateBps
|
|
469
|
+
});
|
|
470
|
+
Object.defineProperty(this, "lossBasedBps", {
|
|
471
|
+
enumerable: true,
|
|
472
|
+
configurable: true,
|
|
473
|
+
writable: true,
|
|
474
|
+
value: constants_1.kDefaultStartBitrateBps
|
|
475
|
+
});
|
|
476
|
+
Object.defineProperty(this, "startBitrateBps", {
|
|
477
|
+
enumerable: true,
|
|
478
|
+
configurable: true,
|
|
479
|
+
writable: true,
|
|
480
|
+
value: void 0
|
|
481
|
+
});
|
|
482
|
+
/** pin TargetRateConstraints min. */
|
|
483
|
+
Object.defineProperty(this, "minConfiguredBps", {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
configurable: true,
|
|
486
|
+
writable: true,
|
|
487
|
+
value: constants_1.kMinBitrateBps
|
|
488
|
+
});
|
|
489
|
+
/**
|
|
490
|
+
* App-configured max from {@link setBitrates}. Unset → target uses
|
|
491
|
+
* {@link kMaxBitrateBps} (1 Gbps) and probing uses
|
|
492
|
+
* {@link kDefaultMaxProbingBitrateBps} (5 Mbps). After setBitrates both
|
|
493
|
+
* get the same app max (pin ResetConstraints).
|
|
494
|
+
*/
|
|
495
|
+
Object.defineProperty(this, "appMaxBps", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
configurable: true,
|
|
498
|
+
writable: true,
|
|
499
|
+
value: void 0
|
|
500
|
+
});
|
|
501
|
+
/**
|
|
502
|
+
* pin `SendSideBandwidthEstimation::delay_based_limit_`.
|
|
503
|
+
* Starts at +∞ and is written only by a delay-path result
|
|
504
|
+
* (`UpdateDelayBasedEstimate`). A matched TWCC without receive times
|
|
505
|
+
* (all-lost / ReceivedWithoutDelta) must **not** turn the constructor
|
|
506
|
+
* start bitrate into a delay cap (pin `delay_based_limit_`). See pin `delay_based_limit_`.
|
|
507
|
+
*/
|
|
508
|
+
Object.defineProperty(this, "delayBasedLimitBps", {
|
|
509
|
+
enumerable: true,
|
|
510
|
+
configurable: true,
|
|
511
|
+
writable: true,
|
|
512
|
+
value: Number.POSITIVE_INFINITY
|
|
513
|
+
});
|
|
514
|
+
Object.defineProperty(this, "probingConfigured", {
|
|
515
|
+
enumerable: true,
|
|
516
|
+
configurable: true,
|
|
517
|
+
writable: true,
|
|
518
|
+
value: false
|
|
519
|
+
});
|
|
520
|
+
/** Valid TWCC samples seen at least once (gates publishing estimates). */
|
|
521
|
+
Object.defineProperty(this, "hasValidSample", {
|
|
522
|
+
enumerable: true,
|
|
523
|
+
configurable: true,
|
|
524
|
+
writable: true,
|
|
525
|
+
value: false
|
|
526
|
+
});
|
|
527
|
+
/** Bytes already sent while any probe cluster is active. */
|
|
528
|
+
Object.defineProperty(this, "probeClusterSentBytes", {
|
|
529
|
+
enumerable: true,
|
|
530
|
+
configurable: true,
|
|
531
|
+
writable: true,
|
|
532
|
+
value: 0
|
|
533
|
+
});
|
|
534
|
+
Object.defineProperty(this, "probeClusterStartMs", {
|
|
535
|
+
enumerable: true,
|
|
536
|
+
configurable: true,
|
|
537
|
+
writable: true,
|
|
538
|
+
value: 0
|
|
539
|
+
});
|
|
540
|
+
Object.defineProperty(this, "lastProbeTargetBps", {
|
|
541
|
+
enumerable: true,
|
|
542
|
+
configurable: true,
|
|
543
|
+
writable: true,
|
|
544
|
+
value: 0
|
|
545
|
+
});
|
|
546
|
+
/**
|
|
547
|
+
* libwebrtc RttBasedBackoff — IsRttAboveLimit uses **propagation RTT**
|
|
548
|
+
* (CorrectedRtt), not raw max feedback RTT. max feedback RTT is stored only
|
|
549
|
+
* for diagnostics (congestion-window style uses in pin).
|
|
550
|
+
* When above limit, pin UpdateEstimate applies ×0.8 target drops.
|
|
551
|
+
*/
|
|
552
|
+
Object.defineProperty(this, "rttBackoff", {
|
|
553
|
+
enumerable: true,
|
|
554
|
+
configurable: true,
|
|
555
|
+
writable: true,
|
|
556
|
+
value: new rttBasedBackoff_1.RttBasedBackoff()
|
|
557
|
+
});
|
|
558
|
+
/**
|
|
559
|
+
* pin `SendSideBandwidthEstimation::current_target_` — final target layer
|
|
560
|
+
* that RTT backoff multiplies. Initialized to start bitrate (constraints).
|
|
561
|
+
*/
|
|
562
|
+
Object.defineProperty(this, "currentTargetBps", {
|
|
563
|
+
enumerable: true,
|
|
564
|
+
configurable: true,
|
|
565
|
+
writable: true,
|
|
566
|
+
value: void 0
|
|
567
|
+
});
|
|
568
|
+
/**
|
|
569
|
+
* pin `time_last_decrease_` for RTT-based target drops
|
|
570
|
+
* (MinusInfinity so the first drop fires immediately when above limit).
|
|
571
|
+
*/
|
|
572
|
+
Object.defineProperty(this, "lastRttDecreaseMs", {
|
|
573
|
+
enumerable: true,
|
|
574
|
+
configurable: true,
|
|
575
|
+
writable: true,
|
|
576
|
+
value: Number.NEGATIVE_INFINITY
|
|
577
|
+
});
|
|
578
|
+
/** pin `first_packet_sent_` — seeds UpdatePropagationRtt(send, 0). */
|
|
579
|
+
Object.defineProperty(this, "firstPacketSent", {
|
|
580
|
+
enumerable: true,
|
|
581
|
+
configurable: true,
|
|
582
|
+
writable: true,
|
|
583
|
+
value: false
|
|
584
|
+
});
|
|
585
|
+
/**
|
|
586
|
+
* pin `last_fraction_loss_` (Q8, 0–255). Updated only via
|
|
587
|
+
* {@link updatePacketsLost} (OnTransportLossReport). TWCC does not
|
|
588
|
+
* write this — LossBasedV2 has its own observation path.
|
|
589
|
+
*/
|
|
590
|
+
Object.defineProperty(this, "lastFractionLoss", {
|
|
591
|
+
enumerable: true,
|
|
592
|
+
configurable: true,
|
|
593
|
+
writable: true,
|
|
594
|
+
value: 0
|
|
595
|
+
});
|
|
596
|
+
/**
|
|
597
|
+
* pin `first_report_time_`. MinusInfinity until the first
|
|
598
|
+
* {@link updatePacketsLost}. `IsInStartPhase` is then true forever
|
|
599
|
+
* until a TransportLossReport arrives (TWCC-only production path).
|
|
600
|
+
*/
|
|
601
|
+
Object.defineProperty(this, "firstReportTimeMs", {
|
|
602
|
+
enumerable: true,
|
|
603
|
+
configurable: true,
|
|
604
|
+
writable: true,
|
|
605
|
+
value: Number.NEGATIVE_INFINITY
|
|
606
|
+
});
|
|
607
|
+
/** pin accumulators for `UpdatePacketsLost` (`kLimitNumPackets` = 20). */
|
|
608
|
+
Object.defineProperty(this, "lostPacketsSinceLastLossUpdate", {
|
|
609
|
+
enumerable: true,
|
|
610
|
+
configurable: true,
|
|
611
|
+
writable: true,
|
|
612
|
+
value: 0
|
|
613
|
+
});
|
|
614
|
+
Object.defineProperty(this, "expectedPacketsSinceLastLossUpdate", {
|
|
615
|
+
enumerable: true,
|
|
616
|
+
configurable: true,
|
|
617
|
+
writable: true,
|
|
618
|
+
value: 0
|
|
619
|
+
});
|
|
620
|
+
/** Last batch max_feedback_rtt (diagnostics; not used for probe cause). */
|
|
621
|
+
Object.defineProperty(this, "lastMaxFeedbackRttMs", {
|
|
622
|
+
enumerable: true,
|
|
623
|
+
configurable: true,
|
|
624
|
+
writable: true,
|
|
625
|
+
value: 0
|
|
626
|
+
});
|
|
627
|
+
/** Last batch min_propagation_rtt (before timeout correction). */
|
|
628
|
+
Object.defineProperty(this, "lastPropagationRttMs", {
|
|
629
|
+
enumerable: true,
|
|
630
|
+
configurable: true,
|
|
631
|
+
writable: true,
|
|
632
|
+
value: 0
|
|
633
|
+
});
|
|
634
|
+
/**
|
|
635
|
+
* Sender clock of the last TWCC packet feedback that fed the delay path
|
|
636
|
+
* (libwebrtc DelayBasedBwe::last_seen_packet_).
|
|
637
|
+
*/
|
|
638
|
+
Object.defineProperty(this, "lastSeenPacketMs", {
|
|
639
|
+
enumerable: true,
|
|
640
|
+
configurable: true,
|
|
641
|
+
writable: true,
|
|
642
|
+
value: Number.NEGATIVE_INFINITY
|
|
643
|
+
});
|
|
644
|
+
/**
|
|
645
|
+
* pin `DelayBasedBwe::prev_bitrate_` / `last_estimate()`.
|
|
646
|
+
* Used to drop probes below both last delay estimate and NSE lower.
|
|
647
|
+
*/
|
|
648
|
+
Object.defineProperty(this, "lastDelayEstimateBps", {
|
|
649
|
+
enumerable: true,
|
|
650
|
+
configurable: true,
|
|
651
|
+
writable: true,
|
|
652
|
+
value: 0
|
|
653
|
+
});
|
|
654
|
+
/** pin `NetworkStateEstimate::link_capacity_lower`. 0 = unset. */
|
|
655
|
+
Object.defineProperty(this, "networkLowerBps", {
|
|
656
|
+
enumerable: true,
|
|
657
|
+
configurable: true,
|
|
658
|
+
writable: true,
|
|
659
|
+
value: 0
|
|
660
|
+
});
|
|
661
|
+
/**
|
|
662
|
+
* pin `enable_periodic_alr_probing_` — persisted across {@link reset}
|
|
663
|
+
* (constructor / {@link enablePeriodicAlrProbing}).
|
|
664
|
+
*/
|
|
665
|
+
Object.defineProperty(this, "periodicAlrProbing", {
|
|
666
|
+
enumerable: true,
|
|
667
|
+
configurable: true,
|
|
668
|
+
writable: true,
|
|
669
|
+
value: false
|
|
670
|
+
});
|
|
671
|
+
/**
|
|
672
|
+
* Token-bucket for pin GetPacingRates padding_rate while
|
|
673
|
+
* `kIncreaseUsingPadding`. Accrued on process / pending query; drained
|
|
674
|
+
* by media and injected padding.
|
|
675
|
+
*/
|
|
676
|
+
Object.defineProperty(this, "paddingDueBytes", {
|
|
677
|
+
enumerable: true,
|
|
678
|
+
configurable: true,
|
|
679
|
+
writable: true,
|
|
680
|
+
value: 0
|
|
681
|
+
});
|
|
682
|
+
Object.defineProperty(this, "lastPaddingAccrueMs", {
|
|
683
|
+
enumerable: true,
|
|
684
|
+
configurable: true,
|
|
685
|
+
writable: true,
|
|
686
|
+
value: Number.NEGATIVE_INFINITY
|
|
687
|
+
});
|
|
688
|
+
this.startBitrateBps = startBitrateBps;
|
|
689
|
+
this.currentTargetBps = startBitrateBps;
|
|
690
|
+
this.clock = options?.clock ?? utils_1.milliTime;
|
|
691
|
+
this.aimd.reset(startBitrateBps);
|
|
692
|
+
this.lossBwe.reset(startBitrateBps);
|
|
693
|
+
this.delayBasedBps = startBitrateBps;
|
|
694
|
+
this.lossBasedBps = startBitrateBps;
|
|
695
|
+
this.enablePeriodicAlrProbing(options?.periodicAlrProbing === true);
|
|
696
|
+
}
|
|
697
|
+
rtpPacketSent(info) {
|
|
698
|
+
if (this.disposed)
|
|
699
|
+
return;
|
|
700
|
+
this.alr.onBytesSent(info.size, info.sendingAtMs);
|
|
701
|
+
this.accrueLossPadding(info.sendingAtMs);
|
|
702
|
+
this.paddingDueBytes = Math.max(0, this.paddingDueBytes - info.size);
|
|
703
|
+
this.ackedBitrate.setAlr(this.alr.inAlr);
|
|
704
|
+
this.aimd.setInApplicationLimitedRegion(this.alr.inAlr);
|
|
705
|
+
const seq = this.feedbackAdapter.onSent(info);
|
|
706
|
+
// pin GoogCcNetworkController::OnSentPacket — first packet seeds
|
|
707
|
+
// UpdatePropagationRtt(send_time, 0) so CorrectedRtt grows while
|
|
708
|
+
// packets are sent without feedback (ProcessInterval / sender clock).
|
|
709
|
+
if (!this.firstPacketSent) {
|
|
710
|
+
this.firstPacketSent = true;
|
|
711
|
+
this.rttBackoff.updatePropagationRtt(info.sendingAtMs, 0);
|
|
712
|
+
}
|
|
713
|
+
this.rttBackoff.onSentPacket(info.sendingAtMs);
|
|
714
|
+
// pin OnSentPacket does **not** call UpdateEstimate, ProbeController::Process,
|
|
715
|
+
// or SetBitrates / initial probing. Those run on ProcessInterval /
|
|
716
|
+
// OnNetworkAvailability.
|
|
717
|
+
// Attribute using the **reserved** cluster id (pin PacedPacketInfo
|
|
718
|
+
// captured before send). Do not look at the current pacing front —
|
|
719
|
+
// a concurrent send may have already advanced FIFO.
|
|
720
|
+
const reservedId = info.probeClusterId;
|
|
721
|
+
if (info.isProbation || (reservedId !== undefined && reservedId > 0)) {
|
|
722
|
+
const { activated } = this.probe.onProbePacketSent(info.size, info.sendingAtMs, seq, reservedId);
|
|
723
|
+
this.probeClusterSentBytes += info.size;
|
|
724
|
+
for (const cfg of activated) {
|
|
725
|
+
this.onProbeClusterActivated(cfg, info.sendingAtMs);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
receiveTWCC(feedback) {
|
|
730
|
+
if (this.disposed)
|
|
731
|
+
return;
|
|
732
|
+
// pin feedback_time is sender-local Timestamp (same domain as send times).
|
|
733
|
+
// No wall/receive-timeline heuristic — tests inject {@link GccClock} when
|
|
734
|
+
// using synthetic send timelines.
|
|
735
|
+
const nowMs = this.clock();
|
|
736
|
+
let received = 0;
|
|
737
|
+
let lost = 0;
|
|
738
|
+
let matched = 0;
|
|
739
|
+
let lostBytes = 0;
|
|
740
|
+
let batchBytes = 0;
|
|
741
|
+
let firstSend = Number.POSITIVE_INFINITY;
|
|
742
|
+
let lastSend = 0;
|
|
743
|
+
const lossPackets = [];
|
|
744
|
+
/** Received packets with valid TWCC timing for delay / acked / probe. */
|
|
745
|
+
const timedReceived = [];
|
|
746
|
+
// Loss path uses transport-seq (send) order. Delay + acked + probe use
|
|
747
|
+
// receive-time order below (libwebrtc SortedByReceiveTime). The adapter
|
|
748
|
+
// already dropped unknown sequences (other BUNDLE senders) and packets
|
|
749
|
+
// previously reported as received.
|
|
750
|
+
for (const packet of this.feedbackAdapter.onFeedback(feedback, nowMs)) {
|
|
751
|
+
const seq = packet.extSeq;
|
|
752
|
+
const info = packet.sent;
|
|
753
|
+
matched++;
|
|
754
|
+
batchBytes += info.size;
|
|
755
|
+
if (info.sendingAtMs < firstSend)
|
|
756
|
+
firstSend = info.sendingAtMs;
|
|
757
|
+
if (info.sendingAtMs > lastSend)
|
|
758
|
+
lastSend = info.sendingAtMs;
|
|
759
|
+
if (!packet.received) {
|
|
760
|
+
// Soft loss: counted for this observation. Repeated PacketNotReceived
|
|
761
|
+
// is forwarded again (pin PushBackObservation).
|
|
762
|
+
lost++;
|
|
763
|
+
lostBytes += info.size;
|
|
764
|
+
lossPackets.push({
|
|
765
|
+
seq,
|
|
766
|
+
size: info.size,
|
|
767
|
+
received: false,
|
|
768
|
+
sendMs: info.sendingAtMs,
|
|
769
|
+
});
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
// Received — may unmark a prior soft loss inside LossBasedBwe partial map.
|
|
773
|
+
received++;
|
|
774
|
+
lossPackets.push({
|
|
775
|
+
seq,
|
|
776
|
+
size: info.size,
|
|
777
|
+
received: true,
|
|
778
|
+
sendMs: info.sendingAtMs,
|
|
779
|
+
});
|
|
780
|
+
// ReceivedWithoutDelta: received for loss only, skip delay path.
|
|
781
|
+
if (packet.recvMs === undefined) {
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
timedReceived.push({
|
|
785
|
+
seq,
|
|
786
|
+
size: info.size,
|
|
787
|
+
sendMs: info.sendingAtMs,
|
|
788
|
+
recvMs: packet.recvMs,
|
|
789
|
+
isProbation: !!info.isProbation,
|
|
790
|
+
priorUnackedBytes: info.priorUnackedBytes ?? 0,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
// No known samples → do not update estimate or fire events.
|
|
794
|
+
if (matched === 0) {
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
this.hasValidSample = true;
|
|
798
|
+
// pin OnTransportPacketsFeedback: ALR-ended is published *before*
|
|
799
|
+
// delay / loss / RequestProbe. SetAlrStartTime is ProcessInterval-only
|
|
800
|
+
// except the recovered_from_overuse path below.
|
|
801
|
+
this.noteAlrLeave(nowMs);
|
|
802
|
+
// libwebrtc: delay detector, acked bitrate, and probe estimator consume
|
|
803
|
+
// feedback in receive-time order (not transport-seq order).
|
|
804
|
+
timedReceived.sort((a, b) => a.recvMs - b.recvMs || a.seq - b.seq);
|
|
805
|
+
this.ackedBitrate.incomingPacketFeedbackVector(timedReceived.map((p) => ({
|
|
806
|
+
receiveTimeMs: p.recvMs,
|
|
807
|
+
sendTimeMs: p.sendMs,
|
|
808
|
+
sizeBytes: p.size,
|
|
809
|
+
priorUnackedBytes: p.priorUnackedBytes,
|
|
810
|
+
})));
|
|
811
|
+
// pin DelayBasedBwe::IncomingPacketFeedbackVector: SortedByReceiveTime
|
|
812
|
+
// empty (all lost / ReceivedWithoutDelta) → Result() (updated=false)
|
|
813
|
+
// and **no** AIMD update. ProbeController::Process is ProcessInterval-only.
|
|
814
|
+
const delayFeedback = timedReceived.length > 0;
|
|
815
|
+
// libwebrtc DelayBasedBwe::kStreamTimeOut — idle > 2s resets delay path
|
|
816
|
+
// so stale trendline history does not produce false overuse/underuse.
|
|
817
|
+
if (delayFeedback &&
|
|
818
|
+
Number.isFinite(this.lastSeenPacketMs) &&
|
|
819
|
+
nowMs - this.lastSeenPacketMs > constants_1.kStreamTimeOutMs) {
|
|
820
|
+
this.interArrival.reset();
|
|
821
|
+
this.trendline.reset();
|
|
822
|
+
this.lastUsage = "normal";
|
|
823
|
+
}
|
|
824
|
+
if (delayFeedback) {
|
|
825
|
+
this.lastSeenPacketMs = nowMs;
|
|
826
|
+
}
|
|
827
|
+
// libwebrtc DelayBasedBwe::IncomingPacketFeedbackVector — latch
|
|
828
|
+
// recovered_from_overuse on **per-packet** underuse→normal transitions
|
|
829
|
+
// inside this feedback (not only feedback-to-feedback lastUsage).
|
|
830
|
+
let recoveredFromUnderuse = false;
|
|
831
|
+
if (delayFeedback) {
|
|
832
|
+
for (const p of timedReceived) {
|
|
833
|
+
// Result validation only (sender clock for session complete/cooldown).
|
|
834
|
+
// FIFO pacing advance happens on send-fill, not on ACK.
|
|
835
|
+
this.probe.onAckedPacket(p.size, p.recvMs, p.isProbation, p.seq, nowMs, p.sendMs);
|
|
836
|
+
const prevUsage = this.trendline.state;
|
|
837
|
+
this.pushInterArrival(p.sendMs, p.recvMs, p.size, nowMs);
|
|
838
|
+
const nextUsage = this.trendline.state;
|
|
839
|
+
if (prevUsage === "underuse" && nextUsage === "normal") {
|
|
840
|
+
recoveredFromUnderuse = true;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
const known = received + lost;
|
|
845
|
+
const lossFraction = known > 0 ? lost / known : 0;
|
|
846
|
+
const ackedBps = this.ackedBitrate.bitrate();
|
|
847
|
+
const usage = this.trendline.state;
|
|
848
|
+
if (delayFeedback && usage !== this.lastUsage) {
|
|
849
|
+
this.lastUsage = usage;
|
|
850
|
+
this.onOveruseDetected.execute(usage);
|
|
851
|
+
}
|
|
852
|
+
// pin DelayBasedBwe::MaybeUpdateEstimate:
|
|
853
|
+
// - overusing → ignore probe_bitrate entirely (AIMD decrease only)
|
|
854
|
+
// - else if probe_bitrate → SetEstimate(probe); recovered_from_overuse=false
|
|
855
|
+
// - else → UpdateEstimate; may surface recovered_from_overuse
|
|
856
|
+
// Active clusters keep pacing until send-fill or pacing timeout.
|
|
857
|
+
const overusing = usage === "overuse";
|
|
858
|
+
const batchFirstSend = Number.isFinite(firstSend) ? firstSend : 0;
|
|
859
|
+
const batchLastSend = lastSend > 0 ? lastSend : batchFirstSend;
|
|
860
|
+
// libwebrtc OnTransportPacketsFeedback RTT split:
|
|
861
|
+
// max_feedback_rtt → feedback_max_rtts_ (CWND; not probe cause)
|
|
862
|
+
// min_propagation_rtt → UpdatePropagationRtt → IsRttAboveLimit + target drop
|
|
863
|
+
// AIMD RTT is a separate path (OnRoundTripTimeUpdate / RTCP RR via
|
|
864
|
+
// {@link setRoundTripTime}) — never copy propagation RTT into AIMD.
|
|
865
|
+
// feedback_time = sender clock now (pin report.feedback_time domain).
|
|
866
|
+
const rttPackets = timedReceived.map((p) => ({
|
|
867
|
+
sendMs: p.sendMs,
|
|
868
|
+
recvMs: p.recvMs,
|
|
869
|
+
}));
|
|
870
|
+
const rttStats = (0, rttBasedBackoff_1.computeFeedbackRttStats)(rttPackets, nowMs);
|
|
871
|
+
if (rttStats) {
|
|
872
|
+
this.lastMaxFeedbackRttMs = rttStats.maxFeedbackRttMs;
|
|
873
|
+
this.lastPropagationRttMs = rttStats.minPropagationRttMs;
|
|
874
|
+
this.rttBackoff.updatePropagationRtt(nowMs, rttStats.minPropagationRttMs);
|
|
875
|
+
}
|
|
876
|
+
// --- Pin order (goog_cc_network_control OnTransportPacketsFeedback) ---
|
|
877
|
+
// 1) Delay path (AIMD) with optional probe SetEstimate
|
|
878
|
+
// 2) LossBased estimator with post-probe delay estimate as input
|
|
879
|
+
// 3) GetBandwidthLimitedCause / target from **post-loss** state
|
|
880
|
+
//
|
|
881
|
+
// Consume pending probe before deciding recovery (pin FetchAndReset before
|
|
882
|
+
// MaybeUpdateEstimate — any probe estimate suppresses recovered_from_overuse).
|
|
883
|
+
const probeBps = this.probe.takePendingEstimateBps();
|
|
884
|
+
// pin ignore_probes_lower_than_network_estimate_ (default enabled):
|
|
885
|
+
// drop a probe below both last delay estimate and NSE link_capacity_lower.
|
|
886
|
+
let hasProbeEstimate = probeBps > 0;
|
|
887
|
+
if (hasProbeEstimate &&
|
|
888
|
+
this.networkLowerBps > 0 &&
|
|
889
|
+
this.lastDelayEstimateBps > 0 &&
|
|
890
|
+
probeBps < this.lastDelayEstimateBps &&
|
|
891
|
+
probeBps < this.networkLowerBps) {
|
|
892
|
+
hasProbeEstimate = false;
|
|
893
|
+
}
|
|
894
|
+
// pin DelayBasedBwe::Result — default (updated=false) when no receive-time
|
|
895
|
+
// samples. MaybeTriggerOnNetworkChanged only runs when updated.
|
|
896
|
+
const delayResult = {
|
|
897
|
+
updated: false,
|
|
898
|
+
probe: false,
|
|
899
|
+
recoveredFromOveruse: false,
|
|
900
|
+
targetBps: this.delayBasedBps,
|
|
901
|
+
};
|
|
902
|
+
if (delayFeedback) {
|
|
903
|
+
if (overusing) {
|
|
904
|
+
// pin MaybeUpdateEstimate overuse: Update only when
|
|
905
|
+
// TimeToReduceFurther / InitialTimeToReduceFurther. Otherwise
|
|
906
|
+
// Result.updated stays false (no UpdateDelayBasedEstimate /
|
|
907
|
+
// MaybeTriggerOnNetworkChanged).
|
|
908
|
+
const canReduce = ackedBps > 0
|
|
909
|
+
? this.aimd.timeToReduceFurther(nowMs, ackedBps)
|
|
910
|
+
: this.aimd.initialTimeToReduceFurther(nowMs);
|
|
911
|
+
if (canReduce) {
|
|
912
|
+
this.delayBasedBps = this.aimd.update(usage, ackedBps, nowMs);
|
|
913
|
+
delayResult.updated = this.aimd.validEstimate();
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
else if (hasProbeEstimate) {
|
|
917
|
+
// pin MaybeUpdateEstimate (non-overuse + probe_bitrate):
|
|
918
|
+
// SetEstimate(probe) as-is — **no upward caps**. Only lower probes get
|
|
919
|
+
// limit_probes_lower_than_throughput_estimate:
|
|
920
|
+
// probe = max(probe, min(delayEstimate, acked × 0.85)).
|
|
921
|
+
let accepted = Math.min(probeBps, constants_1.kMaxBitrateBps);
|
|
922
|
+
const delayTarget = this.delayBasedBps > 0
|
|
923
|
+
? this.delayBasedBps
|
|
924
|
+
: this.aimd.targetBitrateBps;
|
|
925
|
+
if (accepted < delayTarget) {
|
|
926
|
+
const ackedFloor = ackedBps > constants_1.kMinBitrateBps
|
|
927
|
+
? ackedBps * constants_1.kProbeDropThroughputFraction
|
|
928
|
+
: accepted;
|
|
929
|
+
const floor = Math.min(delayTarget, ackedFloor);
|
|
930
|
+
accepted = Math.max(accepted, floor);
|
|
931
|
+
accepted = Math.min(accepted, delayTarget);
|
|
932
|
+
}
|
|
933
|
+
if (accepted > 0) {
|
|
934
|
+
this.aimd.setEstimate(accepted, nowMs);
|
|
935
|
+
this.delayBasedBps = this.aimd.targetBitrateBps;
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
this.delayBasedBps = this.aimd.targetBitrateBps;
|
|
939
|
+
}
|
|
940
|
+
delayResult.updated = true;
|
|
941
|
+
delayResult.probe = true;
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
this.delayBasedBps = this.aimd.update(usage, ackedBps, nowMs);
|
|
945
|
+
delayResult.updated = this.aimd.validEstimate();
|
|
946
|
+
delayResult.recoveredFromOveruse = recoveredFromUnderuse;
|
|
947
|
+
}
|
|
948
|
+
delayResult.targetBps = this.delayBasedBps;
|
|
949
|
+
// pin UpdateDelayBasedEstimate only when Result.updated.
|
|
950
|
+
if (delayResult.updated) {
|
|
951
|
+
this.noteDelayBasedEstimate(this.delayBasedBps);
|
|
952
|
+
this.lastDelayEstimateBps = this.delayBasedBps;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
// Loss path after delay/probe (pin UpdateLossBasedEstimator).
|
|
956
|
+
// Always update the estimator. UpdateEstimate adopts the result only
|
|
957
|
+
// when LossBasedBandwidthEstimatorV2ReadyForUse / {@link LossBasedBwe.isReady}.
|
|
958
|
+
// When RTT-limited pin returns before that gate.
|
|
959
|
+
// pin passes delay_based_limit_ (PlusInfinity until the first delay result).
|
|
960
|
+
this.lossBwe.update(lossFraction, this.delayLimitForLossBwe(), ackedBps, known, lost, batchFirstSend, batchBytes, batchLastSend, lostBytes, lossPackets, this.alr.inAlr);
|
|
961
|
+
// pin UpdateLossBasedEstimator → UpdateEstimate (single function):
|
|
962
|
+
// 1. RTT-limited: drop / ApplyTargetLimits, return (no LossBased adopt).
|
|
963
|
+
// 2. Startup: last_fraction_loss==0 && start phase &&
|
|
964
|
+
// !ReadyToUseInStartPhase → max(current, delay_based_limit).
|
|
965
|
+
// 3. IsReady: adopt GetLossBasedResult.
|
|
966
|
+
// 4. Else: ApplyTargetLimits (do not freeze delay ramp-up at step 2).
|
|
967
|
+
//
|
|
968
|
+
// Probe SetSendBitrate is applied *before* UpdateEstimate when a
|
|
969
|
+
// valid probe result updated the delay path (pin OnTransportPacketsFeedback).
|
|
970
|
+
const rttLimited = this.rttBackoff.isRttAboveLimit();
|
|
971
|
+
if (rttLimited &&
|
|
972
|
+
delayFeedback &&
|
|
973
|
+
hasProbeEstimate &&
|
|
974
|
+
!overusing &&
|
|
975
|
+
this.delayBasedBps > 0) {
|
|
976
|
+
this.currentTargetBps = this.delayBasedBps;
|
|
977
|
+
}
|
|
978
|
+
this.updateEstimate(nowMs);
|
|
979
|
+
const target = this.currentTargetBps;
|
|
980
|
+
// pin MaybeTriggerOnNetworkChanged **only** when delay Result.updated.
|
|
981
|
+
// All-lost / no-timing feedback updates LossBased + current_target_ but
|
|
982
|
+
// must not push cause to ProbeController before the next ProcessInterval.
|
|
983
|
+
let bandwidthLimitedCause;
|
|
984
|
+
if (delayResult.updated) {
|
|
985
|
+
bandwidthLimitedCause = this.propagateTarget(nowMs);
|
|
986
|
+
}
|
|
987
|
+
const allowNewProbe = bandwidthLimitedCause
|
|
988
|
+
? (0, bandwidthLimitedCause_1.isProbeInitiationAllowed)(bandwidthLimitedCause)
|
|
989
|
+
: false;
|
|
990
|
+
// Recovery probe only on latched underuse→normal (recovered_from_overuse).
|
|
991
|
+
// pin MaybeUpdateEstimate: recovered_from_overuse is surfaced only when
|
|
992
|
+
// not overusing and no probe_bitrate was present this feedback.
|
|
993
|
+
// Same post-loss cause gate as further (including RTT-high and loss-limited).
|
|
994
|
+
if (delayResult.recoveredFromOveruse &&
|
|
995
|
+
!overusing &&
|
|
996
|
+
!hasProbeEstimate &&
|
|
997
|
+
this.probe.probeState === "complete" &&
|
|
998
|
+
allowNewProbe &&
|
|
999
|
+
bandwidthLimitedCause) {
|
|
1000
|
+
// pin: SetAlrStartTime immediately before RequestProbe.
|
|
1001
|
+
this.probe.setAlrStartTime(this.alr.startMs);
|
|
1002
|
+
const est = this._availableBitrate > 0 ? this._availableBitrate : target;
|
|
1003
|
+
const maxProbe = (0, bandwidthLimitedCause_1.maxProbeBitrateBps)(bandwidthLimitedCause, est, this.targetMaxBps());
|
|
1004
|
+
for (const cfg of this.probe.requestProbe(est, nowMs, {
|
|
1005
|
+
maxProbeBps: maxProbe,
|
|
1006
|
+
})) {
|
|
1007
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* pin `OnNetworkRouteChange`: reset everything path-dependent, keep the
|
|
1013
|
+
* app constraints from {@link setBitrates} (min, start, max). Probing is
|
|
1014
|
+
* reconfigured from them on the next {@link process}.
|
|
1015
|
+
*/
|
|
1016
|
+
resetNetworkRoute() {
|
|
1017
|
+
if (this.disposed)
|
|
1018
|
+
return;
|
|
1019
|
+
const minBps = this.minConfiguredBps;
|
|
1020
|
+
const appMaxBps = this.appMaxBps;
|
|
1021
|
+
this.reset();
|
|
1022
|
+
this.minConfiguredBps = minBps;
|
|
1023
|
+
this.appMaxBps = appMaxBps;
|
|
1024
|
+
this.aimd.setMinBitrate(minBps);
|
|
1025
|
+
this.lossBwe.setMinMaxBitrate(minBps, this.targetMaxBps());
|
|
1026
|
+
this.applyTargetLimits();
|
|
1027
|
+
}
|
|
1028
|
+
reset() {
|
|
1029
|
+
this.disposed = false;
|
|
1030
|
+
this.trendline.reset();
|
|
1031
|
+
this.aimd.reset(this.startBitrateBps);
|
|
1032
|
+
this.lossBwe.reset(this.startBitrateBps);
|
|
1033
|
+
this.probe.reset(this.clock());
|
|
1034
|
+
this.interArrival.reset();
|
|
1035
|
+
this.feedbackAdapter.reset();
|
|
1036
|
+
this.lastUsage = "normal";
|
|
1037
|
+
this.ackedBitrate.reset();
|
|
1038
|
+
this._availableBitrate = 0;
|
|
1039
|
+
this.delayBasedBps = this.startBitrateBps;
|
|
1040
|
+
this.lossBasedBps = this.startBitrateBps;
|
|
1041
|
+
this.currentTargetBps = this.startBitrateBps;
|
|
1042
|
+
this.lastRttDecreaseMs = Number.NEGATIVE_INFINITY;
|
|
1043
|
+
this.firstPacketSent = false;
|
|
1044
|
+
this.probingConfigured = false;
|
|
1045
|
+
this.hasValidSample = false;
|
|
1046
|
+
this.probeClusterSentBytes = 0;
|
|
1047
|
+
this.probeClusterStartMs = 0;
|
|
1048
|
+
this.lastProbeTargetBps = 0;
|
|
1049
|
+
this.rttBackoff.reset();
|
|
1050
|
+
this.lastMaxFeedbackRttMs = 0;
|
|
1051
|
+
this.lastPropagationRttMs = 0;
|
|
1052
|
+
this.lastSeenPacketMs = Number.NEGATIVE_INFINITY;
|
|
1053
|
+
this.lastDelayEstimateBps = 0;
|
|
1054
|
+
this.networkLowerBps = 0;
|
|
1055
|
+
this.paddingDueBytes = 0;
|
|
1056
|
+
this.lastPaddingAccrueMs = Number.NEGATIVE_INFINITY;
|
|
1057
|
+
this.alr.reset();
|
|
1058
|
+
this.previouslyInAlr = false;
|
|
1059
|
+
this.minConfiguredBps = constants_1.kMinBitrateBps;
|
|
1060
|
+
this.appMaxBps = undefined;
|
|
1061
|
+
this.delayBasedLimitBps = Number.POSITIVE_INFINITY;
|
|
1062
|
+
this.lastFractionLoss = 0;
|
|
1063
|
+
this.firstReportTimeMs = Number.NEGATIVE_INFINITY;
|
|
1064
|
+
this.lostPacketsSinceLastLossUpdate = 0;
|
|
1065
|
+
this.expectedPacketsSinceLastLossUpdate = 0;
|
|
1066
|
+
this.lossBwe.setMinMaxBitrate(this.minConfiguredBps, this.targetMaxBps());
|
|
1067
|
+
// pin Reset keeps enable_periodic_alr_probing_; restore in case a
|
|
1068
|
+
// direct ProbeController.reset(0) was used without the flag.
|
|
1069
|
+
this.probe.enablePeriodicAlrProbing(this.periodicAlrProbing);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* pin `GetUpperLimit` delay_based_limit_. +∞ until
|
|
1073
|
+
* {@link noteDelayBasedEstimate} (not merely `hasValidSample`).
|
|
1074
|
+
*/
|
|
1075
|
+
delayBasedUpperLimitBps() {
|
|
1076
|
+
if (!Number.isFinite(this.delayBasedLimitBps) ||
|
|
1077
|
+
this.delayBasedLimitBps <= 0) {
|
|
1078
|
+
return constants_1.kMaxBitrateBps;
|
|
1079
|
+
}
|
|
1080
|
+
return this.delayBasedLimitBps;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* pin `UpdateDelayBasedEstimate`: zero means PlusInfinity (no delay cap).
|
|
1084
|
+
*/
|
|
1085
|
+
noteDelayBasedEstimate(bitrateBps) {
|
|
1086
|
+
this.delayBasedBps = bitrateBps;
|
|
1087
|
+
this.delayBasedLimitBps =
|
|
1088
|
+
bitrateBps > 0 ? bitrateBps : Number.POSITIVE_INFINITY;
|
|
1089
|
+
}
|
|
1090
|
+
/** pin loss BWE input: delay_based_limit_, or 0 while it is +∞. */
|
|
1091
|
+
delayLimitForLossBwe() {
|
|
1092
|
+
return Number.isFinite(this.delayBasedLimitBps) &&
|
|
1093
|
+
this.delayBasedLimitBps > 0
|
|
1094
|
+
? this.delayBasedLimitBps
|
|
1095
|
+
: 0;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* pin `UpdateEstimate` when `LossBasedBandwidthEstimatorV2ReadyForUse`.
|
|
1099
|
+
* Reads {@link LossBasedBwe.getLossBasedResult} and applies target limits.
|
|
1100
|
+
*/
|
|
1101
|
+
adoptLossBasedResult() {
|
|
1102
|
+
const result = this.lossBwe.getLossBasedResult();
|
|
1103
|
+
if (!result.ready)
|
|
1104
|
+
return;
|
|
1105
|
+
if (!(result.bandwidthEstimateBps > 0) ||
|
|
1106
|
+
!Number.isFinite(result.bandwidthEstimateBps)) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
this.lossBasedBps = result.bandwidthEstimateBps;
|
|
1110
|
+
const delayLossTarget = this.combineDelayLossTarget(this.lossBasedBps);
|
|
1111
|
+
if (delayLossTarget > 0) {
|
|
1112
|
+
this.currentTargetBps = delayLossTarget;
|
|
1113
|
+
this.applyTargetLimits();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* pin UpdateEstimate (LossBased ready): adopt the loss result, then
|
|
1118
|
+
* ApplyTargetLimits. Without a delay result, do not min() against start.
|
|
1119
|
+
*/
|
|
1120
|
+
combineDelayLossTarget(lossBps) {
|
|
1121
|
+
if (lossBps <= 0)
|
|
1122
|
+
return 0;
|
|
1123
|
+
if (Number.isFinite(this.delayBasedLimitBps) &&
|
|
1124
|
+
this.delayBasedLimitBps > 0 &&
|
|
1125
|
+
this.delayBasedBps > 0) {
|
|
1126
|
+
return Math.min(this.delayBasedBps, lossBps);
|
|
1127
|
+
}
|
|
1128
|
+
return lossBps;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* pin `GoogCcNetworkController::ResetConstraints` + `ClampConstraints`.
|
|
1132
|
+
*
|
|
1133
|
+
* 1. min_target = provided min, or 0 (never the previous min)
|
|
1134
|
+
* then min = max(min_target, kCongestionControllerMinBitrate)
|
|
1135
|
+
* 2. max: finite and >0 stays (raised to min if below); 0 / non-finite
|
|
1136
|
+
* is PlusInfinity (unset app cap — target 1 Gbps, probe 5 Mbps)
|
|
1137
|
+
* 3. if start is set and below min, start = min
|
|
1138
|
+
*
|
|
1139
|
+
* `start = 0` stays 0 (pin optional starting_rate / skip SetSendBitrate).
|
|
1140
|
+
*/
|
|
1141
|
+
clampConstraints(minBps, startBps, maxBps) {
|
|
1142
|
+
const minTarget = Number.isFinite(minBps) && minBps > 0 ? minBps : 0;
|
|
1143
|
+
const min = Math.max(minTarget, constants_1.kMinBitrateBps);
|
|
1144
|
+
let max;
|
|
1145
|
+
if (Number.isFinite(maxBps) && maxBps > 0) {
|
|
1146
|
+
max = maxBps;
|
|
1147
|
+
if (max < min) {
|
|
1148
|
+
max = min;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
let start = startBps;
|
|
1152
|
+
if (start > 0 && start < min) {
|
|
1153
|
+
start = min;
|
|
1154
|
+
}
|
|
1155
|
+
return { minBps: min, startBps: start, maxBps: max };
|
|
1156
|
+
}
|
|
1157
|
+
/** pin send-side max: app max or kDefaultMaxBitrate (1 Gbps). */
|
|
1158
|
+
targetMaxBps() {
|
|
1159
|
+
return this.appMaxBps !== undefined && this.appMaxBps > 0
|
|
1160
|
+
? this.appMaxBps
|
|
1161
|
+
: constants_1.kMaxBitrateBps;
|
|
1162
|
+
}
|
|
1163
|
+
/** pin probe max: app max or kDefaultMaxProbingBitrate (5 Mbps). */
|
|
1164
|
+
probeMaxBps() {
|
|
1165
|
+
return this.appMaxBps !== undefined && this.appMaxBps > 0
|
|
1166
|
+
? this.appMaxBps
|
|
1167
|
+
: constants_1.kDefaultMaxProbingBitrateBps;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Accrue pin padding_rate × elapsed into {@link paddingDueBytes}.
|
|
1171
|
+
* Cap at 100ms of the current padding rate so idle ticks cannot explode.
|
|
1172
|
+
*/
|
|
1173
|
+
accrueLossPadding(nowMs) {
|
|
1174
|
+
const rate = this.getPaddingBitrateBps();
|
|
1175
|
+
if (!(rate > 0)) {
|
|
1176
|
+
this.paddingDueBytes = 0;
|
|
1177
|
+
this.lastPaddingAccrueMs = nowMs;
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
if (!Number.isFinite(this.lastPaddingAccrueMs)) {
|
|
1181
|
+
this.lastPaddingAccrueMs = nowMs;
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
const dtMs = Math.max(0, nowMs - this.lastPaddingAccrueMs);
|
|
1185
|
+
this.lastPaddingAccrueMs = nowMs;
|
|
1186
|
+
this.paddingDueBytes += (rate / 8) * (dtMs / 1000);
|
|
1187
|
+
const cap = (rate / 8) * 0.1;
|
|
1188
|
+
if (this.paddingDueBytes > cap)
|
|
1189
|
+
this.paddingDueBytes = cap;
|
|
1190
|
+
}
|
|
1191
|
+
applyTargetLimits() {
|
|
1192
|
+
if (this.currentTargetBps <= 0) {
|
|
1193
|
+
this.currentTargetBps = this.startBitrateBps;
|
|
1194
|
+
}
|
|
1195
|
+
const upper = Math.min(this.delayBasedUpperLimitBps(), this.targetMaxBps());
|
|
1196
|
+
this.currentTargetBps = Math.min(this.currentTargetBps, upper);
|
|
1197
|
+
this.currentTargetBps = Math.max(this.currentTargetBps, this.minConfiguredBps, constants_1.kMinBitrateBps);
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* pin `SendSideBandwidthEstimation::IsInStartPhase`.
|
|
1201
|
+
* True until the first TransportLossReport, then for {@link kStartPhaseMs}.
|
|
1202
|
+
*/
|
|
1203
|
+
isInStartPhase(nowMs) {
|
|
1204
|
+
if (!Number.isFinite(this.firstReportTimeMs) ||
|
|
1205
|
+
this.firstReportTimeMs < 0) {
|
|
1206
|
+
return true;
|
|
1207
|
+
}
|
|
1208
|
+
return nowMs - this.firstReportTimeMs < constants_1.kStartPhaseMs;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* pin UpdateEstimate startup branch:
|
|
1212
|
+
* `last_fraction_loss_ == 0 && IsInStartPhase && !ReadyToUseInStartPhase`.
|
|
1213
|
+
* Raises current_target to delay_based_limit (REMB not wired).
|
|
1214
|
+
* Returns true when the pin path `UpdateTargetBitrate` + return fired.
|
|
1215
|
+
*/
|
|
1216
|
+
maybeApplyStartupDelayEstimate(_nowMs) {
|
|
1217
|
+
if (this.lastFractionLoss !== 0)
|
|
1218
|
+
return false;
|
|
1219
|
+
if (!this.isInStartPhase(_nowMs))
|
|
1220
|
+
return false;
|
|
1221
|
+
if (this.lossBwe.readyToUseInStartPhase)
|
|
1222
|
+
return false;
|
|
1223
|
+
let next = this.currentTargetBps;
|
|
1224
|
+
if (Number.isFinite(this.delayBasedLimitBps) &&
|
|
1225
|
+
this.delayBasedLimitBps > 0) {
|
|
1226
|
+
next = Math.max(next, this.delayBasedLimitBps);
|
|
1227
|
+
}
|
|
1228
|
+
if (next === this.currentTargetBps)
|
|
1229
|
+
return false;
|
|
1230
|
+
this.currentTargetBps = next;
|
|
1231
|
+
this.applyTargetLimits();
|
|
1232
|
+
return true;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* pin `SendSideBandwidthEstimation::UpdateEstimate`.
|
|
1236
|
+
*
|
|
1237
|
+
* Shared by receiveTWCC (`UpdateLossBasedEstimator` → UpdateEstimate)
|
|
1238
|
+
* and process() (`OnProcessInterval` → UpdateEstimate).
|
|
1239
|
+
*/
|
|
1240
|
+
updateEstimate(nowMs) {
|
|
1241
|
+
if (this.rttBackoff.isRttAboveLimit()) {
|
|
1242
|
+
this.maybeApplyRttBasedBackoff(nowMs);
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
if (this.maybeApplyStartupDelayEstimate(nowMs)) {
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (this.lossBwe.isReady) {
|
|
1249
|
+
this.adoptLossBasedResult();
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
if (this.currentTargetBps <= 0)
|
|
1253
|
+
return;
|
|
1254
|
+
this.applyTargetLimits();
|
|
1255
|
+
}
|
|
1256
|
+
/**
|
|
1257
|
+
* pin `SendSideBandwidthEstimation::UpdateEstimate` on OnProcessInterval.
|
|
1258
|
+
* Does **not** invent a new delay sample.
|
|
1259
|
+
*/
|
|
1260
|
+
updateEstimateOnProcessInterval(nowMs) {
|
|
1261
|
+
this.updateEstimate(nowMs);
|
|
1262
|
+
if (this.hasValidSample || this._availableBitrate > 0) {
|
|
1263
|
+
(0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, this.currentTargetBps);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* pin `SendSideBandwidthEstimation::UpdateEstimate` RTT branch:
|
|
1268
|
+
* drop first (if interval due), then ApplyTargetLimits (delay upper + min).
|
|
1269
|
+
*
|
|
1270
|
+
* Called from {@link process} (pin OnProcessInterval) and after TWCC when
|
|
1271
|
+
* still RTT-limited. **Not** from `rtpPacketSent` (pin OnSentPacket).
|
|
1272
|
+
* Returns true when a drop was applied.
|
|
1273
|
+
*/
|
|
1274
|
+
maybeApplyRttBasedBackoff(nowMs) {
|
|
1275
|
+
if (!Number.isFinite(nowMs))
|
|
1276
|
+
return false;
|
|
1277
|
+
if (!this.rttBackoff.isRttAboveLimit())
|
|
1278
|
+
return false;
|
|
1279
|
+
if (this.currentTargetBps <= 0) {
|
|
1280
|
+
this.currentTargetBps = this.startBitrateBps;
|
|
1281
|
+
}
|
|
1282
|
+
let dropped = false;
|
|
1283
|
+
if (nowMs - this.lastRttDecreaseMs >= constants_1.kRttBasedBackOffDropIntervalMs &&
|
|
1284
|
+
this.currentTargetBps > constants_1.kRttBasedBackOffBandwidthFloorBps) {
|
|
1285
|
+
this.lastRttDecreaseMs = nowMs;
|
|
1286
|
+
this.currentTargetBps = Math.max(this.currentTargetBps * constants_1.kRttBasedBackOffDropFraction, constants_1.kRttBasedBackOffBandwidthFloorBps);
|
|
1287
|
+
dropped = true;
|
|
1288
|
+
}
|
|
1289
|
+
this.applyTargetLimits();
|
|
1290
|
+
// Safety drop publishes even before first TWCC (pin ProcessInterval path).
|
|
1291
|
+
(0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, this.currentTargetBps);
|
|
1292
|
+
return dropped;
|
|
1293
|
+
}
|
|
1294
|
+
dispose() {
|
|
1295
|
+
this.onAvailableBitrate.allUnsubscribe();
|
|
1296
|
+
this.onOveruseDetected.allUnsubscribe();
|
|
1297
|
+
this.onProbeClusterConfig.allUnsubscribe();
|
|
1298
|
+
this.onCongestion.allUnsubscribe();
|
|
1299
|
+
this.onCongestionScore.allUnsubscribe();
|
|
1300
|
+
this.reset();
|
|
1301
|
+
this.disposed = true;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* pin MaybeTriggerOnNetworkChanged — publish target, ALR budget, and
|
|
1305
|
+
* ProbeController estimated bitrate + BandwidthLimitedCause.
|
|
1306
|
+
* On {@link process} this runs **after** ProbeController::Process so the
|
|
1307
|
+
* same tick still uses the previous cause (pin order).
|
|
1308
|
+
*/
|
|
1309
|
+
propagateTarget(nowMs) {
|
|
1310
|
+
const target = this.currentTargetBps;
|
|
1311
|
+
if (!(target > 0))
|
|
1312
|
+
return undefined;
|
|
1313
|
+
// Do not publish the constructor start rate on ProcessInterval before
|
|
1314
|
+
// the first TWCC. RTT safety drops already publish via maybeApplyRttBasedBackoff.
|
|
1315
|
+
if (this.hasValidSample || this._availableBitrate > 0) {
|
|
1316
|
+
(0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, target);
|
|
1317
|
+
}
|
|
1318
|
+
this.alr.setEstimatedBitrate(target);
|
|
1319
|
+
const cause = (0, bandwidthLimitedCause_1.getBandwidthLimitedCause)(this.trendline.state, this.rttBackoff.isRttAboveLimit(), this.lossBwe.lossState);
|
|
1320
|
+
const maxProbe = (0, bandwidthLimitedCause_1.isProbeInitiationAllowed)(cause)
|
|
1321
|
+
? (0, bandwidthLimitedCause_1.maxProbeBitrateBps)(cause, target, this.targetMaxBps())
|
|
1322
|
+
: 0;
|
|
1323
|
+
for (const cfg of this.probe.setEstimatedBitrate(target, nowMs, {
|
|
1324
|
+
cause,
|
|
1325
|
+
maxProbeBps: maxProbe,
|
|
1326
|
+
})) {
|
|
1327
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
1328
|
+
}
|
|
1329
|
+
return cause;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* pin OnTransportPacketsFeedback ALR-ended wiring (before delay/loss).
|
|
1333
|
+
* Does **not** SetAlrStartTime — that is ProcessInterval + recovery only.
|
|
1334
|
+
*/
|
|
1335
|
+
noteAlrLeave(nowMs) {
|
|
1336
|
+
const inAlr = this.hasValidSample && this.alr.inAlr;
|
|
1337
|
+
if (this.previouslyInAlr && !inAlr) {
|
|
1338
|
+
this.probe.setAlrEndedTime(nowMs);
|
|
1339
|
+
this.ackedBitrate.setAlrEndedTime(nowMs);
|
|
1340
|
+
}
|
|
1341
|
+
this.previouslyInAlr = inAlr;
|
|
1342
|
+
this.aimd.setInApplicationLimitedRegion(inAlr);
|
|
1343
|
+
this.ackedBitrate.setAlr(inAlr);
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* pin OnProcessInterval ALR wiring: SetAlrStartTime then leave detection.
|
|
1347
|
+
* Does **not** enable periodic ALR probing (pin default false).
|
|
1348
|
+
*/
|
|
1349
|
+
syncAlr(nowMs) {
|
|
1350
|
+
this.probe.setAlrStartTime(this.hasValidSample ? this.alr.startMs : undefined);
|
|
1351
|
+
this.noteAlrLeave(nowMs);
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Fired only when a cluster becomes the **pacing** front (activated).
|
|
1355
|
+
* RTCRtpSender uses this for pace budget + padding injection — not for
|
|
1356
|
+
* queued-but-not-yet-active configs (e.g. 6x while 3x is still sending).
|
|
1357
|
+
*/
|
|
1358
|
+
onProbeClusterActivated(cfg, nowMs) {
|
|
1359
|
+
this.probeClusterSentBytes = 0;
|
|
1360
|
+
this.probeClusterStartMs = nowMs;
|
|
1361
|
+
this.lastProbeTargetBps = cfg.targetBps;
|
|
1362
|
+
this.onProbeClusterConfig.execute(cfg);
|
|
1363
|
+
}
|
|
1364
|
+
ensureProbing(nowMs) {
|
|
1365
|
+
if (this.probingConfigured)
|
|
1366
|
+
return;
|
|
1367
|
+
const clamped = this.clampConstraints(this.minConfiguredBps, this.startBitrateBps, this.appMaxBps ?? Number.POSITIVE_INFINITY);
|
|
1368
|
+
this.minConfiguredBps = clamped.minBps;
|
|
1369
|
+
if (clamped.startBps > 0) {
|
|
1370
|
+
this.startBitrateBps = clamped.startBps;
|
|
1371
|
+
}
|
|
1372
|
+
this.probingConfigured = true;
|
|
1373
|
+
for (const cfg of this.probe.setBitrates(this.minConfiguredBps, clamped.startBps, this.probeMaxBps(), nowMs)) {
|
|
1374
|
+
this.onProbeClusterActivated(cfg, nowMs);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
pushInterArrival(sendMs, recvMs, size, systemMs) {
|
|
1378
|
+
const deltas = this.interArrival.computeDeltas(sendMs, recvMs, size, systemMs);
|
|
1379
|
+
if (deltas) {
|
|
1380
|
+
this.trendline.update(deltas.recvDeltaMs, deltas.sendDeltaMs, recvMs);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
exports.GccBandwidthEstimator = GccBandwidthEstimator;
|
|
1385
|
+
Object.defineProperty(GccBandwidthEstimator, "knownDifferences", {
|
|
1386
|
+
enumerable: true,
|
|
1387
|
+
configurable: true,
|
|
1388
|
+
writable: true,
|
|
1389
|
+
value: constants_1.GCC_KNOWN_DIFFERENCES
|
|
1390
|
+
});
|
|
1391
|
+
//# sourceMappingURL=gccBwe.js.map
|