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
@@ -1059,16 +1059,16 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1059
1059
  /*paddingLength*/ 0);
1060
1060
 
1061
1061
  REQUIRE(packet->IsPaddedTo4Bytes() == true);
1062
- REQUIRE(packet->GetCaptureMs() == std::nullopt);
1062
+ REQUIRE(packet->GetCaptureAtUs() == std::nullopt);
1063
1063
 
1064
1064
  packet->SetPayloadType(100);
1065
1065
  packet->SetMarker(true);
1066
1066
  packet->SetSequenceNumber(12345);
1067
1067
  packet->SetTimestamp(987654321);
1068
1068
  packet->SetSsrc(1234567890);
1069
- packet->SetCaptureMs(99998888);
1069
+ packet->SetCaptureAtUs(99998888);
1070
1070
 
1071
- REQUIRE(packet->GetCaptureMs() == 99998888);
1071
+ REQUIRE(packet->GetCaptureAtUs() == 99998888);
1072
1072
 
1073
1073
  std::vector<RTC::RTP::Packet::Extension> extensions;
1074
1074
 
@@ -1208,7 +1208,7 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1208
1208
  REQUIRE(extensionLen == 3);
1209
1209
 
1210
1210
  REQUIRE(packet->IsPaddedTo4Bytes() == true);
1211
- REQUIRE(packet->GetCaptureMs() == 99998888);
1211
+ REQUIRE(packet->GetCaptureAtUs() == 99998888);
1212
1212
 
1213
1213
  /* Clone it. */
1214
1214
 
@@ -1257,7 +1257,7 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1257
1257
  REQUIRE(extensionLen == 3);
1258
1258
 
1259
1259
  REQUIRE(packet->IsPaddedTo4Bytes() == true);
1260
- REQUIRE(packet->GetCaptureMs() == 99998888);
1260
+ REQUIRE(packet->GetCaptureAtUs() == 99998888);
1261
1261
 
1262
1262
  /* Set payload. */
1263
1263
 
@@ -1547,12 +1547,12 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1547
1547
  REQUIRE(packet->ReadTransportWideCc01(readWideSeqNumber));
1548
1548
  REQUIRE(readWideSeqNumber == wideSeqNumber);
1549
1549
 
1550
- std::string newMid{ "mid-®2" };
1551
- uint64_t newAbsSendtimeMs{ 999999 };
1552
- uint16_t newWideSeqNumber{ 5556 };
1550
+ const std::string newMid{ "mid-®2" };
1551
+ const int64_t newAbsSendtimeUs{ 999999250 };
1552
+ const uint16_t newWideSeqNumber{ 5556 };
1553
1553
 
1554
1554
  REQUIRE(packet->UpdateMid(newMid));
1555
- REQUIRE(packet->UpdateAbsSendTime(newAbsSendtimeMs));
1555
+ REQUIRE(packet->UpdateAbsSendTime(newAbsSendtimeUs));
1556
1556
  REQUIRE(packet->UpdateTransportWideCc01(newWideSeqNumber));
1557
1557
 
1558
1558
  REQUIRE(packet->ReadMid(readMid));
@@ -1560,7 +1560,7 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1560
1560
  REQUIRE(packet->ReadRid(readRid));
1561
1561
  REQUIRE(readRid == rid);
1562
1562
  REQUIRE(packet->ReadAbsSendTime(readAbsSendtime));
1563
- REQUIRE(readAbsSendtime == Utils::Time::TimeMsToAbsSendTime(newAbsSendtimeMs));
1563
+ REQUIRE(readAbsSendtime == Utils::Time::TimeUsToAbsSendTime(newAbsSendtimeUs));
1564
1564
  REQUIRE(packet->ReadTransportWideCc01(readWideSeqNumber));
1565
1565
  REQUIRE(readWideSeqNumber == newWideSeqNumber);
1566
1566
 
@@ -1587,7 +1587,7 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1587
1587
  REQUIRE(packet2->ReadRid(readRid));
1588
1588
  REQUIRE(readRid == rid);
1589
1589
  REQUIRE(packet2->ReadAbsSendTime(readAbsSendtime));
1590
- REQUIRE(readAbsSendtime == Utils::Time::TimeMsToAbsSendTime(newAbsSendtimeMs));
1590
+ REQUIRE(readAbsSendtime == Utils::Time::TimeUsToAbsSendTime(newAbsSendtimeUs));
1591
1591
  REQUIRE(packet2->ReadTransportWideCc01(readWideSeqNumber));
1592
1592
  REQUIRE(readWideSeqNumber == newWideSeqNumber);
1593
1593
  }
@@ -20,7 +20,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
20
20
  };
21
21
 
22
22
  public:
23
- RtpMyRetransmissionBuffer(uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate)
23
+ RtpMyRetransmissionBuffer(uint16_t maxItems, int64_t maxRetransmissionDelayMs, uint32_t clockRate)
24
24
  : RTC::RTP::RetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate)
25
25
  {
26
26
  }
@@ -51,7 +51,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
51
51
  {
52
52
  REQUIRE(verificationBuffer.size() == this->buffer.size());
53
53
 
54
- for (size_t idx{ 0u }; idx < verificationBuffer.size(); ++idx)
54
+ for (size_t idx{ 0 }; idx < verificationBuffer.size(); ++idx)
55
55
  {
56
56
  auto& verificationItem = verificationBuffer.at(idx);
57
57
  auto* item = this->buffer.at(idx);
@@ -70,7 +70,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
70
70
  SECTION("proper packets received in order")
71
71
  {
72
72
  const uint16_t maxItems{ 4 };
73
- const uint32_t maxRetransmissionDelayMs{ 2000u };
73
+ const int64_t maxRetransmissionDelayMs{ 2000 };
74
74
  const uint32_t clockRate{ 90000 };
75
75
 
76
76
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -95,7 +95,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
95
95
  SECTION("proper packets received out of order")
96
96
  {
97
97
  const uint16_t maxItems{ 4 };
98
- const uint32_t maxRetransmissionDelayMs{ 2000u };
98
+ const int64_t maxRetransmissionDelayMs{ 2000 };
99
99
  const uint32_t clockRate{ 90000 };
100
100
 
101
101
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -120,7 +120,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
120
120
  SECTION("packet with too new sequence number produces buffer emptying")
121
121
  {
122
122
  const uint16_t maxItems{ 4 };
123
- const uint32_t maxRetransmissionDelayMs{ 2000u };
123
+ const int64_t maxRetransmissionDelayMs{ 2000 };
124
124
  const uint32_t clockRate{ 90000 };
125
125
 
126
126
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -142,7 +142,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
142
142
  SECTION("blank slots are properly created")
143
143
  {
144
144
  const uint16_t maxItems{ 10 };
145
- const uint32_t maxRetransmissionDelayMs{ 2000u };
145
+ const int64_t maxRetransmissionDelayMs{ 2000 };
146
146
  const uint32_t clockRate{ 90000 };
147
147
 
148
148
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -180,7 +180,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
180
180
  SECTION("packet with too old sequence number is discarded")
181
181
  {
182
182
  const uint16_t maxItems{ 4 };
183
- const uint32_t maxRetransmissionDelayMs{ 2000u };
183
+ const int64_t maxRetransmissionDelayMs{ 2000 };
184
184
  const uint32_t clockRate{ 90000 };
185
185
 
186
186
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -205,7 +205,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
205
205
  SECTION("packet with too old timestamp is discarded")
206
206
  {
207
207
  const uint16_t maxItems{ 4 };
208
- const uint32_t maxRetransmissionDelayMs{ 2000u };
208
+ const int64_t maxRetransmissionDelayMs{ 2000 };
209
209
  const uint32_t clockRate{ 90000 };
210
210
 
211
211
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -232,7 +232,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
232
232
  SECTION("packet with very newest timestamp is inserted as newest item despite its seq is old")
233
233
  {
234
234
  const uint16_t maxItems{ 4 };
235
- const uint32_t maxRetransmissionDelayMs{ 2000u };
235
+ const int64_t maxRetransmissionDelayMs{ 2000 };
236
236
  const uint32_t clockRate{ 90000 };
237
237
 
238
238
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -256,7 +256,7 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
256
256
  "packet with lower seq than newest packet in the buffer and higher timestamp forces buffer emptying")
257
257
  {
258
258
  const uint16_t maxItems{ 4 };
259
- const uint32_t maxRetransmissionDelayMs{ 2000u };
259
+ const int64_t maxRetransmissionDelayMs{ 2000 };
260
260
  const uint32_t clockRate{ 90000 };
261
261
 
262
262
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -276,8 +276,8 @@ SCENARIO("RTP RetransmissionBuffer", "[rtp][rtx]")
276
276
 
277
277
  SECTION("fuzzer generated packets")
278
278
  {
279
- const uint16_t maxItems{ 2500u };
280
- const uint32_t maxRetransmissionDelayMs{ 2000u };
279
+ const uint16_t maxItems{ 2500 };
280
+ const int64_t maxRetransmissionDelayMs{ 2000 };
281
281
  const uint32_t clockRate{ 90000 };
282
282
 
283
283
  RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
@@ -1,4 +1,6 @@
1
1
  #include "common.hpp"
2
+ #include "RTC/RTCP/FeedbackPs.hpp"
3
+ #include "RTC/RTCP/FeedbackRtpNack.hpp"
2
4
  #include "RTC/RTP/Packet.hpp"
3
5
  #include "RTC/RTP/RtpStream.hpp"
4
6
  #include "RTC/RTP/RtpStreamRecv.hpp"
@@ -111,6 +113,11 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
111
113
  return 0;
112
114
  }
113
115
 
116
+ void OnRtpStreamSpatialLayerActivityChanged(
117
+ RTC::RTP::RtpStreamRecv* /*rtpStream*/, uint8_t /*spatialLayer*/, bool /*isActive*/) override
118
+ {
119
+ }
120
+
114
121
  public:
115
122
  bool shouldTriggerNack = false;
116
123
  bool shouldTriggerPLI = false;
@@ -118,10 +125,10 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
118
125
  std::vector<uint16_t> nackedSeqNumbers;
119
126
  };
120
127
 
121
- mocks::MockShared shared(/*getTimeMs*/
122
- []()
128
+ mocks::MockShared shared(/*getTimeUs*/
129
+ []() -> int64_t
123
130
  {
124
- return 1000;
131
+ return 1000 * 1000;
125
132
  });
126
133
 
127
134
  // clang-format off
@@ -158,25 +165,25 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
158
165
  std::addressof(listener), std::addressof(shared), params, SendNackDelay, UseRtpInactivityCheck);
159
166
 
160
167
  packet->SetSequenceNumber(1);
161
- rtpStream.ReceivePacket(packet.get());
168
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
162
169
 
163
170
  packet->SetSequenceNumber(3);
164
171
  listener.shouldTriggerNack = true;
165
172
  listener.shouldTriggerPLI = false;
166
173
  listener.shouldTriggerFIR = false;
167
- rtpStream.ReceivePacket(packet.get());
174
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
168
175
 
169
176
  REQUIRE(listener.nackedSeqNumbers.size() == 1);
170
177
  REQUIRE(listener.nackedSeqNumbers[0] == 2);
171
178
  listener.nackedSeqNumbers.clear();
172
179
 
173
180
  packet->SetSequenceNumber(2);
174
- rtpStream.ReceivePacket(packet.get());
181
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
175
182
 
176
183
  REQUIRE(listener.nackedSeqNumbers.empty());
177
184
 
178
185
  packet->SetSequenceNumber(4);
179
- rtpStream.ReceivePacket(packet.get());
186
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
180
187
 
181
188
  REQUIRE(listener.nackedSeqNumbers.empty());
182
189
  }
@@ -188,19 +195,19 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
188
195
  std::addressof(listener), std::addressof(shared), params, SendNackDelay, UseRtpInactivityCheck);
189
196
 
190
197
  packet->SetSequenceNumber(1);
191
- rtpStream.ReceivePacket(packet.get());
198
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
192
199
 
193
200
  packet->SetSequenceNumber(2);
194
- rtpStream.ReceivePacket(packet.get());
201
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
195
202
 
196
203
  packet->SetSequenceNumber(3);
197
- rtpStream.ReceivePacket(packet.get());
204
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
198
205
 
199
206
  packet->SetSequenceNumber(4);
200
- rtpStream.ReceivePacket(packet.get());
207
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
201
208
 
202
209
  packet->SetSequenceNumber(5);
203
- rtpStream.ReceivePacket(packet.get());
210
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
204
211
 
205
212
  // Sequence number 6 arrives via RTX before the original RTP packet.
206
213
 
@@ -222,13 +229,13 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
222
229
  std::addressof(listener), std::addressof(shared), params, SendNackDelay, UseRtpInactivityCheck);
223
230
 
224
231
  packet->SetSequenceNumber(0xfffe);
225
- rtpStream.ReceivePacket(packet.get());
232
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
226
233
 
227
234
  packet->SetSequenceNumber(1);
228
235
  listener.shouldTriggerNack = true;
229
236
  listener.shouldTriggerPLI = false;
230
237
  listener.shouldTriggerFIR = false;
231
- rtpStream.ReceivePacket(packet.get());
238
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
232
239
 
233
240
  REQUIRE(listener.nackedSeqNumbers.size() == 2);
234
241
  REQUIRE(listener.nackedSeqNumbers[0] == 0xffff);
@@ -243,13 +250,13 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
243
250
  std::addressof(listener), std::addressof(shared), params, SendNackDelay, UseRtpInactivityCheck);
244
251
 
245
252
  packet->SetSequenceNumber(1);
246
- rtpStream.ReceivePacket(packet.get());
253
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
247
254
 
248
255
  // Seq different is bigger than MaxNackPackets in NackGenerator, so it
249
256
  // triggers a key frame.
250
257
  packet->SetSequenceNumber(1003);
251
258
  listener.shouldTriggerPLI = true;
252
259
  listener.shouldTriggerFIR = false;
253
- rtpStream.ReceivePacket(packet.get());
260
+ rtpStream.ReceivePacket(packet.get(), shared.GetTimeUs());
254
261
  }
255
262
  }
@@ -107,10 +107,10 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
107
107
  packet->SetPayloadDescriptorHandler(payloadDescriptorHandler);
108
108
  };
109
109
 
110
- mocks::MockShared shared(/*getTimeMs*/
111
- []()
110
+ mocks::MockShared shared(/*getTimeUs*/
111
+ []() -> int64_t
112
112
  {
113
- return 1000;
113
+ return 1000 * 1000;
114
114
  });
115
115
 
116
116
  // clang-format off
@@ -1129,7 +1129,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1129
1129
  SECTION("Sender Report RTP timestamp is based on the capture instant when known")
1130
1130
  {
1131
1131
  // Instant reported by the mocked clock, and hence the one at which packets are seen.
1132
- constexpr uint64_t PacketMs{ 1000 };
1132
+ constexpr int64_t PacketAtUs{ 1000 * 1000 };
1133
1133
  constexpr uint32_t PacketTs{ 1533790901 };
1134
1134
 
1135
1135
  TestRtpStreamListener testRtpStreamListener;
@@ -1155,7 +1155,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1155
1155
  packet.get());
1156
1156
 
1157
1157
  const std::unique_ptr<RTC::RTCP::SenderReport> report(
1158
- stream.GetRtcpSenderReport(PacketMs + 1000));
1158
+ stream.GetRtcpSenderReport(PacketAtUs + 1000000));
1159
1159
 
1160
1160
  REQUIRE(report);
1161
1161
  REQUIRE(report->GetRtpTs() == PacketTs + params.clockRate);
@@ -1167,7 +1167,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1167
1167
  std::addressof(testRtpStreamListener), std::addressof(shared), params, mid);
1168
1168
  auto packet(createRtpPacket(rtpBuffer1, sizeof(rtpBuffer1), 21006, PacketTs));
1169
1169
 
1170
- packet->SetCaptureMs(PacketMs - 500);
1170
+ packet->SetCaptureAtUs(PacketAtUs - 500000);
1171
1171
 
1172
1172
  sendRtpPacket(
1173
1173
  {
@@ -1176,7 +1176,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1176
1176
  packet.get());
1177
1177
 
1178
1178
  const std::unique_ptr<RTC::RTCP::SenderReport> report(
1179
- stream.GetRtcpSenderReport(PacketMs + 1000));
1179
+ stream.GetRtcpSenderReport(PacketAtUs + 1000000));
1180
1180
 
1181
1181
  REQUIRE(report);
1182
1182
  REQUIRE(report->GetRtpTs() == PacketTs + ((1500 * params.clockRate) / 1000));
@@ -1189,7 +1189,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1189
1189
  std::addressof(testRtpStreamListener), std::addressof(shared), params, mid);
1190
1190
  auto packet(createRtpPacket(rtpBuffer1, sizeof(rtpBuffer1), 21006, PacketTs));
1191
1191
 
1192
- packet->SetCaptureMs(PacketMs + 3000);
1192
+ packet->SetCaptureAtUs(PacketAtUs + 3000000);
1193
1193
 
1194
1194
  sendRtpPacket(
1195
1195
  {
@@ -1198,7 +1198,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1198
1198
  packet.get());
1199
1199
 
1200
1200
  const std::unique_ptr<RTC::RTCP::SenderReport> report(
1201
- stream.GetRtcpSenderReport(PacketMs + 1000));
1201
+ stream.GetRtcpSenderReport(PacketAtUs + 1000000));
1202
1202
 
1203
1203
  REQUIRE(report);
1204
1204
  REQUIRE(report->GetRtpTs() == PacketTs);
@@ -1208,7 +1208,7 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1208
1208
  SECTION("no Sender Report is generated once the stream has stopped sending")
1209
1209
  {
1210
1210
  // Instant reported by the mocked clock, and hence the one at which packets are seen.
1211
- constexpr uint64_t PacketMs{ 1000 };
1211
+ constexpr int64_t PacketAtUs{ 1000 * 1000 };
1212
1212
  constexpr uint32_t PacketTs{ 1533790901 };
1213
1213
 
1214
1214
  TestRtpStreamListener testRtpStreamListener;
@@ -1232,14 +1232,14 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1232
1232
  packet.get());
1233
1233
 
1234
1234
  // Right at the limit the Sender Report is still generated.
1235
- const std::unique_ptr<RTC::RTCP::SenderReport> report(
1236
- stream.GetRtcpSenderReport(PacketMs + RTC::RTP::RtpStreamSend::MaxSenderReportReferenceAgeMs));
1235
+ const std::unique_ptr<RTC::RTCP::SenderReport> report(stream.GetRtcpSenderReport(
1236
+ PacketAtUs + (RTC::RTP::RtpStreamSend::MaxSenderReportReferenceAgeMs * 1000)));
1237
1237
 
1238
1238
  REQUIRE(report);
1239
1239
 
1240
1240
  // Past the limit it is not.
1241
1241
  const std::unique_ptr<RTC::RTCP::SenderReport> staleReport(stream.GetRtcpSenderReport(
1242
- PacketMs + RTC::RTP::RtpStreamSend::MaxSenderReportReferenceAgeMs + 1));
1242
+ PacketAtUs + ((RTC::RTP::RtpStreamSend::MaxSenderReportReferenceAgeMs + 1) * 1000)));
1243
1243
 
1244
1244
  REQUIRE_FALSE(staleReport);
1245
1245
  }
@@ -33,8 +33,8 @@
33
33
 
34
34
  namespace
35
35
  {
36
- // Initial value of the simulated clock (ms).
37
- constexpr uint64_t InitialNowMs{ 1000000 };
36
+ // Initial value of the simulated clock (us).
37
+ constexpr int64_t InitialNowUs{ 1000000 * 1000 };
38
38
 
39
39
  // All backoff timer labels an SCTP association may create. Used by `runTimers()`
40
40
  // to fire whichever timers have expired after advancing time.
@@ -78,10 +78,10 @@ namespace
78
78
  bool mayConnectOnReceivedSctpData = false)
79
79
  // NOTE: The order in which these members are initialized is **critical**.
80
80
  : sctpOptions(sctpOptions),
81
- shared(/*getTimeMs*/
82
- [this]()
83
- {
84
- return this->nowMs;
81
+ shared(/*getTimeUs*/
82
+ [this]() -> int64_t
83
+ {
84
+ return this->nowUs;
85
85
  }),
86
86
  association(
87
87
  this->sctpOptions,
@@ -94,14 +94,18 @@ namespace
94
94
 
95
95
  /**
96
96
  * Advances the simulated clock of this association by `incrementMs`.
97
+ *
98
+ * @remarks
99
+ * - The increment is given in milliseconds since it comes from the SCTP
100
+ * options and the timers, which work in milliseconds.
97
101
  */
98
- void AdvanceTimeMs(uint64_t incrementMs)
102
+ void AdvanceTimeMs(int64_t incrementMs)
99
103
  {
100
- this->nowMs += incrementMs;
104
+ this->nowUs += incrementMs * 1000;
101
105
  }
102
106
 
103
107
  public:
104
- uint64_t nowMs{ InitialNowMs };
108
+ int64_t nowUs{ InitialNowUs };
105
109
  RTC::SCTP::SctpOptions sctpOptions;
106
110
  mocks::RTC::SCTP::MockAssociationListener listener;
107
111
  mocks::MockShared shared;
@@ -148,7 +152,7 @@ namespace
148
152
 
149
153
  REQUIRE(!buffer.empty());
150
154
 
151
- to.association.ReceiveSctpData(buffer.data(), buffer.size());
155
+ to.association.ReceiveSctpData(buffer.data(), buffer.size(), to.shared.GetTimeUs());
152
156
  }
153
157
 
154
158
  /**
@@ -168,7 +172,7 @@ namespace
168
172
  if (!bufferFromA.empty())
169
173
  {
170
174
  deliveredPacket = true;
171
- z.association.ReceiveSctpData(bufferFromA.data(), bufferFromA.size());
175
+ z.association.ReceiveSctpData(bufferFromA.data(), bufferFromA.size(), z.shared.GetTimeUs());
172
176
  }
173
177
 
174
178
  const auto bufferFromZ = z.listener.ConsumeFirstSentPacket();
@@ -176,7 +180,7 @@ namespace
176
180
  if (!bufferFromZ.empty())
177
181
  {
178
182
  deliveredPacket = true;
179
- a.association.ReceiveSctpData(bufferFromZ.data(), bufferFromZ.size());
183
+ a.association.ReceiveSctpData(bufferFromZ.data(), bufferFromZ.size(), a.shared.GetTimeUs());
180
184
  }
181
185
  } while (deliveredPacket);
182
186
  }
@@ -212,7 +216,7 @@ namespace
212
216
  * Advances the simulated clock of both associations by `durationMs` and fires
213
217
  * any timer that has expired.
214
218
  */
215
- void advanceTimeMs(AssociationUnderTest& a, AssociationUnderTest& z, uint64_t durationMs)
219
+ void advanceTimeMs(AssociationUnderTest& a, AssociationUnderTest& z, int64_t durationMs)
216
220
  {
217
221
  a.AdvanceTimeMs(durationMs);
218
222
  z.AdvanceTimeMs(durationMs);
@@ -259,7 +263,7 @@ namespace
259
263
  const uint32_t verificationTag = parsePacket(buffer)->GetVerificationTag();
260
264
 
261
265
  // Deliver the COOKIE-ACK so the connection is fully established on A.
262
- a.association.ReceiveSctpData(buffer.data(), buffer.size());
266
+ a.association.ReceiveSctpData(buffer.data(), buffer.size(), a.shared.GetTimeUs());
263
267
 
264
268
  REQUIRE(a.association.GetAssociationState() == RTC::SCTP::Types::AssociationState::CONNECTED);
265
269
  REQUIRE(z.association.GetAssociationState() == RTC::SCTP::Types::AssociationState::CONNECTED);
@@ -291,7 +295,8 @@ namespace
291
295
  {
292
296
  packet->WriteCRC32cChecksum();
293
297
 
294
- target.association.ReceiveSctpData(packet->GetBuffer(), packet->GetLength());
298
+ target.association.ReceiveSctpData(
299
+ packet->GetBuffer(), packet->GetLength(), target.shared.GetTimeUs());
295
300
  }
296
301
 
297
302
  /**
@@ -836,7 +841,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
836
841
  REQUIRE(packetHasSingleChunkOfType<RTC::SCTP::HeartbeatRequestChunk>(buffer) == true);
837
842
 
838
843
  // Feed it to Z and expect a HEARTBEAT-ACK that is propagated back to A.
839
- z.association.ReceiveSctpData(buffer.data(), buffer.size());
844
+ z.association.ReceiveSctpData(buffer.data(), buffer.size(), z.shared.GetTimeUs());
840
845
  deliverFirstSentPacket(z, a);
841
846
  }
842
847
 
@@ -1282,7 +1287,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1282
1287
  REQUIRE(packetHasSingleChunkOfType<RTC::SCTP::HeartbeatRequestChunk>(bufferA) == true);
1283
1288
 
1284
1289
  // Z receives the heartbeat and sends an ACK that is propagated back to A.
1285
- z.association.ReceiveSctpData(bufferA.data(), bufferA.size());
1290
+ z.association.ReceiveSctpData(bufferA.data(), bufferA.size(), z.shared.GetTimeUs());
1286
1291
  deliverFirstSentPacket(z, a);
1287
1292
 
1288
1293
  // A little while later, Z should send heartbeats to A.
@@ -1293,7 +1298,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1293
1298
  REQUIRE(packetHasSingleChunkOfType<RTC::SCTP::HeartbeatRequestChunk>(bufferZ) == true);
1294
1299
 
1295
1300
  // A receives the heartbeat and sends an ACK that is propagated back to Z.
1296
- a.association.ReceiveSctpData(bufferZ.data(), bufferZ.size());
1301
+ a.association.ReceiveSctpData(bufferZ.data(), bufferZ.size(), a.shared.GetTimeUs());
1297
1302
  deliverFirstSentPacket(a, z);
1298
1303
  }
1299
1304
 
@@ -1313,7 +1318,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1313
1318
 
1314
1319
  const auto maxRetransmissions = a.sctpOptions.maxRetransmissions.value();
1315
1320
 
1316
- uint64_t timeToNextHeartbeatMs = a.sctpOptions.heartbeatIntervalMs;
1321
+ int64_t timeToNextHeartbeatMs = a.sctpOptions.heartbeatIntervalMs;
1317
1322
 
1318
1323
  for (size_t i = 0; i < maxRetransmissions; ++i)
1319
1324
  {
@@ -1362,7 +1367,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1362
1367
 
1363
1368
  const auto maxRetransmissions = a.sctpOptions.maxRetransmissions.value();
1364
1369
 
1365
- uint64_t timeToNextHeartbeatMs = a.sctpOptions.heartbeatIntervalMs;
1370
+ int64_t timeToNextHeartbeatMs = a.sctpOptions.heartbeatIntervalMs;
1366
1371
 
1367
1372
  for (size_t i = 0; i < maxRetransmissions; ++i)
1368
1373
  {
@@ -1384,7 +1389,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1384
1389
 
1385
1390
  REQUIRE(packetHasSingleChunkOfType<RTC::SCTP::HeartbeatRequestChunk>(buffer) == true);
1386
1391
 
1387
- z.association.ReceiveSctpData(buffer.data(), buffer.size());
1392
+ z.association.ReceiveSctpData(buffer.data(), buffer.size(), z.shared.GetTimeUs());
1388
1393
  // A reads the HEARTBEAT-ACK, which clears the error counter.
1389
1394
  deliverFirstSentPacket(z, a);
1390
1395
 
@@ -1890,7 +1895,7 @@ SCENARIO("SCTP Association", "[sctp][association]")
1890
1895
 
1891
1896
  // Make the cookie stale on Z's side by advancing its clock beyond the cookie
1892
1897
  // lifespan before the COOKIE-ECHO is delivered.
1893
- z.AdvanceTimeMs(RTC::SCTP::StateCookie::ValidCookieLifeMs + 1000);
1898
+ z.AdvanceTimeMs((RTC::SCTP::StateCookie::ValidCookieLifeUs / 1000) + 1000);
1894
1899
 
1895
1900
  // Z reads the now stale COOKIE-ECHO.
1896
1901
  deliverFirstSentPacket(a, z);
@@ -18,13 +18,13 @@
18
18
 
19
19
  SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
20
20
  {
21
- constexpr uint64_t InitialNowMs{ 1000000 };
22
- constexpr uint64_t HeartbeatIntervalMs{ 30000 };
21
+ constexpr int64_t InitialNowUs{ 1000000 * 1000 };
22
+ constexpr int64_t HeartbeatIntervalMs{ 30000 };
23
23
 
24
24
  class TestHeartbeatHandler
25
25
  {
26
26
  public:
27
- explicit TestHeartbeatHandler(uint64_t heartbeatIntervalMs)
27
+ explicit TestHeartbeatHandler(int64_t heartbeatIntervalMs)
28
28
  // NOTE: The order in which these members are initialized is **critical**.
29
29
  : sctpOptions(
30
30
  RTC::SCTP::SctpOptions{
@@ -33,10 +33,10 @@ SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
33
33
  .zeroChecksumAlternateErrorDetectionMethod =
34
34
  RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE }),
35
35
  tcbContext(this->associationListener, this->sctpOptions),
36
- shared(/*getTimeMs*/
37
- [this]()
38
- {
39
- return this->nowMs;
36
+ shared(/*getTimeUs*/
37
+ [this]() -> int64_t
38
+ {
39
+ return this->nowUs;
40
40
  }),
41
41
  heartbeatHandler(
42
42
  this->associationListenerDeferrer,
@@ -49,13 +49,18 @@ SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
49
49
  };
50
50
 
51
51
  public:
52
+ /**
53
+ * @remarks
54
+ * - The increment is given in milliseconds since it comes from the SCTP
55
+ * options and the timers, which work in milliseconds.
56
+ */
52
57
  void AdvanceTimeMs(int64_t incrementMs)
53
58
  {
54
- this->nowMs += incrementMs;
59
+ this->nowUs += incrementMs * 1000;
55
60
  }
56
61
 
57
62
  private:
58
- uint64_t nowMs{ InitialNowMs };
63
+ int64_t nowUs{ InitialNowUs };
59
64
 
60
65
  // NOTE: Public members for testing.
61
66
  public:
@@ -185,9 +190,10 @@ SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
185
190
  receivedHeartbeatInfoParameter->Consolidate();
186
191
 
187
192
  // Respond a while later.
188
- const uint64_t rttMs{ 313 };
193
+ const int64_t rttMs{ 313 };
189
194
 
190
- test.tcbContext.ExpectObserveRttMsCalledTimes(1);
195
+ test.tcbContext.ExpectObserveRttUsCalledTimes(1).ExpectObserveRttUsCalledWith(
196
+ static_cast<int64_t>(rttMs * 1000));
191
197
 
192
198
  test.AdvanceTimeMs(rttMs);
193
199
  test.heartbeatHandler.HandleReceivedHeartbeatAckChunk(receivedHeartbeatAckChunk.get());
@@ -237,7 +243,7 @@ SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
237
243
  sentHeartbeatInfoParameter->GetInfo(), sentHeartbeatInfoParameter->GetInfoLength());
238
244
  receivedHeartbeatInfoParameter->Consolidate();
239
245
 
240
- test.tcbContext.ExpectObserveRttMsCalledTimes(0);
246
+ test.tcbContext.ExpectObserveRttUsCalledTimes(0);
241
247
 
242
248
  // Go backwards in time to make the HEARTBEAT-ACK have an invalid timestamp
243
249
  // in it, as it will be in the future.
@@ -251,12 +257,12 @@ SCENARIO("SCTP HeartbeatHandler", "[sctp][heartbeathandler]")
251
257
  {
252
258
  TestHeartbeatHandler test(HeartbeatIntervalMs);
253
259
 
254
- const uint64_t rtoMs{ 105 };
260
+ const int64_t rtoMs{ 105 };
255
261
 
256
- test.tcbContext.WillGetCurrentRtoMsOnce(
262
+ test.tcbContext.WillGetCurrentRtoUsOnce(
257
263
  []()
258
264
  {
259
- return rtoMs;
265
+ return static_cast<int64_t>(rtoMs * 1000);
260
266
  });
261
267
 
262
268
  test.AdvanceTimeMs(test.sctpOptions.heartbeatIntervalMs);
@@ -614,9 +614,9 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
614
614
  RTC::SCTP::ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
615
615
  };
616
616
 
617
- const uint8_t macKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
618
- 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
619
- const uint64_t creationTimestampMs = 1234567890;
617
+ const uint8_t macKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
618
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
619
+ const int64_t creationTimestampUs = 1234567890;
620
620
 
621
621
  auto* buffer = sctpCommon::FactoryBuffer;
622
622
 
@@ -630,7 +630,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
630
630
  /*remoteAdvertisedReceiverWindowCredit*/ 999909999,
631
631
  /*tieTag*/ 1111222233334444,
632
632
  remoteCapabilities,
633
- /*creationTimestampMs*/ creationTimestampMs,
633
+ /*creationTimestampUs*/ creationTimestampUs,
634
634
  /*macKey*/ macKey,
635
635
  /*macKeyLength*/ sizeof(macKey));
636
636
 
@@ -648,7 +648,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
648
648
  REQUIRE(stateCookie);
649
649
  REQUIRE(stateCookie->GetLength() == RTC::SCTP::StateCookie::AuthenticatedStateCookieLength);
650
650
  REQUIRE(stateCookie->IsAuthenticated() == true);
651
- REQUIRE(stateCookie->GetCreationTimestampMs() == creationTimestampMs);
651
+ REQUIRE(stateCookie->GetCreationTimestampUs() == creationTimestampUs);
652
652
  REQUIRE(stateCookie->GetLocalVerificationTag() == 6660666);
653
653
  REQUIRE(stateCookie->GetRemoteVerificationTag() == 9990999);
654
654
 
@@ -662,7 +662,7 @@ SCENARIO("SCTP State Cookie", "[sctp][statecookie]")
662
662
  /* The MAC must NOT verify with a wrong key. */
663
663
 
664
664
  const uint8_t wrongMacKey[] = { 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
665
- 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00 };
665
+ 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00 };
666
666
 
667
667
  REQUIRE(
668
668
  RTC::SCTP::StateCookie::VerifyMac(