mediasoup 3.26.0 → 3.27.1

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 (322) hide show
  1. package/CHANGELOG.md +16 -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/FBS/meson.build +25 -0
  49. package/worker/fbs/meson.build +15 -18
  50. package/worker/fbs/rtpParameters.fbs +1 -2
  51. package/worker/fbs/rtpStream.fbs +3 -3
  52. package/worker/fbs/transport.fbs +23 -23
  53. package/worker/fuzzer/include/RTC/FuzzerDtlsTransport.hpp +4 -1
  54. package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
  55. package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +8 -5
  56. package/worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp +3 -3
  57. package/worker/fuzzer/src/RTC/FuzzerTrendCalculator.cpp +6 -6
  58. package/worker/fuzzer/src/RTC/RTCP/FuzzerFeedbackRtpTransport.cpp +3 -3
  59. package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +2 -2
  60. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +5 -5
  61. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +3 -3
  62. package/worker/fuzzer/src/fuzzer.cpp +4 -0
  63. package/worker/include/Channel/ChannelNotification.hpp +3 -3
  64. package/worker/include/Channel/ChannelRequest.hpp +1 -1
  65. package/worker/include/Channel/ChannelSocket.hpp +11 -0
  66. package/worker/include/DepLibUV.hpp +16 -33
  67. package/worker/include/RTC/ActiveSpeakerObserver.hpp +11 -11
  68. package/worker/include/RTC/AudioLevelObserver.hpp +4 -4
  69. package/worker/include/RTC/BWE/AcknowledgedBitrateEstimatorInterface.hpp +55 -0
  70. package/worker/include/RTC/BWE/AimdRateControl.hpp +190 -0
  71. package/worker/include/RTC/BWE/BweTypes.hpp +211 -0
  72. package/worker/include/RTC/BWE/DelayBasedBwe.hpp +173 -0
  73. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +72 -0
  74. package/worker/include/RTC/BWE/InterArrivalDelta.hpp +106 -0
  75. package/worker/include/RTC/BWE/LinkCapacityEstimator.hpp +84 -0
  76. package/worker/include/RTC/BWE/LossBasedController.hpp +520 -0
  77. package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +94 -0
  78. package/worker/include/RTC/BWE/SendPacketHistory.hpp +137 -0
  79. package/worker/include/RTC/BWE/TargetRateController.hpp +306 -0
  80. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +143 -0
  81. package/worker/include/RTC/BWE/Utils.hpp +39 -0
  82. package/worker/include/RTC/Consts.hpp +6 -6
  83. package/worker/include/RTC/Consumer.hpp +14 -12
  84. package/worker/include/RTC/DataConsumer.hpp +3 -3
  85. package/worker/include/RTC/DataProducer.hpp +3 -3
  86. package/worker/include/RTC/DtlsTransport.hpp +5 -2
  87. package/worker/include/RTC/ICE/IceCandidate.hpp +2 -2
  88. package/worker/include/RTC/ICE/IceServer.hpp +3 -3
  89. package/worker/include/RTC/KeyFrameRequestManager.hpp +3 -3
  90. package/worker/include/RTC/NEW_RTCP/packet/Packet.hpp +1 -1
  91. package/worker/include/RTC/NackGenerator.hpp +12 -12
  92. package/worker/include/RTC/PipeProducerStreamManager.hpp +3 -4
  93. package/worker/include/RTC/PipeTransport.hpp +18 -5
  94. package/worker/include/RTC/PlainTransport.hpp +18 -5
  95. package/worker/include/RTC/PortManager.hpp +4 -4
  96. package/worker/include/RTC/Producer.hpp +21 -12
  97. package/worker/include/RTC/ProducerStreamManager.hpp +12 -6
  98. package/worker/include/RTC/RTCP/Bye.hpp +2 -2
  99. package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +4 -4
  100. package/worker/include/RTC/RTCP/FeedbackRtpTmmb.hpp +3 -3
  101. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +54 -39
  102. package/worker/include/RTC/RTCP/Packet.hpp +3 -3
  103. package/worker/include/RTC/RTCP/ReceiverReport.hpp +3 -3
  104. package/worker/include/RTC/RTCP/Sdes.hpp +2 -2
  105. package/worker/include/RTC/RTCP/XR.hpp +2 -2
  106. package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +1 -1
  107. package/worker/include/RTC/RTP/Codecs/H264.hpp +1 -1
  108. package/worker/include/RTC/RTP/Codecs/Opus.hpp +2 -2
  109. package/worker/include/RTC/RTP/Codecs/PayloadDescriptorHandler.hpp +3 -3
  110. package/worker/include/RTC/RTP/Codecs/VP8.hpp +2 -2
  111. package/worker/include/RTC/RTP/Codecs/VP9.hpp +2 -2
  112. package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +12 -12
  113. package/worker/include/RTC/RTP/Packet.hpp +13 -13
  114. package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
  115. package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +7 -7
  116. package/worker/include/RTC/RTP/RtpStream.hpp +37 -51
  117. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +59 -41
  118. package/worker/include/RTC/RTP/RtpStreamSend.hpp +20 -14
  119. package/worker/include/RTC/RTP/RtxStream.hpp +12 -13
  120. package/worker/include/RTC/RateCalculator.hpp +50 -44
  121. package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +5 -4
  122. package/worker/include/RTC/RemoteClockOffsetEstimator.hpp +11 -11
  123. package/worker/include/RTC/Router.hpp +6 -0
  124. package/worker/include/RTC/RtcLogger.hpp +1 -1
  125. package/worker/include/RTC/RtpDictionaries.hpp +10 -10
  126. package/worker/include/RTC/SCTP/association/Association.hpp +56 -28
  127. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +4 -4
  128. package/worker/include/RTC/SCTP/association/StateCookie.hpp +14 -14
  129. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +38 -2
  130. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +12 -12
  131. package/worker/include/RTC/SCTP/association/TransmissionControlBlockContextInterface.hpp +4 -4
  132. package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
  133. package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +3 -3
  134. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +4 -1
  135. package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +1 -1
  136. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +12 -12
  137. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +6 -6
  138. package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +10 -0
  139. package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +15 -16
  140. package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +7 -8
  141. package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +20 -16
  142. package/worker/include/RTC/SCTP/tx/RoundRobinSendQueue.hpp +5 -6
  143. package/worker/include/RTC/SCTP/tx/SendQueueInterface.hpp +2 -2
  144. package/worker/include/RTC/SCTP/tx/StreamScheduler.hpp +5 -5
  145. package/worker/include/RTC/SctpDictionaries.hpp +3 -3
  146. package/worker/include/RTC/Serializable.hpp +1 -1
  147. package/worker/include/RTC/SimpleProducerStreamManager.hpp +3 -4
  148. package/worker/include/RTC/SimulcastProducerStreamManager.hpp +6 -7
  149. package/worker/include/RTC/SvcProducerStreamManager.hpp +6 -5
  150. package/worker/include/RTC/TcpConnection.hpp +9 -3
  151. package/worker/include/RTC/TcpServer.hpp +3 -0
  152. package/worker/include/RTC/Transport.hpp +52 -45
  153. package/worker/include/RTC/TransportCongestionControlClient.hpp +30 -25
  154. package/worker/include/RTC/TransportCongestionControlServer.hpp +17 -17
  155. package/worker/include/RTC/TrendCalculator.hpp +5 -5
  156. package/worker/include/RTC/UdpSocket.hpp +11 -2
  157. package/worker/include/RTC/WebRtcServer.hpp +20 -5
  158. package/worker/include/RTC/WebRtcTransport.hpp +35 -10
  159. package/worker/include/Settings.hpp +4 -2
  160. package/worker/include/Shared.hpp +5 -20
  161. package/worker/include/SharedInterface.hpp +6 -28
  162. package/worker/include/Utils.hpp +40 -21
  163. package/worker/include/common.hpp +4 -0
  164. package/worker/include/handles/BackoffTimerHandle.hpp +4 -4
  165. package/worker/include/handles/BackoffTimerHandleInterface.hpp +5 -5
  166. package/worker/include/handles/TcpConnectionHandle.hpp +6 -6
  167. package/worker/include/handles/TcpServerHandle.hpp +1 -1
  168. package/worker/include/handles/TimerHandle.hpp +15 -9
  169. package/worker/include/handles/TimerHandleInterface.hpp +10 -4
  170. package/worker/include/handles/UdpSocketHandle.hpp +3 -3
  171. package/worker/include/handles/UnixStreamSocketHandle.hpp +2 -2
  172. package/worker/meson.build +87 -36
  173. package/worker/meson_options.txt +1 -0
  174. package/worker/mocks/include/MockShared.hpp +24 -23
  175. package/worker/mocks/include/RTC/SCTP/association/MockTransmissionControlBlockContext.hpp +51 -27
  176. package/worker/mocks/include/RTC/SCTP/tx/MockSendQueue.hpp +11 -11
  177. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +10 -10
  178. package/worker/mocks/include/handles/MockTimerHandle.hpp +60 -22
  179. package/worker/mocks/src/MockShared.cpp +51 -5
  180. package/worker/mocks/src/handles/MockBackoffTimerHandle.cpp +29 -15
  181. package/worker/mocks/src/handles/MockTimerHandle.cpp +117 -0
  182. package/worker/scripts/clang-scripts.mjs +2 -2
  183. package/worker/src/Channel/ChannelNotification.cpp +5 -6
  184. package/worker/src/Channel/ChannelSocket.cpp +20 -2
  185. package/worker/src/DepLibUV.cpp +4 -5
  186. package/worker/src/RTC/ActiveSpeakerObserver.cpp +59 -47
  187. package/worker/src/RTC/AudioLevelObserver.cpp +7 -7
  188. package/worker/src/RTC/BWE/AimdRateControl.cpp +468 -0
  189. package/worker/src/RTC/BWE/BweTypes.cpp +61 -0
  190. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +275 -0
  191. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +148 -0
  192. package/worker/src/RTC/BWE/InterArrivalDelta.cpp +181 -0
  193. package/worker/src/RTC/BWE/LinkCapacityEstimator.cpp +133 -0
  194. package/worker/src/RTC/BWE/LossBasedController.cpp +1046 -0
  195. package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +245 -0
  196. package/worker/src/RTC/BWE/SendPacketHistory.cpp +184 -0
  197. package/worker/src/RTC/BWE/TargetRateController.cpp +435 -0
  198. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +311 -0
  199. package/worker/src/RTC/BWE/Utils.cpp +54 -0
  200. package/worker/src/RTC/Consumer.cpp +48 -35
  201. package/worker/src/RTC/DataConsumer.cpp +4 -4
  202. package/worker/src/RTC/DataProducer.cpp +3 -3
  203. package/worker/src/RTC/DirectTransport.cpp +2 -2
  204. package/worker/src/RTC/DtlsTransport.cpp +14 -11
  205. package/worker/src/RTC/ICE/IceServer.cpp +2 -2
  206. package/worker/src/RTC/KeyFrameRequestManager.cpp +16 -12
  207. package/worker/src/RTC/NackGenerator.cpp +12 -12
  208. package/worker/src/RTC/PipeProducerStreamManager.cpp +6 -6
  209. package/worker/src/RTC/PipeTransport.cpp +16 -13
  210. package/worker/src/RTC/PlainTransport.cpp +25 -16
  211. package/worker/src/RTC/Producer.cpp +50 -36
  212. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +13 -6
  213. package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +14 -5
  214. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +76 -50
  215. package/worker/src/RTC/RTP/Codecs/VP8.cpp +1 -1
  216. package/worker/src/RTC/RTP/Codecs/VP9.cpp +4 -4
  217. package/worker/src/RTC/RTP/Packet.cpp +9 -10
  218. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +6 -6
  219. package/worker/src/RTC/RTP/RtpStream.cpp +19 -19
  220. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +146 -81
  221. package/worker/src/RTC/RTP/RtpStreamSend.cpp +49 -44
  222. package/worker/src/RTC/RTP/RtxStream.cpp +7 -10
  223. package/worker/src/RTC/RateCalculator.cpp +99 -136
  224. package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +13 -13
  225. package/worker/src/RTC/RemoteClockOffsetEstimator.cpp +18 -17
  226. package/worker/src/RTC/Router.cpp +18 -1
  227. package/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +5 -2
  228. package/worker/src/RTC/SCTP/association/Association.cpp +146 -103
  229. package/worker/src/RTC/SCTP/association/AssociationListenerDeferrer.cpp +4 -4
  230. package/worker/src/RTC/SCTP/association/Capabilities.cpp +1 -1
  231. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +25 -18
  232. package/worker/src/RTC/SCTP/association/StateCookie.cpp +7 -6
  233. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +122 -14
  234. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +28 -26
  235. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +0 -1
  236. package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +2 -2
  237. package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +2 -2
  238. package/worker/src/RTC/SCTP/public/SctpOptions.cpp +13 -13
  239. package/worker/src/RTC/SCTP/rx/DataTracker.cpp +1 -1
  240. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +5 -5
  241. package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +15 -15
  242. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +15 -15
  243. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +29 -26
  244. package/worker/src/RTC/SCTP/tx/RoundRobinSendQueue.cpp +12 -11
  245. package/worker/src/RTC/SCTP/tx/StreamScheduler.cpp +4 -4
  246. package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +2 -2
  247. package/worker/src/RTC/SimpleProducerStreamManager.cpp +10 -10
  248. package/worker/src/RTC/SimulcastProducerStreamManager.cpp +39 -37
  249. package/worker/src/RTC/SvcProducerStreamManager.cpp +39 -25
  250. package/worker/src/RTC/TcpConnection.cpp +9 -3
  251. package/worker/src/RTC/TcpServer.cpp +7 -2
  252. package/worker/src/RTC/Transport.cpp +266 -307
  253. package/worker/src/RTC/TransportCongestionControlClient.cpp +78 -71
  254. package/worker/src/RTC/TransportCongestionControlServer.cpp +38 -40
  255. package/worker/src/RTC/TrendCalculator.cpp +3 -3
  256. package/worker/src/RTC/UdpSocket.cpp +14 -3
  257. package/worker/src/RTC/WebRtcServer.cpp +20 -14
  258. package/worker/src/RTC/WebRtcTransport.cpp +35 -30
  259. package/worker/src/Settings.cpp +10 -0
  260. package/worker/src/Shared.cpp +2 -2
  261. package/worker/src/Utils/Crypto.cpp +2 -2
  262. package/worker/src/Worker.cpp +5 -1
  263. package/worker/src/handles/BackoffTimerHandle.cpp +24 -11
  264. package/worker/src/handles/TimerHandle.cpp +74 -25
  265. package/worker/src/lib.cpp +6 -0
  266. package/worker/tasks.py +197 -45
  267. package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +117 -0
  268. package/worker/test/src/RTC/BWE/TestAimdRateControl.cpp +400 -0
  269. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +568 -0
  270. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +546 -0
  271. package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +301 -0
  272. package/worker/test/src/RTC/BWE/TestLinkCapacityEstimator.cpp +115 -0
  273. package/worker/test/src/RTC/BWE/TestLossBasedController.cpp +1199 -0
  274. package/worker/test/src/RTC/BWE/TestRobustThroughputEstimator.cpp +433 -0
  275. package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +259 -0
  276. package/worker/test/src/RTC/BWE/TestTargetRateController.cpp +337 -0
  277. package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +182 -0
  278. package/worker/test/src/RTC/BWE/TestUtils.cpp +61 -0
  279. package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +171 -0
  280. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
  281. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  282. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +246 -208
  283. package/worker/test/src/RTC/RTP/TestPacket.cpp +11 -11
  284. package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +12 -12
  285. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +23 -16
  286. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +13 -13
  287. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +27 -22
  288. package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +21 -15
  289. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +6 -6
  290. package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +128 -13
  291. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +3 -3
  292. package/worker/test/src/RTC/SCTP/packet/chunks/TestForwardTsnChunk.cpp +2 -2
  293. package/worker/test/src/RTC/SCTP/packet/chunks/TestIForwardTsnChunk.cpp +23 -23
  294. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +1 -1
  295. package/worker/test/src/RTC/SCTP/packet/chunks/TestSackChunk.cpp +1 -1
  296. package/worker/test/src/RTC/SCTP/packet/parameters/TestIPv6AddressParameter.cpp +1 -1
  297. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +37 -37
  298. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +10 -10
  299. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
  300. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +93 -93
  301. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +247 -247
  302. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +100 -80
  303. package/worker/test/src/RTC/SCTP/tx/TestRoundRobinSendQueue.cpp +163 -163
  304. package/worker/test/src/RTC/SCTP/tx/TestStreamScheduler.cpp +76 -77
  305. package/worker/test/src/RTC/TestConsumer.cpp +8 -3
  306. package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +3 -3
  307. package/worker/test/src/RTC/TestNackGenerator.cpp +3 -3
  308. package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +5 -5
  309. package/worker/test/src/RTC/TestRateCalculator.cpp +110 -14
  310. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +22 -17
  311. package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +87 -85
  312. package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +54 -47
  313. package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +83 -69
  314. package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +76 -65
  315. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +72 -66
  316. package/worker/test/src/RTC/TestTransportTuple.cpp +19 -4
  317. package/worker/test/src/TestDepLibUV.cpp +19 -0
  318. package/worker/test/src/Utils/TestTime.cpp +57 -26
  319. package/worker/test/src/testHelpers.cpp +1 -1
  320. package/worker/test/src/tests.cpp +6 -0
  321. package/worker/include/RTC/SenderBandwidthEstimator.hpp +0 -118
  322. package/worker/src/RTC/SenderBandwidthEstimator.cpp +0 -269
@@ -8,10 +8,10 @@ namespace RTC
8
8
  {
9
9
  /* Static. */
10
10
 
11
- static constexpr uint64_t StreamMinActiveMs{ 2000u };
12
- static constexpr uint64_t BweDowngradeConservativeMs{ 10000u };
13
- static constexpr uint64_t BweDowngradeMinActiveMs{ 8000u };
14
- static constexpr uint16_t MaxSequenceNumberGap{ 100u };
11
+ static constexpr int64_t StreamMinActiveMs{ 2000 };
12
+ static constexpr int64_t BweDowngradeConservativeMs{ 10000 };
13
+ static constexpr int64_t BweDowngradeMinActiveMs{ 8000 };
14
+ static constexpr uint16_t MaxSequenceNumberGap{ 100 };
15
15
 
16
16
  /* Instance methods. */
17
17
 
@@ -200,18 +200,18 @@ namespace RTC
200
200
  }
201
201
  }
202
202
 
203
- uint32_t SimulcastProducerStreamManager::IncreaseLayer(
204
- uint32_t bitrate, bool considerLoss, float lossPercentage, uint64_t nowMs)
203
+ int64_t SimulcastProducerStreamManager::IncreaseLayer(
204
+ int64_t bitrate, bool considerLoss, float lossPercentage, int64_t nowMs)
205
205
  {
206
206
  MS_TRACE();
207
207
 
208
208
  // If already in the preferred layers, do nothing.
209
209
  if (this->provisionalTargetLayers == this->preferredLayers)
210
210
  {
211
- return 0u;
211
+ return 0;
212
212
  }
213
213
 
214
- uint32_t virtualBitrate;
214
+ int64_t virtualBitrate;
215
215
 
216
216
  if (considerLoss)
217
217
  {
@@ -235,7 +235,7 @@ namespace RTC
235
235
  virtualBitrate = bitrate;
236
236
  }
237
237
 
238
- uint32_t requiredBitrate{ 0u };
238
+ int64_t requiredBitrate{ 0 };
239
239
  int16_t spatialLayer{ 0 };
240
240
  int16_t temporalLayer{ 0 };
241
241
  // Whether a usable spatial layer has been found, in which case we must not
@@ -351,7 +351,7 @@ namespace RTC
351
351
  // temporal spatial layer if this is the temporal layer 0 of a higher
352
352
  // spatial layer.
353
353
  if (
354
- requiredBitrate && temporalLayer == 0 && this->provisionalTargetLayers.spatial > -1 &&
354
+ requiredBitrate > 0 && temporalLayer == 0 && this->provisionalTargetLayers.spatial > -1 &&
355
355
  spatialLayer > this->provisionalTargetLayers.spatial)
356
356
  {
357
357
  auto* provisionalProducerRtpStream =
@@ -365,13 +365,13 @@ namespace RTC
365
365
  }
366
366
  else
367
367
  {
368
- requiredBitrate = 1u; // Don't set 0 since it would be ignored.
368
+ requiredBitrate = 1; // Don't set 0 since it would be ignored.
369
369
  }
370
370
  }
371
371
 
372
372
  MS_DEBUG_DEV(
373
- "testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIu32
374
- ", required bitrate:%" PRIu32 "]",
373
+ "testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
374
+ ", required bitrate:%" PRIi64 "]",
375
375
  spatialLayer,
376
376
  temporalLayer,
377
377
  virtualBitrate,
@@ -379,7 +379,7 @@ namespace RTC
379
379
 
380
380
  // If active layer, end iterations here. Otherwise move to next spatial
381
381
  // layer.
382
- if (requiredBitrate)
382
+ if (requiredBitrate > 0)
383
383
  {
384
384
  goto done;
385
385
  }
@@ -399,15 +399,15 @@ namespace RTC
399
399
  done:
400
400
 
401
401
  // No higher active layers found.
402
- if (!requiredBitrate)
402
+ if (requiredBitrate <= 0)
403
403
  {
404
- return 0u;
404
+ return 0;
405
405
  }
406
406
 
407
407
  // No luck.
408
408
  if (requiredBitrate > virtualBitrate)
409
409
  {
410
- return 0u;
410
+ return 0;
411
411
  }
412
412
 
413
413
  // Set provisional layers.
@@ -415,8 +415,8 @@ namespace RTC
415
415
  this->provisionalTargetLayers.temporal = temporalLayer;
416
416
 
417
417
  MS_DEBUG_DEV(
418
- "setting provisional layers to %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIu32
419
- ", required bitrate:%" PRIu32 "]",
418
+ "setting provisional layers to %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
419
+ ", required bitrate:%" PRIi64 "]",
420
420
  this->provisionalTargetLayers.spatial,
421
421
  this->provisionalTargetLayers.temporal,
422
422
  virtualBitrate,
@@ -436,7 +436,7 @@ namespace RTC
436
436
  }
437
437
  }
438
438
 
439
- void SimulcastProducerStreamManager::ApplyLayers(uint64_t rtpStreamActiveMs)
439
+ void SimulcastProducerStreamManager::ApplyLayers(int64_t rtpStreamActiveMs)
440
440
  {
441
441
  MS_TRACE();
442
442
 
@@ -467,11 +467,11 @@ namespace RTC
467
467
  }
468
468
  }
469
469
 
470
- uint32_t SimulcastProducerStreamManager::GetDesiredBitrate(uint64_t nowMs) const
470
+ int64_t SimulcastProducerStreamManager::GetDesiredBitrate(int64_t nowMs) const
471
471
  {
472
472
  MS_TRACE();
473
473
 
474
- uint32_t desiredBitrate{ 0u };
474
+ int64_t desiredBitrate{ 0 };
475
475
 
476
476
  // Let's iterate all streams of the Producer (from highest to lowest) and
477
477
  // obtain their bitrate. Choose the highest one.
@@ -673,13 +673,13 @@ namespace RTC
673
673
  else
674
674
  {
675
675
  // Calculate capture instant and TS stuff.
676
- const auto captureMs1 = tsReferenceCaptureMapping.value().captureMs;
677
- const auto ts1 = tsReferenceCaptureMapping.value().ts;
678
- const auto captureMs2 = captureMapping.value().captureMs;
679
- const auto ts2 = captureMapping.value().ts;
680
- const int64_t diffMs = static_cast<int64_t>(captureMs2) - static_cast<int64_t>(captureMs1);
681
- const int64_t diffTs = diffMs * clockRate / 1000;
682
- const uint32_t newTs2 = ts2 - diffTs;
676
+ const auto captureAtUs1 = tsReferenceCaptureMapping.value().captureAtUs;
677
+ const auto ts1 = tsReferenceCaptureMapping.value().ts;
678
+ const auto captureAtUs2 = captureMapping.value().captureAtUs;
679
+ const auto ts2 = captureMapping.value().ts;
680
+ const int64_t diffUs = captureAtUs2 - captureAtUs1;
681
+ const int64_t diffTs = (diffUs * clockRate) / 1000000;
682
+ const uint32_t newTs2 = ts2 - diffTs;
683
683
 
684
684
  // Apply offset. This is the difference that later must be removed from
685
685
  // the sending RTP packet.
@@ -695,15 +695,17 @@ namespace RTC
695
695
  {
696
696
  // Max delay in ms we allow for the stream when switching.
697
697
  // https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
698
- static constexpr uint32_t MaxExtraOffsetMs{ 75 };
698
+ static constexpr int64_t MaxExtraOffsetMs{ 75 };
699
699
 
700
700
  // Outgoing packet matches the highest timestamp seen in the previous
701
701
  // stream. Apply an expected offset for a new frame in a 30fps stream.
702
- static constexpr uint8_t MsOffset{ 33 }; // (1 / 30 * 1000).
702
+ static constexpr int64_t OffsetMs{ 33 }; // (1 / 30 * 1000).
703
703
 
704
704
  const int64_t maxTsExtraOffset = MaxExtraOffsetMs * clockRate / 1000;
705
- uint32_t tsExtraOffset =
706
- maxPacketTs - packet->GetTimestamp() + tsOffset + (MsOffset * clockRate / 1000);
705
+
706
+ // NOTE: RTP timestamps wrap around, so the sum is truncated on purpose.
707
+ auto tsExtraOffset = static_cast<uint32_t>(
708
+ maxPacketTs - packet->GetTimestamp() + tsOffset + (OffsetMs * clockRate / 1000));
707
709
 
708
710
  // NOTE: Don't ask for a key frame if already done.
709
711
  if (this->keyFrameForTsOffsetRequested)
@@ -717,7 +719,7 @@ namespace RTC
717
719
  "which still too high RTP timestamp extra offset is needed (%" PRIu32 ")",
718
720
  tsExtraOffset);
719
721
 
720
- tsExtraOffset = 1u;
722
+ tsExtraOffset = 1;
721
723
  }
722
724
  }
723
725
  else if (std::cmp_greater(tsExtraOffset, maxTsExtraOffset))
@@ -746,7 +748,7 @@ namespace RTC
746
748
  return result;
747
749
  }
748
750
 
749
- if (tsExtraOffset > 0u)
751
+ if (tsExtraOffset > 0)
750
752
  {
751
753
  MS_DEBUG_TAG(
752
754
  simulcast,
@@ -918,7 +920,7 @@ namespace RTC
918
920
  if (
919
921
  newTargetSpatialLayer != -1 &&
920
922
  (this->tsReferenceSpatialLayer == -1 ||
921
- !GetProducerTsReferenceRtpStream()->GetCaptureMapping().has_value()))
923
+ !GetProducerTsReferenceRtpStream()->GetCaptureMapping().has_value()))
922
924
  {
923
925
  MS_DEBUG_TAG(
924
926
  simulcast, "using spatial layer %" PRIi16 " as RTP timestamp reference", newTargetSpatialLayer);
@@ -982,7 +984,7 @@ namespace RTC
982
984
  // Start with no layers.
983
985
  newTargetLayers.Reset();
984
986
 
985
- auto nowMs = this->shared->GetTimeMs();
987
+ const int64_t nowMs = this->shared->GetTimeMs();
986
988
 
987
989
  for (size_t sIdx{ 0u }; sIdx < this->producerRtpStreams.size(); ++sIdx)
988
990
  {
@@ -8,8 +8,8 @@ namespace RTC
8
8
  {
9
9
  /* Static. */
10
10
 
11
- static constexpr uint64_t BweDowngradeConservativeMs{ 10000u };
12
- static constexpr uint64_t BweDowngradeMinActiveMs{ 8000u };
11
+ static constexpr int64_t BweDowngradeConservativeMs{ 10000 };
12
+ static constexpr int64_t BweDowngradeMinActiveMs{ 8000 };
13
13
 
14
14
  /* Instance methods. */
15
15
 
@@ -122,23 +122,37 @@ namespace RTC
122
122
  // Do nothing.
123
123
  }
124
124
 
125
- uint32_t SvcProducerStreamManager::IncreaseLayer(
126
- uint32_t bitrate, bool considerLoss, float lossPercentage, uint64_t nowMs)
125
+ void SvcProducerStreamManager::ProducerSpatialLayerActivityChanged(
126
+ RTC::RTP::RtpStreamRecv* /*rtpStream*/, uint8_t /*spatialLayer*/, bool /*isActive*/)
127
127
  {
128
128
  MS_TRACE();
129
129
 
130
- if (!this->producerRtpStream || this->producerRtpStream->GetScore() == 0u)
130
+ // All spatial layers share a single RTP stream, so neither its score nor its
131
+ // inactivity check can tell that just one of them started or stopped. This is
132
+ // the only chance to reconsider the target layers.
133
+ if (IsActive())
134
+ {
135
+ MayChangeLayers(/*force*/ false);
136
+ }
137
+ }
138
+
139
+ int64_t SvcProducerStreamManager::IncreaseLayer(
140
+ int64_t bitrate, bool considerLoss, float lossPercentage, int64_t nowMs)
141
+ {
142
+ MS_TRACE();
143
+
144
+ if (!this->producerRtpStream || this->producerRtpStream->GetScore() == 0)
131
145
  {
132
- return 0u;
146
+ return 0;
133
147
  }
134
148
 
135
149
  // If already in the preferred layers, do nothing.
136
150
  if (this->provisionalTargetLayers == this->preferredLayers)
137
151
  {
138
- return 0u;
152
+ return 0;
139
153
  }
140
154
 
141
- uint32_t virtualBitrate;
155
+ int64_t virtualBitrate;
142
156
 
143
157
  if (considerLoss)
144
158
  {
@@ -162,7 +176,7 @@ namespace RTC
162
176
  virtualBitrate = bitrate;
163
177
  }
164
178
 
165
- uint32_t requiredBitrate{ 0u };
179
+ int64_t requiredBitrate{ 0 };
166
180
  int16_t spatialLayer{ 0 };
167
181
  int16_t temporalLayer{ 0 };
168
182
 
@@ -215,7 +229,7 @@ namespace RTC
215
229
  // layer if the new layer is the temporal layer 0 of a higher spatial
216
230
  // layer.
217
231
  if (
218
- this->encodingContext->IsKSvc() && requiredBitrate && temporalLayer == 0 &&
232
+ this->encodingContext->IsKSvc() && requiredBitrate > 0 && temporalLayer == 0 &&
219
233
  this->provisionalTargetLayers.spatial > -1 &&
220
234
  spatialLayer > this->provisionalTargetLayers.spatial)
221
235
  {
@@ -228,13 +242,13 @@ namespace RTC
228
242
  }
229
243
  else
230
244
  {
231
- requiredBitrate = 1u; // Don't set 0 since it would be ignored.
245
+ requiredBitrate = 1; // Don't set 0 since it would be ignored.
232
246
  }
233
247
  }
234
248
 
235
249
  MS_DEBUG_DEV(
236
- "testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIu32
237
- ", required bitrate:%" PRIu32 "]",
250
+ "testing layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
251
+ ", required bitrate:%" PRIi64 "]",
238
252
  spatialLayer,
239
253
  temporalLayer,
240
254
  virtualBitrate,
@@ -242,7 +256,7 @@ namespace RTC
242
256
 
243
257
  // If active layer, end iterations here. Otherwise move to next spatial
244
258
  // layer.
245
- if (requiredBitrate)
259
+ if (requiredBitrate > 0)
246
260
  {
247
261
  goto done;
248
262
  }
@@ -263,15 +277,15 @@ namespace RTC
263
277
  done:
264
278
 
265
279
  // No higher active layers found.
266
- if (!requiredBitrate)
280
+ if (requiredBitrate <= 0)
267
281
  {
268
- return 0u;
282
+ return 0;
269
283
  }
270
284
 
271
285
  // No luck.
272
286
  if (requiredBitrate > virtualBitrate)
273
287
  {
274
- return 0u;
288
+ return 0;
275
289
  }
276
290
 
277
291
  // Set provisional layers.
@@ -279,8 +293,8 @@ namespace RTC
279
293
  this->provisionalTargetLayers.temporal = temporalLayer;
280
294
 
281
295
  MS_DEBUG_DEV(
282
- "upgrading to layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIu32
283
- ", required bitrate:%" PRIu32 "]",
296
+ "upgrading to layers %" PRIi16 ":%" PRIi16 " [virtual bitrate:%" PRIi64
297
+ ", required bitrate:%" PRIi64 "]",
284
298
  this->provisionalTargetLayers.spatial,
285
299
  this->provisionalTargetLayers.temporal,
286
300
  virtualBitrate,
@@ -300,7 +314,7 @@ namespace RTC
300
314
  }
301
315
  }
302
316
 
303
- void SvcProducerStreamManager::ApplyLayers(uint64_t rtpStreamActiveMs)
317
+ void SvcProducerStreamManager::ApplyLayers(int64_t rtpStreamActiveMs)
304
318
  {
305
319
  MS_TRACE();
306
320
 
@@ -332,16 +346,16 @@ namespace RTC
332
346
  }
333
347
  }
334
348
 
335
- uint32_t SvcProducerStreamManager::GetDesiredBitrate(uint64_t nowMs) const
349
+ int64_t SvcProducerStreamManager::GetDesiredBitrate(int64_t nowMs) const
336
350
  {
337
351
  MS_TRACE();
338
352
 
339
- if (!this->producerRtpStream || this->producerRtpStream->GetScore() == 0u)
353
+ if (!this->producerRtpStream || this->producerRtpStream->GetScore() == 0)
340
354
  {
341
- return 0u;
355
+ return 0;
342
356
  }
343
357
 
344
- uint32_t desiredBitrate{ 0u };
358
+ int64_t desiredBitrate{ 0 };
345
359
 
346
360
  // When using K-SVC each spatial layer is independent of the others.
347
361
  if (this->encodingContext->IsKSvc())
@@ -564,7 +578,7 @@ namespace RTC
564
578
  // Start with no layers.
565
579
  newTargetLayers.Reset();
566
580
 
567
- auto nowMs = this->shared->GetTimeMs();
581
+ const int64_t nowMs = this->shared->GetTimeMs();
568
582
  int16_t spatialLayer{ 0 };
569
583
 
570
584
  if (!this->producerRtpStream)
@@ -19,8 +19,8 @@ namespace RTC
19
19
 
20
20
  /* Instance methods. */
21
21
 
22
- TcpConnection::TcpConnection(Listener* listener, size_t bufferSize)
23
- : ::TcpConnectionHandle::TcpConnectionHandle(bufferSize), listener(listener)
22
+ TcpConnection::TcpConnection(Listener* listener, SharedInterface* shared, size_t bufferSize)
23
+ : ::TcpConnectionHandle::TcpConnectionHandle(bufferSize), listener(listener), shared(shared)
24
24
  {
25
25
  MS_TRACE();
26
26
  }
@@ -34,6 +34,11 @@ namespace RTC
34
34
  {
35
35
  MS_TRACE();
36
36
 
37
+ // NOTE: Take the arrival time before anything else is done with the read
38
+ // data, so that it doesn't include the cost of processing it. All the frames
39
+ // found within this read share it, since they all arrived in it.
40
+ const int64_t receivedAtUs = this->shared->GetTimeUs();
41
+
37
42
  MS_DEBUG_DEV(
38
43
  "data received [local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
39
44
  GetLocalIp().c_str(),
@@ -88,7 +93,8 @@ namespace RTC
88
93
  // later.
89
94
  std::memcpy(ReadBuffer, packet, packetLen);
90
95
 
91
- this->listener->OnTcpConnectionPacketReceived(this, ReadBuffer, packetLen, ReadBufferSize);
96
+ this->listener->OnTcpConnectionPacketReceived(
97
+ this, ReadBuffer, packetLen, ReadBufferSize, receivedAtUs);
92
98
  }
93
99
 
94
100
  // If there is no more space available in the buffer and that is because
@@ -17,6 +17,7 @@ namespace RTC
17
17
  TcpServer::TcpServer(
18
18
  Listener* listener,
19
19
  RTC::TcpConnection::Listener* connListener,
20
+ SharedInterface* shared,
20
21
  std::string& ip,
21
22
  uint16_t port,
22
23
  RTC::Transport::SocketFlags& flags)
@@ -24,6 +25,7 @@ namespace RTC
24
25
  ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip, port, flags)),
25
26
  listener(listener),
26
27
  connListener(connListener),
28
+ shared(shared),
27
29
  fixedPort(true)
28
30
  {
29
31
  MS_TRACE();
@@ -32,6 +34,7 @@ namespace RTC
32
34
  TcpServer::TcpServer(
33
35
  Listener* listener,
34
36
  RTC::TcpConnection::Listener* connListener,
37
+ SharedInterface* shared,
35
38
  std::string& ip,
36
39
  uint16_t minPort,
37
40
  uint16_t maxPort,
@@ -41,7 +44,8 @@ namespace RTC
41
44
  ::TcpServerHandle::TcpServerHandle(
42
45
  RTC::PortManager::BindTcp(ip, minPort, maxPort, flags, portRangeKey)),
43
46
  listener(listener),
44
- connListener(connListener)
47
+ connListener(connListener),
48
+ shared(shared)
45
49
  {
46
50
  MS_TRACE();
47
51
 
@@ -63,7 +67,8 @@ namespace RTC
63
67
  MS_TRACE();
64
68
 
65
69
  // Allocate a new RTC::TcpConnection for the TcpServer to handle it.
66
- auto* connection = new RTC::TcpConnection(this->connListener, TcpConnectionBufferSize);
70
+ auto* connection =
71
+ new RTC::TcpConnection(this->connListener, this->shared, TcpConnectionBufferSize);
67
72
 
68
73
  // Accept it.
69
74
  AcceptTcpConnection(connection);