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,414 @@
1
+ #include "common.hpp"
2
+ #include "RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp"
3
+ #include "RTC/RTP/HeaderExtensionIds.hpp"
4
+ #include "RTC/RTP/Packet.hpp"
5
+ #include "RTC/RtpDictionaries.hpp"
6
+ #include "Utils.hpp"
7
+ #include "test/include/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.hpp"
8
+ #include "test/include/RTC/RTP/rtpCommon.hpp"
9
+ #include <catch2/catch_test_macros.hpp>
10
+ #include <cstdlib> // std::abs()
11
+ #include <vector>
12
+
13
+ SCENARIO("BWE RemoteBitrateEstimatorAbsSendTime", "[bwe][remotebitrateestimatorabssendtime]")
14
+ {
15
+ class TestRemoteBitrateEstimatorAbsSendTimeListener
16
+ : public RTC::BWE::RemoteBitrateEstimatorAbsSendTime::Listener
17
+ {
18
+ public:
19
+ void OnRemoteBitrateEstimatorAbsSendTimeBitrateChanged(
20
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime* /*remoteBitrateEstimator*/,
21
+ const std::vector<uint32_t>& ssrcs,
22
+ int64_t bitrate) override
23
+ {
24
+ this->updated = true;
25
+ this->latestBitrate = bitrate;
26
+ this->latestSsrcs = ssrcs;
27
+ }
28
+
29
+ public:
30
+ bool updated{ false };
31
+ int64_t latestBitrate{ 0 };
32
+ std::vector<uint32_t> latestSsrcs;
33
+ };
34
+
35
+ constexpr uint32_t Ssrc{ 1111 };
36
+ // Instant the scenarios below start at, which is irrelevant other than for
37
+ // being far from zero.
38
+ constexpr int64_t BaseTimeUs{ 1000 * 1000 };
39
+ // Fewest packets a burst needs for it to be taken as one.
40
+ constexpr int Probes{ 5 };
41
+
42
+ // Builds a packet of the given size carrying the given instant in its
43
+ // `abs-send-time` extension.
44
+ //
45
+ // NOTE: Every scenario reuses `rtpCommon::FactoryBuffer`, so the returned
46
+ // packet is only valid until the next call.
47
+ const auto buildPacket =
48
+ [](size_t payloadSize, int64_t sendTimeUs) -> std::unique_ptr<RTC::RTP::Packet>
49
+ {
50
+ std::unique_ptr<RTC::RTP::Packet> packet(
51
+ RTC::RTP::Packet::Factory(rtpCommon::FactoryBuffer, sizeof(rtpCommon::FactoryBuffer)));
52
+
53
+ REQUIRE(packet);
54
+
55
+ packet->SetSsrc(Ssrc);
56
+
57
+ const auto absSendTimeId = static_cast<uint8_t>(RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME);
58
+
59
+ const std::vector<RTC::RTP::Packet::Extension> extensions{
60
+ { RTC::RtpHeaderExtensionUri::Type::ABS_SEND_TIME, absSendTimeId, /*len*/ 3, rtpCommon::DataBuffer }
61
+ };
62
+
63
+ packet->SetExtensions(RTC::RTP::Packet::ExtensionsType::OneByte, extensions);
64
+
65
+ RTC::RTP::HeaderExtensionIds headerExtensionIds;
66
+
67
+ headerExtensionIds.absSendTime = absSendTimeId;
68
+
69
+ packet->AssignExtensionIds(headerExtensionIds);
70
+ packet->SetPayloadLength(payloadSize);
71
+
72
+ REQUIRE(packet->UpdateAbsSendTime(Utils::Time::TimeUsToAbsSendTime(sendTimeUs)));
73
+
74
+ return packet;
75
+ };
76
+
77
+ // Feeds a packet that says it left at `sendTimeUs` and arrived at
78
+ // `arrivalTimeUs`, which is also taken as the current instant.
79
+ const auto feedPacket = [&buildPacket](
80
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime& remoteBitrateEstimator,
81
+ size_t payloadSize,
82
+ int64_t sendTimeUs,
83
+ int64_t arrivalTimeUs,
84
+ int64_t nowUs) -> void
85
+ {
86
+ const auto packet = buildPacket(payloadSize, sendTimeUs);
87
+
88
+ remoteBitrateEstimator.ReceiveRtpPacket(packet.get(), arrivalTimeUs, nowUs);
89
+ };
90
+
91
+ SECTION("a burst faster than the one before it raises the estimation")
92
+ {
93
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
94
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
95
+
96
+ int64_t nowUs{ BaseTimeUs };
97
+
98
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
99
+ for (int i{ 0 }; i < Probes; ++i)
100
+ {
101
+ nowUs += 10 * 1000;
102
+
103
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
104
+ }
105
+
106
+ // Second burst sent at 8 * 1000 / 5 = 1600 kbps.
107
+ for (int i{ 0 }; i < Probes; ++i)
108
+ {
109
+ nowUs += 5 * 1000;
110
+
111
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
112
+ }
113
+
114
+ REQUIRE(listener.updated);
115
+ REQUIRE(listener.latestBitrate > 1500000);
116
+ }
117
+
118
+ SECTION("packets that were not paced do not spoil the burst")
119
+ {
120
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
121
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
122
+
123
+ int64_t nowUs{ BaseTimeUs };
124
+
125
+ // Burst sent at 8 * 1000 / 10 = 800 kbps, with a small packet in between
126
+ // each pair of its packets.
127
+ for (int i{ 0 }; i < Probes; ++i)
128
+ {
129
+ nowUs += 5 * 1000;
130
+
131
+ const int64_t burstTimeUs = nowUs;
132
+
133
+ feedPacket(remoteBitrateEstimator, 1000, burstTimeUs, burstTimeUs, nowUs);
134
+
135
+ nowUs += 5 * 1000;
136
+
137
+ feedPacket(remoteBitrateEstimator, 100, burstTimeUs, burstTimeUs, nowUs);
138
+ }
139
+
140
+ REQUIRE(listener.updated);
141
+ REQUIRE(listener.latestBitrate > 800000);
142
+ }
143
+
144
+ SECTION("a burst that arrives dispersed is measured by how it arrived")
145
+ {
146
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
147
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
148
+
149
+ int64_t nowUs{ BaseTimeUs };
150
+ int64_t sendTimeUs{ BaseTimeUs };
151
+
152
+ // First burst sent at 8 * 1000 / 10 = 800 kbps.
153
+ for (int i{ 0 }; i < Probes; ++i)
154
+ {
155
+ nowUs += 10 * 1000;
156
+ sendTimeUs += 10 * 1000;
157
+
158
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
159
+ }
160
+
161
+ // Second burst sent at 8 * 1000 / 5 = 1600 kbps but arriving at
162
+ // 8 * 1000 / 8 = 1000 kbps, so the link did not take it.
163
+ for (int i{ 0 }; i < Probes; ++i)
164
+ {
165
+ nowUs += 8 * 1000;
166
+ sendTimeUs += 5 * 1000;
167
+
168
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
169
+ }
170
+
171
+ REQUIRE(listener.updated);
172
+ REQUIRE(std::abs(listener.latestBitrate - 800000) <= 10000);
173
+ }
174
+
175
+ SECTION("a burst that arrives slightly faster than it was sent is taken")
176
+ {
177
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
178
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
179
+
180
+ int64_t nowUs{ BaseTimeUs };
181
+ int64_t sendTimeUs{ BaseTimeUs };
182
+
183
+ // Sent at 8 * 1000 / 10 = 800 kbps, arriving at 8 * 1000 / 5 = 1600 kbps.
184
+ for (int i{ 0 }; i < Probes; ++i)
185
+ {
186
+ nowUs += 5 * 1000;
187
+ sendTimeUs += 10 * 1000;
188
+
189
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
190
+ }
191
+
192
+ REQUIRE(listener.updated);
193
+ REQUIRE(listener.latestBitrate > 800000);
194
+ }
195
+
196
+ SECTION("a burst that arrives far faster than it was sent says nothing")
197
+ {
198
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
199
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
200
+
201
+ int64_t nowUs{ BaseTimeUs };
202
+ int64_t sendTimeUs{ BaseTimeUs };
203
+
204
+ // Sent at 8 * 1000 / 10 = 800 kbps, arriving ten times faster, which no
205
+ // link explains.
206
+ for (int i{ 0 }; i < Probes; ++i)
207
+ {
208
+ nowUs += 1 * 1000;
209
+ sendTimeUs += 10 * 1000;
210
+
211
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
212
+ }
213
+
214
+ REQUIRE(!listener.updated);
215
+ }
216
+
217
+ SECTION("a burst that arrives slower than it was sent is measured by how it arrived")
218
+ {
219
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
220
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
221
+
222
+ int64_t nowUs{ BaseTimeUs };
223
+ int64_t sendTimeUs{ BaseTimeUs };
224
+
225
+ // Sent at 8 * 1000 / 5 = 1600 kbps, arriving at 8 * 1000 / 7 = 1142 kbps.
226
+ for (int i{ 0 }; i < Probes; ++i)
227
+ {
228
+ nowUs += 7 * 1000;
229
+ sendTimeUs += 5 * 1000;
230
+
231
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
232
+ }
233
+
234
+ REQUIRE(listener.updated);
235
+ REQUIRE(std::abs(listener.latestBitrate - 1140000) <= 10000);
236
+ }
237
+
238
+ SECTION("a fast burst that arrives slower is measured by how it arrived")
239
+ {
240
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
241
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
242
+
243
+ int64_t nowUs{ BaseTimeUs };
244
+ int64_t sendTimeUs{ BaseTimeUs };
245
+
246
+ // Sent at 8 * 1000 / 1 = 8000 kbps, arriving at 8 * 1000 / 2 = 4000 kbps.
247
+ for (int i{ 0 }; i < Probes; ++i)
248
+ {
249
+ nowUs += 2 * 1000;
250
+ sendTimeUs += 1 * 1000;
251
+
252
+ feedPacket(remoteBitrateEstimator, 1000, sendTimeUs, nowUs, nowUs);
253
+ }
254
+
255
+ REQUIRE(listener.updated);
256
+ REQUIRE(std::abs(listener.latestBitrate - 4000000) <= 10000);
257
+ }
258
+
259
+ SECTION("packets too small to have been paced are not taken as a burst")
260
+ {
261
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
262
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
263
+
264
+ int64_t nowUs{ BaseTimeUs };
265
+
266
+ // 200 bytes every 10 ms, which is not big enough to have been paced.
267
+ for (int i{ 0 }; i < Probes; ++i)
268
+ {
269
+ nowUs += 10 * 1000;
270
+
271
+ feedPacket(remoteBitrateEstimator, 200, nowUs, nowUs, nowUs);
272
+ }
273
+
274
+ REQUIRE(!listener.updated);
275
+
276
+ // The same cadence with packets that are big enough is a burst.
277
+ for (int i{ 0 }; i < Probes; ++i)
278
+ {
279
+ nowUs += 10 * 1000;
280
+
281
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
282
+ }
283
+
284
+ REQUIRE(listener.updated);
285
+ REQUIRE(std::abs(listener.latestBitrate - 800000) <= 10000);
286
+ }
287
+
288
+ // NOTE: What this pins is that a packet arriving after every stream has timed
289
+ // out, and every packet after that one, never reach a null inter arrival or
290
+ // overuse estimator.
291
+ SECTION("a packet after every stream timed out is handled")
292
+ {
293
+ TestRemoteBitrateEstimatorAbsSendTimeListener listener;
294
+ RTC::BWE::RemoteBitrateEstimatorAbsSendTime remoteBitrateEstimator(std::addressof(listener));
295
+
296
+ int64_t nowUs{ BaseTimeUs };
297
+
298
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
299
+
300
+ // Longer than the two seconds a stream may be silent for.
301
+ nowUs += 2001 * 1000;
302
+
303
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
304
+
305
+ nowUs += 1000 * 1000;
306
+
307
+ feedPacket(remoteBitrateEstimator, 1000, nowUs, nowUs, nowUs);
308
+ }
309
+
310
+ SECTION("initial behavior")
311
+ {
312
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
313
+
314
+ helper.InitialBehaviorTestHelper(674840);
315
+ }
316
+
317
+ SECTION("a rate increase with reordered packets")
318
+ {
319
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
320
+
321
+ helper.RateIncreaseReorderingTestHelper(674840);
322
+ }
323
+
324
+ SECTION("a rate increase measured in rtp timestamps")
325
+ {
326
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
327
+
328
+ helper.RateIncreaseRtpTimestampsTestHelper(1237);
329
+ }
330
+
331
+ SECTION("a capacity drop with one stream")
332
+ {
333
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
334
+
335
+ helper.CapacityDropTestHelper(1, false, 633, 0);
336
+ }
337
+
338
+ SECTION("a capacity drop with the receiver clock moved forward")
339
+ {
340
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
341
+
342
+ helper.CapacityDropTestHelper(1, false, 267, 30000);
343
+ }
344
+
345
+ SECTION("a capacity drop with the receiver clock moved back")
346
+ {
347
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
348
+
349
+ helper.CapacityDropTestHelper(1, false, 267, -30000);
350
+ }
351
+
352
+ SECTION("a capacity drop with one stream whose timestamps wrap")
353
+ {
354
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
355
+
356
+ helper.CapacityDropTestHelper(1, true, 633, 0);
357
+ }
358
+
359
+ SECTION("a capacity drop with two streams whose timestamps wrap")
360
+ {
361
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
362
+
363
+ helper.CapacityDropTestHelper(2, true, 700, 0);
364
+ }
365
+
366
+ SECTION("a capacity drop with three streams whose timestamps wrap")
367
+ {
368
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
369
+
370
+ helper.CapacityDropTestHelper(3, true, 633, 0);
371
+ }
372
+
373
+ SECTION("a capacity drop with thirteen streams whose timestamps wrap")
374
+ {
375
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
376
+
377
+ helper.CapacityDropTestHelper(13, true, 667, 0);
378
+ }
379
+
380
+ SECTION("a capacity drop with nineteen streams whose timestamps wrap")
381
+ {
382
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
383
+
384
+ helper.CapacityDropTestHelper(19, true, 667, 0);
385
+ }
386
+
387
+ SECTION("a capacity drop with thirty streams whose timestamps wrap")
388
+ {
389
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
390
+
391
+ helper.CapacityDropTestHelper(30, true, 667, 0);
392
+ }
393
+
394
+ SECTION("packets sent very close together are taken as one group")
395
+ {
396
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
397
+
398
+ helper.TestTimestampGroupingTestHelper();
399
+ }
400
+
401
+ SECTION("a sender rejoining after a short silence, which wraps abs-send-time")
402
+ {
403
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
404
+
405
+ helper.TestWrappingHelper(35);
406
+ }
407
+
408
+ SECTION("a sender rejoining after a silence that leaves abs-send-time unchanged")
409
+ {
410
+ bweHelpers::RemoteBitrateEstimatorAbsSendTimeTestHelper helper;
411
+
412
+ helper.TestWrappingHelper(10 * 64);
413
+ }
414
+ }