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
@@ -63,9 +63,13 @@ namespace RTC
63
63
  flatbuffers::Offset<FBS::WebRtcTransport::DumpResponse> FillBuffer(
64
64
  flatbuffers::FlatBufferBuilder& builder) const;
65
65
  void ProcessStunPacketFromWebRtcServer(
66
- RTC::TransportTuple* tuple, const RTC::ICE::StunPacket* packet);
66
+ RTC::TransportTuple* tuple, const RTC::ICE::StunPacket* packet, int64_t receivedAtUs);
67
67
  void ProcessNonStunPacketFromWebRtcServer(
68
- RTC::TransportTuple* tuple, const uint8_t* data, size_t len, size_t bufferLen);
68
+ RTC::TransportTuple* tuple,
69
+ const uint8_t* data,
70
+ size_t len,
71
+ size_t bufferLen,
72
+ int64_t receivedAtUs);
69
73
  void RemoveTuple(RTC::TransportTuple* tuple);
70
74
 
71
75
  /* Methods inherited from Channel::ChannelSocket::RequestHandler. */
@@ -92,11 +96,24 @@ namespace RTC
92
96
  bool SendData(const uint8_t* data, size_t len) override;
93
97
  void RecvStreamClosed(uint32_t ssrc) override;
94
98
  void SendStreamClosed(uint32_t ssrc) override;
95
- void OnPacketReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len, size_t bufferLen);
96
- void OnStunDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
97
- void OnDtlsDataReceived(const RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
98
- void OnRtpDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len, size_t bufferLen);
99
- void OnRtcpDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
99
+ void OnPacketReceived(
100
+ RTC::TransportTuple* tuple,
101
+ const uint8_t* data,
102
+ size_t len,
103
+ size_t bufferLen,
104
+ int64_t receivedAtUs);
105
+ void OnStunDataReceived(
106
+ RTC::TransportTuple* tuple, const uint8_t* data, size_t len, int64_t receivedAtUs);
107
+ void OnDtlsDataReceived(
108
+ const RTC::TransportTuple* tuple, const uint8_t* data, size_t len, int64_t receivedAtUs);
109
+ void OnRtpDataReceived(
110
+ RTC::TransportTuple* tuple,
111
+ const uint8_t* data,
112
+ size_t len,
113
+ size_t bufferLen,
114
+ int64_t receivedAtUs);
115
+ void OnRtcpDataReceived(
116
+ RTC::TransportTuple* tuple, const uint8_t* data, size_t len, int64_t receivedAtUs);
100
117
 
101
118
  /* Pure virtual methods inherited from RTC::UdpSocket::Listener. */
102
119
  public:
@@ -105,7 +122,8 @@ namespace RTC
105
122
  const uint8_t* data,
106
123
  size_t len,
107
124
  size_t bufferLen,
108
- const struct sockaddr* remoteAddr) override;
125
+ const struct sockaddr* remoteAddr,
126
+ int64_t receivedAtUs) override;
109
127
 
110
128
  /* Pure virtual methods inherited from RTC::TcpServer::Listener. */
111
129
  public:
@@ -114,7 +132,11 @@ namespace RTC
114
132
  /* Pure virtual methods inherited from RTC::TcpConnection::Listener. */
115
133
  public:
116
134
  void OnTcpConnectionPacketReceived(
117
- RTC::TcpConnection* connection, const uint8_t* data, size_t len, size_t bufferLen) override;
135
+ RTC::TcpConnection* connection,
136
+ const uint8_t* data,
137
+ size_t len,
138
+ size_t bufferLen,
139
+ int64_t receivedAtUs) override;
118
140
 
119
141
  /* Pure virtual methods inherited from RTC::ICE::IceServer::Listener. */
120
142
  public:
@@ -150,7 +172,10 @@ namespace RTC
150
172
  void OnDtlsTransportSendData(
151
173
  const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
152
174
  void OnDtlsTransportApplicationDataReceived(
153
- const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
175
+ const RTC::DtlsTransport* dtlsTransport,
176
+ const uint8_t* data,
177
+ size_t len,
178
+ int64_t receivedAtUs) override;
154
179
 
155
180
  private:
156
181
  // Passed by argument.
@@ -34,11 +34,13 @@ public:
34
34
  {
35
35
  LogLevel logLevel{ LogLevel::LOG_ERROR };
36
36
  struct LogTags logTags;
37
- uint16_t rtcMinPort{ 10000u };
38
- uint16_t rtcMaxPort{ 59999u };
37
+ uint16_t rtcMinPort{ 10000 };
38
+ uint16_t rtcMaxPort{ 59999 };
39
39
  std::string dtlsCertificateFile;
40
40
  std::string dtlsPrivateKeyFile;
41
+ #ifndef MS_USE_BUILTIN_BWE
41
42
  std::string libwebrtcFieldTrials{ "WebRTC-Bwe-AlrLimitedBackoff/Enabled/" };
43
+ #endif
42
44
  };
43
45
 
44
46
  public:
@@ -26,39 +26,24 @@ public:
26
26
  return this->channelNotifier.get();
27
27
  }
28
28
 
29
- TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener) override;
29
+ TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener, std::string label) override;
30
30
 
31
31
  BackoffTimerHandleInterface* CreateBackoffTimer(
32
32
  const BackoffTimerHandleInterface::BackoffTimerHandleOptions& options) override;
33
33
 
34
- uint64_t GetTimeMs() override
34
+ int64_t GetTimeMs() override
35
35
  {
36
36
  return DepLibUV::GetTimeMs();
37
37
  }
38
38
 
39
- uint64_t GetTimeUs() override
39
+ int64_t GetTimeUs() override
40
40
  {
41
41
  return DepLibUV::GetTimeUs();
42
42
  }
43
43
 
44
- uint64_t GetTimeNs() override
44
+ int64_t GetNtpOffsetUs() override
45
45
  {
46
- return DepLibUV::GetTimeNs();
47
- }
48
-
49
- int64_t GetTimeMsInt64() override
50
- {
51
- return DepLibUV::GetTimeMsInt64();
52
- }
53
-
54
- int64_t GetTimeUsInt64() override
55
- {
56
- return DepLibUV::GetTimeUsInt64();
57
- }
58
-
59
- uint64_t GetNtpOffsetMs() override
60
- {
61
- return DepLibUV::GetNtpOffsetMs();
46
+ return DepLibUV::GetNtpOffsetUs();
62
47
  }
63
48
 
64
49
  private:
@@ -29,7 +29,8 @@ public:
29
29
  * @remarks
30
30
  * - The caller is responsible for freeing it.
31
31
  */
32
- virtual TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener) = 0;
32
+ virtual TimerHandleInterface* CreateTimer(
33
+ TimerHandleInterface::Listener* listener, std::string label) = 0;
33
34
 
34
35
  /**
35
36
  * Creates a BackoffTimerHandle timer.
@@ -43,41 +44,18 @@ public:
43
44
  /**
44
45
  * Get current time in milliseconds.
45
46
  */
46
- virtual uint64_t GetTimeMs() = 0;
47
+ virtual int64_t GetTimeMs() = 0;
47
48
 
48
49
  /**
49
50
  * Get current time in microseconds.
50
51
  */
51
- virtual uint64_t GetTimeUs() = 0;
52
+ virtual int64_t GetTimeUs() = 0;
52
53
 
53
54
  /**
54
- * Get current time in nanoseconds.
55
- */
56
- virtual uint64_t GetTimeNs() = 0;
57
-
58
- /**
59
- * @remarks
60
- * - Used within libwebrtc dependency which uses int64_t values for time
61
- * representation.
62
- *
63
- * @todo Remove once not needed.
64
- */
65
- virtual int64_t GetTimeMsInt64() = 0;
66
-
67
- /**
68
- * @remarks
69
- * - Used within libwebrtc dependency which uses int64_t values for time
70
- * representation.
71
- *
72
- * @todo Remove once not needed.
73
- */
74
- virtual int64_t GetTimeUsInt64() = 0;
75
-
76
- /**
77
- * Distance from the clock above to the NTP epoch (ms), which is what has to be added
55
+ * Distance from the clock above to the NTP epoch (us), which is what has to be added
78
56
  * to it to obtain the NTP timestamps of the RTCP we generate.
79
57
  */
80
- virtual uint64_t GetNtpOffsetMs() = 0;
58
+ virtual int64_t GetNtpOffsetUs() = 0;
81
59
  };
82
60
 
83
61
  #endif
@@ -197,13 +197,13 @@ namespace Utils
197
197
  template<typename T>
198
198
  typename std::enable_if<std::is_unsigned<T>::value, bool>::type static IsPaddedTo4Bytes(T size)
199
199
  {
200
- return (size & 0x03) == 0u;
200
+ return (size & 0x03) == 0;
201
201
  }
202
202
 
203
203
  template<typename T>
204
204
  typename std::enable_if<std::is_unsigned<T>::value, bool>::type static IsPaddedTo8Bytes(T size)
205
205
  {
206
- return (size & 0x07) == 0u;
206
+ return (size & 0x07) == 0;
207
207
  }
208
208
 
209
209
  template<typename T>
@@ -515,7 +515,10 @@ namespace Utils
515
515
  uint32_t fractions;
516
516
  };
517
517
 
518
- static Time::Ntp TimeMs2Ntp(uint64_t ms)
518
+ /**
519
+ * Convert microseconds into an NTP timestamp.
520
+ */
521
+ static Time::Ntp TimeUs2Ntp(int64_t timeUs)
519
522
  {
520
523
  Time::Ntp ntp{}; // NOLINT(cppcoreguidelines-pro-type-member-init)
521
524
 
@@ -523,28 +526,44 @@ namespace Utils
523
526
  // every 2^32 seconds since Jan 1, 1900, being Feb 7, 2036 the next time it
524
527
  // happens. That is the NTP era and receivers deal with it by doing modular
525
528
  // arithmetic, so there is nothing to protect against here.
526
- ntp.seconds = static_cast<uint32_t>(ms / 1000);
529
+ ntp.seconds = static_cast<uint32_t>(timeUs / 1000000);
527
530
  ntp.fractions =
528
- static_cast<uint32_t>((static_cast<double>(ms % 1000) / 1000) * NtpFractionalUnit);
531
+ static_cast<uint32_t>((static_cast<double>(timeUs % 1000000) / 1000000) * NtpFractionalUnit);
529
532
 
530
533
  return ntp;
531
534
  }
532
535
 
533
- static uint64_t Ntp2TimeMs(Time::Ntp ntp)
536
+ /**
537
+ * Convert an NTP timestamp into microseconds.
538
+ */
539
+ static int64_t Ntp2TimeUs(Time::Ntp ntp)
534
540
  {
535
541
  return (
536
- (static_cast<uint64_t>(ntp.seconds) * 1000) +
537
- static_cast<uint64_t>(
538
- std::round((static_cast<double>(ntp.fractions) * 1000) / NtpFractionalUnit)));
542
+ (static_cast<int64_t>(ntp.seconds) * 1000000) +
543
+ static_cast<int64_t>(
544
+ std::round((static_cast<double>(ntp.fractions) * 1000000) / NtpFractionalUnit)));
539
545
  }
540
546
 
541
- static uint32_t TimeMsToAbsSendTime(uint64_t ms)
547
+ /**
548
+ * Convert microseconds into the 6.18 fixed point seconds of the
549
+ * `abs-send-time` RTP header extension, whose resolution is hence 1/262144
550
+ * of a second.
551
+ */
552
+ static uint32_t TimeUsToAbsSendTime(int64_t timeUs)
542
553
  {
543
- return static_cast<uint32_t>(((ms << 18) + 500) / 1000) & 0x00FFFFFF;
554
+ // Period after which the 24 bits of the field wrap around.
555
+ constexpr int64_t WrapPeriodUs{ 64 * 1000000 };
556
+
557
+ // NOTE: Bring the given time into the period first. This keeps the shift
558
+ // below from overflowing, and makes a negative time yield the same value
559
+ // as the positive time it's congruent with rather than a meaningless one.
560
+ const int64_t wrappedUs = ((timeUs % WrapPeriodUs) + WrapPeriodUs) % WrapPeriodUs;
561
+
562
+ return static_cast<uint32_t>(((wrappedUs << 18) + 500000) / 1000000) & 0x00FFFFFF;
544
563
  }
545
564
 
546
565
  /**
547
- * Convert milliseconds into signed Q32.32 fixed point seconds, which is how the
566
+ * Convert microseconds into signed Q32.32 fixed point seconds, which is how the
548
567
  * `abs-capture-time` RTP header extension encodes its clock offset, being the
549
568
  * capture timestamp itself unsigned instead (UQ32.32).
550
569
  *
@@ -553,29 +572,29 @@ namespace Utils
553
572
  *
554
573
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-avtcore-abs-capture-time-00
555
574
  */
556
- static std::optional<int64_t> TimeMs2Q32x32(int64_t ms)
575
+ static std::optional<int64_t> TimeUs2Q32x32(int64_t timeUs)
557
576
  {
558
577
  // The seconds of the format are 32 bits wide, so from here on it does not fit.
559
- static constexpr int64_t OutOfRangeMs{ (1LL << 31) * 1000 };
578
+ static constexpr int64_t OutOfRangeUs{ (1LL << 31) * 1000000 };
560
579
 
561
- if (ms >= OutOfRangeMs || ms <= -OutOfRangeMs)
580
+ if (timeUs >= OutOfRangeUs || timeUs <= -OutOfRangeUs)
562
581
  {
563
582
  return std::nullopt;
564
583
  }
565
584
 
566
- return static_cast<int64_t>(
567
- std::round(static_cast<double>(ms) * (static_cast<double>(NtpFractionalUnit) / 1000)));
585
+ return static_cast<int64_t>(std::round(
586
+ static_cast<double>(timeUs) * (static_cast<double>(NtpFractionalUnit) / 1000000)));
568
587
  }
569
588
 
570
589
  /**
571
- * Convert signed Q32.32 fixed point seconds into milliseconds.
590
+ * Convert signed Q32.32 fixed point seconds into microseconds.
572
591
  *
573
592
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-avtcore-abs-capture-time-00
574
593
  */
575
- static int64_t Q32x32ToTimeMs(int64_t q32x32)
594
+ static int64_t Q32x32ToTimeUs(int64_t q32x32)
576
595
  {
577
- return static_cast<int64_t>(
578
- std::round(static_cast<double>(q32x32) * (1000 / static_cast<double>(NtpFractionalUnit))));
596
+ return static_cast<int64_t>(std::round(
597
+ static_cast<double>(q32x32) * (1000000 / static_cast<double>(NtpFractionalUnit))));
579
598
  }
580
599
  };
581
600
 
@@ -1,6 +1,9 @@
1
1
  #ifndef MS_COMMON_HPP
2
2
  #define MS_COMMON_HPP
3
3
 
4
+ // NOTE: This is an umbrella header. The includes below are not meant to be used
5
+ // by this file, but re-exported to whoever includes it.
6
+ // IWYU pragma: begin_exports
4
7
  #include <algorithm> // std::transform(), std::find(), std::min(), std::max(), std::copy(), std::clamp(), std::ranges
5
8
  #include <cinttypes> // PRIu64, etc
6
9
  #include <cstddef> // size_t
@@ -24,6 +27,7 @@ typedef SSIZE_T ssize_t;
24
27
  #include <netinet/in.h> // sockaddr_in, sockaddr_in6
25
28
  #include <sys/socket.h> // struct sockaddr, struct sockaddr_storage, AF_INET, AF_INET6
26
29
  #endif
30
+ // IWYU pragma: end_exports
27
31
 
28
32
  // This is a macro to silence false warnings in GCC in switch() blocks with FBS
29
33
  // types.
@@ -40,7 +40,7 @@ public:
40
40
  * Set the base timeout duration. It will be applied after the next timeout
41
41
  * and effective duration can be larger if backoff algorithm is exponential.
42
42
  */
43
- void SetBaseTimeoutMs(uint64_t baseTimeoutMs) override;
43
+ void SetBaseTimeoutMs(int64_t baseTimeoutMs) override;
44
44
 
45
45
  /**
46
46
  * Whether the BackoffTimer is running. Useful to check if this BackoffTimer
@@ -77,7 +77,7 @@ public:
77
77
  }
78
78
 
79
79
  private:
80
- uint64_t ComputeNextTimeoutMs() const;
80
+ int64_t ComputeNextTimeoutMs() const;
81
81
 
82
82
  /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
83
83
  public:
@@ -87,9 +87,9 @@ private:
87
87
  // Passed by argument.
88
88
  BackoffTimerHandleInterface::Listener* listener{ nullptr };
89
89
  const std::string label;
90
- uint64_t baseTimeoutMs;
90
+ int64_t baseTimeoutMs;
91
91
  BackoffAlgorithm backoffAlgorithm;
92
- std::optional<uint64_t> maxBackoffTimeoutMs;
92
+ std::optional<int64_t> maxBackoffTimeoutMs;
93
93
  std::optional<size_t> maxRestarts;
94
94
  // Allocated by this.
95
95
  TimerHandle* timer{ nullptr };
@@ -23,7 +23,7 @@ public:
23
23
  * it must signal it be setting `stop` to true.
24
24
  */
25
25
  virtual void OnBackoffTimer(
26
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) = 0;
26
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop) = 0;
27
27
  };
28
28
 
29
29
  public:
@@ -51,7 +51,7 @@ public:
51
51
  /**
52
52
  * Base timeout duration (ms).
53
53
  */
54
- uint64_t baseTimeoutMs;
54
+ int64_t baseTimeoutMs;
55
55
  /**
56
56
  * Backoff algorithm.
57
57
  */
@@ -60,7 +60,7 @@ public:
60
60
  * Maximum duration of the backoff timeout (ms). If no value is given, no
61
61
  * limit is set.
62
62
  */
63
- std::optional<uint64_t> maxBackoffTimeoutMs;
63
+ std::optional<int64_t> maxBackoffTimeoutMs;
64
64
  /**
65
65
  * Maximum number of restarts. If no value is given, it will restart
66
66
  * forever until stopped.
@@ -69,7 +69,7 @@ public:
69
69
  };
70
70
 
71
71
  public:
72
- static constexpr uint64_t MaxTimeoutMs{ std::numeric_limits<uint64_t>::max() / 2 };
72
+ static constexpr int64_t MaxTimeoutMs{ std::numeric_limits<int64_t>::max() / 2 };
73
73
 
74
74
  public:
75
75
  BackoffTimerHandleInterface() = default;
@@ -96,7 +96,7 @@ public:
96
96
  * Set the base timeout duration. It will be applied after the next timeout
97
97
  * and effective duration can be larger if backoff algorithm is exponential.
98
98
  */
99
- virtual void SetBaseTimeoutMs(uint64_t baseTimeoutMs) = 0;
99
+ virtual void SetBaseTimeoutMs(int64_t baseTimeoutMs) = 0;
100
100
 
101
101
  /**
102
102
  * Whether the BackoffTimer is running. Useful to check if this BackoffTimer
@@ -125,16 +125,16 @@ protected:
125
125
 
126
126
  protected:
127
127
  // Passed by argument.
128
- size_t bufferSize{ 0u };
128
+ size_t bufferSize{ 0 };
129
129
  // Allocated by this.
130
130
  uint8_t* buffer{ nullptr };
131
131
  // Others.
132
- size_t bufferDataLen{ 0u };
132
+ size_t bufferDataLen{ 0 };
133
133
  std::string localIp;
134
- uint16_t localPort{ 0u };
134
+ uint16_t localPort{ 0 };
135
135
  struct sockaddr_storage peerAddr{};
136
136
  std::string peerIp;
137
- uint16_t peerPort{ 0u };
137
+ uint16_t peerPort{ 0 };
138
138
 
139
139
  private:
140
140
  // Passed by argument.
@@ -144,8 +144,8 @@ private:
144
144
  // Others.
145
145
  struct sockaddr_storage* localAddr{ nullptr };
146
146
  bool closed{ false };
147
- size_t recvBytes{ 0u };
148
- size_t sentBytes{ 0u };
147
+ size_t recvBytes{ 0 };
148
+ size_t sentBytes{ 0 };
149
149
  bool isClosedByPeer{ false };
150
150
  bool hasError{ false };
151
151
  };
@@ -66,7 +66,7 @@ public:
66
66
  protected:
67
67
  struct sockaddr_storage localAddr{};
68
68
  std::string localIp;
69
- uint16_t localPort{ 0u };
69
+ uint16_t localPort{ 0 };
70
70
 
71
71
  private:
72
72
  // Allocated by this (may be passed by argument).
@@ -16,7 +16,7 @@ class TimerHandle : public TimerHandleInterface
16
16
  friend class BackoffTimerHandle;
17
17
 
18
18
  private:
19
- explicit TimerHandle(TimerHandleInterface::Listener* listener);
19
+ explicit TimerHandle(TimerHandleInterface::Listener* listener, std::string label);
20
20
 
21
21
  public:
22
22
  TimerHandle& operator=(const TimerHandle&) = delete;
@@ -26,22 +26,22 @@ public:
26
26
  ~TimerHandle() override;
27
27
 
28
28
  public:
29
- void Start(uint64_t timeout, uint64_t repeat = 0) override;
29
+ void Start(int64_t timeoutMs, int64_t repeatMs = 0) override;
30
30
 
31
31
  void Stop() override;
32
32
 
33
33
  void Restart() override;
34
34
 
35
- void Restart(uint64_t timeout, uint64_t repeat = 0) override;
35
+ void Restart(int64_t timeoutMs, int64_t repeatMs = 0) override;
36
36
 
37
- uint64_t GetTimeout() const override
37
+ int64_t GetTimeoutMs() const override
38
38
  {
39
- return this->timeout;
39
+ return this->timeoutMs;
40
40
  }
41
41
 
42
- uint64_t GetRepeat() const override
42
+ int64_t GetRepeatMs() const override
43
43
  {
44
- return this->repeat;
44
+ return this->repeatMs;
45
45
  }
46
46
 
47
47
  bool IsActive() const override
@@ -49,6 +49,11 @@ public:
49
49
  return uv_is_active(reinterpret_cast<uv_handle_t*>(this->uvHandle)) != 0;
50
50
  }
51
51
 
52
+ const std::string GetLabel() const override
53
+ {
54
+ return this->label;
55
+ }
56
+
52
57
  private:
53
58
  void InternalClose();
54
59
 
@@ -59,12 +64,13 @@ public:
59
64
  private:
60
65
  // Passed by argument.
61
66
  TimerHandleInterface::Listener* listener{ nullptr };
67
+ const std::string label;
62
68
  // Allocated by this.
63
69
  uv_timer_t* uvHandle{ nullptr };
64
70
  // Others.
65
71
  bool closed{ false };
66
- uint64_t timeout{ 0u };
67
- uint64_t repeat{ 0u };
72
+ int64_t timeoutMs{ 0 };
73
+ int64_t repeatMs{ 0 };
68
74
  };
69
75
 
70
76
  #endif
@@ -2,6 +2,7 @@
2
2
  #define MS_TIMER_HANDLE_INTERFACE_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include <string>
5
6
 
6
7
  class TimerHandleInterface
7
8
  {
@@ -25,19 +26,24 @@ public:
25
26
  virtual ~TimerHandleInterface() = default;
26
27
 
27
28
  public:
28
- virtual void Start(uint64_t timeout, uint64_t repeat = 0) = 0;
29
+ virtual void Start(int64_t timeoutMs, int64_t repeatMs = 0) = 0;
29
30
 
30
31
  virtual void Stop() = 0;
31
32
 
32
33
  virtual void Restart() = 0;
33
34
 
34
- virtual void Restart(uint64_t timeout, uint64_t repeat = 0) = 0;
35
+ virtual void Restart(int64_t timeoutMs, int64_t repeatMs = 0) = 0;
35
36
 
36
- virtual uint64_t GetTimeout() const = 0;
37
+ virtual int64_t GetTimeoutMs() const = 0;
37
38
 
38
- virtual uint64_t GetRepeat() const = 0;
39
+ virtual int64_t GetRepeatMs() const = 0;
39
40
 
40
41
  virtual bool IsActive() const = 0;
42
+
43
+ /**
44
+ * Label of this timer, given at creation time.
45
+ */
46
+ virtual const std::string GetLabel() const = 0;
41
47
  };
42
48
 
43
49
  #endif
@@ -96,15 +96,15 @@ protected:
96
96
  protected:
97
97
  struct sockaddr_storage localAddr{};
98
98
  std::string localIp;
99
- uint16_t localPort{ 0u };
99
+ uint16_t localPort{ 0 };
100
100
 
101
101
  private:
102
102
  // Allocated by this (may be passed by argument).
103
103
  uv_udp_t* uvHandle{ nullptr };
104
104
  // Others.
105
105
  bool closed{ false };
106
- size_t recvBytes{ 0u };
107
- size_t sentBytes{ 0u };
106
+ size_t recvBytes{ 0 };
107
+ size_t sentBytes{ 0 };
108
108
  };
109
109
 
110
110
  #endif
@@ -71,12 +71,12 @@ private:
71
71
 
72
72
  protected:
73
73
  // Passed by argument.
74
- size_t bufferSize{ 0u };
74
+ size_t bufferSize{ 0 };
75
75
  UnixStreamSocketHandle::Role role;
76
76
  // Allocated by this.
77
77
  uint8_t* buffer{ nullptr };
78
78
  // Others.
79
- size_t bufferDataLen{ 0u };
79
+ size_t bufferDataLen{ 0 };
80
80
  };
81
81
 
82
82
  #endif