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
@@ -0,0 +1,190 @@
1
+ #ifndef MS_RTC_BWE_AIMD_RATE_CONTROL_HPP
2
+ #define MS_RTC_BWE_AIMD_RATE_CONTROL_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/BweTypes.hpp"
6
+ #include "RTC/BWE/LinkCapacityEstimator.hpp"
7
+
8
+ namespace RTC
9
+ {
10
+ namespace BWE
11
+ {
12
+ /**
13
+ * Decides the target bitrate out of what the delay based detector says about
14
+ * the network.
15
+ *
16
+ * While no overuse is detected the bitrate is increased, multiplicatively
17
+ * when the capacity of the link is still unknown and additively once it has
18
+ * been estimated, since being close to the capacity makes a big step
19
+ * expensive. On overuse it is decreased to slightly below the measured
20
+ * throughput and held there until the queues of the network drain.
21
+ */
22
+ class AimdRateControl
23
+ {
24
+ public:
25
+ struct AimdRateControlOptions
26
+ {
27
+ /**
28
+ * Fraction of the measured throughput the bitrate is dropped to when
29
+ * overuse is detected.
30
+ */
31
+ double backoffFactor{ 0.85 };
32
+ /**
33
+ * Whether the bitrate is not allowed to increase while the sender is in
34
+ * an application limited region. In that region the network gives no
35
+ * feedback about whether a higher bitrate would have worked, so an
36
+ * increase cannot be validated.
37
+ */
38
+ bool noBitrateIncreaseInAlr{ false };
39
+ /**
40
+ * Whether the estimate of the link capacity is used as an upper bound.
41
+ */
42
+ bool estimateBoundedIncrease{ true };
43
+ /**
44
+ * Whether the current bitrate is taken as the lowest possible upper
45
+ * bound, so that an estimate of the link capacity below it does not
46
+ * drag the bitrate down.
47
+ */
48
+ bool useCurrentEstimateAsMinUpperBound{ true };
49
+ /**
50
+ * Whether this rate control runs in the endpoint that sends the media
51
+ * whose capacity is being estimated, rather than in the one that
52
+ * receives it. Only the sender can know that it's in an application
53
+ * limited region, so `noBitrateIncreaseInAlr` has no effect otherwise.
54
+ */
55
+ bool sendSide{ false };
56
+ };
57
+
58
+ private:
59
+ enum class RateControlState : uint8_t
60
+ {
61
+ HOLD,
62
+ INCREASE,
63
+ DECREASE
64
+ };
65
+
66
+ public:
67
+ AimdRateControl();
68
+
69
+ explicit AimdRateControl(AimdRateControlOptions options);
70
+
71
+ /**
72
+ * Whether the target bitrate has been initialized, which happens either
73
+ * when it's explicitly set or once a throughput has been measured for long
74
+ * enough.
75
+ */
76
+ bool IsValidEstimate() const
77
+ {
78
+ return this->bitrateIsInitialized;
79
+ }
80
+
81
+ /**
82
+ * Current target bitrate (bps).
83
+ */
84
+ int64_t GetLatestEstimate() const
85
+ {
86
+ return this->currentBitrate;
87
+ }
88
+
89
+ /**
90
+ * Feed what the delay based detector says about the network.
91
+ *
92
+ * @param input - State of the network plus the acknowledged bitrate.
93
+ * @param atTimeUs - Time at which the input was produced.
94
+ *
95
+ * @returns The new target bitrate (bps).
96
+ */
97
+ int64_t Update(const Types::RateControlInput& input, int64_t atTimeUs);
98
+
99
+ /**
100
+ * Set the target bitrate from outside the rate control, for instance out of
101
+ * the bitrate measured by a probe.
102
+ *
103
+ * @param bitrate - New target bitrate (bps).
104
+ */
105
+ void SetEstimate(int64_t bitrate, int64_t atTimeUs);
106
+
107
+ /**
108
+ * @param startBitrate - Bitrate to start from (bps).
109
+ */
110
+ void SetStartBitrate(int64_t startBitrate);
111
+
112
+ /**
113
+ * @param minBitrate - Bitrate the target is never taken below (bps).
114
+ */
115
+ void SetMinBitrate(int64_t minBitrate);
116
+
117
+ void SetRttUs(int64_t rttUs);
118
+
119
+ void SetInApplicationLimitedRegion(bool inAlr);
120
+
121
+ void SetNetworkStateEstimate(const std::optional<Types::NetworkStateEstimate>& estimate);
122
+
123
+ /**
124
+ * Whether the bitrate can be reduced again, which requires that it has not
125
+ * been changed for more than an RTT or that the throughput has fallen well
126
+ * below the current target. It's what keeps a single overuse from
127
+ * collapsing the bitrate in a few milliseconds.
128
+ */
129
+ bool IsTimeToReduceFurther(int64_t atTimeUs, int64_t estimatedThroughput) const;
130
+
131
+ /**
132
+ * As above, to be used when overusing before any throughput has been
133
+ * measured.
134
+ */
135
+ bool IsInitialTimeToReduceFurther(int64_t atTimeUs) const;
136
+
137
+ /**
138
+ * Rate at which the bitrate is increased once it's close to the capacity of
139
+ * the link (bps per second).
140
+ */
141
+ double GetNearMaxIncreaseRateBpsPerSecond() const;
142
+
143
+ /**
144
+ * How often feedback can be sent while devoting no more than 5% of the
145
+ * current bitrate to it.
146
+ */
147
+ int64_t GetFeedbackIntervalUs() const;
148
+
149
+ private:
150
+ void ChangeBitrate(const Types::RateControlInput& input, int64_t atTimeUs);
151
+
152
+ void ChangeState(const Types::RateControlInput& input, int64_t atTimeUs);
153
+
154
+ /**
155
+ * Apply the configured bounds to a candidate bitrate.
156
+ */
157
+ int64_t ClampBitrate(int64_t newBitrate) const;
158
+
159
+ /**
160
+ * Increase used while the capacity of the link is unknown, which ramps up
161
+ * fast to discover it.
162
+ */
163
+ int64_t MultiplicativeRateIncrease(
164
+ int64_t atTimeUs, std::optional<int64_t> lastTimeUs, int64_t currentBitrate) const;
165
+
166
+ /**
167
+ * Increase used once the capacity of the link has been estimated, which
168
+ * approaches it in small steps.
169
+ */
170
+ int64_t AdditiveRateIncrease(int64_t atTimeUs, int64_t lastTimeUs) const;
171
+
172
+ private:
173
+ const AimdRateControlOptions options;
174
+ int64_t minConfiguredBitrate;
175
+ int64_t maxConfiguredBitrate;
176
+ int64_t currentBitrate;
177
+ int64_t latestEstimatedThroughput;
178
+ LinkCapacityEstimator linkCapacity;
179
+ std::optional<Types::NetworkStateEstimate> networkEstimate;
180
+ RateControlState rateControlState{ RateControlState::HOLD };
181
+ std::optional<int64_t> timeLastBitrateChangeUs;
182
+ std::optional<int64_t> timeFirstThroughputEstimateUs;
183
+ bool bitrateIsInitialized{ false };
184
+ bool inAlr{ false };
185
+ int64_t rttUs;
186
+ };
187
+ } // namespace BWE
188
+ } // namespace RTC
189
+
190
+ #endif
@@ -0,0 +1,211 @@
1
+ #ifndef MS_RTC_BWE_BWE_TYPES_HPP
2
+ #define MS_RTC_BWE_BWE_TYPES_HPP
3
+
4
+ #include "common.hpp"
5
+ #include <limits>
6
+ #include <string_view>
7
+ #include <vector>
8
+
9
+ namespace RTC
10
+ {
11
+ namespace BWE
12
+ {
13
+ namespace Types
14
+ {
15
+ /**
16
+ * Bitrate meaning that there is no limit at all (bps).
17
+ */
18
+ constexpr int64_t BitrateInfinite{ std::numeric_limits<int64_t>::max() };
19
+
20
+ /**
21
+ * Time meaning that no time was ever assigned.
22
+ */
23
+ constexpr int64_t TimeUsInfinite{ std::numeric_limits<int64_t>::max() };
24
+
25
+ /**
26
+ * How the network is behaving according to the delay based detector.
27
+ */
28
+ enum class BandwidthUsage : uint8_t
29
+ {
30
+ /**
31
+ * Queues are not growing.
32
+ */
33
+ NORMAL,
34
+ /**
35
+ * Queues are being emptied, so we are sending below the link capacity.
36
+ */
37
+ UNDERUSING,
38
+ /**
39
+ * Queues are filling up, so we are sending above the link capacity.
40
+ */
41
+ OVERUSING
42
+ };
43
+
44
+ constexpr std::string_view bandwidthUsageToString(BandwidthUsage bandwidthUsage)
45
+ {
46
+ switch (bandwidthUsage)
47
+ {
48
+ case BandwidthUsage::NORMAL:
49
+ {
50
+ return "NORMAL";
51
+ }
52
+
53
+ case BandwidthUsage::UNDERUSING:
54
+ {
55
+ return "UNDERUSING";
56
+ }
57
+
58
+ case BandwidthUsage::OVERUSING:
59
+ {
60
+ return "OVERUSING";
61
+ }
62
+
63
+ NO_DEFAULT_GCC();
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Estimate of the capacity of the link, used to bound the rate control.
69
+ */
70
+ struct NetworkStateEstimate
71
+ {
72
+ /**
73
+ * Safe measure of the available capacity (bps).
74
+ */
75
+ std::optional<int64_t> linkCapacityLower;
76
+ /**
77
+ * Limit applied when increasing the bitrate (bps).
78
+ */
79
+ std::optional<int64_t> linkCapacityUpper;
80
+ };
81
+
82
+ /**
83
+ * Input given to the rate control on every update.
84
+ */
85
+ struct RateControlInput
86
+ {
87
+ /**
88
+ * How the network is behaving according to the delay based detector.
89
+ */
90
+ BandwidthUsage bandwidthUsage;
91
+ /**
92
+ * Bitrate acknowledged by the receiver (bps), or no value if it could
93
+ * not be measured.
94
+ */
95
+ std::optional<int64_t> estimatedThroughput;
96
+ };
97
+
98
+ /**
99
+ * A packet that was sent and is being tracked until its feedback arrives.
100
+ */
101
+ struct SentPacket
102
+ {
103
+ /**
104
+ * Sequence number of the packet within the transport, unique over the
105
+ * whole transport and increasing by one per tracked packet.
106
+ *
107
+ * @remarks
108
+ * - It's independent of the feedback format. With transport-cc it
109
+ * matches the wide sequence number carried in the header extension,
110
+ * while with RFC 8888 the feedback identifies packets by SSRC and RTP
111
+ * sequence number and the adapter resolves them against this one.
112
+ */
113
+ int64_t sequenceNumber;
114
+ /**
115
+ * Time at which the packet was sent, or `Types::TimeUsInfinite` if it was
116
+ * never assigned one.
117
+ */
118
+ int64_t sendTimeUs{ TimeUsInfinite };
119
+ /**
120
+ * Size of the packet including overhead up to the IP layer (bytes).
121
+ */
122
+ size_t size{ 0 };
123
+ /**
124
+ * Size of the preceding packets that are not part of any feedback
125
+ * (bytes).
126
+ */
127
+ size_t priorUnackedData{ 0 };
128
+ /**
129
+ * Data that was in flight when the packet was sent, itself included and
130
+ * the data that no feedback covers excluded (bytes).
131
+ */
132
+ size_t dataInFlight{ 0 };
133
+ /**
134
+ * Whether it's an audio packet. False for video, padding and RTX.
135
+ */
136
+ bool audio{ false };
137
+ };
138
+
139
+ /**
140
+ * What a feedback reported about a single sent packet.
141
+ */
142
+ struct PacketResult
143
+ {
144
+ /**
145
+ * Orders packets by the time at which they arrived.
146
+ *
147
+ * @remarks
148
+ * - Send time and sequence number break the ties, which are common
149
+ * because the arrival times within a burst are reported with a coarse
150
+ * resolution.
151
+ */
152
+ struct ReceiveTimeOrder
153
+ {
154
+ bool operator()(const PacketResult& lhs, const PacketResult& rhs) const;
155
+ };
156
+
157
+ /**
158
+ * Whether the packet reached the receiver at all.
159
+ */
160
+ bool IsReceived() const
161
+ {
162
+ return this->receiveTimeUs.has_value();
163
+ }
164
+
165
+ SentPacket sentPacket;
166
+ /**
167
+ * Time at which the packet arrived, in the remote clock reference, or no
168
+ * value if it was reported as lost.
169
+ */
170
+ std::optional<int64_t> receiveTimeUs;
171
+ };
172
+
173
+ /**
174
+ * A whole feedback message, reporting on the packets sent so far.
175
+ */
176
+ struct TransportPacketsFeedback
177
+ {
178
+ /**
179
+ * The packets that reached the receiver, ordered by arrival time.
180
+ *
181
+ * @remarks
182
+ * - Send time and sequence number break the ties, which are common
183
+ * because the arrival times within a burst are reported with a coarse
184
+ * resolution.
185
+ */
186
+ std::vector<PacketResult> SortedByReceiveTime() const;
187
+
188
+ /**
189
+ * The packets that reached the receiver, in the order they were
190
+ * reported.
191
+ */
192
+ std::vector<PacketResult> ReceivedWithSendInfo() const;
193
+
194
+ /**
195
+ * Time at which this feedback was received, in our own clock reference.
196
+ */
197
+ int64_t feedbackTimeUs;
198
+ /**
199
+ * Data that was sent and no feedback has reported on yet (bytes).
200
+ */
201
+ size_t dataInFlight{ 0 };
202
+ /**
203
+ * Every packet the feedback reports on, received and lost alike.
204
+ */
205
+ std::vector<PacketResult> packetFeedbacks;
206
+ };
207
+ } // namespace Types
208
+ } // namespace BWE
209
+ } // namespace RTC
210
+
211
+ #endif
@@ -0,0 +1,173 @@
1
+ #ifndef MS_RTC_BWE_DELAY_BASED_BWE_HPP
2
+ #define MS_RTC_BWE_DELAY_BASED_BWE_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/AimdRateControl.hpp"
6
+ #include "RTC/BWE/BweTypes.hpp"
7
+ #include "RTC/BWE/InterArrivalDelta.hpp"
8
+ #include "RTC/BWE/TrendlineEstimator.hpp"
9
+
10
+ namespace RTC
11
+ {
12
+ namespace BWE
13
+ {
14
+ /**
15
+ * Estimates the available bitrate out of the delay between the packets that
16
+ * were sent and the feedback reporting when they arrived.
17
+ *
18
+ * It's the glue of the delay based path: the packets of each feedback are
19
+ * grouped into send bursts, the delay between consecutive groups feeds the
20
+ * trendline detector, and what the detector says about the network drives
21
+ * the rate control.
22
+ */
23
+ class DelayBasedBwe
24
+ {
25
+ public:
26
+ struct DelayBasedBweOptions
27
+ {
28
+ /**
29
+ * Whether audio and video get a delay detector of their own instead of
30
+ * sharing one.
31
+ */
32
+ bool separateAudioPackets{ false };
33
+ /**
34
+ * Number of audio packets without a video one after which the audio
35
+ * detector becomes the active one.
36
+ *
37
+ * @remarks
38
+ * - Only used when `separateAudioPackets` is set.
39
+ */
40
+ int64_t separateAudioPacketThreshold{ 10 };
41
+ /**
42
+ * Time without a video packet after which the audio detector becomes
43
+ * the active one.
44
+ *
45
+ * @remarks
46
+ * - Only used when `separateAudioPackets` is set.
47
+ */
48
+ int64_t separateAudioTimeThresholdUs{ 1000 * 1000 };
49
+ };
50
+
51
+ struct Result
52
+ {
53
+ /**
54
+ * Whether the target bitrate was recomputed.
55
+ */
56
+ bool updated{ false };
57
+ /**
58
+ * Whether the target bitrate comes from the bitrate measured by a
59
+ * probe.
60
+ */
61
+ bool probe{ false };
62
+ /**
63
+ * Target bitrate (bps).
64
+ */
65
+ int64_t targetBitrate{ 0 };
66
+ /**
67
+ * Whether the detector went back to normal after having been
68
+ * underusing.
69
+ */
70
+ bool recoveredFromOveruse{ false };
71
+ /**
72
+ * What the delay based detector says about the network.
73
+ */
74
+ Types::BandwidthUsage delayDetectorState{ Types::BandwidthUsage::NORMAL };
75
+ };
76
+
77
+ public:
78
+ DelayBasedBwe();
79
+
80
+ explicit DelayBasedBwe(DelayBasedBweOptions options);
81
+
82
+ /**
83
+ * Feed a whole feedback message.
84
+ *
85
+ * @param feedback - What the receiver reported about the packets sent so
86
+ * far.
87
+ * @param ackedBitrate - Bitrate acknowledged by the receiver (bps), or no
88
+ * value if it could not be measured.
89
+ * @param probeBitrate - Bitrate measured by a probe (bps), or no value if
90
+ * no probe was completed.
91
+ * @param networkEstimate - Estimate of the capacity of the link, used to
92
+ * bound the rate control.
93
+ * @param inAlr - Whether the sender is in an application limited region.
94
+ */
95
+ Result IncomingPacketFeedbackVector(
96
+ const Types::TransportPacketsFeedback& feedback,
97
+ std::optional<int64_t> ackedBitrate,
98
+ std::optional<int64_t> probeBitrate,
99
+ const std::optional<Types::NetworkStateEstimate>& networkEstimate,
100
+ bool inAlr);
101
+
102
+ void OnRttUpdate(int64_t avgRttUs);
103
+
104
+ /**
105
+ * @param startBitrate - Bitrate to start from (bps).
106
+ */
107
+ void SetStartBitrate(int64_t startBitrate);
108
+
109
+ /**
110
+ * @param minBitrate - Bitrate the target is never taken below (bps).
111
+ */
112
+ void SetMinBitrate(int64_t minBitrate);
113
+
114
+ /**
115
+ * Current target bitrate of the rate control (bps), or no value if there
116
+ * is no valid estimate yet.
117
+ *
118
+ * @remarks
119
+ * - Unlike `GetLastEstimate()`, this is what the rate control holds right
120
+ * now rather than the latest value that was reported.
121
+ */
122
+ std::optional<int64_t> GetLatestEstimate() const;
123
+
124
+ /**
125
+ * Latest target bitrate that was reported (bps).
126
+ */
127
+ int64_t GetLastEstimate() const
128
+ {
129
+ return this->prevBitrate;
130
+ }
131
+
132
+ /**
133
+ * Latest state of the delay based detector that was reported.
134
+ */
135
+ Types::BandwidthUsage GetLastState() const
136
+ {
137
+ return this->prevState;
138
+ }
139
+
140
+ private:
141
+ void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t atTimeUs);
142
+
143
+ Result MaybeUpdateEstimate(
144
+ std::optional<int64_t> ackedBitrate,
145
+ std::optional<int64_t> probeBitrate,
146
+ bool recoveredFromOveruse,
147
+ int64_t atTimeUs);
148
+
149
+ /**
150
+ * Recompute the target bitrate.
151
+ *
152
+ * @returns Whether there is a valid estimate.
153
+ */
154
+ bool UpdateEstimate(int64_t atTimeUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate);
155
+
156
+ private:
157
+ const DelayBasedBweOptions options;
158
+ int64_t audioPacketsSinceLastVideo{ 0 };
159
+ std::optional<int64_t> lastVideoPacketRecvTimeUs;
160
+ std::optional<InterArrivalDelta> videoInterArrivalDelta;
161
+ std::optional<InterArrivalDelta> audioInterArrivalDelta;
162
+ std::optional<TrendlineEstimator> videoDelayDetector;
163
+ std::optional<TrendlineEstimator> audioDelayDetector;
164
+ TrendlineEstimator* activeDelayDetector{ nullptr };
165
+ std::optional<int64_t> lastSeenPacketUs;
166
+ AimdRateControl rateControl;
167
+ int64_t prevBitrate{ 0 };
168
+ Types::BandwidthUsage prevState{ Types::BandwidthUsage::NORMAL };
169
+ };
170
+ } // namespace BWE
171
+ } // namespace RTC
172
+
173
+ #endif
@@ -0,0 +1,72 @@
1
+ #ifndef MS_RTC_BWE_FEEDBACK_ADAPTER_HPP
2
+ #define MS_RTC_BWE_FEEDBACK_ADAPTER_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/BWE/BweTypes.hpp"
6
+ #include "RTC/BWE/SendPacketHistory.hpp"
7
+ #include "RTC/RTCP/FeedbackRtpTransport.hpp"
8
+
9
+ namespace RTC
10
+ {
11
+ namespace BWE
12
+ {
13
+ /**
14
+ * Turns a feedback message into what it reports about the packets that were
15
+ * sent, resolved against the history of sent packets.
16
+ *
17
+ * It's the only place that knows what a feedback looks like, so that
18
+ * supporting another format is a matter of adding another method here.
19
+ *
20
+ * The arrival times a feedback carries come from the remote clock, against
21
+ * a base time that wraps around, so they are unusable as they are. The
22
+ * first feedback is anchored on the time it was received and every later
23
+ * one advances that anchor by the elapsed base time, which puts the arrival
24
+ * times of all of them on a single timeline. Only their differences matter
25
+ * downstream.
26
+ *
27
+ * @see https://datatracker.ietf.org/doc/html/draft-holmer-rmcat-transport-wide-cc-extensions
28
+ * @see https://datatracker.ietf.org/doc/html/rfc8888
29
+ */
30
+ class FeedbackAdapter
31
+ {
32
+ public:
33
+ explicit FeedbackAdapter(SendPacketHistory* sendPacketHistory);
34
+
35
+ /**
36
+ * Process a transport-cc feedback.
37
+ *
38
+ * @param receivedAtUs - Time at which the feedback was received.
39
+ * @returns What the feedback reports about the packets that were sent, in
40
+ * the order it reports them, or no value if it reports on no packet the
41
+ * history still holds.
42
+ */
43
+ std::optional<Types::TransportPacketsFeedback> ProcessTransportFeedback(
44
+ const RTCP::FeedbackRtpTransportPacket* feedback, int64_t receivedAtUs);
45
+
46
+ private:
47
+ /**
48
+ * Recover the sequence number the history gave to a packet out of the
49
+ * lowest bits of it that the wire carries.
50
+ *
51
+ * @param previousSequenceNumber - Sequence number the previous packet the
52
+ * feedback reported on resolved into, which the returned one is the
53
+ * closest to.
54
+ */
55
+ static int64_t UnwrapSequenceNumber(uint16_t wideSequenceNumber, int64_t previousSequenceNumber);
56
+
57
+ private:
58
+ SendPacketHistory* const sendPacketHistory;
59
+ // Our own time the arrival times of the current feedback are given
60
+ // against.
61
+ int64_t currentOffsetUs{ 0 };
62
+ // Base time of the latest feedback processed, in the remote clock, or no
63
+ // value if no feedback was ever processed.
64
+ std::optional<int64_t> lastFeedbackBaseTimeUs;
65
+ // Sequence number the latest packet reported on resolved into, or no
66
+ // value if no feedback was ever processed.
67
+ std::optional<int64_t> lastUnwrappedSequenceNumber;
68
+ };
69
+ } // namespace BWE
70
+ } // namespace RTC
71
+
72
+ #endif