mediasoup 3.26.0 → 3.27.1

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 (322) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/node/lib/DataConsumer.js +1 -1
  3. package/node/lib/Router.js +1 -1
  4. package/node/lib/Transport.js +15 -15
  5. package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts +2 -6
  6. package/node/lib/fbs/rtp-parameters/encoding-mapping.d.ts.map +1 -1
  7. package/node/lib/fbs/rtp-parameters/encoding-mapping.js +7 -19
  8. package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.d.ts +4 -4
  9. package/node/lib/fbs/rtp-parameters/rtp-encoding-parameters.js +2 -2
  10. package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts +5 -5
  11. package/node/lib/fbs/rtp-stream/bitrate-by-layer.d.ts.map +1 -1
  12. package/node/lib/fbs/rtp-stream/bitrate-by-layer.js +3 -3
  13. package/node/lib/fbs/rtp-stream/recv-stats.d.ts +5 -5
  14. package/node/lib/fbs/rtp-stream/recv-stats.d.ts.map +1 -1
  15. package/node/lib/fbs/rtp-stream/recv-stats.js +3 -3
  16. package/node/lib/fbs/rtp-stream/send-stats.d.ts +5 -5
  17. package/node/lib/fbs/rtp-stream/send-stats.d.ts.map +1 -1
  18. package/node/lib/fbs/rtp-stream/send-stats.js +3 -3
  19. package/node/lib/fbs/transport/bwe-trace-info.d.ts +23 -23
  20. package/node/lib/fbs/transport/bwe-trace-info.d.ts.map +1 -1
  21. package/node/lib/fbs/transport/bwe-trace-info.js +15 -15
  22. package/node/lib/fbs/transport/options.d.ts +5 -5
  23. package/node/lib/fbs/transport/options.js +2 -2
  24. package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts +5 -5
  25. package/node/lib/fbs/transport/set-max-incoming-bitrate-request.d.ts.map +1 -1
  26. package/node/lib/fbs/transport/set-max-incoming-bitrate-request.js +3 -3
  27. package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts +5 -5
  28. package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.d.ts.map +1 -1
  29. package/node/lib/fbs/transport/set-max-outgoing-bitrate-request.js +3 -3
  30. package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts +5 -5
  31. package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.d.ts.map +1 -1
  32. package/node/lib/fbs/transport/set-min-outgoing-bitrate-request.js +3 -3
  33. package/node/lib/fbs/transport/stats.d.ts +38 -38
  34. package/node/lib/fbs/transport/stats.d.ts.map +1 -1
  35. package/node/lib/fbs/transport/stats.js +25 -25
  36. package/node/lib/ortc.d.ts +0 -1
  37. package/node/lib/ortc.d.ts.map +1 -1
  38. package/node/lib/ortc.js +1 -2
  39. package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
  40. package/node/lib/rtpParametersFbsUtils.js +2 -2
  41. package/package.json +9 -9
  42. package/worker/deps/libwebrtc/libwebrtc/call/rtp_transport_controller_send.cc +10 -10
  43. package/worker/deps/libwebrtc/libwebrtc/mediasoup_helpers.h +6 -6
  44. package/worker/deps/libwebrtc/libwebrtc/modules/congestion_controller/goog_cc/alr_detector.cc +1 -1
  45. package/worker/deps/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc +7 -7
  46. package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +1 -1
  47. package/worker/deps/libwebrtc/libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +1 -1
  48. package/worker/fbs/FBS/meson.build +25 -0
  49. package/worker/fbs/meson.build +15 -18
  50. package/worker/fbs/rtpParameters.fbs +1 -2
  51. package/worker/fbs/rtpStream.fbs +3 -3
  52. package/worker/fbs/transport.fbs +23 -23
  53. package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
  54. package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
  55. package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
  56. package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
  57. package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
  58. package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
  59. package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
  60. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
  61. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
  62. package/worker/fuzzer/src/fuzzer.cpp +4 -0
  63. package/worker/include/Channel/ChannelNotification.hpp +3 -3
  64. package/worker/include/Channel/ChannelRequest.hpp +1 -1
  65. package/worker/include/Channel/ChannelSocket.hpp +11 -0
  66. package/worker/include/DepLibUV.hpp +16 -33
  67. package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
  68. package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
  69. package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
  70. package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
  71. package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
  72. package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
  73. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
  74. package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
  75. package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
  76. package/worker/include/RTC/BWE/LossBasedController.hpp +520 -0
  77. package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
  78. package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
  79. package/worker/include/RTC/BWE/TargetRateController.hpp +306 -0
  80. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +143 -0
  81. package/worker/include/RTC/BWE/Utils.hpp +39 -0
  82. package/worker/include/RTC/Consts.hpp +6 -6
  83. package/worker/include/RTC/Consumer.hpp +14 -12
  84. package/worker/include/RTC/DataConsumer.hpp +3 -3
  85. package/worker/include/RTC/DataProducer.hpp +3 -3
  86. package/worker/include/RTC/DtlsTransport.hpp +5 -2
  87. package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
  88. package/worker/include/RTC/ICE/IceServer.hpp +3 -3
  89. package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
  90. package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
  91. package/worker/include/RTC/NackGenerator.hpp +12 -12
  92. package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
  93. package/worker/include/RTC/PipeTransport.hpp +18 -5
  94. package/worker/include/RTC/PlainTransport.hpp +18 -5
  95. package/worker/include/RTC/PortManager.hpp +4 -4
  96. package/worker/include/RTC/Producer.hpp +21 -12
  97. package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
  98. package/worker/include/RTC/RTCP/Bye.hpp +2 -2
  99. package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
  100. package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
  101. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
  102. package/worker/include/RTC/RTCP/Packet.hpp +3 -3
  103. package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
  104. package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
  105. package/worker/include/RTC/RTCP/XR.hpp +2 -2
  106. package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
  107. package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
  108. package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
  109. package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
  110. package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
  111. package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
  112. package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
  113. package/worker/include/RTC/RTP/Packet.hpp +13 -13
  114. package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
  115. package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
  116. package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
  117. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
  118. package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
  119. package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
  120. package/worker/include/RTC/RateCalculator.hpp +50 -44
  121. package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
  122. package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
  123. package/worker/include/RTC/Router.hpp +6 -0
  124. package/worker/include/RTC/RtcLogger.hpp +1 -1
  125. package/worker/include/RTC/RtpDictionaries.hpp +10 -10
  126. package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
  127. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
  128. package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
  129. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +38 -2
  130. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
  131. package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
  132. package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
  133. package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
  134. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
  135. package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
  136. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
  137. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +6 -6
  138. package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +10 -0
  139. package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
  140. package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
  141. package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
  142. package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
  143. package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
  144. package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
  145. package/worker/include/RTC/SctpDictionaries.hpp +3 -3
  146. package/worker/include/RTC/Serializable.hpp +1 -1
  147. package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
  148. package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
  149. package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
  150. package/worker/include/RTC/TcpConnection.hpp +9 -3
  151. package/worker/include/RTC/TcpServer.hpp +3 -0
  152. package/worker/include/RTC/Transport.hpp +52 -45
  153. package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
  154. package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
  155. package/worker/include/RTC/TrendCalculator.hpp +5 -5
  156. package/worker/include/RTC/UdpSocket.hpp +11 -2
  157. package/worker/include/RTC/WebRtcServer.hpp +20 -5
  158. package/worker/include/RTC/WebRtcTransport.hpp +35 -10
  159. package/worker/include/Settings.hpp +4 -2
  160. package/worker/include/Shared.hpp +5 -20
  161. package/worker/include/SharedInterface.hpp +6 -28
  162. package/worker/include/Utils.hpp +40 -21
  163. package/worker/include/common.hpp +4 -0
  164. package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
  165. package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
  166. package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
  167. package/worker/include/handles/TcpServerHandle.hpp +1 -1
  168. package/worker/include/handles/TimerHandle.hpp +15 -9
  169. package/worker/include/handles/TimerHandleInterface.hpp +10 -4
  170. package/worker/include/handles/UdpSocketHandle.hpp +3 -3
  171. package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
  172. package/worker/meson.build +87 -36
  173. package/worker/meson_options.txt +1 -0
  174. package/worker/mocks/include/MockShared.hpp +24 -23
  175. package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
  176. package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
  177. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
  178. package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
  179. package/worker/mocks/src/MockShared.cpp +51 -5
  180. package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
  181. package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
  182. package/worker/scripts/clang-scripts.mjs +2 -2
  183. package/worker/src/Channel/ChannelNotification.cpp +5 -6
  184. package/worker/src/Channel/ChannelSocket.cpp +20 -2
  185. package/worker/src/DepLibUV.cpp +4 -5
  186. package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
  187. package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
  188. package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
  189. package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
  190. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
  191. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
  192. package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
  193. package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
  194. package/worker/src/RTC/BWE/LossBasedController.cpp +1046 -0
  195. package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
  196. package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
  197. package/worker/src/RTC/BWE/TargetRateController.cpp +435 -0
  198. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +311 -0
  199. package/worker/src/RTC/BWE/Utils.cpp +54 -0
  200. package/worker/src/RTC/Consumer.cpp +48 -35
  201. package/worker/src/RTC/DataConsumer.cpp +4 -4
  202. package/worker/src/RTC/DataProducer.cpp +3 -3
  203. package/worker/src/RTC/DirectTransport.cpp +2 -2
  204. package/worker/src/RTC/DtlsTransport.cpp +14 -11
  205. package/worker/src/RTC/ICE/IceServer.cpp +2 -2
  206. package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
  207. package/worker/src/RTC/NackGenerator.cpp +12 -12
  208. package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
  209. package/worker/src/RTC/PipeTransport.cpp +16 -13
  210. package/worker/src/RTC/PlainTransport.cpp +25 -16
  211. package/worker/src/RTC/Producer.cpp +50 -36
  212. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
  213. package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
  214. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
  215. package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
  216. package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
  217. package/worker/src/RTC/RTP/Packet.cpp +9 -10
  218. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
  219. package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
  220. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
  221. package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
  222. package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
  223. package/worker/src/RTC/RateCalculator.cpp +99 -136
  224. package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
  225. package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
  226. package/worker/src/RTC/Router.cpp +18 -1
  227. package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
  228. package/worker/src/RTC/SCTP/association/Association.cpp +146 -103
  229. package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
  230. package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
  231. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
  232. package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
  233. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +122 -14
  234. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
  235. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
  236. package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
  237. package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +2 -2
  238. package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
  239. package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
  240. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
  241. package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
  242. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
  243. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
  244. package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
  245. package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
  246. package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
  247. package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
  248. package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
  249. package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
  250. package/worker/src/RTC/TcpConnection.cpp +9 -3
  251. package/worker/src/RTC/TcpServer.cpp +7 -2
  252. package/worker/src/RTC/Transport.cpp +266 -307
  253. package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
  254. package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
  255. package/worker/src/RTC/TrendCalculator.cpp +3 -3
  256. package/worker/src/RTC/UdpSocket.cpp +14 -3
  257. package/worker/src/RTC/WebRtcServer.cpp +20 -14
  258. package/worker/src/RTC/WebRtcTransport.cpp +35 -30
  259. package/worker/src/Settings.cpp +10 -0
  260. package/worker/src/Shared.cpp +2 -2
  261. package/worker/src/Utils/Crypto.cpp +2 -2
  262. package/worker/src/Worker.cpp +5 -1
  263. package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
  264. package/worker/src/handles/TimerHandle.cpp +74 -25
  265. package/worker/src/lib.cpp +6 -0
  266. package/worker/tasks.py +197 -45
  267. package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
  268. package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
  269. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
  270. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
  271. package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
  272. package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
  273. package/worker/test/src/RTC/BWE/TestLossBasedController.cpp +1199 -0
  274. package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
  275. package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
  276. package/worker/test/src/RTC/BWE/TestTargetRateController.cpp +337 -0
  277. package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +182 -0
  278. package/worker/test/src/RTC/BWE/TestUtils.cpp +61 -0
  279. package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
  280. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
  281. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  282. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
  283. package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
  284. package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
  285. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
  286. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
  287. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
  288. package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
  289. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
  290. package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +128 -13
  291. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
  292. package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
  293. package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
  294. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
  295. package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
  296. package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
  297. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
  298. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
  299. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
  300. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
  301. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
  302. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
  303. package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
  304. package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
  305. package/worker/test/src/RTC/TestConsumer.cpp +8 -3
  306. package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
  307. package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
  308. package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
  309. package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
  310. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
  311. package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
  312. package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
  313. package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
  314. package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
  315. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
  316. package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
  317. package/worker/test/src/TestDepLibUV.cpp +19 -0
  318. package/worker/test/src/Utils/TestTime.cpp +57 -26
  319. package/worker/test/src/testHelpers.cpp +1 -1
  320. package/worker/test/src/tests.cpp +6 -0
  321. package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
  322. package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
package/worker/tasks.py CHANGED
@@ -8,8 +8,11 @@ Usage:
8
8
  invoke --list
9
9
  """
10
10
 
11
+ import glob
11
12
  import inspect
13
+ import json
12
14
  import os
15
+ import re
13
16
  import shutil
14
17
  import sys
15
18
  from contextlib import contextmanager, suppress
@@ -26,6 +29,22 @@ MEDIASOUP_INSTALL_DIR = (
26
29
  os.getenv("MEDIASOUP_INSTALL_DIR") or f"{MEDIASOUP_OUT_DIR}/{MEDIASOUP_BUILDTYPE}"
27
30
  )
28
31
  BUILD_DIR = os.getenv("BUILD_DIR") or f"{MEDIASOUP_INSTALL_DIR}/build"
32
+ # NOTE: Each set of Meson options gets its own build directory. Meson keeps the
33
+ # options it's not given again, so sharing a single build directory would leak
34
+ # options such as `ms_build_tests` (which adds MS_TEST and MS_LOG_STD to every
35
+ # compiled file) into the next build, and would also rebuild everything on every
36
+ # switch from a task to another.
37
+ TEST_BUILD_DIR = f"{BUILD_DIR}-test"
38
+ TEST_ASAN_ADDRESS_BUILD_DIR = f"{BUILD_DIR}-test-asan-address"
39
+ TEST_ASAN_UNDEFINED_BUILD_DIR = f"{BUILD_DIR}-test-asan-undefined"
40
+ FUZZER_BUILD_DIR = f"{BUILD_DIR}-fuzzer"
41
+ BUILD_DIRS = [
42
+ BUILD_DIR,
43
+ TEST_BUILD_DIR,
44
+ TEST_ASAN_ADDRESS_BUILD_DIR,
45
+ TEST_ASAN_UNDEFINED_BUILD_DIR,
46
+ FUZZER_BUILD_DIR,
47
+ ]
29
48
  # Custom pip folder for invoke package.
30
49
  # NOTE: We invoke `pip install` always with `--no-user` to make it not complain
31
50
  # about "can not combine --user and --target".
@@ -43,7 +62,7 @@ NUM_CORES = (
43
62
  )
44
63
  PYTHON = os.getenv("PYTHON") or sys.executable
45
64
  MESON = os.getenv("MESON") or f"{PIP_MESON_NINJA_DIR}/bin/meson"
46
- MESON_VERSION = os.getenv("MESON_VERSION") or "1.11.2"
65
+ MESON_VERSION = os.getenv("MESON_VERSION") or "1.12.0"
47
66
  # MESON_ARGS can be used to provide extra configuration parameters to meson,
48
67
  # such as adding defines or changing optimization options. For instance, use
49
68
  # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile
@@ -57,10 +76,7 @@ MESON_ARGS = (
57
76
  if os.name == "nt"
58
77
  else ""
59
78
  )
60
- # Let's use a specific version of ninja to avoid buggy version 1.11.1:
61
- # https://mediasoup.discourse.group/t/partly-solved-could-not-detect-ninja-v1-8-2-or-newer/
62
- # https://github.com/ninja-build/ninja/issues/2211
63
- NINJA_VERSION = os.getenv("NINJA_VERSION") or "1.10.2.4"
79
+ NINJA_VERSION = os.getenv("NINJA_VERSION") or "1.13.2"
64
80
  RUFF_VERSION = os.getenv("RUFF_VERSION") or "0.15.15"
65
81
  NPM = os.getenv("NPM") or "npm"
66
82
  DOCKER = os.getenv("DOCKER") or "docker"
@@ -155,16 +171,73 @@ def meson_ninja(ctx):
155
171
  )
156
172
 
157
173
 
174
+ def default_meson_options():
175
+ """
176
+ Return every option in meson_options.txt mapped to its default value
177
+ """
178
+
179
+ options = {}
180
+
181
+ with open(f"{WORKER_DIR}/meson_options.txt", encoding="utf-8") as options_file:
182
+ for line in options_file:
183
+ match = re.match(r"\s*option\('([^']+)'.*value:\s*([^,)]+)", line)
184
+
185
+ if match:
186
+ options[match.group(1)] = match.group(2).strip().strip(chr(39))
187
+
188
+ return options
189
+
190
+
191
+ def configured_meson_options(build_dir):
192
+ """
193
+ Return the name of every option the given build directory is configured with
194
+ """
195
+
196
+ try:
197
+ with open(
198
+ f"{build_dir}/meson-info/intro-buildoptions.json", encoding="utf-8"
199
+ ) as options_file:
200
+ return {option["name"] for option in json.load(options_file)}
201
+ except (OSError, ValueError):
202
+ return set()
203
+
204
+
158
205
  @task(pre=[meson_ninja])
159
- def setup(ctx, meson_args=MESON_ARGS):
206
+ def setup(ctx, meson_args=MESON_ARGS, build_dir=BUILD_DIR):
160
207
  """
161
208
  Run meson setup
162
209
  """
163
210
 
211
+ # NOTE: Meson keeps every option of an already configured build directory
212
+ # that is not given again, so all of them are passed with their default
213
+ # value before meson_args, which comes later and hence wins. Without this,
214
+ # removing an option from MESON_ARGS would silently keep the value it was
215
+ # given the previous time.
216
+ default_options = default_meson_options()
217
+ default_options_args = " ".join(
218
+ f"-D{name}={value}" for name, value in default_options.items()
219
+ )
220
+
221
+ # NOTE: Given an already configured build directory, "meson setup" just
222
+ # prints "Directory already configured" and exits successfully, silently
223
+ # ignoring the given options. So it must be told to reconfigure it or
224
+ # changing MESON_ARGS would have no effect until the directory is removed.
225
+ reconfigure = ""
226
+
227
+ if os.path.isdir(f"{build_dir}/meson-info"):
228
+ # NOTE: Meson validates the given options against the ones it has cached
229
+ # before reading meson_options.txt again, so a build directory configured
230
+ # back when an option didn't exist yet cannot be reconfigured with it.
231
+ # There is nothing to preserve in that case, so it's built from scratch.
232
+ if default_options.keys() <= configured_meson_options(build_dir):
233
+ reconfigure = "--reconfigure"
234
+ else:
235
+ shutil.rmtree(build_dir, ignore_errors=True)
236
+
164
237
  if MEDIASOUP_BUILDTYPE == "Release":
165
238
  with cd_worker():
166
239
  ctx.run(
167
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {meson_args} "{BUILD_DIR}"',
240
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {default_options_args} {meson_args} "{build_dir}"',
168
241
  echo=True,
169
242
  pty=PTY_SUPPORTED,
170
243
  shell=SHELL,
@@ -172,7 +245,7 @@ def setup(ctx, meson_args=MESON_ARGS):
172
245
  elif MEDIASOUP_BUILDTYPE == "Debug":
173
246
  with cd_worker():
174
247
  ctx.run(
175
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {meson_args} "{BUILD_DIR}"',
248
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {default_options_args} {meson_args} "{build_dir}"',
176
249
  echo=True,
177
250
  pty=PTY_SUPPORTED,
178
251
  shell=SHELL,
@@ -180,7 +253,7 @@ def setup(ctx, meson_args=MESON_ARGS):
180
253
  else:
181
254
  with cd_worker():
182
255
  ctx.run(
183
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {meson_args} "{BUILD_DIR}"',
256
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {default_options_args} {meson_args} "{build_dir}"',
184
257
  echo=True,
185
258
  pty=PTY_SUPPORTED,
186
259
  shell=SHELL,
@@ -190,19 +263,36 @@ def setup(ctx, meson_args=MESON_ARGS):
190
263
  @task
191
264
  def clean(ctx):
192
265
  """
193
- Clean the installation directory
266
+ Clean the objects and binaries of mediasoup, keeping those of subprojects
194
267
  """
195
268
 
196
- shutil.rmtree(MEDIASOUP_INSTALL_DIR, ignore_errors=True)
269
+ # NOTE: Meson keeps the objects of each target in a "<target>.p" directory,
270
+ # and those of the subprojects and the dependencies in their own
271
+ # subdirectories, so this removes just what belongs to mediasoup itself.
272
+ # glob.escape() is needed because the path of the build directory may
273
+ # contain characters that glob would otherwise take as wildcards.
274
+ for build_dir in BUILD_DIRS:
275
+ for path in glob.glob(f"{glob.escape(build_dir)}/*.p"):
276
+ shutil.rmtree(path, ignore_errors=True)
277
+
278
+ # NOTE: The installed artifacts are files, while the build directories are
279
+ # directories.
280
+ for path in glob.glob(f"{glob.escape(MEDIASOUP_INSTALL_DIR)}/*"):
281
+ if os.path.isfile(path):
282
+ # NOTE: Be as tolerant as shutil.rmtree() above, since in Windows
283
+ # removing a binary that is being run fails.
284
+ with suppress(OSError):
285
+ os.remove(path)
197
286
 
198
287
 
199
288
  @task
200
289
  def clean_build(ctx):
201
290
  """
202
- Clean the build directory
291
+ Clean the build directories
203
292
  """
204
293
 
205
- shutil.rmtree(BUILD_DIR, ignore_errors=True)
294
+ for build_dir in BUILD_DIRS:
295
+ shutil.rmtree(build_dir, ignore_errors=True)
206
296
 
207
297
 
208
298
  @task
@@ -246,7 +336,6 @@ def clean_all(ctx):
246
336
  )
247
337
 
248
338
  shutil.rmtree(MEDIASOUP_OUT_DIR, ignore_errors=True)
249
- shutil.rmtree("include/FBS", ignore_errors=True)
250
339
 
251
340
 
252
341
  @task(pre=[meson_ninja])
@@ -274,22 +363,29 @@ def update_wrap_file(ctx, subproject):
274
363
  )
275
364
 
276
365
 
277
- @task(pre=[setup])
278
- def flatc(ctx):
366
+ @task(pre=[meson_ninja])
367
+ def flatc(ctx, meson_args=MESON_ARGS, build_dir=BUILD_DIR):
279
368
  """
280
369
  Compile FlatBuffers FBS files
281
370
  """
282
371
 
372
+ # NOTE: The generated C++ headers are written into the build directory, so
373
+ # they must be generated in the very same build directory that compiles them
374
+ # and with the very same Meson options. setup() is called here instead of
375
+ # being declared as a pre task because a pre task cannot receive the
376
+ # parameters given to the task it precedes.
377
+ setup(ctx, meson_args=meson_args, build_dir=build_dir)
378
+
283
379
  with cd_worker():
284
380
  ctx.run(
285
- f'"{MESON}" compile -C "{BUILD_DIR}" flatbuffers-generator',
381
+ f'"{MESON}" compile -C "{build_dir}" flatbuffers-generator',
286
382
  echo=True,
287
383
  pty=PTY_SUPPORTED,
288
384
  shell=SHELL,
289
385
  )
290
386
 
291
387
 
292
- @task(pre=[setup, flatc], default=True)
388
+ @task(pre=[flatc], default=True)
293
389
  def mediasoup_worker(ctx):
294
390
  """
295
391
  Compile mediasoup-worker binary
@@ -317,7 +413,7 @@ def mediasoup_worker(ctx):
317
413
  )
318
414
 
319
415
 
320
- @task(pre=[setup, flatc])
416
+ @task(pre=[flatc])
321
417
  def libmediasoup_worker(ctx):
322
418
  """
323
419
  Compile libmediasoup-worker library
@@ -339,7 +435,7 @@ def libmediasoup_worker(ctx):
339
435
  )
340
436
 
341
437
 
342
- @task(pre=[setup, flatc])
438
+ @task(pre=[flatc])
343
439
  def xcode(ctx):
344
440
  """
345
441
  Setup Xcode project
@@ -419,7 +515,49 @@ def format(ctx):
419
515
  ctx.run(f'"{PYTHON}" -m ruff format', echo=True, pty=PTY_SUPPORTED, shell=SHELL)
420
516
 
421
517
 
422
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
518
+ @task(
519
+ pre=[
520
+ call(
521
+ flatc,
522
+ meson_args=MESON_ARGS + " -Dms_build_tests=true",
523
+ build_dir=TEST_BUILD_DIR,
524
+ )
525
+ ]
526
+ )
527
+ def tidy_setup(ctx):
528
+ """
529
+ Configure the build directory that `tidy` uses, generating its
530
+ compile_commands.json
531
+
532
+ NOTE: Test files are only given the Catch2 include paths when
533
+ `ms_build_tests` is enabled, so clang-tidy needs this very build directory to
534
+ analyze them.
535
+ """
536
+
537
+
538
+ @task(pre=[tidy_setup])
539
+ def tidy_normalize_compile_commands(ctx):
540
+ """
541
+ Rewrite the paths of the compile_commands.json that `tidy` uses so that
542
+ third party clang-tidy runners can resolve them
543
+
544
+ NOTE: Just needed by CI, since it doesn't run `tidy` but its own clang-tidy
545
+ over the files of the pull request.
546
+ """
547
+
548
+ with cd_worker():
549
+ ctx.run(
550
+ f'"{NPM}" run normalize-compile-commands --prefix scripts/',
551
+ echo=True,
552
+ pty=PTY_SUPPORTED,
553
+ shell=SHELL,
554
+ # NOTE: Tell the script which build directory holds the
555
+ # compile_commands.json to use.
556
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
557
+ )
558
+
559
+
560
+ @task(pre=[tidy_setup])
423
561
  def tidy(ctx):
424
562
  """
425
563
  Performs C++ code checks according to `worker/.clang-tidy` rules
@@ -431,10 +569,13 @@ def tidy(ctx):
431
569
  echo=True,
432
570
  pty=PTY_SUPPORTED,
433
571
  shell=SHELL,
572
+ # NOTE: Tell the script which build directory holds the
573
+ # compile_commands.json to use.
574
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
434
575
  )
435
576
 
436
577
 
437
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
578
+ @task(pre=[tidy_setup])
438
579
  def tidy_fix(ctx):
439
580
  """
440
581
  Performs C++ code checks according to `worker/.clang-tidy` rules and applies
@@ -447,10 +588,21 @@ def tidy_fix(ctx):
447
588
  echo=True,
448
589
  pty=PTY_SUPPORTED,
449
590
  shell=SHELL,
591
+ # NOTE: Tell the script which build directory holds the
592
+ # compile_commands.json to use.
593
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
450
594
  )
451
595
 
452
596
 
453
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
597
+ @task(
598
+ pre=[
599
+ call(
600
+ flatc,
601
+ meson_args=MESON_ARGS + " -Dms_build_tests=true",
602
+ build_dir=TEST_BUILD_DIR,
603
+ )
604
+ ]
605
+ )
454
606
  def test(ctx):
455
607
  """
456
608
  Run worker tests
@@ -458,14 +610,14 @@ def test(ctx):
458
610
 
459
611
  with cd_worker():
460
612
  ctx.run(
461
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
613
+ f'"{MESON}" compile -C "{TEST_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
462
614
  echo=True,
463
615
  pty=PTY_SUPPORTED,
464
616
  shell=SHELL,
465
617
  )
466
618
  with cd_worker():
467
619
  ctx.run(
468
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
620
+ f'"{MESON}" install -C "{TEST_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
469
621
  echo=True,
470
622
  pty=PTY_SUPPORTED,
471
623
  shell=SHELL,
@@ -478,7 +630,7 @@ def test(ctx):
478
630
 
479
631
  with cd_worker():
480
632
  ctx.run(
481
- f'"{BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
633
+ f'"{TEST_BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
482
634
  echo=True,
483
635
  pty=PTY_SUPPORTED,
484
636
  shell=SHELL,
@@ -488,11 +640,11 @@ def test(ctx):
488
640
  @task(
489
641
  pre=[
490
642
  call(
491
- setup,
643
+ flatc,
492
644
  meson_args=MESON_ARGS
493
645
  + " -Dms_build_tests=true -Db_sanitize=address -Db_lundef=false",
494
- ),
495
- flatc,
646
+ build_dir=TEST_ASAN_ADDRESS_BUILD_DIR,
647
+ )
496
648
  ]
497
649
  )
498
650
  def test_asan_address(ctx):
@@ -502,14 +654,14 @@ def test_asan_address(ctx):
502
654
 
503
655
  with cd_worker():
504
656
  ctx.run(
505
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-address',
657
+ f'"{MESON}" compile -C "{TEST_ASAN_ADDRESS_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-address',
506
658
  echo=True,
507
659
  pty=PTY_SUPPORTED,
508
660
  shell=SHELL,
509
661
  )
510
662
  with cd_worker():
511
663
  ctx.run(
512
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-address',
664
+ f'"{MESON}" install -C "{TEST_ASAN_ADDRESS_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-address',
513
665
  echo=True,
514
666
  pty=PTY_SUPPORTED,
515
667
  shell=SHELL,
@@ -519,7 +671,7 @@ def test_asan_address(ctx):
519
671
 
520
672
  with cd_worker():
521
673
  ctx.run(
522
- f'"{BUILD_DIR}/mediasoup-worker-test-asan-address" --invisibles {mediasoup_test_tags}',
674
+ f'"{TEST_ASAN_ADDRESS_BUILD_DIR}/mediasoup-worker-test-asan-address" --invisibles {mediasoup_test_tags}',
523
675
  echo=True,
524
676
  pty=PTY_SUPPORTED,
525
677
  shell=SHELL,
@@ -533,11 +685,11 @@ def test_asan_address(ctx):
533
685
  @task(
534
686
  pre=[
535
687
  call(
536
- setup,
688
+ flatc,
537
689
  meson_args=MESON_ARGS
538
690
  + " -Dms_build_tests=true -Db_sanitize=undefined -Db_lundef=false",
539
- ),
540
- flatc,
691
+ build_dir=TEST_ASAN_UNDEFINED_BUILD_DIR,
692
+ )
541
693
  ]
542
694
  )
543
695
  def test_asan_undefined(ctx):
@@ -547,14 +699,14 @@ def test_asan_undefined(ctx):
547
699
 
548
700
  with cd_worker():
549
701
  ctx.run(
550
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-undefined',
702
+ f'"{MESON}" compile -C "{TEST_ASAN_UNDEFINED_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-undefined',
551
703
  echo=True,
552
704
  pty=PTY_SUPPORTED,
553
705
  shell=SHELL,
554
706
  )
555
707
  with cd_worker():
556
708
  ctx.run(
557
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-undefined',
709
+ f'"{MESON}" install -C "{TEST_ASAN_UNDEFINED_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-undefined',
558
710
  echo=True,
559
711
  pty=PTY_SUPPORTED,
560
712
  shell=SHELL,
@@ -564,7 +716,7 @@ def test_asan_undefined(ctx):
564
716
 
565
717
  with cd_worker():
566
718
  ctx.run(
567
- f'"{BUILD_DIR}/mediasoup-worker-test-asan-undefined" --invisibles {mediasoup_test_tags}',
719
+ f'"{TEST_ASAN_UNDEFINED_BUILD_DIR}/mediasoup-worker-test-asan-undefined" --invisibles {mediasoup_test_tags}',
568
720
  echo=True,
569
721
  pty=PTY_SUPPORTED,
570
722
  shell=SHELL,
@@ -580,11 +732,11 @@ def test_asan_undefined(ctx):
580
732
  @task(
581
733
  pre=[
582
734
  call(
583
- setup,
735
+ flatc,
584
736
  meson_args=MESON_ARGS
585
737
  + " -Dms_build_fuzzer=true -Db_sanitize=address -Db_lundef=false",
586
- ),
587
- flatc,
738
+ build_dir=FUZZER_BUILD_DIR,
739
+ )
588
740
  ]
589
741
  )
590
742
  def fuzzer(ctx):
@@ -593,18 +745,18 @@ def fuzzer(ctx):
593
745
  """
594
746
 
595
747
  # NOTE: We need to pass '-Db_sanitize=address' to enable fuzzer in all Meson
596
- # subprojects, so we pass it to the setup() task.
748
+ # subprojects, so we pass it to the setup() task (through the flatc() task).
597
749
 
598
750
  with cd_worker():
599
751
  ctx.run(
600
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
752
+ f'"{MESON}" compile -C "{FUZZER_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
601
753
  echo=True,
602
754
  pty=PTY_SUPPORTED,
603
755
  shell=SHELL,
604
756
  )
605
757
  with cd_worker():
606
758
  ctx.run(
607
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
759
+ f'"{MESON}" install -C "{FUZZER_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
608
760
  echo=True,
609
761
  pty=PTY_SUPPORTED,
610
762
  shell=SHELL,
@@ -619,7 +771,7 @@ def fuzzer_run_all(ctx):
619
771
 
620
772
  with cd_worker():
621
773
  ctx.run(
622
- f'LSAN_OPTIONS=verbosity=1:log_threads=1 "{BUILD_DIR}/mediasoup-worker-fuzzer" -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus',
774
+ f'LSAN_OPTIONS=verbosity=1:log_threads=1 "{FUZZER_BUILD_DIR}/mediasoup-worker-fuzzer" -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus',
623
775
  echo=True,
624
776
  pty=PTY_SUPPORTED,
625
777
  shell=SHELL,
@@ -0,0 +1,117 @@
1
+ #ifndef MS_TEST_RTC_BWE_LINK_SIMULATOR_HPP
2
+ #define MS_TEST_RTC_BWE_LINK_SIMULATOR_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/BweTypes.hpp"
6
+
7
+ namespace bweHelpers
8
+ {
9
+ /**
10
+ * A stream that produces frames at a given frame rate and bitrate, split into
11
+ * packets of at most one MTU.
12
+ */
13
+ class RtpStream
14
+ {
15
+ public:
16
+ /**
17
+ * Offset added to the send times so that they don't share the origin with
18
+ * the arrival ones, which would hide a mistake mixing both references.
19
+ */
20
+ static constexpr int64_t SendSideOffsetUs{ 1000 * 1000 };
21
+
22
+ public:
23
+ RtpStream(int fps, int64_t bitrateBps);
24
+
25
+ RtpStream& operator=(const RtpStream&) = delete;
26
+
27
+ RtpStream(const RtpStream&) = delete;
28
+
29
+ /**
30
+ * Generate a frame and split it into packets, appending them to
31
+ * `packetResults`. Nothing is generated if it's called before the next frame
32
+ * is due.
33
+ *
34
+ * @returns The send time at which the next frame can be generated.
35
+ */
36
+ int64_t GenerateFrame(
37
+ int64_t timeNowUs,
38
+ int64_t& nextSequenceNumber,
39
+ std::vector<RTC::BWE::Types::PacketResult>& packetResults);
40
+
41
+ /**
42
+ * Send time at which the next frame can be generated.
43
+ */
44
+ int64_t GetNextRtpTimeUs() const
45
+ {
46
+ return this->nextRtpTimeUs;
47
+ }
48
+
49
+ int64_t GetBitrateBps() const
50
+ {
51
+ return this->bitrateBps;
52
+ }
53
+
54
+ void SetBitrateBps(int64_t bitrateBps);
55
+
56
+ /**
57
+ * Orders streams by which one is due to produce a frame first.
58
+ */
59
+ static bool Compare(const std::unique_ptr<RtpStream>& lhs, const std::unique_ptr<RtpStream>& rhs);
60
+
61
+ private:
62
+ const int fps;
63
+ int64_t bitrateBps;
64
+ int64_t nextRtpTimeUs{ 0 };
65
+ };
66
+
67
+ /**
68
+ * Pushes the frames of several streams through a link of a given capacity and
69
+ * decides when each packet arrives.
70
+ *
71
+ * The link has no queue limit: a packet takes as long to arrive as its size
72
+ * divided by the capacity, and packets that don't fit queue up behind the
73
+ * previous one for as long as needed.
74
+ */
75
+ class LinkSimulator
76
+ {
77
+ public:
78
+ LinkSimulator(int64_t capacityBps, int64_t timeNowUs);
79
+
80
+ LinkSimulator& operator=(const LinkSimulator&) = delete;
81
+
82
+ LinkSimulator(const LinkSimulator&) = delete;
83
+
84
+ /**
85
+ * Add a stream, whose ownership is taken.
86
+ */
87
+ void AddStream(std::unique_ptr<RtpStream> stream);
88
+
89
+ void SetCapacityBps(int64_t capacityBps);
90
+
91
+ /**
92
+ * Divide `bitrateBps` among the streams, keeping the ratios they had.
93
+ */
94
+ void SetBitrateBps(int64_t bitrateBps);
95
+
96
+ /**
97
+ * Generate a frame of whichever stream is due first and push its packets
98
+ * through the link, appending them to `packetResults` with the time at which
99
+ * each one arrives.
100
+ *
101
+ * @returns The send time at which the next frame can be generated.
102
+ */
103
+ int64_t GenerateFrame(
104
+ int64_t timeNowUs,
105
+ int64_t& nextSequenceNumber,
106
+ std::vector<RTC::BWE::Types::PacketResult>& packetResults);
107
+
108
+ private:
109
+ // Capacity of the simulated link (bps).
110
+ int64_t capacityBps;
111
+ // Time at which the latest packet arrived.
112
+ int64_t prevArrivalTimeUs;
113
+ std::vector<std::unique_ptr<RtpStream>> streams;
114
+ };
115
+ } // namespace bweHelpers
116
+
117
+ #endif