werift 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -8
- package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
- package/lib/common/src/binary.d.ts +1 -3
- package/lib/common/src/binary.js +8 -6
- package/lib/common/src/binary.js.map +1 -1
- package/lib/common/src/binaryData.js +2 -1
- package/lib/common/src/binaryData.js.map +1 -1
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/log.js +5 -7
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +12 -5
- package/lib/common/src/transport.js +13 -7
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/cipher.d.ts +1 -1
- package/lib/dtls/src/context/cipher.js +6 -3
- package/lib/dtls/src/context/cipher.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +11 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +40 -3
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight1.js +2 -1
- package/lib/dtls/src/flight/client/flight1.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +8 -3
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +6 -1
- package/lib/dtls/src/flight/flight.js +18 -5
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight4.js +4 -2
- package/lib/dtls/src/flight/server/flight4.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +6 -2
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/handshake/const.d.ts +17 -13
- package/lib/dtls/src/handshake/const.js +16 -14
- package/lib/dtls/src/handshake/const.js.map +1 -1
- package/lib/dtls/src/handshake/message/alert.js +4 -2
- package/lib/dtls/src/handshake/message/alert.js.map +1 -1
- package/lib/dtls/src/handshake/message/certificate.js +2 -1
- package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -1
- package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/certificateVerify.js +4 -2
- package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/hello.js +14 -7
- package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js +2 -1
- package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/message/finished.js +2 -1
- package/lib/dtls/src/handshake/message/finished.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/certificateRequest.js +6 -3
- package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/hello.js +12 -6
- package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +4 -2
- package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
- package/lib/dtls/src/handshake/message/server/keyExchange.js +16 -8
- package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
- package/lib/dtls/src/handshake/random.d.ts +2 -2
- package/lib/dtls/src/handshake/random.js +5 -2
- package/lib/dtls/src/handshake/random.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +52 -33
- package/lib/dtls/src/record/const.js +51 -36
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/message/fragment.js +12 -6
- package/lib/dtls/src/record/message/fragment.js.map +1 -1
- package/lib/dtls/src/record/message/header.js +10 -5
- package/lib/dtls/src/record/message/header.js.map +1 -1
- package/lib/dtls/src/record/message/plaintext.js +4 -2
- package/lib/dtls/src/record/message/plaintext.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +326 -8
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidate.d.ts +1 -1
- package/lib/ice/src/candidate.js +24 -12
- package/lib/ice/src/candidate.js.map +1 -1
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/dns/lookup.d.ts +10 -1
- package/lib/ice/src/dns/lookup.js +42 -7
- package/lib/ice/src/dns/lookup.js.map +1 -1
- package/lib/ice/src/exceptions.d.ts +21 -5
- package/lib/ice/src/exceptions.js +58 -13
- package/lib/ice/src/exceptions.js.map +1 -1
- package/lib/ice/src/ice.d.ts +254 -58
- package/lib/ice/src/ice.js +979 -945
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +328 -14
- package/lib/ice/src/iceBase.js +254 -38
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +30 -1
- package/lib/ice/src/stun/transaction.js +90 -19
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/credential.d.ts +49 -0
- package/lib/ice/src/turn/credential.js +78 -0
- package/lib/ice/src/turn/credential.js.map +1 -0
- package/lib/ice/src/turn/protocol.d.ts +31 -10
- package/lib/ice/src/turn/protocol.js +127 -51
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.d.ts +2 -0
- package/lib/ice-server/src/stun/attributes.js +11 -1
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +44 -17
- package/lib/ice-server/src/stun/const.js +31 -19
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +29 -4
- package/lib/ice-server/src/stun/message.js +115 -24
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +35121 -22337
- package/lib/nonstandard/index.mjs +3169 -1399
- package/lib/polyfill/dom.mjs +24650 -12365
- package/lib/polyfill/index.mjs +24650 -12365
- package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
- package/lib/rtp/src/codec/assertPayload.js +12 -0
- package/lib/rtp/src/codec/assertPayload.js.map +1 -0
- package/lib/rtp/src/codec/av1.js +2 -0
- package/lib/rtp/src/codec/av1.js.map +1 -1
- package/lib/rtp/src/codec/h264.js +35 -43
- package/lib/rtp/src/codec/h264.js.map +1 -1
- package/lib/rtp/src/codec/vp8.js +11 -5
- package/lib/rtp/src/codec/vp8.js.map +1 -1
- package/lib/rtp/src/codec/vp9.js +12 -0
- package/lib/rtp/src/codec/vp9.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/container.js +2 -1
- package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
- package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
- package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
- package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
- package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js +1 -0
- package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
- package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
- package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
- package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js +6 -3
- package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
- package/lib/rtp/src/extra/processor/depacketizer.d.ts +5 -0
- package/lib/rtp/src/extra/processor/depacketizer.js +28 -2
- package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
- package/lib/rtp/src/extra/processor/dtx.js +4 -2
- package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
- package/lib/rtp/src/extra/processor/index.d.ts +2 -0
- package/lib/rtp/src/extra/processor/index.js +2 -0
- package/lib/rtp/src/extra/processor/index.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
- package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
- package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
- package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
- package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
- package/lib/rtp/src/extra/processor/lipsync.js +202 -51
- package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
- package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
- package/lib/rtp/src/extra/processor/mp4.js +6 -3
- package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
- package/lib/rtp/src/extra/processor/mute.js +4 -2
- package/lib/rtp/src/extra/processor/mute.js.map +1 -1
- package/lib/rtp/src/extra/processor/nack.js +4 -2
- package/lib/rtp/src/extra/processor/nack.js.map +1 -1
- package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
- package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
- package/lib/rtp/src/extra/processor/ogg.js +221 -0
- package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
- package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
- package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
- package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
- package/lib/rtp/src/extra/processor/rtpCallback.js +2 -1
- package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
- package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
- package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
- package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
- package/lib/rtp/src/extra/processor/webm.js +14 -7
- package/lib/rtp/src/extra/processor/webm.js.map +1 -1
- package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
- package/lib/rtp/src/index.d.ts +8 -0
- package/lib/rtp/src/index.js +8 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +4 -0
- package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
- package/lib/rtp/src/rtcp/rtcp.js +8 -4
- package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
- package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
- package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
- package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
- package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
- package/lib/rtp/src/rtcp/sr.js +1 -0
- package/lib/rtp/src/rtcp/sr.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +49 -0
- package/lib/rtp/src/rtp/continuity.js +120 -0
- package/lib/rtp/src/rtp/continuity.js.map +1 -0
- package/lib/rtp/src/rtp/headerExtension.js +41 -21
- package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
- package/lib/rtp/src/rtp/padding.d.ts +17 -0
- package/lib/rtp/src/rtp/padding.js +37 -0
- package/lib/rtp/src/rtp/padding.js.map +1 -0
- package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
- package/lib/rtp/src/rtp/red/encoder.js +14 -1
- package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
- package/lib/rtp/src/rtp/red/packet.js +24 -8
- package/lib/rtp/src/rtp/red/packet.js.map +1 -1
- package/lib/rtp/src/rtp/rtp.d.ts +24 -1
- package/lib/rtp/src/rtp/rtp.js +70 -29
- package/lib/rtp/src/rtp/rtp.js.map +1 -1
- package/lib/rtp/src/rtp/rtx.js +3 -0
- package/lib/rtp/src/rtp/rtx.js.map +1 -1
- package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
- package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/rtp/src/srtp/cipher/ctr.js +4 -2
- package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
- package/lib/rtp/src/srtp/cipher/index.js +8 -4
- package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
- package/lib/rtp/src/srtp/context/context.js +6 -3
- package/lib/rtp/src/srtp/context/context.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtcp.js +33 -0
- package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
- package/lib/rtp/src/srtp/context/srtp.js +34 -10
- package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
- package/lib/rtp/src/srtp/error.d.ts +8 -0
- package/lib/rtp/src/srtp/error.js +13 -1
- package/lib/rtp/src/srtp/error.js.map +1 -1
- package/lib/rtp/src/srtp/packet.js +4 -1
- package/lib/rtp/src/srtp/packet.js.map +1 -1
- package/lib/rtp/src/srtp/replay.d.ts +24 -0
- package/lib/rtp/src/srtp/replay.js +75 -0
- package/lib/rtp/src/srtp/replay.js.map +1 -0
- package/lib/rtp/src/srtp/session.js +2 -1
- package/lib/rtp/src/srtp/session.js.map +1 -1
- package/lib/rtp/src/srtp/srtcp.js +2 -1
- package/lib/rtp/src/srtp/srtcp.js.map +1 -1
- package/lib/rtp/src/srtp/srtp.js +2 -1
- package/lib/rtp/src/srtp/srtp.js.map +1 -1
- package/lib/rtp/src/util.js +2 -1
- package/lib/rtp/src/util.js.map +1 -1
- package/lib/sctp/src/chunk.d.ts +5 -0
- package/lib/sctp/src/chunk.js +31 -8
- package/lib/sctp/src/chunk.js.map +1 -1
- package/lib/sctp/src/const.d.ts +25 -17
- package/lib/sctp/src/const.js +23 -19
- package/lib/sctp/src/const.js.map +1 -1
- package/lib/sctp/src/param.d.ts +6 -2
- package/lib/sctp/src/param.js +22 -8
- package/lib/sctp/src/param.js.map +1 -1
- package/lib/sctp/src/sctp.d.ts +85 -0
- package/lib/sctp/src/sctp.js +707 -126
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/sctp/src/transport.js +4 -2
- package/lib/sctp/src/transport.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +385 -28
- package/lib/webrtc/src/api/peerConfig.js +121 -14
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/dataChannel.d.ts +10 -0
- package/lib/webrtc/src/dataChannel.js +24 -4
- package/lib/webrtc/src/dataChannel.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/index.d.ts +10 -0
- package/lib/webrtc/src/media/index.js +70 -0
- package/lib/webrtc/src/media/index.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +246 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
- package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
- package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +241 -40
- package/lib/webrtc/src/media/router.js +676 -205
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +252 -2
- package/lib/webrtc/src/media/rtpReceiver.js +833 -44
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +191 -70
- package/lib/webrtc/src/media/rtpSender.js +631 -448
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +19 -3
- package/lib/webrtc/src/media/rtpTransceiver.js +74 -9
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
- package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
- package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
- package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
- package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
- package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
- package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
- package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
- package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
- package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
- package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
- package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
- package/lib/webrtc/src/media/sender/padding.js +134 -0
- package/lib/webrtc/src/media/sender/padding.js.map +1 -0
- package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
- package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
- package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
- package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
- package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
- package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
- package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
- package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -33
- package/lib/webrtc/src/media/sender/senderBWE.js +5 -154
- package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +101 -0
- package/lib/webrtc/src/media/sender/senderStats.js +317 -0
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
- package/lib/webrtc/src/media/track.d.ts +29 -2
- package/lib/webrtc/src/media/track.js +32 -5
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/bundleTopology.d.ts +1 -5
- package/lib/webrtc/src/negotiation/bundleTopology.js +15 -11
- package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -1
- package/lib/webrtc/src/negotiation/descriptionValidation.js +12 -6
- package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js +2 -1
- package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteCandidates.js +10 -5
- package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +24 -7
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +67 -27
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +40 -8
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +43 -5
- package/lib/webrtc/src/negotiationTransaction.js +129 -13
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
- package/lib/webrtc/src/nonstandard/navigator.js +4 -3
- package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
- package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
- package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +9 -7
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +8 -1
- package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
- package/lib/webrtc/src/nonstandard/userMedia.js +2 -1
- package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +108 -6
- package/lib/webrtc/src/peerConnection.js +357 -36
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
- package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
- package/lib/webrtc/src/sctpManager.d.ts +46 -14
- package/lib/webrtc/src/sctpManager.js +92 -25
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +151 -20
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +89 -4
- package/lib/webrtc/src/secureTransportManager.js +184 -26
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +239 -41
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +147 -1
- package/lib/webrtc/src/transport/dtls.js +446 -50
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +71 -90
- package/lib/webrtc/src/transport/ice.js +250 -42
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +25 -0
- package/lib/webrtc/src/transport/sctp.js +153 -22
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +69 -3
- package/lib/webrtc/src/utils.js +105 -16
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +9 -6
|
@@ -0,0 +1,1073 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProbeController = void 0;
|
|
4
|
+
const bandwidthLimitedCause_1 = require("./bandwidthLimitedCause");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Probe controller (libwebrtc ProbeController + BitrateProber FIFO +
|
|
8
|
+
* ProbeBitrateEstimator).
|
|
9
|
+
*
|
|
10
|
+
* Pacing vs result-wait are **separated** (libwebrtc BitrateProber):
|
|
11
|
+
* - `pacing`: cluster currently being sent (at most one)
|
|
12
|
+
* - `awaitingResults`: send-fill done; ProbeController still waiting for a
|
|
13
|
+
* result to decide further probing (sender-clock 1s lifetime)
|
|
14
|
+
* - `estimatorHistory`: ProbeBitrateEstimator clusters kept after controller
|
|
15
|
+
* timeout so late TWCC can still produce estimates (receive-timeline 1s).
|
|
16
|
+
* Also pruned by **sender-side** age ({@link kSendTimeHistoryWindowMs}) so clusters
|
|
17
|
+
* that never receive ACK cannot grow unbounded.
|
|
18
|
+
* - On **send** fill (minBytes AND minPackets), front is moved to awaiting and
|
|
19
|
+
* the next queued cluster becomes pacing — **without waiting for ACK**
|
|
20
|
+
* - ACK / 80% estimate must **never** clear pacing (send-fill is independent)
|
|
21
|
+
* - Controller timeout / cooldown / startMs use **sender clock**; estimator
|
|
22
|
+
* history prune uses **receive timeline** (`receivedAtMs`) plus sender age
|
|
23
|
+
* - Zero-packet pacing timeouts are discarded (nothing measurable for TWCC)
|
|
24
|
+
* - `setBitrates` / activate returns only **activated** configs (for pacing).
|
|
25
|
+
* In `complete`, a higher max than the previous max (and than the estimate)
|
|
26
|
+
* starts one probe at the new max (`probe_further=false`).
|
|
27
|
+
* - Further via {@link setEstimatedBitrate} only while `waiting_for_result`
|
|
28
|
+
* (pin SetEstimatedBitrate); session `complete` sets
|
|
29
|
+
* `minBitrateToProbeFurther = +∞` (UpdateState(kProbingComplete))
|
|
30
|
+
* - Recovery after complete uses {@link requestProbe} (not further threshold)
|
|
31
|
+
*/
|
|
32
|
+
class ProbeController {
|
|
33
|
+
/**
|
|
34
|
+
* pin `ProbeController::Reset(at_time)`.
|
|
35
|
+
*
|
|
36
|
+
* Keeps configuration: `enable_periodic_alr_probing_`, `network_available_`,
|
|
37
|
+
* `alr_start_time_`, NSE probe interval. Sets drop / recovery cooldown
|
|
38
|
+
* clocks to `atTimeMs` so RequestProbe cannot fire until
|
|
39
|
+
* {@link kMinTimeBetweenAlrProbesMs} after reset.
|
|
40
|
+
*/
|
|
41
|
+
reset(atTimeMs = 0) {
|
|
42
|
+
const now = Number.isFinite(atTimeMs) ? atTimeMs : 0;
|
|
43
|
+
this.state = "init";
|
|
44
|
+
// pin does not reset next_probe_cluster_id_.
|
|
45
|
+
this.pacing = undefined;
|
|
46
|
+
this.awaitingResults.clear();
|
|
47
|
+
this.estimatorHistory.clear();
|
|
48
|
+
this.queue = [];
|
|
49
|
+
this.estimatedBps = 0;
|
|
50
|
+
this.pendingEstimateBps = 0;
|
|
51
|
+
this.lastProbeTargetBps = 0;
|
|
52
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
53
|
+
this.lastProbeEndMs = Number.NEGATIVE_INFINITY;
|
|
54
|
+
this.minBitrateBps = constants_1.kMinBitrateBps;
|
|
55
|
+
this.startBitrateBps = 0;
|
|
56
|
+
this.maxBitrateBps = constants_1.kDefaultMaxProbingBitrateBps;
|
|
57
|
+
this.seqToCluster.clear();
|
|
58
|
+
this.seqToSendInfo.clear();
|
|
59
|
+
// Keep periodicAlrProbing, networkAvailable, alrStartMs, NSE interval.
|
|
60
|
+
this.alrEndMs = undefined;
|
|
61
|
+
this.lastProbeInitiatedMs = 0;
|
|
62
|
+
this.lastCause = "delay_based_limited";
|
|
63
|
+
this.networkStateUpperBps = 0;
|
|
64
|
+
this.bitrateBeforeLastLargeDrop = 0;
|
|
65
|
+
this.timeOfLastLargeDropMs = now;
|
|
66
|
+
this.lastBweDropProbingMs = now;
|
|
67
|
+
this.nextProbeTimeMs = Number.NEGATIVE_INFINITY;
|
|
68
|
+
}
|
|
69
|
+
constructor() {
|
|
70
|
+
Object.defineProperty(this, "state", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: "init"
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(this, "nextClusterId", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
value: 1
|
|
81
|
+
});
|
|
82
|
+
/** Cluster currently being paced/sent (FIFO front). */
|
|
83
|
+
Object.defineProperty(this, "pacing", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true,
|
|
87
|
+
value: void 0
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Send-complete clusters while ProbeController still waits for a result
|
|
91
|
+
* (further-probe decision). Cleared on sender-clock 1s timeout without
|
|
92
|
+
* dropping ProbeBitrateEstimator seq maps.
|
|
93
|
+
*/
|
|
94
|
+
Object.defineProperty(this, "awaitingResults", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
value: new Map()
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Clusters retained for late TWCC measurement after controller wait ends
|
|
102
|
+
* (libwebrtc ProbeBitrateEstimator cluster history).
|
|
103
|
+
*/
|
|
104
|
+
Object.defineProperty(this, "estimatorHistory", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: new Map()
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "queue", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: []
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "estimatedBps", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: 0
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(this, "pendingEstimateBps", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
configurable: true,
|
|
125
|
+
writable: true,
|
|
126
|
+
value: 0
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(this, "lastProbeTargetBps", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: 0
|
|
133
|
+
});
|
|
134
|
+
/**
|
|
135
|
+
* Further-probe threshold from the **last planned** cluster target
|
|
136
|
+
* (libwebrtc min_bitrate_to_probe_further = last_pending_target × 0.7),
|
|
137
|
+
* not from the last successful result.
|
|
138
|
+
*/
|
|
139
|
+
Object.defineProperty(this, "minBitrateToProbeFurther", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
writable: true,
|
|
143
|
+
value: 0
|
|
144
|
+
});
|
|
145
|
+
/** Sender-clock time when last probe session ended. */
|
|
146
|
+
Object.defineProperty(this, "lastProbeEndMs", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true,
|
|
149
|
+
writable: true,
|
|
150
|
+
value: Number.NEGATIVE_INFINITY
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(this, "minBitrateBps", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: constants_1.kMinBitrateBps
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(this, "startBitrateBps", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: constants_1.kDefaultStartBitrateBps
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(this, "maxBitrateBps", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: constants_1.kMaxBitrateBps
|
|
169
|
+
});
|
|
170
|
+
/** pin `network_available_` — starts false until OnNetworkAvailability. */
|
|
171
|
+
Object.defineProperty(this, "networkAvailable", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
configurable: true,
|
|
174
|
+
writable: true,
|
|
175
|
+
value: false
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* Transport-wide seq → cluster id for probation packets.
|
|
179
|
+
* Keys are the already-resolved extended seqs {@link GccBandwidthEstimator}
|
|
180
|
+
* passes (opaque; do not unwrap again).
|
|
181
|
+
*/
|
|
182
|
+
Object.defineProperty(this, "seqToCluster", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: new Map()
|
|
187
|
+
});
|
|
188
|
+
/** Same extended-seq keys as {@link seqToCluster} → send-time / size. */
|
|
189
|
+
Object.defineProperty(this, "seqToSendInfo", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
configurable: true,
|
|
192
|
+
writable: true,
|
|
193
|
+
value: new Map()
|
|
194
|
+
});
|
|
195
|
+
/** pin `enable_periodic_alr_probing_`. */
|
|
196
|
+
Object.defineProperty(this, "periodicAlrProbing", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
configurable: true,
|
|
199
|
+
writable: true,
|
|
200
|
+
value: false
|
|
201
|
+
});
|
|
202
|
+
/** pin `alr_start_time_`. */
|
|
203
|
+
Object.defineProperty(this, "alrStartMs", {
|
|
204
|
+
enumerable: true,
|
|
205
|
+
configurable: true,
|
|
206
|
+
writable: true,
|
|
207
|
+
value: void 0
|
|
208
|
+
});
|
|
209
|
+
/** pin `alr_end_time_`. */
|
|
210
|
+
Object.defineProperty(this, "alrEndMs", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
configurable: true,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: void 0
|
|
215
|
+
});
|
|
216
|
+
/** pin `time_last_probing_initiated_`. */
|
|
217
|
+
Object.defineProperty(this, "lastProbeInitiatedMs", {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
configurable: true,
|
|
220
|
+
writable: true,
|
|
221
|
+
value: Number.NEGATIVE_INFINITY
|
|
222
|
+
});
|
|
223
|
+
/**
|
|
224
|
+
* pin `bandwidth_limited_cause_` — gates InitiateProbing from Process()
|
|
225
|
+
* ALR / network-state probes.
|
|
226
|
+
*/
|
|
227
|
+
Object.defineProperty(this, "lastCause", {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
configurable: true,
|
|
230
|
+
writable: true,
|
|
231
|
+
value: "delay_based_limited"
|
|
232
|
+
});
|
|
233
|
+
/** pin `network_estimate_.link_capacity_upper` (bps); 0 = unset. */
|
|
234
|
+
Object.defineProperty(this, "networkStateUpperBps", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
configurable: true,
|
|
237
|
+
writable: true,
|
|
238
|
+
value: 0
|
|
239
|
+
});
|
|
240
|
+
/**
|
|
241
|
+
* pin `network_state_estimate_probing_interval` (ms). Default +∞.
|
|
242
|
+
*/
|
|
243
|
+
Object.defineProperty(this, "networkStateProbeIntervalMs", {
|
|
244
|
+
enumerable: true,
|
|
245
|
+
configurable: true,
|
|
246
|
+
writable: true,
|
|
247
|
+
value: constants_1.kNetworkStateEstimateProbingIntervalMs
|
|
248
|
+
});
|
|
249
|
+
/** pin `bitrate_before_last_large_drop_`. */
|
|
250
|
+
Object.defineProperty(this, "bitrateBeforeLastLargeDrop", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
configurable: true,
|
|
253
|
+
writable: true,
|
|
254
|
+
value: 0
|
|
255
|
+
});
|
|
256
|
+
/** pin `time_of_last_large_drop_`. */
|
|
257
|
+
Object.defineProperty(this, "timeOfLastLargeDropMs", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
configurable: true,
|
|
260
|
+
writable: true,
|
|
261
|
+
value: 0
|
|
262
|
+
});
|
|
263
|
+
/** pin `last_bwe_drop_probing_time_`. */
|
|
264
|
+
Object.defineProperty(this, "lastBweDropProbingMs", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
configurable: true,
|
|
267
|
+
writable: true,
|
|
268
|
+
value: 0
|
|
269
|
+
});
|
|
270
|
+
/**
|
|
271
|
+
* pin `next_probe_time_`. MinusInfinity until the first packet of the
|
|
272
|
+
* active cluster; then `started_at + sent_bytes / send_bitrate`.
|
|
273
|
+
*/
|
|
274
|
+
Object.defineProperty(this, "nextProbeTimeMs", {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
configurable: true,
|
|
277
|
+
writable: true,
|
|
278
|
+
value: Number.NEGATIVE_INFINITY
|
|
279
|
+
});
|
|
280
|
+
this.reset(0);
|
|
281
|
+
}
|
|
282
|
+
get probeState() {
|
|
283
|
+
return this.state;
|
|
284
|
+
}
|
|
285
|
+
get estimatedBitrateBps() {
|
|
286
|
+
return this.estimatedBps;
|
|
287
|
+
}
|
|
288
|
+
/** Pacing target = current pacing cluster only (not queued, not awaiting). */
|
|
289
|
+
get currentProbeTargetBps() {
|
|
290
|
+
return this.pacing?.config.targetBps ?? 0;
|
|
291
|
+
}
|
|
292
|
+
get suggestedProbeBitrateBps() {
|
|
293
|
+
return this.currentProbeTargetBps;
|
|
294
|
+
}
|
|
295
|
+
get activeClusterCount() {
|
|
296
|
+
return this.pacing ? 1 : 0;
|
|
297
|
+
}
|
|
298
|
+
get queuedClusterCount() {
|
|
299
|
+
return this.queue.length;
|
|
300
|
+
}
|
|
301
|
+
get awaitingResultCount() {
|
|
302
|
+
return this.awaitingResults.size;
|
|
303
|
+
}
|
|
304
|
+
/** Clusters kept only for late TWCC measurement (tests / diagnostics). */
|
|
305
|
+
get estimatorHistoryCount() {
|
|
306
|
+
return this.estimatorHistory.size;
|
|
307
|
+
}
|
|
308
|
+
/** Exposed for tests / diagnostics (last planned further-probe threshold). */
|
|
309
|
+
get furtherProbeThresholdBps() {
|
|
310
|
+
return this.minBitrateToProbeFurther;
|
|
311
|
+
}
|
|
312
|
+
takePendingEstimateBps() {
|
|
313
|
+
const v = this.pendingEstimateBps;
|
|
314
|
+
this.pendingEstimateBps = 0;
|
|
315
|
+
return v;
|
|
316
|
+
}
|
|
317
|
+
shouldTagProbePacket() {
|
|
318
|
+
return this.pacing !== undefined && !this.sendFillComplete(this.pacing);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* pin `BitrateProber::CurrentCluster(now)` — take the active cluster id
|
|
322
|
+
* **before** send. If `now - next_probe_time > max_probe_delay` (10ms),
|
|
323
|
+
* the active cluster is discarded (not a 5s scheduling timeout).
|
|
324
|
+
*/
|
|
325
|
+
reserveOutgoingProbe(nowMs) {
|
|
326
|
+
this.maybeDiscardLatePacing(nowMs);
|
|
327
|
+
if (!this.pacing || this.sendFillComplete(this.pacing)) {
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
clusterId: this.pacing.config.id,
|
|
332
|
+
nextSendTimeMs: this.nextProbeTimeMs,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* pin `NextProbeTime`. PlusInfinity when inactive.
|
|
337
|
+
*/
|
|
338
|
+
nextProbeSendTimeMs() {
|
|
339
|
+
if (!this.pacing)
|
|
340
|
+
return Number.POSITIVE_INFINITY;
|
|
341
|
+
return this.nextProbeTimeMs;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* pin `RecommendedMinProbeSize` = send_rate × min_probe_delta.
|
|
345
|
+
*/
|
|
346
|
+
recommendedMinProbeSizeBytes() {
|
|
347
|
+
if (!this.pacing)
|
|
348
|
+
return 0;
|
|
349
|
+
const rate = this.pacing.config.targetBps;
|
|
350
|
+
const deltaMs = this.pacing.config.minProbeDeltaMs;
|
|
351
|
+
if (!(rate > 0) || !(deltaMs > 0))
|
|
352
|
+
return 0;
|
|
353
|
+
return Math.ceil((rate / 8) * (deltaMs / 1000));
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* pin CurrentCluster late-discard: next_probe_time finite and
|
|
357
|
+
* now - next > max_probe_delay → pop active cluster.
|
|
358
|
+
*/
|
|
359
|
+
maybeDiscardLatePacing(nowMs) {
|
|
360
|
+
if (!this.pacing)
|
|
361
|
+
return;
|
|
362
|
+
if (!Number.isFinite(this.nextProbeTimeMs))
|
|
363
|
+
return;
|
|
364
|
+
if (nowMs - this.nextProbeTimeMs <= constants_1.kMaxProbeDelayMs)
|
|
365
|
+
return;
|
|
366
|
+
const dropped = this.pacing;
|
|
367
|
+
this.pacing = undefined;
|
|
368
|
+
this.nextProbeTimeMs = Number.NEGATIVE_INFINITY;
|
|
369
|
+
if (dropped.sentPackets > 0) {
|
|
370
|
+
this.moveToEstimatorHistory(dropped);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.dropClusterSeqs(dropped.config.id);
|
|
374
|
+
}
|
|
375
|
+
this.maybeActivateQueued(nowMs);
|
|
376
|
+
this.maybeMarkComplete(nowMs);
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* pin `ProbeController::OnNetworkAvailability`.
|
|
380
|
+
* Initial exponential probing starts only after the network is available
|
|
381
|
+
* **and** start bitrate is set (SetBitrates or this call).
|
|
382
|
+
*/
|
|
383
|
+
onNetworkAvailability(available, nowMs) {
|
|
384
|
+
this.networkAvailable = available;
|
|
385
|
+
if (!available && this.state === "waiting_for_result") {
|
|
386
|
+
this.state = "complete";
|
|
387
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
388
|
+
}
|
|
389
|
+
if (available && this.state === "init" && this.startBitrateBps > 0) {
|
|
390
|
+
return this.initiateExponentialProbing(nowMs);
|
|
391
|
+
}
|
|
392
|
+
return [];
|
|
393
|
+
}
|
|
394
|
+
/** pin `network_available_` (tests / diagnostics). */
|
|
395
|
+
get isNetworkAvailable() {
|
|
396
|
+
return this.networkAvailable;
|
|
397
|
+
}
|
|
398
|
+
sendFillComplete(c) {
|
|
399
|
+
return (c.sentPackets >= c.config.minPackets && c.sentBytes >= c.config.minBytes);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Bytes still needed for the **pacing** cluster (padding injection).
|
|
403
|
+
*/
|
|
404
|
+
remainingProbeBytes(packetBytes = 200) {
|
|
405
|
+
if (!this.pacing)
|
|
406
|
+
return 0;
|
|
407
|
+
const c = this.pacing;
|
|
408
|
+
if (this.sendFillComplete(c))
|
|
409
|
+
return 0;
|
|
410
|
+
const needBytes = Math.max(0, c.config.minBytes - c.sentBytes);
|
|
411
|
+
const needPkts = Math.max(0, c.config.minPackets - c.sentPackets);
|
|
412
|
+
const needPktBytes = needPkts * Math.max(1, packetBytes);
|
|
413
|
+
return Math.max(needBytes, needPktBytes);
|
|
414
|
+
}
|
|
415
|
+
setBitrates(minBps, startBps, maxBps, nowMs) {
|
|
416
|
+
this.minBitrateBps = Math.max(minBps, constants_1.kMinBitrateBps);
|
|
417
|
+
// pin: start > 0 overwrites start_bitrate_ and estimated_bitrate_.
|
|
418
|
+
if (startBps > 0) {
|
|
419
|
+
this.startBitrateBps = startBps;
|
|
420
|
+
this.estimatedBps = startBps;
|
|
421
|
+
}
|
|
422
|
+
else if (this.startBitrateBps <= 0) {
|
|
423
|
+
this.startBitrateBps = this.minBitrateBps;
|
|
424
|
+
}
|
|
425
|
+
// pin: non-finite max → kDefaultMaxProbingBitrate (5 Mbps).
|
|
426
|
+
const oldMax = this.maxBitrateBps;
|
|
427
|
+
this.maxBitrateBps =
|
|
428
|
+
Number.isFinite(maxBps) && maxBps !== Number.POSITIVE_INFINITY
|
|
429
|
+
? maxBps
|
|
430
|
+
: constants_1.kDefaultMaxProbingBitrateBps;
|
|
431
|
+
if (this.state === "init" && this.networkAvailable) {
|
|
432
|
+
return this.initiateExponentialProbing(nowMs);
|
|
433
|
+
}
|
|
434
|
+
// network unavailable: store bitrates only (pin SetBitrates kInit).
|
|
435
|
+
if (this.state === "waiting_for_result") {
|
|
436
|
+
return [];
|
|
437
|
+
}
|
|
438
|
+
// pin kProbingComplete: new max higher than old max and estimate.
|
|
439
|
+
if (this.estimatedBps > 0 &&
|
|
440
|
+
oldMax < this.maxBitrateBps &&
|
|
441
|
+
this.estimatedBps < this.maxBitrateBps) {
|
|
442
|
+
return this.enqueueClusters(nowMs, [this.maxBitrateBps], {
|
|
443
|
+
stopFurtherAfter: true,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
return [];
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* pin `ProbeController::RequestProbe`.
|
|
450
|
+
*
|
|
451
|
+
* Only while complete + (in ALR or ALR ended < 3s) + large drop within 5s.
|
|
452
|
+
* Target is 0.85 × bitrate_before_last_large_drop. Always probe_further=false.
|
|
453
|
+
*/
|
|
454
|
+
requestProbe(estimatedBps, nowMs, opts) {
|
|
455
|
+
if (estimatedBps > 0)
|
|
456
|
+
this.estimatedBps = estimatedBps;
|
|
457
|
+
if (this.state !== "complete")
|
|
458
|
+
return [];
|
|
459
|
+
const inAlr = this.alrStartMs !== undefined;
|
|
460
|
+
const alrEndedRecently = this.alrEndMs !== undefined && nowMs - this.alrEndMs < constants_1.kAlrEndedTimeoutMs;
|
|
461
|
+
if (!inAlr && !alrEndedRecently)
|
|
462
|
+
return [];
|
|
463
|
+
if (!(0, bandwidthLimitedCause_1.isProbeInitiationAllowed)(this.lastCause))
|
|
464
|
+
return [];
|
|
465
|
+
const suggested = this.bitrateBeforeLastLargeDrop * constants_1.kProbeFractionAfterDrop;
|
|
466
|
+
const minExpected = suggested * (1 - constants_1.kProbeUncertainty);
|
|
467
|
+
if (!(suggested > 0) || minExpected <= this.estimatedBps)
|
|
468
|
+
return [];
|
|
469
|
+
// pin: time_since_drop < 5s AND time_since_probe > 5s
|
|
470
|
+
if (nowMs - this.timeOfLastLargeDropMs >= constants_1.kBitrateDropTimeoutMs)
|
|
471
|
+
return [];
|
|
472
|
+
if (nowMs - this.lastBweDropProbingMs <= constants_1.kMinTimeBetweenAlrProbesMs) {
|
|
473
|
+
return [];
|
|
474
|
+
}
|
|
475
|
+
const maxProbe = this.effectiveMaxProbeBps(opts?.maxProbeBps);
|
|
476
|
+
if (maxProbe <= 0)
|
|
477
|
+
return [];
|
|
478
|
+
const target = Math.min(suggested, maxProbe);
|
|
479
|
+
if (target <= this.estimatedBps * (1 + constants_1.kProbeUncertainty))
|
|
480
|
+
return [];
|
|
481
|
+
this.lastBweDropProbingMs = nowMs;
|
|
482
|
+
return this.enqueueClusters(nowMs, [target], { stopFurtherAfter: true });
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Further-probe after a successful estimate update.
|
|
486
|
+
*
|
|
487
|
+
* libwebrtc `ProbeController::SetEstimatedBitrate` only continues exponential
|
|
488
|
+
* further probing while `state_ == kWaitingForProbingResult`. Once the session
|
|
489
|
+
* is `kProbingComplete`, `min_bitrate_to_probe_further_` is +∞ and further
|
|
490
|
+
* clusters are not opened from this path (recovery uses {@link requestProbe}).
|
|
491
|
+
*
|
|
492
|
+
* `maxProbeBps` mirrors InitiateProbing max_probe_bitrate for the current
|
|
493
|
+
* BandwidthLimitedCause (loss-limited increasing → estimated × 1.5).
|
|
494
|
+
*/
|
|
495
|
+
setEstimatedBitrate(bitrateBps, nowMs, opts) {
|
|
496
|
+
// Track the latest BWE target (libwebrtc updates estimated_bitrate_ always).
|
|
497
|
+
if (bitrateBps > 0) {
|
|
498
|
+
if (this.estimatedBps > 0 &&
|
|
499
|
+
bitrateBps < this.estimatedBps * constants_1.kBitrateDropThreshold) {
|
|
500
|
+
this.timeOfLastLargeDropMs = nowMs;
|
|
501
|
+
this.bitrateBeforeLastLargeDrop = this.estimatedBps;
|
|
502
|
+
}
|
|
503
|
+
this.estimatedBps = bitrateBps;
|
|
504
|
+
}
|
|
505
|
+
if (opts?.cause) {
|
|
506
|
+
this.lastCause = opts.cause;
|
|
507
|
+
}
|
|
508
|
+
// Further probing is **only** while the controller still awaits results.
|
|
509
|
+
// complete / init never open further via this path (pin SetEstimatedBitrate).
|
|
510
|
+
if (this.state !== "waiting_for_result") {
|
|
511
|
+
return [];
|
|
512
|
+
}
|
|
513
|
+
// Further-probe uses last **planned** target threshold, not last success.
|
|
514
|
+
// Infinity disables further probes after a max-bitrate last cluster or after
|
|
515
|
+
// the session transitions to complete (UpdateState(kProbingComplete)).
|
|
516
|
+
// pin: further-probe also stops if bitrate exceeds NSE upper × 0.7.
|
|
517
|
+
const nseFurtherLimit = this.networkStateUpperBps > 0
|
|
518
|
+
? this.networkStateUpperBps * constants_1.kFurtherProbeThreshold
|
|
519
|
+
: Number.POSITIVE_INFINITY;
|
|
520
|
+
if (this.minBitrateToProbeFurther > 0 &&
|
|
521
|
+
Number.isFinite(this.minBitrateToProbeFurther) &&
|
|
522
|
+
bitrateBps > this.minBitrateToProbeFurther &&
|
|
523
|
+
bitrateBps <= nseFurtherLimit) {
|
|
524
|
+
const maxProbe = this.effectiveMaxProbeBps(opts?.maxProbeBps);
|
|
525
|
+
if (maxProbe <= 0)
|
|
526
|
+
return [];
|
|
527
|
+
const uncapped = Math.min(bitrateBps * constants_1.kFurtherProbeStepMultiplier, bitrateBps * constants_1.kProbeRecoveryMaxScale);
|
|
528
|
+
const next = clamp(uncapped, maxProbe);
|
|
529
|
+
// libwebrtc InitiateProbing: bitrate >= max_probe_bitrate → clamp + stop.
|
|
530
|
+
const stopFurtherAfter = uncapped >= maxProbe;
|
|
531
|
+
return this.enqueueClusters(nowMs, [next], { stopFurtherAfter });
|
|
532
|
+
}
|
|
533
|
+
return [];
|
|
534
|
+
}
|
|
535
|
+
/** Configured max_bitrate combined with optional cause-based probe cap. */
|
|
536
|
+
effectiveMaxProbeBps(maxProbeBps) {
|
|
537
|
+
if (maxProbeBps === undefined)
|
|
538
|
+
return this.maxBitrateBps;
|
|
539
|
+
if (!Number.isFinite(maxProbeBps) || maxProbeBps <= 0)
|
|
540
|
+
return 0;
|
|
541
|
+
return Math.min(this.maxBitrateBps, maxProbeBps);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Advance **controller** timeouts using sender clock (`nowMs` = milliTime).
|
|
545
|
+
* Does not erase ProbeBitrateEstimator seq maps — late TWCC may still
|
|
546
|
+
* produce estimates from {@link estimatorHistory}.
|
|
547
|
+
* Returns newly activated pacing configs (if any).
|
|
548
|
+
*/
|
|
549
|
+
process(nowMs) {
|
|
550
|
+
// pin BitrateProber::CreateProbeCluster — drop **queued** clusters
|
|
551
|
+
// older than 5s or beyond kMaxPendingProbeClusters. Active pacing
|
|
552
|
+
// is not timed out here (late discard uses max_probe_delay instead).
|
|
553
|
+
while (this.queue.length > 0 &&
|
|
554
|
+
(nowMs - this.queue[0].requestedAtMs > constants_1.kProbePacingTimeoutMs ||
|
|
555
|
+
this.queue.length > constants_1.kMaxPendingProbeClusters)) {
|
|
556
|
+
this.queue.shift();
|
|
557
|
+
}
|
|
558
|
+
// ProbeController: result wait after send-fill — 1s from last send.
|
|
559
|
+
// Controller leaves waiting_for_result; estimator history stays when useful.
|
|
560
|
+
for (const [id, c] of this.awaitingResults) {
|
|
561
|
+
const waitStart = c.sentPackets > 0 ? c.lastSendMs : c.startMs;
|
|
562
|
+
if (nowMs - waitStart > constants_1.kProbeResultTimeoutMs) {
|
|
563
|
+
this.awaitingResults.delete(id);
|
|
564
|
+
if (c.sentPackets > 0) {
|
|
565
|
+
this.moveToEstimatorHistory(c);
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
this.dropClusterSeqs(id);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// pin ProbeController::Process:
|
|
573
|
+
// if (at_time - time_last_probing_initiated_ > 1s && waiting)
|
|
574
|
+
// UpdateState(kProbingComplete)
|
|
575
|
+
// Pacing / queued clusters continue (BitrateProber is independent).
|
|
576
|
+
if (this.state === "waiting_for_result" &&
|
|
577
|
+
Number.isFinite(this.lastProbeInitiatedMs) &&
|
|
578
|
+
nowMs - this.lastProbeInitiatedMs > constants_1.kProbeResultTimeoutMs) {
|
|
579
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
580
|
+
this.state = "complete";
|
|
581
|
+
this.lastProbeEndMs = nowMs;
|
|
582
|
+
for (const [id, c] of this.awaitingResults) {
|
|
583
|
+
this.awaitingResults.delete(id);
|
|
584
|
+
if (c.sentPackets > 0) {
|
|
585
|
+
this.moveToEstimatorHistory(c);
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
this.dropClusterSeqs(id);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
// Absolute sender-side cap (align with GccBandwidthEstimator sentInfos).
|
|
593
|
+
// Receive-time 1s history alone never prunes lastRecvMs===0 clusters.
|
|
594
|
+
this.pruneEstimatorHistoryBySendAge(nowMs);
|
|
595
|
+
this.pruneSeqMapsBySendAge(nowMs);
|
|
596
|
+
const activated = this.maybeActivateQueued(nowMs);
|
|
597
|
+
this.maybeMarkComplete(nowMs);
|
|
598
|
+
if (activated.length > 0)
|
|
599
|
+
return activated;
|
|
600
|
+
// pin ProbeController::Process — ALR / network-state probes only after
|
|
601
|
+
// the session is complete (not while waiting_for_result). Same tick that
|
|
602
|
+
// just timed out to complete may still start an ALR/NSE probe.
|
|
603
|
+
if (this.state === "complete") {
|
|
604
|
+
return this.maybePeriodicProbe(nowMs);
|
|
605
|
+
}
|
|
606
|
+
return [];
|
|
607
|
+
}
|
|
608
|
+
/** pin `EnablePeriodicAlrProbing`. */
|
|
609
|
+
enablePeriodicAlrProbing(enable) {
|
|
610
|
+
this.periodicAlrProbing = enable;
|
|
611
|
+
}
|
|
612
|
+
/** pin `SetAlrStartTime` (`undefined` = not in ALR). */
|
|
613
|
+
setAlrStartTime(startMs) {
|
|
614
|
+
this.alrStartMs = startMs;
|
|
615
|
+
}
|
|
616
|
+
/** pin `SetAlrEndedTime`. */
|
|
617
|
+
setAlrEndedTime(endMs) {
|
|
618
|
+
if (Number.isFinite(endMs))
|
|
619
|
+
this.alrEndMs = endMs;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* pin `SetNetworkStateEstimate` — `linkCapacityUpperBps <= 0` clears.
|
|
623
|
+
*/
|
|
624
|
+
setNetworkStateEstimate(linkCapacityUpperBps) {
|
|
625
|
+
this.networkStateUpperBps =
|
|
626
|
+
Number.isFinite(linkCapacityUpperBps) && linkCapacityUpperBps > 0
|
|
627
|
+
? linkCapacityUpperBps
|
|
628
|
+
: 0;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Override pin-default +∞ NSE probe interval (ms) so tests / callers can
|
|
632
|
+
* enable TimeForNetworkStateProbe.
|
|
633
|
+
*/
|
|
634
|
+
setNetworkStateProbeIntervalMs(ms) {
|
|
635
|
+
this.networkStateProbeIntervalMs = Number.isFinite(ms)
|
|
636
|
+
? Math.max(0, ms)
|
|
637
|
+
: constants_1.kNetworkStateEstimateProbingIntervalMs;
|
|
638
|
+
}
|
|
639
|
+
/** Last BandwidthLimitedCause (tests / diagnostics). */
|
|
640
|
+
get lastBandwidthLimitedCause() {
|
|
641
|
+
return this.lastCause;
|
|
642
|
+
}
|
|
643
|
+
/** pin `TimeForAlrProbe`. */
|
|
644
|
+
timeForAlrProbe(nowMs) {
|
|
645
|
+
if (!this.periodicAlrProbing || this.alrStartMs === undefined)
|
|
646
|
+
return false;
|
|
647
|
+
const origin = Math.max(this.alrStartMs, this.lastProbeInitiatedMs);
|
|
648
|
+
return nowMs >= origin + constants_1.kAlrProbingIntervalMs;
|
|
649
|
+
}
|
|
650
|
+
/** pin `TimeForNetworkStateProbe`. */
|
|
651
|
+
timeForNetworkStateProbe(nowMs) {
|
|
652
|
+
if (this.networkStateUpperBps <= 0)
|
|
653
|
+
return false;
|
|
654
|
+
const lowEstimate = this.lastCause === "delay_based_limited" &&
|
|
655
|
+
this.estimatedBps <
|
|
656
|
+
constants_1.kEstimateLowerThanNetworkStateRatio * this.networkStateUpperBps;
|
|
657
|
+
if (lowEstimate &&
|
|
658
|
+
Number.isFinite(constants_1.kEstimateLowerThanNetworkStateIntervalMs)) {
|
|
659
|
+
return (nowMs >=
|
|
660
|
+
this.lastProbeInitiatedMs + constants_1.kEstimateLowerThanNetworkStateIntervalMs);
|
|
661
|
+
}
|
|
662
|
+
if (this.estimatedBps < this.networkStateUpperBps &&
|
|
663
|
+
Number.isFinite(this.networkStateProbeIntervalMs)) {
|
|
664
|
+
return (nowMs >= this.lastProbeInitiatedMs + this.networkStateProbeIntervalMs);
|
|
665
|
+
}
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* pin Process() after kProbingComplete: ALR or NSE periodic probe at
|
|
670
|
+
* estimated × alr_scale, gated by BandwidthLimitedCause.
|
|
671
|
+
*/
|
|
672
|
+
maybePeriodicProbe(nowMs) {
|
|
673
|
+
if (!this.timeForAlrProbe(nowMs) && !this.timeForNetworkStateProbe(nowMs)) {
|
|
674
|
+
return [];
|
|
675
|
+
}
|
|
676
|
+
if (!(0, bandwidthLimitedCause_1.isProbeInitiationAllowed)(this.lastCause))
|
|
677
|
+
return [];
|
|
678
|
+
if (this.estimatedBps <= 0)
|
|
679
|
+
return [];
|
|
680
|
+
let target = this.estimatedBps * constants_1.kAlrProbeScale;
|
|
681
|
+
const causeMax = (0, bandwidthLimitedCause_1.maxProbeBitrateBps)(this.lastCause, this.estimatedBps);
|
|
682
|
+
if (causeMax > 0)
|
|
683
|
+
target = Math.min(target, causeMax);
|
|
684
|
+
if (this.networkStateUpperBps > 0) {
|
|
685
|
+
target = Math.min(target, Math.max(this.estimatedBps, this.networkStateUpperBps * constants_1.kNetworkStateProbeScale));
|
|
686
|
+
}
|
|
687
|
+
if (target <= this.estimatedBps * 1.05)
|
|
688
|
+
return [];
|
|
689
|
+
return this.enqueueClusters(nowMs, [target], { stopFurtherAfter: false });
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Record a probation packet at **send** time (sender clock = sendMs).
|
|
693
|
+
* When minBytes AND minPackets are met, pops pacing → awaitingResults and
|
|
694
|
+
* activates the next queued cluster (libwebrtc BitrateProber::ProbeSent).
|
|
695
|
+
*
|
|
696
|
+
* @returns newly activated pacing configs (may include the next FIFO cluster)
|
|
697
|
+
*/
|
|
698
|
+
onProbePacketSent(sizeBytes, sendMs, wideSeq, reservedClusterId) {
|
|
699
|
+
const reservedId = reservedClusterId ?? this.pacing?.config.id ?? 0;
|
|
700
|
+
const cluster = reservedId > 0 ? this.lookupCluster(reservedId) : this.pacing;
|
|
701
|
+
if (!cluster) {
|
|
702
|
+
return { clusterId: 0, activated: [] };
|
|
703
|
+
}
|
|
704
|
+
// Opaque key: gcc already unwraps. Re-unwrapping here diverges after
|
|
705
|
+
// media packets (which do not advance this map) — e.g. stored -25536
|
|
706
|
+
// vs ACK lookup 40000, so the probe estimate never lands.
|
|
707
|
+
this.seqToCluster.set(wideSeq, cluster.config.id);
|
|
708
|
+
this.seqToSendInfo.set(wideSeq, { sendMs, size: sizeBytes });
|
|
709
|
+
const isActivePacing = this.pacing === cluster;
|
|
710
|
+
if (isActivePacing && this.sendFillComplete(cluster)) {
|
|
711
|
+
return {
|
|
712
|
+
clusterId: cluster.config.id,
|
|
713
|
+
activated: this.finishPacingSend(sendMs),
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
if (cluster.sentPackets === 0) {
|
|
717
|
+
cluster.firstSendMs = sendMs;
|
|
718
|
+
cluster.startedAtMs = sendMs;
|
|
719
|
+
}
|
|
720
|
+
cluster.lastSendMs = sendMs;
|
|
721
|
+
cluster.sentBytes += sizeBytes;
|
|
722
|
+
cluster.sentPackets += 1;
|
|
723
|
+
if (isActivePacing) {
|
|
724
|
+
this.nextProbeTimeMs = this.calculateNextProbeTime(cluster);
|
|
725
|
+
if (this.sendFillComplete(cluster)) {
|
|
726
|
+
return {
|
|
727
|
+
clusterId: cluster.config.id,
|
|
728
|
+
activated: this.finishPacingSend(sendMs),
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return { clusterId: cluster.config.id, activated: [] };
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* pin `CalculateNextProbeTime`: started_at + sent_bytes / send_bitrate.
|
|
736
|
+
*/
|
|
737
|
+
calculateNextProbeTime(cluster) {
|
|
738
|
+
const rate = cluster.config.targetBps;
|
|
739
|
+
if (!(rate > 0) || !Number.isFinite(cluster.startedAtMs)) {
|
|
740
|
+
return Number.NEGATIVE_INFINITY;
|
|
741
|
+
}
|
|
742
|
+
const deltaMs = (cluster.sentBytes * 8 * 1000) / rate;
|
|
743
|
+
return cluster.startedAtMs + deltaMs;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Move pacing cluster to awaiting-results (or settle if result already
|
|
747
|
+
* accepted) and activate next from queue.
|
|
748
|
+
* Uses **sender clock** for the new cluster's startMs.
|
|
749
|
+
*/
|
|
750
|
+
finishPacingSend(senderNowMs) {
|
|
751
|
+
if (!this.pacing)
|
|
752
|
+
return [];
|
|
753
|
+
const done = this.pacing;
|
|
754
|
+
this.pacing = undefined;
|
|
755
|
+
this.nextProbeTimeMs = Number.NEGATIVE_INFINITY;
|
|
756
|
+
// Always await TWCC (including late ACKs after an early 80% result).
|
|
757
|
+
// Cluster is removed on result timeout in process(), not on first estimate.
|
|
758
|
+
this.awaitingResults.set(done.config.id, done);
|
|
759
|
+
const activated = this.maybeActivateQueued(senderNowMs);
|
|
760
|
+
this.maybeMarkComplete(senderNowMs);
|
|
761
|
+
return activated;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* ACK a probe packet. Credits the cluster that owned wideSeq (pacing or
|
|
765
|
+
* awaiting). Does **not** advance or clear FIFO pacing — send-fill only.
|
|
766
|
+
*
|
|
767
|
+
* Rate stats use min/max of ACKed send/receive times (libwebrtc
|
|
768
|
+
* ProbeBitrateEstimator / SortedByReceiveTime semantics) so reorder does
|
|
769
|
+
* not invert the receive interval.
|
|
770
|
+
*
|
|
771
|
+
* 80% ACK is the *minimum* to produce an estimate; further ACKs keep
|
|
772
|
+
* updating cluster stats and may overwrite the pending estimate.
|
|
773
|
+
*
|
|
774
|
+
* @param receivedAtMs TWCC receiver timeline (rate math only)
|
|
775
|
+
* @param senderNowMs sender clock for session completion / cooldown
|
|
776
|
+
* @param sendingAtMs optional send time; defaults to seq map from ProbeSent
|
|
777
|
+
*/
|
|
778
|
+
onAckedPacket(sizeBytes, receivedAtMs, isProbe, wideSeq, senderNowMs, sendingAtMs) {
|
|
779
|
+
if (!isProbe)
|
|
780
|
+
return;
|
|
781
|
+
// Prune estimator history first (libwebrtc EraseOldClusters on receive time).
|
|
782
|
+
this.eraseOldEstimatorClusters(receivedAtMs);
|
|
783
|
+
let cluster;
|
|
784
|
+
let sendMs = sendingAtMs;
|
|
785
|
+
if (wideSeq !== undefined) {
|
|
786
|
+
// Gcc passes the already-resolved extended seq. Use it as an opaque key
|
|
787
|
+
// so a late ACK for generation N does not re-unwrap onto generation N+1.
|
|
788
|
+
const seq = wideSeq;
|
|
789
|
+
const id = this.seqToCluster.get(seq);
|
|
790
|
+
if (id !== undefined) {
|
|
791
|
+
cluster = this.lookupCluster(id);
|
|
792
|
+
}
|
|
793
|
+
if (sendMs === undefined) {
|
|
794
|
+
sendMs = this.seqToSendInfo.get(seq)?.sendMs;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else if (this.pacing && this.awaitingResults.size === 0) {
|
|
798
|
+
// Unit-test fallback without seq map.
|
|
799
|
+
cluster = this.pacing;
|
|
800
|
+
}
|
|
801
|
+
if (!cluster)
|
|
802
|
+
return;
|
|
803
|
+
// Need a send timestamp for ACKed-only send-rate math.
|
|
804
|
+
if (sendMs === undefined || !Number.isFinite(sendMs)) {
|
|
805
|
+
// Last resort: cluster send span. 0 is a valid Timestamp::Zero.
|
|
806
|
+
sendMs = cluster.sentPackets > 0 ? cluster.lastSendMs : cluster.startMs;
|
|
807
|
+
}
|
|
808
|
+
if (!Number.isFinite(sendMs))
|
|
809
|
+
return;
|
|
810
|
+
// libwebrtc-style min/max aggregation (order-independent).
|
|
811
|
+
if (cluster.ackedPackets === 0) {
|
|
812
|
+
cluster.firstAckedSendMs = sendMs;
|
|
813
|
+
cluster.lastAckedSendMs = sendMs;
|
|
814
|
+
cluster.sizeLastAckedSend = sizeBytes;
|
|
815
|
+
cluster.firstRecvMs = receivedAtMs;
|
|
816
|
+
cluster.lastRecvMs = receivedAtMs;
|
|
817
|
+
cluster.sizeFirstRecv = sizeBytes;
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
if (sendMs < cluster.firstAckedSendMs) {
|
|
821
|
+
cluster.firstAckedSendMs = sendMs;
|
|
822
|
+
}
|
|
823
|
+
if (sendMs > cluster.lastAckedSendMs) {
|
|
824
|
+
cluster.lastAckedSendMs = sendMs;
|
|
825
|
+
cluster.sizeLastAckedSend = sizeBytes;
|
|
826
|
+
}
|
|
827
|
+
if (receivedAtMs < cluster.firstRecvMs) {
|
|
828
|
+
cluster.firstRecvMs = receivedAtMs;
|
|
829
|
+
cluster.sizeFirstRecv = sizeBytes;
|
|
830
|
+
}
|
|
831
|
+
if (receivedAtMs > cluster.lastRecvMs) {
|
|
832
|
+
cluster.lastRecvMs = receivedAtMs;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
cluster.ackedBytes += sizeBytes;
|
|
836
|
+
cluster.ackedPackets += 1;
|
|
837
|
+
const estimate = this.estimateClusterBitrate(cluster);
|
|
838
|
+
if (estimate === undefined)
|
|
839
|
+
return;
|
|
840
|
+
// Always surface latest valid result (up or down). Later ACKs overwrite.
|
|
841
|
+
this.pendingEstimateBps = estimate;
|
|
842
|
+
if (estimate > this.estimatedBps) {
|
|
843
|
+
this.estimatedBps = estimate;
|
|
844
|
+
}
|
|
845
|
+
this.lastProbeTargetBps = Math.max(this.lastProbeTargetBps, cluster.config.targetBps);
|
|
846
|
+
cluster.resultAccepted = true;
|
|
847
|
+
// Controller awaiting / estimator history keep seq maps until their
|
|
848
|
+
// respective lifetimes end so the remaining 20% of ACKs can refine.
|
|
849
|
+
void senderNowMs;
|
|
850
|
+
}
|
|
851
|
+
abort(nowMs) {
|
|
852
|
+
this.pacing = undefined;
|
|
853
|
+
this.nextProbeTimeMs = Number.NEGATIVE_INFINITY;
|
|
854
|
+
this.awaitingResults.clear();
|
|
855
|
+
this.estimatorHistory.clear();
|
|
856
|
+
this.queue = [];
|
|
857
|
+
this.seqToCluster.clear();
|
|
858
|
+
this.seqToSendInfo.clear();
|
|
859
|
+
// Any abort ends further-probe eligibility for this session (same as
|
|
860
|
+
// UpdateState(kProbingComplete) clearing min_bitrate_to_probe_further_).
|
|
861
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
862
|
+
if (this.state === "waiting_for_result") {
|
|
863
|
+
// After probing was initiated, failures still end in complete so
|
|
864
|
+
// recovery probing remains available (libwebrtc kProbingComplete).
|
|
865
|
+
this.state = "complete";
|
|
866
|
+
this.lastProbeEndMs = nowMs;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
/** Resolve cluster across pacing / controller-await / estimator history. */
|
|
870
|
+
lookupCluster(id) {
|
|
871
|
+
if (this.pacing?.config.id === id)
|
|
872
|
+
return this.pacing;
|
|
873
|
+
return this.awaitingResults.get(id) ?? this.estimatorHistory.get(id);
|
|
874
|
+
}
|
|
875
|
+
moveToEstimatorHistory(c) {
|
|
876
|
+
// Nothing sent ⇒ no TWCC will match; skip history retention.
|
|
877
|
+
if (c.sentPackets <= 0) {
|
|
878
|
+
this.dropClusterSeqs(c.config.id);
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
this.estimatorHistory.set(c.config.id, c);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* libwebrtc ProbeBitrateEstimator::EraseOldClusters — drop clusters whose
|
|
885
|
+
* last receive is more than {@link kProbeResultTimeoutMs} before `receiveTimeMs`.
|
|
886
|
+
*/
|
|
887
|
+
eraseOldEstimatorClusters(receiveTimeMs) {
|
|
888
|
+
for (const [id, c] of this.estimatorHistory) {
|
|
889
|
+
if (c.ackedPackets > 0 &&
|
|
890
|
+
receiveTimeMs - c.lastRecvMs > constants_1.kProbeResultTimeoutMs) {
|
|
891
|
+
this.dropClusterSeqs(id);
|
|
892
|
+
this.estimatorHistory.delete(id);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Drop estimator-history clusters whose last send is older than the
|
|
898
|
+
* sentInfos lifetime. GCC cannot match late TWCC after that window, so
|
|
899
|
+
* keeping seq maps would only leak memory (esp. never-ACK'd clusters with
|
|
900
|
+
* lastRecvMs === 0 that receive-time prune never removes).
|
|
901
|
+
*/
|
|
902
|
+
pruneEstimatorHistoryBySendAge(nowMs) {
|
|
903
|
+
for (const [id, c] of this.estimatorHistory) {
|
|
904
|
+
const lastSend = c.sentPackets > 0 ? c.lastSendMs : c.startMs;
|
|
905
|
+
if (nowMs - lastSend > constants_1.kSendTimeHistoryWindowMs) {
|
|
906
|
+
this.dropClusterSeqs(id);
|
|
907
|
+
this.estimatorHistory.delete(id);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Drop seq maps whose send time is older than the sentInfos window, even
|
|
913
|
+
* if the owning cluster is still pacing / awaiting. After 60s GCC cannot
|
|
914
|
+
* match TWCC, so keeping the mapping only leaks (and after wrap would
|
|
915
|
+
* collide if we still keyed by 16-bit seq).
|
|
916
|
+
*/
|
|
917
|
+
pruneSeqMapsBySendAge(nowMs) {
|
|
918
|
+
for (const [seq, info] of this.seqToSendInfo) {
|
|
919
|
+
if (nowMs - info.sendMs > constants_1.kSendTimeHistoryWindowMs) {
|
|
920
|
+
this.seqToCluster.delete(seq);
|
|
921
|
+
this.seqToSendInfo.delete(seq);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
maybeMarkComplete(senderNowMs) {
|
|
926
|
+
if (!this.pacing &&
|
|
927
|
+
this.awaitingResults.size === 0 &&
|
|
928
|
+
this.queue.length === 0 &&
|
|
929
|
+
this.state === "waiting_for_result") {
|
|
930
|
+
this.lastProbeEndMs = senderNowMs;
|
|
931
|
+
// Always complete once a session was started — even if every cluster
|
|
932
|
+
// timed out / failed. Returning to init permanently disables recovery
|
|
933
|
+
// because ensureProbing() will not re-run setBitrates().
|
|
934
|
+
//
|
|
935
|
+
// libwebrtc UpdateState(kProbingComplete): min_bitrate_to_probe_further_
|
|
936
|
+
// becomes +∞ so SetEstimatedBitrate cannot re-open further clusters after
|
|
937
|
+
// the controller leaves kWaitingForProbingResult (timeout or empty queue).
|
|
938
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
939
|
+
this.state = "complete";
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* libwebrtc ProbeBitrateEstimator validation on **ACKed** packets only:
|
|
944
|
+
* sendInterval = max(ack send) − min(ack send)
|
|
945
|
+
* recvInterval = max(ack recv) − min(ack recv)
|
|
946
|
+
* sizes exclude the last-sent and first-received packet payloads.
|
|
947
|
+
*/
|
|
948
|
+
estimateClusterBitrate(c) {
|
|
949
|
+
const minProbes = Math.ceil((c.config.minPackets * constants_1.kProbeMinReceivedProbesPercent) / 100);
|
|
950
|
+
const minBytes = Math.ceil((c.config.minBytes * constants_1.kProbeMinReceivedBytesPercent) / 100);
|
|
951
|
+
if (c.ackedPackets < minProbes || c.ackedBytes < minBytes) {
|
|
952
|
+
return undefined;
|
|
953
|
+
}
|
|
954
|
+
const sendIntervalMs = c.lastAckedSendMs - c.firstAckedSendMs;
|
|
955
|
+
const recvIntervalMs = c.lastRecvMs - c.firstRecvMs;
|
|
956
|
+
if (sendIntervalMs <= 0 ||
|
|
957
|
+
sendIntervalMs > constants_1.kProbeMaxIntervalMs ||
|
|
958
|
+
recvIntervalMs <= 0 ||
|
|
959
|
+
recvIntervalMs > constants_1.kProbeMaxIntervalMs) {
|
|
960
|
+
return undefined;
|
|
961
|
+
}
|
|
962
|
+
const sendSize = Math.max(0, c.ackedBytes - c.sizeLastAckedSend);
|
|
963
|
+
const recvSize = Math.max(0, c.ackedBytes - c.sizeFirstRecv);
|
|
964
|
+
if (sendSize <= 0 || recvSize <= 0)
|
|
965
|
+
return undefined;
|
|
966
|
+
const sendBps = (sendSize * 8 * 1000) / sendIntervalMs;
|
|
967
|
+
const recvBps = (recvSize * 8 * 1000) / recvIntervalMs;
|
|
968
|
+
const ratio = recvBps / sendBps;
|
|
969
|
+
if (ratio > constants_1.kProbeMaxValidRatio) {
|
|
970
|
+
return undefined;
|
|
971
|
+
}
|
|
972
|
+
let res = Math.min(sendBps, recvBps);
|
|
973
|
+
if (recvBps < constants_1.kProbeMinRatioForUnsaturated * sendBps) {
|
|
974
|
+
res = constants_1.kProbeTargetUtilization * recvBps;
|
|
975
|
+
}
|
|
976
|
+
// pin ProbeBitrateEstimator does **not** clamp to configured max.
|
|
977
|
+
// The send-side target layer applies app max later.
|
|
978
|
+
return Math.round(res);
|
|
979
|
+
}
|
|
980
|
+
dropClusterSeqs(clusterId) {
|
|
981
|
+
for (const [seq, id] of this.seqToCluster) {
|
|
982
|
+
if (id === clusterId) {
|
|
983
|
+
this.seqToCluster.delete(seq);
|
|
984
|
+
this.seqToSendInfo.delete(seq);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
initiateExponentialProbing(nowMs) {
|
|
989
|
+
const uncapped = constants_1.kProbeBitrateMultipliers.map((s) => this.startBitrateBps * s);
|
|
990
|
+
const bitrates = uncapped.map((b) => clamp(b, this.maxBitrateBps));
|
|
991
|
+
// If the last step is limited by max_bitrate (>= max), do not schedule
|
|
992
|
+
// further probes after the initial session (libwebrtc probe_further=false).
|
|
993
|
+
const stopFurtherAfter = uncapped[uncapped.length - 1] >= this.maxBitrateBps;
|
|
994
|
+
// Only return **activated** configs (front 3x). 6x stays queued until
|
|
995
|
+
// 3x send-fill completes (BitrateProber FIFO).
|
|
996
|
+
return this.enqueueClusters(nowMs, bitrates, {
|
|
997
|
+
stopFurtherAfter,
|
|
998
|
+
minProbeDeltaMs: constants_1.kInitialMinProbeDeltaMs,
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
enqueueClusters(nowMs, bitrates, opts) {
|
|
1002
|
+
// pin InitiateProbing: high-RTT / delay-increased / loss-limited forbid
|
|
1003
|
+
// every new cluster, including further probes from SetEstimatedBitrate.
|
|
1004
|
+
if (!(0, bandwidthLimitedCause_1.isProbeInitiationAllowed)(this.lastCause)) {
|
|
1005
|
+
return [];
|
|
1006
|
+
}
|
|
1007
|
+
const minProbeDeltaMs = opts?.minProbeDeltaMs ?? constants_1.kMinProbeDeltaMs;
|
|
1008
|
+
for (const bps of bitrates) {
|
|
1009
|
+
const minBytes = Math.max(constants_1.kProbeMinPackets * 200, Math.ceil((bps / 8) * (constants_1.kProbeMinDurationMs / 1000)));
|
|
1010
|
+
this.queue.push({
|
|
1011
|
+
id: this.nextClusterId++,
|
|
1012
|
+
targetBps: bps,
|
|
1013
|
+
minPackets: constants_1.kProbeMinPackets,
|
|
1014
|
+
minDurationMs: constants_1.kProbeMinDurationMs,
|
|
1015
|
+
minBytes,
|
|
1016
|
+
minProbeDeltaMs,
|
|
1017
|
+
requestedAtMs: nowMs,
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
if (bitrates.length) {
|
|
1021
|
+
this.lastProbeInitiatedMs = nowMs;
|
|
1022
|
+
if (opts?.stopFurtherAfter) {
|
|
1023
|
+
// pin InitiateProbing(probe_further=false) → kProbingComplete.
|
|
1024
|
+
// BitrateProber FIFO / pacing continues independently.
|
|
1025
|
+
this.minBitrateToProbeFurther = Number.POSITIVE_INFINITY;
|
|
1026
|
+
this.state = "complete";
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
// libwebrtc: min_bitrate_to_probe_further = last planned target × 0.7
|
|
1030
|
+
// (for initial session: 6x × 0.7, not 3x after first success).
|
|
1031
|
+
const lastPlanned = bitrates[bitrates.length - 1];
|
|
1032
|
+
this.minBitrateToProbeFurther = Math.round(lastPlanned * constants_1.kFurtherProbeThreshold);
|
|
1033
|
+
this.state = "waiting_for_result";
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return this.maybeActivateQueued(nowMs);
|
|
1037
|
+
}
|
|
1038
|
+
maybeActivateQueued(nowMs) {
|
|
1039
|
+
if (this.pacing || this.queue.length === 0)
|
|
1040
|
+
return [];
|
|
1041
|
+
const config = this.queue.shift();
|
|
1042
|
+
this.pacing = this.newRuntime(config, nowMs);
|
|
1043
|
+
this.nextProbeTimeMs = Number.NEGATIVE_INFINITY;
|
|
1044
|
+
// BitrateProber FIFO must not reopen ProbeController waiting_for_result.
|
|
1045
|
+
// pin pacer activation is independent of ProbeController::state_.
|
|
1046
|
+
return [config];
|
|
1047
|
+
}
|
|
1048
|
+
newRuntime(config, senderStartMs) {
|
|
1049
|
+
return {
|
|
1050
|
+
config,
|
|
1051
|
+
startMs: senderStartMs,
|
|
1052
|
+
startedAtMs: Number.NEGATIVE_INFINITY,
|
|
1053
|
+
sentBytes: 0,
|
|
1054
|
+
sentPackets: 0,
|
|
1055
|
+
firstSendMs: 0,
|
|
1056
|
+
lastSendMs: 0,
|
|
1057
|
+
ackedBytes: 0,
|
|
1058
|
+
ackedPackets: 0,
|
|
1059
|
+
firstAckedSendMs: 0,
|
|
1060
|
+
lastAckedSendMs: 0,
|
|
1061
|
+
sizeLastAckedSend: 0,
|
|
1062
|
+
firstRecvMs: 0,
|
|
1063
|
+
lastRecvMs: 0,
|
|
1064
|
+
sizeFirstRecv: 0,
|
|
1065
|
+
resultAccepted: false,
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
exports.ProbeController = ProbeController;
|
|
1070
|
+
function clamp(bps, maxBps = constants_1.kMaxBitrateBps) {
|
|
1071
|
+
return Math.min(Math.max(Math.round(bps), constants_1.kMinBitrateBps), maxBps);
|
|
1072
|
+
}
|
|
1073
|
+
//# sourceMappingURL=probeController.js.map
|