mediasoup 3.26.0 → 3.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/CHANGELOG.md +11 -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/rtpParameters.fbs +1 -2
  49. package/worker/fbs/rtpStream.fbs +3 -3
  50. package/worker/fbs/transport.fbs +23 -23
  51. package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
  52. package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
  53. package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
  54. package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
  55. package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
  56. package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
  57. package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
  58. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
  59. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
  60. package/worker/fuzzer/src/fuzzer.cpp +4 -0
  61. package/worker/include/Channel/ChannelNotification.hpp +3 -3
  62. package/worker/include/Channel/ChannelRequest.hpp +1 -1
  63. package/worker/include/Channel/ChannelSocket.hpp +11 -0
  64. package/worker/include/DepLibUV.hpp +16 -33
  65. package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
  66. package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
  67. package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
  68. package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
  69. package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
  70. package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
  71. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
  72. package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
  73. package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
  74. package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
  75. package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
  76. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +101 -0
  77. package/worker/include/RTC/Consts.hpp +6 -6
  78. package/worker/include/RTC/Consumer.hpp +14 -12
  79. package/worker/include/RTC/DataConsumer.hpp +3 -3
  80. package/worker/include/RTC/DataProducer.hpp +3 -3
  81. package/worker/include/RTC/DtlsTransport.hpp +5 -2
  82. package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
  83. package/worker/include/RTC/ICE/IceServer.hpp +3 -3
  84. package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
  85. package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
  86. package/worker/include/RTC/NackGenerator.hpp +12 -12
  87. package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
  88. package/worker/include/RTC/PipeTransport.hpp +18 -5
  89. package/worker/include/RTC/PlainTransport.hpp +18 -5
  90. package/worker/include/RTC/PortManager.hpp +4 -4
  91. package/worker/include/RTC/Producer.hpp +21 -12
  92. package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
  93. package/worker/include/RTC/RTCP/Bye.hpp +2 -2
  94. package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
  95. package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
  96. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
  97. package/worker/include/RTC/RTCP/Packet.hpp +3 -3
  98. package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
  99. package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
  100. package/worker/include/RTC/RTCP/XR.hpp +2 -2
  101. package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
  102. package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
  103. package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
  104. package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
  105. package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
  106. package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
  107. package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
  108. package/worker/include/RTC/RTP/Packet.hpp +13 -13
  109. package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
  110. package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
  111. package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
  112. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
  113. package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
  114. package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
  115. package/worker/include/RTC/RateCalculator.hpp +50 -44
  116. package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
  117. package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
  118. package/worker/include/RTC/Router.hpp +6 -0
  119. package/worker/include/RTC/RtcLogger.hpp +1 -1
  120. package/worker/include/RTC/RtpDictionaries.hpp +10 -10
  121. package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
  122. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
  123. package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
  124. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +2 -2
  125. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
  126. package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
  127. package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
  128. package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
  129. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
  130. package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
  131. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
  132. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +1 -1
  133. package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
  134. package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
  135. package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
  136. package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
  137. package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
  138. package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
  139. package/worker/include/RTC/SctpDictionaries.hpp +3 -3
  140. package/worker/include/RTC/Serializable.hpp +1 -1
  141. package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
  142. package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
  143. package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
  144. package/worker/include/RTC/TcpConnection.hpp +9 -3
  145. package/worker/include/RTC/TcpServer.hpp +3 -0
  146. package/worker/include/RTC/Transport.hpp +52 -45
  147. package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
  148. package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
  149. package/worker/include/RTC/TrendCalculator.hpp +5 -5
  150. package/worker/include/RTC/UdpSocket.hpp +11 -2
  151. package/worker/include/RTC/WebRtcServer.hpp +20 -5
  152. package/worker/include/RTC/WebRtcTransport.hpp +35 -10
  153. package/worker/include/Settings.hpp +4 -2
  154. package/worker/include/Shared.hpp +5 -20
  155. package/worker/include/SharedInterface.hpp +6 -28
  156. package/worker/include/Utils.hpp +40 -21
  157. package/worker/include/common.hpp +4 -0
  158. package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
  159. package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
  160. package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
  161. package/worker/include/handles/TcpServerHandle.hpp +1 -1
  162. package/worker/include/handles/TimerHandle.hpp +15 -9
  163. package/worker/include/handles/TimerHandleInterface.hpp +10 -4
  164. package/worker/include/handles/UdpSocketHandle.hpp +3 -3
  165. package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
  166. package/worker/meson.build +81 -36
  167. package/worker/meson_options.txt +1 -0
  168. package/worker/mocks/include/MockShared.hpp +24 -23
  169. package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
  170. package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
  171. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
  172. package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
  173. package/worker/mocks/src/MockShared.cpp +51 -5
  174. package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
  175. package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
  176. package/worker/scripts/clang-scripts.mjs +2 -2
  177. package/worker/src/Channel/ChannelNotification.cpp +5 -6
  178. package/worker/src/Channel/ChannelSocket.cpp +20 -2
  179. package/worker/src/DepLibUV.cpp +4 -5
  180. package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
  181. package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
  182. package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
  183. package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
  184. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
  185. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
  186. package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
  187. package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
  188. package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
  189. package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
  190. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +233 -0
  191. package/worker/src/RTC/Consumer.cpp +48 -35
  192. package/worker/src/RTC/DataConsumer.cpp +4 -4
  193. package/worker/src/RTC/DataProducer.cpp +3 -3
  194. package/worker/src/RTC/DirectTransport.cpp +2 -2
  195. package/worker/src/RTC/DtlsTransport.cpp +14 -11
  196. package/worker/src/RTC/ICE/IceServer.cpp +2 -2
  197. package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
  198. package/worker/src/RTC/NackGenerator.cpp +12 -12
  199. package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
  200. package/worker/src/RTC/PipeTransport.cpp +16 -13
  201. package/worker/src/RTC/PlainTransport.cpp +25 -16
  202. package/worker/src/RTC/Producer.cpp +50 -36
  203. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
  204. package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
  205. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
  206. package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
  207. package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
  208. package/worker/src/RTC/RTP/Packet.cpp +9 -10
  209. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
  210. package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
  211. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
  212. package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
  213. package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
  214. package/worker/src/RTC/RateCalculator.cpp +99 -136
  215. package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
  216. package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
  217. package/worker/src/RTC/Router.cpp +18 -1
  218. package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
  219. package/worker/src/RTC/SCTP/association/Association.cpp +131 -102
  220. package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
  221. package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
  222. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
  223. package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
  224. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +16 -13
  225. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
  226. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
  227. package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
  228. package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
  229. package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
  230. package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
  231. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
  232. package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
  233. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
  234. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
  235. package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
  236. package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
  237. package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
  238. package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
  239. package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
  240. package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
  241. package/worker/src/RTC/TcpConnection.cpp +9 -3
  242. package/worker/src/RTC/TcpServer.cpp +7 -2
  243. package/worker/src/RTC/Transport.cpp +242 -302
  244. package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
  245. package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
  246. package/worker/src/RTC/TrendCalculator.cpp +3 -3
  247. package/worker/src/RTC/UdpSocket.cpp +14 -3
  248. package/worker/src/RTC/WebRtcServer.cpp +20 -14
  249. package/worker/src/RTC/WebRtcTransport.cpp +35 -30
  250. package/worker/src/Settings.cpp +10 -0
  251. package/worker/src/Shared.cpp +2 -2
  252. package/worker/src/Utils/Crypto.cpp +2 -2
  253. package/worker/src/Worker.cpp +5 -1
  254. package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
  255. package/worker/src/handles/TimerHandle.cpp +74 -25
  256. package/worker/src/lib.cpp +6 -0
  257. package/worker/tasks.py +171 -44
  258. package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
  259. package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
  260. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
  261. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
  262. package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
  263. package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
  264. package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
  265. package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
  266. package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +137 -0
  267. package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
  268. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
  269. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  270. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
  271. package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
  272. package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
  273. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
  274. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
  275. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
  276. package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
  277. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
  278. package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +17 -13
  279. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
  280. package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
  281. package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
  282. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
  283. package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
  284. package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
  285. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
  286. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
  287. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
  288. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
  289. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
  290. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
  291. package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
  292. package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
  293. package/worker/test/src/RTC/TestConsumer.cpp +8 -3
  294. package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
  295. package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
  296. package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
  297. package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
  298. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
  299. package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
  300. package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
  301. package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
  302. package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
  303. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
  304. package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
  305. package/worker/test/src/TestDepLibUV.cpp +19 -0
  306. package/worker/test/src/Utils/TestTime.cpp +57 -26
  307. package/worker/test/src/testHelpers.cpp +1 -1
  308. package/worker/test/src/tests.cpp +6 -0
  309. package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
  310. package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
@@ -24,11 +24,27 @@ static void onCloseTimer(uv_handle_t* handle)
24
24
 
25
25
  /* Instance methods. */
26
26
 
27
- TimerHandle::TimerHandle(TimerHandleInterface::Listener* listener)
28
- : listener(listener), uvHandle(new uv_timer_t)
27
+ TimerHandle::TimerHandle(TimerHandleInterface::Listener* listener, std::string label)
28
+ : listener(listener), label(std::move(label)), uvHandle(new uv_timer_t)
29
29
  {
30
30
  MS_TRACE();
31
31
 
32
+ if (!this->listener)
33
+ {
34
+ delete this->uvHandle;
35
+ this->uvHandle = nullptr;
36
+
37
+ MS_THROW_TYPE_ERROR("[%s] listener must be given", this->label.c_str());
38
+ }
39
+
40
+ if (this->label.empty())
41
+ {
42
+ delete this->uvHandle;
43
+ this->uvHandle = nullptr;
44
+
45
+ MS_THROW_TYPE_ERROR("label must be given");
46
+ }
47
+
32
48
  this->uvHandle->data = static_cast<void*>(this);
33
49
 
34
50
  const int err = uv_timer_init(DepLibUV::GetLoop(), this->uvHandle);
@@ -38,7 +54,7 @@ TimerHandle::TimerHandle(TimerHandleInterface::Listener* listener)
38
54
  delete this->uvHandle;
39
55
  this->uvHandle = nullptr;
40
56
 
41
- MS_THROW_ERROR("uv_timer_init() failed: %s", uv_strerror(err));
57
+ MS_THROW_ERROR("[%s] uv_timer_init() failed: %s", this->label.c_str(), uv_strerror(err));
42
58
  }
43
59
  }
44
60
 
@@ -52,17 +68,29 @@ TimerHandle::~TimerHandle()
52
68
  }
53
69
  }
54
70
 
55
- void TimerHandle::Start(uint64_t timeout, uint64_t repeat)
71
+ void TimerHandle::Start(int64_t timeoutMs, int64_t repeatMs)
56
72
  {
57
73
  MS_TRACE();
58
74
 
59
75
  if (this->closed)
60
76
  {
61
- MS_THROW_ERROR("closed");
77
+ MS_THROW_ERROR("[%s] closed", this->label.c_str());
62
78
  }
63
79
 
64
- this->timeout = timeout;
65
- this->repeat = repeat;
80
+ if (timeoutMs < 0)
81
+ {
82
+ MS_THROW_TYPE_ERROR(
83
+ "[%s] timeoutMs (%" PRIi64 " ms) cannot be negative", this->label.c_str(), timeoutMs);
84
+ }
85
+
86
+ if (repeatMs < 0)
87
+ {
88
+ MS_THROW_TYPE_ERROR(
89
+ "[%s] repeatMs (%" PRIi64 " ms) cannot be negative", this->label.c_str(), repeatMs);
90
+ }
91
+
92
+ this->timeoutMs = timeoutMs;
93
+ this->repeatMs = repeatMs;
66
94
 
67
95
  int err;
68
96
 
@@ -72,16 +100,19 @@ void TimerHandle::Start(uint64_t timeout, uint64_t repeat)
72
100
 
73
101
  if (err != 0)
74
102
  {
75
- MS_THROW_ERROR("uv_timer_stop() failed: %s", uv_strerror(err));
103
+ MS_THROW_ERROR("[%s] uv_timer_stop() failed: %s", this->label.c_str(), uv_strerror(err));
76
104
  }
77
105
  }
78
106
 
79
- err =
80
- uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), this->timeout, this->repeat);
107
+ err = uv_timer_start(
108
+ this->uvHandle,
109
+ static_cast<uv_timer_cb>(onTimer),
110
+ static_cast<uint64_t>(this->timeoutMs),
111
+ static_cast<uint64_t>(this->repeatMs));
81
112
 
82
113
  if (err != 0)
83
114
  {
84
- MS_THROW_ERROR("uv_timer_start() failed: %s", uv_strerror(err));
115
+ MS_THROW_ERROR("[%s] uv_timer_start() failed: %s", this->label.c_str(), uv_strerror(err));
85
116
  }
86
117
  }
87
118
 
@@ -91,7 +122,7 @@ void TimerHandle::Stop()
91
122
 
92
123
  if (this->closed)
93
124
  {
94
- MS_THROW_ERROR("closed");
125
+ MS_THROW_ERROR("[%s] closed", this->label.c_str());
95
126
  }
96
127
 
97
128
  const int err = uv_timer_stop(this->uvHandle);
@@ -108,7 +139,7 @@ void TimerHandle::Restart()
108
139
 
109
140
  if (this->closed)
110
141
  {
111
- MS_THROW_ERROR("closed");
142
+ MS_THROW_ERROR("[%s] closed", this->label.c_str());
112
143
  }
113
144
 
114
145
  int err;
@@ -119,30 +150,45 @@ void TimerHandle::Restart()
119
150
 
120
151
  if (err != 0)
121
152
  {
122
- MS_THROW_ERROR("uv_timer_stop() failed: %s", uv_strerror(err));
153
+ MS_THROW_ERROR("[%s] uv_timer_stop() failed: %s", this->label.c_str(), uv_strerror(err));
123
154
  }
124
155
  }
125
156
 
126
- err =
127
- uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), this->timeout, this->repeat);
157
+ err = uv_timer_start(
158
+ this->uvHandle,
159
+ static_cast<uv_timer_cb>(onTimer),
160
+ static_cast<uint64_t>(this->timeoutMs),
161
+ static_cast<uint64_t>(this->repeatMs));
128
162
 
129
163
  if (err != 0)
130
164
  {
131
- MS_THROW_ERROR("uv_timer_start() failed: %s", uv_strerror(err));
165
+ MS_THROW_ERROR("[%s] uv_timer_start() failed: %s", this->label.c_str(), uv_strerror(err));
132
166
  }
133
167
  }
134
168
 
135
- void TimerHandle::Restart(uint64_t timeout, uint64_t repeat)
169
+ void TimerHandle::Restart(int64_t timeoutMs, int64_t repeatMs)
136
170
  {
137
171
  MS_TRACE();
138
172
 
139
173
  if (this->closed)
140
174
  {
141
- MS_THROW_ERROR("closed");
175
+ MS_THROW_ERROR("[%s] closed", this->label.c_str());
176
+ }
177
+
178
+ if (timeoutMs < 0)
179
+ {
180
+ MS_THROW_TYPE_ERROR(
181
+ "[%s] timeoutMs (%" PRIi64 " ms) cannot be negative", this->label.c_str(), timeoutMs);
182
+ }
183
+
184
+ if (repeatMs < 0)
185
+ {
186
+ MS_THROW_TYPE_ERROR(
187
+ "[%s] repeatMs (%" PRIi64 " ms) cannot be negative", this->label.c_str(), repeatMs);
142
188
  }
143
189
 
144
- this->timeout = timeout;
145
- this->repeat = repeat;
190
+ this->timeoutMs = timeoutMs;
191
+ this->repeatMs = repeatMs;
146
192
 
147
193
  int err;
148
194
 
@@ -152,16 +198,19 @@ void TimerHandle::Restart(uint64_t timeout, uint64_t repeat)
152
198
 
153
199
  if (err != 0)
154
200
  {
155
- MS_THROW_ERROR("uv_timer_stop() failed: %s", uv_strerror(err));
201
+ MS_THROW_ERROR("[%s] uv_timer_stop() failed: %s", this->label.c_str(), uv_strerror(err));
156
202
  }
157
203
  }
158
204
 
159
- err =
160
- uv_timer_start(this->uvHandle, static_cast<uv_timer_cb>(onTimer), this->timeout, this->repeat);
205
+ err = uv_timer_start(
206
+ this->uvHandle,
207
+ static_cast<uv_timer_cb>(onTimer),
208
+ static_cast<uint64_t>(this->timeoutMs),
209
+ static_cast<uint64_t>(this->repeatMs));
161
210
 
162
211
  if (err != 0)
163
212
  {
164
- MS_THROW_ERROR("uv_timer_start() failed: %s", uv_strerror(err));
213
+ MS_THROW_ERROR("[%s] uv_timer_start() failed: %s", this->label.c_str(), uv_strerror(err));
165
214
  }
166
215
  }
167
216
 
@@ -8,7 +8,9 @@
8
8
  #include "Channel/ChannelSocket.hpp"
9
9
  #include "DepLibSRTP.hpp"
10
10
  #include "DepLibUV.hpp"
11
+ #ifndef MS_USE_BUILTIN_BWE
11
12
  #include "DepLibWebRTC.hpp"
13
+ #endif
12
14
  #include "DepOpenSSL.hpp"
13
15
  #include "Logger.hpp"
14
16
  #include "MediaSoupErrors.hpp"
@@ -150,7 +152,9 @@ extern "C" int mediasoup_worker_run(
150
152
  // Initialize static stuff.
151
153
  DepOpenSSL::ClassInit();
152
154
  DepLibSRTP::ClassInit();
155
+ #ifndef MS_USE_BUILTIN_BWE
153
156
  DepLibWebRTC::ClassInit();
157
+ #endif
154
158
  Utils::Crypto::ClassInit();
155
159
  RTC::DtlsTransport::ClassInit();
156
160
  RTC::SrtpSession::ClassInit();
@@ -168,7 +172,9 @@ extern "C" int mediasoup_worker_run(
168
172
  // Free static stuff.
169
173
  DepLibSRTP::ClassDestroy();
170
174
  Utils::Crypto::ClassDestroy();
175
+ #ifndef MS_USE_BUILTIN_BWE
171
176
  DepLibWebRTC::ClassDestroy();
177
+ #endif
172
178
  RTC::DtlsTransport::ClassDestroy();
173
179
  DepLibUV::ClassDestroy();
174
180
 
package/worker/tasks.py CHANGED
@@ -8,8 +8,10 @@ Usage:
8
8
  invoke --list
9
9
  """
10
10
 
11
+ import glob
11
12
  import inspect
12
13
  import os
14
+ import re
13
15
  import shutil
14
16
  import sys
15
17
  from contextlib import contextmanager, suppress
@@ -26,6 +28,22 @@ MEDIASOUP_INSTALL_DIR = (
26
28
  os.getenv("MEDIASOUP_INSTALL_DIR") or f"{MEDIASOUP_OUT_DIR}/{MEDIASOUP_BUILDTYPE}"
27
29
  )
28
30
  BUILD_DIR = os.getenv("BUILD_DIR") or f"{MEDIASOUP_INSTALL_DIR}/build"
31
+ # NOTE: Each set of Meson options gets its own build directory. Meson keeps the
32
+ # options it's not given again, so sharing a single build directory would leak
33
+ # options such as `ms_build_tests` (which adds MS_TEST and MS_LOG_STD to every
34
+ # compiled file) into the next build, and would also rebuild everything on every
35
+ # switch from a task to another.
36
+ TEST_BUILD_DIR = f"{BUILD_DIR}-test"
37
+ TEST_ASAN_ADDRESS_BUILD_DIR = f"{BUILD_DIR}-test-asan-address"
38
+ TEST_ASAN_UNDEFINED_BUILD_DIR = f"{BUILD_DIR}-test-asan-undefined"
39
+ FUZZER_BUILD_DIR = f"{BUILD_DIR}-fuzzer"
40
+ BUILD_DIRS = [
41
+ BUILD_DIR,
42
+ TEST_BUILD_DIR,
43
+ TEST_ASAN_ADDRESS_BUILD_DIR,
44
+ TEST_ASAN_UNDEFINED_BUILD_DIR,
45
+ FUZZER_BUILD_DIR,
46
+ ]
29
47
  # Custom pip folder for invoke package.
30
48
  # NOTE: We invoke `pip install` always with `--no-user` to make it not complain
31
49
  # about "can not combine --user and --target".
@@ -43,7 +61,7 @@ NUM_CORES = (
43
61
  )
44
62
  PYTHON = os.getenv("PYTHON") or sys.executable
45
63
  MESON = os.getenv("MESON") or f"{PIP_MESON_NINJA_DIR}/bin/meson"
46
- MESON_VERSION = os.getenv("MESON_VERSION") or "1.11.2"
64
+ MESON_VERSION = os.getenv("MESON_VERSION") or "1.12.0"
47
65
  # MESON_ARGS can be used to provide extra configuration parameters to meson,
48
66
  # such as adding defines or changing optimization options. For instance, use
49
67
  # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile
@@ -57,10 +75,7 @@ MESON_ARGS = (
57
75
  if os.name == "nt"
58
76
  else ""
59
77
  )
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"
78
+ NINJA_VERSION = os.getenv("NINJA_VERSION") or "1.13.2"
64
79
  RUFF_VERSION = os.getenv("RUFF_VERSION") or "0.15.15"
65
80
  NPM = os.getenv("NPM") or "npm"
66
81
  DOCKER = os.getenv("DOCKER") or "docker"
@@ -155,16 +170,48 @@ def meson_ninja(ctx):
155
170
  )
156
171
 
157
172
 
173
+ def default_meson_options():
174
+ """
175
+ Return every option in meson_options.txt set to its default value
176
+ """
177
+
178
+ options = []
179
+
180
+ with open(f"{WORKER_DIR}/meson_options.txt", encoding="utf-8") as options_file:
181
+ for line in options_file:
182
+ match = re.match(r"\s*option\('([^']+)'.*value:\s*([^,)]+)", line)
183
+
184
+ if match:
185
+ options.append(
186
+ f"-D{match.group(1)}={match.group(2).strip().strip(chr(39))}"
187
+ )
188
+
189
+ return " ".join(options)
190
+
191
+
158
192
  @task(pre=[meson_ninja])
159
- def setup(ctx, meson_args=MESON_ARGS):
193
+ def setup(ctx, meson_args=MESON_ARGS, build_dir=BUILD_DIR):
160
194
  """
161
195
  Run meson setup
162
196
  """
163
197
 
198
+ # NOTE: Given an already configured build directory, "meson setup" just
199
+ # prints "Directory already configured" and exits successfully, silently
200
+ # ignoring the given options. So it must be told to reconfigure it or
201
+ # changing MESON_ARGS would have no effect until the directory is removed.
202
+ reconfigure = "--reconfigure" if os.path.isdir(f"{build_dir}/meson-info") else ""
203
+
204
+ # NOTE: Meson also keeps every option of an already configured build
205
+ # directory that is not given again, so all of them are passed with their
206
+ # default value before meson_args, which comes later and hence wins. Without
207
+ # this, removing an option from MESON_ARGS would silently keep the value it
208
+ # was given the previous time.
209
+ default_options = default_meson_options()
210
+
164
211
  if MEDIASOUP_BUILDTYPE == "Release":
165
212
  with cd_worker():
166
213
  ctx.run(
167
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {meson_args} "{BUILD_DIR}"',
214
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {default_options} {meson_args} "{build_dir}"',
168
215
  echo=True,
169
216
  pty=PTY_SUPPORTED,
170
217
  shell=SHELL,
@@ -172,7 +219,7 @@ def setup(ctx, meson_args=MESON_ARGS):
172
219
  elif MEDIASOUP_BUILDTYPE == "Debug":
173
220
  with cd_worker():
174
221
  ctx.run(
175
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {meson_args} "{BUILD_DIR}"',
222
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {default_options} {meson_args} "{build_dir}"',
176
223
  echo=True,
177
224
  pty=PTY_SUPPORTED,
178
225
  shell=SHELL,
@@ -180,7 +227,7 @@ def setup(ctx, meson_args=MESON_ARGS):
180
227
  else:
181
228
  with cd_worker():
182
229
  ctx.run(
183
- f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {meson_args} "{BUILD_DIR}"',
230
+ f'"{MESON}" setup {reconfigure} --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {default_options} {meson_args} "{build_dir}"',
184
231
  echo=True,
185
232
  pty=PTY_SUPPORTED,
186
233
  shell=SHELL,
@@ -190,19 +237,36 @@ def setup(ctx, meson_args=MESON_ARGS):
190
237
  @task
191
238
  def clean(ctx):
192
239
  """
193
- Clean the installation directory
240
+ Clean the objects and binaries of mediasoup, keeping those of subprojects
194
241
  """
195
242
 
196
- shutil.rmtree(MEDIASOUP_INSTALL_DIR, ignore_errors=True)
243
+ # NOTE: Meson keeps the objects of each target in a "<target>.p" directory,
244
+ # and those of the subprojects and the dependencies in their own
245
+ # subdirectories, so this removes just what belongs to mediasoup itself.
246
+ # glob.escape() is needed because the path of the build directory may
247
+ # contain characters that glob would otherwise take as wildcards.
248
+ for build_dir in BUILD_DIRS:
249
+ for path in glob.glob(f"{glob.escape(build_dir)}/*.p"):
250
+ shutil.rmtree(path, ignore_errors=True)
251
+
252
+ # NOTE: The installed artifacts are files, while the build directories are
253
+ # directories.
254
+ for path in glob.glob(f"{glob.escape(MEDIASOUP_INSTALL_DIR)}/*"):
255
+ if os.path.isfile(path):
256
+ # NOTE: Be as tolerant as shutil.rmtree() above, since in Windows
257
+ # removing a binary that is being run fails.
258
+ with suppress(OSError):
259
+ os.remove(path)
197
260
 
198
261
 
199
262
  @task
200
263
  def clean_build(ctx):
201
264
  """
202
- Clean the build directory
265
+ Clean the build directories
203
266
  """
204
267
 
205
- shutil.rmtree(BUILD_DIR, ignore_errors=True)
268
+ for build_dir in BUILD_DIRS:
269
+ shutil.rmtree(build_dir, ignore_errors=True)
206
270
 
207
271
 
208
272
  @task
@@ -274,22 +338,29 @@ def update_wrap_file(ctx, subproject):
274
338
  )
275
339
 
276
340
 
277
- @task(pre=[setup])
278
- def flatc(ctx):
341
+ @task(pre=[meson_ninja])
342
+ def flatc(ctx, meson_args=MESON_ARGS, build_dir=BUILD_DIR):
279
343
  """
280
344
  Compile FlatBuffers FBS files
281
345
  """
282
346
 
347
+ # NOTE: The generated C++ headers are written into the build directory, so
348
+ # they must be generated in the very same build directory that compiles them
349
+ # and with the very same Meson options. setup() is called here instead of
350
+ # being declared as a pre task because a pre task cannot receive the
351
+ # parameters given to the task it precedes.
352
+ setup(ctx, meson_args=meson_args, build_dir=build_dir)
353
+
283
354
  with cd_worker():
284
355
  ctx.run(
285
- f'"{MESON}" compile -C "{BUILD_DIR}" flatbuffers-generator',
356
+ f'"{MESON}" compile -C "{build_dir}" flatbuffers-generator',
286
357
  echo=True,
287
358
  pty=PTY_SUPPORTED,
288
359
  shell=SHELL,
289
360
  )
290
361
 
291
362
 
292
- @task(pre=[setup, flatc], default=True)
363
+ @task(pre=[flatc], default=True)
293
364
  def mediasoup_worker(ctx):
294
365
  """
295
366
  Compile mediasoup-worker binary
@@ -317,7 +388,7 @@ def mediasoup_worker(ctx):
317
388
  )
318
389
 
319
390
 
320
- @task(pre=[setup, flatc])
391
+ @task(pre=[flatc])
321
392
  def libmediasoup_worker(ctx):
322
393
  """
323
394
  Compile libmediasoup-worker library
@@ -339,7 +410,7 @@ def libmediasoup_worker(ctx):
339
410
  )
340
411
 
341
412
 
342
- @task(pre=[setup, flatc])
413
+ @task(pre=[flatc])
343
414
  def xcode(ctx):
344
415
  """
345
416
  Setup Xcode project
@@ -419,7 +490,49 @@ def format(ctx):
419
490
  ctx.run(f'"{PYTHON}" -m ruff format', echo=True, pty=PTY_SUPPORTED, shell=SHELL)
420
491
 
421
492
 
422
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
493
+ @task(
494
+ pre=[
495
+ call(
496
+ flatc,
497
+ meson_args=MESON_ARGS + " -Dms_build_tests=true",
498
+ build_dir=TEST_BUILD_DIR,
499
+ )
500
+ ]
501
+ )
502
+ def tidy_setup(ctx):
503
+ """
504
+ Configure the build directory that `tidy` uses, generating its
505
+ compile_commands.json
506
+
507
+ NOTE: Test files are only given the Catch2 include paths when
508
+ `ms_build_tests` is enabled, so clang-tidy needs this very build directory to
509
+ analyze them.
510
+ """
511
+
512
+
513
+ @task(pre=[tidy_setup])
514
+ def tidy_normalize_compile_commands(ctx):
515
+ """
516
+ Rewrite the paths of the compile_commands.json that `tidy` uses so that
517
+ third party clang-tidy runners can resolve them
518
+
519
+ NOTE: Just needed by CI, since it doesn't run `tidy` but its own clang-tidy
520
+ over the files of the pull request.
521
+ """
522
+
523
+ with cd_worker():
524
+ ctx.run(
525
+ f'"{NPM}" run normalize-compile-commands --prefix scripts/',
526
+ echo=True,
527
+ pty=PTY_SUPPORTED,
528
+ shell=SHELL,
529
+ # NOTE: Tell the script which build directory holds the
530
+ # compile_commands.json to use.
531
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
532
+ )
533
+
534
+
535
+ @task(pre=[tidy_setup])
423
536
  def tidy(ctx):
424
537
  """
425
538
  Performs C++ code checks according to `worker/.clang-tidy` rules
@@ -431,10 +544,13 @@ def tidy(ctx):
431
544
  echo=True,
432
545
  pty=PTY_SUPPORTED,
433
546
  shell=SHELL,
547
+ # NOTE: Tell the script which build directory holds the
548
+ # compile_commands.json to use.
549
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
434
550
  )
435
551
 
436
552
 
437
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
553
+ @task(pre=[tidy_setup])
438
554
  def tidy_fix(ctx):
439
555
  """
440
556
  Performs C++ code checks according to `worker/.clang-tidy` rules and applies
@@ -447,10 +563,21 @@ def tidy_fix(ctx):
447
563
  echo=True,
448
564
  pty=PTY_SUPPORTED,
449
565
  shell=SHELL,
566
+ # NOTE: Tell the script which build directory holds the
567
+ # compile_commands.json to use.
568
+ env={**os.environ, "BUILD_DIR": TEST_BUILD_DIR},
450
569
  )
451
570
 
452
571
 
453
- @task(pre=[call(setup, meson_args=MESON_ARGS + " -Dms_build_tests=true"), flatc])
572
+ @task(
573
+ pre=[
574
+ call(
575
+ flatc,
576
+ meson_args=MESON_ARGS + " -Dms_build_tests=true",
577
+ build_dir=TEST_BUILD_DIR,
578
+ )
579
+ ]
580
+ )
454
581
  def test(ctx):
455
582
  """
456
583
  Run worker tests
@@ -458,14 +585,14 @@ def test(ctx):
458
585
 
459
586
  with cd_worker():
460
587
  ctx.run(
461
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
588
+ f'"{MESON}" compile -C "{TEST_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
462
589
  echo=True,
463
590
  pty=PTY_SUPPORTED,
464
591
  shell=SHELL,
465
592
  )
466
593
  with cd_worker():
467
594
  ctx.run(
468
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
595
+ f'"{MESON}" install -C "{TEST_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
469
596
  echo=True,
470
597
  pty=PTY_SUPPORTED,
471
598
  shell=SHELL,
@@ -478,7 +605,7 @@ def test(ctx):
478
605
 
479
606
  with cd_worker():
480
607
  ctx.run(
481
- f'"{BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
608
+ f'"{TEST_BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
482
609
  echo=True,
483
610
  pty=PTY_SUPPORTED,
484
611
  shell=SHELL,
@@ -488,11 +615,11 @@ def test(ctx):
488
615
  @task(
489
616
  pre=[
490
617
  call(
491
- setup,
618
+ flatc,
492
619
  meson_args=MESON_ARGS
493
620
  + " -Dms_build_tests=true -Db_sanitize=address -Db_lundef=false",
494
- ),
495
- flatc,
621
+ build_dir=TEST_ASAN_ADDRESS_BUILD_DIR,
622
+ )
496
623
  ]
497
624
  )
498
625
  def test_asan_address(ctx):
@@ -502,14 +629,14 @@ def test_asan_address(ctx):
502
629
 
503
630
  with cd_worker():
504
631
  ctx.run(
505
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-address',
632
+ f'"{MESON}" compile -C "{TEST_ASAN_ADDRESS_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-address',
506
633
  echo=True,
507
634
  pty=PTY_SUPPORTED,
508
635
  shell=SHELL,
509
636
  )
510
637
  with cd_worker():
511
638
  ctx.run(
512
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-address',
639
+ f'"{MESON}" install -C "{TEST_ASAN_ADDRESS_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-address',
513
640
  echo=True,
514
641
  pty=PTY_SUPPORTED,
515
642
  shell=SHELL,
@@ -519,7 +646,7 @@ def test_asan_address(ctx):
519
646
 
520
647
  with cd_worker():
521
648
  ctx.run(
522
- f'"{BUILD_DIR}/mediasoup-worker-test-asan-address" --invisibles {mediasoup_test_tags}',
649
+ f'"{TEST_ASAN_ADDRESS_BUILD_DIR}/mediasoup-worker-test-asan-address" --invisibles {mediasoup_test_tags}',
523
650
  echo=True,
524
651
  pty=PTY_SUPPORTED,
525
652
  shell=SHELL,
@@ -533,11 +660,11 @@ def test_asan_address(ctx):
533
660
  @task(
534
661
  pre=[
535
662
  call(
536
- setup,
663
+ flatc,
537
664
  meson_args=MESON_ARGS
538
665
  + " -Dms_build_tests=true -Db_sanitize=undefined -Db_lundef=false",
539
- ),
540
- flatc,
666
+ build_dir=TEST_ASAN_UNDEFINED_BUILD_DIR,
667
+ )
541
668
  ]
542
669
  )
543
670
  def test_asan_undefined(ctx):
@@ -547,14 +674,14 @@ def test_asan_undefined(ctx):
547
674
 
548
675
  with cd_worker():
549
676
  ctx.run(
550
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-undefined',
677
+ f'"{MESON}" compile -C "{TEST_ASAN_UNDEFINED_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan-undefined',
551
678
  echo=True,
552
679
  pty=PTY_SUPPORTED,
553
680
  shell=SHELL,
554
681
  )
555
682
  with cd_worker():
556
683
  ctx.run(
557
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-undefined',
684
+ f'"{MESON}" install -C "{TEST_ASAN_UNDEFINED_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan-undefined',
558
685
  echo=True,
559
686
  pty=PTY_SUPPORTED,
560
687
  shell=SHELL,
@@ -564,7 +691,7 @@ def test_asan_undefined(ctx):
564
691
 
565
692
  with cd_worker():
566
693
  ctx.run(
567
- f'"{BUILD_DIR}/mediasoup-worker-test-asan-undefined" --invisibles {mediasoup_test_tags}',
694
+ f'"{TEST_ASAN_UNDEFINED_BUILD_DIR}/mediasoup-worker-test-asan-undefined" --invisibles {mediasoup_test_tags}',
568
695
  echo=True,
569
696
  pty=PTY_SUPPORTED,
570
697
  shell=SHELL,
@@ -580,11 +707,11 @@ def test_asan_undefined(ctx):
580
707
  @task(
581
708
  pre=[
582
709
  call(
583
- setup,
710
+ flatc,
584
711
  meson_args=MESON_ARGS
585
712
  + " -Dms_build_fuzzer=true -Db_sanitize=address -Db_lundef=false",
586
- ),
587
- flatc,
713
+ build_dir=FUZZER_BUILD_DIR,
714
+ )
588
715
  ]
589
716
  )
590
717
  def fuzzer(ctx):
@@ -593,18 +720,18 @@ def fuzzer(ctx):
593
720
  """
594
721
 
595
722
  # NOTE: We need to pass '-Db_sanitize=address' to enable fuzzer in all Meson
596
- # subprojects, so we pass it to the setup() task.
723
+ # subprojects, so we pass it to the setup() task (through the flatc() task).
597
724
 
598
725
  with cd_worker():
599
726
  ctx.run(
600
- f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
727
+ f'"{MESON}" compile -C "{FUZZER_BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
601
728
  echo=True,
602
729
  pty=PTY_SUPPORTED,
603
730
  shell=SHELL,
604
731
  )
605
732
  with cd_worker():
606
733
  ctx.run(
607
- f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
734
+ f'"{MESON}" install -C "{FUZZER_BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
608
735
  echo=True,
609
736
  pty=PTY_SUPPORTED,
610
737
  shell=SHELL,
@@ -619,7 +746,7 @@ def fuzzer_run_all(ctx):
619
746
 
620
747
  with cd_worker():
621
748
  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',
749
+ 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
750
  echo=True,
624
751
  pty=PTY_SUPPORTED,
625
752
  shell=SHELL,