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
@@ -196,7 +196,7 @@ namespace RTC
196
196
  {
197
197
  StreamReset streamReset = std::get<StreamReset>(std::move(data));
198
198
  listener->OnAssociationStreamsResetPerformed(streamReset.streamIds);
199
- },
199
+ },
200
200
  StreamReset{ .streamIds = { outboundStreamIds.begin(), outboundStreamIds.end() } });
201
201
  }
202
202
 
@@ -212,9 +212,9 @@ namespace RTC
212
212
  {
213
213
  StreamReset streamReset = std::get<StreamReset>(std::move(data));
214
214
  listener->OnAssociationStreamsResetFailed(streamReset.streamIds, streamReset.errorMessage);
215
- },
215
+ },
216
216
  StreamReset{ .streamIds = { outboundStreamIds.begin(), outboundStreamIds.end() },
217
- .errorMessage = std::string(errorMessage) });
217
+ .errorMessage = std::string(errorMessage) });
218
218
  }
219
219
 
220
220
  void AssociationListenerDeferrer::OnAssociationInboundStreamsReset(
@@ -229,7 +229,7 @@ namespace RTC
229
229
  {
230
230
  StreamReset streamReset = std::get<StreamReset>(std::move(data));
231
231
  listener->OnAssociationInboundStreamsReset(streamReset.streamIds);
232
- },
232
+ },
233
233
  StreamReset{ .streamIds = { inboundStreamIds.begin(), inboundStreamIds.end() } });
234
234
  }
235
235
 
@@ -35,7 +35,7 @@ namespace RTC
35
35
  capabilities.partialReliability =
36
36
  remoteForwardTsnSupportedParameter ||
37
37
  (remoteSupportedExtensionsParameter &&
38
- remoteSupportedExtensionsParameter->IncludesChunkType(Chunk::ChunkType::FORWARD_TSN));
38
+ remoteSupportedExtensionsParameter->IncludesChunkType(Chunk::ChunkType::FORWARD_TSN));
39
39
 
40
40
  // Remote announces Message Interleaving support via Supported Extensions
41
41
  // parameter.
@@ -71,8 +71,9 @@ namespace RTC
71
71
 
72
72
  if (intervalDurationShouldIncludeRtt)
73
73
  {
74
+ // NOTE: The timer takes milliseconds, so the RTO is truncated here.
74
75
  this->intervalTimer->SetBaseTimeoutMs(
75
- this->intervalDurationMs + this->tcbContext->GetCurrentRtoMs());
76
+ this->intervalDurationMs + (this->tcbContext->GetCurrentRtoUs() / 1000));
76
77
  }
77
78
  else
78
79
  {
@@ -149,24 +150,27 @@ namespace RTC
149
150
  return;
150
151
  }
151
152
 
152
- const uint64_t createdAtMs = Utils::Byte::Get8Bytes(info, 0);
153
- const uint64_t nowMs = this->shared->GetTimeMs();
153
+ // NOTE: The peer echoes back the info we wrote, so this value cannot be
154
+ // trusted. The guard below rejects it unless it's a past instant, which
155
+ // also rejects a negative resulting from garbage above 2^63.
156
+ const auto createdAtUs = static_cast<int64_t>(Utils::Byte::Get8Bytes(info, 0));
157
+ const int64_t nowUs = this->shared->GetTimeUs();
154
158
 
155
- if (createdAtMs > 0 && createdAtMs <= nowMs)
159
+ if (createdAtUs > 0 && createdAtUs <= nowUs)
156
160
  {
157
- const uint64_t rttMs = nowMs - createdAtMs;
161
+ const int64_t rttUs = nowUs - createdAtUs;
158
162
 
159
- MS_DEBUG_DEV("valid HEARTBEAT-ACK chunk received, calling ObserveRttMs(%" PRIu64 ")", rttMs);
163
+ MS_DEBUG_DEV("valid HEARTBEAT-ACK chunk received, calling ObserveRttUs(%" PRIi64 ")", rttUs);
160
164
 
161
- this->tcbContext->ObserveRttMs(rttMs);
165
+ this->tcbContext->ObserveRttUs(rttUs);
162
166
  }
163
167
  else
164
168
  {
165
169
  MS_WARN_DEV(
166
- "ignoring received HEARTBEAT-ACK chunk with invalid info content [createdAtMs:%" PRIu64
167
- ", nowMs:%" PRIu64 "]",
168
- createdAtMs,
169
- nowMs);
170
+ "ignoring received HEARTBEAT-ACK chunk with invalid info content [createdAtUs:%" PRIi64
171
+ ", nowUs:%" PRIi64 "]",
172
+ createdAtUs,
173
+ nowUs);
170
174
  }
171
175
 
172
176
  // https://datatracker.ietf.org/doc/html/rfc9260#section-8.1
@@ -176,7 +180,7 @@ namespace RTC
176
180
  this->tcbContext->ClearTxErrorCounter();
177
181
  }
178
182
 
179
- void HeartbeatHandler::OnIntervalTimer(uint64_t& /*baseTimeoutMs*/, bool& /*stop*/)
183
+ void HeartbeatHandler::OnIntervalTimer(int64_t& /*baseTimeoutMs*/, bool& /*stop*/)
180
184
  {
181
185
  MS_TRACE();
182
186
 
@@ -204,14 +208,17 @@ namespace RTC
204
208
  return;
205
209
  }
206
210
 
207
- this->timeoutTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoMs());
211
+ // NOTE: The timer takes milliseconds, so the RTO is truncated here.
212
+ this->timeoutTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoUs() / 1000);
208
213
  this->timeoutTimer->Start();
209
214
 
210
215
  alignas(8) uint8_t info[HeartbeatInfoLength];
211
216
 
212
- const uint64_t nowMs = this->shared->GetTimeMs();
217
+ // NOTE: This is read back in HandleReceivedHeartbeatAckChunk() when the
218
+ // peer echoes it, so both sides of it must use the same unit.
219
+ const int64_t nowUs = this->shared->GetTimeUs();
213
220
 
214
- Utils::Byte::Set8Bytes(info, 0, nowMs);
221
+ Utils::Byte::Set8Bytes(info, 0, static_cast<uint64_t>(nowUs));
215
222
 
216
223
  auto packet = this->tcbContext->CreatePacket();
217
224
  auto* heartbeatRequestChunk = packet->BuildChunkInPlace<HeartbeatRequestChunk>();
@@ -222,12 +229,12 @@ namespace RTC
222
229
  heartbeatInfoParameter->Consolidate();
223
230
  heartbeatRequestChunk->Consolidate();
224
231
 
225
- MS_DEBUG_DEV("sending HEARTBEAT-REQUEST chunk with info content [nowMs:%" PRIu64 "]", nowMs);
232
+ MS_DEBUG_DEV("sending HEARTBEAT-REQUEST chunk with info content [nowUs:%" PRIi64 "]", nowUs);
226
233
 
227
234
  this->tcbContext->SendPacket(packet.get());
228
235
  }
229
236
 
230
- void HeartbeatHandler::OnTimeoutTimer(uint64_t& /*baseTimeoutMs*/, bool& stop)
237
+ void HeartbeatHandler::OnTimeoutTimer(int64_t& /*baseTimeoutMs*/, bool& stop)
231
238
  {
232
239
  MS_TRACE();
233
240
 
@@ -261,7 +268,7 @@ namespace RTC
261
268
  }
262
269
 
263
270
  void HeartbeatHandler::OnBackoffTimer(
264
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop)
271
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop)
265
272
  {
266
273
  MS_TRACE();
267
274
 
@@ -49,7 +49,7 @@ namespace RTC
49
49
  uint32_t remoteAdvertisedReceiverWindowCredit,
50
50
  uint64_t tieTag,
51
51
  const Capabilities& remoteCapabilities,
52
- uint64_t creationTimestampMs,
52
+ int64_t creationTimestampUs,
53
53
  const uint8_t* macKey,
54
54
  size_t macKeyLength)
55
55
  {
@@ -66,7 +66,7 @@ namespace RTC
66
66
  remoteAdvertisedReceiverWindowCredit,
67
67
  tieTag,
68
68
  remoteCapabilities,
69
- creationTimestampMs,
69
+ creationTimestampUs,
70
70
  macKey,
71
71
  macKeyLength);
72
72
 
@@ -86,7 +86,7 @@ namespace RTC
86
86
  uint32_t remoteAdvertisedReceiverWindowCredit,
87
87
  uint64_t tieTag,
88
88
  const Capabilities& remoteCapabilities,
89
- uint64_t creationTimestampMs,
89
+ int64_t creationTimestampUs,
90
90
  const uint8_t* macKey,
91
91
  size_t macKeyLength)
92
92
  {
@@ -132,7 +132,8 @@ namespace RTC
132
132
  // bytes (including the timestamp).
133
133
  //
134
134
  // @see RFC 9260 section 5.1.3.
135
- Utils::Byte::Set8Bytes(buffer, StateCookie::TimestampOffset, creationTimestampMs);
135
+ Utils::Byte::Set8Bytes(
136
+ buffer, StateCookie::TimestampOffset, static_cast<uint64_t>(creationTimestampUs));
136
137
 
137
138
  const uint8_t* mac = Utils::Crypto::GetHmacSha1(
138
139
  reinterpret_cast<const char*>(macKey), macKeyLength, buffer, StateCookie::MacOffset);
@@ -228,7 +229,7 @@ namespace RTC
228
229
  SetLength(
229
230
  bufferLength == StateCookie::AuthenticatedStateCookieLength
230
231
  ? StateCookie::AuthenticatedStateCookieLength
231
- : StateCookie::StateCookieLength);
232
+ : StateCookie::StateCookieLength);
232
233
  }
233
234
 
234
235
  StateCookie::~StateCookie()
@@ -258,7 +259,7 @@ namespace RTC
258
259
 
259
260
  if (IsAuthenticated())
260
261
  {
261
- MS_DUMP_CLEAN(indentation, " creation timestamp (ms): %" PRIu64, GetCreationTimestampMs());
262
+ MS_DUMP_CLEAN(indentation, " creation timestamp (us): %" PRIi64, GetCreationTimestampUs());
262
263
  }
263
264
 
264
265
  MS_DUMP_CLEAN(indentation, " remote capabilities:");
@@ -77,7 +77,8 @@ namespace RTC
77
77
  this->retransmissionQueue->GetLastAssignedTsn(),
78
78
  this->retransmissionQueue->BeginResetStreams());
79
79
 
80
- this->reConfigTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoMs());
80
+ // NOTE: The timer takes milliseconds, so the RTO is truncated here.
81
+ this->reConfigTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoUs() / 1000);
81
82
  this->reConfigTimer->Start();
82
83
 
83
84
  AddReConfigChunk(packet);
@@ -168,21 +169,21 @@ namespace RTC
168
169
 
169
170
  if (
170
171
  (firstParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST &&
171
- secondParameter->GetType() == Parameter::ParameterType::INCOMING_SSN_RESET_REQUEST) ||
172
+ secondParameter->GetType() == Parameter::ParameterType::INCOMING_SSN_RESET_REQUEST) ||
172
173
  (firstParameter->GetType() == Parameter::ParameterType::INCOMING_SSN_RESET_REQUEST &&
173
- secondParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST) ||
174
+ secondParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST) ||
174
175
  (firstParameter->GetType() == Parameter::ParameterType::ADD_OUTGOING_STREAMS_REQUEST &&
175
- secondParameter->GetType() == Parameter::ParameterType::ADD_INCOMING_STREAMS_REQUEST) ||
176
+ secondParameter->GetType() == Parameter::ParameterType::ADD_INCOMING_STREAMS_REQUEST) ||
176
177
  (firstParameter->GetType() == Parameter::ParameterType::ADD_INCOMING_STREAMS_REQUEST &&
177
- secondParameter->GetType() == Parameter::ParameterType::ADD_OUTGOING_STREAMS_REQUEST) ||
178
+ secondParameter->GetType() == Parameter::ParameterType::ADD_OUTGOING_STREAMS_REQUEST) ||
178
179
  (firstParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE &&
179
- secondParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST) ||
180
+ secondParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST) ||
180
181
  (firstParameter->GetType() == Parameter::ParameterType::OUTGOING_SSN_RESET_REQUEST &&
181
- secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE) ||
182
+ secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE) ||
182
183
  (firstParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE &&
183
- secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE) ||
184
+ secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE) ||
184
185
  (firstParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE &&
185
- secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE))
186
+ secondParameter->GetType() == Parameter::ParameterType::RECONFIGURATION_RESPONSE))
186
187
  {
187
188
  return true;
188
189
  }
@@ -435,7 +436,8 @@ namespace RTC
435
436
  // Force this request to be sent again, but with the same `reqSeqNbr`.
436
437
  this->currentRequest->SetDeferred(true);
437
438
 
438
- this->reConfigTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoMs());
439
+ // NOTE: The timer takes milliseconds, so the RTO is truncated here.
440
+ this->reConfigTimer->SetBaseTimeoutMs(this->tcbContext->GetCurrentRtoUs() / 1000);
439
441
  this->reConfigTimer->Start();
440
442
 
441
443
  break;
@@ -469,7 +471,7 @@ namespace RTC
469
471
  }
470
472
  }
471
473
 
472
- void StreamResetHandler::OnReConfigTimer(uint64_t& baseTimeoutMs, bool& stop)
474
+ void StreamResetHandler::OnReConfigTimer(int64_t& baseTimeoutMs, bool& stop)
473
475
  {
474
476
  MS_TRACE();
475
477
 
@@ -520,11 +522,12 @@ namespace RTC
520
522
 
521
523
  this->tcbContext->SendPacket(packet.get());
522
524
 
523
- baseTimeoutMs = this->tcbContext->GetCurrentRtoMs();
525
+ // NOTE: The timer takes milliseconds, so the RTO is truncated here.
526
+ baseTimeoutMs = this->tcbContext->GetCurrentRtoUs() / 1000;
524
527
  }
525
528
 
526
529
  void StreamResetHandler::OnBackoffTimer(
527
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop)
530
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop)
528
531
  {
529
532
  MS_TRACE();
530
533
 
@@ -125,27 +125,31 @@ namespace RTC
125
125
  MS_DUMP_CLEAN(indentation, "</SCTP::TransmissionControlBlock>");
126
126
  }
127
127
 
128
- void TransmissionControlBlock::ObserveRttMs(uint64_t rttMs)
128
+ void TransmissionControlBlock::ObserveRttUs(int64_t rttUs)
129
129
  {
130
130
  MS_TRACE();
131
131
 
132
132
  #if MS_LOG_DEV_LEVEL == 3
133
- const auto prevRtoMs = this->rto.GetRtoMs();
133
+ const auto prevRtoUs = this->rto.GetRtoUs();
134
134
  #endif
135
135
 
136
- this->rto.ObserveRttMs(rttMs);
136
+ this->rto.ObserveRttUs(rttUs);
137
137
 
138
138
  MS_DEBUG_DEV(
139
- "new rtt:%" PRIu64 ", previous rto:%" PRIu64 ", new rto:%" PRIu64 ", srtt:%" PRIu64,
140
- rttMs,
141
- prevRtoMs,
142
- this->rto.GetRtoMs(),
143
- this->rto.GetSrttMs());
139
+ "new rtt:%" PRIi64 " us, previous rto:%" PRIi64 " us, new rto:%" PRIi64 " us, srtt:%" PRIi64
140
+ " us",
141
+ rttUs,
142
+ prevRtoUs,
143
+ this->rto.GetRtoUs(),
144
+ this->rto.GetSrttUs());
144
145
 
145
- this->t3RtxTimer->SetBaseTimeoutMs(this->rto.GetRtoMs());
146
+ // NOTE: The timers take milliseconds, so the RTO is truncated here. It is
147
+ // hundreds of milliseconds long, so the sub-millisecond part is noise.
148
+ this->t3RtxTimer->SetBaseTimeoutMs(this->rto.GetRtoUs() / 1000);
146
149
 
147
- const uint64_t delayedAckTimeoutMs = std::min(
148
- static_cast<uint64_t>(this->rto.GetRtoMs() * 0.5), this->sctpOptions.delayedAckMaxTimeoutMs);
150
+ const int64_t delayedAckTimeoutMs = std::min(
151
+ static_cast<int64_t>((this->rto.GetRtoUs() * 0.5) / 1000),
152
+ this->sctpOptions.delayedAckMaxTimeoutMs);
149
153
 
150
154
  this->delayedAckTimer->SetBaseTimeoutMs(delayedAckTimeoutMs);
151
155
  }
@@ -211,11 +215,11 @@ namespace RTC
211
215
  SendPacket(packet.get());
212
216
  }
213
217
 
214
- void TransmissionControlBlock::MayAddForwardTsnChunk(Packet* packet, uint64_t nowMs)
218
+ void TransmissionControlBlock::MayAddForwardTsnChunk(Packet* packet, int64_t nowUs)
215
219
  {
216
220
  MS_TRACE();
217
221
 
218
- if (nowMs >= this->limitForwardTsnUntilMs && this->retransmissionQueue.ShouldSendForwardTsn(nowMs))
222
+ if (nowUs >= this->limitForwardTsnUntilUs && this->retransmissionQueue.ShouldSendForwardTsn(nowUs))
219
223
  {
220
224
  if (this->negotiatedCapabilities.messageInterleaving)
221
225
  {
@@ -233,7 +237,7 @@ namespace RTC
233
237
  // before sending a duplicate FORWARD TSN."
234
238
  // "Any delay applied to the sending of FORWARD TSN chunk SHOULD NOT
235
239
  // exceed 200ms and MUST NOT exceed 500ms".
236
- this->limitForwardTsnUntilMs = nowMs + std::min(uint64_t{ 200 }, this->rto.GetSrttMs());
240
+ this->limitForwardTsnUntilUs = nowUs + std::min(int64_t{ 200 * 1000 }, this->rto.GetSrttUs());
237
241
  }
238
242
  }
239
243
 
@@ -284,7 +288,7 @@ namespace RTC
284
288
  SendPacket(packet.get());
285
289
  }
286
290
 
287
- void TransmissionControlBlock::SendBufferedPackets(uint64_t nowMs, bool addCookieAckChunk)
291
+ void TransmissionControlBlock::SendBufferedPackets(int64_t nowUs, bool addCookieAckChunk)
288
292
  {
289
293
  MS_TRACE();
290
294
 
@@ -338,9 +342,7 @@ namespace RTC
338
342
  packet.get(), this->reassemblyQueue.GetRemainingBytes());
339
343
  }
340
344
 
341
- const uint64_t nowMs = this->shared->GetTimeMs();
342
-
343
- MayAddForwardTsnChunk(packet.get(), nowMs);
345
+ MayAddForwardTsnChunk(packet.get(), nowUs);
344
346
 
345
347
  if (this->streamResetHandler.ShouldSendStreamResetRequest())
346
348
  {
@@ -349,7 +351,7 @@ namespace RTC
349
351
  }
350
352
 
351
353
  auto chunksToSend =
352
- this->retransmissionQueue.GetChunksToSend(nowMs, packet->GetAvailableLength());
354
+ this->retransmissionQueue.GetChunksToSend(nowUs, packet->GetAvailableLength());
353
355
 
354
356
  if (!chunksToSend.empty())
355
357
  {
@@ -409,7 +411,7 @@ namespace RTC
409
411
  }
410
412
  }
411
413
 
412
- void TransmissionControlBlock::OnT3RtxTimer(uint64_t& /*baseTimeoutMs*/, bool& stop)
414
+ void TransmissionControlBlock::OnT3RtxTimer(int64_t& /*baseTimeoutMs*/, bool& stop)
413
415
  {
414
416
  MS_TRACE();
415
417
 
@@ -439,9 +441,9 @@ namespace RTC
439
441
  {
440
442
  this->retransmissionQueue.HandleT3RtxTimerExpiry();
441
443
 
442
- const uint64_t nowMs = this->shared->GetTimeMs();
444
+ const int64_t nowUs = this->shared->GetTimeUs();
443
445
 
444
- SendBufferedPackets(nowMs);
446
+ SendBufferedPackets(nowUs);
445
447
  }
446
448
  else
447
449
  {
@@ -455,7 +457,7 @@ namespace RTC
455
457
  }
456
458
  }
457
459
 
458
- void TransmissionControlBlock::OnDelayedAckTimer(uint64_t& /*baseTimeoutMs*/, bool& /*stop*/)
460
+ void TransmissionControlBlock::OnDelayedAckTimer(int64_t& /*baseTimeoutMs*/, bool& /*stop*/)
459
461
  {
460
462
  MS_TRACE();
461
463
 
@@ -482,7 +484,7 @@ namespace RTC
482
484
  }
483
485
 
484
486
  void TransmissionControlBlock::OnBackoffTimer(
485
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop)
487
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop)
486
488
  {
487
489
  MS_TRACE();
488
490
 
@@ -496,11 +498,11 @@ namespace RTC
496
498
  }
497
499
  }
498
500
 
499
- void TransmissionControlBlock::OnRetransmissionQueueNewRttMs(uint64_t newRttMs)
501
+ void TransmissionControlBlock::OnRetransmissionQueueNewRttUs(int64_t newRttUs)
500
502
  {
501
503
  MS_TRACE();
502
504
 
503
- ObserveRttMs(newRttMs);
505
+ ObserveRttUs(newRttUs);
504
506
  }
505
507
 
506
508
  void TransmissionControlBlock::OnRetransmissionQueueClearRetransmissionCounter()
@@ -5,7 +5,6 @@
5
5
  #include "Logger.hpp"
6
6
  #include "MediaSoupErrors.hpp"
7
7
  #include <cstring> // std::memmove()
8
- #include <ranges>
9
8
 
10
9
  namespace RTC
11
10
  {
@@ -123,7 +123,7 @@ namespace RTC
123
123
  uint32_t remoteAdvertisedReceiverWindowCredit,
124
124
  uint64_t tieTag,
125
125
  const Capabilities& remoteCapabilities,
126
- uint64_t creationTimestampMs,
126
+ int64_t creationTimestampUs,
127
127
  const uint8_t* macKey,
128
128
  size_t macKeyLength)
129
129
  {
@@ -148,7 +148,7 @@ namespace RTC
148
148
  remoteAdvertisedReceiverWindowCredit,
149
149
  tieTag,
150
150
  remoteCapabilities,
151
- creationTimestampMs,
151
+ creationTimestampUs,
152
152
  macKey,
153
153
  macKeyLength);
154
154
 
@@ -24,7 +24,7 @@ namespace RTC
24
24
  MS_DUMP_CLEAN(indentation, " rtx packets count: %" PRIu64, this->rtxPacketsCount);
25
25
  MS_DUMP_CLEAN(indentation, " rtx bytes count: %" PRIu64, this->rtxBytesCount);
26
26
  MS_DUMP_CLEAN(indentation, " current congestion window (bytes): %zu", this->cwndBytes);
27
- MS_DUMP_CLEAN(indentation, " smoothed round trip time (ms): %" PRIu64, this->srttMs);
27
+ MS_DUMP_CLEAN(indentation, " smoothed round trip time (ms): %" PRIi64, this->srttMs);
28
28
  MS_DUMP_CLEAN(indentation, " unacked data count: %zu", this->unackDataCount);
29
29
  MS_DUMP_CLEAN(
30
30
  indentation, " peer's last announced receiver window size: %" PRIu32, this->peerRwndBytes);
@@ -34,23 +34,23 @@ namespace RTC
34
34
  " total buffered amount low threshold: %zu",
35
35
  this->totalBufferedAmountLowThreshold);
36
36
  MS_DUMP_CLEAN(indentation, " default stream priority: %" PRIu16, this->defaultStreamPriority);
37
- MS_DUMP_CLEAN(indentation, " max rtt (ms): %" PRIu64, this->maxRttMs);
38
- MS_DUMP_CLEAN(indentation, " initial rto (ms): %" PRIu64, this->initialRtoMs);
39
- MS_DUMP_CLEAN(indentation, " min rto (ms): %" PRIu64, this->minRtoMs);
40
- MS_DUMP_CLEAN(indentation, " max rto (ms): %" PRIu64, this->maxRtoMs);
41
- MS_DUMP_CLEAN(indentation, " t1-init timeout (ms): %" PRIu64, this->t1InitTimeoutMs);
42
- MS_DUMP_CLEAN(indentation, " t1-cookie timeout (ms): %" PRIu64, this->t1CookieTimeoutMs);
43
- MS_DUMP_CLEAN(indentation, " t2-shutdown timeout (ms): %" PRIu64, this->t2ShutdownTimeoutMs);
37
+ MS_DUMP_CLEAN(indentation, " max rtt (ms): %" PRIi64, this->maxRttMs);
38
+ MS_DUMP_CLEAN(indentation, " initial rto (ms): %" PRIi64, this->initialRtoMs);
39
+ MS_DUMP_CLEAN(indentation, " min rto (ms): %" PRIi64, this->minRtoMs);
40
+ MS_DUMP_CLEAN(indentation, " max rto (ms): %" PRIi64, this->maxRtoMs);
41
+ MS_DUMP_CLEAN(indentation, " t1-init timeout (ms): %" PRIi64, this->t1InitTimeoutMs);
42
+ MS_DUMP_CLEAN(indentation, " t1-cookie timeout (ms): %" PRIi64, this->t1CookieTimeoutMs);
43
+ MS_DUMP_CLEAN(indentation, " t2-shutdown timeout (ms): %" PRIi64, this->t2ShutdownTimeoutMs);
44
44
  MS_DUMP_CLEAN(
45
45
  indentation,
46
46
  " timer max backoff timeout (ms): %s",
47
47
  this->timerMaxBackoffTimeoutMs
48
48
  ? std::to_string(this->timerMaxBackoffTimeoutMs.value()).c_str()
49
- : "Infinite");
50
- MS_DUMP_CLEAN(indentation, " heartbeat interval (ms): %" PRIu64, this->heartbeatIntervalMs);
49
+ : "Infinite");
50
+ MS_DUMP_CLEAN(indentation, " heartbeat interval (ms): %" PRIi64, this->heartbeatIntervalMs);
51
51
  MS_DUMP_CLEAN(
52
- indentation, " delayed ack max timeout (ms): %" PRIu64, this->delayedAckMaxTimeoutMs);
53
- MS_DUMP_CLEAN(indentation, " min rtt variance (ms): %" PRIu64, this->minRttVarianceMs);
52
+ indentation, " delayed ack max timeout (ms): %" PRIi64, this->delayedAckMaxTimeoutMs);
53
+ MS_DUMP_CLEAN(indentation, " min rtt variance (ms): %" PRIi64, this->minRttVarianceMs);
54
54
  MS_DUMP_CLEAN(indentation, " initial cwnd mtus: %zu", this->initialCwndMtus);
55
55
  MS_DUMP_CLEAN(indentation, " min cwnd mtus: %zu", this->minCwndMtus);
56
56
  MS_DUMP_CLEAN(
@@ -62,12 +62,12 @@ namespace RTC
62
62
  indentation,
63
63
  " max retransmissions: %s",
64
64
  this->maxRetransmissions ? std::to_string(this->maxRetransmissions.value()).c_str()
65
- : "Infinite");
65
+ : "Infinite");
66
66
  MS_DUMP_CLEAN(
67
67
  indentation,
68
68
  " max init retransmissions: %s",
69
69
  this->maxInitRetransmissions ? std::to_string(this->maxInitRetransmissions.value()).c_str()
70
- : "Infinite");
70
+ : "Infinite");
71
71
  MS_DUMP_CLEAN(
72
72
  indentation, " enable partial reliability: %s", this->enablePartialReliability ? "yes" : "no");
73
73
  MS_DUMP_CLEAN(
@@ -256,7 +256,7 @@ namespace RTC
256
256
  if (
257
257
  this->ackState == AckState::IMMEDIATE ||
258
258
  (alsoIfDelayed &&
259
- (this->ackState == AckState::BECOMING_DELAYED || this->ackState == AckState::DELAYED)))
259
+ (this->ackState == AckState::BECOMING_DELAYED || this->ackState == AckState::DELAYED)))
260
260
  {
261
261
  UpdateAckState(AckState::IDLE, "should send SACK");
262
262
 
@@ -41,9 +41,9 @@ namespace RTC
41
41
  data.GetMessageId(),
42
42
  data.GetFragmentSequenceNumber(),
43
43
  (data.IsBeginning() && data.IsEnd() ? "complete"
44
- : data.IsBeginning() ? "first"
45
- : data.IsEnd() ? "last"
46
- : "middle"));
44
+ : data.IsBeginning() ? "first"
45
+ : data.IsEnd() ? "last"
46
+ : "middle"));
47
47
 
48
48
  const Types::UnwrappedTsn unwrappedTsn = this->tsnUnwrapper.Unwrap(tsn);
49
49
 
@@ -144,8 +144,8 @@ namespace RTC
144
144
 
145
145
  this->deferredResetStreams->deferredActions.emplace_back(
146
146
  [this,
147
- newCumulativeTsn,
148
- skippedStreams2 = std::vector<AnyForwardTsnChunk::SkippedStream>(
147
+ newCumulativeTsn,
148
+ skippedStreams2 = std::vector<AnyForwardTsnChunk::SkippedStream>(
149
149
  skippedStreams.begin(), skippedStreams.end())]
150
150
  {
151
151
  this->queuedBytes -= ForwardTsnCost(skippedStreams2.size());
@@ -24,15 +24,15 @@ namespace RTC
24
24
  OutstandingData::Item::Item(
25
25
  uint32_t outgoingMessageId,
26
26
  UserData data,
27
- uint64_t timeSentMs,
27
+ int64_t timeSentUs,
28
28
  uint16_t maxRetransmissions,
29
- uint64_t expiresAtMs,
29
+ int64_t expiresAtUs,
30
30
  std::optional<uint64_t> lifecycleId)
31
31
  : outgoingMessageId(outgoingMessageId),
32
32
  data(std::move(data)),
33
- timeSentMs(timeSentMs),
33
+ timeSentUs(timeSentUs),
34
34
  maxRetransmissions(maxRetransmissions),
35
- expiresAtMs(expiresAtMs),
35
+ expiresAtUs(expiresAtUs),
36
36
  lifecycleId(lifecycleId)
37
37
  {
38
38
  MS_TRACE();
@@ -90,7 +90,7 @@ namespace RTC
90
90
  MS_TRACE();
91
91
 
92
92
  MS_ASSERT(
93
- this->expiresAtMs != Types::ExpiresAtMsInfinite ||
93
+ this->expiresAtUs != Types::ExpiresAtUsInfinite ||
94
94
  this->maxRetransmissions != Types::MaxRetransmitsNoLimit,
95
95
  "item should not have infinite expiration time or its retransmission times shouldn't be the maximum");
96
96
 
@@ -173,7 +173,7 @@ namespace RTC
173
173
  return ExtractChunksThatCanFit(this->toBeRetransmitted, maxLength);
174
174
  }
175
175
 
176
- void OutstandingData::ExpireOutstandingChunks(uint64_t nowMs)
176
+ void OutstandingData::ExpireOutstandingChunks(int64_t nowUs)
177
177
  {
178
178
  MS_TRACE();
179
179
 
@@ -192,7 +192,7 @@ namespace RTC
192
192
  {
193
193
  // Already abandoned.
194
194
  }
195
- else if (item.IsNacked() && item.HasExpired(nowMs))
195
+ else if (item.IsNacked() && item.HasExpired(nowUs))
196
196
  {
197
197
  tsnsToExpire.push_back(tsn);
198
198
  }
@@ -232,9 +232,9 @@ namespace RTC
232
232
  std::optional<Types::UnwrappedTsn> OutstandingData::Insert(
233
233
  uint32_t outgoingMessageId,
234
234
  const UserData& data,
235
- uint64_t timeSentMs,
235
+ int64_t timeSentUs,
236
236
  uint16_t maxRetransmissions,
237
- uint64_t expiresAtMs,
237
+ int64_t expiresAtUs,
238
238
  std::optional<uint64_t> lifecycleId)
239
239
  {
240
240
  MS_TRACE();
@@ -248,9 +248,9 @@ namespace RTC
248
248
 
249
249
  const Types::UnwrappedTsn tsn = GetNextTsn();
250
250
  const Item& item = this->outstandingData.emplace_back(
251
- outgoingMessageId, data.Clone(), timeSentMs, maxRetransmissions, expiresAtMs, lifecycleId);
251
+ outgoingMessageId, data.Clone(), timeSentUs, maxRetransmissions, expiresAtUs, lifecycleId);
252
252
 
253
- if (item.HasExpired(timeSentMs))
253
+ if (item.HasExpired(timeSentUs))
254
254
  {
255
255
  // No need to send it, it was expired when it was in the send queue.
256
256
  MS_WARN_TAG(
@@ -390,7 +390,7 @@ namespace RTC
390
390
  return iForwardTsnChunk;
391
391
  }
392
392
 
393
- std::optional<uint64_t> OutstandingData::MeasureRtt(uint64_t nowMs, Types::UnwrappedTsn tsn) const
393
+ std::optional<int64_t> OutstandingData::MeasureRttUs(int64_t nowUs, Types::UnwrappedTsn tsn) const
394
394
  {
395
395
  MS_TRACE();
396
396
 
@@ -406,7 +406,7 @@ namespace RTC
406
406
  // that were retransmitted (and thus for which it is ambiguous
407
407
  // whether the reply was for the first instance of the Chunk or for a
408
408
  // later instance)"
409
- return nowMs - item.GetTimeSentMs();
409
+ return nowUs - item.GetTimeSentUs();
410
410
  }
411
411
  }
412
412
 
@@ -772,9 +772,9 @@ namespace RTC
772
772
  Item& addedItem = this->outstandingData.emplace_back(
773
773
  item.GetOutgoingMessageId(),
774
774
  std::move(messageEnd),
775
- /*timeSentMs*/ 0,
775
+ /*timeSentUs*/ 0,
776
776
  /*maxRetransmissions*/ 0,
777
- /*expiresAtMs*/ Types::ExpiresAtMsInfinite,
777
+ /*expiresAtUs*/ Types::ExpiresAtUsInfinite,
778
778
  /*lifecycleId*/ std::nullopt);
779
779
 
780
780
  // The added chunk shouldn't be included in `this->unackedPacketBytes`,