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.
Files changed (437) hide show
  1. package/README.md +63 -0
  2. package/THIRD_PARTY_LICENSES_LIBWEBRTC.txt +58 -0
  3. package/lib/common/src/binary.d.ts +1 -3
  4. package/lib/common/src/binary.js +8 -6
  5. package/lib/common/src/binary.js.map +1 -1
  6. package/lib/common/src/binaryData.js +2 -1
  7. package/lib/common/src/binaryData.js.map +1 -1
  8. package/lib/common/src/log.js +5 -7
  9. package/lib/common/src/log.js.map +1 -1
  10. package/lib/common/src/transport.js +10 -5
  11. package/lib/common/src/transport.js.map +1 -1
  12. package/lib/dtls/src/context/cipher.d.ts +1 -1
  13. package/lib/dtls/src/context/cipher.js +6 -3
  14. package/lib/dtls/src/context/cipher.js.map +1 -1
  15. package/lib/dtls/src/context/dtls.js +4 -2
  16. package/lib/dtls/src/context/dtls.js.map +1 -1
  17. package/lib/dtls/src/context/transport.js +2 -1
  18. package/lib/dtls/src/context/transport.js.map +1 -1
  19. package/lib/dtls/src/flight/client/flight1.js +2 -1
  20. package/lib/dtls/src/flight/client/flight1.js.map +1 -1
  21. package/lib/dtls/src/flight/client/flight5.js +4 -2
  22. package/lib/dtls/src/flight/client/flight5.js.map +1 -1
  23. package/lib/dtls/src/flight/flight.d.ts +1 -1
  24. package/lib/dtls/src/flight/flight.js +8 -4
  25. package/lib/dtls/src/flight/flight.js.map +1 -1
  26. package/lib/dtls/src/flight/server/flight4.js +4 -2
  27. package/lib/dtls/src/flight/server/flight4.js.map +1 -1
  28. package/lib/dtls/src/flight/server/flight6.js +2 -1
  29. package/lib/dtls/src/flight/server/flight6.js.map +1 -1
  30. package/lib/dtls/src/handshake/const.d.ts +17 -13
  31. package/lib/dtls/src/handshake/const.js +16 -14
  32. package/lib/dtls/src/handshake/const.js.map +1 -1
  33. package/lib/dtls/src/handshake/message/alert.js +4 -2
  34. package/lib/dtls/src/handshake/message/alert.js.map +1 -1
  35. package/lib/dtls/src/handshake/message/certificate.js +2 -1
  36. package/lib/dtls/src/handshake/message/certificate.js.map +1 -1
  37. package/lib/dtls/src/handshake/message/changeCipherSpec.js +2 -1
  38. package/lib/dtls/src/handshake/message/changeCipherSpec.js.map +1 -1
  39. package/lib/dtls/src/handshake/message/client/certificateVerify.js +4 -2
  40. package/lib/dtls/src/handshake/message/client/certificateVerify.js.map +1 -1
  41. package/lib/dtls/src/handshake/message/client/hello.js +14 -7
  42. package/lib/dtls/src/handshake/message/client/hello.js.map +1 -1
  43. package/lib/dtls/src/handshake/message/client/keyExchange.js +2 -1
  44. package/lib/dtls/src/handshake/message/client/keyExchange.js.map +1 -1
  45. package/lib/dtls/src/handshake/message/finished.js +2 -1
  46. package/lib/dtls/src/handshake/message/finished.js.map +1 -1
  47. package/lib/dtls/src/handshake/message/server/certificateRequest.js +6 -3
  48. package/lib/dtls/src/handshake/message/server/certificateRequest.js.map +1 -1
  49. package/lib/dtls/src/handshake/message/server/hello.js +12 -6
  50. package/lib/dtls/src/handshake/message/server/hello.js.map +1 -1
  51. package/lib/dtls/src/handshake/message/server/helloDone.js.map +1 -1
  52. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js +4 -2
  53. package/lib/dtls/src/handshake/message/server/helloVerifyRequest.js.map +1 -1
  54. package/lib/dtls/src/handshake/message/server/keyExchange.js +16 -8
  55. package/lib/dtls/src/handshake/message/server/keyExchange.js.map +1 -1
  56. package/lib/dtls/src/handshake/random.d.ts +2 -2
  57. package/lib/dtls/src/handshake/random.js +5 -2
  58. package/lib/dtls/src/handshake/random.js.map +1 -1
  59. package/lib/dtls/src/record/const.d.ts +43 -33
  60. package/lib/dtls/src/record/const.js +43 -36
  61. package/lib/dtls/src/record/const.js.map +1 -1
  62. package/lib/dtls/src/record/message/fragment.js +12 -6
  63. package/lib/dtls/src/record/message/fragment.js.map +1 -1
  64. package/lib/dtls/src/record/message/header.js +10 -5
  65. package/lib/dtls/src/record/message/header.js.map +1 -1
  66. package/lib/dtls/src/record/message/plaintext.js +4 -2
  67. package/lib/dtls/src/record/message/plaintext.js.map +1 -1
  68. package/lib/dtls/src/record/receive.js +2 -2
  69. package/lib/dtls/src/record/receive.js.map +1 -1
  70. package/lib/dtls/src/socket.js +4 -2
  71. package/lib/dtls/src/socket.js.map +1 -1
  72. package/lib/ice/src/candidate.d.ts +1 -1
  73. package/lib/ice/src/candidate.js +24 -12
  74. package/lib/ice/src/candidate.js.map +1 -1
  75. package/lib/ice/src/dns/lookup.d.ts +10 -1
  76. package/lib/ice/src/dns/lookup.js +42 -7
  77. package/lib/ice/src/dns/lookup.js.map +1 -1
  78. package/lib/ice/src/exceptions.d.ts +21 -5
  79. package/lib/ice/src/exceptions.js +58 -13
  80. package/lib/ice/src/exceptions.js.map +1 -1
  81. package/lib/ice/src/ice.d.ts +52 -8
  82. package/lib/ice/src/ice.js +288 -152
  83. package/lib/ice/src/ice.js.map +1 -1
  84. package/lib/ice/src/iceBase.d.ts +126 -11
  85. package/lib/ice/src/iceBase.js +165 -12
  86. package/lib/ice/src/iceBase.js.map +1 -1
  87. package/lib/ice/src/stun/transaction.d.ts +30 -1
  88. package/lib/ice/src/stun/transaction.js +86 -17
  89. package/lib/ice/src/stun/transaction.js.map +1 -1
  90. package/lib/ice/src/turn/credential.d.ts +49 -0
  91. package/lib/ice/src/turn/credential.js +78 -0
  92. package/lib/ice/src/turn/credential.js.map +1 -0
  93. package/lib/ice/src/turn/protocol.d.ts +29 -8
  94. package/lib/ice/src/turn/protocol.js +121 -48
  95. package/lib/ice/src/turn/protocol.js.map +1 -1
  96. package/lib/ice-server/src/stun/attributes.d.ts +2 -0
  97. package/lib/ice-server/src/stun/attributes.js +7 -1
  98. package/lib/ice-server/src/stun/attributes.js.map +1 -1
  99. package/lib/ice-server/src/stun/const.d.ts +24 -16
  100. package/lib/ice-server/src/stun/const.js +22 -18
  101. package/lib/ice-server/src/stun/const.js.map +1 -1
  102. package/lib/ice-server/src/stun/message.d.ts +1 -3
  103. package/lib/ice-server/src/stun/message.js +13 -9
  104. package/lib/ice-server/src/stun/message.js.map +1 -1
  105. package/lib/index.mjs +9770 -2648
  106. package/lib/nonstandard/index.mjs +2428 -1052
  107. package/lib/polyfill/dom.mjs +8738 -1815
  108. package/lib/polyfill/index.mjs +8738 -1815
  109. package/lib/rtp/src/codec/assertPayload.d.ts +4 -0
  110. package/lib/rtp/src/codec/assertPayload.js +12 -0
  111. package/lib/rtp/src/codec/assertPayload.js.map +1 -0
  112. package/lib/rtp/src/codec/av1.js +2 -0
  113. package/lib/rtp/src/codec/av1.js.map +1 -1
  114. package/lib/rtp/src/codec/h264.js +35 -43
  115. package/lib/rtp/src/codec/h264.js.map +1 -1
  116. package/lib/rtp/src/codec/vp8.js +11 -5
  117. package/lib/rtp/src/codec/vp8.js.map +1 -1
  118. package/lib/rtp/src/codec/vp9.js +12 -0
  119. package/lib/rtp/src/codec/vp9.js.map +1 -1
  120. package/lib/rtp/src/extra/container/mp4/container.js +2 -1
  121. package/lib/rtp/src/extra/container/mp4/container.js.map +1 -1
  122. package/lib/rtp/src/extra/container/mp4/exp-golomb.js +2 -1
  123. package/lib/rtp/src/extra/container/mp4/exp-golomb.js.map +1 -1
  124. package/lib/rtp/src/extra/container/mp4/h264.d.ts +21 -17
  125. package/lib/rtp/src/extra/container/mp4/h264.js +26 -24
  126. package/lib/rtp/src/extra/container/mp4/h264.js.map +1 -1
  127. package/lib/rtp/src/extra/container/ogg/index.d.ts +1 -0
  128. package/lib/rtp/src/extra/container/ogg/index.js +1 -0
  129. package/lib/rtp/src/extra/container/ogg/index.js.map +1 -1
  130. package/lib/rtp/src/extra/container/ogg/writer.d.ts +90 -0
  131. package/lib/rtp/src/extra/container/ogg/writer.js +300 -0
  132. package/lib/rtp/src/extra/container/ogg/writer.js.map +1 -0
  133. package/lib/rtp/src/extra/container/webm/ebml/ebml.js +6 -3
  134. package/lib/rtp/src/extra/container/webm/ebml/ebml.js.map +1 -1
  135. package/lib/rtp/src/extra/processor/depacketizer.d.ts +5 -0
  136. package/lib/rtp/src/extra/processor/depacketizer.js +28 -2
  137. package/lib/rtp/src/extra/processor/depacketizer.js.map +1 -1
  138. package/lib/rtp/src/extra/processor/dtx.js +4 -2
  139. package/lib/rtp/src/extra/processor/dtx.js.map +1 -1
  140. package/lib/rtp/src/extra/processor/index.d.ts +2 -0
  141. package/lib/rtp/src/extra/processor/index.js +2 -0
  142. package/lib/rtp/src/extra/processor/index.js.map +1 -1
  143. package/lib/rtp/src/extra/processor/jitterBuffer.d.ts +29 -6
  144. package/lib/rtp/src/extra/processor/jitterBuffer.js +101 -111
  145. package/lib/rtp/src/extra/processor/jitterBuffer.js.map +1 -1
  146. package/lib/rtp/src/extra/processor/jitterBufferTransformer.js +2 -1
  147. package/lib/rtp/src/extra/processor/jitterBufferTransformer.js.map +1 -1
  148. package/lib/rtp/src/extra/processor/lipsync.d.ts +63 -0
  149. package/lib/rtp/src/extra/processor/lipsync.js +202 -51
  150. package/lib/rtp/src/extra/processor/lipsync.js.map +1 -1
  151. package/lib/rtp/src/extra/processor/mp4.d.ts +0 -6
  152. package/lib/rtp/src/extra/processor/mp4.js +6 -3
  153. package/lib/rtp/src/extra/processor/mp4.js.map +1 -1
  154. package/lib/rtp/src/extra/processor/mute.js +4 -2
  155. package/lib/rtp/src/extra/processor/mute.js.map +1 -1
  156. package/lib/rtp/src/extra/processor/nack.js +4 -2
  157. package/lib/rtp/src/extra/processor/nack.js.map +1 -1
  158. package/lib/rtp/src/extra/processor/ntpTime.js +4 -6
  159. package/lib/rtp/src/extra/processor/ntpTime.js.map +1 -1
  160. package/lib/rtp/src/extra/processor/ogg.d.ts +72 -0
  161. package/lib/rtp/src/extra/processor/ogg.js +221 -0
  162. package/lib/rtp/src/extra/processor/ogg.js.map +1 -0
  163. package/lib/rtp/src/extra/processor/oggCallback.d.ts +21 -0
  164. package/lib/rtp/src/extra/processor/oggCallback.js +97 -0
  165. package/lib/rtp/src/extra/processor/oggCallback.js.map +1 -0
  166. package/lib/rtp/src/extra/processor/rtpCallback.js +2 -1
  167. package/lib/rtp/src/extra/processor/rtpCallback.js.map +1 -1
  168. package/lib/rtp/src/extra/processor/rtpStream.js +2 -1
  169. package/lib/rtp/src/extra/processor/rtpStream.js.map +1 -1
  170. package/lib/rtp/src/extra/processor/rtpTime.js +2 -1
  171. package/lib/rtp/src/extra/processor/rtpTime.js.map +1 -1
  172. package/lib/rtp/src/extra/processor/webm.js +14 -7
  173. package/lib/rtp/src/extra/processor/webm.js.map +1 -1
  174. package/lib/rtp/src/extra/processor/webmCallback.js.map +1 -1
  175. package/lib/rtp/src/index.d.ts +7 -0
  176. package/lib/rtp/src/index.js +7 -0
  177. package/lib/rtp/src/index.js.map +1 -1
  178. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.d.ts +4 -0
  179. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js +4 -0
  180. package/lib/rtp/src/rtcp/psfb/fullIntraRequest.js.map +1 -1
  181. package/lib/rtp/src/rtcp/rtcp.js +8 -4
  182. package/lib/rtp/src/rtcp/rtcp.js.map +1 -1
  183. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.d.ts +58 -0
  184. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js +143 -0
  185. package/lib/rtp/src/rtcp/rtpfb/transportWideSequence.js.map +1 -0
  186. package/lib/rtp/src/rtcp/rtpfb/twcc.d.ts +35 -13
  187. package/lib/rtp/src/rtcp/rtpfb/twcc.js +132 -54
  188. package/lib/rtp/src/rtcp/rtpfb/twcc.js.map +1 -1
  189. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.d.ts +13 -0
  190. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js +29 -0
  191. package/lib/rtp/src/rtcp/rtpfb/twccReceiveTiming.js.map +1 -0
  192. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.d.ts +41 -0
  193. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js +89 -0
  194. package/lib/rtp/src/rtcp/rtpfb/twccReferenceTime.js.map +1 -0
  195. package/lib/rtp/src/rtcp/sr.js +1 -0
  196. package/lib/rtp/src/rtcp/sr.js.map +1 -1
  197. package/lib/rtp/src/rtp/continuity.d.ts +36 -0
  198. package/lib/rtp/src/rtp/continuity.js +100 -0
  199. package/lib/rtp/src/rtp/continuity.js.map +1 -0
  200. package/lib/rtp/src/rtp/headerExtension.js +41 -21
  201. package/lib/rtp/src/rtp/headerExtension.js.map +1 -1
  202. package/lib/rtp/src/rtp/padding.d.ts +17 -0
  203. package/lib/rtp/src/rtp/padding.js +37 -0
  204. package/lib/rtp/src/rtp/padding.js.map +1 -0
  205. package/lib/rtp/src/rtp/red/encoder.d.ts +10 -0
  206. package/lib/rtp/src/rtp/red/encoder.js +14 -1
  207. package/lib/rtp/src/rtp/red/encoder.js.map +1 -1
  208. package/lib/rtp/src/rtp/red/packet.js +24 -8
  209. package/lib/rtp/src/rtp/red/packet.js.map +1 -1
  210. package/lib/rtp/src/rtp/rtp.d.ts +24 -1
  211. package/lib/rtp/src/rtp/rtp.js +70 -29
  212. package/lib/rtp/src/rtp/rtp.js.map +1 -1
  213. package/lib/rtp/src/rtp/rtx.js +3 -0
  214. package/lib/rtp/src/rtp/rtx.js.map +1 -1
  215. package/lib/rtp/src/rtp/sendHeaderExtensions.d.ts +36 -0
  216. package/lib/rtp/src/rtp/sendHeaderExtensions.js +85 -0
  217. package/lib/rtp/src/rtp/sendHeaderExtensions.js.map +1 -0
  218. package/lib/rtp/src/srtp/cipher/ctr.js +4 -2
  219. package/lib/rtp/src/srtp/cipher/ctr.js.map +1 -1
  220. package/lib/rtp/src/srtp/cipher/index.js +8 -4
  221. package/lib/rtp/src/srtp/cipher/index.js.map +1 -1
  222. package/lib/rtp/src/srtp/context/context.js +6 -3
  223. package/lib/rtp/src/srtp/context/context.js.map +1 -1
  224. package/lib/rtp/src/srtp/context/srtcp.d.ts +1 -1
  225. package/lib/rtp/src/srtp/context/srtcp.js +33 -0
  226. package/lib/rtp/src/srtp/context/srtcp.js.map +1 -1
  227. package/lib/rtp/src/srtp/context/srtp.d.ts +1 -1
  228. package/lib/rtp/src/srtp/context/srtp.js +34 -10
  229. package/lib/rtp/src/srtp/context/srtp.js.map +1 -1
  230. package/lib/rtp/src/srtp/error.d.ts +8 -0
  231. package/lib/rtp/src/srtp/error.js +13 -1
  232. package/lib/rtp/src/srtp/error.js.map +1 -1
  233. package/lib/rtp/src/srtp/packet.js +4 -1
  234. package/lib/rtp/src/srtp/packet.js.map +1 -1
  235. package/lib/rtp/src/srtp/replay.d.ts +24 -0
  236. package/lib/rtp/src/srtp/replay.js +75 -0
  237. package/lib/rtp/src/srtp/replay.js.map +1 -0
  238. package/lib/rtp/src/srtp/session.js +2 -1
  239. package/lib/rtp/src/srtp/session.js.map +1 -1
  240. package/lib/rtp/src/srtp/srtcp.js +2 -1
  241. package/lib/rtp/src/srtp/srtcp.js.map +1 -1
  242. package/lib/rtp/src/srtp/srtp.js +2 -1
  243. package/lib/rtp/src/srtp/srtp.js.map +1 -1
  244. package/lib/rtp/src/util.js +2 -1
  245. package/lib/rtp/src/util.js.map +1 -1
  246. package/lib/sctp/src/chunk.d.ts +5 -0
  247. package/lib/sctp/src/chunk.js +31 -8
  248. package/lib/sctp/src/chunk.js.map +1 -1
  249. package/lib/sctp/src/const.d.ts +25 -17
  250. package/lib/sctp/src/const.js +23 -19
  251. package/lib/sctp/src/const.js.map +1 -1
  252. package/lib/sctp/src/param.d.ts +6 -2
  253. package/lib/sctp/src/param.js +22 -8
  254. package/lib/sctp/src/param.js.map +1 -1
  255. package/lib/sctp/src/sctp.d.ts +80 -0
  256. package/lib/sctp/src/sctp.js +655 -108
  257. package/lib/sctp/src/sctp.js.map +1 -1
  258. package/lib/sctp/src/transport.js +4 -2
  259. package/lib/sctp/src/transport.js.map +1 -1
  260. package/lib/webrtc/src/api/peerConfig.d.ts +48 -5
  261. package/lib/webrtc/src/api/peerConfig.js +41 -0
  262. package/lib/webrtc/src/api/peerConfig.js.map +1 -1
  263. package/lib/webrtc/src/dataChannel.d.ts +10 -0
  264. package/lib/webrtc/src/dataChannel.js +24 -4
  265. package/lib/webrtc/src/dataChannel.js.map +1 -1
  266. package/lib/webrtc/src/media/index.d.ts +10 -0
  267. package/lib/webrtc/src/media/index.js +70 -0
  268. package/lib/webrtc/src/media/index.js.map +1 -1
  269. package/lib/webrtc/src/media/receiver/nack.js +2 -1
  270. package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
  271. package/lib/webrtc/src/media/receiver/receiverTwcc.d.ts +61 -1
  272. package/lib/webrtc/src/media/receiver/receiverTwcc.js +218 -63
  273. package/lib/webrtc/src/media/receiver/receiverTwcc.js.map +1 -1
  274. package/lib/webrtc/src/media/router.d.ts +14 -1
  275. package/lib/webrtc/src/media/router.js +46 -2
  276. package/lib/webrtc/src/media/router.js.map +1 -1
  277. package/lib/webrtc/src/media/rtpReceiver.d.ts +30 -2
  278. package/lib/webrtc/src/media/rtpReceiver.js +175 -26
  279. package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
  280. package/lib/webrtc/src/media/rtpSender.d.ts +184 -70
  281. package/lib/webrtc/src/media/rtpSender.js +626 -449
  282. package/lib/webrtc/src/media/rtpSender.js.map +1 -1
  283. package/lib/webrtc/src/media/rtpTransceiver.d.ts +1 -3
  284. package/lib/webrtc/src/media/rtpTransceiver.js +10 -7
  285. package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
  286. package/lib/webrtc/src/media/sender/bandwidthEstimator.d.ts +249 -0
  287. package/lib/webrtc/src/media/sender/bandwidthEstimator.js +144 -0
  288. package/lib/webrtc/src/media/sender/bandwidthEstimator.js.map +1 -0
  289. package/lib/webrtc/src/media/sender/createBandwidthEstimator.d.ts +20 -0
  290. package/lib/webrtc/src/media/sender/createBandwidthEstimator.js +26 -0
  291. package/lib/webrtc/src/media/sender/createBandwidthEstimator.js.map +1 -0
  292. package/lib/webrtc/src/media/sender/estimatorBinding.d.ts +70 -0
  293. package/lib/webrtc/src/media/sender/estimatorBinding.js +175 -0
  294. package/lib/webrtc/src/media/sender/estimatorBinding.js.map +1 -0
  295. package/lib/webrtc/src/media/sender/estimators/disabledBwe.d.ts +18 -0
  296. package/lib/webrtc/src/media/sender/estimators/disabledBwe.js +44 -0
  297. package/lib/webrtc/src/media/sender/estimators/disabledBwe.js.map +1 -0
  298. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.d.ts +79 -0
  299. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js +289 -0
  300. package/lib/webrtc/src/media/sender/estimators/gcc/acknowledgedBitrateEstimator.js.map +1 -0
  301. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.d.ts +87 -0
  302. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js +429 -0
  303. package/lib/webrtc/src/media/sender/estimators/gcc/aimdRateControl.js.map +1 -0
  304. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.d.ts +21 -0
  305. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js +84 -0
  306. package/lib/webrtc/src/media/sender/estimators/gcc/alrDetector.js.map +1 -0
  307. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.d.ts +37 -0
  308. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js +74 -0
  309. package/lib/webrtc/src/media/sender/estimators/gcc/bandwidthLimitedCause.js.map +1 -0
  310. package/lib/webrtc/src/media/sender/estimators/gcc/constants.d.ts +383 -0
  311. package/lib/webrtc/src/media/sender/estimators/gcc/constants.js +408 -0
  312. package/lib/webrtc/src/media/sender/estimators/gcc/constants.js.map +1 -0
  313. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.d.ts +406 -0
  314. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js +1391 -0
  315. package/lib/webrtc/src/media/sender/estimators/gcc/gccBwe.js.map +1 -0
  316. package/lib/webrtc/src/media/sender/estimators/gcc/index.d.ts +19 -0
  317. package/lib/webrtc/src/media/sender/estimators/gcc/index.js +75 -0
  318. package/lib/webrtc/src/media/sender/estimators/gcc/index.js.map +1 -0
  319. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.d.ts +68 -0
  320. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js +201 -0
  321. package/lib/webrtc/src/media/sender/estimators/gcc/interArrivalDelta.js.map +1 -0
  322. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.d.ts +26 -0
  323. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js +72 -0
  324. package/lib/webrtc/src/media/sender/estimators/gcc/intervalBudget.js.map +1 -0
  325. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.d.ts +41 -0
  326. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js +99 -0
  327. package/lib/webrtc/src/media/sender/estimators/gcc/linkCapacityEstimator.js.map +1 -0
  328. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.d.ts +247 -0
  329. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js +1042 -0
  330. package/lib/webrtc/src/media/sender/estimators/gcc/lossBasedBwe.js.map +1 -0
  331. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.d.ts +26 -0
  332. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js +132 -0
  333. package/lib/webrtc/src/media/sender/estimators/gcc/overuseDetector.js.map +1 -0
  334. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.d.ts +305 -0
  335. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js +1073 -0
  336. package/lib/webrtc/src/media/sender/estimators/gcc/probeController.js.map +1 -0
  337. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.d.ts +60 -0
  338. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js +151 -0
  339. package/lib/webrtc/src/media/sender/estimators/gcc/rttBasedBackoff.js.map +1 -0
  340. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.d.ts +44 -0
  341. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js +246 -0
  342. package/lib/webrtc/src/media/sender/estimators/gcc/trendlineEstimator.js.map +1 -0
  343. package/lib/webrtc/src/media/sender/estimators/index.d.ts +7 -0
  344. package/lib/webrtc/src/media/sender/estimators/index.js +19 -0
  345. package/lib/webrtc/src/media/sender/estimators/index.js.map +1 -0
  346. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.d.ts +64 -0
  347. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js +216 -0
  348. package/lib/webrtc/src/media/sender/estimators/lightweightBwe.js.map +1 -0
  349. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.d.ts +117 -0
  350. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js +250 -0
  351. package/lib/webrtc/src/media/sender/estimators/twccFeedbackAdapter.js.map +1 -0
  352. package/lib/webrtc/src/media/sender/outgoingQueue.d.ts +40 -0
  353. package/lib/webrtc/src/media/sender/outgoingQueue.js +153 -0
  354. package/lib/webrtc/src/media/sender/outgoingQueue.js.map +1 -0
  355. package/lib/webrtc/src/media/sender/padding.d.ts +45 -0
  356. package/lib/webrtc/src/media/sender/padding.js +134 -0
  357. package/lib/webrtc/src/media/sender/padding.js.map +1 -0
  358. package/lib/webrtc/src/media/sender/pendingRtp.d.ts +35 -0
  359. package/lib/webrtc/src/media/sender/pendingRtp.js +120 -0
  360. package/lib/webrtc/src/media/sender/pendingRtp.js.map +1 -0
  361. package/lib/webrtc/src/media/sender/rtpWire.d.ts +13 -0
  362. package/lib/webrtc/src/media/sender/rtpWire.js +38 -0
  363. package/lib/webrtc/src/media/sender/rtpWire.js.map +1 -0
  364. package/lib/webrtc/src/media/sender/sendPacer.d.ts +27 -0
  365. package/lib/webrtc/src/media/sender/sendPacer.js +110 -0
  366. package/lib/webrtc/src/media/sender/sendPacer.js.map +1 -0
  367. package/lib/webrtc/src/media/sender/senderBWE.d.ts +8 -33
  368. package/lib/webrtc/src/media/sender/senderBWE.js +5 -154
  369. package/lib/webrtc/src/media/sender/senderBWE.js.map +1 -1
  370. package/lib/webrtc/src/media/sender/senderStats.d.ts +100 -0
  371. package/lib/webrtc/src/media/sender/senderStats.js +322 -0
  372. package/lib/webrtc/src/media/sender/senderStats.js.map +1 -0
  373. package/lib/webrtc/src/media/track.d.ts +20 -2
  374. package/lib/webrtc/src/media/track.js +23 -5
  375. package/lib/webrtc/src/media/track.js.map +1 -1
  376. package/lib/webrtc/src/negotiation/bundleTopology.d.ts +1 -5
  377. package/lib/webrtc/src/negotiation/bundleTopology.js +15 -11
  378. package/lib/webrtc/src/negotiation/bundleTopology.js.map +1 -1
  379. package/lib/webrtc/src/negotiation/descriptionValidation.js +12 -6
  380. package/lib/webrtc/src/negotiation/descriptionValidation.js.map +1 -1
  381. package/lib/webrtc/src/negotiation/negotiationNeeded.js +2 -1
  382. package/lib/webrtc/src/negotiation/negotiationNeeded.js.map +1 -1
  383. package/lib/webrtc/src/negotiation/remoteCandidates.js +10 -5
  384. package/lib/webrtc/src/negotiation/remoteCandidates.js.map +1 -1
  385. package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +1 -1
  386. package/lib/webrtc/src/negotiation/remoteMediaApplication.js +22 -6
  387. package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
  388. package/lib/webrtc/src/negotiation/transportActivation.js +19 -8
  389. package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
  390. package/lib/webrtc/src/negotiationTransaction.d.ts +8 -1
  391. package/lib/webrtc/src/negotiationTransaction.js +18 -5
  392. package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
  393. package/lib/webrtc/src/nonstandard/dummyMedia.js +2 -1
  394. package/lib/webrtc/src/nonstandard/dummyMedia.js.map +1 -1
  395. package/lib/webrtc/src/nonstandard/navigator.js +4 -3
  396. package/lib/webrtc/src/nonstandard/navigator.js.map +1 -1
  397. package/lib/webrtc/src/nonstandard/recorder/index.d.ts +32 -8
  398. package/lib/webrtc/src/nonstandard/recorder/index.js +81 -20
  399. package/lib/webrtc/src/nonstandard/recorder/index.js.map +1 -1
  400. package/lib/webrtc/src/nonstandard/recorder/writer/index.d.ts +9 -7
  401. package/lib/webrtc/src/nonstandard/recorder/writer/index.js +2 -1
  402. package/lib/webrtc/src/nonstandard/recorder/writer/index.js.map +1 -1
  403. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.d.ts +32 -0
  404. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js +185 -0
  405. package/lib/webrtc/src/nonstandard/recorder/writer/ogg.js.map +1 -0
  406. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js +8 -1
  407. package/lib/webrtc/src/nonstandard/recorder/writer/webm.js.map +1 -1
  408. package/lib/webrtc/src/nonstandard/userMedia.js +2 -1
  409. package/lib/webrtc/src/nonstandard/userMedia.js.map +1 -1
  410. package/lib/webrtc/src/peerConnection.d.ts +44 -1
  411. package/lib/webrtc/src/peerConnection.js +74 -8
  412. package/lib/webrtc/src/peerConnection.js.map +1 -1
  413. package/lib/webrtc/src/polyfill/mediaDevices.js +2 -1
  414. package/lib/webrtc/src/polyfill/mediaDevices.js.map +1 -1
  415. package/lib/webrtc/src/sctpManager.d.ts +46 -14
  416. package/lib/webrtc/src/sctpManager.js +88 -25
  417. package/lib/webrtc/src/sctpManager.js.map +1 -1
  418. package/lib/webrtc/src/sdp.js +12 -6
  419. package/lib/webrtc/src/sdp.js.map +1 -1
  420. package/lib/webrtc/src/secureTransportManager.d.ts +52 -4
  421. package/lib/webrtc/src/secureTransportManager.js +106 -23
  422. package/lib/webrtc/src/secureTransportManager.js.map +1 -1
  423. package/lib/webrtc/src/transceiverManager.js +8 -3
  424. package/lib/webrtc/src/transceiverManager.js.map +1 -1
  425. package/lib/webrtc/src/transport/dtls.d.ts +53 -1
  426. package/lib/webrtc/src/transport/dtls.js +131 -31
  427. package/lib/webrtc/src/transport/dtls.js.map +1 -1
  428. package/lib/webrtc/src/transport/ice.d.ts +10 -86
  429. package/lib/webrtc/src/transport/ice.js +70 -31
  430. package/lib/webrtc/src/transport/ice.js.map +1 -1
  431. package/lib/webrtc/src/transport/sctp.d.ts +2 -0
  432. package/lib/webrtc/src/transport/sctp.js +66 -20
  433. package/lib/webrtc/src/transport/sctp.js.map +1 -1
  434. package/lib/webrtc/src/utils.d.ts +36 -3
  435. package/lib/webrtc/src/utils.js +56 -16
  436. package/lib/webrtc/src/utils.js.map +1 -1
  437. package/package.json +8 -6
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrendlineEstimator = void 0;
4
+ /*!
5
+ * Portions of this file are ported from libwebrtc
6
+ * (https://webrtc.googlesource.com/src, commit 0fda16159e33adf59c71a7ad1173dcbe5a632102).
7
+ * Copyright (c) 2011, The WebRTC project authors. All rights reserved.
8
+ * Use of that source is governed by a BSD-style license and an additional
9
+ * patent grant; both are reproduced in THIRD_PARTY_LICENSES_LIBWEBRTC.txt
10
+ * (shipped with this package).
11
+ */
12
+ const constants_1 = require("./constants");
13
+ /**
14
+ * libwebrtc TrendlineEstimator port
15
+ * (`modules/congestion_controller/goog_cc/trendline_estimator.cc`).
16
+ *
17
+ * - Exponentially smoothed accumulated delay
18
+ * - Linear regression slope only when the history window is **full**
19
+ * - `modified_trend = min(num_deltas, 60) * trend * 4.0`
20
+ * - Adaptive threshold with k_up=0.0087 / k_down=0.039
21
+ * - Overuse / underuse / normal hypothesis (same role as OveruseDetector)
22
+ */
23
+ class TrendlineEstimator {
24
+ constructor() {
25
+ Object.defineProperty(this, "numOfDeltas", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: 0
30
+ });
31
+ Object.defineProperty(this, "firstArrivalTimeMs", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: -1
36
+ });
37
+ Object.defineProperty(this, "accumulatedDelay", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: 0
42
+ });
43
+ Object.defineProperty(this, "smoothedDelay", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: 0
48
+ });
49
+ Object.defineProperty(this, "delayHist", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: []
54
+ });
55
+ Object.defineProperty(this, "prevTrend", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: 0
60
+ });
61
+ Object.defineProperty(this, "threshold", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: constants_1.kInitialThresholdMs
66
+ });
67
+ Object.defineProperty(this, "timeOverUsing", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: -1
72
+ });
73
+ Object.defineProperty(this, "overuseCounter", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: 0
78
+ });
79
+ Object.defineProperty(this, "hypothesis", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: "normal"
84
+ });
85
+ Object.defineProperty(this, "lastUpdateMs", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: -1
90
+ });
91
+ Object.defineProperty(this, "prevModifiedTrend", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: 0
96
+ });
97
+ }
98
+ reset() {
99
+ this.numOfDeltas = 0;
100
+ this.firstArrivalTimeMs = -1;
101
+ this.accumulatedDelay = 0;
102
+ this.smoothedDelay = 0;
103
+ this.delayHist.length = 0;
104
+ this.prevTrend = 0;
105
+ this.threshold = constants_1.kInitialThresholdMs;
106
+ this.timeOverUsing = -1;
107
+ this.overuseCounter = 0;
108
+ this.hypothesis = "normal";
109
+ this.lastUpdateMs = -1;
110
+ this.prevModifiedTrend = 0;
111
+ }
112
+ get state() {
113
+ return this.hypothesis;
114
+ }
115
+ get sampleCount() {
116
+ return this.delayHist.length;
117
+ }
118
+ get numDeltas() {
119
+ return this.numOfDeltas;
120
+ }
121
+ get trend() {
122
+ return this.prevTrend;
123
+ }
124
+ get modifiedTrend() {
125
+ return this.prevModifiedTrend;
126
+ }
127
+ get adaptiveThreshold() {
128
+ return this.threshold;
129
+ }
130
+ /**
131
+ * @param recvDeltaMs inter-arrival (ms)
132
+ * @param sendDeltaMs inter-departure (ms) — also drives overuse timer
133
+ * @param arrivalTimeMs absolute arrival time
134
+ * @returns modified trend (for tests / logging)
135
+ */
136
+ update(recvDeltaMs, sendDeltaMs, arrivalTimeMs) {
137
+ const deltaMs = recvDeltaMs - sendDeltaMs;
138
+ this.numOfDeltas = Math.min(this.numOfDeltas + 1, constants_1.kTrendlineDeltaCounterMax);
139
+ if (this.firstArrivalTimeMs === -1) {
140
+ this.firstArrivalTimeMs = arrivalTimeMs;
141
+ }
142
+ this.accumulatedDelay += deltaMs;
143
+ this.smoothedDelay =
144
+ constants_1.kTrendlineSmoothingCoeff * this.smoothedDelay +
145
+ (1 - constants_1.kTrendlineSmoothingCoeff) * this.accumulatedDelay;
146
+ this.delayHist.push({
147
+ arrivalTimeMs: arrivalTimeMs - this.firstArrivalTimeMs,
148
+ smoothedDelayMs: this.smoothedDelay,
149
+ rawDelayMs: this.accumulatedDelay,
150
+ });
151
+ if (this.delayHist.length > constants_1.kTrendlineWindowSize) {
152
+ this.delayHist.shift();
153
+ }
154
+ // libwebrtc: only recompute slope when the window is full.
155
+ let trend = this.prevTrend;
156
+ if (this.delayHist.length === constants_1.kTrendlineWindowSize) {
157
+ trend = linearFitSlope(this.delayHist) ?? trend;
158
+ }
159
+ this.detect(trend, sendDeltaMs, arrivalTimeMs);
160
+ return this.prevModifiedTrend;
161
+ }
162
+ /**
163
+ * libwebrtc TrendlineEstimator::Detect
164
+ */
165
+ detect(trend, tsDeltaMs, nowMs) {
166
+ if (this.numOfDeltas < 2) {
167
+ this.hypothesis = "normal";
168
+ return;
169
+ }
170
+ const modifiedTrend = Math.min(this.numOfDeltas, constants_1.kTrendlineMinNumDeltas) *
171
+ trend *
172
+ constants_1.kTrendlineThresholdGain;
173
+ this.prevModifiedTrend = modifiedTrend;
174
+ if (modifiedTrend > this.threshold) {
175
+ if (this.timeOverUsing === -1) {
176
+ // Assume over-using half the time since previous sample.
177
+ this.timeOverUsing = tsDeltaMs / 2;
178
+ }
179
+ else {
180
+ this.timeOverUsing += tsDeltaMs;
181
+ }
182
+ this.overuseCounter++;
183
+ if (this.timeOverUsing > constants_1.kOveruseTimeThresholdMs &&
184
+ this.overuseCounter > 1) {
185
+ if (trend >= this.prevTrend) {
186
+ this.timeOverUsing = 0;
187
+ this.overuseCounter = 0;
188
+ this.hypothesis = "overuse";
189
+ }
190
+ }
191
+ }
192
+ else if (modifiedTrend < -this.threshold) {
193
+ this.timeOverUsing = -1;
194
+ this.overuseCounter = 0;
195
+ this.hypothesis = "underuse";
196
+ }
197
+ else {
198
+ this.timeOverUsing = -1;
199
+ this.overuseCounter = 0;
200
+ this.hypothesis = "normal";
201
+ }
202
+ this.prevTrend = trend;
203
+ this.updateThreshold(modifiedTrend, nowMs);
204
+ }
205
+ updateThreshold(modifiedTrend, nowMs) {
206
+ if (this.lastUpdateMs === -1) {
207
+ this.lastUpdateMs = nowMs;
208
+ }
209
+ if (Math.abs(modifiedTrend) > this.threshold + constants_1.kMaxAdaptOffsetMs) {
210
+ this.lastUpdateMs = nowMs;
211
+ return;
212
+ }
213
+ const k = Math.abs(modifiedTrend) < this.threshold
214
+ ? constants_1.kThresholdGainDown
215
+ : constants_1.kThresholdGainUp;
216
+ const timeDeltaMs = Math.min(nowMs - this.lastUpdateMs, 100);
217
+ this.threshold +=
218
+ k * (Math.abs(modifiedTrend) - this.threshold) * timeDeltaMs;
219
+ this.threshold = Math.min(Math.max(this.threshold, constants_1.kMinThresholdMs), constants_1.kMaxThresholdMs);
220
+ this.lastUpdateMs = nowMs;
221
+ }
222
+ }
223
+ exports.TrendlineEstimator = TrendlineEstimator;
224
+ function linearFitSlope(packets) {
225
+ if (packets.length < 2)
226
+ return undefined;
227
+ let sumX = 0;
228
+ let sumY = 0;
229
+ for (const p of packets) {
230
+ sumX += p.arrivalTimeMs;
231
+ sumY += p.smoothedDelayMs;
232
+ }
233
+ const xAvg = sumX / packets.length;
234
+ const yAvg = sumY / packets.length;
235
+ let numerator = 0;
236
+ let denominator = 0;
237
+ for (const p of packets) {
238
+ const dx = p.arrivalTimeMs - xAvg;
239
+ numerator += dx * (p.smoothedDelayMs - yAvg);
240
+ denominator += dx * dx;
241
+ }
242
+ if (denominator === 0)
243
+ return undefined;
244
+ return numerator / denominator;
245
+ }
246
+ //# sourceMappingURL=trendlineEstimator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trendlineEstimator.js","sourceRoot":"","sources":["../../../../../../../src/media/sender/estimators/gcc/trendlineEstimator.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,2CAaqB;AAUrB;;;;;;;;;GASG;AACH,MAAa,kBAAkB;IAA/B;QACU;;;;mBAAc,CAAC;WAAC;QAChB;;;;mBAAqB,CAAC,CAAC;WAAC;QACxB;;;;mBAAmB,CAAC;WAAC;QACrB;;;;mBAAgB,CAAC;WAAC;QACT;;;;mBAA4B,EAAE;WAAC;QACxC;;;;mBAAY,CAAC;WAAC;QACd;;;;mBAAY,+BAAmB;WAAC;QAChC;;;;mBAAgB,CAAC,CAAC;WAAC;QACnB;;;;mBAAiB,CAAC;WAAC;QACnB;;;;mBAA6B,QAAQ;WAAC;QACtC;;;;mBAAe,CAAC,CAAC;WAAC;QAClB;;;;mBAAoB,CAAC;WAAC;IA2JhC,CAAC;IAzJC,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,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G,IAAI,CAAC;QAClC,SAAS,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;QAC7C,WAAW,IAAI,EAAE,GAAG,EAAE,CAAC;IACzB,CAAC;IACD,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO,SAAS,GAAG,WAAW,CAAC;AACjC,CAAC","sourcesContent":["/*!\n * Portions of this file are ported from libwebrtc\n * (https://webrtc.googlesource.com/src, commit 0fda16159e33adf59c71a7ad1173dcbe5a632102).\n * Copyright (c) 2011, The WebRTC project authors. All rights reserved.\n * Use of that source is governed by a BSD-style license and an additional\n * patent grant; both are reproduced in THIRD_PARTY_LICENSES_LIBWEBRTC.txt\n * (shipped with this package).\n */\nimport {\n kInitialThresholdMs,\n kMaxAdaptOffsetMs,\n kMaxThresholdMs,\n kMinThresholdMs,\n kOveruseTimeThresholdMs,\n kThresholdGainDown,\n kThresholdGainUp,\n kTrendlineDeltaCounterMax,\n kTrendlineMinNumDeltas,\n kTrendlineSmoothingCoeff,\n kTrendlineThresholdGain,\n kTrendlineWindowSize,\n} from \"./constants\";\nimport type { BandwidthUsage } from \"./overuseDetector\";\n\ninterface PacketTiming {\n /** Arrival time relative to first sample (ms). */\n arrivalTimeMs: number;\n smoothedDelayMs: number;\n rawDelayMs: number;\n}\n\n/**\n * libwebrtc TrendlineEstimator port\n * (`modules/congestion_controller/goog_cc/trendline_estimator.cc`).\n *\n * - Exponentially smoothed accumulated delay\n * - Linear regression slope only when the history window is **full**\n * - `modified_trend = min(num_deltas, 60) * trend * 4.0`\n * - Adaptive threshold with k_up=0.0087 / k_down=0.039\n * - Overuse / underuse / normal hypothesis (same role as OveruseDetector)\n */\nexport class TrendlineEstimator {\n private numOfDeltas = 0;\n private firstArrivalTimeMs = -1;\n private accumulatedDelay = 0;\n private smoothedDelay = 0;\n private readonly delayHist: PacketTiming[] = [];\n private prevTrend = 0;\n private threshold = kInitialThresholdMs;\n private timeOverUsing = -1;\n private overuseCounter = 0;\n private hypothesis: BandwidthUsage = \"normal\";\n private lastUpdateMs = -1;\n private prevModifiedTrend = 0;\n\n reset() {\n this.numOfDeltas = 0;\n this.firstArrivalTimeMs = -1;\n this.accumulatedDelay = 0;\n this.smoothedDelay = 0;\n this.delayHist.length = 0;\n this.prevTrend = 0;\n this.threshold = kInitialThresholdMs;\n this.timeOverUsing = -1;\n this.overuseCounter = 0;\n this.hypothesis = \"normal\";\n this.lastUpdateMs = -1;\n this.prevModifiedTrend = 0;\n }\n\n get state(): BandwidthUsage {\n return this.hypothesis;\n }\n\n get sampleCount() {\n return this.delayHist.length;\n }\n\n get numDeltas() {\n return this.numOfDeltas;\n }\n\n get trend() {\n return this.prevTrend;\n }\n\n get modifiedTrend() {\n return this.prevModifiedTrend;\n }\n\n get adaptiveThreshold() {\n return this.threshold;\n }\n\n /**\n * @param recvDeltaMs inter-arrival (ms)\n * @param sendDeltaMs inter-departure (ms) — also drives overuse timer\n * @param arrivalTimeMs absolute arrival time\n * @returns modified trend (for tests / logging)\n */\n update(\n recvDeltaMs: number,\n sendDeltaMs: number,\n arrivalTimeMs: number,\n ): number {\n const deltaMs = recvDeltaMs - sendDeltaMs;\n this.numOfDeltas = Math.min(\n this.numOfDeltas + 1,\n kTrendlineDeltaCounterMax,\n );\n if (this.firstArrivalTimeMs === -1) {\n this.firstArrivalTimeMs = arrivalTimeMs;\n }\n\n this.accumulatedDelay += deltaMs;\n this.smoothedDelay =\n kTrendlineSmoothingCoeff * this.smoothedDelay +\n (1 - kTrendlineSmoothingCoeff) * this.accumulatedDelay;\n\n this.delayHist.push({\n arrivalTimeMs: arrivalTimeMs - this.firstArrivalTimeMs,\n smoothedDelayMs: this.smoothedDelay,\n rawDelayMs: this.accumulatedDelay,\n });\n if (this.delayHist.length > kTrendlineWindowSize) {\n this.delayHist.shift();\n }\n\n // libwebrtc: only recompute slope when the window is full.\n let trend = this.prevTrend;\n if (this.delayHist.length === kTrendlineWindowSize) {\n trend = linearFitSlope(this.delayHist) ?? trend;\n }\n\n this.detect(trend, sendDeltaMs, arrivalTimeMs);\n return this.prevModifiedTrend;\n }\n\n /**\n * libwebrtc TrendlineEstimator::Detect\n */\n private detect(trend: number, tsDeltaMs: number, nowMs: number) {\n if (this.numOfDeltas < 2) {\n this.hypothesis = \"normal\";\n return;\n }\n\n const modifiedTrend =\n Math.min(this.numOfDeltas, kTrendlineMinNumDeltas) *\n trend *\n kTrendlineThresholdGain;\n this.prevModifiedTrend = modifiedTrend;\n\n if (modifiedTrend > this.threshold) {\n if (this.timeOverUsing === -1) {\n // Assume over-using half the time since previous sample.\n this.timeOverUsing = tsDeltaMs / 2;\n } else {\n this.timeOverUsing += tsDeltaMs;\n }\n this.overuseCounter++;\n if (\n this.timeOverUsing > kOveruseTimeThresholdMs &&\n this.overuseCounter > 1\n ) {\n if (trend >= this.prevTrend) {\n this.timeOverUsing = 0;\n this.overuseCounter = 0;\n this.hypothesis = \"overuse\";\n }\n }\n } else if (modifiedTrend < -this.threshold) {\n this.timeOverUsing = -1;\n this.overuseCounter = 0;\n this.hypothesis = \"underuse\";\n } else {\n this.timeOverUsing = -1;\n this.overuseCounter = 0;\n this.hypothesis = \"normal\";\n }\n\n this.prevTrend = trend;\n this.updateThreshold(modifiedTrend, nowMs);\n }\n\n private updateThreshold(modifiedTrend: number, nowMs: number) {\n if (this.lastUpdateMs === -1) {\n this.lastUpdateMs = nowMs;\n }\n\n if (Math.abs(modifiedTrend) > this.threshold + kMaxAdaptOffsetMs) {\n this.lastUpdateMs = nowMs;\n return;\n }\n\n const k =\n Math.abs(modifiedTrend) < this.threshold\n ? kThresholdGainDown\n : kThresholdGainUp;\n const timeDeltaMs = Math.min(nowMs - this.lastUpdateMs, 100);\n this.threshold +=\n k * (Math.abs(modifiedTrend) - this.threshold) * timeDeltaMs;\n this.threshold = Math.min(\n Math.max(this.threshold, kMinThresholdMs),\n kMaxThresholdMs,\n );\n this.lastUpdateMs = nowMs;\n }\n}\n\nfunction linearFitSlope(packets: PacketTiming[]): number | undefined {\n if (packets.length < 2) return undefined;\n let sumX = 0;\n let sumY = 0;\n for (const p of packets) {\n sumX += p.arrivalTimeMs;\n sumY += p.smoothedDelayMs;\n }\n const xAvg = sumX / packets.length;\n const yAvg = sumY / packets.length;\n let numerator = 0;\n let denominator = 0;\n for (const p of packets) {\n const dx = p.arrivalTimeMs - xAvg;\n numerator += dx * (p.smoothedDelayMs - yAvg);\n denominator += dx * dx;\n }\n if (denominator === 0) return undefined;\n return numerator / denominator;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export type { BandwidthEstimator, SentInfo } from "../bandwidthEstimator";
2
+ export { DisabledBandwidthEstimator } from "./disabledBwe";
3
+ export type { BandwidthUsage, ProbeState } from "./gcc";
4
+ export { GCC_KNOWN_DIFFERENCES, GccBandwidthEstimator, kDefaultStartBitrateBps, kMaxBitrateBps, kMinBitrateBps, } from "./gcc";
5
+ export { isLightweightBandwidthEstimator, LightweightBandwidthEstimator, SenderBandwidthEstimator, } from "./lightweightBwe";
6
+ export type { TwccPacketFeedback } from "./twccFeedbackAdapter";
7
+ export { kTwccFeedbackHistoryMaxSeqSpan, TwccFeedbackAdapter, } from "./twccFeedbackAdapter";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TwccFeedbackAdapter = exports.kTwccFeedbackHistoryMaxSeqSpan = exports.SenderBandwidthEstimator = exports.LightweightBandwidthEstimator = exports.isLightweightBandwidthEstimator = exports.kMinBitrateBps = exports.kMaxBitrateBps = exports.kDefaultStartBitrateBps = exports.GccBandwidthEstimator = exports.GCC_KNOWN_DIFFERENCES = exports.DisabledBandwidthEstimator = void 0;
4
+ var disabledBwe_1 = require("./disabledBwe");
5
+ Object.defineProperty(exports, "DisabledBandwidthEstimator", { enumerable: true, get: function () { return disabledBwe_1.DisabledBandwidthEstimator; } });
6
+ var gcc_1 = require("./gcc");
7
+ Object.defineProperty(exports, "GCC_KNOWN_DIFFERENCES", { enumerable: true, get: function () { return gcc_1.GCC_KNOWN_DIFFERENCES; } });
8
+ Object.defineProperty(exports, "GccBandwidthEstimator", { enumerable: true, get: function () { return gcc_1.GccBandwidthEstimator; } });
9
+ Object.defineProperty(exports, "kDefaultStartBitrateBps", { enumerable: true, get: function () { return gcc_1.kDefaultStartBitrateBps; } });
10
+ Object.defineProperty(exports, "kMaxBitrateBps", { enumerable: true, get: function () { return gcc_1.kMaxBitrateBps; } });
11
+ Object.defineProperty(exports, "kMinBitrateBps", { enumerable: true, get: function () { return gcc_1.kMinBitrateBps; } });
12
+ var lightweightBwe_1 = require("./lightweightBwe");
13
+ Object.defineProperty(exports, "isLightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.isLightweightBandwidthEstimator; } });
14
+ Object.defineProperty(exports, "LightweightBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.LightweightBandwidthEstimator; } });
15
+ Object.defineProperty(exports, "SenderBandwidthEstimator", { enumerable: true, get: function () { return lightweightBwe_1.SenderBandwidthEstimator; } });
16
+ var twccFeedbackAdapter_1 = require("./twccFeedbackAdapter");
17
+ Object.defineProperty(exports, "kTwccFeedbackHistoryMaxSeqSpan", { enumerable: true, get: function () { return twccFeedbackAdapter_1.kTwccFeedbackHistoryMaxSeqSpan; } });
18
+ Object.defineProperty(exports, "TwccFeedbackAdapter", { enumerable: true, get: function () { return twccFeedbackAdapter_1.TwccFeedbackAdapter; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/media/sender/estimators/index.ts"],"names":[],"mappings":";;;AACA,6CAA2D;AAAlD,yHAAA,0BAA0B,OAAA;AAEnC,6BAMe;AALb,4GAAA,qBAAqB,OAAA;AACrB,4GAAA,qBAAqB,OAAA;AACrB,8GAAA,uBAAuB,OAAA;AACvB,qGAAA,cAAc,OAAA;AACd,qGAAA,cAAc,OAAA;AAEhB,mDAI0B;AAHxB,iIAAA,+BAA+B,OAAA;AAC/B,+HAAA,6BAA6B,OAAA;AAC7B,0HAAA,wBAAwB,OAAA;AAG1B,6DAG+B;AAF7B,qIAAA,8BAA8B,OAAA;AAC9B,0HAAA,mBAAmB,OAAA","sourcesContent":["export type { BandwidthEstimator, SentInfo } from \"../bandwidthEstimator\";\nexport { DisabledBandwidthEstimator } from \"./disabledBwe\";\nexport type { BandwidthUsage, ProbeState } from \"./gcc\";\nexport {\n GCC_KNOWN_DIFFERENCES,\n GccBandwidthEstimator,\n kDefaultStartBitrateBps,\n kMaxBitrateBps,\n kMinBitrateBps,\n} from \"./gcc\";\nexport {\n isLightweightBandwidthEstimator,\n LightweightBandwidthEstimator,\n SenderBandwidthEstimator,\n} from \"./lightweightBwe\";\nexport type { TwccPacketFeedback } from \"./twccFeedbackAdapter\";\nexport {\n kTwccFeedbackHistoryMaxSeqSpan,\n TwccFeedbackAdapter,\n} from \"./twccFeedbackAdapter\";\n"]}
@@ -0,0 +1,64 @@
1
+ import { Event } from "../../../imports/common";
2
+ import { type TransportWideCC } from "../../../imports/rtp";
3
+ import type { BandwidthEstimator, SentInfo } from "../bandwidthEstimator";
4
+ import { BandwidthEstimatorNoopHooks } from "../bandwidthEstimator";
5
+ /**
6
+ * Lightweight cumulative min(send, recv) bandwidth estimator (mediasoup-inspired).
7
+ *
8
+ * This is the **default** send-side BWE used by {@link RTCRtpSender}: no
9
+ * probing, pacing or process timer, only the TWCC-observed send and receive
10
+ * rates. Implements {@link BandwidthEstimator}; congestion-related events are
11
+ * specific to this estimator and are not part of the shared interface. GCC send-path hooks (probe, pacing,
12
+ * RTT, process interval) are no-ops so {@link RTCRtpSender} can call them
13
+ * unconditionally.
14
+ *
15
+ * @see CumulativeResult
16
+ */
17
+ export declare class LightweightBandwidthEstimator extends BandwidthEstimatorNoopHooks implements BandwidthEstimator {
18
+ congestion: boolean;
19
+ /**
20
+ * Fires when recommended send bitrate (**bps**) changes.
21
+ * @see BandwidthEstimator.onAvailableBitrate
22
+ */
23
+ readonly onAvailableBitrate: Event<[number]>;
24
+ /** Lightweight-only: whether congestion is considered active. */
25
+ readonly onCongestion: Event<[boolean]>;
26
+ /** Lightweight-only: congestion score 1–10 (higher is worse). */
27
+ readonly onCongestionScore: Event<[number]>;
28
+ private congestionCounter;
29
+ private cumulativeResult;
30
+ /**
31
+ * Send history + feedback normalization shared with GCC. Each sent packet
32
+ * is counted as received at most once, even across corrective feedback.
33
+ */
34
+ private feedbackAdapter;
35
+ private _congestionScore;
36
+ private readonly clock;
37
+ /**
38
+ * @param options.clock Optional sender clock for unit tests. Must match the
39
+ * domain of {@link SentInfo.sendingAtMs} / {@link SentInfo.sentAtMs} used
40
+ * with this instance. Production omits this (defaults to
41
+ * {@link milliTime}).
42
+ */
43
+ constructor(options?: {
44
+ clock?: () => number;
45
+ });
46
+ /** 1–10; larger means worse congestion (lightweight-specific). */
47
+ get congestionScore(): number;
48
+ set congestionScore(v: number);
49
+ get availableBitrate(): number;
50
+ set availableBitrate(v: number);
51
+ receiveTWCC(feedback: TransportWideCC): void;
52
+ rtpPacketSent(sentInfo: SentInfo): void;
53
+ reset(): void;
54
+ dispose(): void;
55
+ }
56
+ /**
57
+ * @deprecated Renamed to {@link LightweightBandwidthEstimator}. Kept so
58
+ * existing `new SenderBandwidthEstimator()` / `instanceof` code keeps working.
59
+ */
60
+ export declare const SenderBandwidthEstimator: typeof LightweightBandwidthEstimator;
61
+ /** @deprecated Renamed to {@link LightweightBandwidthEstimator}. */
62
+ export type SenderBandwidthEstimator = LightweightBandwidthEstimator;
63
+ /** True when the estimator is the lightweight (default) implementation. */
64
+ export declare function isLightweightBandwidthEstimator(e: BandwidthEstimator): e is LightweightBandwidthEstimator;
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SenderBandwidthEstimator = exports.LightweightBandwidthEstimator = void 0;
4
+ exports.isLightweightBandwidthEstimator = isLightweightBandwidthEstimator;
5
+ const common_1 = require("../../../imports/common");
6
+ const rtp_1 = require("../../../imports/rtp");
7
+ const utils_1 = require("../../../utils");
8
+ const bandwidthEstimator_1 = require("../bandwidthEstimator");
9
+ const cumulativeResult_1 = require("../cumulativeResult");
10
+ const twccFeedbackAdapter_1 = require("./twccFeedbackAdapter");
11
+ const COUNTER_MAX = 20;
12
+ const SCORE_MAX = 10;
13
+ /**
14
+ * Time-based sent-info window. Prefer this over a sequence-count cap so a
15
+ * high packet rate plus delayed TWCC still matches (parent-ticket default
16
+ * estimator must stay backward compatible).
17
+ */
18
+ const kLightweightSentInfoMaxAgeMs = 10000;
19
+ /**
20
+ * Lightweight cumulative min(send, recv) bandwidth estimator (mediasoup-inspired).
21
+ *
22
+ * This is the **default** send-side BWE used by {@link RTCRtpSender}: no
23
+ * probing, pacing or process timer, only the TWCC-observed send and receive
24
+ * rates. Implements {@link BandwidthEstimator}; congestion-related events are
25
+ * specific to this estimator and are not part of the shared interface. GCC send-path hooks (probe, pacing,
26
+ * RTT, process interval) are no-ops so {@link RTCRtpSender} can call them
27
+ * unconditionally.
28
+ *
29
+ * @see CumulativeResult
30
+ */
31
+ class LightweightBandwidthEstimator extends bandwidthEstimator_1.BandwidthEstimatorNoopHooks {
32
+ /**
33
+ * @param options.clock Optional sender clock for unit tests. Must match the
34
+ * domain of {@link SentInfo.sendingAtMs} / {@link SentInfo.sentAtMs} used
35
+ * with this instance. Production omits this (defaults to
36
+ * {@link milliTime}).
37
+ */
38
+ constructor(options) {
39
+ super();
40
+ Object.defineProperty(this, "congestion", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: false
45
+ });
46
+ /**
47
+ * Recommended available send bitrate in **bps**.
48
+ * Notifies {@link onAvailableBitrate} only when the value changes.
49
+ */
50
+ /** @internal */
51
+ Object.defineProperty(this, "_availableBitrate", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: 0
56
+ });
57
+ /**
58
+ * Fires when recommended send bitrate (**bps**) changes.
59
+ * @see BandwidthEstimator.onAvailableBitrate
60
+ */
61
+ Object.defineProperty(this, "onAvailableBitrate", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: new common_1.Event()
66
+ });
67
+ /** Lightweight-only: whether congestion is considered active. */
68
+ Object.defineProperty(this, "onCongestion", {
69
+ enumerable: true,
70
+ configurable: true,
71
+ writable: true,
72
+ value: new common_1.Event()
73
+ });
74
+ /** Lightweight-only: congestion score 1–10 (higher is worse). */
75
+ Object.defineProperty(this, "onCongestionScore", {
76
+ enumerable: true,
77
+ configurable: true,
78
+ writable: true,
79
+ value: new common_1.Event()
80
+ });
81
+ Object.defineProperty(this, "congestionCounter", {
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true,
85
+ value: 0
86
+ });
87
+ Object.defineProperty(this, "cumulativeResult", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: new cumulativeResult_1.CumulativeResult()
92
+ });
93
+ /**
94
+ * Send history + feedback normalization shared with GCC. Each sent packet
95
+ * is counted as received at most once, even across corrective feedback.
96
+ */
97
+ Object.defineProperty(this, "feedbackAdapter", {
98
+ enumerable: true,
99
+ configurable: true,
100
+ writable: true,
101
+ value: new twccFeedbackAdapter_1.TwccFeedbackAdapter(kLightweightSentInfoMaxAgeMs)
102
+ });
103
+ Object.defineProperty(this, "_congestionScore", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: 1
108
+ });
109
+ Object.defineProperty(this, "clock", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: void 0
114
+ });
115
+ this.clock = options?.clock ?? utils_1.milliTime;
116
+ }
117
+ /** 1–10; larger means worse congestion (lightweight-specific). */
118
+ get congestionScore() {
119
+ return this._congestionScore;
120
+ }
121
+ set congestionScore(v) {
122
+ // Change-only: do not re-fire when the score is unchanged.
123
+ if (v === this._congestionScore)
124
+ return;
125
+ this._congestionScore = v;
126
+ this.onCongestionScore.execute(v);
127
+ }
128
+ get availableBitrate() {
129
+ return this._availableBitrate;
130
+ }
131
+ set availableBitrate(v) {
132
+ (0, bandwidthEstimator_1.setAvailableBitrateIfChanged)(this, v);
133
+ }
134
+ receiveTWCC(feedback) {
135
+ // With BUNDLE, TWCC is fanned out to every sender on the transport. A
136
+ // feedback that matches none of this sender's packets is not about this
137
+ // sender: ignore it like GCC does, so an idle sender does not count it
138
+ // toward congestion (develop only ever delivered the sender's own TWCC).
139
+ const nowMs = this.clock();
140
+ const packets = this.feedbackAdapter.onFeedback(feedback, nowMs);
141
+ if (packets.length === 0)
142
+ return;
143
+ const elapsedMs = nowMs - this.cumulativeResult.firstPacketSentAtMs;
144
+ if (elapsedMs > 1000) {
145
+ this.cumulativeResult.reset();
146
+ // Congestion may be occurring.
147
+ if (this.congestionCounter < COUNTER_MAX) {
148
+ this.congestionCounter++;
149
+ }
150
+ else if (this.congestionScore < SCORE_MAX) {
151
+ this.congestionScore++;
152
+ }
153
+ if (this.congestionCounter >= COUNTER_MAX && !this.congestion) {
154
+ this.congestion = true;
155
+ this.onCongestion.execute(this.congestion);
156
+ }
157
+ }
158
+ for (const packet of packets) {
159
+ // Timing sample only: lost / ReceivedWithoutDelta carry no recvMs
160
+ // (recvMs === 0 is a valid time, not falsy).
161
+ if (packet.recvMs === undefined)
162
+ continue;
163
+ this.cumulativeResult.addPacket(packet.sent.size, packet.sent.sendingAtMs, packet.recvMs);
164
+ }
165
+ if (elapsedMs >= 100 && this.cumulativeResult.numPackets >= 20) {
166
+ this.availableBitrate = Math.min(this.cumulativeResult.sendBitrate, this.cumulativeResult.receiveBitrate);
167
+ this.cumulativeResult.reset();
168
+ if (this.congestionCounter > -COUNTER_MAX) {
169
+ const maxBonus = (0, rtp_1.Int)(COUNTER_MAX / 2) + 1;
170
+ const minBonus = (0, rtp_1.Int)(COUNTER_MAX / 4) + 1;
171
+ const bonus = maxBonus - ((maxBonus - minBonus) / 10) * this.congestionScore;
172
+ this.congestionCounter = this.congestionCounter - bonus;
173
+ }
174
+ if (this.congestionCounter <= -COUNTER_MAX) {
175
+ if (this.congestionScore > 1) {
176
+ this.congestionScore--;
177
+ this.onCongestion.execute(false);
178
+ }
179
+ this.congestionCounter = 0;
180
+ }
181
+ if (this.congestionCounter <= 0 && this.congestion) {
182
+ this.congestion = false;
183
+ this.onCongestion.execute(this.congestion);
184
+ }
185
+ }
186
+ }
187
+ rtpPacketSent(sentInfo) {
188
+ this.feedbackAdapter.onSent(sentInfo);
189
+ }
190
+ reset() {
191
+ this.congestion = false;
192
+ this.congestionCounter = 0;
193
+ this._congestionScore = 1;
194
+ this._availableBitrate = 0;
195
+ this.cumulativeResult.reset();
196
+ this.feedbackAdapter.reset();
197
+ }
198
+ dispose() {
199
+ this.onAvailableBitrate.allUnsubscribe();
200
+ this.onCongestion.allUnsubscribe();
201
+ this.onCongestionScore.allUnsubscribe();
202
+ this.disposeNoopHooks();
203
+ this.reset();
204
+ }
205
+ }
206
+ exports.LightweightBandwidthEstimator = LightweightBandwidthEstimator;
207
+ /**
208
+ * @deprecated Renamed to {@link LightweightBandwidthEstimator}. Kept so
209
+ * existing `new SenderBandwidthEstimator()` / `instanceof` code keeps working.
210
+ */
211
+ exports.SenderBandwidthEstimator = LightweightBandwidthEstimator;
212
+ /** True when the estimator is the lightweight (default) implementation. */
213
+ function isLightweightBandwidthEstimator(e) {
214
+ return e instanceof LightweightBandwidthEstimator;
215
+ }
216
+ //# sourceMappingURL=lightweightBwe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightweightBwe.js","sourceRoot":"","sources":["../../../../../../src/media/sender/estimators/lightweightBwe.ts"],"names":[],"mappings":";;;AAsMA,0EAIC;AA1MD,oDAAgD;AAChD,8CAAiE;AACjE,0CAA2C;AAE3C,8DAG+B;AAC/B,0DAAuD;AACvD,+DAA4D;AAE5D,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB;;;;GAIG;A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AC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AA3JD,sEA2JC;AAED;;;GAGG;AACU,QAAA,wBAAwB,GAAG,6BAA6B,CAAC;AAItE,2EAA2E;AAC3E,SAAgB,+BAA+B,CAC7C,CAAqB;IAErB,OAAO,CAAC,YAAY,6BAA6B,CAAC;AACpD,CAAC","sourcesContent":["import { Event } from \"../../../imports/common\";\nimport { Int, type TransportWideCC } from \"../../../imports/rtp\";\nimport { milliTime } from \"../../../utils\";\nimport type { BandwidthEstimator, SentInfo } from \"../bandwidthEstimator\";\nimport {\n BandwidthEstimatorNoopHooks,\n setAvailableBitrateIfChanged,\n} from \"../bandwidthEstimator\";\nimport { CumulativeResult } from \"../cumulativeResult\";\nimport { TwccFeedbackAdapter } from \"./twccFeedbackAdapter\";\n\nconst COUNTER_MAX = 20;\nconst SCORE_MAX = 10;\n/**\n * Time-based sent-info window. Prefer this over a sequence-count cap so a\n * high packet rate plus delayed TWCC still matches (parent-ticket default\n * estimator must stay backward compatible).\n */\nconst kLightweightSentInfoMaxAgeMs = 10_000;\n\n/**\n * Lightweight cumulative min(send, recv) bandwidth estimator (mediasoup-inspired).\n *\n * This is the **default** send-side BWE used by {@link RTCRtpSender}: no\n * probing, pacing or process timer, only the TWCC-observed send and receive\n * rates. Implements {@link BandwidthEstimator}; congestion-related events are\n * specific to this estimator and are not part of the shared interface. GCC send-path hooks (probe, pacing,\n * RTT, process interval) are no-ops so {@link RTCRtpSender} can call them\n * unconditionally.\n *\n * @see CumulativeResult\n */\nexport class LightweightBandwidthEstimator\n extends BandwidthEstimatorNoopHooks\n implements BandwidthEstimator\n{\n congestion = false;\n\n /**\n * Recommended available send bitrate in **bps**.\n * Notifies {@link onAvailableBitrate} only when the value changes.\n */\n /** @internal */\n _availableBitrate = 0;\n\n /**\n * Fires when recommended send bitrate (**bps**) changes.\n * @see BandwidthEstimator.onAvailableBitrate\n */\n readonly onAvailableBitrate = new Event<[number]>();\n\n /** Lightweight-only: whether congestion is considered active. */\n readonly onCongestion = new Event<[boolean]>();\n /** Lightweight-only: congestion score 1–10 (higher is worse). */\n readonly onCongestionScore = new Event<[number]>();\n\n private congestionCounter = 0;\n private cumulativeResult = new CumulativeResult();\n /**\n * Send history + feedback normalization shared with GCC. Each sent packet\n * is counted as received at most once, even across corrective feedback.\n */\n private feedbackAdapter = new TwccFeedbackAdapter(\n kLightweightSentInfoMaxAgeMs,\n );\n private _congestionScore = 1;\n private readonly clock: () => number;\n\n /**\n * @param options.clock Optional sender clock for unit tests. Must match the\n * domain of {@link SentInfo.sendingAtMs} / {@link SentInfo.sentAtMs} used\n * with this instance. Production omits this (defaults to\n * {@link milliTime}).\n */\n constructor(options?: { clock?: () => number }) {\n super();\n this.clock = options?.clock ?? milliTime;\n }\n\n /** 1–10; larger means worse congestion (lightweight-specific). */\n get congestionScore() {\n return this._congestionScore;\n }\n set congestionScore(v: number) {\n // Change-only: do not re-fire when the score is unchanged.\n if (v === this._congestionScore) return;\n this._congestionScore = v;\n this.onCongestionScore.execute(v);\n }\n\n get availableBitrate() {\n return this._availableBitrate;\n }\n set availableBitrate(v: number) {\n setAvailableBitrateIfChanged(this, v);\n }\n\n receiveTWCC(feedback: TransportWideCC) {\n // With BUNDLE, TWCC is fanned out to every sender on the transport. A\n // feedback that matches none of this sender's packets is not about this\n // sender: ignore it like GCC does, so an idle sender does not count it\n // toward congestion (develop only ever delivered the sender's own TWCC).\n const nowMs = this.clock();\n const packets = this.feedbackAdapter.onFeedback(feedback, nowMs);\n if (packets.length === 0) return;\n\n const elapsedMs = nowMs - this.cumulativeResult.firstPacketSentAtMs;\n if (elapsedMs > 1000) {\n this.cumulativeResult.reset();\n\n // Congestion may be occurring.\n\n if (this.congestionCounter < COUNTER_MAX) {\n this.congestionCounter++;\n } else if (this.congestionScore < SCORE_MAX) {\n this.congestionScore++;\n }\n\n if (this.congestionCounter >= COUNTER_MAX && !this.congestion) {\n this.congestion = true;\n this.onCongestion.execute(this.congestion);\n }\n }\n\n for (const packet of packets) {\n // Timing sample only: lost / ReceivedWithoutDelta carry no recvMs\n // (recvMs === 0 is a valid time, not falsy).\n if (packet.recvMs === undefined) continue;\n\n this.cumulativeResult.addPacket(\n packet.sent.size,\n packet.sent.sendingAtMs,\n packet.recvMs,\n );\n }\n\n if (elapsedMs >= 100 && this.cumulativeResult.numPackets >= 20) {\n this.availableBitrate = Math.min(\n this.cumulativeResult.sendBitrate,\n this.cumulativeResult.receiveBitrate,\n );\n this.cumulativeResult.reset();\n\n if (this.congestionCounter > -COUNTER_MAX) {\n const maxBonus = Int(COUNTER_MAX / 2) + 1;\n const minBonus = Int(COUNTER_MAX / 4) + 1;\n const bonus =\n maxBonus - ((maxBonus - minBonus) / 10) * this.congestionScore;\n\n this.congestionCounter = this.congestionCounter - bonus;\n }\n\n if (this.congestionCounter <= -COUNTER_MAX) {\n if (this.congestionScore > 1) {\n this.congestionScore--;\n this.onCongestion.execute(false);\n }\n this.congestionCounter = 0;\n }\n\n if (this.congestionCounter <= 0 && this.congestion) {\n this.congestion = false;\n this.onCongestion.execute(this.congestion);\n }\n }\n }\n\n rtpPacketSent(sentInfo: SentInfo) {\n this.feedbackAdapter.onSent(sentInfo);\n }\n\n reset() {\n this.congestion = false;\n this.congestionCounter = 0;\n this._congestionScore = 1;\n this._availableBitrate = 0;\n this.cumulativeResult.reset();\n this.feedbackAdapter.reset();\n }\n\n dispose() {\n this.onAvailableBitrate.allUnsubscribe();\n this.onCongestion.allUnsubscribe();\n this.onCongestionScore.allUnsubscribe();\n this.disposeNoopHooks();\n this.reset();\n }\n}\n\n/**\n * @deprecated Renamed to {@link LightweightBandwidthEstimator}. Kept so\n * existing `new SenderBandwidthEstimator()` / `instanceof` code keeps working.\n */\nexport const SenderBandwidthEstimator = LightweightBandwidthEstimator;\n/** @deprecated Renamed to {@link LightweightBandwidthEstimator}. */\nexport type SenderBandwidthEstimator = LightweightBandwidthEstimator;\n\n/** True when the estimator is the lightweight (default) implementation. */\nexport function isLightweightBandwidthEstimator(\n e: BandwidthEstimator,\n): e is LightweightBandwidthEstimator {\n return e instanceof LightweightBandwidthEstimator;\n}\n"]}