mediasoup 3.27.1 → 3.29.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 (297) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/node/lib/Consumer.d.ts.map +1 -1
  3. package/node/lib/Consumer.js +4 -51
  4. package/node/lib/PipeTransportTypes.d.ts +6 -1
  5. package/node/lib/PipeTransportTypes.d.ts.map +1 -1
  6. package/node/lib/PlainTransportTypes.d.ts +6 -1
  7. package/node/lib/PlainTransportTypes.d.ts.map +1 -1
  8. package/node/lib/Producer.d.ts.map +1 -1
  9. package/node/lib/Producer.js +4 -8
  10. package/node/lib/ProducerTypes.d.ts +4 -2
  11. package/node/lib/ProducerTypes.d.ts.map +1 -1
  12. package/node/lib/Router.d.ts +4 -4
  13. package/node/lib/Router.d.ts.map +1 -1
  14. package/node/lib/Router.js +14 -7
  15. package/node/lib/RouterTypes.d.ts +7 -1
  16. package/node/lib/RouterTypes.d.ts.map +1 -1
  17. package/node/lib/Transport.d.ts +2 -1
  18. package/node/lib/Transport.d.ts.map +1 -1
  19. package/node/lib/Transport.js +24 -16
  20. package/node/lib/TransportTypes.d.ts +12 -2
  21. package/node/lib/TransportTypes.d.ts.map +1 -1
  22. package/node/lib/WebRtcTransportTypes.d.ts +6 -1
  23. package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
  24. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts +3 -4
  25. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts.map +1 -1
  26. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.js +3 -4
  27. package/node/lib/fbs/transport/options.d.ts +6 -2
  28. package/node/lib/fbs/transport/options.d.ts.map +1 -1
  29. package/node/lib/fbs/transport/options.js +19 -7
  30. package/node/lib/fbs/transport/sctp-zero-checksum.d.ts +6 -0
  31. package/node/lib/fbs/transport/sctp-zero-checksum.d.ts.map +1 -0
  32. package/node/lib/fbs/transport/sctp-zero-checksum.js +11 -0
  33. package/node/lib/fbs/transport/stats.d.ts +2 -8
  34. package/node/lib/fbs/transport/stats.d.ts.map +1 -1
  35. package/node/lib/fbs/transport/stats.js +5 -29
  36. package/node/lib/fbs/transport.d.ts +1 -0
  37. package/node/lib/fbs/transport.d.ts.map +1 -1
  38. package/node/lib/fbs/transport.js +4 -2
  39. package/node/lib/ortc.d.ts +0 -2
  40. package/node/lib/ortc.d.ts.map +1 -1
  41. package/node/lib/ortc.js +11 -21
  42. package/node/lib/rtpMappingFbsUtils.d.ts +6 -0
  43. package/node/lib/rtpMappingFbsUtils.d.ts.map +1 -0
  44. package/node/lib/rtpMappingFbsUtils.js +65 -0
  45. package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
  46. package/node/lib/rtpParametersFbsUtils.js +0 -6
  47. package/node/lib/rtpParametersTypes.d.ts +1 -1
  48. package/node/lib/rtpParametersTypes.d.ts.map +1 -1
  49. package/node/lib/rtpStreamFbsUtils.d.ts +4 -0
  50. package/node/lib/rtpStreamFbsUtils.d.ts.map +1 -0
  51. package/node/lib/rtpStreamFbsUtils.js +51 -0
  52. package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
  53. package/node/lib/supportedRtpCapabilities.js +6 -13
  54. package/node/lib/test/test-Consumer.js +1 -13
  55. package/node/lib/test/test-DataConsumer.js +9 -0
  56. package/node/lib/test/test-DataProducer.js +38 -0
  57. package/node/lib/test/test-PipeTransport.js +27 -29
  58. package/node/lib/test/test-Producer.js +97 -0
  59. package/node/lib/test/test-ortc.js +34 -14
  60. package/npm-scripts.mjs +35 -44
  61. package/package.json +14 -10
  62. package/worker/fbs/rtpParameters.fbs +0 -1
  63. package/worker/fbs/transport.fbs +9 -2
  64. package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
  65. package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +16 -2
  66. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +14 -1
  67. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +17 -4
  68. package/worker/include/DepLibUV.hpp +13 -0
  69. package/worker/include/RTC/BWE/AimdRateControl.hpp +9 -9
  70. package/worker/include/RTC/BWE/AlrDetector.hpp +97 -0
  71. package/worker/include/RTC/BWE/BitrateProber.hpp +217 -0
  72. package/worker/include/RTC/BWE/{Utils.hpp → BitrateUtils.hpp} +3 -3
  73. package/worker/include/RTC/BWE/BweTypes.hpp +207 -2
  74. package/worker/include/RTC/BWE/DelayBasedBwe.hpp +3 -3
  75. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +2 -16
  76. package/worker/include/RTC/BWE/InterArrival.hpp +117 -0
  77. package/worker/include/RTC/BWE/IntervalBudget.hpp +81 -0
  78. package/worker/include/RTC/BWE/LossBasedController.hpp +109 -4
  79. package/worker/include/RTC/BWE/OveruseDetector.hpp +72 -0
  80. package/worker/include/RTC/BWE/OveruseEstimator.hpp +115 -0
  81. package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +84 -0
  82. package/worker/include/RTC/BWE/ProbeController.hpp +379 -0
  83. package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +126 -0
  84. package/worker/include/RTC/BWE/ProbingScheduler.hpp +183 -0
  85. package/worker/include/RTC/BWE/ReceiverTransportCongestionController.hpp +148 -0
  86. package/worker/include/RTC/BWE/RembGenerator.hpp +97 -0
  87. package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +237 -0
  88. package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +26 -0
  89. package/worker/include/RTC/BWE/SendPacketHistory.hpp +161 -25
  90. package/worker/include/RTC/BWE/SenderTransportCongestionController.hpp +343 -0
  91. package/worker/include/RTC/BWE/TargetRateController.hpp +4 -1
  92. package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +147 -0
  93. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +18 -3
  94. package/worker/include/RTC/Consts.hpp +70 -0
  95. package/worker/include/RTC/Consumer.hpp +8 -1
  96. package/worker/include/RTC/DataConsumer.hpp +3 -5
  97. package/worker/include/RTC/DirectTransport.hpp +4 -5
  98. package/worker/include/RTC/PipeTransport.hpp +4 -5
  99. package/worker/include/RTC/PlainTransport.hpp +4 -5
  100. package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +6 -7
  101. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +3 -1
  102. package/worker/include/RTC/RTP/Codecs/Tools.hpp +1 -1
  103. package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +0 -1
  104. package/worker/include/RTC/RTP/Packet.hpp +16 -4
  105. package/worker/include/RTC/RTP/ProbationGenerator.hpp +0 -8
  106. package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +36 -10
  107. package/worker/include/RTC/RTP/RtpStream.hpp +33 -9
  108. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +23 -4
  109. package/worker/include/RTC/RTP/RtpStreamSend.hpp +126 -11
  110. package/worker/include/RTC/RTP/RtxStream.hpp +10 -4
  111. package/worker/include/RTC/RateCalculator.hpp +103 -24
  112. package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +33 -3
  113. package/worker/include/RTC/{RtcLogger.hpp → RtcLogger/RtpPacket.hpp} +5 -3
  114. package/worker/include/RTC/RtcLogger/SendBurst.hpp +88 -0
  115. package/worker/include/RTC/RtpDictionaries.hpp +3 -4
  116. package/worker/include/RTC/SCTP/association/Association.hpp +1 -1
  117. package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +12 -3
  118. package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +0 -1
  119. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +4 -4
  120. package/worker/include/RTC/SCTP/rx/DataTracker.hpp +1 -1
  121. package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +1 -1
  122. package/worker/include/RTC/SctpDictionaries.hpp +2 -2
  123. package/worker/include/RTC/TcpConnection.hpp +2 -1
  124. package/worker/include/RTC/Transport.hpp +23 -8
  125. package/worker/include/RTC/TransportCongestionControlClient.hpp +0 -5
  126. package/worker/include/RTC/TransportCongestionControlServer.hpp +0 -5
  127. package/worker/include/RTC/TransportTuple.hpp +61 -6
  128. package/worker/include/RTC/WebRtcTransport.hpp +4 -5
  129. package/worker/include/Shared.hpp +5 -0
  130. package/worker/include/SharedInterface.hpp +10 -0
  131. package/worker/include/Utils.hpp +81 -5
  132. package/worker/include/common.hpp +12 -4
  133. package/worker/include/handles/SendCallbacks.hpp +34 -0
  134. package/worker/include/handles/TcpConnectionHandle.hpp +4 -12
  135. package/worker/include/handles/UdpSocketHandle.hpp +4 -8
  136. package/worker/meson.build +45 -3
  137. package/worker/meson_options.txt +1 -0
  138. package/worker/mocks/include/MockShared.hpp +16 -2
  139. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +1 -1
  140. package/worker/scripts/package-lock.json +6 -6
  141. package/worker/src/RTC/BWE/AimdRateControl.cpp +26 -27
  142. package/worker/src/RTC/BWE/AlrDetector.cpp +80 -0
  143. package/worker/src/RTC/BWE/BitrateProber.cpp +256 -0
  144. package/worker/src/RTC/BWE/{Utils.cpp → BitrateUtils.cpp} +4 -4
  145. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +18 -22
  146. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +21 -38
  147. package/worker/src/RTC/BWE/InterArrival.cpp +216 -0
  148. package/worker/src/RTC/BWE/IntervalBudget.cpp +93 -0
  149. package/worker/src/RTC/BWE/LossBasedController.cpp +189 -41
  150. package/worker/src/RTC/BWE/OveruseDetector.cpp +128 -0
  151. package/worker/src/RTC/BWE/OveruseEstimator.cpp +166 -0
  152. package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +222 -0
  153. package/worker/src/RTC/BWE/ProbeController.cpp +645 -0
  154. package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +135 -0
  155. package/worker/src/RTC/BWE/ProbingScheduler.cpp +191 -0
  156. package/worker/src/RTC/BWE/ReceiverTransportCongestionController.cpp +207 -0
  157. package/worker/src/RTC/BWE/RembGenerator.cpp +169 -0
  158. package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +497 -0
  159. package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +47 -0
  160. package/worker/src/RTC/BWE/SendPacketHistory.cpp +173 -50
  161. package/worker/src/RTC/BWE/SenderTransportCongestionController.cpp +599 -0
  162. package/worker/src/RTC/BWE/TargetRateController.cpp +12 -14
  163. package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +376 -0
  164. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +24 -5
  165. package/worker/src/RTC/Consumer.cpp +10 -7
  166. package/worker/src/RTC/DataConsumer.cpp +10 -12
  167. package/worker/src/RTC/DirectTransport.cpp +14 -8
  168. package/worker/src/RTC/DtlsTransport.cpp +8 -8
  169. package/worker/src/RTC/ICE/IceCandidate.cpp +4 -4
  170. package/worker/src/RTC/ICE/IceServer.cpp +1 -1
  171. package/worker/src/RTC/PipeTransport.cpp +13 -8
  172. package/worker/src/RTC/PlainTransport.cpp +13 -8
  173. package/worker/src/RTC/Producer.cpp +14 -31
  174. package/worker/src/RTC/RTCP/Bye.cpp +1 -1
  175. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +18 -0
  176. package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +2 -2
  177. package/worker/src/RTC/RTCP/FeedbackPsVbcm.cpp +2 -1
  178. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +2 -2
  179. package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
  180. package/worker/src/RTC/RTP/Codecs/DependencyDescriptor.cpp +2 -1
  181. package/worker/src/RTC/RTP/Packet.cpp +26 -11
  182. package/worker/src/RTC/RTP/ProbationGenerator.cpp +5 -6
  183. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +21 -8
  184. package/worker/src/RTC/RTP/RtpStream.cpp +1 -4
  185. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +109 -102
  186. package/worker/src/RTC/RTP/RtpStreamSend.cpp +442 -258
  187. package/worker/src/RTC/RTP/RtxStream.cpp +32 -22
  188. package/worker/src/RTC/RateCalculator.cpp +133 -28
  189. package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +56 -1
  190. package/worker/src/RTC/{RtcLogger.cpp → RtcLogger/RtpPacket.cpp} +2 -2
  191. package/worker/src/RTC/RtcLogger/SendBurst.cpp +124 -0
  192. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +2 -12
  193. package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +1 -1
  194. package/worker/src/RTC/SCTP/association/Association.cpp +4 -3
  195. package/worker/src/RTC/SCTP/association/StateCookie.cpp +26 -6
  196. package/worker/src/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.cpp +4 -3
  197. package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +3 -3
  198. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +4 -2
  199. package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +4 -4
  200. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +4 -2
  201. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +4 -4
  202. package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +6 -10
  203. package/worker/src/RTC/SimulcastProducerStreamManager.cpp +2 -2
  204. package/worker/src/RTC/SrtpSession.cpp +2 -2
  205. package/worker/src/RTC/SvcProducerStreamManager.cpp +2 -2
  206. package/worker/src/RTC/TcpConnection.cpp +2 -2
  207. package/worker/src/RTC/Transport.cpp +160 -113
  208. package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -66
  209. package/worker/src/RTC/TransportCongestionControlServer.cpp +0 -55
  210. package/worker/src/RTC/TransportTuple.cpp +4 -4
  211. package/worker/src/RTC/WebRtcServer.cpp +4 -3
  212. package/worker/src/RTC/WebRtcTransport.cpp +20 -13
  213. package/worker/src/Utils/BitStream.cpp +24 -0
  214. package/worker/src/Utils/Crypto.cpp +114 -98
  215. package/worker/src/handles/BackoffTimerHandle.cpp +1 -1
  216. package/worker/src/handles/TcpConnectionHandle.cpp +13 -23
  217. package/worker/src/handles/UdpSocketHandle.cpp +14 -21
  218. package/worker/subprojects/catch2.wrap +6 -6
  219. package/worker/subprojects/openssl.wrap +11 -12
  220. package/worker/subprojects/packagefiles/ankerl-unordered-dense/meson.build +1 -1
  221. package/worker/subprojects/unordered-dense.wrap +4 -4
  222. package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +68 -14
  223. package/worker/test/include/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.hpp +125 -0
  224. package/worker/test/src/RTC/BWE/TestAlrDetector.cpp +110 -0
  225. package/worker/test/src/RTC/BWE/TestBitrateProber.cpp +418 -0
  226. package/worker/test/src/RTC/BWE/TestBitrateUtils.cpp +61 -0
  227. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +9 -9
  228. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +79 -60
  229. package/worker/test/src/RTC/BWE/TestInterArrival.cpp +643 -0
  230. package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +8 -8
  231. package/worker/test/src/RTC/BWE/TestIntervalBudget.cpp +130 -0
  232. package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +519 -0
  233. package/worker/test/src/RTC/BWE/TestProbeBitrateEstimator.cpp +266 -0
  234. package/worker/test/src/RTC/BWE/TestProbeController.cpp +1685 -0
  235. package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +250 -0
  236. package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +236 -0
  237. package/worker/test/src/RTC/BWE/TestReceiverTransportCongestionController.cpp +346 -0
  238. package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +285 -0
  239. package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +414 -0
  240. package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +296 -77
  241. package/worker/test/src/RTC/BWE/TestSenderTransportCongestionController.cpp +510 -0
  242. package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +580 -0
  243. package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +6 -6
  244. package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +133 -29
  245. package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +624 -0
  246. package/worker/test/src/RTC/RTCP/TestBye.cpp +1 -1
  247. package/worker/test/src/RTC/RTCP/TestFeedbackPsAfb.cpp +1 -1
  248. package/worker/test/src/RTC/RTCP/TestFeedbackPsFir.cpp +1 -1
  249. package/worker/test/src/RTC/RTCP/TestFeedbackPsLei.cpp +1 -1
  250. package/worker/test/src/RTC/RTCP/TestFeedbackPsPli.cpp +1 -1
  251. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +20 -1
  252. package/worker/test/src/RTC/RTCP/TestFeedbackPsRpsi.cpp +1 -1
  253. package/worker/test/src/RTC/RTCP/TestFeedbackPsSli.cpp +1 -1
  254. package/worker/test/src/RTC/RTCP/TestFeedbackPsTst.cpp +1 -1
  255. package/worker/test/src/RTC/RTCP/TestFeedbackPsVbcm.cpp +1 -1
  256. package/worker/test/src/RTC/RTCP/TestFeedbackRtpEcn.cpp +1 -1
  257. package/worker/test/src/RTC/RTCP/TestFeedbackRtpNack.cpp +1 -1
  258. package/worker/test/src/RTC/RTCP/TestFeedbackRtpSrReq.cpp +1 -1
  259. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTllei.cpp +1 -1
  260. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  261. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +1 -1
  262. package/worker/test/src/RTC/RTCP/TestReceiverReport.cpp +1 -1
  263. package/worker/test/src/RTC/RTCP/TestSenderReport.cpp +1 -1
  264. package/worker/test/src/RTC/RTP/TestPacket.cpp +58 -4
  265. package/worker/test/src/RTC/RTP/TestProbationGenerator.cpp +3 -2
  266. package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +60 -28
  267. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +50 -0
  268. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +804 -23
  269. package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
  270. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +42 -0
  271. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +54 -5
  272. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +80 -15
  273. package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +410 -3
  274. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +1 -1
  275. package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +37 -5
  276. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +5 -4
  277. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +1 -1
  278. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
  279. package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +1 -1
  280. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1 -1
  281. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +11 -10
  282. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +1 -1
  283. package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
  284. package/worker/test/src/RTC/TestPortManager.cpp +2 -2
  285. package/worker/test/src/RTC/TestRateCalculator.cpp +323 -61
  286. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +103 -9
  287. package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +13 -13
  288. package/worker/test/src/RTC/TestRtpEncodingParameters.cpp +1 -1
  289. package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +34 -16
  290. package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +31 -13
  291. package/worker/test/src/RTC/TestSubchannelsCodec.cpp +2 -2
  292. package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +37 -19
  293. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +11 -11
  294. package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
  295. package/worker/test/src/Utils/TestCrypto.cpp +71 -2
  296. package/worker/test/src/Utils/TestTime.cpp +120 -21
  297. package/worker/test/src/RTC/BWE/TestUtils.cpp +0 -61
@@ -0,0 +1,97 @@
1
+ #ifndef MS_RTC_BWE_ALR_DETECTOR_HPP
2
+ #define MS_RTC_BWE_ALR_DETECTOR_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/IntervalBudget.hpp"
6
+ #include "SharedInterface.hpp"
7
+
8
+ namespace RTC
9
+ {
10
+ namespace BWE
11
+ {
12
+ /**
13
+ * Tells whether the sender is not sending enough to fill the link.
14
+ *
15
+ * While that is the case nothing measured says anything about the capacity
16
+ * of the link, because what arrives is only what was sent: the delay doesn't
17
+ * grow, no packet is lost, and the bitrate that gets acknowledged is the one
18
+ * chosen rather than the one the link can carry. So the estimate cannot grow
19
+ * on its own, and the only way out is to probe.
20
+ *
21
+ * The question is answered by giving the sender a budget that refills at a
22
+ * fraction of the estimated bitrate and is spent as bytes go out. A budget
23
+ * that keeps growing means the sender is not using what it was given.
24
+ *
25
+ * @remarks
26
+ * - For a browser this is an odd situation, but for an SFU whose consumers
27
+ * sit on low layers it is the normal state.
28
+ */
29
+ class AlrDetector
30
+ {
31
+ public:
32
+ struct AlrDetectorOptions
33
+ {
34
+ /**
35
+ * Fraction of the estimated bitrate the sender is expected to be using.
36
+ * The budget refills at that fraction rather than at the whole estimate,
37
+ * so that staying somewhat below it doesn't count as not filling the
38
+ * link.
39
+ */
40
+ double bandwidthUsageRatio{ 0.65 };
41
+ /**
42
+ * Level the budget has to grow past for the sender to be taken as not
43
+ * filling the link.
44
+ */
45
+ double startBudgetLevelRatio{ 0.80 };
46
+ /**
47
+ * Level the budget has to fall back below for it to stop being taken as
48
+ * such. It is lower than the one above so that a short burst doesn't end
49
+ * the state.
50
+ */
51
+ double stopBudgetLevelRatio{ 0.50 };
52
+ };
53
+
54
+ public:
55
+ explicit AlrDetector(SharedInterface* shared);
56
+
57
+ AlrDetector(SharedInterface* shared, AlrDetectorOptions options);
58
+
59
+ /**
60
+ * Feed bytes that have just left towards the network.
61
+ *
62
+ * @param sentAtUs - Instant at which they left, which is what the span of
63
+ * time they were sent over is measured with.
64
+ */
65
+ void OnBytesSent(int64_t bytesSent, int64_t sentAtUs);
66
+
67
+ /**
68
+ * Bitrate the sender is expected to be able to use (bps).
69
+ */
70
+ void SetEstimatedBitrate(int64_t bitrate);
71
+
72
+ /**
73
+ * Instant at which the sender started not filling the link, or no value
74
+ * while it is filling it.
75
+ */
76
+ std::optional<int64_t> GetAlrStartTimeUs() const
77
+ {
78
+ return this->alrStartTimeUs;
79
+ }
80
+
81
+ private:
82
+ // Passed by argument.
83
+ SharedInterface* shared{ nullptr };
84
+ const AlrDetectorOptions options;
85
+ // Others.
86
+ // Budget of what the sender was expected to use, whose level is the whole
87
+ // signal this produces.
88
+ IntervalBudget alrBudget;
89
+ // Instant of the latest send, which is what the span of the next one is
90
+ // measured against.
91
+ std::optional<int64_t> lastSentAtUs;
92
+ std::optional<int64_t> alrStartTimeUs;
93
+ };
94
+ } // namespace BWE
95
+ } // namespace RTC
96
+
97
+ #endif
@@ -0,0 +1,217 @@
1
+ #ifndef MS_RTC_BWE_BITRATE_PROBER_HPP
2
+ #define MS_RTC_BWE_BITRATE_PROBER_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/BweTypes.hpp"
6
+ #include <queue>
7
+
8
+ namespace RTC
9
+ {
10
+ namespace BWE
11
+ {
12
+ /**
13
+ * Paces out the bursts that somebody else decided to send.
14
+ *
15
+ * It takes the bursts asked for, keeps them in the order they were asked for,
16
+ * and answers a single question over and over: at what instant may the next
17
+ * packet of the current one go out, and how many bytes should it carry. It
18
+ * sends nothing itself.
19
+ *
20
+ * The spacing is what makes a burst worth anything. A burst is a bitrate held
21
+ * for a few milliseconds, so letting the packets go as fast as the socket
22
+ * takes them measures the queue of whoever is in the way rather than the link.
23
+ * So each instant is computed from the start of the burst and the bytes gone
24
+ * out so far, which keeps the whole of it close to the bitrate asked for even
25
+ * when a packet leaves late.
26
+ */
27
+ class BitrateProber
28
+ {
29
+ private:
30
+ /**
31
+ * Whether bursts are being emitted, and why not when they are not.
32
+ */
33
+ enum class State : uint8_t
34
+ {
35
+ /**
36
+ * There may be bursts waiting, but none of them has started.
37
+ */
38
+ INACTIVE,
39
+ /**
40
+ * A burst is being emitted.
41
+ */
42
+ ACTIVE
43
+ };
44
+
45
+ /**
46
+ * A burst that was asked for, and how much of it has gone out.
47
+ */
48
+ struct Cluster
49
+ {
50
+ /**
51
+ * What travels with each of its packets, and what makes its result
52
+ * trustworthy.
53
+ */
54
+ Types::ProbeCluster probeCluster;
55
+ /**
56
+ * Bitrate it is meant to be sent at (bps).
57
+ */
58
+ int64_t sendBitrate{ 0 };
59
+ /**
60
+ * Time between two consecutive bursts of packets within it.
61
+ */
62
+ int64_t minProbeDeltaUs{ 0 };
63
+ /**
64
+ * Instant at which it was asked for, which is what makes it go stale.
65
+ */
66
+ int64_t requestedAtUs{ 0 };
67
+ /**
68
+ * Instant at which its first packet went out, or no value while none
69
+ * has.
70
+ */
71
+ std::optional<int64_t> startedAtUs;
72
+ int64_t sentProbes{ 0 };
73
+ int64_t sentBytes{ 0 };
74
+ };
75
+
76
+ public:
77
+ struct BitrateProberOptions
78
+ {
79
+ /**
80
+ * How late a packet of a burst may go out before the whole burst is
81
+ * given up on, since one sent too slowly no longer measures the bitrate
82
+ * it was meant to.
83
+ */
84
+ int64_t maxProbeDelayUs{ 10 * 1000 };
85
+ /**
86
+ * Size a packet has to reach for a burst to start on it (bytes).
87
+ *
88
+ * @remarks
89
+ * - It only applies while the bursts are made of traffic that somebody
90
+ * else produces, since a burst that begins on a tiny packet starts
91
+ * measuring from an instant that says nothing.
92
+ */
93
+ size_t minPacketSize{ 200 };
94
+ /**
95
+ * Whether a burst may start without waiting for a packet of that size.
96
+ */
97
+ bool allowStartProbingImmediately{ false };
98
+ };
99
+
100
+ /**
101
+ * The burst being emitted, together with how much of it has gone out.
102
+ */
103
+ struct CurrentCluster
104
+ {
105
+ /**
106
+ * What travels with each of its packets.
107
+ */
108
+ Types::ProbeCluster probeCluster;
109
+ /**
110
+ * Bytes of the burst that have already gone out (bytes).
111
+ *
112
+ * @remarks
113
+ * - It doesn't belong in `Types::ProbeCluster` because that one travels
114
+ * attached to every packet until its feedback comes back, and by then
115
+ * this count means nothing.
116
+ */
117
+ int64_t sentBytes{ 0 };
118
+ };
119
+
120
+ public:
121
+ BitrateProber();
122
+
123
+ explicit BitrateProber(BitrateProberOptions options);
124
+
125
+ ~BitrateProber() = default;
126
+
127
+ /**
128
+ * Whether a burst is being emitted right now.
129
+ */
130
+ bool IsProbing() const
131
+ {
132
+ return this->state == State::ACTIVE;
133
+ }
134
+
135
+ /**
136
+ * Take a burst that has been asked for.
137
+ */
138
+ void CreateProbeCluster(const Types::ProbeClusterConfig& clusterConfig);
139
+
140
+ /**
141
+ * Instant at which the next packet of the current burst may go out, or no
142
+ * value if there is nothing to send.
143
+ *
144
+ * @remarks
145
+ * - The instant given is `nowUs` itself when the packet may go out right
146
+ * away, so that the answer is always an instant that can be operated
147
+ * with rather than a value meaning "as soon as possible".
148
+ */
149
+ [[nodiscard]] std::optional<int64_t> GetNextProbeTimeUs(int64_t nowUs) const;
150
+
151
+ /**
152
+ * The burst being emitted, or no value if there is none.
153
+ *
154
+ * @remarks
155
+ * - It gives up on the burst, and may leave none being emitted, when the
156
+ * instant it was due at is too far behind.
157
+ */
158
+ [[nodiscard]] std::optional<CurrentCluster> GetCurrentCluster(int64_t nowUs);
159
+
160
+ /**
161
+ * Bytes the next packet of the current burst should carry, or zero if there
162
+ * is no burst.
163
+ *
164
+ * @remarks
165
+ * - Packets are allowed to be grouped into a single shot as long as they
166
+ * add up to this, which is what keeps a burst from needing a packet every
167
+ * couple of milliseconds.
168
+ */
169
+ size_t GetRecommendedMinProbeSize() const;
170
+
171
+ /**
172
+ * Report that the given bytes of the current burst have gone out.
173
+ */
174
+ void ProbeSent(int64_t nowUs, size_t size);
175
+
176
+ /**
177
+ * Feed a packet that somebody else is sending, which is what may start a
178
+ * burst that is waiting for one.
179
+ *
180
+ * @remarks
181
+ * - Only the tests call it today, because the bursts are made of packets
182
+ * fabricated for them and there is no traffic of somebody else's to wait
183
+ * for. This is the way in for the day a burst rides on real traffic
184
+ * instead, and with it `minPacketSize` starts meaning something.
185
+ */
186
+ void OnIncomingPacket(size_t packetSize);
187
+
188
+ private:
189
+ /**
190
+ * Start emitting if there is a burst waiting and the given packet is enough
191
+ * to begin on.
192
+ */
193
+ void MaybeSetActiveState(size_t packetSize);
194
+
195
+ bool IsReadyToSetActiveState(size_t packetSize) const;
196
+
197
+ /**
198
+ * Instant at which the next packet of the given burst is due, computed from
199
+ * the start of the burst so that it stays close to its bitrate.
200
+ */
201
+ int64_t CalculateNextProbeTimeUs(const Cluster& cluster) const;
202
+
203
+ private:
204
+ // Passed by argument.
205
+ BitrateProberOptions options;
206
+ // Others.
207
+ State state{ State::INACTIVE };
208
+ // The bursts asked for, the first one being the one being emitted.
209
+ std::queue<Cluster> clusters;
210
+ // Instant at which the next packet is due, or no value while it is due
211
+ // right away.
212
+ std::optional<int64_t> nextProbeTimeUs;
213
+ };
214
+ } // namespace BWE
215
+ } // namespace RTC
216
+
217
+ #endif
@@ -1,5 +1,5 @@
1
- #ifndef MS_RTC_BWE_UTILS_HPP
2
- #define MS_RTC_BWE_UTILS_HPP
1
+ #ifndef MS_RTC_BWE_BITRATE_UTILS_HPP
2
+ #define MS_RTC_BWE_BITRATE_UTILS_HPP
3
3
 
4
4
  #include "common.hpp"
5
5
 
@@ -7,7 +7,7 @@ namespace RTC
7
7
  {
8
8
  namespace BWE
9
9
  {
10
- class Utils
10
+ class BitrateUtils
11
11
  {
12
12
  public:
13
13
  /**
@@ -22,6 +22,43 @@ namespace RTC
22
22
  */
23
23
  constexpr int64_t TimeUsInfinite{ std::numeric_limits<int64_t>::max() };
24
24
 
25
+ /**
26
+ * Which RTCP mechanism the two endpoints negotiated to deal with
27
+ * congestion, which is what decides on which of them the estimation is
28
+ * computed.
29
+ */
30
+ enum class CongestionControlType : uint8_t
31
+ {
32
+ /**
33
+ * The receiving endpoint reports when each packet arrived and the
34
+ * sending one estimates from that.
35
+ */
36
+ TRANSPORT_CC = 1,
37
+ /**
38
+ * The receiving endpoint estimates and tells the sending one how much
39
+ * it may send.
40
+ */
41
+ REMB = 2
42
+ };
43
+
44
+ constexpr std::string_view congestionControlTypeToString(CongestionControlType congestionControlType)
45
+ {
46
+ switch (congestionControlType)
47
+ {
48
+ case CongestionControlType::TRANSPORT_CC:
49
+ {
50
+ return "TRANSPORT_CC";
51
+ }
52
+
53
+ case CongestionControlType::REMB:
54
+ {
55
+ return "REMB";
56
+ }
57
+
58
+ NO_DEFAULT();
59
+ }
60
+ }
61
+
25
62
  /**
26
63
  * How the network is behaving according to the delay based detector.
27
64
  */
@@ -60,10 +97,36 @@ namespace RTC
60
97
  return "OVERUSING";
61
98
  }
62
99
 
63
- NO_DEFAULT_GCC();
100
+ NO_DEFAULT();
64
101
  }
65
102
  }
66
103
 
104
+ /**
105
+ * The two bits of the IP header with which the network tells that it is
106
+ * congested instead of dropping the packet.
107
+ *
108
+ * @see https://www.rfc-editor.org/rfc/rfc9331.html
109
+ */
110
+ enum class EcnMarking : uint8_t
111
+ {
112
+ /**
113
+ * Not ECN capable transport.
114
+ */
115
+ NOT_ECT = 0b00,
116
+ /**
117
+ * ECN capable transport, which is the one L4S uses.
118
+ */
119
+ ECT1 = 0b01,
120
+ /**
121
+ * ECN capable transport, not used by L4S.
122
+ */
123
+ ECT0 = 0b10,
124
+ /**
125
+ * Congestion experienced, which is what the network sets on the way.
126
+ */
127
+ CE = 0b11
128
+ };
129
+
67
130
  /**
68
131
  * Estimate of the capacity of the link, used to bound the rate control.
69
132
  */
@@ -95,6 +158,67 @@ namespace RTC
95
158
  std::optional<int64_t> estimatedThroughput;
96
159
  };
97
160
 
161
+ /**
162
+ * The burst of packets a probe is sent as, and what makes its result
163
+ * trustworthy.
164
+ *
165
+ * A probe is only worth believing once enough of what was sent has come
166
+ * back, so the burst carries how many packets and how many bytes it was
167
+ * meant to be. Whoever measures it compares those against what actually
168
+ * arrived, and discards the cluster if too little of it did.
169
+ */
170
+ struct ProbeCluster
171
+ {
172
+ /**
173
+ * Identifies the burst, so that the packets of one probe are not mixed
174
+ * with those of another.
175
+ */
176
+ int64_t id{ 0 };
177
+ /**
178
+ * Packets the burst was meant to be made of.
179
+ */
180
+ int64_t minProbes{ 0 };
181
+ /**
182
+ * Bytes the burst was meant to carry.
183
+ */
184
+ int64_t minBytes{ 0 };
185
+ };
186
+
187
+ /**
188
+ * A burst that has been asked for but not sent yet.
189
+ *
190
+ * It's what whoever decides to probe hands over to whoever emits the
191
+ * packets: at what bitrate, for how long and in how many packets. What
192
+ * travels with each of those packets afterwards is a `ProbeCluster`.
193
+ */
194
+ struct ProbeClusterConfig
195
+ {
196
+ /**
197
+ * Identifies the burst, and is what each of its packets carries.
198
+ */
199
+ int64_t id{ 0 };
200
+ /**
201
+ * Instant at which the burst was asked for.
202
+ */
203
+ int64_t atUs{ 0 };
204
+ /**
205
+ * Bitrate the burst is meant to be sent at (bps).
206
+ */
207
+ int64_t targetBitrate{ 0 };
208
+ /**
209
+ * How long the burst is meant to last.
210
+ */
211
+ int64_t targetDurationUs{ 0 };
212
+ /**
213
+ * Time between two consecutive bursts of packets within the probe.
214
+ */
215
+ int64_t minProbeDeltaUs{ 2 * 1000 };
216
+ /**
217
+ * Packets the burst is meant to be made of.
218
+ */
219
+ int64_t targetProbeCount{ 0 };
220
+ };
221
+
98
222
  /**
99
223
  * A packet that was sent and is being tracked until its feedback arrives.
100
224
  */
@@ -133,7 +257,12 @@ namespace RTC
133
257
  /**
134
258
  * Whether it's an audio packet. False for video, padding and RTX.
135
259
  */
136
- bool audio{ false };
260
+ bool isAudio{ false };
261
+ /**
262
+ * The probe cluster the packet belongs to, or no value if it isn't a
263
+ * probe.
264
+ */
265
+ std::optional<ProbeCluster> probeCluster;
137
266
  };
138
267
 
139
268
  /**
@@ -154,6 +283,16 @@ namespace RTC
154
283
  bool operator()(const PacketResult& lhs, const PacketResult& rhs) const;
155
284
  };
156
285
 
286
+ /**
287
+ * What identifies the packet on the wire.
288
+ */
289
+ struct RtpPacketInfo
290
+ {
291
+ uint32_t ssrc{ 0 };
292
+ uint16_t rtpSequenceNumber{ 0 };
293
+ bool isRetransmission{ false };
294
+ };
295
+
157
296
  /**
158
297
  * Whether the packet reached the receiver at all.
159
298
  */
@@ -168,6 +307,72 @@ namespace RTC
168
307
  * value if it was reported as lost.
169
308
  */
170
309
  std::optional<int64_t> receiveTimeUs;
310
+ /**
311
+ * What identifies the packet on the wire, or no value when the feedback
312
+ * doesn't report on an RTP packet.
313
+ */
314
+ std::optional<RtpPacketInfo> rtpPacketInfo;
315
+ /**
316
+ * How long the receiver held the packet before sending the feedback
317
+ * that reports it, which is what allows a round trip time per packet.
318
+ *
319
+ * @remark
320
+ * - Only a feedback that carries it per packet has it, which is the one
321
+ * of RFC 8888 and not the transport-cc one.
322
+ *
323
+ * @see https://datatracker.ietf.org/doc/html/rfc8888
324
+ */
325
+ std::optional<int64_t> arrivalTimeOffsetUs;
326
+ /**
327
+ * The marking the packet carried when it arrived, which is how the
328
+ * network reports being congested without dropping it.
329
+ *
330
+ * @remark
331
+ * - Only a feedback that reports it has it, which is the one of RFC
332
+ * 8888 and not the transport-cc one.
333
+ *
334
+ * @see https://datatracker.ietf.org/doc/html/rfc8888
335
+ */
336
+ EcnMarking ecn{ EcnMarking::NOT_ECT };
337
+ /**
338
+ * Whether the arrival time reported for this packet cannot be told from
339
+ * that of another one, so it says nothing about the delay.
340
+ *
341
+ * @remark
342
+ * - Nothing in this estimator reads it. It is only of use to SCReAM,
343
+ * another way of estimating the bandwidth.
344
+ *
345
+ * @link https://datatracker.ietf.org/doc/draft-johansson-ccwg-rfc8298bis-screamv2
346
+ */
347
+ bool ambiguousReceiveTime{ false };
348
+ /**
349
+ * Whether the packet was sent marked as ECT(1), which asks the network
350
+ * to report congestion instead of dropping the packet.
351
+ *
352
+ * @see https://www.rfc-editor.org/rfc/rfc9331.html
353
+ */
354
+ bool sentWithEct1{ false };
355
+ /**
356
+ * Whether this is the first feedback to report the packet as lost.
357
+ *
358
+ * @remark
359
+ * - Only a feedback that reports on a whole range of packets can tell,
360
+ * which is the one of RFC 8888 and not the transport-cc one.
361
+ *
362
+ * @see https://datatracker.ietf.org/doc/html/rfc8888
363
+ */
364
+ bool reportedLostForTheFirstTime{ false };
365
+ /**
366
+ * Whether this feedback reports as received a packet that an earlier
367
+ * one had reported as lost.
368
+ *
369
+ * @remark
370
+ * - Only a feedback that reports on a whole range of packets can tell,
371
+ * which is the one of RFC 8888 and not the transport-cc one.
372
+ *
373
+ * @see https://datatracker.ietf.org/doc/html/rfc8888
374
+ */
375
+ bool reportedRecoveredForTheFirstTime{ false };
171
376
  };
172
377
 
173
378
  /**
@@ -138,20 +138,20 @@ namespace RTC
138
138
  }
139
139
 
140
140
  private:
141
- void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t atTimeUs);
141
+ void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t nowUs);
142
142
 
143
143
  Result MaybeUpdateEstimate(
144
144
  std::optional<int64_t> ackedBitrate,
145
145
  std::optional<int64_t> probeBitrate,
146
146
  bool recoveredFromOveruse,
147
- int64_t atTimeUs);
147
+ int64_t nowUs);
148
148
 
149
149
  /**
150
150
  * Recompute the target bitrate.
151
151
  *
152
152
  * @returns Whether there is a valid estimate.
153
153
  */
154
- bool UpdateEstimate(int64_t atTimeUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate);
154
+ bool UpdateEstimate(int64_t nowUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate);
155
155
 
156
156
  private:
157
157
  const DelayBasedBweOptions options;
@@ -33,27 +33,16 @@ namespace RTC
33
33
  explicit FeedbackAdapter(SendPacketHistory* sendPacketHistory);
34
34
 
35
35
  /**
36
- * Process a transport-cc feedback.
36
+ * Process a transport wide cc feedback.
37
37
  *
38
38
  * @param receivedAtUs - Time at which the feedback was received.
39
39
  * @returns What the feedback reports about the packets that were sent, in
40
40
  * the order it reports them, or no value if it reports on no packet the
41
41
  * history still holds.
42
42
  */
43
- std::optional<Types::TransportPacketsFeedback> ProcessTransportFeedback(
43
+ std::optional<Types::TransportPacketsFeedback> ProcessTransportWideCcFeedback(
44
44
  const RTCP::FeedbackRtpTransportPacket* feedback, int64_t receivedAtUs);
45
45
 
46
- private:
47
- /**
48
- * Recover the sequence number the history gave to a packet out of the
49
- * lowest bits of it that the wire carries.
50
- *
51
- * @param previousSequenceNumber - Sequence number the previous packet the
52
- * feedback reported on resolved into, which the returned one is the
53
- * closest to.
54
- */
55
- static int64_t UnwrapSequenceNumber(uint16_t wideSequenceNumber, int64_t previousSequenceNumber);
56
-
57
46
  private:
58
47
  SendPacketHistory* const sendPacketHistory;
59
48
  // Our own time the arrival times of the current feedback are given
@@ -62,9 +51,6 @@ namespace RTC
62
51
  // Base time of the latest feedback processed, in the remote clock, or no
63
52
  // value if no feedback was ever processed.
64
53
  std::optional<int64_t> lastFeedbackBaseTimeUs;
65
- // Sequence number the latest packet reported on resolved into, or no
66
- // value if no feedback was ever processed.
67
- std::optional<int64_t> lastUnwrappedSequenceNumber;
68
54
  };
69
55
  } // namespace BWE
70
56
  } // namespace RTC