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
@@ -12,18 +12,18 @@ namespace RTC
12
12
  struct HeaderExtensionIds
13
13
  {
14
14
  // 0 means no id.
15
- uint8_t mid{ 0u };
16
- uint8_t rid{ 0u };
17
- uint8_t rrid{ 0u };
18
- uint8_t absSendTime{ 0u };
19
- uint8_t transportWideCc01{ 0u };
20
- uint8_t ssrcAudioLevel{ 0u };
21
- uint8_t dependencyDescriptor{ 0u };
22
- uint8_t videoOrientation{ 0u };
23
- uint8_t timeOffset{ 0u };
24
- uint8_t absCaptureTime{ 0u };
25
- uint8_t playoutDelay{ 0u };
26
- uint8_t mediasoupPacketId{ 0u };
15
+ uint8_t mid{ 0 };
16
+ uint8_t rid{ 0 };
17
+ uint8_t rrid{ 0 };
18
+ uint8_t absSendTime{ 0 };
19
+ uint8_t transportWideCc01{ 0 };
20
+ uint8_t ssrcAudioLevel{ 0 };
21
+ uint8_t dependencyDescriptor{ 0 };
22
+ uint8_t videoOrientation{ 0 };
23
+ uint8_t timeOffset{ 0 };
24
+ uint8_t absCaptureTime{ 0 };
25
+ uint8_t playoutDelay{ 0 };
26
+ uint8_t mediasoupPacketId{ 0 };
27
27
  };
28
28
  } // namespace RTP
29
29
  } // namespace RTC
@@ -527,10 +527,10 @@ namespace RTC
527
527
 
528
528
  /**
529
529
  * @remarks
530
- * - Contrary to `ReadAbsSendTime()` method, given `ms` is internally
531
- * converted to ABS Send Time.
530
+ * - `sentAtUs` is converted internally to the 3 bytes ABS Send Time format,
531
+ * unlike `ReadAbsSendTime()`, which exposes the raw extension value.
532
532
  */
533
- bool UpdateAbsSendTime(uint64_t ms) const;
533
+ bool UpdateAbsSendTime(int64_t sentAtUs) const;
534
534
 
535
535
  bool ReadTransportWideCc01(uint16_t& wideSeqNumber) const;
536
536
 
@@ -819,7 +819,7 @@ namespace RTC
819
819
  {
820
820
  if (!this->payloadDescriptorHandler)
821
821
  {
822
- return 0u;
822
+ return 0;
823
823
  }
824
824
 
825
825
  return this->payloadDescriptorHandler->GetSpatialLayer();
@@ -832,26 +832,26 @@ namespace RTC
832
832
  {
833
833
  if (!this->payloadDescriptorHandler)
834
834
  {
835
- return 0u;
835
+ return 0;
836
836
  }
837
837
 
838
838
  return this->payloadDescriptorHandler->GetTemporalLayer();
839
839
  }
840
840
 
841
841
  /**
842
- * Capture time (in ms) of the packet.
842
+ * Capture time (in us) of the packet.
843
843
  */
844
- std::optional<uint64_t> GetCaptureMs() const
844
+ std::optional<int64_t> GetCaptureAtUs() const
845
845
  {
846
- return this->captureMs;
846
+ return this->captureAtUs;
847
847
  }
848
848
 
849
849
  /**
850
- * Set the capture time (in ms) of the packet.
850
+ * Set the capture time (in us) of the packet.
851
851
  */
852
- void SetCaptureMs(uint64_t captureMs)
852
+ void SetCaptureAtUs(int64_t captureAtUs)
853
853
  {
854
- this->captureMs = captureMs;
854
+ this->captureAtUs = captureAtUs;
855
855
  }
856
856
 
857
857
  private:
@@ -967,7 +967,7 @@ namespace RTC
967
967
  // each entry is the offset (in bytes) from the beginning of the header
968
968
  // extension value to the beginning of the extension.
969
969
  std::array<ssize_t, 14> oneByteExtensions{ -1, -1, -1, -1, -1, -1, -1,
970
- -1, -1, -1, -1, -1, -1, -1 };
970
+ -1, -1, -1, -1, -1, -1, -1 };
971
971
  // Ordered map of Two Bytes Extensions. Key is the id 1 of the extension,
972
972
  // each entry is the offset (in bytes) from the beginning of the header
973
973
  // extension value to the beginning of the extension.
@@ -977,7 +977,7 @@ namespace RTC
977
977
  // Codec related.
978
978
  std::shared_ptr<Codecs::PayloadDescriptorHandler> payloadDescriptorHandler;
979
979
  // Capture time of the packet.
980
- std::optional<uint64_t> captureMs;
980
+ std::optional<int64_t> captureAtUs;
981
981
  };
982
982
  } // namespace RTP
983
983
  } // namespace RTC
@@ -22,7 +22,7 @@ namespace RTC
22
22
  /**
23
23
  * Codec payload type of the probation RTP stream.
24
24
  */
25
- static const uint8_t PayloadType{ 127u };
25
+ static const uint8_t PayloadType{ 127 };
26
26
 
27
27
  public:
28
28
  explicit ProbationGenerator();
@@ -27,24 +27,24 @@ namespace RTC
27
27
  // Payload descriptor encoder.
28
28
  std::unique_ptr<RTP::Codecs::PayloadDescriptor::Encoder> encoder{ nullptr };
29
29
  // Correct SSRC since original packet may not have the same.
30
- uint32_t ssrc{ 0u };
30
+ uint32_t ssrc{ 0 };
31
31
  // Correct sequence number since original packet may not have the same.
32
- uint16_t sequenceNumber{ 0u };
32
+ uint16_t sequenceNumber{ 0 };
33
33
  // Correct timestamp since original packet may not have the same.
34
- uint32_t timestamp{ 0u };
34
+ uint32_t timestamp{ 0 };
35
35
  // Correct marker bit since original packet may not have the same.
36
36
  bool marker{ false };
37
37
  // Last time this packet was resent.
38
- uint64_t resentAtMs{ 0u };
38
+ int64_t resentAtMs{ 0 };
39
39
  // Number of times this packet was resent.
40
- uint8_t sentTimes{ 0u };
40
+ uint8_t sentTimes{ 0 };
41
41
  };
42
42
 
43
43
  private:
44
44
  static Item* FillItem(Item* item, RTP::Packet* packet, const RTP::SharedPacket& sharedPacket);
45
45
 
46
46
  public:
47
- RetransmissionBuffer(uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate);
47
+ RetransmissionBuffer(uint16_t maxItems, int64_t maxRetransmissionDelayMs, uint32_t clockRate);
48
48
  ~RetransmissionBuffer();
49
49
 
50
50
  void Dump(int indentation = 0) const;
@@ -67,7 +67,7 @@ namespace RTC
67
67
  private:
68
68
  // Given as argument.
69
69
  uint16_t maxItems;
70
- uint32_t maxRetransmissionDelayMs;
70
+ int64_t maxRetransmissionDelayMs;
71
71
  uint32_t clockRate;
72
72
  };
73
73
  } // namespace RTP
@@ -3,15 +3,6 @@
3
3
 
4
4
  #include "common.hpp"
5
5
  #include "FBS/rtpStream.h"
6
- #include "RTC/RTCP/FeedbackPsFir.hpp"
7
- #include "RTC/RTCP/FeedbackPsPli.hpp"
8
- #include "RTC/RTCP/FeedbackRtpNack.hpp"
9
- #include "RTC/RTCP/Packet.hpp"
10
- #include "RTC/RTCP/ReceiverReport.hpp"
11
- #include "RTC/RTCP/Sdes.hpp"
12
- #include "RTC/RTCP/SenderReport.hpp"
13
- #include "RTC/RTCP/XrDelaySinceLastRr.hpp"
14
- #include "RTC/RTCP/XrReceiverReferenceTime.hpp"
15
6
  #include "RTC/RTP/Packet.hpp"
16
7
  #include "RTC/RTP/RtxStream.hpp"
17
8
  #include "RTC/RtpDictionaries.hpp"
@@ -42,22 +33,22 @@ namespace RTC
42
33
  flatbuffers::Offset<FBS::RtpStream::Params> FillBuffer(
43
34
  flatbuffers::FlatBufferBuilder& builder) const;
44
35
 
45
- size_t encodingIdx{ 0u };
46
- uint32_t ssrc{ 0u };
47
- uint8_t payloadType{ 0u };
36
+ size_t encodingIdx{ 0 };
37
+ uint32_t ssrc{ 0 };
38
+ uint8_t payloadType{ 0 };
48
39
  RTC::RtpCodecMimeType mimeType;
49
- uint32_t clockRate{ 0u };
40
+ uint32_t clockRate{ 0 };
50
41
  std::string rid;
51
42
  std::string cname;
52
- uint32_t rtxSsrc{ 0u };
53
- uint8_t rtxPayloadType{ 0u };
43
+ uint32_t rtxSsrc{ 0 };
44
+ uint8_t rtxPayloadType{ 0 };
54
45
  bool useNack{ false };
55
46
  bool usePli{ false };
56
47
  bool useFir{ false };
57
48
  bool useInBandFec{ false };
58
49
  bool useDtx{ false };
59
- uint8_t spatialLayers{ 1u };
60
- uint8_t temporalLayers{ 1u };
50
+ uint8_t spatialLayers{ 1 };
51
+ uint8_t temporalLayers{ 1 };
61
52
  };
62
53
 
63
54
  public:
@@ -68,9 +59,9 @@ namespace RTC
68
59
  struct SenderReportMapping
69
60
  {
70
61
  /**
71
- * NTP timestamp of the Sender Report (ms).
62
+ * NTP timestamp of the Sender Report (us).
72
63
  */
73
- uint64_t ntpMs;
64
+ int64_t ntpUs;
74
65
  /**
75
66
  * RTP timestamp the NTP timestamp above corresponds to.
76
67
  */
@@ -165,13 +156,13 @@ namespace RTC
165
156
 
166
157
  virtual void Resume() = 0;
167
158
 
168
- virtual uint32_t GetBitrate(uint64_t nowMs) = 0;
159
+ virtual int64_t GetBitrate(int64_t nowMs) = 0;
169
160
 
170
- virtual uint32_t GetBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) = 0;
161
+ virtual int64_t GetBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) = 0;
171
162
 
172
- virtual uint32_t GetSpatialLayerBitrate(uint64_t nowMs, uint8_t spatialLayer) = 0;
163
+ virtual int64_t GetSpatialLayerBitrate(int64_t nowMs, uint8_t spatialLayer) = 0;
173
164
 
174
- virtual uint32_t GetLayerBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) = 0;
165
+ virtual int64_t GetLayerBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) = 0;
175
166
 
176
167
  void ResetScore(uint8_t score, bool notify);
177
168
 
@@ -185,14 +176,9 @@ namespace RTC
185
176
  return static_cast<float>(this->fractionLost) * 100 / 256;
186
177
  }
187
178
 
188
- float GetRtt() const
179
+ float GetRttMs() const
189
180
  {
190
- return this->rtt;
191
- }
192
-
193
- uint64_t GetMaxPacketMs() const
194
- {
195
- return this->maxPacketMs;
181
+ return this->rttMs;
196
182
  }
197
183
 
198
184
  uint32_t GetMaxPacketTs() const
@@ -216,7 +202,7 @@ namespace RTC
216
202
  return this->score;
217
203
  }
218
204
 
219
- uint64_t GetActiveMs() const
205
+ int64_t GetActiveMs() const
220
206
  {
221
207
  return this->shared->GetTimeMs() - this->activeSinceMs;
222
208
  }
@@ -250,55 +236,55 @@ namespace RTC
250
236
  // Others.
251
237
  // https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
252
238
  // Highest seq. number seen.
253
- uint16_t maxSeq{ 0u };
239
+ uint16_t maxSeq{ 0 };
254
240
  // Shifted count of seq. number cycles.
255
- uint32_t cycles{ 0u };
241
+ uint32_t cycles{ 0 };
256
242
  // Base seq number.
257
- uint32_t baseSeq{ 0u };
243
+ uint32_t baseSeq{ 0 };
258
244
  // Last 'bad' seq number + 1.
259
- uint32_t badSeq{ 0u };
245
+ uint32_t badSeq{ 0 };
260
246
  // Highest timestamp seen.
261
- uint32_t maxPacketTs{ 0u };
247
+ uint32_t maxPacketTs{ 0 };
262
248
  // When the packet with highest timestammp was seen.
263
- uint64_t maxPacketMs{ 0u };
249
+ int64_t maxPacketAtUs{ 0 };
264
250
  // When the media in the packet with highest timestamp was captured, in our own
265
251
  // monotonic clock.
266
252
  // NOTE: Only meaningful in a send stream, whose packets arrive already carrying
267
253
  // their capture instant. In a receive stream it is the Producer that tells it,
268
254
  // once this class has already seen the packet, so
269
255
  // RtpStreamRecv::GetCaptureMapping() is what must be used there.
270
- std::optional<uint64_t> maxPacketCaptureMs;
256
+ std::optional<int64_t> maxPacketCaptureAtUs;
271
257
  int32_t packetsLost{ 0 };
272
- uint8_t fractionLost{ 0u };
258
+ uint8_t fractionLost{ 0 };
273
259
  // Jitter in RTP timestamp units. As per spec it's kept as floating value
274
260
  // although it's exposed as integer in the stats.
275
261
  float jitter{ 0 };
276
- size_t packetsDiscarded{ 0u };
277
- size_t packetsRetransmitted{ 0u };
278
- size_t packetsRepaired{ 0u };
279
- size_t nackCount{ 0u };
280
- size_t nackPacketCount{ 0u };
281
- size_t pliCount{ 0u };
282
- size_t firCount{ 0u };
262
+ size_t packetsDiscarded{ 0 };
263
+ size_t packetsRetransmitted{ 0 };
264
+ size_t packetsRepaired{ 0 };
265
+ size_t nackCount{ 0 };
266
+ size_t nackPacketCount{ 0 };
267
+ size_t pliCount{ 0 };
268
+ size_t firCount{ 0 };
283
269
  // Packets repaired at last interval for score calculation.
284
- size_t repairedPriorScore{ 0u };
270
+ size_t repairedPriorScore{ 0 };
285
271
  // Packets retransmitted at last interval for score calculation.
286
- size_t retransmittedPriorScore{ 0u };
272
+ size_t retransmittedPriorScore{ 0 };
287
273
  // Correspondence between wall clock and RTP timeline given by the last Sender
288
274
  // Report.
289
275
  std::optional<RTP::RtpStream::SenderReportMapping> lastSenderReportMapping;
290
- float rtt{ 0.0f };
276
+ float rttMs{ 0.0f };
291
277
  // Instance of RtxStream.
292
278
  RTP::RtxStream* rtxStream{ nullptr };
293
279
 
294
280
  private:
295
281
  // Score related.
296
- uint8_t score{ 0u };
282
+ uint8_t score{ 0 };
297
283
  std::vector<uint8_t> scores;
298
284
  // Whether at least a RTP packet has been received.
299
285
  bool started{ false };
300
286
  // Last time since the stream is active.
301
- uint64_t activeSinceMs{ 0u };
287
+ int64_t activeSinceMs{ 0 };
302
288
  };
303
289
  } // namespace RTP
304
290
  } // namespace RTC
@@ -3,6 +3,9 @@
3
3
 
4
4
  #include "handles/TimerHandleInterface.hpp"
5
5
  #include "RTC/NackGenerator.hpp"
6
+ #include "RTC/RTCP/Packet.hpp"
7
+ #include "RTC/RTCP/ReceiverReport.hpp"
8
+ #include "RTC/RTCP/SenderReport.hpp"
6
9
  #include "RTC/RTCP/XrDelaySinceLastRr.hpp"
7
10
  #include "RTC/RTP/RtpStream.hpp"
8
11
  #include "RTC/RateCalculator.hpp"
@@ -26,12 +29,12 @@ namespace RTC
26
29
  * - Same value libwebrtc uses in `AbsoluteCaptureTimeInterpolator`, which
27
30
  * pairs with senders emitting the extension at least once per second.
28
31
  */
29
- static constexpr uint64_t MaxAbsCaptureTimeInterpolationMs{ 5000 };
32
+ static constexpr int64_t MaxAbsCaptureTimeInterpolationMs{ 5000 };
30
33
  /**
31
34
  * How far the RTP timestamp of a packet may be from the last received RTCP
32
35
  * Sender Report for its capture instant to still be interpolated from it (ms).
33
36
  */
34
- static constexpr uint64_t MaxSenderReportInterpolationMs{ 10000 };
37
+ static constexpr int64_t MaxSenderReportInterpolationMs{ 10000 };
35
38
 
36
39
  public:
37
40
  class Listener : public RTP::RtpStream::Listener
@@ -44,6 +47,16 @@ namespace RTC
44
47
  * streams consuming this RtpStreamRecv.
45
48
  */
46
49
  virtual uint8_t OnRtpStreamNeedWorstRemoteFractionLost(RTP::RtpStreamRecv* rtpStream) = 0;
50
+ /**
51
+ * A spatial layer of this stream started or stopped carrying traffic, so
52
+ * whoever chose a target layer out of them must choose again.
53
+ *
54
+ * @remarks
55
+ * - Only fired by streams with more than a spatial layer, which are those
56
+ * of a SVC sender.
57
+ */
58
+ virtual void OnRtpStreamSpatialLayerActivityChanged(
59
+ RTP::RtpStreamRecv* rtpStream, uint8_t spatialLayer, bool isActive) = 0;
47
60
  };
48
61
 
49
62
  public:
@@ -51,18 +64,18 @@ namespace RTC
51
64
  {
52
65
  public:
53
66
  TransmissionCounter(
54
- SharedInterface* shared, uint8_t spatialLayers, uint8_t temporalLayers, size_t windowSize);
67
+ SharedInterface* shared, uint8_t spatialLayers, uint8_t temporalLayers, int64_t windowSizeMs);
55
68
 
56
69
  public:
57
70
  void Update(const RTP::Packet* packet);
58
71
 
59
- uint32_t GetBitrate(uint64_t nowMs);
72
+ int64_t GetBitrate(int64_t nowMs);
60
73
 
61
- uint32_t GetBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer);
74
+ int64_t GetBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer);
62
75
 
63
- uint32_t GetSpatialLayerBitrate(uint64_t nowMs, uint8_t spatialLayer);
76
+ int64_t GetSpatialLayerBitrate(int64_t nowMs, uint8_t spatialLayer);
64
77
 
65
- uint32_t GetLayerBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer);
78
+ int64_t GetLayerBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer);
66
79
 
67
80
  size_t GetPacketCount() const;
68
81
 
@@ -81,9 +94,9 @@ namespace RTC
81
94
  {
82
95
  /**
83
96
  * Capture instant of the media carried by the RTP timestamp below, in our own
84
- * monotonic clock (ms).
97
+ * monotonic clock (us).
85
98
  */
86
- uint64_t captureMs;
99
+ int64_t captureAtUs;
87
100
  /**
88
101
  * RTP timestamp the capture instant above refers to.
89
102
  */
@@ -104,7 +117,7 @@ namespace RTC
104
117
  /**
105
118
  * Local time at which the Sender Report arrived.
106
119
  */
107
- uint64_t receivedMs;
120
+ int64_t receivedAtUs;
108
121
  };
109
122
 
110
123
  /**
@@ -118,9 +131,9 @@ namespace RTC
118
131
  */
119
132
  uint32_t ts;
120
133
  /**
121
- * Capture instant in the remote sender's wall clock (ms).
134
+ * Capture instant in the remote sender's wall clock (us).
122
135
  */
123
- uint64_t ntpMs;
136
+ int64_t ntpUs;
124
137
  };
125
138
 
126
139
  public:
@@ -128,7 +141,7 @@ namespace RTC
128
141
  RTP::RtpStreamRecv::Listener* listener,
129
142
  SharedInterface* shared,
130
143
  RTP::RtpStream::Params& params,
131
- uint32_t sendNackDelayMs,
144
+ int64_t sendNackDelayMs,
132
145
  bool useRtpInactivityCheck);
133
146
 
134
147
  ~RtpStreamRecv() override;
@@ -137,7 +150,7 @@ namespace RTC
137
150
  flatbuffers::Offset<FBS::RtpStream::Stats> FillBufferStats(
138
151
  flatbuffers::FlatBufferBuilder& builder) override;
139
152
 
140
- bool ReceivePacket(RTP::Packet* packet);
153
+ bool ReceivePacket(RTP::Packet* packet, int64_t receivedAtUs);
141
154
 
142
155
  bool ReceiveRtxPacket(RTP::Packet* packet);
143
156
 
@@ -145,25 +158,26 @@ namespace RTC
145
158
 
146
159
  RTC::RTCP::ReceiverReport* GetRtxRtcpReceiverReport();
147
160
 
148
- void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
161
+ void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report, int64_t receivedAtUs);
149
162
 
150
- void ReceiveRtxRtcpSenderReport(RTC::RTCP::SenderReport* report);
163
+ void ReceiveRtxRtcpSenderReport(RTC::RTCP::SenderReport* report, int64_t receivedAtUs);
151
164
 
152
- void ReceiveRtcpXrDelaySinceLastRr(RTC::RTCP::DelaySinceLastRr::SsrcInfo* ssrcInfo);
165
+ void ReceiveRtcpXrDelaySinceLastRr(
166
+ RTC::RTCP::DelaySinceLastRr::SsrcInfo* ssrcInfo, int64_t receivedAtUs);
153
167
 
154
168
  /**
155
169
  * Local time at which the last RTCP Sender Report arrived.
156
170
  *
157
171
  * @returns No value if no Sender Report has arrived yet.
158
172
  */
159
- std::optional<uint64_t> GetSenderReportReceivedMs() const
173
+ std::optional<int64_t> GetSenderReportReceivedAtUs() const
160
174
  {
161
175
  if (!this->lastSenderReportTiming.has_value())
162
176
  {
163
177
  return std::nullopt;
164
178
  }
165
179
 
166
- return this->lastSenderReportTiming.value().receivedMs;
180
+ return this->lastSenderReportTiming.value().receivedAtUs;
167
181
  }
168
182
 
169
183
  /**
@@ -175,14 +189,14 @@ namespace RTC
175
189
  * remote sender into our own clock needs the whole set of streams of that
176
190
  * sender.
177
191
  *
178
- * @param captureMs - Capture instant of `ts` in our own monotonic clock.
192
+ * @param captureAtUs - Capture instant of `ts` in our own monotonic clock.
179
193
  * @param ts - RTP timestamp the capture instant refers to.
180
194
  */
181
- void SetCaptureMapping(uint64_t captureMs, uint32_t ts)
195
+ void SetCaptureMapping(int64_t captureAtUs, uint32_t ts)
182
196
  {
183
197
  this->lastCaptureMapping = RTP::RtpStreamRecv::CaptureMapping{
184
- .captureMs = captureMs,
185
- .ts = ts,
198
+ .captureAtUs = captureAtUs,
199
+ .ts = ts,
186
200
  };
187
201
  }
188
202
 
@@ -211,7 +225,7 @@ namespace RTC
211
225
  * @returns No value if no such extension has been received, or if the given RTP
212
226
  * timestamp is too far away from the one it referred to.
213
227
  */
214
- std::optional<uint64_t> GetRemoteCaptureMsFromAbsCaptureTime(uint32_t ts) const;
228
+ std::optional<int64_t> GetRemoteCaptureAtUsFromAbsCaptureTime(uint32_t ts) const;
215
229
 
216
230
  /**
217
231
  * Capture instant of the given RTP timestamp, expressed in the remote sender's
@@ -222,7 +236,7 @@ namespace RTC
222
236
  * @returns No value if no Sender Report has been received, or if the given RTP
223
237
  * timestamp is too far away from the one it reported.
224
238
  */
225
- std::optional<uint64_t> GetRemoteCaptureMsFromSenderReport(uint32_t ts) const;
239
+ std::optional<int64_t> GetRemoteCaptureAtUsFromSenderReport(uint32_t ts) const;
226
240
 
227
241
  void RequestKeyFrame();
228
242
 
@@ -230,22 +244,22 @@ namespace RTC
230
244
 
231
245
  void Resume() override;
232
246
 
233
- uint32_t GetBitrate(uint64_t nowMs) override
247
+ int64_t GetBitrate(int64_t nowMs) override
234
248
  {
235
249
  return this->transmissionCounter.GetBitrate(nowMs);
236
250
  }
237
251
 
238
- uint32_t GetBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) override
252
+ int64_t GetBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) override
239
253
  {
240
254
  return this->transmissionCounter.GetBitrate(nowMs, spatialLayer, temporalLayer);
241
255
  }
242
256
 
243
- uint32_t GetSpatialLayerBitrate(uint64_t nowMs, uint8_t spatialLayer) override
257
+ int64_t GetSpatialLayerBitrate(int64_t nowMs, uint8_t spatialLayer) override
244
258
  {
245
259
  return this->transmissionCounter.GetSpatialLayerBitrate(nowMs, spatialLayer);
246
260
  }
247
261
 
248
- uint32_t GetLayerBitrate(uint64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) override
262
+ int64_t GetLayerBitrate(int64_t nowMs, uint8_t spatialLayer, uint8_t temporalLayer) override
249
263
  {
250
264
  return this->transmissionCounter.GetLayerBitrate(nowMs, spatialLayer, temporalLayer);
251
265
  }
@@ -256,7 +270,7 @@ namespace RTC
256
270
  }
257
271
 
258
272
  private:
259
- void CalculateJitter(uint32_t rtpTimestamp);
273
+ void CalculateJitter(uint32_t rtpTimestamp, int64_t receivedAtUs);
260
274
 
261
275
  void UpdateScore();
262
276
 
@@ -264,13 +278,13 @@ namespace RTC
264
278
  * Interpolate the capture instant of `ts` from a reference pair, all of them
265
279
  * expressed in the remote sender's wall clock.
266
280
  *
267
- * @param referenceNtpMs - Capture instant of `referenceTs`.
281
+ * @param referenceNtpUs - Capture instant of `referenceTs`.
268
282
  * @param referenceTs - RTP timestamp the reference instant refers to.
269
283
  * @param ts - RTP timestamp whose capture instant is wanted.
270
- * @param maxDistanceMs - How far `ts` may be from `referenceTs`.
284
+ * @param maxDistanceUs - How far `ts` may be from `referenceTs`.
271
285
  */
272
- std::optional<uint64_t> InterpolateRemoteCaptureMs(
273
- uint64_t referenceNtpMs, uint32_t referenceTs, uint32_t ts, uint64_t maxDistanceMs) const;
286
+ std::optional<int64_t> InterpolateRemoteCaptureAtUs(
287
+ int64_t referenceNtpUs, uint32_t referenceTs, uint32_t ts, int64_t maxDistanceUs) const;
274
288
 
275
289
  /* Pure virtual methods inherited from RTP::RtpStream. */
276
290
  public:
@@ -288,17 +302,17 @@ namespace RTC
288
302
 
289
303
  private:
290
304
  // Passed by argument.
291
- uint32_t sendNackDelayMs{ 0u };
305
+ int64_t sendNackDelayMs{ 0 };
292
306
  bool useRtpInactivityCheck{ false };
293
307
  // Others.
294
308
  // Packets expected at last interval.
295
- uint32_t expectedPrior{ 0u };
309
+ uint32_t expectedPrior{ 0 };
296
310
  // Packets expected at last interval for score calculation.
297
- uint32_t expectedPriorScore{ 0u };
311
+ uint32_t expectedPriorScore{ 0 };
298
312
  // Packets received at last interval.
299
- uint32_t receivedPrior{ 0u };
313
+ uint32_t receivedPrior{ 0 };
300
314
  // Packets received at last interval for score calculation.
301
- uint32_t receivedPriorScore{ 0u };
315
+ uint32_t receivedPriorScore{ 0 };
302
316
  // Timing data of the most recent Sender Report received.
303
317
  std::optional<SenderReportTiming> lastSenderReportTiming;
304
318
  // Most recent `abs-capture-time` RTP header extension received.
@@ -306,12 +320,16 @@ namespace RTC
306
320
  // Most recent RTP timestamp whose capture instant could be told, along with it.
307
321
  std::optional<CaptureMapping> lastCaptureMapping;
308
322
  // Relative transit time for prev packet.
309
- int32_t transit{ 0u };
310
- uint8_t firSeqNumber{ 0u };
323
+ int32_t transit{ 0 };
324
+ uint8_t firSeqNumber{ 0 };
311
325
  int32_t reportedPacketsLost{ 0 };
312
326
  std::unique_ptr<RTC::NackGenerator> nackGenerator;
313
327
  TimerHandleInterface* inactivityCheckPeriodicTimer{ nullptr };
314
328
  bool inactive{ false };
329
+ TimerHandleInterface* spatialLayersActivityCheckPeriodicTimer{ nullptr };
330
+ // Whether each spatial layer was carrying traffic at the latest check.
331
+ // Empty unless this stream has more than a spatial layer.
332
+ std::vector<bool> spatialLayersActivity;
315
333
  // Valid media + valid RTX.
316
334
  TransmissionCounter transmissionCounter;
317
335
  // Just valid media.