werift 0.26.0 → 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/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/log.js +5 -7
- package/lib/common/src/log.js.map +1 -1
- package/lib/common/src/transport.js +10 -5
- package/lib/common/src/transport.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.js +4 -2
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.js +2 -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 +8 -4
- 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 +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/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/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.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.js +2 -2
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/socket.js +4 -2
- 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 +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 +52 -8
- package/lib/ice/src/ice.js +288 -152
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +126 -11
- package/lib/ice/src/iceBase.js +165 -12
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/stun/transaction.d.ts +30 -1
- package/lib/ice/src/stun/transaction.js +86 -17
- 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 +29 -8
- package/lib/ice/src/turn/protocol.js +121 -48
- package/lib/ice/src/turn/protocol.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 +1 -3
- package/lib/ice-server/src/stun/message.js +13 -9
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +9770 -2648
- package/lib/nonstandard/index.mjs +2428 -1052
- package/lib/polyfill/dom.mjs +8738 -1815
- package/lib/polyfill/index.mjs +8738 -1815
- 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 +7 -0
- package/lib/rtp/src/index.js +7 -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 +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.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 +80 -0
- package/lib/sctp/src/sctp.js +655 -108
- 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 +48 -5
- package/lib/webrtc/src/api/peerConfig.js +41 -0
- package/lib/webrtc/src/api/peerConfig.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/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.js +2 -1
- 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 +14 -1
- package/lib/webrtc/src/media/router.js +46 -2
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/rtpReceiver.d.ts +30 -2
- package/lib/webrtc/src/media/rtpReceiver.js +175 -26
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +184 -70
- package/lib/webrtc/src/media/rtpSender.js +626 -449
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +1 -3
- package/lib/webrtc/src/media/rtpTransceiver.js +10 -7
- 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/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 +20 -2
- package/lib/webrtc/src/media/track.js +23 -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 +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +22 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +19 -8
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +8 -1
- package/lib/webrtc/src/negotiationTransaction.js +18 -5
- 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 +44 -1
- package/lib/webrtc/src/peerConnection.js +74 -8
- package/lib/webrtc/src/peerConnection.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 +88 -25
- 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/secureTransportManager.d.ts +52 -4
- package/lib/webrtc/src/secureTransportManager.js +106 -23
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.js +8 -3
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +53 -1
- package/lib/webrtc/src/transport/dtls.js +131 -31
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +10 -86
- package/lib/webrtc/src/transport/ice.js +70 -31
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +2 -0
- package/lib/webrtc/src/transport/sctp.js +66 -20
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +36 -3
- package/lib/webrtc/src/utils.js +56 -16
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +8 -6
|
@@ -1,157 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SenderBandwidthEstimator = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const COUNTER_MAX = 20;
|
|
9
|
-
const SCORE_MAX = 10;
|
|
10
|
-
/**
|
|
11
|
-
* A sent packet is kept for its transport-cc feedback this long: feedback
|
|
12
|
-
* arrives within a round trip, and the estimate only uses the last second.
|
|
13
|
-
*/
|
|
14
|
-
const SENT_INFO_MAX_AGE_MS = 5000;
|
|
15
|
-
/** At most half the 16-bit sequence space, so a wrapped number never aliases a kept one. */
|
|
16
|
-
const SENT_INFO_MAX_COUNT = 0x8000;
|
|
17
|
-
class SenderBandwidthEstimator {
|
|
18
|
-
/**1~10 big is worth*/
|
|
19
|
-
get congestionScore() {
|
|
20
|
-
return this._congestionScore;
|
|
21
|
-
}
|
|
22
|
-
set congestionScore(v) {
|
|
23
|
-
this._congestionScore = v;
|
|
24
|
-
this.onCongestionScore.execute(v);
|
|
25
|
-
}
|
|
26
|
-
get availableBitrate() {
|
|
27
|
-
return this._availableBitrate;
|
|
28
|
-
}
|
|
29
|
-
set availableBitrate(v) {
|
|
30
|
-
this._availableBitrate = v;
|
|
31
|
-
this.onAvailableBitrate.execute(v);
|
|
32
|
-
}
|
|
33
|
-
constructor() {
|
|
34
|
-
Object.defineProperty(this, "congestion", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: false
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "onAvailableBitrate", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: new common_1.Event()
|
|
45
|
-
});
|
|
46
|
-
/**congestion occur or not */
|
|
47
|
-
Object.defineProperty(this, "onCongestion", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: new common_1.Event()
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "onCongestionScore", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: new common_1.Event()
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "congestionCounter", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "cumulativeResult", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: new cumulativeResult_1.CumulativeResult()
|
|
70
|
-
});
|
|
71
|
-
/** Packets awaiting feedback by transport-wide sequence number, oldest first. */
|
|
72
|
-
Object.defineProperty(this, "sentInfos", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
configurable: true,
|
|
75
|
-
writable: true,
|
|
76
|
-
value: new Map()
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(this, "_congestionScore", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
configurable: true,
|
|
81
|
-
writable: true,
|
|
82
|
-
value: 1
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(this, "_availableBitrate", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
configurable: true,
|
|
87
|
-
writable: true,
|
|
88
|
-
value: 0
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
receiveTWCC(feedback) {
|
|
92
|
-
const nowMs = (0, utils_1.milliTime)();
|
|
93
|
-
const elapsedMs = nowMs - this.cumulativeResult.firstPacketSentAtMs;
|
|
94
|
-
if (elapsedMs > 1000) {
|
|
95
|
-
this.cumulativeResult.reset();
|
|
96
|
-
// Congestion may be occurring.
|
|
97
|
-
if (this.congestionCounter < COUNTER_MAX) {
|
|
98
|
-
this.congestionCounter++;
|
|
99
|
-
}
|
|
100
|
-
else if (this.congestionScore < SCORE_MAX) {
|
|
101
|
-
this.congestionScore++;
|
|
102
|
-
}
|
|
103
|
-
if (this.congestionCounter >= COUNTER_MAX && !this.congestion) {
|
|
104
|
-
this.congestion = true;
|
|
105
|
-
this.onCongestion.execute(this.congestion);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
for (const result of feedback.packetResults) {
|
|
109
|
-
if (!result.received)
|
|
110
|
-
continue;
|
|
111
|
-
const wideSeq = result.sequenceNumber;
|
|
112
|
-
const info = this.sentInfos.get(wideSeq);
|
|
113
|
-
if (!info)
|
|
114
|
-
continue;
|
|
115
|
-
if (!result.receivedAtMs)
|
|
116
|
-
continue;
|
|
117
|
-
this.cumulativeResult.addPacket(info.size, info.sendingAtMs, result.receivedAtMs);
|
|
118
|
-
}
|
|
119
|
-
if (elapsedMs >= 100 && this.cumulativeResult.numPackets >= 20) {
|
|
120
|
-
this.availableBitrate = Math.min(this.cumulativeResult.sendBitrate, this.cumulativeResult.receiveBitrate);
|
|
121
|
-
this.cumulativeResult.reset();
|
|
122
|
-
if (this.congestionCounter > -COUNTER_MAX) {
|
|
123
|
-
const maxBonus = (0, rtp_1.Int)(COUNTER_MAX / 2) + 1;
|
|
124
|
-
const minBonus = (0, rtp_1.Int)(COUNTER_MAX / 4) + 1;
|
|
125
|
-
const bonus = maxBonus - ((maxBonus - minBonus) / 10) * this.congestionScore;
|
|
126
|
-
this.congestionCounter = this.congestionCounter - bonus;
|
|
127
|
-
}
|
|
128
|
-
if (this.congestionCounter <= -COUNTER_MAX) {
|
|
129
|
-
if (this.congestionScore > 1) {
|
|
130
|
-
this.congestionScore--;
|
|
131
|
-
this.onCongestion.execute(false);
|
|
132
|
-
}
|
|
133
|
-
this.congestionCounter = 0;
|
|
134
|
-
}
|
|
135
|
-
if (this.congestionCounter <= 0 && this.congestion) {
|
|
136
|
-
this.congestion = false;
|
|
137
|
-
this.onCongestion.execute(this.congestion);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
rtpPacketSent(sentInfo) {
|
|
142
|
-
// A wrapped sequence number replaces its old entry at the newest position.
|
|
143
|
-
this.sentInfos.delete(sentInfo.wideSeq);
|
|
144
|
-
this.sentInfos.set(sentInfo.wideSeq, sentInfo);
|
|
145
|
-
// Drop packets too old for feedback to matter (every sent packet stayed
|
|
146
|
-
// here before, one entry per packet for the sender's lifetime).
|
|
147
|
-
for (const [seq, info] of this.sentInfos) {
|
|
148
|
-
if (this.sentInfos.size <= SENT_INFO_MAX_COUNT &&
|
|
149
|
-
sentInfo.sentAtMs - info.sentAtMs <= SENT_INFO_MAX_AGE_MS) {
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
this.sentInfos.delete(seq);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.SenderBandwidthEstimator = SenderBandwidthEstimator;
|
|
3
|
+
exports.SenderBandwidthEstimator = exports.LightweightBandwidthEstimator = exports.isLightweightBandwidthEstimator = void 0;
|
|
4
|
+
var lightweightBwe_1 = require("./estimators/lightweightBwe");
|
|
5
|
+
Object.defineProperty(exports, "isLightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.isLightweightBandwidthEstimator; } });
|
|
6
|
+
Object.defineProperty(exports, "LightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.LightweightBandwidthEstimator; } });
|
|
7
|
+
Object.defineProperty(exports, "SenderBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.SenderBandwidthEstimator; } });
|
|
157
8
|
//# sourceMappingURL=senderBWE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"senderBWE.js","sourceRoot":"","sources":["../../../../../src/media/sender/senderBWE.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"senderBWE.js","sourceRoot":"","sources":["../../../../../src/media/sender/senderBWE.ts"],"names":[],"mappings":";;;AAOA,8DAIqC;AAHnC,iIAAA,+BAA+B,OAAA;AAC/B,+HAAA,6BAA6B,OAAA;AAC7B,0HAAA,wBAAwB,OAAA","sourcesContent":["/**\n * Backward-compatible entry for the default (lightweight) send-side BWE.\n *\n * Prefer importing {@link BandwidthEstimator}, {@link LightweightBandwidthEstimator},\n * or {@link GccBandwidthEstimator} from the package root / media exports.\n */\nexport type { BandwidthEstimator, SentInfo } from \"./bandwidthEstimator\";\nexport {\n isLightweightBandwidthEstimator,\n LightweightBandwidthEstimator,\n SenderBandwidthEstimator,\n} from \"./estimators/lightweightBwe\";\n"]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { RtcpSrPacket } from "../../imports/rtp";
|
|
2
|
+
import type { Kind } from "../../types/domain";
|
|
3
|
+
import type { RTCRtpCodecParameters } from "../parameters";
|
|
4
|
+
import { type RTCStats } from "../stats";
|
|
5
|
+
/** The part of an RTCP reception report block this sender reads. */
|
|
6
|
+
export type ReceptionReport = {
|
|
7
|
+
packetsLost: number;
|
|
8
|
+
fractionLost: number;
|
|
9
|
+
lsr: number;
|
|
10
|
+
dlsr: number;
|
|
11
|
+
};
|
|
12
|
+
/** Sender identity / negotiation state the stats entries are built from. */
|
|
13
|
+
export type SenderStatsContext = {
|
|
14
|
+
trackId: string;
|
|
15
|
+
ssrc: number;
|
|
16
|
+
kind: Kind;
|
|
17
|
+
mid?: string;
|
|
18
|
+
/** The DTLS transport, when one is set. */
|
|
19
|
+
dtlsTransport?: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
codec?: RTCRtpCodecParameters;
|
|
23
|
+
/** RTX SSRC, only when RTX is negotiated. */
|
|
24
|
+
rtxSsrc?: number;
|
|
25
|
+
/** `trackIdentifier` of the attached track, when there is one. */
|
|
26
|
+
trackIdentifier?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Send-side statistics of one {@link RTCRtpSender}: packet / byte counters,
|
|
30
|
+
* remote reception reports (loss, RTT), and the RTCP Sender Report built from
|
|
31
|
+
* them.
|
|
32
|
+
*/
|
|
33
|
+
export declare class SenderStatistics {
|
|
34
|
+
packetCount: number;
|
|
35
|
+
octetCount: number;
|
|
36
|
+
headerBytesSent: number;
|
|
37
|
+
retransmittedPacketsSent: number;
|
|
38
|
+
retransmittedBytesSent: number;
|
|
39
|
+
nackCount: number;
|
|
40
|
+
pliCount: number;
|
|
41
|
+
firCount: number;
|
|
42
|
+
/** EWMA of the raw RR RTT samples (seconds). */
|
|
43
|
+
private rtt?;
|
|
44
|
+
private totalRoundTripTime;
|
|
45
|
+
private roundTripTimeMeasurements;
|
|
46
|
+
private remotePacketsLost?;
|
|
47
|
+
private remoteFractionLost?;
|
|
48
|
+
/** Compact NTP of the last SR sent (matched against a report's LSR). */
|
|
49
|
+
lastSRtimestamp?: number;
|
|
50
|
+
private lastSentSRTimestamp?;
|
|
51
|
+
/**
|
|
52
|
+
* NTP<->RTP clock anchor for RTCP Sender Reports (RFC 3550 §6.4.1).
|
|
53
|
+
* The send time of the first packet of the newest RTP timestamp (output
|
|
54
|
+
* timeline, after continuity rewrite) approximates that frame's sampling
|
|
55
|
+
* instant; werift does not know the capture time, so for relayed RTP the
|
|
56
|
+
* send jitter becomes SR mapping error. Later packets with the same or a
|
|
57
|
+
* slightly older timestamp (frame fragments, reordered relay packets) and RTX
|
|
58
|
+
* retransmissions do not move it. A continuity rewrite, a clock rate change
|
|
59
|
+
* or a backward timestamp step beyond `RTP_CLOCK_ANCHOR_MAX_REORDER_SEC`
|
|
60
|
+
* resets it (libwebrtc follows the last frame unconditionally).
|
|
61
|
+
*/
|
|
62
|
+
private rtpClockAnchor?;
|
|
63
|
+
private rtpClockAnchorReset;
|
|
64
|
+
/** A media packet left (counted in the SR). */
|
|
65
|
+
recordMediaSent(headerBytes: number, payloadOctets: number): void;
|
|
66
|
+
/** A retransmission left (not counted in the SR packet / octet counts). */
|
|
67
|
+
recordRetransmissionSent(headerBytes: number, payloadBytes: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Record a reception report about this sender's SSRC.
|
|
70
|
+
* @returns the raw RTT (seconds) when the report answers the last SR sent.
|
|
71
|
+
*/
|
|
72
|
+
recordReceptionReport(report: ReceptionReport): number | undefined;
|
|
73
|
+
/** The output RTP timeline restarted (continuity rewrite). */
|
|
74
|
+
resetClockAnchor(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Move the SR clock anchor to a sent packet with a newer timestamp, or to a
|
|
77
|
+
* packet that steps back further than reordering can explain.
|
|
78
|
+
*/
|
|
79
|
+
updateClockAnchor(rtpTimestamp: number, clockRate: number): void;
|
|
80
|
+
/**
|
|
81
|
+
* Build a Sender Report for the instant `nowMonotonicMs` (`performance.now()`).
|
|
82
|
+
* The NTP timestamp is the wall-clock time of that instant and the RTP
|
|
83
|
+
* timestamp is extrapolated from the clock anchor to the same instant with
|
|
84
|
+
* the send clock rate, so an SR sent long after the last RTP packet (idle,
|
|
85
|
+
* silence suppression) still maps the current time (as libwebrtc does).
|
|
86
|
+
* Records the LSR of the NTP timestamp actually sent.
|
|
87
|
+
*/
|
|
88
|
+
buildSenderReport(ssrc: number, nowMonotonicMs: number): RtcpSrPacket;
|
|
89
|
+
/**
|
|
90
|
+
* outbound-rtp, media-source (with a track), codec (with a codec and a
|
|
91
|
+
* transport), and remote-inbound-rtp (once a report arrived) entries.
|
|
92
|
+
*/
|
|
93
|
+
collect(context: SenderStatsContext, timestamp: number): RTCStats[];
|
|
94
|
+
}
|
|
95
|
+
/** Stats ids of the entries a sender reports, keyed by its track id. */
|
|
96
|
+
export declare function senderStatsIds(trackId: string): {
|
|
97
|
+
outboundRtp: string;
|
|
98
|
+
mediaSource: string;
|
|
99
|
+
remoteInboundRtp: string;
|
|
100
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SenderStatistics = void 0;
|
|
4
|
+
exports.senderStatsIds = senderStatsIds;
|
|
5
|
+
const common_1 = require("../../imports/common");
|
|
6
|
+
const rtp_1 = require("../../imports/rtp");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const stats_1 = require("../stats");
|
|
9
|
+
/** EWMA weight of the previous RTT for `roundTripTime` in stats. */
|
|
10
|
+
const RTT_ALPHA = 0.85;
|
|
11
|
+
/**
|
|
12
|
+
* A sent RTP timestamp at most this far behind the SR clock anchor is treated
|
|
13
|
+
* as reordering (relay jitter, B-frames) and does not move the anchor. A larger
|
|
14
|
+
* backward step is a source timestamp discontinuity without continuity rewrite.
|
|
15
|
+
*/
|
|
16
|
+
const RTP_CLOCK_ANCHOR_MAX_REORDER_SEC = 3;
|
|
17
|
+
/**
|
|
18
|
+
* Send-side statistics of one {@link RTCRtpSender}: packet / byte counters,
|
|
19
|
+
* remote reception reports (loss, RTT), and the RTCP Sender Report built from
|
|
20
|
+
* them.
|
|
21
|
+
*/
|
|
22
|
+
class SenderStatistics {
|
|
23
|
+
constructor() {
|
|
24
|
+
Object.defineProperty(this, "packetCount", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "octetCount", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: 0
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(this, "headerBytesSent", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: 0
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "retransmittedPacketsSent", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: 0
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "retransmittedBytesSent", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: 0
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(this, "nackCount", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: 0
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(this, "pliCount", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
value: 0
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(this, "firCount", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: 0
|
|
71
|
+
});
|
|
72
|
+
/** EWMA of the raw RR RTT samples (seconds). */
|
|
73
|
+
Object.defineProperty(this, "rtt", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: void 0
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, "totalRoundTripTime", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: 0
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(this, "roundTripTimeMeasurements", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: 0
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this, "remotePacketsLost", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
value: void 0
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(this, "remoteFractionLost", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
/** Compact NTP of the last SR sent (matched against a report's LSR). */
|
|
104
|
+
Object.defineProperty(this, "lastSRtimestamp", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: void 0
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "lastSentSRTimestamp", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: void 0
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* NTP<->RTP clock anchor for RTCP Sender Reports (RFC 3550 §6.4.1).
|
|
118
|
+
* The send time of the first packet of the newest RTP timestamp (output
|
|
119
|
+
* timeline, after continuity rewrite) approximates that frame's sampling
|
|
120
|
+
* instant; werift does not know the capture time, so for relayed RTP the
|
|
121
|
+
* send jitter becomes SR mapping error. Later packets with the same or a
|
|
122
|
+
* slightly older timestamp (frame fragments, reordered relay packets) and RTX
|
|
123
|
+
* retransmissions do not move it. A continuity rewrite, a clock rate change
|
|
124
|
+
* or a backward timestamp step beyond `RTP_CLOCK_ANCHOR_MAX_REORDER_SEC`
|
|
125
|
+
* resets it (libwebrtc follows the last frame unconditionally).
|
|
126
|
+
*/
|
|
127
|
+
Object.defineProperty(this, "rtpClockAnchor", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
configurable: true,
|
|
130
|
+
writable: true,
|
|
131
|
+
value: void 0
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(this, "rtpClockAnchorReset", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: false
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** A media packet left (counted in the SR). */
|
|
141
|
+
recordMediaSent(headerBytes, payloadOctets) {
|
|
142
|
+
this.headerBytesSent += headerBytes;
|
|
143
|
+
this.packetCount = (0, common_1.uint32Add)(this.packetCount, 1);
|
|
144
|
+
this.octetCount += payloadOctets;
|
|
145
|
+
}
|
|
146
|
+
/** A retransmission left (not counted in the SR packet / octet counts). */
|
|
147
|
+
recordRetransmissionSent(headerBytes, payloadBytes) {
|
|
148
|
+
this.retransmittedPacketsSent++;
|
|
149
|
+
this.retransmittedBytesSent += payloadBytes;
|
|
150
|
+
this.headerBytesSent += headerBytes;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Record a reception report about this sender's SSRC.
|
|
154
|
+
* @returns the raw RTT (seconds) when the report answers the last SR sent.
|
|
155
|
+
*/
|
|
156
|
+
recordReceptionReport(report) {
|
|
157
|
+
this.remotePacketsLost = report.packetsLost;
|
|
158
|
+
this.remoteFractionLost = report.fractionLost / 256;
|
|
159
|
+
if (this.lastSRtimestamp !== report.lsr || !report.dlsr)
|
|
160
|
+
return;
|
|
161
|
+
if (!this.lastSentSRTimestamp)
|
|
162
|
+
return;
|
|
163
|
+
const rawRttSeconds = (0, utils_1.timestampSeconds)() - this.lastSentSRTimestamp - report.dlsr / 65536;
|
|
164
|
+
this.totalRoundTripTime += rawRttSeconds;
|
|
165
|
+
this.roundTripTimeMeasurements++;
|
|
166
|
+
// Stats / getStats keep an EWMA; the raw sample is returned for AIMD.
|
|
167
|
+
if (this.rtt === undefined) {
|
|
168
|
+
this.rtt = rawRttSeconds;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this.rtt = RTT_ALPHA * this.rtt + (1 - RTT_ALPHA) * rawRttSeconds;
|
|
172
|
+
}
|
|
173
|
+
return rawRttSeconds;
|
|
174
|
+
}
|
|
175
|
+
/** The output RTP timeline restarted (continuity rewrite). */
|
|
176
|
+
resetClockAnchor() {
|
|
177
|
+
this.rtpClockAnchorReset = true;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Move the SR clock anchor to a sent packet with a newer timestamp, or to a
|
|
181
|
+
* packet that steps back further than reordering can explain.
|
|
182
|
+
*/
|
|
183
|
+
updateClockAnchor(rtpTimestamp, clockRate) {
|
|
184
|
+
const anchor = this.rtpClockAnchor;
|
|
185
|
+
if (anchor && !this.rtpClockAnchorReset && anchor.clockRate === clockRate) {
|
|
186
|
+
// 32bit signed difference: handles timestamp wraparound
|
|
187
|
+
const delta = (rtpTimestamp - anchor.rtpTimestamp) | 0;
|
|
188
|
+
if (delta <= 0 &&
|
|
189
|
+
-delta <= clockRate * RTP_CLOCK_ANCHOR_MAX_REORDER_SEC) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
this.rtpClockAnchorReset = false;
|
|
194
|
+
this.rtpClockAnchor = {
|
|
195
|
+
monotonicMs: performance.now(),
|
|
196
|
+
rtpTimestamp,
|
|
197
|
+
clockRate,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Build a Sender Report for the instant `nowMonotonicMs` (`performance.now()`).
|
|
202
|
+
* The NTP timestamp is the wall-clock time of that instant and the RTP
|
|
203
|
+
* timestamp is extrapolated from the clock anchor to the same instant with
|
|
204
|
+
* the send clock rate, so an SR sent long after the last RTP packet (idle,
|
|
205
|
+
* silence suppression) still maps the current time (as libwebrtc does).
|
|
206
|
+
* Records the LSR of the NTP timestamp actually sent.
|
|
207
|
+
*/
|
|
208
|
+
buildSenderReport(ssrc, nowMonotonicMs) {
|
|
209
|
+
const ntpTimestamp = (0, utils_1.ntpTime)(performance.timeOrigin + nowMonotonicMs);
|
|
210
|
+
let rtpTimestamp = 0;
|
|
211
|
+
const anchor = this.rtpClockAnchor;
|
|
212
|
+
if (anchor) {
|
|
213
|
+
const elapsedMs = Math.max(0, nowMonotonicMs - anchor.monotonicMs);
|
|
214
|
+
rtpTimestamp = (0, common_1.uint32Add)(anchor.rtpTimestamp, Math.round((elapsedMs * anchor.clockRate) / 1000) % 4294967296);
|
|
215
|
+
}
|
|
216
|
+
this.lastSRtimestamp = (0, utils_1.compactNtp)(ntpTimestamp);
|
|
217
|
+
this.lastSentSRTimestamp = (0, utils_1.timestampSeconds)();
|
|
218
|
+
return new rtp_1.RtcpSrPacket({
|
|
219
|
+
ssrc,
|
|
220
|
+
senderInfo: new rtp_1.RtcpSenderInfo({
|
|
221
|
+
ntpTimestamp,
|
|
222
|
+
rtpTimestamp,
|
|
223
|
+
packetCount: this.packetCount,
|
|
224
|
+
octetCount: this.octetCount,
|
|
225
|
+
}),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* outbound-rtp, media-source (with a track), codec (with a codec and a
|
|
230
|
+
* transport), and remote-inbound-rtp (once a report arrived) entries.
|
|
231
|
+
*/
|
|
232
|
+
collect(context, timestamp) {
|
|
233
|
+
const stats = [];
|
|
234
|
+
const transportId = context.dtlsTransport
|
|
235
|
+
? (0, stats_1.generateStatsId)("transport", context.dtlsTransport.id)
|
|
236
|
+
: undefined;
|
|
237
|
+
const codec = context.codec;
|
|
238
|
+
const codecId = codec && transportId
|
|
239
|
+
? (0, stats_1.generateCodecStatsId)(transportId, codec.payloadType, context.trackId)
|
|
240
|
+
: undefined;
|
|
241
|
+
const hasRemote = this.rtt !== undefined ||
|
|
242
|
+
this.remotePacketsLost !== undefined ||
|
|
243
|
+
this.remoteFractionLost !== undefined;
|
|
244
|
+
const mediaSourceId = senderStatsIds(context.trackId).mediaSource;
|
|
245
|
+
const remoteInboundId = senderStatsIds(context.trackId).remoteInboundRtp;
|
|
246
|
+
const outboundRtpStats = {
|
|
247
|
+
type: "outbound-rtp",
|
|
248
|
+
id: senderStatsIds(context.trackId).outboundRtp,
|
|
249
|
+
timestamp,
|
|
250
|
+
ssrc: context.ssrc,
|
|
251
|
+
kind: context.kind,
|
|
252
|
+
transportId,
|
|
253
|
+
codecId,
|
|
254
|
+
mid: context.mid,
|
|
255
|
+
packetsSent: this.packetCount,
|
|
256
|
+
bytesSent: this.octetCount,
|
|
257
|
+
headerBytesSent: this.headerBytesSent,
|
|
258
|
+
retransmittedPacketsSent: this.retransmittedPacketsSent || undefined,
|
|
259
|
+
retransmittedBytesSent: this.retransmittedBytesSent || undefined,
|
|
260
|
+
rtxSsrc: context.rtxSsrc,
|
|
261
|
+
mediaSourceId: context.trackIdentifier !== undefined ? mediaSourceId : undefined,
|
|
262
|
+
remoteId: hasRemote ? remoteInboundId : undefined,
|
|
263
|
+
nackCount: this.nackCount || undefined,
|
|
264
|
+
pliCount: this.pliCount || undefined,
|
|
265
|
+
firCount: this.firCount || undefined,
|
|
266
|
+
};
|
|
267
|
+
stats.push(outboundRtpStats);
|
|
268
|
+
if (context.trackIdentifier !== undefined) {
|
|
269
|
+
const mediaSourceStats = {
|
|
270
|
+
type: "media-source",
|
|
271
|
+
id: mediaSourceId,
|
|
272
|
+
timestamp,
|
|
273
|
+
trackIdentifier: context.trackIdentifier,
|
|
274
|
+
kind: context.kind,
|
|
275
|
+
};
|
|
276
|
+
stats.push(mediaSourceStats);
|
|
277
|
+
}
|
|
278
|
+
if (codec && transportId) {
|
|
279
|
+
const codecStats = {
|
|
280
|
+
type: "codec",
|
|
281
|
+
id: codecId,
|
|
282
|
+
timestamp,
|
|
283
|
+
payloadType: codec.payloadType,
|
|
284
|
+
transportId,
|
|
285
|
+
mimeType: codec.mimeType,
|
|
286
|
+
clockRate: codec.clockRate,
|
|
287
|
+
channels: codec.channels,
|
|
288
|
+
sdpFmtpLine: codec.parameters,
|
|
289
|
+
};
|
|
290
|
+
stats.push(codecStats);
|
|
291
|
+
}
|
|
292
|
+
if (hasRemote) {
|
|
293
|
+
const remoteInboundStats = {
|
|
294
|
+
type: "remote-inbound-rtp",
|
|
295
|
+
id: remoteInboundId,
|
|
296
|
+
timestamp,
|
|
297
|
+
ssrc: context.ssrc,
|
|
298
|
+
kind: context.kind,
|
|
299
|
+
transportId,
|
|
300
|
+
codecId: outboundRtpStats.codecId,
|
|
301
|
+
localId: outboundRtpStats.id,
|
|
302
|
+
roundTripTime: this.rtt,
|
|
303
|
+
totalRoundTripTime: this.totalRoundTripTime,
|
|
304
|
+
roundTripTimeMeasurements: this.roundTripTimeMeasurements,
|
|
305
|
+
packetsLost: this.remotePacketsLost,
|
|
306
|
+
fractionLost: this.remoteFractionLost,
|
|
307
|
+
};
|
|
308
|
+
stats.push(remoteInboundStats);
|
|
309
|
+
}
|
|
310
|
+
return stats;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.SenderStatistics = SenderStatistics;
|
|
314
|
+
/** Stats ids of the entries a sender reports, keyed by its track id. */
|
|
315
|
+
function senderStatsIds(trackId) {
|
|
316
|
+
return {
|
|
317
|
+
outboundRtp: (0, stats_1.generateStatsId)("outbound-rtp", trackId),
|
|
318
|
+
mediaSource: (0, stats_1.generateStatsId)("media-source", trackId),
|
|
319
|
+
remoteInboundRtp: (0, stats_1.generateStatsId)("remote-inbound-rtp", trackId),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=senderStats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"senderStats.js","sourceRoot":"","sources":["../../../../../src/media/sender/senderStats.ts"],"names":[],"mappings":";;;AA6RA,wCAMC;AAnSD,iDAAiD;AACjD,2CAAiE;AAEjE,uCAAoE;AAEpE,oCAQkB;AAElB,oEAAoE;AACp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yB,EAAE,IAAI,CAAC,yBAAyB;gBACzD,WAAW,EAAE,IAAI,CAAC,iBAAiB;gBACnC,YAAY,EAAE,IAAI,CAAC,kBAAkB;aACtC,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtOD,4CAsOC;AAED,wEAAwE;AACxE,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO;QACL,WAAW,EAAE,IAAA,uBAAe,EAAC,cAAc,EAAE,OAAO,CAAC;QACrD,WAAW,EAAE,IAAA,uBAAe,EAAC,cAAc,EAAE,OAAO,CAAC;QACrD,gBAAgB,EAAE,IAAA,uBAAe,EAAC,oBAAoB,EAAE,OAAO,CAAC;KACjE,CAAC;AACJ,CAAC","sourcesContent":["import { uint32Add } from \"../../imports/common\";\nimport { RtcpSenderInfo, RtcpSrPacket } from \"../../imports/rtp\";\nimport type { Kind } from \"../../types/domain\";\nimport { compactNtp, ntpTime, timestampSeconds } from \"../../utils\";\nimport type { RTCRtpCodecParameters } from \"../parameters\";\nimport {\n generateCodecStatsId,\n generateStatsId,\n type RTCCodecStats,\n type RTCMediaSourceStats,\n type RTCOutboundRtpStreamStats,\n type RTCRemoteInboundRtpStreamStats,\n type RTCStats,\n} from \"../stats\";\n\n/** EWMA weight of the previous RTT for `roundTripTime` in stats. */\nconst RTT_ALPHA = 0.85;\n/**\n * A sent RTP timestamp at most this far behind the SR clock anchor is treated\n * as reordering (relay jitter, B-frames) and does not move the anchor. A larger\n * backward step is a source timestamp discontinuity without continuity rewrite.\n */\nconst RTP_CLOCK_ANCHOR_MAX_REORDER_SEC = 3;\n\n/** The part of an RTCP reception report block this sender reads. */\nexport type ReceptionReport = {\n packetsLost: number;\n fractionLost: number;\n lsr: number;\n dlsr: number;\n};\n\n/** Sender identity / negotiation state the stats entries are built from. */\nexport type SenderStatsContext = {\n trackId: string;\n ssrc: number;\n kind: Kind;\n mid?: string;\n /** The DTLS transport, when one is set. */\n dtlsTransport?: { id: string };\n codec?: RTCRtpCodecParameters;\n /** RTX SSRC, only when RTX is negotiated. */\n rtxSsrc?: number;\n /** `trackIdentifier` of the attached track, when there is one. */\n trackIdentifier?: string;\n};\n\n/**\n * Send-side statistics of one {@link RTCRtpSender}: packet / byte counters,\n * remote reception reports (loss, RTT), and the RTCP Sender Report built from\n * them.\n */\nexport class SenderStatistics {\n packetCount = 0;\n octetCount = 0;\n headerBytesSent = 0;\n retransmittedPacketsSent = 0;\n retransmittedBytesSent = 0;\n nackCount = 0;\n pliCount = 0;\n firCount = 0;\n\n /** EWMA of the raw RR RTT samples (seconds). */\n private rtt?: number;\n private totalRoundTripTime = 0;\n private roundTripTimeMeasurements = 0;\n private remotePacketsLost?: number;\n private remoteFractionLost?: number;\n\n /** Compact NTP of the last SR sent (matched against a report's LSR). */\n lastSRtimestamp?: number;\n private lastSentSRTimestamp?: number;\n /**\n * NTP<->RTP clock anchor for RTCP Sender Reports (RFC 3550 §6.4.1).\n * The send time of the first packet of the newest RTP timestamp (output\n * timeline, after continuity rewrite) approximates that frame's sampling\n * instant; werift does not know the capture time, so for relayed RTP the\n * send jitter becomes SR mapping error. Later packets with the same or a\n * slightly older timestamp (frame fragments, reordered relay packets) and RTX\n * retransmissions do not move it. A continuity rewrite, a clock rate change\n * or a backward timestamp step beyond `RTP_CLOCK_ANCHOR_MAX_REORDER_SEC`\n * resets it (libwebrtc follows the last frame unconditionally).\n */\n private rtpClockAnchor?: {\n /** `performance.now()` when the anchor packet was sent */\n monotonicMs: number;\n rtpTimestamp: number;\n clockRate: number;\n };\n private rtpClockAnchorReset = false;\n\n /** A media packet left (counted in the SR). */\n recordMediaSent(headerBytes: number, payloadOctets: number) {\n this.headerBytesSent += headerBytes;\n this.packetCount = uint32Add(this.packetCount, 1);\n this.octetCount += payloadOctets;\n }\n\n /** A retransmission left (not counted in the SR packet / octet counts). */\n recordRetransmissionSent(headerBytes: number, payloadBytes: number) {\n this.retransmittedPacketsSent++;\n this.retransmittedBytesSent += payloadBytes;\n this.headerBytesSent += headerBytes;\n }\n\n /**\n * Record a reception report about this sender's SSRC.\n * @returns the raw RTT (seconds) when the report answers the last SR sent.\n */\n recordReceptionReport(report: ReceptionReport): number | undefined {\n this.remotePacketsLost = report.packetsLost;\n this.remoteFractionLost = report.fractionLost / 256;\n if (this.lastSRtimestamp !== report.lsr || !report.dlsr) return;\n if (!this.lastSentSRTimestamp) return;\n const rawRttSeconds =\n timestampSeconds() - this.lastSentSRTimestamp - report.dlsr / 65536;\n this.totalRoundTripTime += rawRttSeconds;\n this.roundTripTimeMeasurements++;\n // Stats / getStats keep an EWMA; the raw sample is returned for AIMD.\n if (this.rtt === undefined) {\n this.rtt = rawRttSeconds;\n } else {\n this.rtt = RTT_ALPHA * this.rtt + (1 - RTT_ALPHA) * rawRttSeconds;\n }\n return rawRttSeconds;\n }\n\n /** The output RTP timeline restarted (continuity rewrite). */\n resetClockAnchor() {\n this.rtpClockAnchorReset = true;\n }\n\n /**\n * Move the SR clock anchor to a sent packet with a newer timestamp, or to a\n * packet that steps back further than reordering can explain.\n */\n updateClockAnchor(rtpTimestamp: number, clockRate: number) {\n const anchor = this.rtpClockAnchor;\n if (anchor && !this.rtpClockAnchorReset && anchor.clockRate === clockRate) {\n // 32bit signed difference: handles timestamp wraparound\n const delta = (rtpTimestamp - anchor.rtpTimestamp) | 0;\n if (\n delta <= 0 &&\n -delta <= clockRate * RTP_CLOCK_ANCHOR_MAX_REORDER_SEC\n ) {\n return;\n }\n }\n this.rtpClockAnchorReset = false;\n this.rtpClockAnchor = {\n monotonicMs: performance.now(),\n rtpTimestamp,\n clockRate,\n };\n }\n\n /**\n * Build a Sender Report for the instant `nowMonotonicMs` (`performance.now()`).\n * The NTP timestamp is the wall-clock time of that instant and the RTP\n * timestamp is extrapolated from the clock anchor to the same instant with\n * the send clock rate, so an SR sent long after the last RTP packet (idle,\n * silence suppression) still maps the current time (as libwebrtc does).\n * Records the LSR of the NTP timestamp actually sent.\n */\n buildSenderReport(ssrc: number, nowMonotonicMs: number) {\n const ntpTimestamp = ntpTime(performance.timeOrigin + nowMonotonicMs);\n let rtpTimestamp = 0;\n const anchor = this.rtpClockAnchor;\n if (anchor) {\n const elapsedMs = Math.max(0, nowMonotonicMs - anchor.monotonicMs);\n rtpTimestamp = uint32Add(\n anchor.rtpTimestamp,\n Math.round((elapsedMs * anchor.clockRate) / 1000) % 0x1_0000_0000,\n );\n }\n\n this.lastSRtimestamp = compactNtp(ntpTimestamp);\n this.lastSentSRTimestamp = timestampSeconds();\n\n return new RtcpSrPacket({\n ssrc,\n senderInfo: new RtcpSenderInfo({\n ntpTimestamp,\n rtpTimestamp,\n packetCount: this.packetCount,\n octetCount: this.octetCount,\n }),\n });\n }\n\n /**\n * outbound-rtp, media-source (with a track), codec (with a codec and a\n * transport), and remote-inbound-rtp (once a report arrived) entries.\n */\n collect(context: SenderStatsContext, timestamp: number): RTCStats[] {\n const stats: RTCStats[] = [];\n const transportId = context.dtlsTransport\n ? generateStatsId(\"transport\", context.dtlsTransport.id)\n : undefined;\n const codec = context.codec;\n const codecId =\n codec && transportId\n ? generateCodecStatsId(transportId, codec.payloadType, context.trackId)\n : undefined;\n const hasRemote =\n this.rtt !== undefined ||\n this.remotePacketsLost !== undefined ||\n this.remoteFractionLost !== undefined;\n const mediaSourceId = senderStatsIds(context.trackId).mediaSource;\n const remoteInboundId = senderStatsIds(context.trackId).remoteInboundRtp;\n\n const outboundRtpStats: RTCOutboundRtpStreamStats = {\n type: \"outbound-rtp\",\n id: senderStatsIds(context.trackId).outboundRtp,\n timestamp,\n ssrc: context.ssrc,\n kind: context.kind,\n transportId,\n codecId,\n mid: context.mid,\n packetsSent: this.packetCount,\n bytesSent: this.octetCount,\n headerBytesSent: this.headerBytesSent,\n retransmittedPacketsSent: this.retransmittedPacketsSent || undefined,\n retransmittedBytesSent: this.retransmittedBytesSent || undefined,\n rtxSsrc: context.rtxSsrc,\n mediaSourceId:\n context.trackIdentifier !== undefined ? mediaSourceId : undefined,\n remoteId: hasRemote ? remoteInboundId : undefined,\n nackCount: this.nackCount || undefined,\n pliCount: this.pliCount || undefined,\n firCount: this.firCount || undefined,\n };\n stats.push(outboundRtpStats);\n\n if (context.trackIdentifier !== undefined) {\n const mediaSourceStats: RTCMediaSourceStats = {\n type: \"media-source\",\n id: mediaSourceId,\n timestamp,\n trackIdentifier: context.trackIdentifier,\n kind: context.kind,\n };\n stats.push(mediaSourceStats);\n }\n\n if (codec && transportId) {\n const codecStats: RTCCodecStats = {\n type: \"codec\",\n id: codecId!,\n timestamp,\n payloadType: codec.payloadType,\n transportId,\n mimeType: codec.mimeType,\n clockRate: codec.clockRate,\n channels: codec.channels,\n sdpFmtpLine: codec.parameters,\n };\n stats.push(codecStats);\n }\n\n if (hasRemote) {\n const remoteInboundStats: RTCRemoteInboundRtpStreamStats = {\n type: \"remote-inbound-rtp\",\n id: remoteInboundId,\n timestamp,\n ssrc: context.ssrc,\n kind: context.kind,\n transportId,\n codecId: outboundRtpStats.codecId,\n localId: outboundRtpStats.id,\n roundTripTime: this.rtt,\n totalRoundTripTime: this.totalRoundTripTime,\n roundTripTimeMeasurements: this.roundTripTimeMeasurements,\n packetsLost: this.remotePacketsLost,\n fractionLost: this.remoteFractionLost,\n };\n stats.push(remoteInboundStats);\n }\n\n return stats;\n }\n}\n\n/** Stats ids of the entries a sender reports, keyed by its track id. */\nexport function senderStatsIds(trackId: string) {\n return {\n outboundRtp: generateStatsId(\"outbound-rtp\", trackId),\n mediaSource: generateStatsId(\"media-source\", trackId),\n remoteInboundRtp: generateStatsId(\"remote-inbound-rtp\", trackId),\n };\n}\n"]}
|