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
@@ -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
@@ -0,0 +1,106 @@
1
+ #ifndef MS_RTC_BWE_INTER_ARRIVAL_DELTA_HPP
2
+ #define MS_RTC_BWE_INTER_ARRIVAL_DELTA_HPP
3
+
4
+ #include "common.hpp"
5
+
6
+ namespace RTC
7
+ {
8
+ namespace BWE
9
+ {
10
+ /**
11
+ * Groups sent packets into send bursts and computes the deltas between two
12
+ * consecutive bursts.
13
+ *
14
+ * All packets sent within `sendTimeGroupLengthUs` of the first packet of a
15
+ * group belong to that group. This means that a burst of packets written
16
+ * into the socket at once produces a single sample rather than one per
17
+ * packet, which is what prevents a key frame being forwarded as a burst from
18
+ * being read as network congestion.
19
+ *
20
+ * The computed deltas are the input of the trendline estimator: if the
21
+ * arrival delta grows faster than the send delta then queues are building up
22
+ * somewhere in the network.
23
+ */
24
+ class InterArrivalDelta
25
+ {
26
+ public:
27
+ /**
28
+ * Deltas between two consecutive groups of packets sent in a burst.
29
+ */
30
+ struct Deltas
31
+ {
32
+ /**
33
+ * Time elapsed between the send times of both groups (us).
34
+ */
35
+ int64_t sendDeltaUs;
36
+
37
+ /**
38
+ * Time elapsed between the arrival times of both groups (us).
39
+ */
40
+ int64_t arrivalDeltaUs;
41
+
42
+ /**
43
+ * Difference of size between both groups (bytes).
44
+ */
45
+ int64_t sizeDelta;
46
+ };
47
+
48
+ private:
49
+ struct SendTimeGroup
50
+ {
51
+ bool IsFirstPacket() const
52
+ {
53
+ return !this->completeTimeUs.has_value();
54
+ }
55
+
56
+ size_t size{ 0 };
57
+ int64_t firstSendTimeUs{ 0 };
58
+ int64_t sendTimeUs{ 0 };
59
+ int64_t firstArrivalTimeUs{ 0 };
60
+ std::optional<int64_t> completeTimeUs;
61
+ int64_t lastFeedbackAtUs{ 0 };
62
+ };
63
+
64
+ public:
65
+ /**
66
+ * @param sendTimeGroupLengthUs - Every packet sent within this time of the
67
+ * first packet of a group belongs to that group.
68
+ */
69
+ explicit InterArrivalDelta(int64_t sendTimeGroupLengthUs);
70
+
71
+ /**
72
+ * Feed a sent packet whose arrival time is already known.
73
+ *
74
+ * @param sendTimeUs - Time at which the packet was sent.
75
+ * @param arrivalTimeUs - Time at which the packet arrived, in the remote
76
+ * clock reference.
77
+ * @param feedbackAtUs - Time, in our own clock reference, at which the
78
+ * RTCP feedback reporting this packet was received. It's the very same
79
+ * value for every packet within a given feedback, and it's used to
80
+ * detect that the remote clock has jumped by comparing how much it
81
+ * advanced against how much ours did.
82
+ * @param packetSize - Size of the packet (bytes).
83
+ *
84
+ * @returns The deltas between the two latest complete groups, or no value
85
+ * if they cannot be computed yet.
86
+ */
87
+ std::optional<Deltas> ComputeDeltas(
88
+ int64_t sendTimeUs, int64_t arrivalTimeUs, int64_t feedbackAtUs, size_t packetSize);
89
+
90
+ private:
91
+ bool IsNewSendTimeGroup(int64_t arrivalTimeUs, int64_t sendTimeUs) const;
92
+
93
+ bool BelongsToBurst(int64_t arrivalTimeUs, int64_t sendTimeUs) const;
94
+
95
+ void Reset();
96
+
97
+ private:
98
+ const int64_t sendTimeGroupLengthUs;
99
+ SendTimeGroup currentGroup;
100
+ SendTimeGroup prevGroup;
101
+ size_t numConsecutiveReorderedGroups{ 0 };
102
+ };
103
+ } // namespace BWE
104
+ } // namespace RTC
105
+
106
+ #endif
@@ -0,0 +1,84 @@
1
+ #ifndef MS_RTC_BWE_LINK_CAPACITY_ESTIMATOR_HPP
2
+ #define MS_RTC_BWE_LINK_CAPACITY_ESTIMATOR_HPP
3
+
4
+ #include "common.hpp"
5
+
6
+ namespace RTC
7
+ {
8
+ namespace BWE
9
+ {
10
+ /**
11
+ * Estimates the capacity of the link out of the bitrates at which
12
+ * congestion was observed.
13
+ *
14
+ * Every sample is fed into an exponential filter, and the variance of the
15
+ * estimate is tracked along with it so that a confidence interval can be
16
+ * derived. The rate control uses that interval to tell whether the measured
17
+ * throughput still has anything to do with the capacity it had estimated: a
18
+ * throughput outside of it means that the link changed, so the estimate is
19
+ * dropped instead of being slowly filtered towards the new reality.
20
+ */
21
+ class LinkCapacityEstimator
22
+ {
23
+ public:
24
+ /**
25
+ * Feed the bitrate at which the network started to be overused, which is
26
+ * an observation of where the capacity of the link is.
27
+ *
28
+ * @param ackedBitrate - Acknowledged bitrate when overuse was detected
29
+ * (bps).
30
+ */
31
+ void OnOveruseDetected(int64_t ackedBitrate);
32
+
33
+ /**
34
+ * Feed the bitrate measured by a probe. It's given far more weight than an
35
+ * overuse, since a probe measures the capacity of the link directly rather
36
+ * than inferring it from the delay.
37
+ *
38
+ * @param probeBitrate - Bitrate measured by the probe (bps).
39
+ */
40
+ void OnProbeRate(int64_t probeBitrate);
41
+
42
+ /**
43
+ * Current estimate of the capacity of the link (bps), or no value if
44
+ * nothing has been observed yet.
45
+ */
46
+ std::optional<int64_t> GetEstimate() const;
47
+
48
+ /**
49
+ * Upper end of the confidence interval of the estimate (bps), or
50
+ * `Types::BitrateInfinite` if there is no estimate yet.
51
+ */
52
+ int64_t GetUpperBound() const;
53
+
54
+ /**
55
+ * Lower end of the confidence interval of the estimate (bps), or 0 if
56
+ * there is no estimate yet.
57
+ */
58
+ int64_t GetLowerBound() const;
59
+
60
+ /**
61
+ * Drop the estimate, so that the next sample is taken as is instead of
62
+ * being filtered against a value that no longer holds.
63
+ */
64
+ void Reset();
65
+
66
+ private:
67
+ void Update(int64_t bitrate, double alpha);
68
+
69
+ /**
70
+ * Standard deviation of the estimate, derived from the normalized variance
71
+ * being tracked. Only meaningful once there is an estimate.
72
+ */
73
+ double GetDeviationEstimateKbps() const;
74
+
75
+ private:
76
+ // NOTE: The filter works in kbps as double since the bounds applied to the
77
+ // variance are calibrated in those units.
78
+ std::optional<double> estimateKbps;
79
+ double deviationKbps{ 0.4 };
80
+ };
81
+ } // namespace BWE
82
+ } // namespace RTC
83
+
84
+ #endif