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
@@ -139,12 +139,12 @@ namespace RTC
139
139
  // Fixed length of our generated State Cookies when authentication is
140
140
  // enabled.
141
141
  static constexpr size_t AuthenticatedStateCookieLength{ StateCookie::MacOffset +
142
- StateCookie::MacLength };
143
- // State Cookie lifespan (Valid.Cookie.Life) in milliseconds. Used to
142
+ StateCookie::MacLength };
143
+ // State Cookie lifespan (Valid.Cookie.Life) in microseconds. Used to
144
144
  // reject stale authenticated cookies.
145
145
  //
146
146
  // @see RFC 9260 section 16.
147
- static constexpr uint64_t ValidCookieLifeMs{ 60000 };
147
+ static constexpr int64_t ValidCookieLifeUs{ 60000 * 1000 };
148
148
 
149
149
  public:
150
150
  /**
@@ -163,7 +163,7 @@ namespace RTC
163
163
  * cookie.
164
164
  * - If `macKey` is not nullptr, an authenticated cookie (with creation
165
165
  * timestamp and MAC) is generated. Otherwise a plain cookie is
166
- * generated and `creationTimestampMs`/`macKey` are ignored.
166
+ * generated and `creationTimestampUs`/`macKey` are ignored.
167
167
  */
168
168
  static StateCookie* Factory(
169
169
  uint8_t* buffer,
@@ -175,9 +175,9 @@ namespace RTC
175
175
  uint32_t remoteAdvertisedReceiverWindowCredit,
176
176
  uint64_t tieTag,
177
177
  const Capabilities& remoteCapabilities,
178
- uint64_t creationTimestampMs = 0,
179
- const uint8_t* macKey = nullptr,
180
- size_t macKeyLength = 0);
178
+ int64_t creationTimestampUs = 0,
179
+ const uint8_t* macKey = nullptr,
180
+ size_t macKeyLength = 0);
181
181
 
182
182
  /**
183
183
  * Serialize a StateCookie (based on given arguments) in the given buffer.
@@ -185,7 +185,7 @@ namespace RTC
185
185
  * @remarks
186
186
  * - If `macKey` is not nullptr, an authenticated cookie (with creation
187
187
  * timestamp and MAC) is generated. Otherwise a plain cookie is
188
- * generated and `creationTimestampMs`/`macKey` are ignored.
188
+ * generated and `creationTimestampUs`/`macKey` are ignored.
189
189
  */
190
190
  static void Write(
191
191
  uint8_t* buffer,
@@ -197,9 +197,9 @@ namespace RTC
197
197
  uint32_t remoteAdvertisedReceiverWindowCredit,
198
198
  uint64_t tieTag,
199
199
  const Capabilities& remoteCapabilities,
200
- uint64_t creationTimestampMs = 0,
201
- const uint8_t* macKey = nullptr,
202
- size_t macKeyLength = 0);
200
+ int64_t creationTimestampUs = 0,
201
+ const uint8_t* macKey = nullptr,
202
+ size_t macKeyLength = 0);
203
203
 
204
204
  /**
205
205
  * Whether the given buffer is a StateCookie generated by mediasoup.
@@ -311,14 +311,14 @@ namespace RTC
311
311
  }
312
312
 
313
313
  /**
314
- * The time (in milliseconds) at which this StateCookie was created.
314
+ * The time (in microseconds) at which this StateCookie was created.
315
315
  *
316
316
  * @remarks
317
317
  * - Only meaningful in authenticated cookies (see `IsAuthenticated()`).
318
318
  */
319
- uint64_t GetCreationTimestampMs() const
319
+ int64_t GetCreationTimestampUs() const
320
320
  {
321
- return Utils::Byte::Get8Bytes(GetBuffer(), StateCookie::TimestampOffset);
321
+ return static_cast<int64_t>(Utils::Byte::Get8Bytes(GetBuffer(), StateCookie::TimestampOffset));
322
322
  }
323
323
 
324
324
  private:
@@ -255,12 +255,12 @@ namespace RTC
255
255
  void HandleReceivedReconfigurationResponseParameter(
256
256
  const ReconfigurationResponseParameter* receivedReconfigurationResponseParameter);
257
257
 
258
- void OnReConfigTimer(uint64_t& baseTimeoutMs, bool& stop);
258
+ void OnReConfigTimer(int64_t& baseTimeoutMs, bool& stop);
259
259
 
260
260
  /* Pure virtual methods inherited from BackoffTimerHandleInterface::Listener. */
261
261
  public:
262
262
  void OnBackoffTimer(
263
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
263
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop) override;
264
264
 
265
265
  private:
266
266
  AssociationListenerDeferrer& associationListenerDeferrer;
@@ -140,7 +140,7 @@ namespace RTC
140
140
  * @remarks
141
141
  * - Implements TransmissionControlBlockContextInterface.
142
142
  */
143
- void ObserveRttMs(uint64_t rttMs) override;
143
+ void ObserveRttUs(int64_t rttUs) override;
144
144
 
145
145
  size_t GetCwnd() const
146
146
  {
@@ -151,14 +151,14 @@ namespace RTC
151
151
  * @remarks
152
152
  * - Implements TransmissionControlBlockContextInterface.
153
153
  */
154
- uint64_t GetCurrentRtoMs() const override
154
+ int64_t GetCurrentRtoUs() const override
155
155
  {
156
- return this->rto.GetRtoMs();
156
+ return this->rto.GetRtoUs();
157
157
  }
158
158
 
159
- uint64_t GetCurrentSrttMs() const
159
+ int64_t GetCurrentSrttUs() const
160
160
  {
161
- return this->rto.GetSrttMs();
161
+ return this->rto.GetSrttUs();
162
162
  }
163
163
 
164
164
  /**
@@ -229,7 +229,7 @@ namespace RTC
229
229
  * May add a FORWARD-TSN or I-FORWARD-TSN chunk to the given packet if it
230
230
  * is needed and allowed (rate-limited).
231
231
  */
232
- void MayAddForwardTsnChunk(Packet* packet, uint64_t nowMs);
232
+ void MayAddForwardTsnChunk(Packet* packet, int64_t nowUs);
233
233
 
234
234
  void MaySendFastRetransmit();
235
235
 
@@ -243,7 +243,7 @@ namespace RTC
243
243
  * - Cannot pass `addCookieAckChunk=true` if `this->remoteStateCookie` is
244
244
  * present (will throw).
245
245
  */
246
- void SendBufferedPackets(uint64_t nowMs, bool addCookieAckChunk = false);
246
+ void SendBufferedPackets(int64_t nowUs, bool addCookieAckChunk = false);
247
247
 
248
248
  /**
249
249
  * @remarks
@@ -286,20 +286,20 @@ namespace RTC
286
286
  }
287
287
 
288
288
  private:
289
- void OnT3RtxTimer(uint64_t& baseTimeoutMs, bool& stop);
289
+ void OnT3RtxTimer(int64_t& baseTimeoutMs, bool& stop);
290
290
 
291
- void OnDelayedAckTimer(uint64_t& baseTimeoutMs, bool& stop);
291
+ void OnDelayedAckTimer(int64_t& baseTimeoutMs, bool& stop);
292
292
 
293
293
  /* Pure virtual methods inherited from RetransmissionQueue::Listener. */
294
294
  public:
295
- void OnRetransmissionQueueNewRttMs(uint64_t newRttMs) override;
295
+ void OnRetransmissionQueueNewRttUs(int64_t newRttUs) override;
296
296
  void OnRetransmissionQueueClearRetransmissionCounter() override;
297
297
  ;
298
298
 
299
299
  /* Pure virtual methods inherited from BackoffTimerHandleInterface::Listener. */
300
300
  public:
301
301
  void OnBackoffTimer(
302
- BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
302
+ BackoffTimerHandleInterface* backoffTimer, int64_t& baseTimeoutMs, bool& stop) override;
303
303
 
304
304
  private:
305
305
  TransmissionControlBlockContextInterface::Listener* listener;
@@ -332,7 +332,7 @@ namespace RTC
332
332
  HeartbeatHandler heartbeatHandler;
333
333
  // Rate limiting of FORWARD-TSN. Next can be sent at or after this
334
334
  // timestamp.
335
- uint64_t limitForwardTsnUntilMs{ 0 };
335
+ int64_t limitForwardTsnUntilUs{ 0 };
336
336
  // Only valid when state is State::COOKIE_ECHOED. In this state, the
337
337
  // association must wait for COOKIE-ACK to continue sending any packets (not
338
338
  // including a COOKIE-ECHO). So if this state cookie is present, the
@@ -49,15 +49,15 @@ namespace RTC
49
49
  virtual uint32_t GetRemoteInitialTsn() const = 0;
50
50
 
51
51
  /**
52
- * To be called when a RTT (ms) has been measured, to update the RTO
52
+ * To be called when a RTT (us) has been measured, to update the RTO
53
53
  * value.
54
54
  */
55
- virtual void ObserveRttMs(uint64_t rttMs) = 0;
55
+ virtual void ObserveRttUs(int64_t rttUs) = 0;
56
56
 
57
57
  /**
58
- * Returns the Retransmission Timeout (RTO) value.
58
+ * Returns the Retransmission Timeout (RTO) value (us).
59
59
  */
60
- virtual uint64_t GetCurrentRtoMs() const = 0;
60
+ virtual int64_t GetCurrentRtoUs() const = 0;
61
61
 
62
62
  /**
63
63
  * Increments the transmission error counter, given a human readable
@@ -134,7 +134,7 @@ namespace RTC
134
134
  {
135
135
  if (!HasVariableLengthValue())
136
136
  {
137
- return 0u;
137
+ return 0;
138
138
  }
139
139
 
140
140
  return GetLengthField() - GetHeaderLength();
@@ -105,9 +105,9 @@ namespace RTC
105
105
  uint32_t remoteAdvertisedReceiverWindowCredit,
106
106
  uint64_t tieTag,
107
107
  const Capabilities& remoteCapabilities,
108
- uint64_t creationTimestampMs = 0,
109
- const uint8_t* macKey = nullptr,
110
- size_t macKeyLength = 0);
108
+ int64_t creationTimestampUs = 0,
109
+ const uint8_t* macKey = nullptr,
110
+ size_t macKeyLength = 0);
111
111
 
112
112
  protected:
113
113
  StateCookieParameter* SoftClone(const uint8_t* buffer) const final;
@@ -175,8 +175,11 @@ namespace RTC
175
175
 
176
176
  /**
177
177
  * Receives SCTP data (hopefully an SCTP packet) from the remote peer.
178
+ *
179
+ * @param receivedAtUs - Time at which the data arrived from the network,
180
+ * taken as close to the socket read as possible.
178
181
  */
179
- virtual void ReceiveSctpData(const uint8_t* data, size_t len) = 0;
182
+ virtual void ReceiveSctpData(const uint8_t* data, size_t len, int64_t receivedAtUs) = 0;
180
183
 
181
184
  /**
182
185
  * Get negotiated max outbound streams. Returns 0 if the association is
@@ -58,7 +58,7 @@ namespace RTC
58
58
  * Smoothed round trip time (in ms), corresponding to `spinfo_srtt`
59
59
  * defined in RFC 6458.
60
60
  */
61
- uint64_t srttMs{ 0 };
61
+ int64_t srttMs{ 0 };
62
62
 
63
63
  /**
64
64
  * Number of data items in the retransmission queue that haven’t been
@@ -109,55 +109,55 @@ namespace RTC
109
109
  * RTO calculation. The default value is an extreme maximum but can be
110
110
  * adapted to better match the environment.
111
111
  */
112
- uint64_t maxRttMs{ 60000 };
112
+ int64_t maxRttMs{ 60000 };
113
113
 
114
114
  /**
115
115
  * Initial RTO value.
116
116
  */
117
- uint64_t initialRtoMs{ 500 };
117
+ int64_t initialRtoMs{ 500 };
118
118
 
119
119
  /**
120
120
  * Minimum RTO value.
121
121
  */
122
- uint64_t minRtoMs{ 400 };
122
+ int64_t minRtoMs{ 400 };
123
123
 
124
124
  /**
125
125
  * Minimum RTO value.
126
126
  */
127
- uint64_t maxRtoMs{ 60000 };
127
+ int64_t maxRtoMs{ 60000 };
128
128
 
129
129
  /**
130
130
  * T1-init timeout (ms).
131
131
  */
132
- uint64_t t1InitTimeoutMs{ 1000 };
132
+ int64_t t1InitTimeoutMs{ 1000 };
133
133
 
134
134
  /**
135
135
  * T1-cookie timeout (ms).
136
136
  */
137
- uint64_t t1CookieTimeoutMs{ 1000 };
137
+ int64_t t1CookieTimeoutMs{ 1000 };
138
138
 
139
139
  /**
140
140
  * T2-shutdown timeout (ms).
141
141
  */
142
- uint64_t t2ShutdownTimeoutMs{ 1000 };
142
+ int64_t t2ShutdownTimeoutMs{ 1000 };
143
143
 
144
144
  /**
145
145
  * Maximum duration of the backoff timeout. If no value is given, no
146
146
  * limit is set.
147
147
  */
148
- std::optional<uint64_t> timerMaxBackoffTimeoutMs{ std::nullopt };
148
+ std::optional<int64_t> timerMaxBackoffTimeoutMs{ std::nullopt };
149
149
 
150
150
  /**
151
151
  * Hearbeat interval (on idle connections only). Set to zero to disable.
152
152
  */
153
- uint64_t heartbeatIntervalMs{ 30000 };
153
+ int64_t heartbeatIntervalMs{ 30000 };
154
154
 
155
155
  /**
156
156
  * The maximum time when a SACK will be sent from the arrival of an
157
157
  * unacknowledged packet. Whatever is smallest of RTO/2 and this will be
158
158
  * used.
159
159
  */
160
- uint64_t delayedAckMaxTimeoutMs{ 200 };
160
+ int64_t delayedAckMaxTimeoutMs{ 200 };
161
161
 
162
162
  /**
163
163
  * The minimum limit for the measured RTT variance.
@@ -174,7 +174,7 @@ namespace RTC
174
174
  * This is defined as "G" in the algorithm for TCP in
175
175
  * https://datatracker.ietf.org/doc/html/rfc6298#section-4.
176
176
  */
177
- uint64_t minRttVarianceMs{ 220 };
177
+ int64_t minRttVarianceMs{ 220 };
178
178
 
179
179
  /**
180
180
  * The initial congestion window size, in number of MTUs.
@@ -302,7 +302,7 @@ namespace RTC
302
302
  * received before the lifetime has expired. This is only available if
303
303
  * the peer supports Partial Reliability Extension (RFC 3758).
304
304
  */
305
- std::optional<uint64_t> lifetimeMs{ std::nullopt };
305
+ std::optional<int64_t> lifetimeMs{ std::nullopt };
306
306
 
307
307
  /**
308
308
  * If set, limits the number of retransmissions. This is only available
@@ -338,7 +338,7 @@ namespace RTC
338
338
 
339
339
  constexpr uint16_t MaxRetransmitsNoLimit{ std::numeric_limits<uint16_t>::max() };
340
340
 
341
- constexpr uint64_t ExpiresAtMsInfinite{ std::numeric_limits<uint64_t>::max() };
341
+ constexpr int64_t ExpiresAtUsInfinite{ std::numeric_limits<int64_t>::max() };
342
342
 
343
343
  /**
344
344
  * Unwrapped Transmission Sequence Numbers (TSN).
@@ -162,9 +162,9 @@ namespace RTC
162
162
  Item(
163
163
  uint32_t outgoingMessageId,
164
164
  UserData data,
165
- uint64_t timeSentMs,
165
+ int64_t timeSentUs,
166
166
  uint16_t maxRetransmissions,
167
- uint64_t expiresAtMs,
167
+ int64_t expiresAtUs,
168
168
  std::optional<uint64_t> lifecycleId);
169
169
 
170
170
  Item(const Item&) = delete;
@@ -177,9 +177,9 @@ namespace RTC
177
177
  return this->outgoingMessageId;
178
178
  }
179
179
 
180
- uint64_t GetTimeSentMs() const
180
+ int64_t GetTimeSentUs() const
181
181
  {
182
- return this->timeSentMs;
182
+ return this->timeSentUs;
183
183
  }
184
184
 
185
185
  const UserData& GetData() const
@@ -251,9 +251,9 @@ namespace RTC
251
251
  * Given the current time, and the current state of this DATA chunk, it
252
252
  * will indicate if it has expired (SCTP Partial Reliability Extension).
253
253
  */
254
- bool HasExpired(uint64_t nowMs) const
254
+ bool HasExpired(int64_t nowUs) const
255
255
  {
256
- return (this->expiresAtMs != Types::ExpiresAtMsInfinite && this->expiresAtMs <= nowMs);
256
+ return (this->expiresAtUs != Types::ExpiresAtUsInfinite && this->expiresAtUs <= nowUs);
257
257
  }
258
258
 
259
259
  std::optional<uint64_t> GetLifecycleId() const
@@ -265,15 +265,14 @@ namespace RTC
265
265
  // The actual data to send/retransmit.
266
266
  const UserData data;
267
267
  // When the packet was sent, and placed in this queue.
268
- const uint64_t timeSentMs;
268
+ const int64_t timeSentUs;
269
269
  // If the message was sent with a maximum number of retransmissions,
270
270
  // this is set to that number. The value zero (0) means that it will
271
271
  // never be retransmitted.
272
272
  const uint16_t maxRetransmissions;
273
- // At this exact millisecond, the item is considered expired. If the
274
- // message is not to be expired, this is set to the infinite future.
275
- // NOTE: If 0 it means infinite time.
276
- const uint64_t expiresAtMs;
273
+ // At this exact microsecond, the item is considered expired. If the
274
+ // message is not to be expired, this is set to `ExpiresAtUsInfinite`.
275
+ const int64_t expiresAtUs;
277
276
  // An optional lifecycle id, which may only be set for the last
278
277
  // fragment.
279
278
  const std::optional<uint64_t> lifecycleId;
@@ -342,10 +341,10 @@ namespace RTC
342
341
  }
343
342
 
344
343
  /**
345
- * Given the current time `nowMs`, expire and abandon outstanding (sent
344
+ * Given the current time `nowUs`, expire and abandon outstanding (sent
346
345
  * at least once) chunks that have a limited lifetime.
347
346
  */
348
- void ExpireOutstandingChunks(uint64_t nowMs);
347
+ void ExpireOutstandingChunks(int64_t nowUs);
349
348
 
350
349
  bool IsEmpty() const
351
350
  {
@@ -382,9 +381,9 @@ namespace RTC
382
381
  std::optional<Types::UnwrappedTsn> Insert(
383
382
  uint32_t outgoingMessageId,
384
383
  const UserData& data,
385
- uint64_t timeSentMs,
384
+ int64_t timeSentUs,
386
385
  uint16_t maxRetransmissions = Types::MaxRetransmitsNoLimit,
387
- uint64_t expiresAtMs = Types::ExpiresAtMsInfinite,
386
+ int64_t expiresAtUs = Types::ExpiresAtUsInfinite,
388
387
  std::optional<uint64_t> lifecycleId = std::nullopt);
389
388
 
390
389
  /**
@@ -408,7 +407,7 @@ namespace RTC
408
407
  * algorithm, so if the chunk has ever been retransmitted, it will return
409
408
  * `std::nullopt`.
410
409
  */
411
- std::optional<uint64_t> MeasureRtt(uint64_t nowMs, Types::UnwrappedTsn tsn) const;
410
+ std::optional<int64_t> MeasureRttUs(int64_t nowUs, Types::UnwrappedTsn tsn) const;
412
411
 
413
412
  /**
414
413
  * Returns true if the next chunk that is not acked by the peer has been
@@ -37,7 +37,7 @@ namespace RTC
37
37
  virtual ~Listener() = default;
38
38
 
39
39
  public:
40
- virtual void OnRetransmissionQueueNewRttMs(uint64_t newRttMs) = 0;
40
+ virtual void OnRetransmissionQueueNewRttUs(int64_t newRttUs) = 0;
41
41
  virtual void OnRetransmissionQueueClearRetransmissionCounter() = 0;
42
42
  };
43
43
 
@@ -53,7 +53,7 @@ namespace RTC
53
53
  * Creates a RetransmissionQueue which will send data using
54
54
  * `localInitialTsn` as the first TSN to use for sent fragments. It will
55
55
  * poll data from `sendQueue`. When SACKs are received, it will estimate
56
- * the RTT and call `listener->OnRetransmissionQueueNewRttMs()`. When an
56
+ * the RTT and call `listener->OnRetransmissionQueueNewRttUs()`. When an
57
57
  * outstanding chunk has been acked, it will call
58
58
  * `listener->OnRetransmissionQueueClearRetransmissionCounter() and will
59
59
  * also use `t3RtxTimer`, which is the SCTP retransmission timer to manage
@@ -77,7 +77,7 @@ namespace RTC
77
77
  * Handles a received SACK. Returns true if the SACK was processed and
78
78
  * false if it was discarded due to received out-of-order and not relevant.
79
79
  */
80
- bool HandleReceivedSackChunk(uint64_t nowMs, const SackChunk* receivedSackChunk);
80
+ bool HandleReceivedSackChunk(int64_t nowUs, const SackChunk* receivedSackChunk);
81
81
 
82
82
  /**
83
83
  * Handles an expired retransmission timer.
@@ -101,8 +101,7 @@ namespace RTC
101
101
  * Note that `ShouldSendForwardTsn()` must be called prior to this method,
102
102
  * to abandon expired chunks, as this method will not expire any chunks.
103
103
  */
104
- std::vector<std::pair<uint32_t /*tsn*/, UserData>> GetChunksToSend(
105
- uint64_t nowMs, size_t maxLength);
104
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> GetChunksToSend(int64_t nowUs, size_t maxLength);
106
105
 
107
106
  #ifdef MS_TEST
108
107
  /**
@@ -182,11 +181,11 @@ namespace RTC
182
181
  }
183
182
 
184
183
  /**
185
- * Given the current time `nowMs`, it will evaluate if there are chunks
184
+ * Given the current time `nowUs`, it will evaluate if there are chunks
186
185
  * that have expired and that need to be discarded. It returns true if a
187
186
  * FORWARD-TSN should be sent.
188
187
  */
189
- bool ShouldSendForwardTsn(uint64_t nowMs);
188
+ bool ShouldSendForwardTsn(int64_t nowUs);
190
189
 
191
190
  /**
192
191
  * Adds a FORWARD-TSN chunk to the given packet and returns it.
@@ -240,7 +239,7 @@ namespace RTC
240
239
  * When a SACK chunk is received, this method will be called which may
241
240
  * call into the `RetransmissionTimeout` to update the RTO.
242
241
  */
243
- void UpdateRttMs(uint64_t nowMs, Types::UnwrappedTsn cumulativeTsnAck);
242
+ void UpdateRttUs(int64_t nowUs, Types::UnwrappedTsn cumulativeTsnAck);
244
243
 
245
244
  /**
246
245
  * If the congestion control is in "fast recovery mode", this may be
@@ -14,7 +14,7 @@ namespace RTC
14
14
  * as delayed ack.
15
15
  *
16
16
  * When a round-trip-time (RTT) is calculated (outside this class), the
17
- * `ObserveRttMs()` method is called, which calculates the retransmission
17
+ * `ObserveRttUs()` method is called, which calculates the retransmission
18
18
  * timeout (RTO) value. The RTO value will become larger if the RTT is high
19
19
  * and/or the RTT values are varying a lot, which is an indicator of a bad
20
20
  * connection.
@@ -30,35 +30,39 @@ namespace RTC
30
30
  void Dump(int indentation = 0) const;
31
31
 
32
32
  /**
33
- * To be called when a RTT (ms) has been measured, to update the RTO
33
+ * To be called when a RTT (us) has been measured, to update the RTO
34
34
  * value.
35
35
  */
36
- void ObserveRttMs(uint64_t rttMs);
36
+ void ObserveRttUs(int64_t rttUs);
37
37
 
38
38
  /**
39
- * Returns the Retransmission Timeout (RTO) value.
39
+ * Returns the Retransmission Timeout (RTO) value (us).
40
40
  */
41
- uint64_t GetRtoMs() const
41
+ int64_t GetRtoUs() const
42
42
  {
43
- return this->rtoMs;
43
+ return static_cast<int64_t>(this->rtoUs);
44
44
  }
45
45
 
46
46
  /**
47
- * Returns the smoothed RTT value (ms)..
47
+ * Returns the smoothed RTT value (us).
48
+ *
49
+ * @remarks
50
+ * - The smoothed RTT is not rounded, so the sub-microsecond part is
51
+ * truncated here.
48
52
  */
49
- uint64_t GetSrttMs() const
53
+ int64_t GetSrttUs() const
50
54
  {
51
- return this->srttMs;
55
+ return static_cast<int64_t>(this->srttUs);
52
56
  }
53
57
 
54
58
  private:
55
- uint64_t minRtoMs;
56
- uint64_t maxRtoMs;
57
- uint64_t maxRttMs;
58
- uint64_t minRttVarianceMs;
59
- double srttMs;
60
- double rtoMs;
61
- double rttVarMs{ 0 };
59
+ int64_t minRtoUs;
60
+ int64_t maxRtoUs;
61
+ int64_t maxRttUs;
62
+ int64_t minRttVarianceUs;
63
+ double srttUs;
64
+ double rtoUs;
65
+ double rttVarUs{ 0 };
62
66
  bool firstMeasurement{ false };
63
67
  };
64
68
  } // namespace SCTP
@@ -47,7 +47,7 @@ namespace RTC
47
47
  {
48
48
  bool isUnordered;
49
49
  uint16_t maxRetransmissions;
50
- uint64_t expiresAtMs;
50
+ int64_t expiresAtUs;
51
51
  std::optional<uint64_t> lifecycleId;
52
52
  };
53
53
 
@@ -128,7 +128,7 @@ namespace RTC
128
128
 
129
129
  // Implementing `StreamScheduler::StreamProducer`.
130
130
 
131
- std::optional<SendQueueInterface::DataToSend> Produce(uint64_t nowMs, size_t maxLength) override;
131
+ std::optional<SendQueueInterface::DataToSend> Produce(int64_t nowUs, size_t maxLength) override;
132
132
 
133
133
  size_t GetBytesToSendInNextMessage() const override;
134
134
 
@@ -291,12 +291,11 @@ namespace RTC
291
291
 
292
292
  /**
293
293
  * Adds the message to be sent using the `sendMessageOptions` provided.
294
- * The current time should be in `nowMs`. Note that it's the responsibility
294
+ * The current time should be in `nowUs`. Note that it's the responsibility
295
295
  * of the caller to ensure that the buffer is not full (by calling
296
296
  * `IsFull()`) before adding messages to it.
297
297
  */
298
- void AddMessage(
299
- uint64_t nowMs, Message message, const SendMessageOptions& sendMessageOptions = {});
298
+ void AddMessage(int64_t nowUs, Message message, const SendMessageOptions& sendMessageOptions = {});
300
299
 
301
300
  uint16_t GetStreamPriority(uint16_t streamId) const;
302
301
 
@@ -309,7 +308,7 @@ namespace RTC
309
308
  this->scheduler.EnableMessageInterleaving(enabled);
310
309
  }
311
310
 
312
- std::optional<SendQueueInterface::DataToSend> Produce(uint64_t nowMs, size_t maxLength) override;
311
+ std::optional<SendQueueInterface::DataToSend> Produce(int64_t nowUs, size_t maxLength) override;
313
312
 
314
313
  bool Discard(uint16_t streamId, uint32_t outgoingMessageId) override;
315
314
 
@@ -38,7 +38,7 @@ namespace RTC
38
38
  /**
39
39
  * Time when it expires.
40
40
  */
41
- uint64_t expiresAtMs{ Types::ExpiresAtMsInfinite };
41
+ int64_t expiresAtUs{ Types::ExpiresAtUsInfinite };
42
42
 
43
43
  /**
44
44
  * Lifecycle. Set for the last fragment and `std::nullopt` for all
@@ -69,7 +69,7 @@ namespace RTC
69
69
  * model message prioritization, which is important for any advanced
70
70
  * stream scheduler, is further clarified.
71
71
  */
72
- virtual std::optional<DataToSend> Produce(uint64_t nowMs, size_t maxLength) = 0;
72
+ virtual std::optional<DataToSend> Produce(int64_t nowUs, size_t maxLength) = 0;
73
73
 
74
74
  /**
75
75
  * Discards a partially sent message identified by the parameters `streamId`
@@ -49,13 +49,13 @@ namespace RTC
49
49
  public:
50
50
  /**
51
51
  * Produces a fragment of data to send. The current wall time is specified
52
- * as `nowMs` and should be used to skip chunks with expired limited
52
+ * as `nowUs` and should be used to skip chunks with expired limited
53
53
  * lifetime. The parameter `maxLength` specifies the maximum amount of
54
54
  * actual payload that may be returned. If these constraints prevents the
55
55
  * stream from sending some data, `std::nullopt` should be returned.
56
56
  */
57
57
  virtual std::optional<SendQueueInterface::DataToSend> Produce(
58
- uint64_t nowMs, size_t maxLength) = 0;
58
+ int64_t nowUs, size_t maxLength) = 0;
59
59
 
60
60
  /**
61
61
  * Returns the number of payload bytes that is scheduled to be sent in the
@@ -123,7 +123,7 @@ namespace RTC
123
123
  * Produces a message from this stream. This will only be called on
124
124
  * streams that have data.
125
125
  */
126
- std::optional<SendQueueInterface::DataToSend> Produce(uint64_t nowMs, size_t maxLength);
126
+ std::optional<SendQueueInterface::DataToSend> Produce(int64_t nowUs, size_t maxLength);
127
127
 
128
128
  void MakeActive(size_t bytesToSendNext);
129
129
 
@@ -203,12 +203,12 @@ namespace RTC
203
203
 
204
204
  /**
205
205
  * Produces a fragment of data to send. The current wall time is specified
206
- * as `nowMs` and will be used to skip chunks with expired limited
206
+ * as `nowUs` and will be used to skip chunks with expired limited
207
207
  * lifetime. The parameter `maxLength` specifies the maximum amount of
208
208
  * actual payload that may be returned. If no data can be produced,
209
209
  * `std::nullopt` is returned.
210
210
  */
211
- std::optional<SendQueueInterface::DataToSend> Produce(uint64_t nowMs, size_t maxLength);
211
+ std::optional<SendQueueInterface::DataToSend> Produce(int64_t nowUs, size_t maxLength);
212
212
 
213
213
  std::set<uint16_t> GetActiveStreamsForTesting() const;
214
214
 
@@ -16,10 +16,10 @@ namespace RTC
16
16
  flatbuffers::FlatBufferBuilder& builder) const;
17
17
 
18
18
  public:
19
- uint16_t streamId{ 0u };
19
+ uint16_t streamId{ 0 };
20
20
  bool ordered{ true };
21
- uint16_t maxPacketLifeTime{ 0u };
22
- uint16_t maxRetransmits{ 0u };
21
+ uint16_t maxPacketLifeTime{ 0 };
22
+ uint16_t maxRetransmits{ 0 };
23
23
  };
24
24
  } // namespace RTC
25
25