mediasoup 3.19.21 → 3.19.22

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 (130) hide show
  1. package/node/lib/Worker.d.ts +1 -0
  2. package/node/lib/Worker.d.ts.map +1 -1
  3. package/node/lib/Worker.js +14 -0
  4. package/package.json +4 -2
  5. package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +9 -3
  6. package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +9 -1
  7. package/worker/include/Channel/ChannelMessageRegistrator.hpp +39 -0
  8. package/worker/include/Channel/ChannelMessageRegistratorInterface.hpp +32 -0
  9. package/worker/include/Channel/ChannelSocket.hpp +1 -1
  10. package/worker/include/DepUsrSCTP.hpp +8 -7
  11. package/worker/include/RTC/ActiveSpeakerObserver.hpp +7 -7
  12. package/worker/include/RTC/AudioLevelObserver.hpp +7 -7
  13. package/worker/include/RTC/Consumer.hpp +3 -3
  14. package/worker/include/RTC/DataConsumer.hpp +3 -3
  15. package/worker/include/RTC/DataProducer.hpp +3 -3
  16. package/worker/include/RTC/DirectTransport.hpp +2 -2
  17. package/worker/include/RTC/DtlsTransport.hpp +8 -6
  18. package/worker/include/RTC/ICE/IceServer.hpp +8 -5
  19. package/worker/include/RTC/KeyFrameRequestManager.hpp +15 -12
  20. package/worker/include/RTC/NackGenerator.hpp +7 -6
  21. package/worker/include/RTC/PipeConsumer.hpp +1 -2
  22. package/worker/include/RTC/PipeTransport.hpp +2 -2
  23. package/worker/include/RTC/PlainTransport.hpp +2 -2
  24. package/worker/include/RTC/Producer.hpp +3 -3
  25. package/worker/include/RTC/RTP/RtpStream.hpp +7 -1
  26. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +6 -5
  27. package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -1
  28. package/worker/include/RTC/Router.hpp +3 -3
  29. package/worker/include/RTC/RtpObserver.hpp +3 -3
  30. package/worker/include/RTC/SCTP/TODO_SCTP.md +18 -6
  31. package/worker/include/RTC/SCTP/association/Association.hpp +11 -8
  32. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +9 -6
  33. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +37 -23
  34. package/worker/include/RTC/SCTP/association/TCBContext.hpp +3 -2
  35. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +81 -8
  36. package/worker/include/RTC/SCTP/packet/UserData.hpp +36 -0
  37. package/worker/include/RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp +1 -1
  38. package/worker/include/RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp +1 -1
  39. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +2 -1
  40. package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +604 -0
  41. package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +336 -0
  42. package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +5 -4
  43. package/worker/include/RTC/Serializable.hpp +8 -0
  44. package/worker/include/RTC/SimpleConsumer.hpp +1 -2
  45. package/worker/include/RTC/SimulcastConsumer.hpp +1 -2
  46. package/worker/include/RTC/SvcConsumer.hpp +1 -2
  47. package/worker/include/RTC/Transport.hpp +8 -8
  48. package/worker/include/RTC/TransportCongestionControlClient.hpp +8 -5
  49. package/worker/include/RTC/TransportCongestionControlServer.hpp +8 -5
  50. package/worker/include/RTC/WebRtcServer.hpp +3 -3
  51. package/worker/include/RTC/WebRtcTransport.hpp +3 -3
  52. package/worker/include/Shared.hpp +40 -0
  53. package/worker/include/SharedInterface.hpp +44 -0
  54. package/worker/include/Utils.hpp +6 -0
  55. package/worker/include/Worker.hpp +3 -3
  56. package/worker/include/common.hpp +1 -1
  57. package/worker/include/handles/BackoffTimerHandle.hpp +27 -65
  58. package/worker/include/handles/BackoffTimerHandleInterface.hpp +116 -0
  59. package/worker/include/handles/TimerHandle.hpp +36 -20
  60. package/worker/include/handles/TimerHandleInterface.hpp +43 -0
  61. package/worker/meson.build +21 -4
  62. package/worker/meson_options.txt +2 -1
  63. package/worker/mocks/include/Channel/MockChannelMessageRegistrator.hpp +45 -0
  64. package/worker/mocks/include/MockShared.hpp +43 -0
  65. package/worker/mocks/src/Channel/MockChannelMessageRegistrator.cpp +128 -0
  66. package/worker/mocks/src/MockShared.cpp +26 -0
  67. package/worker/scripts/clang-scripts.mjs +4 -1
  68. package/worker/src/Channel/ChannelMessageRegistrator.cpp +125 -0
  69. package/worker/src/Channel/ChannelSocket.cpp +1 -1
  70. package/worker/src/DepUsrSCTP.cpp +10 -4
  71. package/worker/src/RTC/ActiveSpeakerObserver.cpp +7 -7
  72. package/worker/src/RTC/AudioLevelObserver.cpp +12 -10
  73. package/worker/src/RTC/Consumer.cpp +23 -20
  74. package/worker/src/RTC/DataConsumer.cpp +11 -11
  75. package/worker/src/RTC/DataProducer.cpp +3 -3
  76. package/worker/src/RTC/DirectTransport.cpp +16 -16
  77. package/worker/src/RTC/DtlsTransport.cpp +4 -4
  78. package/worker/src/RTC/ICE/IceServer.cpp +4 -3
  79. package/worker/src/RTC/KeyFrameRequestManager.cpp +15 -15
  80. package/worker/src/RTC/NackGenerator.cpp +3 -3
  81. package/worker/src/RTC/PipeConsumer.cpp +5 -4
  82. package/worker/src/RTC/PipeTransport.cpp +3 -3
  83. package/worker/src/RTC/PlainTransport.cpp +10 -9
  84. package/worker/src/RTC/Producer.cpp +30 -28
  85. package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +1 -2
  86. package/worker/src/RTC/RTP/RtpStream.cpp +9 -2
  87. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +5 -4
  88. package/worker/src/RTC/RTP/RtpStreamSend.cpp +5 -2
  89. package/worker/src/RTC/Router.cpp +3 -3
  90. package/worker/src/RTC/RtpObserver.cpp +2 -1
  91. package/worker/src/RTC/SCTP/association/Association.cpp +94 -114
  92. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +27 -21
  93. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +52 -55
  94. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +144 -25
  95. package/worker/src/RTC/SCTP/packet/chunks/ForwardTsnChunk.cpp +2 -2
  96. package/worker/src/RTC/SCTP/packet/chunks/IForwardTsnChunk.cpp +2 -2
  97. package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +905 -0
  98. package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +799 -0
  99. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +1 -1
  100. package/worker/src/RTC/SctpAssociation.cpp +1 -1
  101. package/worker/src/RTC/SimpleConsumer.cpp +8 -7
  102. package/worker/src/RTC/SimulcastConsumer.cpp +11 -10
  103. package/worker/src/RTC/SvcConsumer.cpp +11 -10
  104. package/worker/src/RTC/Transport.cpp +36 -26
  105. package/worker/src/RTC/TransportCongestionControlClient.cpp +4 -2
  106. package/worker/src/RTC/TransportCongestionControlServer.cpp +4 -3
  107. package/worker/src/RTC/WebRtcServer.cpp +5 -4
  108. package/worker/src/RTC/WebRtcTransport.cpp +39 -26
  109. package/worker/src/Shared.cpp +35 -0
  110. package/worker/src/Worker.cpp +10 -23
  111. package/worker/src/handles/BackoffTimerHandle.cpp +11 -16
  112. package/worker/src/handles/TimerHandle.cpp +5 -4
  113. package/worker/src/lib.cpp +14 -1
  114. package/worker/tasks.py +1 -1
  115. package/worker/test/include/RTC/ICE/iceCommon.hpp +1 -0
  116. package/worker/test/include/RTC/RTP/rtpCommon.hpp +1 -0
  117. package/worker/test/include/RTC/SCTP/sctpCommon.hpp +6 -0
  118. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +12 -5
  119. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +34 -23
  120. package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1196 -0
  121. package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +33 -33
  122. package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +14 -6
  123. package/worker/test/src/RTC/TestNackGenerator.cpp +6 -2
  124. package/worker/test/src/RTC/TestSimpleConsumer.cpp +6 -10
  125. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +9 -2
  126. package/worker/test/src/Utils/TestByte.cpp +98 -0
  127. package/worker/include/ChannelMessageRegistrator.hpp +0 -30
  128. package/worker/include/RTC/Shared.hpp +0 -23
  129. package/worker/src/ChannelMessageRegistrator.cpp +0 -119
  130. package/worker/src/RTC/Shared.cpp +0 -23
@@ -0,0 +1,336 @@
1
+ #ifndef MS_RTC_SCTP_RETRANSMISSION_QUEUE_HPP
2
+ #define MS_RTC_SCTP_RETRANSMISSION_QUEUE_HPP
3
+
4
+ #include "common.hpp"
5
+ #include "RTC/SCTP/common/UnwrappedSequenceNumber.hpp"
6
+ #include "RTC/SCTP/packet/Packet.hpp"
7
+ #include "RTC/SCTP/packet/UserData.hpp"
8
+ #include "RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp"
9
+ #include "RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp"
10
+ #include "RTC/SCTP/packet/chunks/SackChunk.hpp"
11
+ #include "RTC/SCTP/public/AssociationListener.hpp"
12
+ #include "RTC/SCTP/public/SctpOptions.hpp"
13
+ #include "RTC/SCTP/tx/OutstandingData.hpp"
14
+ #include "handles/BackoffTimerHandleInterface.hpp"
15
+ #include <vector>
16
+
17
+ namespace RTC
18
+ {
19
+ namespace SCTP
20
+ {
21
+ /**
22
+ * The RetransmissionQueue manages all DATA/I-DATA chunks that are in-flight
23
+ * and schedules them to be retransmitted if necessary. Chunks are
24
+ * retransmitted when they have been lost for a number of consecutive SACKs,
25
+ * or when the retransmission timer expires.
26
+ *
27
+ * As congestion control is tightly connected with the state of transmitted
28
+ * packets, that's also managed here to limit the amount of data that is
29
+ * in-flight (sent, but not yet acknowledged).
30
+ */
31
+ class RetransmissionQueue
32
+ {
33
+ public:
34
+ class Listener
35
+ {
36
+ public:
37
+ virtual ~Listener() = default;
38
+
39
+ public:
40
+ virtual void OnRetransmissionQueueNewRttMs(uint64_t newRttMs) = 0;
41
+ virtual void OnRetransmissionQueueClearRetransmissionCounter() = 0;
42
+ };
43
+
44
+ public:
45
+ using UnwrappedTsn = UnwrappedSequenceNumber<uint32_t>;
46
+
47
+ private:
48
+ enum class CongestionAlgorithmPhase : uint8_t
49
+ {
50
+ SLOW_START,
51
+ CONGESTION_AVOIDANCE,
52
+ };
53
+
54
+ public:
55
+ /**
56
+ * Creates a RetransmissionQueue which will send data using
57
+ * `localInitialTsn` as the first TSN to use for sent fragments. It will
58
+ * poll data from `sendQueue`. When SACKs are received, it will estimate
59
+ * the RTT and call `listener->OnRetransmissionQueueNewRttMs()`. When an
60
+ * outstanding Chunk has been acked, it will call
61
+ * `listener->OnRetransmissionQueueClearRetransmissionCounter() and will
62
+ * also use `t3RtxTimer`, which is the SCTP retransmission timer to manage
63
+ * retransmissions.
64
+ */
65
+ RetransmissionQueue(
66
+ Listener* listener,
67
+ AssociationListener& associationListener,
68
+ uint32_t localInitialTsn,
69
+ uint32_t remoteAdvertisedReceiverWindowCredit,
70
+ // TODO: SCTP: Implement
71
+ // SendQueue& sendQueue,
72
+ BackoffTimerHandleInterface* t3RtxTimer,
73
+ const SctpOptions& sctpOptions,
74
+ // TODO: SCTP: I don't like these defaults (true and false), let's be explicit.
75
+ bool supportsPartialReliability,
76
+ bool useMessageInterleaving);
77
+
78
+ ~RetransmissionQueue();
79
+
80
+ public:
81
+ /**
82
+ * Handles a received SACK. Returns true if the SACK was processed and
83
+ * false if it was discarded due to received out-of-order and not relevant.
84
+ */
85
+ bool HandleReceivedSackChunk(uint64_t nowMs, const SackChunk* receivedSackChunk);
86
+
87
+ /**
88
+ * Handles an expired retransmission timer.
89
+ */
90
+ void HandleT3RtxTimerExpiry();
91
+
92
+ bool HasDataToBeFastRetransmitted() const
93
+ {
94
+ return this->outstandingData.HasDataToBeFastRetransmitted();
95
+ }
96
+
97
+ /**
98
+ * Returns a list of Chunks to "fast retransmit" that would fit in
99
+ * `maxLength` (bytes). The current value of `cwnd` is ignored.
100
+ */
101
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> GetChunksForFastRetransmit(size_t maxLength);
102
+
103
+ /**
104
+ * Returns a list of Chunks to send that would fit in `maxLength`
105
+ * (bytes). This may be further limited by the congestion control windows.
106
+ * Note that `ShouldSendForwardTsn()` must be called prior to this method,
107
+ * to abandon expired Chunks, as this method will not expire any Chunks.
108
+ */
109
+ std::vector<std::pair<uint32_t /*tsn*/, UserData>> GetChunksToSend(
110
+ uint64_t nowMs, size_t maxLength);
111
+
112
+ /**
113
+ * Returns the next TSN that will be allocated for sent DATA Chunks.
114
+ */
115
+ uint32_t GetNextTsn() const
116
+ {
117
+ return this->outstandingData.GetNextTsn().Wrap();
118
+ }
119
+
120
+ uint32_t GetLastAssignedTsn() const
121
+ {
122
+ return UnwrappedTsn::AddTo(this->outstandingData.GetNextTsn(), -1).Wrap();
123
+ }
124
+
125
+ /**
126
+ * Returns the size of the congestion window, in bytes. This is the number
127
+ * of bytes that may be in-flight.
128
+ */
129
+ size_t GetCwnd() const
130
+ {
131
+ return this->cwnd;
132
+ }
133
+
134
+ /**
135
+ * Overrides the current congestion window size.
136
+ */
137
+ void SetCwnd(size_t cwnd)
138
+ {
139
+ this->cwnd = cwnd;
140
+ }
141
+
142
+ /**
143
+ * Returns the current receiver window size.
144
+ */
145
+ size_t GetRwnd() const
146
+ {
147
+ return this->rwnd;
148
+ }
149
+
150
+ size_t GetRtxPacketsCount() const
151
+ {
152
+ return this->rtxPacketsCount;
153
+ }
154
+
155
+ uint64_t GetRtxBytesCount() const
156
+ {
157
+ return this->rtxBytesCount;
158
+ }
159
+
160
+ /**
161
+ * How many inflight bytes there are, as sent on the wire as packets.
162
+ */
163
+ size_t GetUnackedPacketBytes() const
164
+ {
165
+ return this->outstandingData.GetUnackedPacketBytes();
166
+ }
167
+
168
+ /**
169
+ * Returns the number of DATA/I-DATA chunks that are in-flight.
170
+ */
171
+ size_t GetUnackedItems() const
172
+ {
173
+ return this->outstandingData.GetUnackedItems();
174
+ }
175
+
176
+ /**
177
+ * Given the current time `nowMs`, it will evaluate if there are Chunks
178
+ * that have expired and that need to be discarded. It returns true if a
179
+ * FORWARD-TSN should be sent.
180
+ */
181
+ bool ShouldSendForwardTsn(uint64_t nowMs);
182
+
183
+ /**
184
+ * Creates a FORWARD-TSN Chunk and adds it to the given Packet.
185
+ */
186
+ void CreateForwardTsn(Packet* packet) const
187
+ {
188
+ this->outstandingData.CreateForwardTsn(packet);
189
+ }
190
+
191
+ /**
192
+ * Creates an I-FORWARD-TSN Chunk and adds it to the given Packet.
193
+ */
194
+ void CreateIForwardTsn(Packet* packet) const
195
+ {
196
+ this->outstandingData.CreateIForwardTsn(packet);
197
+ }
198
+
199
+ /**
200
+ * @see SendQueue for a longer description of these methods related
201
+ * to stream resetting.
202
+ */
203
+ void PrepareResetStream(uint16_t streamId);
204
+ bool HasStreamsReadyToBeReset() const;
205
+ std::vector<uint16_t /*streamId*/> BeginResetStreams();
206
+ void CommitResetStreams();
207
+ void RollbackResetStreams();
208
+
209
+ #ifdef MS_TEST
210
+ /**
211
+ * Returns the internal state of all queued Chunks.
212
+ *
213
+ * @remarks
214
+ * - This is only used in tests.
215
+ */
216
+ std::vector<std::pair<uint32_t /*tsn*/, OutstandingData::State>> GetChunkStatesForTesting() const
217
+ {
218
+ return this->outstandingData.GetChunkStatesForTesting();
219
+ }
220
+ #endif
221
+
222
+ private:
223
+ /**
224
+ * Returns how large a chunk will be, serialized, carrying the data.
225
+ */
226
+ size_t GetSerializedChunkLength(const UserData& data) const;
227
+
228
+ /**
229
+ * Indicates if the congestion control algorithm is in "fast recovery".
230
+ */
231
+ bool IsInFastRecovery() const
232
+ {
233
+ return this->fastRecoveryExitTsn.has_value();
234
+ }
235
+
236
+ /**
237
+ * Indicates if the provided SACK Chunk is valid given what has previously
238
+ * been received. If it returns false, the SACK is most likely a duplicate
239
+ * of something already seen, so this returning false doesn't necessarily
240
+ * mean that the SACK is illegal.
241
+ */
242
+ bool IsSackChunkValid(const SackChunk* sackChunk) const;
243
+
244
+ /**
245
+ * When a SACK Chunk is received, this method will be called which may
246
+ * call into the `RetransmissionTimeout` to update the RTO.
247
+ */
248
+ void UpdateRttMs(uint64_t nowMs, UnwrappedTsn cumulativeTsnAck);
249
+
250
+ /**
251
+ * If the congestion control is in "fast recovery mode", this may be
252
+ * exited now.
253
+ */
254
+ void MayExitFastRecovery(UnwrappedTsn cumulativeTsnAck);
255
+
256
+ /**
257
+ * If Chunks have been ACKed, stop the retransmission timer.
258
+ *
259
+ * @remarks
260
+ * - This method is NOT defined in dcsctp! See bug report:
261
+ * https://issues.webrtc.org/issues/505751236
262
+ */
263
+ void StopT3RtxTimerOnIncreasedCumulativeTsnAck(UnwrappedTsn cumulativeTsnAck);
264
+
265
+ /**
266
+ * Update the congestion control algorithm given as the cumulative ack TSN
267
+ * value has increased, as reported in an incoming SACK Chunk.
268
+ */
269
+ void HandleIncreasedCumulativeTsnAck(size_t unackedPacketBytes, size_t totalBytesAcked);
270
+
271
+ /**
272
+ * Update the congestion control algorithm, given as packet loss has been
273
+ * detected, as reported in an incoming SACK Chunk.
274
+ */
275
+ void HandlePacketLoss(UnwrappedTsn highestTsnAcked);
276
+
277
+ /**
278
+ * Update the view of the receiver window size.
279
+ */
280
+ void UpdateReceiverWindow(uint32_t aRwnd);
281
+
282
+ /**
283
+ * If there is data sent and not acked, ensure that the retransmission
284
+ * timer is running.
285
+ */
286
+ void StartT3RtxTimerIfOutstandingData();
287
+
288
+ /**
289
+ * Returns the current congestion control algorithm phase.
290
+ */
291
+ CongestionAlgorithmPhase GetCongestionAlgorithmPhase() const
292
+ {
293
+ return (this->cwnd <= this->ssthresh) ? CongestionAlgorithmPhase::SLOW_START
294
+ : CongestionAlgorithmPhase::CONGESTION_AVOIDANCE;
295
+ }
296
+
297
+ private:
298
+ Listener* listener;
299
+ AssociationListener& associationListener;
300
+ const SctpOptions sctpOptions;
301
+ // If the peer supports RFC3758 "SCTP Partial Reliability Extension".
302
+ bool supportsPartialReliability;
303
+ // The length of the data chunk (DATA/I-DATA) header that is used.
304
+ const size_t dataChunkHeaderLength;
305
+ // The retransmission timer.
306
+ BackoffTimerHandleInterface* t3RtxTimer;
307
+ // Unwraps TSNs.
308
+ UnwrappedTsn::Unwrapper tsnUnwrapper;
309
+ // Congestion Window. Number of bytes that may be in-flight (sent, not
310
+ // acked).
311
+ size_t cwnd;
312
+ // Receive Window. Number of bytes available in the receiver's RX buffer.
313
+ size_t rwnd;
314
+ // Slow Start Threshold. See RFC 9260.
315
+ size_t ssthresh;
316
+ // Partial Bytes Acked. See RFC 9260.
317
+ size_t partialBytesAcked{ 0 };
318
+ // See `AssociationMetrics`.
319
+ size_t rtxPacketsCount{ 0 };
320
+ uint64_t rtxBytesCount{ 0 };
321
+ // If set, fast recovery is enabled until this TSN has been cumulative
322
+ // acked.
323
+ std::optional<UnwrappedTsn> fastRecoveryExitTsn{ std::nullopt };
324
+ // The send queue.
325
+ // TODO: SCTP: Implement.
326
+ // SendQueue& sendQueue;
327
+ // All the outstanding data Chunks that are in-flight and that have not
328
+ // been cumulative acked. Note that it also contains chunks that have been
329
+ // acked in gap-ack-blocks.
330
+ OutstandingData outstandingData;
331
+ // TODO: SCTP.
332
+ };
333
+ } // namespace SCTP
334
+ } // namespace RTC
335
+
336
+ #endif
@@ -14,7 +14,7 @@ namespace RTC
14
14
  * as delayed ack.
15
15
  *
16
16
  * When a round-trip-time (RTT) is calculated (outside this class), the
17
- * `ObserveRtt()` method is called, which calculates the retransmission
17
+ * `ObserveRttMs()` method is called, which calculates the retransmission
18
18
  * timeout (RTO) value. The RTO value will become larger if the RTT is high
19
19
  * and/or the RTT values are varying a lot, which is an indicator of a bad
20
20
  * connection.
@@ -30,9 +30,10 @@ namespace RTC
30
30
  void Dump(int indentation = 0) const;
31
31
 
32
32
  /**
33
- * To be called when a RTT has been measured, to update the RTO value.
33
+ * To be called when a RTT (ms) has been measured, to update the RTO
34
+ * value.
34
35
  */
35
- void ObserveRtt(uint64_t rtt);
36
+ void ObserveRttMs(uint64_t rttMs);
36
37
 
37
38
  /**
38
39
  * Returns the Retransmission Timeout (RTO) value.
@@ -43,7 +44,7 @@ namespace RTC
43
44
  }
44
45
 
45
46
  /**
46
- * Returns the smoothed RTT value.
47
+ * Returns the smoothed RTT value (ms)..
47
48
  */
48
49
  uint64_t GetSrttMs() const
49
50
  {
@@ -75,6 +75,14 @@ namespace RTC
75
75
  return this->length;
76
76
  }
77
77
 
78
+ /**
79
+ * Current available length of the Serializable.
80
+ */
81
+ virtual size_t GetAvailableLength() const final
82
+ {
83
+ return this->bufferLength - this->length;
84
+ }
85
+
78
86
  /**
79
87
  * Serialize the Serializable into a new buffer. This method copies the
80
88
  * bytes of the internal buffer into the new buffer and makes `GetBuffer()`
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include "RTC/Consumer.hpp"
5
5
  #include "RTC/SeqManager.hpp"
6
- #include "RTC/Shared.hpp"
7
6
  #include <map>
8
7
 
9
8
  namespace RTC
@@ -12,7 +11,7 @@ namespace RTC
12
11
  {
13
12
  public:
14
13
  SimpleConsumer(
15
- RTC::Shared* shared,
14
+ SharedInterface* shared,
16
15
  const std::string& id,
17
16
  const std::string& producerId,
18
17
  RTC::Consumer::Listener* listener,
@@ -4,7 +4,6 @@
4
4
  #include "RTC/Consumer.hpp"
5
5
  #include "RTC/RTP/Codecs/PayloadDescriptorHandler.hpp"
6
6
  #include "RTC/SeqManager.hpp"
7
- #include "RTC/Shared.hpp"
8
7
  #include <map>
9
8
 
10
9
  namespace RTC
@@ -13,7 +12,7 @@ namespace RTC
13
12
  {
14
13
  public:
15
14
  SimulcastConsumer(
16
- RTC::Shared* shared,
15
+ SharedInterface* shared,
17
16
  const std::string& id,
18
17
  const std::string& producerId,
19
18
  RTC::Consumer::Listener* listener,
@@ -4,7 +4,6 @@
4
4
  #include "RTC/Consumer.hpp"
5
5
  #include "RTC/RTP/Codecs/PayloadDescriptorHandler.hpp"
6
6
  #include "RTC/SeqManager.hpp"
7
- #include "RTC/Shared.hpp"
8
7
  #include <map>
9
8
 
10
9
  namespace RTC
@@ -13,7 +12,7 @@ namespace RTC
13
12
  {
14
13
  public:
15
14
  SvcConsumer(
16
- RTC::Shared* shared,
15
+ SharedInterface* shared,
17
16
  const std::string& id,
18
17
  const std::string& producerId,
19
18
  RTC::Consumer::Listener* listener,
@@ -23,15 +23,15 @@
23
23
  #include "RTC/SCTP/public/Message.hpp"
24
24
  #include "RTC/SCTP/public/SctpTypes.hpp"
25
25
  // TODO: Remove once we only use built-in SCTP stack.
26
+ #include "SharedInterface.hpp"
26
27
  #include "RTC/SctpAssociation.hpp"
27
28
  #include "RTC/SctpListener.hpp"
28
- #include "RTC/Shared.hpp"
29
29
  #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
30
30
  #include "RTC/SenderBandwidthEstimator.hpp"
31
31
  #endif
32
32
  #include "RTC/TransportCongestionControlClient.hpp"
33
33
  #include "RTC/TransportCongestionControlServer.hpp"
34
- #include "handles/TimerHandle.hpp"
34
+ #include "handles/TimerHandleInterface.hpp"
35
35
  #include <absl/container/flat_hash_map.h>
36
36
  #include <string>
37
37
  #include <vector>
@@ -52,7 +52,7 @@ namespace RTC
52
52
  #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
53
53
  public RTC::SenderBandwidthEstimator::Listener,
54
54
  #endif
55
- public TimerHandle::Listener
55
+ public TimerHandleInterface::Listener
56
56
  {
57
57
  protected:
58
58
  using onSendCallback = const std::function<void(bool sent)>;
@@ -157,7 +157,7 @@ namespace RTC
157
157
 
158
158
  public:
159
159
  Transport(
160
- RTC::Shared* shared,
160
+ SharedInterface* shared,
161
161
  const std::string& id,
162
162
  RTC::Transport::Listener* listener,
163
163
  const FBS::Transport::Options* options);
@@ -350,16 +350,16 @@ namespace RTC
350
350
  uint32_t previousAvailableBitrate) override;
351
351
  #endif
352
352
 
353
- /* Pure virtual methods inherited from TimerHandle::Listener. */
353
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
354
354
  public:
355
- void OnTimer(TimerHandle* timer) override;
355
+ void OnTimer(TimerHandleInterface* timer) override;
356
356
 
357
357
  public:
358
358
  // Passed by argument.
359
359
  std::string id;
360
360
 
361
361
  protected:
362
- RTC::Shared* shared{ nullptr };
362
+ SharedInterface* shared{ nullptr };
363
363
  size_t maxMessageSize{ 262144u };
364
364
  // Allocated by this.
365
365
  std::unique_ptr<RTC::SCTP::AssociationInterface> sctpAssociation{ nullptr };
@@ -376,7 +376,7 @@ namespace RTC
376
376
  absl::flat_hash_map<std::string, RTC::DataConsumer*> mapDataConsumers;
377
377
  absl::flat_hash_map<uint32_t, RTC::Consumer*> mapSsrcConsumer;
378
378
  absl::flat_hash_map<uint32_t, RTC::Consumer*> mapRtxSsrcConsumer;
379
- TimerHandle* rtcpTimer{ nullptr };
379
+ TimerHandleInterface* rtcpTimer{ nullptr };
380
380
  std::shared_ptr<RTC::TransportCongestionControlClient> tccClient{ nullptr };
381
381
  std::shared_ptr<RTC::TransportCongestionControlServer> tccServer{ nullptr };
382
382
  #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
@@ -2,13 +2,14 @@
2
2
  #define MS_RTC_TRANSPORT_CONGESTION_CONTROL_CLIENT_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/BweType.hpp"
6
7
  #include "RTC/RTCP/FeedbackRtpTransport.hpp"
7
8
  #include "RTC/RTCP/ReceiverReport.hpp"
8
9
  #include "RTC/RTP/Packet.hpp"
9
10
  #include "RTC/RTP/ProbationGenerator.hpp"
10
11
  #include "RTC/TrendCalculator.hpp"
11
- #include "handles/TimerHandle.hpp"
12
+ #include "handles/TimerHandleInterface.hpp"
12
13
  #include <libwebrtc/api/transport/goog_cc_factory.h>
13
14
  #include <libwebrtc/api/transport/network_types.h>
14
15
  #include <libwebrtc/call/rtp_transport_controller_send.h>
@@ -21,7 +22,7 @@ namespace RTC
21
22
 
22
23
  class TransportCongestionControlClient : public webrtc::PacketRouter,
23
24
  public webrtc::TargetTransferRateObserver,
24
- public TimerHandle::Listener
25
+ public TimerHandleInterface::Listener
25
26
  {
26
27
  public:
27
28
  struct Bitrates
@@ -54,6 +55,7 @@ namespace RTC
54
55
  public:
55
56
  TransportCongestionControlClient(
56
57
  RTC::TransportCongestionControlClient::Listener* listener,
58
+ SharedInterface* shared,
57
59
  RTC::BweType bweType,
58
60
  uint32_t initialAvailableBitrate,
59
61
  uint32_t maxOutgoingBitrate,
@@ -104,18 +106,19 @@ namespace RTC
104
106
  void SendPacket(RTC::RTP::Packet* packet, const webrtc::PacedPacketInfo& pacingInfo) override;
105
107
  RTC::RTP::Packet* GeneratePadding(size_t size) override;
106
108
 
107
- /* Pure virtual methods inherited from RTC::TimerHandle. */
109
+ /* Pure virtual methods inherited from RTC::TimerHandleInterface. */
108
110
  public:
109
- void OnTimer(TimerHandle* timer) override;
111
+ void OnTimer(TimerHandleInterface* timer) override;
110
112
 
111
113
  private:
112
114
  // Passed by argument.
113
115
  Listener* listener{ nullptr };
116
+ SharedInterface* shared{ nullptr };
114
117
  // Allocated by this.
115
118
  webrtc::NetworkControllerFactoryInterface* controllerFactory{ nullptr };
116
119
  webrtc::RtpTransportControllerSend* rtpTransportControllerSend{ nullptr };
117
120
  RTC::RTP::ProbationGenerator* probationGenerator{ nullptr };
118
- TimerHandle* processTimer{ nullptr };
121
+ TimerHandleInterface* processTimer{ nullptr };
119
122
  // Others.
120
123
  RTC::BweType bweType;
121
124
  uint32_t initialAvailableBitrate{ 0u };
@@ -2,19 +2,20 @@
2
2
  #define MS_RTC_TRANSPORT_CONGESTION_CONTROL_SERVER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/BweType.hpp"
6
7
  #include "RTC/RTCP/FeedbackRtpTransport.hpp"
7
8
  #include "RTC/RTCP/Packet.hpp"
8
9
  #include "RTC/RTP/Packet.hpp"
9
10
  #include "RTC/SeqManager.hpp"
10
- #include "handles/TimerHandle.hpp"
11
+ #include "handles/TimerHandleInterface.hpp"
11
12
  #include <libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h>
12
13
  #include <deque>
13
14
 
14
15
  namespace RTC
15
16
  {
16
17
  class TransportCongestionControlServer : public webrtc::RemoteBitrateEstimator::Listener,
17
- public TimerHandle::Listener
18
+ public TimerHandleInterface::Listener
18
19
  {
19
20
  public:
20
21
  class Listener
@@ -30,6 +31,7 @@ namespace RTC
30
31
  public:
31
32
  TransportCongestionControlServer(
32
33
  RTC::TransportCongestionControlServer::Listener* listener,
34
+ SharedInterface* shared,
33
35
  RTC::BweType bweType,
34
36
  size_t maxRtcpPacketLen);
35
37
  ~TransportCongestionControlServer() override;
@@ -72,15 +74,16 @@ namespace RTC
72
74
  const std::vector<uint32_t>& ssrcs,
73
75
  uint32_t availableBitrate) override;
74
76
 
75
- /* Pure virtual methods inherited from TimerHandle::Listener. */
77
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
76
78
  public:
77
- void OnTimer(TimerHandle* timer) override;
79
+ void OnTimer(TimerHandleInterface* timer) override;
78
80
 
79
81
  private:
80
82
  // Passed by argument.
81
83
  Listener* listener{ nullptr };
84
+ SharedInterface* shared{ nullptr };
82
85
  // Allocated by this.
83
- TimerHandle* transportCcFeedbackSendPeriodicTimer{ nullptr };
86
+ TimerHandleInterface* transportCcFeedbackSendPeriodicTimer{ nullptr };
84
87
  std::unique_ptr<RTC::RTCP::FeedbackRtpTransportPacket> transportCcFeedbackPacket;
85
88
  webrtc::RemoteBitrateEstimatorAbsSendTime* rembServer{ nullptr };
86
89
  // Others.
@@ -1,10 +1,10 @@
1
1
  #ifndef MS_RTC_WEBRTC_SERVER_HPP
2
2
  #define MS_RTC_WEBRTC_SERVER_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "Channel/ChannelRequest.hpp"
5
6
  #include "RTC/ICE/IceCandidate.hpp"
6
7
  #include "RTC/ICE/StunPacket.hpp"
7
- #include "RTC/Shared.hpp"
8
8
  #include "RTC/TcpConnection.hpp"
9
9
  #include "RTC/TcpServer.hpp"
10
10
  #include "RTC/TransportTuple.hpp"
@@ -52,7 +52,7 @@ namespace RTC
52
52
 
53
53
  public:
54
54
  WebRtcServer(
55
- RTC::Shared* shared,
55
+ SharedInterface* shared,
56
56
  const std::string& id,
57
57
  const flatbuffers::Vector<flatbuffers::Offset<FBS::Transport::ListenInfo>>* listenInfos);
58
58
  ~WebRtcServer() override;
@@ -112,7 +112,7 @@ namespace RTC
112
112
  // Passed by argument.
113
113
  std::string id;
114
114
  // Passed by argument.
115
- RTC::Shared* shared{ nullptr };
115
+ SharedInterface* shared{ nullptr };
116
116
  // Vector of UdpSockets and TcpServers in the user given order.
117
117
  std::vector<UdpSocketOrTcpServer> udpSocketOrTcpServers;
118
118
  // Set of WebRtcTransports.
@@ -1,11 +1,11 @@
1
1
  #ifndef MS_RTC_WEBRTC_TRANSPORT_HPP
2
2
  #define MS_RTC_WEBRTC_TRANSPORT_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "RTC/DtlsTransport.hpp"
5
6
  #include "RTC/ICE/IceCandidate.hpp"
6
7
  #include "RTC/ICE/IceServer.hpp"
7
8
  #include "RTC/ICE/StunPacket.hpp"
8
- #include "RTC/Shared.hpp"
9
9
  #include "RTC/SrtpSession.hpp"
10
10
  #include "RTC/TcpConnection.hpp"
11
11
  #include "RTC/TcpServer.hpp"
@@ -44,12 +44,12 @@ namespace RTC
44
44
 
45
45
  public:
46
46
  WebRtcTransport(
47
- RTC::Shared* shared,
47
+ SharedInterface* shared,
48
48
  const std::string& id,
49
49
  RTC::Transport::Listener* listener,
50
50
  const FBS::WebRtcTransport::WebRtcTransportOptions* options);
51
51
  WebRtcTransport(
52
- RTC::Shared* shared,
52
+ SharedInterface* shared,
53
53
  const std::string& id,
54
54
  RTC::Transport::Listener* listener,
55
55
  WebRtcTransportListener* webRtcTransportListener,