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,1042 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LossBasedBwe = 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 constants_1 = require("./constants");
|
|
13
|
+
/**
|
|
14
|
+
* LossBasedBweV2-aligned controller
|
|
15
|
+
* (`modules/congestion_controller/goog_cc/loss_based_bwe_v2.*`).
|
|
16
|
+
*
|
|
17
|
+
* - Partial observations accumulate until send-timeline duration ≥ 250ms
|
|
18
|
+
* - Soft loss: not-received seqs live in a map and can be unmarked if later
|
|
19
|
+
* reported as received **before** the observation commits (pin
|
|
20
|
+
* PushBackObservation). `num_packets` / `size` increase on every feedback
|
|
21
|
+
* appearance; the lost map is keyed by seq. After commit, a late received
|
|
22
|
+
* is a new packet.
|
|
23
|
+
* - Byte-loss objective/derivative when `UseByteLossRate` (default true)
|
|
24
|
+
* - High-bandwidth bias adjusted by average loss ratio
|
|
25
|
+
* - Instant upper/lower bounds + delayed-increase window + HOLD rate
|
|
26
|
+
* - `currentBestEstimate` (candidate model) is distinct from
|
|
27
|
+
* `lossBasedResult` (internal GoogCC result). HOLD clamps only the result.
|
|
28
|
+
* - Published output (GetLossBasedResult) stays delay-based until
|
|
29
|
+
* `IsReady()` (initialized current_best + min observations).
|
|
30
|
+
*/
|
|
31
|
+
class LossBasedBwe {
|
|
32
|
+
constructor() {
|
|
33
|
+
/** pin `current_best_estimate_` — next candidate generation basis. */
|
|
34
|
+
Object.defineProperty(this, "currentBestEstimate", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: {
|
|
39
|
+
inherentLoss: constants_1.kLossBasedInitialInherentLoss,
|
|
40
|
+
lossLimitedBandwidthBps: constants_1.kDefaultStartBitrateBps,
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* pin `IsValid(current_best_estimate_.loss_limited_bandwidth)`.
|
|
45
|
+
* Starts false (C++ MinusInfinity). First committed observation copies
|
|
46
|
+
* `delay_based_estimate_`; {@link setBandwidthEstimate} marks it valid.
|
|
47
|
+
*/
|
|
48
|
+
Object.defineProperty(this, "currentBestInitialized", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: false
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* pin `loss_based_result_` — value returned to GoogCC.
|
|
56
|
+
* Initial state is `kDelayBasedEstimate`.
|
|
57
|
+
*/
|
|
58
|
+
Object.defineProperty(this, "lossBasedResult", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: {
|
|
63
|
+
bandwidthEstimateBps: constants_1.kDefaultStartBitrateBps,
|
|
64
|
+
state: "delay_based",
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, "observations", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: []
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(this, "numObservations", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: 0
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, "acknowledgedBps", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: 0
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(this, "delayBasedBps", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: 0
|
|
90
|
+
});
|
|
91
|
+
/** pin `min_bitrate_` / `max_bitrate_` from SetMinMaxBitrate. */
|
|
92
|
+
Object.defineProperty(this, "minBitrateBps", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: constants_1.kMinBitrateBps
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "maxBitrateBps", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: constants_1.kMaxBitrateBps
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(this, "averageReportedLossRatio", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: 0
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "cachedInstantUpperBoundBps", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: constants_1.kMaxBitrateBps
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "cachedInstantLowerBoundBps", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: 0
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(this, "lastSendTimeMostRecentObservation", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
configurable: true,
|
|
125
|
+
writable: true,
|
|
126
|
+
value: Number.NaN
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(this, "recoveringAfterLossMs", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: Number.NaN
|
|
133
|
+
});
|
|
134
|
+
/** pin `bandwidth_limit_in_current_window_` starts as PlusInfinity. */
|
|
135
|
+
Object.defineProperty(this, "bandwidthLimitInCurrentWindow", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
configurable: true,
|
|
138
|
+
writable: true,
|
|
139
|
+
value: Number.POSITIVE_INFINITY
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(this, "holdUntilMs", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
writable: true,
|
|
145
|
+
value: Number.NEGATIVE_INFINITY
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(this, "holdDurationMs", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
configurable: true,
|
|
150
|
+
writable: true,
|
|
151
|
+
value: constants_1.kLossBasedInitHoldDurationMs
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(this, "holdRateBps", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: constants_1.kMaxBitrateBps
|
|
158
|
+
});
|
|
159
|
+
/**
|
|
160
|
+
* pin PaddingDuration. Default {@link kLossBasedPaddingDurationMs} (2s).
|
|
161
|
+
* Tests may override via {@link setPaddingDurationMs}.
|
|
162
|
+
*/
|
|
163
|
+
Object.defineProperty(this, "paddingDurationMs", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
configurable: true,
|
|
166
|
+
writable: true,
|
|
167
|
+
value: constants_1.kLossBasedPaddingDurationMs
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(this, "lastPaddingMs", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
configurable: true,
|
|
172
|
+
writable: true,
|
|
173
|
+
value: Number.NEGATIVE_INFINITY
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(this, "lastPaddingRateBps", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
configurable: true,
|
|
178
|
+
writable: true,
|
|
179
|
+
value: 0
|
|
180
|
+
});
|
|
181
|
+
/** Last `in_alr` passed to {@link update} (GetCandidates). */
|
|
182
|
+
Object.defineProperty(this, "inAlr", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: false
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(this, "partial", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
value: {
|
|
193
|
+
numPackets: 0,
|
|
194
|
+
/** seq → lost size (soft loss map). */
|
|
195
|
+
lostPackets: new Map(),
|
|
196
|
+
size: 0,
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(this, "temporalWeights", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
configurable: true,
|
|
202
|
+
writable: true,
|
|
203
|
+
value: []
|
|
204
|
+
});
|
|
205
|
+
/** pin `instant_upper_bound_temporal_weights_` (average loss ratio). */
|
|
206
|
+
Object.defineProperty(this, "instantTemporalWeights", {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
configurable: true,
|
|
209
|
+
writable: true,
|
|
210
|
+
value: []
|
|
211
|
+
});
|
|
212
|
+
this.recomputeTemporalWeights();
|
|
213
|
+
}
|
|
214
|
+
reset(startBps = constants_1.kDefaultStartBitrateBps) {
|
|
215
|
+
const start = clamp(startBps);
|
|
216
|
+
this.currentBestEstimate = {
|
|
217
|
+
inherentLoss: constants_1.kLossBasedInitialInherentLoss,
|
|
218
|
+
lossLimitedBandwidthBps: start,
|
|
219
|
+
};
|
|
220
|
+
this.currentBestInitialized = false;
|
|
221
|
+
this.lossBasedResult = {
|
|
222
|
+
bandwidthEstimateBps: start,
|
|
223
|
+
state: "delay_based",
|
|
224
|
+
};
|
|
225
|
+
this.observations = [];
|
|
226
|
+
this.numObservations = 0;
|
|
227
|
+
this.acknowledgedBps = 0;
|
|
228
|
+
this.delayBasedBps = 0;
|
|
229
|
+
this.minBitrateBps = constants_1.kMinBitrateBps;
|
|
230
|
+
this.maxBitrateBps = constants_1.kMaxBitrateBps;
|
|
231
|
+
this.averageReportedLossRatio = 0;
|
|
232
|
+
this.cachedInstantUpperBoundBps = constants_1.kMaxBitrateBps;
|
|
233
|
+
this.cachedInstantLowerBoundBps = 0;
|
|
234
|
+
this.lastSendTimeMostRecentObservation = Number.NaN;
|
|
235
|
+
this.recoveringAfterLossMs = Number.NaN;
|
|
236
|
+
this.bandwidthLimitInCurrentWindow = Number.POSITIVE_INFINITY;
|
|
237
|
+
this.holdUntilMs = Number.NEGATIVE_INFINITY;
|
|
238
|
+
this.holdDurationMs = constants_1.kLossBasedInitHoldDurationMs;
|
|
239
|
+
this.holdRateBps = constants_1.kMaxBitrateBps;
|
|
240
|
+
this.paddingDurationMs = constants_1.kLossBasedPaddingDurationMs;
|
|
241
|
+
this.lastPaddingMs = Number.NEGATIVE_INFINITY;
|
|
242
|
+
this.lastPaddingRateBps = 0;
|
|
243
|
+
this.inAlr = false;
|
|
244
|
+
this.partial = {
|
|
245
|
+
numPackets: 0,
|
|
246
|
+
lostPackets: new Map(),
|
|
247
|
+
size: 0,
|
|
248
|
+
};
|
|
249
|
+
this.recomputeTemporalWeights();
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* pin PaddingDuration. 0 keeps `increasing`; >0 enters
|
|
253
|
+
* `increase_using_padding` on loss-limited increase (maps to kLossLimitedBwe).
|
|
254
|
+
*/
|
|
255
|
+
setPaddingDurationMs(ms) {
|
|
256
|
+
this.paddingDurationMs = Number.isFinite(ms) ? Math.max(0, ms) : 0;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* pin `LossBasedBweV2::SetMinMaxBitrate`.
|
|
260
|
+
* `maxBps <= 0` / non-finite → {@link kMaxBitrateBps} (1 Gbps).
|
|
261
|
+
*/
|
|
262
|
+
setMinMaxBitrate(minBps, maxBps) {
|
|
263
|
+
if (Number.isFinite(minBps) && minBps > 0) {
|
|
264
|
+
this.minBitrateBps = Math.max(minBps, constants_1.kMinBitrateBps);
|
|
265
|
+
this.calculateInstantLowerBound();
|
|
266
|
+
}
|
|
267
|
+
if (Number.isFinite(maxBps) && maxBps > 0) {
|
|
268
|
+
this.maxBitrateBps = Math.max(this.minBitrateBps, maxBps);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
this.maxBitrateBps = constants_1.kMaxBitrateBps;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* State-preserving bandwidth update (libwebrtc
|
|
276
|
+
* `LossBasedBweV2::SetBandwidthEstimate`).
|
|
277
|
+
* Sets the loss-limited bandwidth and marks delay-based alignment without
|
|
278
|
+
* clearing observation history, HOLD timers, or inherent-loss estimates.
|
|
279
|
+
*/
|
|
280
|
+
setBandwidthEstimate(bandwidthBps) {
|
|
281
|
+
const bps = clamp(bandwidthBps);
|
|
282
|
+
this.currentBestEstimate.lossLimitedBandwidthBps = bps;
|
|
283
|
+
this.currentBestInitialized = true;
|
|
284
|
+
this.lossBasedResult = {
|
|
285
|
+
bandwidthEstimateBps: bps,
|
|
286
|
+
state: "delay_based",
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* pin `LossBasedBweV2::IsReady` — initialized current_best and
|
|
291
|
+
* `num_observations_ >= MinNumObservations`.
|
|
292
|
+
*/
|
|
293
|
+
get isReady() {
|
|
294
|
+
return (this.currentBestInitialized &&
|
|
295
|
+
this.numObservations >= constants_1.kLossBasedMinNumObservations);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* pin `LossBasedBweV2::UseInStartPhase` (default true).
|
|
299
|
+
*/
|
|
300
|
+
get useInStartPhase() {
|
|
301
|
+
return constants_1.kLossBasedUseInStartPhase;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* pin `LossBasedBweV2::ReadyToUseInStartPhase` —
|
|
305
|
+
* `IsReady() && UseInStartPhase`. While false, send-side UpdateEstimate
|
|
306
|
+
* may still raise `current_target_` via delay_based_limit_ during the
|
|
307
|
+
* start phase (`last_fraction_loss_ == 0`).
|
|
308
|
+
*/
|
|
309
|
+
get readyToUseInStartPhase() {
|
|
310
|
+
return this.isReady && this.useInStartPhase;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* pin `GetLossBasedResult`. Until {@link isReady}, delay (or `+Infinity`
|
|
314
|
+
* if delay is unset) with `kDelayBasedEstimate`. Does **not** expose the
|
|
315
|
+
* internally evolving `loss_based_result_` or uninitialized current-best.
|
|
316
|
+
*/
|
|
317
|
+
get targetBitrateBps() {
|
|
318
|
+
return this.getLossBasedResult().bandwidthEstimateBps;
|
|
319
|
+
}
|
|
320
|
+
get lossState() {
|
|
321
|
+
return this.getLossBasedResult().state;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* @internal test hook — pin `loss_based_result_.state`.
|
|
325
|
+
* Production callers use {@link lossState}.
|
|
326
|
+
*/
|
|
327
|
+
get state() {
|
|
328
|
+
return this.lossBasedResult.state;
|
|
329
|
+
}
|
|
330
|
+
set state(s) {
|
|
331
|
+
this.lossBasedResult.state = s;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @internal test hook — pin `current_best_estimate_`.
|
|
335
|
+
* Mutating fields updates the candidate model, not the published result.
|
|
336
|
+
*/
|
|
337
|
+
get current() {
|
|
338
|
+
return this.currentBestEstimate;
|
|
339
|
+
}
|
|
340
|
+
get averageLossRatio() {
|
|
341
|
+
return this.averageReportedLossRatio;
|
|
342
|
+
}
|
|
343
|
+
get inherentLossEstimate() {
|
|
344
|
+
return this.currentBestEstimate.inherentLoss;
|
|
345
|
+
}
|
|
346
|
+
/** Number of committed observations (for readiness tests). */
|
|
347
|
+
get observationCount() {
|
|
348
|
+
return this.numObservations;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* pin `LossBasedBweV2::GetLossBasedResult`.
|
|
352
|
+
* `ready` is {@link isReady}. Controllers must ignore
|
|
353
|
+
* `bandwidthEstimateBps` until `ready` (pin
|
|
354
|
+
* `LossBasedBandwidthEstimatorV2ReadyForUse`).
|
|
355
|
+
*/
|
|
356
|
+
getLossBasedResult() {
|
|
357
|
+
if (!this.isReady) {
|
|
358
|
+
return {
|
|
359
|
+
ready: false,
|
|
360
|
+
bandwidthEstimateBps: this.delayBasedBps > 0
|
|
361
|
+
? this.delayBasedBps
|
|
362
|
+
: Number.POSITIVE_INFINITY,
|
|
363
|
+
state: "delay_based",
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
ready: true,
|
|
368
|
+
bandwidthEstimateBps: this.lossBasedResult.bandwidthEstimateBps,
|
|
369
|
+
state: this.lossBasedResult.state,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
setBitrateIfHigher(bps) {
|
|
373
|
+
if (bps > this.currentBestEstimate.lossLimitedBandwidthBps) {
|
|
374
|
+
this.currentBestEstimate.lossLimitedBandwidthBps = clamp(bps);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* @param lossFraction fallback when packet counts are 0
|
|
379
|
+
* @param delayBasedBps delay-based A_hat
|
|
380
|
+
* @param acknowledgedBps recent acked bitrate (TWCC-relative throughput)
|
|
381
|
+
* @param packetCount known packets in batch
|
|
382
|
+
* @param lostCount lost among known
|
|
383
|
+
* @param firstSendMs actual first send time of this batch (send timeline)
|
|
384
|
+
* @param batchBytes total sent bytes in batch
|
|
385
|
+
* @param lastSendMs actual last send time of this batch (send timeline)
|
|
386
|
+
* @param lostBytes lost bytes in batch (byte-loss mode); if 0 with losses,
|
|
387
|
+
* approximated from average packet size
|
|
388
|
+
* @param packets optional per-packet feedback for soft-loss map
|
|
389
|
+
* @param inAlr pin `GetCandidates(in_alr)` — skip acked-rate in ALR
|
|
390
|
+
*/
|
|
391
|
+
update(lossFraction, delayBasedBps, acknowledgedBps = 0, packetCount = 0, lostCount = 0, firstSendMs = 0, batchBytes = 0, lastSendMs = 0, lostBytes = 0, packets, inAlr = false) {
|
|
392
|
+
this.inAlr = inAlr;
|
|
393
|
+
if (acknowledgedBps > 0) {
|
|
394
|
+
this.acknowledgedBps = acknowledgedBps;
|
|
395
|
+
this.calculateInstantLowerBound();
|
|
396
|
+
}
|
|
397
|
+
// pin always assigns delay_based_estimate_ (PlusInfinity → 0 here).
|
|
398
|
+
// Keep a stale delay cap only when the caller still has a finite limit.
|
|
399
|
+
this.delayBasedBps = delayBasedBps > 0 ? delayBasedBps : 0;
|
|
400
|
+
const n = packetCount > 0 ? packetCount : 0;
|
|
401
|
+
const lost = packetCount > 0
|
|
402
|
+
? lostCount
|
|
403
|
+
: Math.round(Math.min(Math.max(lossFraction, 0), 1) * Math.max(n, 1));
|
|
404
|
+
// Resolve send timeline: prefer explicit first/last; fall back to duration
|
|
405
|
+
// style when lastSendMs < firstSendMs (legacy test: last arg was duration).
|
|
406
|
+
let batchFirst = firstSendMs;
|
|
407
|
+
let batchLast = lastSendMs;
|
|
408
|
+
if (batchLast > 0 && batchFirst > 0 && batchLast < batchFirst) {
|
|
409
|
+
// Interpreted as (nowMs, sendDurationMs) legacy — do not use for real path.
|
|
410
|
+
batchLast = batchFirst;
|
|
411
|
+
batchFirst = batchFirst - lastSendMs;
|
|
412
|
+
}
|
|
413
|
+
if (batchLast <= 0 && batchFirst > 0) {
|
|
414
|
+
batchLast = batchFirst;
|
|
415
|
+
}
|
|
416
|
+
let committed = false;
|
|
417
|
+
if (n > 0 || (packets && packets.length > 0)) {
|
|
418
|
+
committed = this.accumulatePartial(n, lost, batchBytes, lostBytes, batchFirst, batchLast, packets);
|
|
419
|
+
}
|
|
420
|
+
// pin UpdateBandwidthEstimate: no new observation → return without
|
|
421
|
+
// Newton / state transition. GetLossBasedResult still tracks the latest
|
|
422
|
+
// delay-based estimate while !IsReady().
|
|
423
|
+
if (!committed) {
|
|
424
|
+
return this.getLossBasedResult().bandwidthEstimateBps;
|
|
425
|
+
}
|
|
426
|
+
// pin: first valid current_best_estimate_ is delay_based_estimate_.
|
|
427
|
+
if (!this.currentBestInitialized) {
|
|
428
|
+
if (!(this.delayBasedBps > 0)) {
|
|
429
|
+
return this.getLossBasedResult().bandwidthEstimateBps;
|
|
430
|
+
}
|
|
431
|
+
this.currentBestEstimate.lossLimitedBandwidthBps = this.delayBasedBps;
|
|
432
|
+
this.lossBasedResult = {
|
|
433
|
+
bandwidthEstimateBps: this.delayBasedBps,
|
|
434
|
+
state: "delay_based",
|
|
435
|
+
};
|
|
436
|
+
this.currentBestInitialized = true;
|
|
437
|
+
}
|
|
438
|
+
this.updateAverageReportedLossRatio();
|
|
439
|
+
this.calculateInstantUpperBound();
|
|
440
|
+
this.calculateInstantLowerBound();
|
|
441
|
+
const currentBw = this.currentBestEstimate.lossLimitedBandwidthBps;
|
|
442
|
+
let best = { ...this.currentBestEstimate };
|
|
443
|
+
let bestObjective = Number.NEGATIVE_INFINITY;
|
|
444
|
+
for (const candidate of this.getCandidates(this.inAlr)) {
|
|
445
|
+
this.newtonsMethodUpdate(candidate);
|
|
446
|
+
const obj = this.getObjective(candidate);
|
|
447
|
+
if (obj > bestObjective ||
|
|
448
|
+
(obj === bestObjective &&
|
|
449
|
+
candidate.lossLimitedBandwidthBps > best.lossLimitedBandwidthBps)) {
|
|
450
|
+
bestObjective = obj;
|
|
451
|
+
best = candidate;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// Do not increase if average loss exceeds inherent loss estimate.
|
|
455
|
+
if (constants_1.kLossBasedNotIncreaseIfInherentLessThanAverage &&
|
|
456
|
+
this.averageReportedLossRatio > best.inherentLoss &&
|
|
457
|
+
currentBw < best.lossLimitedBandwidthBps) {
|
|
458
|
+
best.lossLimitedBandwidthBps = currentBw;
|
|
459
|
+
}
|
|
460
|
+
// pin order after best: delayed-increase cap → acked ramp-up cap →
|
|
461
|
+
// decreasing→increasing 1bps nudge. Acked cap is **not** in GetCandidates.
|
|
462
|
+
if (this.isInLossLimitedState()) {
|
|
463
|
+
if (Number.isFinite(this.recoveringAfterLossMs) &&
|
|
464
|
+
this.recoveringAfterLossMs + constants_1.kLossBasedDelayedIncreaseWindowMs >
|
|
465
|
+
this.lastSendTimeMostRecentObservation &&
|
|
466
|
+
best.lossLimitedBandwidthBps > this.bandwidthLimitInCurrentWindow) {
|
|
467
|
+
best.lossLimitedBandwidthBps = this.bandwidthLimitInCurrentWindow;
|
|
468
|
+
}
|
|
469
|
+
const increasingWhenLossLimited = this.isEstimateIncreasingWhenLossLimited(currentBw, best.lossLimitedBandwidthBps);
|
|
470
|
+
if (increasingWhenLossLimited && this.acknowledgedBps > 0) {
|
|
471
|
+
const rampupCap = this.acknowledgedBps * this.rampupBoundFactor();
|
|
472
|
+
best.lossLimitedBandwidthBps = Math.max(currentBw, Math.min(best.lossLimitedBandwidthBps, rampupCap));
|
|
473
|
+
// pin: if acked cap pinned the estimate to current while decreasing,
|
|
474
|
+
// raise 1bps so state can switch to kIncreasing / padding.
|
|
475
|
+
if (this.lossBasedResult.state === "decreasing" &&
|
|
476
|
+
best.lossLimitedBandwidthBps === currentBw) {
|
|
477
|
+
best.lossLimitedBandwidthBps = currentBw + 1;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
// Bound best candidate by instant bounds (+ delay-based when available).
|
|
482
|
+
let bounded = best.lossLimitedBandwidthBps;
|
|
483
|
+
const upper = this.cachedInstantUpperBoundBps;
|
|
484
|
+
const lower = this.cachedInstantLowerBoundBps;
|
|
485
|
+
const delayCap = this.delayBasedCapBps();
|
|
486
|
+
if (Number.isFinite(delayCap)) {
|
|
487
|
+
bounded = Math.max(lower, Math.min(bounded, upper, delayCap));
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
bounded = Math.max(lower, Math.min(bounded, upper));
|
|
491
|
+
}
|
|
492
|
+
if (constants_1.kLossBasedBoundBestCandidate &&
|
|
493
|
+
bounded < best.lossLimitedBandwidthBps) {
|
|
494
|
+
this.currentBestEstimate.lossLimitedBandwidthBps = clamp(bounded);
|
|
495
|
+
this.currentBestEstimate.inherentLoss = 0;
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
this.currentBestEstimate = best;
|
|
499
|
+
this.currentBestEstimate.lossLimitedBandwidthBps = clamp(Math.max(this.currentBestEstimate.lossLimitedBandwidthBps, lower));
|
|
500
|
+
}
|
|
501
|
+
// HOLD: publish min(holdRate, bounded) without rewriting currentBestEstimate.
|
|
502
|
+
// pin keeps kDecreasing while last_hold_info_.timestamp is in the future.
|
|
503
|
+
const lastSend = this.lastSendTimeMostRecentObservation;
|
|
504
|
+
if (this.lossBasedResult.state === "decreasing" &&
|
|
505
|
+
this.holdUntilMs > lastSend &&
|
|
506
|
+
bounded < delayCap) {
|
|
507
|
+
this.holdRateBps = Math.max(lower, this.holdRateBps);
|
|
508
|
+
this.lossBasedResult.bandwidthEstimateBps = clamp(Math.min(this.holdRateBps, bounded));
|
|
509
|
+
return this.getLossBasedResult().bandwidthEstimateBps;
|
|
510
|
+
}
|
|
511
|
+
this.updateState(this.lossBasedResult.bandwidthEstimateBps, bounded, lastSend);
|
|
512
|
+
if (this.isInLossLimitedState()) {
|
|
513
|
+
if (!Number.isFinite(this.recoveringAfterLossMs) ||
|
|
514
|
+
this.recoveringAfterLossMs + constants_1.kLossBasedDelayedIncreaseWindowMs <
|
|
515
|
+
lastSend) {
|
|
516
|
+
this.bandwidthLimitInCurrentWindow = Math.max(constants_1.kMinBitrateBps, this.currentBestEstimate.lossLimitedBandwidthBps *
|
|
517
|
+
constants_1.kLossBasedMaxIncreaseFactor);
|
|
518
|
+
this.recoveringAfterLossMs = lastSend;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return this.getLossBasedResult().bandwidthEstimateBps;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* pin state transition after HOLD early-return is skipped.
|
|
525
|
+
* `prev` is the previously **published** `loss_based_result_.bandwidth_estimate`.
|
|
526
|
+
* `next` is the bounded candidate (not necessarily `current_best_estimate_`).
|
|
527
|
+
*/
|
|
528
|
+
updateState(prev, next, lastSendMs) {
|
|
529
|
+
const delayCap = this.delayBasedCapBps();
|
|
530
|
+
const belowDelay = next < delayCap;
|
|
531
|
+
const belowMax = next < this.maxBitrateBps;
|
|
532
|
+
if (this.isEstimateIncreasingWhenLossLimited(prev, next) &&
|
|
533
|
+
this.canKeepIncreasingState(next) &&
|
|
534
|
+
belowDelay &&
|
|
535
|
+
belowMax) {
|
|
536
|
+
this.enterIncreasingState(next, lastSendMs);
|
|
537
|
+
}
|
|
538
|
+
else if (belowDelay && belowMax) {
|
|
539
|
+
// Arm HOLD only when *entering* decreasing. Stepwise extra decreases
|
|
540
|
+
// keep the existing last_hold_info_ (pin hold_duration_factor > 0).
|
|
541
|
+
if (this.lossBasedResult.state !== "decreasing" &&
|
|
542
|
+
constants_1.kLossBasedHoldDurationFactor > 0) {
|
|
543
|
+
this.armHold(next, lastSendMs);
|
|
544
|
+
}
|
|
545
|
+
this.clearPaddingInfo();
|
|
546
|
+
this.lossBasedResult.state = "decreasing";
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
this.resetHold();
|
|
550
|
+
this.clearPaddingInfo();
|
|
551
|
+
this.lossBasedResult.state = "delay_based";
|
|
552
|
+
}
|
|
553
|
+
this.lossBasedResult.bandwidthEstimateBps = clamp(next);
|
|
554
|
+
}
|
|
555
|
+
/** pin `delay_based_estimate_` defaults to +∞ when unset. */
|
|
556
|
+
delayBasedCapBps() {
|
|
557
|
+
return this.delayBasedBps > 0
|
|
558
|
+
? this.delayBasedBps
|
|
559
|
+
: Number.POSITIVE_INFINITY;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* pin `last_hold_info_` arm: hold_until = now + *current* duration
|
|
563
|
+
* (first time 300ms), then duration *= factor for the *next* HOLD.
|
|
564
|
+
*/
|
|
565
|
+
armHold(rateBps, lastSendMs) {
|
|
566
|
+
this.holdUntilMs = lastSendMs + this.holdDurationMs;
|
|
567
|
+
this.holdRateBps = rateBps;
|
|
568
|
+
this.holdDurationMs = Math.min(constants_1.kLossBasedMaxHoldDurationMs, Math.max(constants_1.kLossBasedInitHoldDurationMs, this.holdDurationMs * constants_1.kLossBasedHoldDurationFactor));
|
|
569
|
+
}
|
|
570
|
+
resetHold() {
|
|
571
|
+
this.holdUntilMs = Number.NEGATIVE_INFINITY;
|
|
572
|
+
this.holdDurationMs = constants_1.kLossBasedInitHoldDurationMs;
|
|
573
|
+
this.holdRateBps = constants_1.kMaxBitrateBps;
|
|
574
|
+
}
|
|
575
|
+
clearPaddingInfo() {
|
|
576
|
+
this.lastPaddingMs = Number.NEGATIVE_INFINITY;
|
|
577
|
+
this.lastPaddingRateBps = 0;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* pin `IsEstimateIncreasingWhenLossLimited`.
|
|
581
|
+
* Flat estimate still counts as increasing while already
|
|
582
|
+
* `increasing` / `increase_using_padding`.
|
|
583
|
+
*/
|
|
584
|
+
isEstimateIncreasingWhenLossLimited(prev, next) {
|
|
585
|
+
if (!this.isInLossLimitedState())
|
|
586
|
+
return false;
|
|
587
|
+
if (next > prev)
|
|
588
|
+
return true;
|
|
589
|
+
return (next === prev &&
|
|
590
|
+
(this.lossBasedResult.state === "increasing" ||
|
|
591
|
+
this.lossBasedResult.state === "increase_using_padding"));
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* pin `CanKeepIncreasingState`.
|
|
595
|
+
* While `increase_using_padding`, keep the state if the padding window
|
|
596
|
+
* (last_padding + PaddingDuration) still covers the latest send time,
|
|
597
|
+
* or if the estimate rose above the last padding rate.
|
|
598
|
+
*/
|
|
599
|
+
canKeepIncreasingState(estimateBps) {
|
|
600
|
+
if (this.paddingDurationMs <= 0 ||
|
|
601
|
+
this.lossBasedResult.state !== "increase_using_padding") {
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
604
|
+
return (this.lastPaddingMs + this.paddingDurationMs >=
|
|
605
|
+
this.lastSendTimeMostRecentObservation ||
|
|
606
|
+
this.lastPaddingRateBps < estimateBps);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* pin: when PaddingDuration > 0 and estimate is increasing while
|
|
610
|
+
* loss-limited, state is kIncreaseUsingPadding; otherwise kIncreasing.
|
|
611
|
+
*/
|
|
612
|
+
enterIncreasingState(nextBps, lastSendMs) {
|
|
613
|
+
if (this.paddingDurationMs > 0) {
|
|
614
|
+
if (nextBps > this.lastPaddingRateBps) {
|
|
615
|
+
this.lastPaddingRateBps = nextBps;
|
|
616
|
+
this.lastPaddingMs = lastSendMs;
|
|
617
|
+
}
|
|
618
|
+
this.lossBasedResult.state = "increase_using_padding";
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
this.lossBasedResult.state = "increasing";
|
|
622
|
+
}
|
|
623
|
+
/** pin: any state other than `kDelayBasedEstimate`. */
|
|
624
|
+
isInLossLimitedState() {
|
|
625
|
+
return this.lossBasedResult.state !== "delay_based";
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* libwebrtc: after HOLD, if acked has not recovered above
|
|
629
|
+
* holdRate × BwRampupUpperBoundHoldThreshold (1.3), use 1.2× factor;
|
|
630
|
+
* otherwise the normal 1.5× factor.
|
|
631
|
+
*/
|
|
632
|
+
rampupBoundFactor() {
|
|
633
|
+
if (this.holdRateBps > 0 &&
|
|
634
|
+
this.holdRateBps < constants_1.kMaxBitrateBps &&
|
|
635
|
+
this.acknowledgedBps > 0 &&
|
|
636
|
+
this.acknowledgedBps <
|
|
637
|
+
this.holdRateBps * constants_1.kLossBasedRampupUpperBoundHoldThreshold) {
|
|
638
|
+
return constants_1.kLossBasedRampupUpperBoundInHoldFactor;
|
|
639
|
+
}
|
|
640
|
+
return constants_1.kLossBasedRampupUpperBoundFactor;
|
|
641
|
+
}
|
|
642
|
+
accumulatePartial(numPackets, numLost, batchBytes, lostBytes, firstSendMs, lastSendMs, packets) {
|
|
643
|
+
if (packets && packets.length > 0) {
|
|
644
|
+
// pin PushBackObservation: count/size grow on every feedback appearance.
|
|
645
|
+
this.partial.numPackets += packets.length;
|
|
646
|
+
let minSend = Number.POSITIVE_INFINITY;
|
|
647
|
+
let maxSend = Number.NEGATIVE_INFINITY;
|
|
648
|
+
for (const p of packets) {
|
|
649
|
+
// Use the caller-supplied seq as-is (gcc passes unwrapped / generation
|
|
650
|
+
// keys). Masking to 16-bit would merge wrap generations in one window.
|
|
651
|
+
const seq = p.seq;
|
|
652
|
+
if (p.received) {
|
|
653
|
+
this.partial.lostPackets.delete(seq);
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
// emplace: first size wins; later not-received does not grow lost_size.
|
|
657
|
+
if (!this.partial.lostPackets.has(seq)) {
|
|
658
|
+
this.partial.lostPackets.set(seq, p.size);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
this.partial.size += p.size;
|
|
662
|
+
if (Number.isFinite(p.sendMs)) {
|
|
663
|
+
if (p.sendMs < minSend)
|
|
664
|
+
minSend = p.sendMs;
|
|
665
|
+
if (p.sendMs > maxSend)
|
|
666
|
+
maxSend = p.sendMs;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (Number.isFinite(minSend))
|
|
670
|
+
firstSendMs = minSend;
|
|
671
|
+
if (Number.isFinite(maxSend))
|
|
672
|
+
lastSendMs = maxSend;
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
this.partial.numPackets += numPackets;
|
|
676
|
+
this.partial.size += batchBytes;
|
|
677
|
+
// Aggregate soft-loss: synthetic seqs so later aggregate "received" cannot
|
|
678
|
+
// unmark — tests without seq still work; real path should pass packets.
|
|
679
|
+
const avgSize = numPackets > 0 ? Math.max(1, Math.round(batchBytes / numPackets)) : 1;
|
|
680
|
+
const lostSize = lostBytes > 0 ? lostBytes : numLost > 0 ? avgSize * numLost : 0;
|
|
681
|
+
// Represent lost packets as unique synthetic keys for this batch.
|
|
682
|
+
const baseKey = (this.numObservations + 1) * 1000000 + this.partial.numPackets;
|
|
683
|
+
for (let i = 0; i < numLost; i++) {
|
|
684
|
+
const per = i === numLost - 1
|
|
685
|
+
? Math.max(1, lostSize - avgSize * (numLost - 1))
|
|
686
|
+
: avgSize;
|
|
687
|
+
this.partial.lostPackets.set(baseKey + i, per);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (!Number.isFinite(this.lastSendTimeMostRecentObservation)) {
|
|
691
|
+
this.lastSendTimeMostRecentObservation = firstSendMs;
|
|
692
|
+
}
|
|
693
|
+
// Bound partial maps if the observation duration never advances
|
|
694
|
+
// (identical send timestamps / stalled clock). Prefer dropping the
|
|
695
|
+
// incomplete window over unbounded growth.
|
|
696
|
+
if (this.partial.numPackets > LossBasedBwe.kMaxPartialPackets) {
|
|
697
|
+
this.partial = {
|
|
698
|
+
numPackets: 0,
|
|
699
|
+
lostPackets: new Map(),
|
|
700
|
+
size: 0,
|
|
701
|
+
};
|
|
702
|
+
this.lastSendTimeMostRecentObservation = lastSendMs;
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
const observationDuration = lastSendMs - this.lastSendTimeMostRecentObservation;
|
|
706
|
+
if (observationDuration <= 0 ||
|
|
707
|
+
observationDuration < constants_1.kLossBasedObservationDurationLowerBoundMs) {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
this.lastSendTimeMostRecentObservation = lastSendMs;
|
|
711
|
+
let lostSize = 0;
|
|
712
|
+
for (const s of this.partial.lostPackets.values()) {
|
|
713
|
+
lostSize += s;
|
|
714
|
+
}
|
|
715
|
+
const numLostPackets = this.partial.lostPackets.size;
|
|
716
|
+
const numPkts = this.partial.numPackets;
|
|
717
|
+
const instantaneous = this.partial.size > 0 && observationDuration > 0
|
|
718
|
+
? (this.partial.size * 8 * 1000) / observationDuration
|
|
719
|
+
: this.acknowledgedBps > 0
|
|
720
|
+
? this.acknowledgedBps
|
|
721
|
+
: this.currentBestEstimate.lossLimitedBandwidthBps;
|
|
722
|
+
const sendingRateBps = this.getSendingRate(instantaneous);
|
|
723
|
+
this.commitObservation({
|
|
724
|
+
numPackets: numPkts,
|
|
725
|
+
numLostPackets: numLostPackets,
|
|
726
|
+
numReceivedPackets: Math.max(0, numPkts - numLostPackets),
|
|
727
|
+
size: this.partial.size,
|
|
728
|
+
lostSize,
|
|
729
|
+
sendingRateBps,
|
|
730
|
+
});
|
|
731
|
+
this.partial = {
|
|
732
|
+
numPackets: 0,
|
|
733
|
+
lostPackets: new Map(),
|
|
734
|
+
size: 0,
|
|
735
|
+
};
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
commitObservation(o) {
|
|
739
|
+
const obs = {
|
|
740
|
+
...o,
|
|
741
|
+
id: this.numObservations++,
|
|
742
|
+
};
|
|
743
|
+
this.observations.push(obs);
|
|
744
|
+
while (this.observations.length > constants_1.kLossBasedObservationWindow) {
|
|
745
|
+
this.observations.shift();
|
|
746
|
+
}
|
|
747
|
+
this.updateAverageReportedLossRatio();
|
|
748
|
+
this.calculateInstantUpperBound();
|
|
749
|
+
}
|
|
750
|
+
recomputeTemporalWeights() {
|
|
751
|
+
this.temporalWeights = [];
|
|
752
|
+
this.instantTemporalWeights = [];
|
|
753
|
+
for (let i = 0; i < constants_1.kLossBasedObservationWindow; i++) {
|
|
754
|
+
this.temporalWeights.push(constants_1.kLossBasedTemporalWeightFactor ** i);
|
|
755
|
+
this.instantTemporalWeights.push(constants_1.kLossBasedInstantUpperBoundTemporalWeightFactor ** i);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
temporalWeightFor(observation) {
|
|
759
|
+
const age = this.numObservations - 1 - observation.id;
|
|
760
|
+
if (age < 0 || age >= this.temporalWeights.length) {
|
|
761
|
+
return constants_1.kLossBasedTemporalWeightFactor ** Math.max(age, 0);
|
|
762
|
+
}
|
|
763
|
+
return this.temporalWeights[age];
|
|
764
|
+
}
|
|
765
|
+
/** pin instant_upper_bound_temporal_weights_ for average loss ratio. */
|
|
766
|
+
instantTemporalWeightFor(observation) {
|
|
767
|
+
const age = this.numObservations - 1 - observation.id;
|
|
768
|
+
if (age < 0 || age >= this.instantTemporalWeights.length) {
|
|
769
|
+
return (constants_1.kLossBasedInstantUpperBoundTemporalWeightFactor ** Math.max(age, 0));
|
|
770
|
+
}
|
|
771
|
+
return this.instantTemporalWeights[age];
|
|
772
|
+
}
|
|
773
|
+
/** pin `GetSendingRate` (smoothing default 0). */
|
|
774
|
+
getSendingRate(instantaneousBps) {
|
|
775
|
+
if (this.numObservations <= 0)
|
|
776
|
+
return instantaneousBps;
|
|
777
|
+
const prev = this.observations[this.observations.length - 1];
|
|
778
|
+
if (!prev || !(prev.sendingRateBps > 0))
|
|
779
|
+
return instantaneousBps;
|
|
780
|
+
return (constants_1.kLossBasedSendingRateSmoothingFactor * prev.sendingRateBps +
|
|
781
|
+
(1 - constants_1.kLossBasedSendingRateSmoothingFactor) * instantaneousBps);
|
|
782
|
+
}
|
|
783
|
+
updateAverageReportedLossRatio() {
|
|
784
|
+
if (this.observations.length === 0) {
|
|
785
|
+
this.averageReportedLossRatio = 0;
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (constants_1.kLossBasedUseByteLossRate) {
|
|
789
|
+
this.averageReportedLossRatio =
|
|
790
|
+
this.calculateAverageReportedByteLossRatio();
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
let lost = 0;
|
|
794
|
+
let total = 0;
|
|
795
|
+
for (const o of this.observations) {
|
|
796
|
+
const w = this.instantTemporalWeightFor(o);
|
|
797
|
+
lost += w * o.numLostPackets;
|
|
798
|
+
total += w * o.numPackets;
|
|
799
|
+
}
|
|
800
|
+
this.averageReportedLossRatio = total > 0 ? lost / total : 0;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* pin `CalculateAverageReportedByteLossRatio`.
|
|
805
|
+
* When more than 3 observations exist, drop the min and max loss-rate
|
|
806
|
+
* windows unless the max-loss window's send rate is ≥ median × 2.
|
|
807
|
+
*/
|
|
808
|
+
calculateAverageReportedByteLossRatio() {
|
|
809
|
+
if (this.observations.length === 0)
|
|
810
|
+
return 0;
|
|
811
|
+
let lost = 0;
|
|
812
|
+
let total = 0;
|
|
813
|
+
let minLossRate = 1;
|
|
814
|
+
let maxLossRate = 0;
|
|
815
|
+
let minLost = 0;
|
|
816
|
+
let maxLost = 0;
|
|
817
|
+
let minBytes = 0;
|
|
818
|
+
let maxBytes = 0;
|
|
819
|
+
let sendRateOfMaxLoss = 0;
|
|
820
|
+
for (const o of this.observations) {
|
|
821
|
+
const w = this.instantTemporalWeightFor(o);
|
|
822
|
+
const wLost = w * o.lostSize;
|
|
823
|
+
const wSize = w * o.size;
|
|
824
|
+
lost += wLost;
|
|
825
|
+
total += wSize;
|
|
826
|
+
const lossRate = o.size > 0 ? o.lostSize / o.size : 0;
|
|
827
|
+
if (this.numObservations > 3) {
|
|
828
|
+
if (lossRate > maxLossRate) {
|
|
829
|
+
maxLossRate = lossRate;
|
|
830
|
+
maxLost = wLost;
|
|
831
|
+
maxBytes = wSize;
|
|
832
|
+
sendRateOfMaxLoss = o.sendingRateBps;
|
|
833
|
+
}
|
|
834
|
+
if (lossRate < minLossRate) {
|
|
835
|
+
minLossRate = lossRate;
|
|
836
|
+
minLost = wLost;
|
|
837
|
+
minBytes = wSize;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (total <= 0)
|
|
842
|
+
return 0;
|
|
843
|
+
if (this.getMedianSendingRate() * constants_1.kLossBasedMedianSendingRateFactor <=
|
|
844
|
+
sendRateOfMaxLoss) {
|
|
845
|
+
return lost / total;
|
|
846
|
+
}
|
|
847
|
+
if (total === maxBytes + minBytes) {
|
|
848
|
+
return lost / total;
|
|
849
|
+
}
|
|
850
|
+
const filteredLost = lost - minLost - maxLost;
|
|
851
|
+
const filteredTotal = total - maxBytes - minBytes;
|
|
852
|
+
if (filteredTotal <= 0)
|
|
853
|
+
return 0;
|
|
854
|
+
return filteredLost / filteredTotal;
|
|
855
|
+
}
|
|
856
|
+
getMedianSendingRate() {
|
|
857
|
+
const rates = this.observations
|
|
858
|
+
.map((o) => o.sendingRateBps)
|
|
859
|
+
.filter((r) => Number.isFinite(r) && r > 0)
|
|
860
|
+
.sort((a, b) => a - b);
|
|
861
|
+
if (rates.length === 0)
|
|
862
|
+
return 0;
|
|
863
|
+
const mid = Math.floor(rates.length / 2);
|
|
864
|
+
if (rates.length % 2 === 0) {
|
|
865
|
+
return (rates[mid - 1] + rates[mid]) / 2;
|
|
866
|
+
}
|
|
867
|
+
return rates[mid];
|
|
868
|
+
}
|
|
869
|
+
calculateInstantUpperBound() {
|
|
870
|
+
let instant = this.maxBitrateBps;
|
|
871
|
+
if (this.averageReportedLossRatio > constants_1.kLossBasedInstantUpperBoundLossOffset) {
|
|
872
|
+
instant =
|
|
873
|
+
constants_1.kLossBasedInstantUpperBoundBwBalanceBps /
|
|
874
|
+
(this.averageReportedLossRatio - constants_1.kLossBasedInstantUpperBoundLossOffset);
|
|
875
|
+
}
|
|
876
|
+
this.cachedInstantUpperBoundBps = instant;
|
|
877
|
+
}
|
|
878
|
+
calculateInstantLowerBound() {
|
|
879
|
+
let lower = 0;
|
|
880
|
+
if (this.acknowledgedBps > 0 && constants_1.kLossBasedLowerBoundByAckedRateFactor > 0) {
|
|
881
|
+
lower = constants_1.kLossBasedLowerBoundByAckedRateFactor * this.acknowledgedBps;
|
|
882
|
+
}
|
|
883
|
+
lower = Math.max(lower, this.minBitrateBps);
|
|
884
|
+
this.cachedInstantLowerBoundBps = lower;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* pin `GetCandidateBandwidthUpperBound`.
|
|
888
|
+
* Delayed-increase window (when loss-limited) or configured max.
|
|
889
|
+
* Acked-rate ramp-up (1.5× / 1.2×) is **not** applied here.
|
|
890
|
+
*/
|
|
891
|
+
getCandidateBandwidthUpperBound() {
|
|
892
|
+
let upper = this.maxBitrateBps;
|
|
893
|
+
if (this.isInLossLimitedState() &&
|
|
894
|
+
Number.isFinite(this.bandwidthLimitInCurrentWindow)) {
|
|
895
|
+
upper = this.bandwidthLimitInCurrentWindow;
|
|
896
|
+
}
|
|
897
|
+
return upper;
|
|
898
|
+
}
|
|
899
|
+
getCandidates(inAlr = this.inAlr) {
|
|
900
|
+
const currentBw = this.currentBestEstimate.lossLimitedBandwidthBps;
|
|
901
|
+
const bandwidths = [];
|
|
902
|
+
for (const f of constants_1.kLossBasedCandidateFactors) {
|
|
903
|
+
bandwidths.push(currentBw * f);
|
|
904
|
+
}
|
|
905
|
+
if (this.acknowledgedBps > 0) {
|
|
906
|
+
const skipAckedInAlr = constants_1.kLossBasedNotUseAckedRateInAlr && inAlr;
|
|
907
|
+
const paddingWindowOpen = this.paddingDurationMs > 0 &&
|
|
908
|
+
this.lastPaddingMs + this.paddingDurationMs >=
|
|
909
|
+
this.lastSendTimeMostRecentObservation;
|
|
910
|
+
if (!skipAckedInAlr || paddingWindowOpen) {
|
|
911
|
+
bandwidths.push(this.acknowledgedBps * constants_1.kLossBasedBandwidthBackoffLowerBoundFactor);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (this.delayBasedBps > currentBw) {
|
|
915
|
+
bandwidths.push(this.delayBasedBps);
|
|
916
|
+
}
|
|
917
|
+
const candidateUpper = this.getCandidateBandwidthUpperBound();
|
|
918
|
+
return bandwidths.map((bw) => {
|
|
919
|
+
const candidate = {
|
|
920
|
+
inherentLoss: this.currentBestEstimate.inherentLoss,
|
|
921
|
+
// pin GetCandidates: no extra configured-max clamp before Newton.
|
|
922
|
+
lossLimitedBandwidthBps: Math.min(bw, Math.max(currentBw, candidateUpper)),
|
|
923
|
+
};
|
|
924
|
+
candidate.inherentLoss = this.getFeasibleInherentLoss(candidate);
|
|
925
|
+
return candidate;
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* libwebrtc loss probability:
|
|
930
|
+
* inherent + (1 - inherent) * max(0, sending - bw) / sending
|
|
931
|
+
*/
|
|
932
|
+
getLossProbability(inherentLoss, lossLimitedBw, sendingRate) {
|
|
933
|
+
const inherent = Math.min(Math.max(inherentLoss, 0), 1);
|
|
934
|
+
let p = inherent;
|
|
935
|
+
if (sendingRate > 0 && sendingRate > lossLimitedBw) {
|
|
936
|
+
p += (1 - inherent) * ((sendingRate - lossLimitedBw) / sendingRate);
|
|
937
|
+
}
|
|
938
|
+
return Math.min(Math.max(p, 1e-6), 1 - 1e-6);
|
|
939
|
+
}
|
|
940
|
+
getInherentLossUpperBound(bandwidthBps) {
|
|
941
|
+
if (bandwidthBps <= 0)
|
|
942
|
+
return 1;
|
|
943
|
+
const ub = constants_1.kLossBasedInherentLossUpperBoundOffset +
|
|
944
|
+
constants_1.kLossBasedInherentLossUpperBoundBwBalanceBps / bandwidthBps;
|
|
945
|
+
return Math.min(ub, 1);
|
|
946
|
+
}
|
|
947
|
+
getFeasibleInherentLoss(c) {
|
|
948
|
+
return Math.min(Math.max(c.inherentLoss, constants_1.kLossBasedInherentLossLowerBound), this.getInherentLossUpperBound(c.lossLimitedBandwidthBps));
|
|
949
|
+
}
|
|
950
|
+
toKiloBytes(bytes) {
|
|
951
|
+
return bytes / 1000;
|
|
952
|
+
}
|
|
953
|
+
getDerivatives(c) {
|
|
954
|
+
let first = 0;
|
|
955
|
+
let second = 0;
|
|
956
|
+
for (const o of this.observations) {
|
|
957
|
+
const lp = this.getLossProbability(c.inherentLoss, c.lossLimitedBandwidthBps, o.sendingRateBps);
|
|
958
|
+
const w = this.temporalWeightFor(o);
|
|
959
|
+
if (constants_1.kLossBasedUseByteLossRate) {
|
|
960
|
+
const lostKb = this.toKiloBytes(o.lostSize);
|
|
961
|
+
const receivedKb = this.toKiloBytes(o.size - o.lostSize);
|
|
962
|
+
first += w * (lostKb / lp - receivedKb / (1 - lp));
|
|
963
|
+
second -= w * (lostKb / lp ** 2 + receivedKb / (1 - lp) ** 2);
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
first += w * (o.numLostPackets / lp - o.numReceivedPackets / (1 - lp));
|
|
967
|
+
second -=
|
|
968
|
+
w *
|
|
969
|
+
(o.numLostPackets / lp ** 2 + o.numReceivedPackets / (1 - lp) ** 2);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (second >= 0)
|
|
973
|
+
second = -1e-6;
|
|
974
|
+
return { first, second };
|
|
975
|
+
}
|
|
976
|
+
newtonsMethodUpdate(c) {
|
|
977
|
+
if (this.observations.length === 0)
|
|
978
|
+
return;
|
|
979
|
+
for (let i = 0; i < constants_1.kLossBasedNewtonIterations; i++) {
|
|
980
|
+
const d = this.getDerivatives(c);
|
|
981
|
+
c.inherentLoss -= (constants_1.kLossBasedNewtonStepSize * d.first) / d.second;
|
|
982
|
+
c.inherentLoss = this.getFeasibleInherentLoss(c);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Adjust bias factor by current average loss
|
|
987
|
+
* (libwebrtc `AdjustBiasFactor`).
|
|
988
|
+
*/
|
|
989
|
+
adjustBiasFactor(lossRate, biasFactor) {
|
|
990
|
+
return ((biasFactor *
|
|
991
|
+
(constants_1.kLossBasedLossThresholdOfHighBandwidthPreference - lossRate)) /
|
|
992
|
+
(constants_1.kLossBasedBandwidthPreferenceSmoothingFactor +
|
|
993
|
+
Math.abs(constants_1.kLossBasedLossThresholdOfHighBandwidthPreference - lossRate)));
|
|
994
|
+
}
|
|
995
|
+
getHighBandwidthBias(bandwidthBps) {
|
|
996
|
+
if (!(bandwidthBps > 0))
|
|
997
|
+
return 0;
|
|
998
|
+
const kbps = bandwidthBps / 1000;
|
|
999
|
+
const loss = this.averageReportedLossRatio;
|
|
1000
|
+
return (this.adjustBiasFactor(loss, constants_1.kLossBasedHigherBwBiasFactor) * kbps +
|
|
1001
|
+
this.adjustBiasFactor(loss, constants_1.kLossBasedHigherLogBwBiasFactor) *
|
|
1002
|
+
Math.log(1 + kbps));
|
|
1003
|
+
}
|
|
1004
|
+
getObjective(c) {
|
|
1005
|
+
let objective = 0;
|
|
1006
|
+
const bias = this.getHighBandwidthBias(c.lossLimitedBandwidthBps);
|
|
1007
|
+
for (const o of this.observations) {
|
|
1008
|
+
const lp = this.getLossProbability(c.inherentLoss, c.lossLimitedBandwidthBps, o.sendingRateBps);
|
|
1009
|
+
const w = this.temporalWeightFor(o);
|
|
1010
|
+
if (constants_1.kLossBasedUseByteLossRate) {
|
|
1011
|
+
const lostKb = this.toKiloBytes(o.lostSize);
|
|
1012
|
+
const receivedKb = this.toKiloBytes(o.size - o.lostSize);
|
|
1013
|
+
objective +=
|
|
1014
|
+
w * (lostKb * Math.log(lp) + receivedKb * Math.log(1 - lp));
|
|
1015
|
+
objective += w * bias * this.toKiloBytes(o.size);
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
objective +=
|
|
1019
|
+
w *
|
|
1020
|
+
(o.numLostPackets * Math.log(lp) +
|
|
1021
|
+
o.numReceivedPackets * Math.log(1 - lp));
|
|
1022
|
+
objective += w * bias * o.numPackets;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return objective;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
exports.LossBasedBwe = LossBasedBwe;
|
|
1029
|
+
/**
|
|
1030
|
+
* Hard cap on partial observation maps. If send-timeline duration never
|
|
1031
|
+
* reaches the 250ms lower bound (e.g. stuck clocks), maps stay bounded.
|
|
1032
|
+
*/
|
|
1033
|
+
Object.defineProperty(LossBasedBwe, "kMaxPartialPackets", {
|
|
1034
|
+
enumerable: true,
|
|
1035
|
+
configurable: true,
|
|
1036
|
+
writable: true,
|
|
1037
|
+
value: 4096
|
|
1038
|
+
});
|
|
1039
|
+
function clamp(bps) {
|
|
1040
|
+
return Math.min(Math.max(Math.round(bps), constants_1.kMinBitrateBps), constants_1.kMaxBitrateBps);
|
|
1041
|
+
}
|
|
1042
|
+
//# sourceMappingURL=lossBasedBwe.js.map
|