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
@@ -26,20 +26,6 @@ if host_machine.system() == 'windows'
26
26
  ]
27
27
  endif
28
28
 
29
- if get_option('ms_build_tests')
30
- cpp_args += [
31
- '-DMS_TEST',
32
- '-DMS_LOG_STD'
33
- ]
34
- endif
35
-
36
- if get_option('ms_build_fuzzer')
37
- cpp_args += [
38
- '-DMS_FUZZER',
39
- '-DMS_LOG_STD'
40
- ]
41
- endif
42
-
43
29
  if get_option('ms_log_trace')
44
30
  cpp_args += [
45
31
  '-DMS_LOG_TRACE',
@@ -70,6 +56,26 @@ if get_option('ms_dump_rtp_shared_packet_memory_usage')
70
56
  ]
71
57
  endif
72
58
 
59
+ if get_option('ms_build_tests')
60
+ cpp_args += [
61
+ '-DMS_TEST',
62
+ '-DMS_LOG_STD',
63
+ ]
64
+ endif
65
+
66
+ if get_option('ms_build_fuzzer')
67
+ cpp_args += [
68
+ '-DMS_FUZZER',
69
+ '-DMS_LOG_STD',
70
+ ]
71
+ endif
72
+
73
+ if get_option('ms_use_builtin_bwe')
74
+ cpp_args += [
75
+ '-DMS_USE_BUILTIN_BWE',
76
+ ]
77
+ endif
78
+
73
79
  cpp = meson.get_compiler('cpp')
74
80
 
75
81
  # This is a workaround to define FLATBUFFERS_LOCALE_INDEPENDENT=0 outside
@@ -86,7 +92,6 @@ common_sources = [
86
92
  'src/lib.cpp',
87
93
  'src/DepLibSRTP.cpp',
88
94
  'src/DepLibUV.cpp',
89
- 'src/DepLibWebRTC.cpp',
90
95
  'src/DepOpenSSL.cpp',
91
96
  'src/Logger.cpp',
92
97
  'src/MediaSoupErrors.cpp',
@@ -131,7 +136,6 @@ common_sources = [
131
136
  'src/RTC/RtpListener.cpp',
132
137
  'src/RTC/RtpObserver.cpp',
133
138
  'src/RTC/SctpListener.cpp',
134
- 'src/RTC/SenderBandwidthEstimator.cpp',
135
139
  'src/RTC/SeqManager.cpp',
136
140
  'src/RTC/Serializable.cpp',
137
141
  'src/RTC/PipeProducerStreamManager.cpp',
@@ -143,8 +147,6 @@ common_sources = [
143
147
  'src/RTC/TcpConnection.cpp',
144
148
  'src/RTC/TcpServer.cpp',
145
149
  'src/RTC/Transport.cpp',
146
- 'src/RTC/TransportCongestionControlClient.cpp',
147
- 'src/RTC/TransportCongestionControlServer.cpp',
148
150
  'src/RTC/TransportTuple.cpp',
149
151
  'src/RTC/TrendCalculator.cpp',
150
152
  'src/RTC/UdpSocket.cpp',
@@ -161,6 +163,15 @@ common_sources = [
161
163
  'src/RTC/RtpDictionaries/RtpParameters.cpp',
162
164
  'src/RTC/RtpDictionaries/RtpRtxParameters.cpp',
163
165
  'src/RTC/SctpDictionaries/SctpStreamParameters.cpp',
166
+ 'src/RTC/BWE/AimdRateControl.cpp',
167
+ 'src/RTC/BWE/BweTypes.cpp',
168
+ 'src/RTC/BWE/DelayBasedBwe.cpp',
169
+ 'src/RTC/BWE/FeedbackAdapter.cpp',
170
+ 'src/RTC/BWE/InterArrivalDelta.cpp',
171
+ 'src/RTC/BWE/LinkCapacityEstimator.cpp',
172
+ 'src/RTC/BWE/RobustThroughputEstimator.cpp',
173
+ 'src/RTC/BWE/SendPacketHistory.cpp',
174
+ 'src/RTC/BWE/TrendlineEstimator.cpp',
164
175
  'src/RTC/ICE/IceCandidate.cpp',
165
176
  'src/RTC/ICE/IceServer.cpp',
166
177
  'src/RTC/ICE/StunPacket.cpp',
@@ -287,6 +298,16 @@ common_sources = [
287
298
  'src/RTC/SCTP/public/Message.cpp',
288
299
  ]
289
300
 
301
+ # The deps/libwebrtc bandwidth estimation is only built when the built-in one is
302
+ # not used.
303
+ if not get_option('ms_use_builtin_bwe')
304
+ common_sources += [
305
+ 'src/DepLibWebRTC.cpp',
306
+ 'src/RTC/TransportCongestionControlClient.cpp',
307
+ 'src/RTC/TransportCongestionControlServer.cpp',
308
+ ]
309
+ endif
310
+
290
311
  libuv_proj = subproject(
291
312
  'libuv',
292
313
  default_options: [
@@ -313,14 +334,6 @@ libsrtp3_proj = subproject(
313
334
  ],
314
335
  )
315
336
 
316
- abseil_cpp_proj = subproject(
317
- 'abseil-cpp',
318
- default_options: [
319
- 'warning_level=0',
320
- 'cpp_std=c++17',
321
- ],
322
- )
323
-
324
337
  ankerl_unordered_dense_dep = dependency('unordered_dense')
325
338
 
326
339
  flatbuffers_proj = subproject(
@@ -333,20 +346,13 @@ flatbuffers_proj = subproject(
333
346
  # flatbuffers schemas subdirectory.
334
347
  subdir('fbs')
335
348
 
336
- # Add current build directory so libwebrtc has access to FBS folder.
337
- libwebrtc_include_directories = include_directories('include', 'fbs')
338
-
339
- subdir('deps/libwebrtc')
340
-
341
349
  dependencies = [
342
350
  libuv_proj.get_variable('libuv_dep'),
343
351
  openssl_proj.get_variable('openssl_dep'),
344
352
  libsrtp3_proj.get_variable('libsrtp3_dep'),
345
- abseil_cpp_proj.get_variable('absl_container_dep'),
346
353
  ankerl_unordered_dense_dep,
347
354
  flatbuffers_proj.get_variable('flatbuffers_dep'),
348
355
  flatbuffers_generator_dep,
349
- libwebrtc_dep,
350
356
  ]
351
357
 
352
358
  link_whole = [
@@ -354,11 +360,34 @@ link_whole = [
354
360
  openssl_proj.get_variable('libcrypto_lib'),
355
361
  openssl_proj.get_variable('libssl_lib'),
356
362
  libsrtp3_proj.get_variable('libsrtp3'),
357
- abseil_cpp_proj.get_variable('absl_container_lib'),
358
363
  flatbuffers_proj.get_variable('flatbuffers_lib'),
359
- libwebrtc,
360
364
  ]
361
365
 
366
+ if not get_option('ms_use_builtin_bwe')
367
+ # NOTE: abseil-cpp is in the tree only because deps/libwebrtc needs it.
368
+ abseil_cpp_proj = subproject(
369
+ 'abseil-cpp',
370
+ default_options: [
371
+ 'warning_level=0',
372
+ 'cpp_std=c++17',
373
+ ],
374
+ )
375
+
376
+ # Add current build directory so libwebrtc has access to FBS folder.
377
+ libwebrtc_include_directories = include_directories('include', 'fbs')
378
+
379
+ subdir('deps/libwebrtc')
380
+
381
+ dependencies += [
382
+ abseil_cpp_proj.get_variable('absl_container_dep'),
383
+ libwebrtc_dep,
384
+ ]
385
+ link_whole += [
386
+ abseil_cpp_proj.get_variable('absl_container_lib'),
387
+ libwebrtc,
388
+ ]
389
+ endif
390
+
362
391
  if host_machine.system() == 'windows'
363
392
  wingetopt_proj = subproject(
364
393
  'wingetopt',
@@ -415,6 +444,7 @@ executable(
415
444
  mock_sources = [
416
445
  'mocks/src/MockShared.cpp',
417
446
  'mocks/src/handles/MockBackoffTimerHandle.cpp',
447
+ 'mocks/src/handles/MockTimerHandle.cpp',
418
448
  'mocks/src/Channel/MockChannelMessageRegistrator.cpp',
419
449
  'mocks/src/RTC/SCTP/association/MockTransmissionControlBlockContext.cpp',
420
450
  ]
@@ -422,6 +452,7 @@ mock_sources = [
422
452
  test_sources = [
423
453
  'test/src/tests.cpp',
424
454
  'test/src/testHelpers.cpp',
455
+ 'test/src/TestDepLibUV.cpp',
425
456
  'test/src/RTC/TestConsumer.cpp',
426
457
  'test/src/RTC/TestPipeProducerStreamManager.cpp',
427
458
  'test/src/RTC/TestSimpleProducerStreamManager.cpp',
@@ -436,9 +467,17 @@ test_sources = [
436
467
  'test/src/RTC/TestRtpEncodingParameters.cpp',
437
468
  'test/src/RTC/TestSeqManager.cpp',
438
469
  'test/src/RTC/TestSubchannelsCodec.cpp',
439
- 'test/src/RTC/TestTransportCongestionControlServer.cpp',
440
470
  'test/src/RTC/TestTransportTuple.cpp',
441
471
  'test/src/RTC/TestTrendCalculator.cpp',
472
+ 'test/src/RTC/BWE/helpers/LinkSimulator.cpp',
473
+ 'test/src/RTC/BWE/TestAimdRateControl.cpp',
474
+ 'test/src/RTC/BWE/TestDelayBasedBwe.cpp',
475
+ 'test/src/RTC/BWE/TestFeedbackAdapter.cpp',
476
+ 'test/src/RTC/BWE/TestInterArrivalDelta.cpp',
477
+ 'test/src/RTC/BWE/TestLinkCapacityEstimator.cpp',
478
+ 'test/src/RTC/BWE/TestRobustThroughputEstimator.cpp',
479
+ 'test/src/RTC/BWE/TestSendPacketHistory.cpp',
480
+ 'test/src/RTC/BWE/TestTrendlineEstimator.cpp',
442
481
  'test/src/RTC/ICE/iceCommon.cpp',
443
482
  'test/src/RTC/ICE/TestStunPacket.cpp',
444
483
  'test/src/RTC/RTP/rtpCommon.cpp',
@@ -558,6 +597,12 @@ test_sources = [
558
597
  'test/src/Utils/TestUnwrappedSequenceNumber.cpp',
559
598
  ]
560
599
 
600
+ if not get_option('ms_use_builtin_bwe')
601
+ test_sources += [
602
+ 'test/src/RTC/TestTransportCongestionControlServer.cpp',
603
+ ]
604
+ endif
605
+
561
606
  mediasoup_worker_test = executable(
562
607
  'mediasoup-worker-test',
563
608
  build_by_default: false,
@@ -5,3 +5,4 @@ option('ms_dump_rtp_payload_descriptor', type: 'boolean', value: false, descript
5
5
  option('ms_dump_rtp_shared_packet_memory_usage', type: 'boolean', value: false, description: 'prints information about total memory allocated by RTC::RTP::SharedPacket instances')
6
6
  option('ms_build_tests', type: 'boolean', value: false, description: 'Must be enabled when building mediasoup worker tests')
7
7
  option('ms_build_fuzzer', type: 'boolean', value: false, description: 'Must be enabled when building mediasoup worker fuzzer')
8
+ option('ms_use_builtin_bwe', type: 'boolean', value: false, description: 'Use the new built-in bandwidth estimation module')
@@ -6,6 +6,7 @@
6
6
  #include "SharedInterface.hpp"
7
7
  #include "mocks/include/Channel/MockChannelMessageRegistrator.hpp"
8
8
  #include "mocks/include/handles/MockBackoffTimerHandle.hpp"
9
+ #include "mocks/include/handles/MockTimerHandle.hpp"
9
10
  #include <map>
10
11
  #include <string>
11
12
  #include <string_view>
@@ -15,7 +16,7 @@ namespace mocks
15
16
  class MockShared : public SharedInterface
16
17
  {
17
18
  public:
18
- explicit MockShared(std::function<uint64_t()> getTimeMs);
19
+ explicit MockShared(std::function<int64_t()> getTimeUs);
19
20
 
20
21
  ~MockShared() override = default;
21
22
 
@@ -30,45 +31,44 @@ namespace mocks
30
31
  return this->channelNotifier.get();
31
32
  }
32
33
 
33
- TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener) override;
34
+ TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener, std::string label) override;
34
35
 
35
36
  BackoffTimerHandleInterface* CreateBackoffTimer(
36
37
  const BackoffTimerHandleInterface::BackoffTimerHandleOptions& options) override;
37
38
 
38
- uint64_t GetTimeMs() override
39
+ int64_t GetTimeMs() override
39
40
  {
40
- return this->getTimeMs();
41
+ return GetTimeUs() / 1000;
41
42
  }
42
43
 
43
- uint64_t GetTimeUs() override
44
+ int64_t GetTimeUs() override
44
45
  {
45
- return GetTimeMs() * 1000;
46
- }
47
-
48
- uint64_t GetTimeNs() override
49
- {
50
- return GetTimeMs() * 1000 * 1000;
51
- }
52
-
53
- int64_t GetTimeMsInt64() override
54
- {
55
- return static_cast<int64_t>(GetTimeMs());
56
- }
57
-
58
- int64_t GetTimeUsInt64() override
59
- {
60
- return static_cast<int64_t>(GetTimeUs());
46
+ return this->getTimeUs();
61
47
  }
62
48
 
63
49
  // NOTE: The NTP epoch is made to be the very clock given by argument, so that tests
64
50
  // can reason about a single set of values.
65
- uint64_t GetNtpOffsetMs() override
51
+ int64_t GetNtpOffsetUs() override
66
52
  {
67
53
  return 0;
68
54
  }
69
55
 
70
56
  // Methods for testing.
71
57
  public:
58
+ MockTimerHandle* GetTimer(const std::string_view label) const
59
+ {
60
+ const auto it = this->timers.find(std::string(label));
61
+
62
+ if (it != this->timers.end())
63
+ {
64
+ return it->second;
65
+ }
66
+ else
67
+ {
68
+ return nullptr;
69
+ }
70
+ }
71
+
72
72
  MockBackoffTimerHandle* GetBackoffTimer(const std::string_view label) const
73
73
  {
74
74
  const auto it = this->backoffTimers.find(std::string(label));
@@ -85,11 +85,12 @@ namespace mocks
85
85
 
86
86
  private:
87
87
  // Given by argument.
88
- const std::function<uint64_t()> getTimeMs;
88
+ const std::function<int64_t()> getTimeUs;
89
89
  // Others.
90
90
  std::unique_ptr<::Channel::ChannelSocket> channelSocket;
91
91
  std::unique_ptr<mocks::Channel::MockChannelMessageRegistrator> channelMessageRegistrator;
92
92
  std::unique_ptr<::Channel::ChannelNotifier> channelNotifier;
93
+ std::map<std::string /*label*/, MockTimerHandle* /*timer*/> timers;
93
94
  std::map<std::string /*label*/, MockBackoffTimerHandle* /*backoffTimer*/> backoffTimers;
94
95
  };
95
96
  } // namespace mocks
@@ -21,7 +21,7 @@ namespace mocks
21
21
  : public ::RTC::SCTP::TransmissionControlBlockContextInterface
22
22
  {
23
23
  public:
24
- using GetCurrentRtoMsAction = std::function<uint64_t()>;
24
+ using GetCurrentRtoUsAction = std::function<int64_t()>;
25
25
 
26
26
  public:
27
27
  explicit MockTransmissionControlBlockContext(
@@ -49,18 +49,19 @@ namespace mocks
49
49
  return 0;
50
50
  }
51
51
 
52
- void ObserveRttMs(uint64_t rttMs) override
52
+ void ObserveRttUs(int64_t rttUs) override
53
53
  {
54
- this->observeRttMsCallCount++;
54
+ this->observeRttUsCallCount++;
55
+ this->observeRttUsCalledWith = rttUs;
55
56
  }
56
57
 
57
- uint64_t GetCurrentRtoMs() const override
58
+ int64_t GetCurrentRtoUs() const override
58
59
  {
59
- if (!this->getCurrentRtoMsOnceActions.empty())
60
+ if (!this->getCurrentRtoUsOnceActions.empty())
60
61
  {
61
- auto action = std::move(this->getCurrentRtoMsOnceActions.front());
62
+ auto action = std::move(this->getCurrentRtoUsOnceActions.front());
62
63
 
63
- this->getCurrentRtoMsOnceActions.pop();
64
+ this->getCurrentRtoUsOnceActions.pop();
64
65
 
65
66
  return action();
66
67
  }
@@ -101,12 +102,19 @@ namespace mocks
101
102
 
102
103
  /**
103
104
  * @remarks
104
- * - Must be called before expecting calls to `ObserveRttMs()`.
105
+ * - Must be called before expecting calls to `ObserveRttUs()`.
105
106
  */
106
- MockTransmissionControlBlockContext& ExpectObserveRttMsCalledTimes(size_t times)
107
+ MockTransmissionControlBlockContext& ExpectObserveRttUsCalledTimes(size_t times)
107
108
  {
108
- this->observeRttMsCallCount = 0;
109
- this->expectedObserveRttMsCallCount = times;
109
+ this->observeRttUsCallCount = 0;
110
+ this->expectedObserveRttUsCallCount = times;
111
+
112
+ return *this;
113
+ }
114
+
115
+ MockTransmissionControlBlockContext& ExpectObserveRttUsCalledWith(int64_t rttUs)
116
+ {
117
+ this->expectedObserveRttUsCalledWith = rttUs;
110
118
 
111
119
  return *this;
112
120
  }
@@ -123,9 +131,9 @@ namespace mocks
123
131
  return *this;
124
132
  }
125
133
 
126
- MockTransmissionControlBlockContext& WillGetCurrentRtoMsOnce(GetCurrentRtoMsAction action)
134
+ MockTransmissionControlBlockContext& WillGetCurrentRtoUsOnce(GetCurrentRtoUsAction action)
127
135
  {
128
- this->getCurrentRtoMsOnceActions.push(std::move(action));
136
+ this->getCurrentRtoUsOnceActions.push(std::move(action));
129
137
 
130
138
  return *this;
131
139
  }
@@ -133,13 +141,27 @@ namespace mocks
133
141
  mocks::VerificationResult VerifyExpectations() const
134
142
  {
135
143
  if (
136
- this->expectedObserveRttMsCallCount.has_value() &&
137
- this->observeRttMsCallCount != this->expectedObserveRttMsCallCount.value())
144
+ this->expectedObserveRttUsCallCount.has_value() &&
145
+ this->observeRttUsCallCount != this->expectedObserveRttUsCallCount.value())
146
+ {
147
+ return { .ok = false,
148
+ .errorMessage = "ObserveRttUs() call count mismatch [expected:" +
149
+ std::to_string(this->expectedObserveRttUsCallCount.value()) +
150
+ ", got:" + std::to_string(this->observeRttUsCallCount) + "]" };
151
+ }
152
+
153
+ if (
154
+ this->expectedObserveRttUsCalledWith.has_value() &&
155
+ this->observeRttUsCalledWith != this->expectedObserveRttUsCalledWith)
138
156
  {
139
157
  return { .ok = false,
140
- .errorMessage = "ObserveRttMs() call count mismatch [expected:" +
141
- std::to_string(this->expectedObserveRttMsCallCount.value()) +
142
- ", got:" + std::to_string(this->observeRttMsCallCount) + "]" };
158
+ .errorMessage = "ObserveRttUs() call mismatch [expected:" +
159
+ std::to_string(this->expectedObserveRttUsCalledWith.value()) +
160
+ ", got:" +
161
+ (this->observeRttUsCalledWith.has_value()
162
+ ? std::to_string(this->observeRttUsCalledWith.value())
163
+ : "none") +
164
+ "]" };
143
165
  }
144
166
 
145
167
  if (
@@ -148,10 +170,10 @@ namespace mocks
148
170
  this->expectedIncrementTxErrorCounterCallCount.value())
149
171
  {
150
172
  return { .ok = false,
151
- .errorMessage =
152
- "IncrementTxErrorCounter() call count mismatch [expected:" +
153
- std::to_string(this->expectedIncrementTxErrorCounterCallCount.value()) +
154
- ", got:" + std::to_string(this->incrementTxErrorCounterCallCount) + "]" };
173
+ .errorMessage =
174
+ "IncrementTxErrorCounter() call count mismatch [expected:" +
175
+ std::to_string(this->expectedIncrementTxErrorCounterCallCount.value()) +
176
+ ", got:" + std::to_string(this->incrementTxErrorCounterCallCount) + "]" };
155
177
  }
156
178
 
157
179
  return { .ok = true, .errorMessage = "" };
@@ -162,12 +184,14 @@ namespace mocks
162
184
  ::RTC::SCTP::AssociationListenerInterface& associationListener;
163
185
  const ::RTC::SCTP::SctpOptions sctpOptions;
164
186
 
165
- // ObserveRttMs().
166
- size_t observeRttMsCallCount{ 0 };
167
- std::optional<size_t> expectedObserveRttMsCallCount;
187
+ // ObserveRttUs().
188
+ size_t observeRttUsCallCount{ 0 };
189
+ std::optional<size_t> expectedObserveRttUsCallCount;
190
+ std::optional<int64_t> observeRttUsCalledWith;
191
+ std::optional<int64_t> expectedObserveRttUsCalledWith;
168
192
 
169
- // GetCurrentRtoMs().
170
- mutable std::queue<GetCurrentRtoMsAction> getCurrentRtoMsOnceActions;
193
+ // GetCurrentRtoUs().
194
+ mutable std::queue<GetCurrentRtoUsAction> getCurrentRtoUsOnceActions;
171
195
 
172
196
  // IncrementTxErrorCounter().
173
197
  size_t incrementTxErrorCounterCallCount{ 0 };
@@ -18,7 +18,7 @@ namespace mocks
18
18
  {
19
19
  public:
20
20
  using ProduceAction =
21
- std::function<std::optional<DataToSend>(uint64_t /*nowMs*/, size_t /*maxLength*/)>;
21
+ std::function<std::optional<DataToSend>(int64_t /*nowUs*/, size_t /*maxLength*/)>;
22
22
 
23
23
  struct DiscardExpectation
24
24
  {
@@ -40,7 +40,7 @@ namespace mocks
40
40
  this->messageInterleavingCalledWith = enabled;
41
41
  }
42
42
 
43
- std::optional<DataToSend> Produce(uint64_t nowMs, size_t maxLength) override
43
+ std::optional<DataToSend> Produce(int64_t nowUs, size_t maxLength) override
44
44
  {
45
45
  this->produceCallCount++;
46
46
 
@@ -50,11 +50,11 @@ namespace mocks
50
50
 
51
51
  this->produceOnceActions.pop();
52
52
 
53
- return action(nowMs, maxLength);
53
+ return action(nowUs, maxLength);
54
54
  }
55
55
  else if (this->produceRepeatedlyAction)
56
56
  {
57
- return this->produceRepeatedlyAction(nowMs, maxLength);
57
+ return this->produceRepeatedlyAction(nowUs, maxLength);
58
58
  }
59
59
  else
60
60
  {
@@ -202,10 +202,10 @@ namespace mocks
202
202
  this->messageInterleavingCalledWith != this->expectedMessageInterleavingCalledWith.value())
203
203
  {
204
204
  return { .ok = false,
205
- .errorMessage =
206
- std::string("EnableMessageInterleaving() call mismatch [expected:") +
207
- (this->expectedMessageInterleavingCalledWith.value() ? "true" : "false") +
208
- ", got:" + (this->messageInterleavingCalledWith ? "true" : "false") + "]" };
205
+ .errorMessage =
206
+ std::string("EnableMessageInterleaving() call mismatch [expected:") +
207
+ (this->expectedMessageInterleavingCalledWith.value() ? "true" : "false") +
208
+ ", got:" + (this->messageInterleavingCalledWith ? "true" : "false") + "]" };
209
209
  }
210
210
 
211
211
  if (
@@ -213,7 +213,7 @@ namespace mocks
213
213
  this->produceCallCount != this->expectedProduceCallCount.value())
214
214
  {
215
215
  return { .ok = false,
216
- .errorMessage = "Produce() call count mismatch [expected:" +
216
+ .errorMessage = "Produce() call count mismatch [expected:" +
217
217
  std::to_string(this->expectedProduceCallCount.value()) +
218
218
  ", got:" + std::to_string(this->produceCallCount) + "]" };
219
219
  }
@@ -223,7 +223,7 @@ namespace mocks
223
223
  this->discardCallCount != this->expectedDiscardCallCount.value())
224
224
  {
225
225
  return { .ok = false,
226
- .errorMessage = "Discard() call count mismatch [expected:" +
226
+ .errorMessage = "Discard() call count mismatch [expected:" +
227
227
  std::to_string(this->expectedDiscardCallCount.value()) +
228
228
  ", got:" + std::to_string(this->discardCallCount) + "]" };
229
229
  }
@@ -231,7 +231,7 @@ namespace mocks
231
231
  if (!this->discardExpectations.empty())
232
232
  {
233
233
  return { .ok = false,
234
- .errorMessage = "Discard() has " +
234
+ .errorMessage = "Discard() has " +
235
235
  std::to_string(this->discardExpectations.size()) +
236
236
  " unconsumed expectation(s)" };
237
237
  }
@@ -18,7 +18,7 @@ namespace mocks
18
18
  private:
19
19
  explicit MockBackoffTimerHandle(
20
20
  BackoffTimerHandleOptions options,
21
- std::function<uint64_t()> getTimeMs,
21
+ std::function<int64_t()> getTimeMs,
22
22
  std::function<void()> onDelete);
23
23
 
24
24
  public:
@@ -49,7 +49,7 @@ namespace mocks
49
49
  // NOTE: Reset the expiration count, just like the real BackoffTimerHandle
50
50
  // does.
51
51
  this->expirationCount = 0;
52
- this->expiresAtMs = std::numeric_limits<uint64_t>::max();
52
+ this->expiresAtMs = std::numeric_limits<int64_t>::max();
53
53
  }
54
54
 
55
55
  /**
@@ -60,7 +60,7 @@ namespace mocks
60
60
  * during construction bypasses virtual dispatch
61
61
  * [clang-analyzer-optin.cplusplus.VirtualCall]"
62
62
  */
63
- void SetBaseTimeoutMs(uint64_t baseTimeoutMs) override;
63
+ void SetBaseTimeoutMs(int64_t baseTimeoutMs) override;
64
64
 
65
65
  bool IsRunning() const override
66
66
  {
@@ -84,7 +84,7 @@ namespace mocks
84
84
 
85
85
  // Methods for testing.
86
86
  public:
87
- uint64_t GetExpiresAtMs() const
87
+ int64_t GetExpiresAtMs() const
88
88
  {
89
89
  return this->expiresAtMs;
90
90
  }
@@ -104,7 +104,7 @@ namespace mocks
104
104
  }
105
105
 
106
106
  private:
107
- uint64_t ComputeNextTimeoutMs() const
107
+ int64_t ComputeNextTimeoutMs() const
108
108
  {
109
109
  auto expirationCount = this->expirationCount;
110
110
 
@@ -130,7 +130,7 @@ namespace mocks
130
130
  }
131
131
  }
132
132
 
133
- return std::min<uint64_t>(timeoutMs, BackoffTimerHandleInterface::MaxTimeoutMs);
133
+ return std::min<int64_t>(timeoutMs, BackoffTimerHandleInterface::MaxTimeoutMs);
134
134
  }
135
135
 
136
136
  NO_DEFAULT_GCC();
@@ -143,16 +143,16 @@ namespace mocks
143
143
  // Passed by argument.
144
144
  BackoffTimerHandleInterface::Listener* listener{ nullptr };
145
145
  const std::string label;
146
- uint64_t baseTimeoutMs;
146
+ int64_t baseTimeoutMs;
147
147
  BackoffAlgorithm backoffAlgorithm;
148
- std::optional<uint64_t> maxBackoffTimeoutMs;
148
+ std::optional<int64_t> maxBackoffTimeoutMs;
149
149
  std::optional<size_t> maxRestarts;
150
- std::function<uint64_t()> getTimeMs;
150
+ std::function<int64_t()> getTimeMs;
151
151
  const std::function<void()> onDelete;
152
152
  // Others.
153
153
  bool running{ false };
154
154
  size_t expirationCount{ 0 };
155
- uint64_t expiresAtMs{ std::numeric_limits<uint64_t>::max() };
155
+ int64_t expiresAtMs{ std::numeric_limits<int64_t>::max() };
156
156
  };
157
157
  } // namespace mocks
158
158