mediasoup 3.28.0 → 3.29.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 (155) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/node/lib/PipeTransportTypes.d.ts +6 -1
  3. package/node/lib/PipeTransportTypes.d.ts.map +1 -1
  4. package/node/lib/PlainTransportTypes.d.ts +6 -1
  5. package/node/lib/PlainTransportTypes.d.ts.map +1 -1
  6. package/node/lib/Router.d.ts +4 -4
  7. package/node/lib/Router.d.ts.map +1 -1
  8. package/node/lib/Router.js +10 -7
  9. package/node/lib/RouterTypes.d.ts +7 -1
  10. package/node/lib/RouterTypes.d.ts.map +1 -1
  11. package/node/lib/Transport.d.ts +2 -1
  12. package/node/lib/Transport.d.ts.map +1 -1
  13. package/node/lib/Transport.js +17 -6
  14. package/node/lib/TransportTypes.d.ts +12 -2
  15. package/node/lib/TransportTypes.d.ts.map +1 -1
  16. package/node/lib/WebRtcTransportTypes.d.ts +6 -1
  17. package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
  18. package/node/lib/fbs/transport/options.d.ts +6 -2
  19. package/node/lib/fbs/transport/options.d.ts.map +1 -1
  20. package/node/lib/fbs/transport/options.js +19 -7
  21. package/node/lib/fbs/transport/sctp-zero-checksum.d.ts +6 -0
  22. package/node/lib/fbs/transport/sctp-zero-checksum.d.ts.map +1 -0
  23. package/node/lib/fbs/transport/sctp-zero-checksum.js +11 -0
  24. package/node/lib/fbs/transport/stats.d.ts +2 -8
  25. package/node/lib/fbs/transport/stats.d.ts.map +1 -1
  26. package/node/lib/fbs/transport/stats.js +5 -29
  27. package/node/lib/fbs/transport.d.ts +1 -0
  28. package/node/lib/fbs/transport.d.ts.map +1 -1
  29. package/node/lib/fbs/transport.js +4 -2
  30. package/npm-scripts.mjs +35 -44
  31. package/package.json +10 -6
  32. package/worker/fbs/transport.fbs +9 -2
  33. package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +14 -1
  34. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +17 -4
  35. package/worker/include/RTC/BWE/AimdRateControl.hpp +9 -9
  36. package/worker/include/RTC/BWE/BweTypes.hpp +54 -17
  37. package/worker/include/RTC/BWE/DelayBasedBwe.hpp +3 -3
  38. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +2 -2
  39. package/worker/include/RTC/BWE/LossBasedController.hpp +4 -4
  40. package/worker/include/RTC/BWE/OveruseDetector.hpp +5 -4
  41. package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +1 -1
  42. package/worker/include/RTC/BWE/ProbeController.hpp +6 -6
  43. package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +2 -6
  44. package/worker/include/RTC/BWE/ProbingScheduler.hpp +3 -7
  45. package/worker/include/RTC/BWE/ReceiverTransportCongestionController.hpp +148 -0
  46. package/worker/include/RTC/BWE/RembGenerator.hpp +4 -3
  47. package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +1 -1
  48. package/worker/include/RTC/BWE/SenderTransportCongestionController.hpp +343 -0
  49. package/worker/include/RTC/BWE/TargetRateController.hpp +4 -1
  50. package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +5 -4
  51. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +3 -3
  52. package/worker/include/RTC/Consumer.hpp +8 -1
  53. package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +36 -10
  54. package/worker/include/RTC/RTP/RtpStream.hpp +21 -0
  55. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +1 -0
  56. package/worker/include/RTC/RTP/RtpStreamSend.hpp +122 -9
  57. package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +12 -3
  58. package/worker/include/RTC/TransportCongestionControlClient.hpp +0 -5
  59. package/worker/include/RTC/TransportCongestionControlServer.hpp +0 -5
  60. package/worker/include/Utils.hpp +9 -2
  61. package/worker/meson.build +4 -0
  62. package/worker/src/RTC/BWE/AimdRateControl.cpp +22 -22
  63. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +16 -20
  64. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +1 -1
  65. package/worker/src/RTC/BWE/OveruseDetector.cpp +8 -8
  66. package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +2 -2
  67. package/worker/src/RTC/BWE/ProbeController.cpp +1 -1
  68. package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +1 -6
  69. package/worker/src/RTC/BWE/ProbingScheduler.cpp +2 -7
  70. package/worker/src/RTC/BWE/ReceiverTransportCongestionController.cpp +207 -0
  71. package/worker/src/RTC/BWE/RembGenerator.cpp +1 -1
  72. package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +1 -1
  73. package/worker/src/RTC/BWE/SenderTransportCongestionController.cpp +599 -0
  74. package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +2 -3
  75. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +5 -5
  76. package/worker/src/RTC/Consumer.cpp +3 -2
  77. package/worker/src/RTC/DataConsumer.cpp +2 -2
  78. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +21 -8
  79. package/worker/src/RTC/RTP/RtpStream.cpp +0 -3
  80. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +57 -71
  81. package/worker/src/RTC/RTP/RtpStreamSend.cpp +428 -244
  82. package/worker/src/RTC/RTP/RtxStream.cpp +14 -19
  83. package/worker/src/RTC/SCTP/association/Association.cpp +3 -2
  84. package/worker/src/RTC/SCTP/association/StateCookie.cpp +26 -6
  85. package/worker/src/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.cpp +4 -3
  86. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
  87. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +4 -2
  88. package/worker/src/RTC/Transport.cpp +49 -20
  89. package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -66
  90. package/worker/src/RTC/TransportCongestionControlServer.cpp +0 -55
  91. package/worker/src/Utils/Crypto.cpp +114 -98
  92. package/worker/subprojects/catch2.wrap +6 -6
  93. package/worker/subprojects/openssl.wrap +11 -12
  94. package/worker/subprojects/packagefiles/ankerl-unordered-dense/meson.build +1 -1
  95. package/worker/subprojects/unordered-dense.wrap +4 -4
  96. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +5 -5
  97. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +26 -23
  98. package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +8 -8
  99. package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +4 -4
  100. package/worker/test/src/RTC/BWE/TestProbeController.cpp +35 -32
  101. package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +2 -17
  102. package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +1 -25
  103. package/worker/test/src/RTC/BWE/TestReceiverTransportCongestionController.cpp +346 -0
  104. package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +1 -1
  105. package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +9 -9
  106. package/worker/test/src/RTC/BWE/TestSenderTransportCongestionController.cpp +510 -0
  107. package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +16 -14
  108. package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +6 -6
  109. package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +1 -2
  110. package/worker/test/src/RTC/RTCP/TestBye.cpp +1 -1
  111. package/worker/test/src/RTC/RTCP/TestFeedbackPsAfb.cpp +1 -1
  112. package/worker/test/src/RTC/RTCP/TestFeedbackPsFir.cpp +1 -1
  113. package/worker/test/src/RTC/RTCP/TestFeedbackPsLei.cpp +1 -1
  114. package/worker/test/src/RTC/RTCP/TestFeedbackPsPli.cpp +1 -1
  115. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
  116. package/worker/test/src/RTC/RTCP/TestFeedbackPsRpsi.cpp +1 -1
  117. package/worker/test/src/RTC/RTCP/TestFeedbackPsSli.cpp +1 -1
  118. package/worker/test/src/RTC/RTCP/TestFeedbackPsTst.cpp +1 -1
  119. package/worker/test/src/RTC/RTCP/TestFeedbackPsVbcm.cpp +1 -1
  120. package/worker/test/src/RTC/RTCP/TestFeedbackRtpEcn.cpp +1 -1
  121. package/worker/test/src/RTC/RTCP/TestFeedbackRtpNack.cpp +1 -1
  122. package/worker/test/src/RTC/RTCP/TestFeedbackRtpSrReq.cpp +1 -1
  123. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTllei.cpp +1 -1
  124. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
  125. package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +1 -1
  126. package/worker/test/src/RTC/RTCP/TestReceiverReport.cpp +1 -1
  127. package/worker/test/src/RTC/RTCP/TestSenderReport.cpp +1 -1
  128. package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +60 -28
  129. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +1 -1
  130. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +746 -24
  131. package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
  132. package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +42 -0
  133. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +54 -5
  134. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +80 -15
  135. package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +410 -3
  136. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +1 -1
  137. package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +37 -5
  138. package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +5 -4
  139. package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +1 -1
  140. package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
  141. package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +1 -1
  142. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1 -1
  143. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +11 -10
  144. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +1 -1
  145. package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
  146. package/worker/test/src/RTC/TestPortManager.cpp +2 -2
  147. package/worker/test/src/RTC/TestRateCalculator.cpp +1 -1
  148. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +21 -15
  149. package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +13 -13
  150. package/worker/test/src/RTC/TestRtpEncodingParameters.cpp +1 -1
  151. package/worker/test/src/RTC/TestSubchannelsCodec.cpp +2 -2
  152. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +1 -1
  153. package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
  154. package/worker/test/src/Utils/TestCrypto.cpp +71 -2
  155. package/worker/test/src/Utils/TestTime.cpp +2 -2
@@ -30,7 +30,7 @@ namespace RTC
30
30
  /* Instance methods. */
31
31
 
32
32
  Types::BandwidthUsage OveruseDetector::Detect(
33
- double offsetMs, double sendDeltaMs, int64_t numOfDeltas, int64_t nowUs)
33
+ double offsetMs, double sendDeltaMs, int64_t numOfDeltas, int64_t arrivalTimeUs)
34
34
  {
35
35
  MS_TRACE();
36
36
 
@@ -86,25 +86,25 @@ namespace RTC
86
86
 
87
87
  this->prevOffsetMs = offsetMs;
88
88
 
89
- UpdateThreshold(modifiedOffsetMs, nowUs);
89
+ UpdateThreshold(modifiedOffsetMs, arrivalTimeUs);
90
90
 
91
91
  return this->state;
92
92
  }
93
93
 
94
- void OveruseDetector::UpdateThreshold(double modifiedOffsetMs, int64_t nowUs)
94
+ void OveruseDetector::UpdateThreshold(double modifiedOffsetMs, int64_t arrivalTimeUs)
95
95
  {
96
96
  MS_TRACE();
97
97
 
98
- if (!this->lastThresholdUpdateAtUs.has_value())
98
+ if (!this->lastSampleArrivalTimeUs.has_value())
99
99
  {
100
- this->lastThresholdUpdateAtUs = nowUs;
100
+ this->lastSampleArrivalTimeUs = arrivalTimeUs;
101
101
  }
102
102
 
103
103
  // Avoid adapting the threshold to big latency spikes, caused for instance
104
104
  // by a sudden capacity drop.
105
105
  if (std::fabs(modifiedOffsetMs) > this->threshold + MaxAdaptOffsetMs)
106
106
  {
107
- this->lastThresholdUpdateAtUs = nowUs;
107
+ this->lastSampleArrivalTimeUs = arrivalTimeUs;
108
108
 
109
109
  return;
110
110
  }
@@ -116,13 +116,13 @@ namespace RTC
116
116
  // NOTE: The coefficients above are rates per millisecond, so the step is
117
117
  // expressed in those units no matter that the instants are microseconds.
118
118
  const double elapsedMs = std::min(
119
- static_cast<double>(nowUs - this->lastThresholdUpdateAtUs.value()) / 1000.0,
119
+ static_cast<double>(arrivalTimeUs - this->lastSampleArrivalTimeUs.value()) / 1000.0,
120
120
  MaxThresholdUpdateDeltaMs);
121
121
 
122
122
  this->threshold += coef * (std::fabs(modifiedOffsetMs) - this->threshold) * elapsedMs;
123
123
  this->threshold = std::clamp(this->threshold, ThresholdMin, ThresholdMax);
124
124
 
125
- this->lastThresholdUpdateAtUs = nowUs;
125
+ this->lastSampleArrivalTimeUs = arrivalTimeUs;
126
126
  }
127
127
  } // namespace BWE
128
128
  } // namespace RTC
@@ -200,7 +200,7 @@ namespace RTC
200
200
  return estimatedBitrate;
201
201
  }
202
202
 
203
- void ProbeBitrateEstimator::EraseOldClusters(int64_t nowUs)
203
+ void ProbeBitrateEstimator::EraseOldClusters(int64_t arrivalTimeUs)
204
204
  {
205
205
  MS_TRACE();
206
206
 
@@ -208,7 +208,7 @@ namespace RTC
208
208
  {
209
209
  const auto& cluster = it->second;
210
210
 
211
- if (cluster.lastReceiveTimeUs.has_value() && cluster.lastReceiveTimeUs.value() + MaxClusterHistoryUs < nowUs)
211
+ if (cluster.lastReceiveTimeUs.has_value() && cluster.lastReceiveTimeUs.value() + MaxClusterHistoryUs < arrivalTimeUs)
212
212
  {
213
213
  it = this->clusters.erase(it);
214
214
  }
@@ -535,7 +535,7 @@ namespace RTC
535
535
  {
536
536
  MS_TRACE();
537
537
 
538
- if (!this->enablePeriodicAlrProbing || !this->alrStartTimeUs.has_value())
538
+ if (!this->options.enablePeriodicAlrProbing || !this->alrStartTimeUs.has_value())
539
539
  {
540
540
  return false;
541
541
  }
@@ -128,12 +128,7 @@ namespace RTC
128
128
 
129
129
  remaining -= std::min(remaining, length);
130
130
 
131
- if (!this->listener->OnProbePacketGeneratorSendRtpPacket(this, this->packet.get()))
132
- {
133
- MS_DEBUG_DEV("burst given up on, %zu bytes were left", remaining);
134
-
135
- break;
136
- }
131
+ this->listener->OnProbePacketGeneratorSendRtpPacket(this, this->packet.get());
137
132
  }
138
133
  }
139
134
  } // namespace BWE
@@ -64,21 +64,16 @@ namespace RTC
64
64
  this->nextProbeTimer->Restart(0);
65
65
  }
66
66
 
67
- bool ProbingScheduler::OnProbePacketGeneratorSendRtpPacket(
67
+ void ProbingScheduler::OnProbePacketGeneratorSendRtpPacket(
68
68
  ProbePacketGenerator* /*probePacketGenerator*/, RTC::RTP::Packet* packet)
69
69
  {
70
70
  MS_TRACE();
71
71
 
72
- if (!this->listener->OnProbingSchedulerSendRtpPacket(this, packet, this->shotProbeCluster))
73
- {
74
- return false;
75
- }
72
+ this->listener->OnProbingSchedulerSendRtpPacket(this, packet, this->shotProbeCluster);
76
73
 
77
74
  // What the burst is measured against is what the link has to carry, which
78
75
  // is more than what the packet itself is worth.
79
76
  this->shotSentBytes += packet->GetLength() + this->packetOverhead;
80
-
81
- return true;
82
77
  }
83
78
 
84
79
  void ProbingScheduler::OnTimer(TimerHandleInterface* timer)
@@ -0,0 +1,207 @@
1
+ #define MS_CLASS "RTC::BWE::ReceiverTransportCongestionController"
2
+ // #define MS_LOG_DEV_LEVEL 3
3
+
4
+ #include "RTC/BWE/ReceiverTransportCongestionController.hpp"
5
+ #include "Logger.hpp"
6
+
7
+ namespace RTC
8
+ {
9
+ namespace BWE
10
+ {
11
+ /* Instance methods. */
12
+
13
+ ReceiverTransportCongestionController::ReceiverTransportCongestionController(
14
+ Listener* listener, SharedInterface* shared, ReceiverTransportCongestionControllerOptions options)
15
+ : options(options), listener(listener), shared(shared), rembGenerator(this)
16
+ {
17
+ MS_TRACE();
18
+
19
+ MS_ASSERT(
20
+ this->options.congestionControlType == Types::CongestionControlType::TRANSPORT_CC ||
21
+ this->options.congestionControlType == Types::CongestionControlType::REMB,
22
+ "no congestion control type given");
23
+
24
+ switch (this->options.congestionControlType)
25
+ {
26
+ case Types::CongestionControlType::TRANSPORT_CC:
27
+ {
28
+ this->transportWideCcFeedbackGenerator = std::make_unique<TransportWideCcFeedbackGenerator>(
29
+ this, this->shared, this->options.maxRtcpPacketLen);
30
+
31
+ break;
32
+ }
33
+
34
+ case Types::CongestionControlType::REMB:
35
+ {
36
+ this->remoteBitrateEstimator = std::make_unique<RemoteBitrateEstimatorAbsSendTime>(this);
37
+
38
+ break;
39
+ }
40
+
41
+ NO_DEFAULT();
42
+ }
43
+ }
44
+
45
+ void ReceiverTransportCongestionController::ReceiveRtpPacket(
46
+ int64_t receivedAtUs, const RTC::RTP::Packet* packet, RTC::Media::Kind kind)
47
+ {
48
+ MS_TRACE();
49
+
50
+ switch (this->options.congestionControlType)
51
+ {
52
+ case Types::CongestionControlType::TRANSPORT_CC:
53
+ {
54
+ this->transportWideCcFeedbackGenerator->ReceiveRtpPacket(receivedAtUs, packet);
55
+
56
+ break;
57
+ }
58
+
59
+ case Types::CongestionControlType::REMB:
60
+ {
61
+ // Audio packets take no part in the estimation of the incoming link,
62
+ // so their streams are not announced in the REMB either.
63
+ if (kind == RTC::Media::Kind::AUDIO)
64
+ {
65
+ break;
66
+ }
67
+
68
+ this->remoteBitrateEstimator->ReceiveRtpPacket(
69
+ packet, receivedAtUs, this->shared->GetTimeUs());
70
+
71
+ break;
72
+ }
73
+
74
+ NO_DEFAULT();
75
+ }
76
+
77
+ // The cap has to keep being announced whatever was negotiated, since a
78
+ // remote sender that only reports arrival times is never told anything
79
+ // else.
80
+ this->rembGenerator.MaySendLimitationRembFeedback(this->shared->GetTimeMs());
81
+ }
82
+
83
+ void ReceiverTransportCongestionController::OnRttUpdate(int64_t avgRttUs)
84
+ {
85
+ MS_TRACE();
86
+
87
+ switch (this->options.congestionControlType)
88
+ {
89
+ case Types::CongestionControlType::TRANSPORT_CC:
90
+ {
91
+ // Nothing is estimated here in this mode, so there is nothing the
92
+ // round trip time bounds.
93
+
94
+ break;
95
+ }
96
+
97
+ case Types::CongestionControlType::REMB:
98
+ {
99
+ this->remoteBitrateEstimator->OnRttUpdate(avgRttUs);
100
+
101
+ break;
102
+ }
103
+
104
+ NO_DEFAULT();
105
+ }
106
+ }
107
+
108
+ void ReceiverTransportCongestionController::RemoveStream(uint32_t ssrc)
109
+ {
110
+ MS_TRACE();
111
+
112
+ switch (this->options.congestionControlType)
113
+ {
114
+ case Types::CongestionControlType::TRANSPORT_CC:
115
+ {
116
+ // No stream is kept track of in this mode.
117
+
118
+ break;
119
+ }
120
+
121
+ case Types::CongestionControlType::REMB:
122
+ {
123
+ this->remoteBitrateEstimator->RemoveStream(ssrc);
124
+
125
+ break;
126
+ }
127
+
128
+ NO_DEFAULT();
129
+ }
130
+ }
131
+
132
+ void ReceiverTransportCongestionController::SetMaxIncomingBitrate(int64_t bitrate)
133
+ {
134
+ MS_TRACE();
135
+
136
+ // NOTE: Zero is how the application asks for no cap at all, while the
137
+ // generator expresses that as no value.
138
+ std::optional<int64_t> maxIncomingBitrate;
139
+
140
+ if (bitrate != 0)
141
+ {
142
+ maxIncomingBitrate = bitrate;
143
+ }
144
+
145
+ this->rembGenerator.SetMaxIncomingBitrate(this->shared->GetTimeMs(), maxIncomingBitrate);
146
+ }
147
+
148
+ std::optional<int64_t> ReceiverTransportCongestionController::GetAvailableBitrate() const
149
+ {
150
+ MS_TRACE();
151
+
152
+ switch (this->options.congestionControlType)
153
+ {
154
+ case Types::CongestionControlType::TRANSPORT_CC:
155
+ {
156
+ // The estimating is the remote sender's job in this mode.
157
+ return std::nullopt;
158
+ }
159
+
160
+ case Types::CongestionControlType::REMB:
161
+ {
162
+ const int64_t bitrate = this->remoteBitrateEstimator->GetLatestEstimate();
163
+
164
+ // NOTE: Zero is how the estimator says that it has nothing, either because
165
+ // no estimation is valid yet or because no stream is active. A measured
166
+ // bitrate never comes out as zero, since the rate control clamps it to the
167
+ // lowest it is configured with.
168
+ if (bitrate == 0)
169
+ {
170
+ return std::nullopt;
171
+ }
172
+
173
+ return bitrate;
174
+ }
175
+
176
+ NO_DEFAULT();
177
+ }
178
+ }
179
+
180
+ void ReceiverTransportCongestionController::OnTransportWideCcFeedbackGeneratorSendPacket(
181
+ TransportWideCcFeedbackGenerator* /*transportWideCcFeedbackGenerator*/,
182
+ RTC::RTCP::FeedbackRtpTransportPacket* packet)
183
+ {
184
+ MS_TRACE();
185
+
186
+ this->listener->OnReceiverTransportCongestionControllerSendRtcpPacket(this, packet);
187
+ }
188
+
189
+ void ReceiverTransportCongestionController::OnRemoteBitrateEstimatorAbsSendTimeBitrateChanged(
190
+ RemoteBitrateEstimatorAbsSendTime* /*remoteBitrateEstimator*/,
191
+ const std::vector<uint32_t>& ssrcs,
192
+ int64_t bitrate)
193
+ {
194
+ MS_TRACE();
195
+
196
+ this->rembGenerator.OnReceiveBitrateChanged(this->shared->GetTimeMs(), ssrcs, bitrate);
197
+ }
198
+
199
+ void ReceiverTransportCongestionController::OnRembGeneratorSendPacket(
200
+ RembGenerator* /*rembGenerator*/, RTC::RTCP::FeedbackPsRembPacket* packet)
201
+ {
202
+ MS_TRACE();
203
+
204
+ this->listener->OnReceiverTransportCongestionControllerSendRtcpPacket(this, packet);
205
+ }
206
+ } // namespace BWE
207
+ } // namespace RTC
@@ -163,7 +163,7 @@ namespace RTC
163
163
  packet.SetSsrcs(ssrcs);
164
164
  }
165
165
 
166
- this->listener->OnRembGeneratorSendRemb(this, std::addressof(packet));
166
+ this->listener->OnRembGeneratorSendPacket(this, std::addressof(packet));
167
167
  }
168
168
  } // namespace BWE
169
169
  } // namespace RTC
@@ -71,7 +71,7 @@ namespace RTC
71
71
  MS_TRACE();
72
72
  }
73
73
 
74
- void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
74
+ void RemoteBitrateEstimatorAbsSendTime::ReceiveRtpPacket(
75
75
  const RTC::RTP::Packet* packet, int64_t arrivalTimeUs, int64_t nowUs)
76
76
  {
77
77
  MS_TRACE();