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
@@ -2,16 +2,17 @@
2
2
  #define MS_RTC_NACK_GENERATOR_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/RTP/Packet.hpp"
6
7
  #include "RTC/SeqManager.hpp"
7
- #include "handles/TimerHandle.hpp"
8
+ #include "handles/TimerHandleInterface.hpp"
8
9
  #include <map>
9
10
  #include <set>
10
11
  #include <vector>
11
12
 
12
13
  namespace RTC
13
14
  {
14
- class NackGenerator : public TimerHandle::Listener
15
+ class NackGenerator : public TimerHandleInterface::Listener
15
16
  {
16
17
  public:
17
18
  class Listener
@@ -47,7 +48,7 @@ namespace RTC
47
48
  };
48
49
 
49
50
  public:
50
- explicit NackGenerator(Listener* listener, unsigned int sendNackDelayMs);
51
+ explicit NackGenerator(Listener* listener, SharedInterface* shared, unsigned int sendNackDelayMs);
51
52
  ~NackGenerator() override;
52
53
 
53
54
  bool ReceivePacket(const RTC::RTP::Packet* packet, bool isRecovered);
@@ -67,16 +68,16 @@ namespace RTC
67
68
  std::vector<uint16_t> GetNackBatch(NackFilter filter);
68
69
  void MayRunTimer() const;
69
70
 
70
- /* Pure virtual methods inherited from TimerHandle::Listener. */
71
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
71
72
  public:
72
- void OnTimer(TimerHandle* timer) override;
73
+ void OnTimer(TimerHandleInterface* timer) override;
73
74
 
74
75
  private:
75
76
  // Passed by argument.
76
77
  Listener* listener{ nullptr };
77
78
  unsigned int sendNackDelayMs{ 0u };
78
79
  // Allocated by this.
79
- TimerHandle* timer{ nullptr };
80
+ TimerHandleInterface* timer{ nullptr };
80
81
  // Others.
81
82
  std::map<uint16_t, NackInfo, RTC::SeqManager<uint16_t>::SeqLowerThan> nackList;
82
83
  std::set<uint16_t, RTC::SeqManager<uint16_t>::SeqLowerThan> keyFrameList;
@@ -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
@@ -19,7 +18,7 @@ namespace RTC
19
18
 
20
19
  public:
21
20
  PipeConsumer(
22
- RTC::Shared* shared,
21
+ SharedInterface* shared,
23
22
  const std::string& id,
24
23
  const std::string& producerId,
25
24
  RTC::Consumer::Listener* listener,
@@ -1,8 +1,8 @@
1
1
  #ifndef MS_RTC_PIPE_TRANSPORT_HPP
2
2
  #define MS_RTC_PIPE_TRANSPORT_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "FBS/pipeTransport.h"
5
- #include "RTC/Shared.hpp"
6
6
  #include "RTC/SrtpSession.hpp"
7
7
  #include "RTC/Transport.hpp"
8
8
  #include "RTC/TransportTuple.hpp"
@@ -19,7 +19,7 @@ namespace RTC
19
19
 
20
20
  public:
21
21
  PipeTransport(
22
- RTC::Shared* shared,
22
+ SharedInterface* shared,
23
23
  const std::string& id,
24
24
  RTC::Transport::Listener* listener,
25
25
  const FBS::PipeTransport::PipeTransportOptions* options);
@@ -1,8 +1,8 @@
1
1
  #ifndef MS_RTC_PLAIN_TRANSPORT_HPP
2
2
  #define MS_RTC_PLAIN_TRANSPORT_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "FBS/plainTransport.h"
5
- #include "RTC/Shared.hpp"
6
6
  #include "RTC/SrtpSession.hpp"
7
7
  #include "RTC/Transport.hpp"
8
8
  #include "RTC/TransportTuple.hpp"
@@ -15,7 +15,7 @@ namespace RTC
15
15
  {
16
16
  public:
17
17
  PlainTransport(
18
- RTC::Shared* shared,
18
+ SharedInterface* shared,
19
19
  const std::string& id,
20
20
  RTC::Transport::Listener* listener,
21
21
  const FBS::PlainTransport::PlainTransportOptions* options);
@@ -2,6 +2,7 @@
2
2
  #define MS_RTC_PRODUCER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "Channel/ChannelRequest.hpp"
6
7
  #include "Channel/ChannelSocket.hpp"
7
8
  #include "RTC/KeyFrameRequestManager.hpp"
@@ -13,7 +14,6 @@
13
14
  #include "RTC/RTP/Packet.hpp"
14
15
  #include "RTC/RTP/RtpStreamRecv.hpp"
15
16
  #include "RTC/RtpDictionaries.hpp"
16
- #include "RTC/Shared.hpp"
17
17
  #include <string>
18
18
  #include <vector>
19
19
 
@@ -94,7 +94,7 @@ namespace RTC
94
94
 
95
95
  public:
96
96
  Producer(
97
- RTC::Shared* shared,
97
+ SharedInterface* shared,
98
98
  const std::string& id,
99
99
  RTC::Producer::Listener* listener,
100
100
  const FBS::Transport::ProduceRequest* data);
@@ -179,7 +179,7 @@ namespace RTC
179
179
 
180
180
  private:
181
181
  // Passed by argument.
182
- RTC::Shared* shared{ nullptr };
182
+ SharedInterface* shared{ nullptr };
183
183
  RTC::Producer::Listener* listener{ nullptr };
184
184
  // Allocated by this.
185
185
  absl::flat_hash_map<uint32_t, RTC::RTP::RtpStreamRecv*> mapSsrcRtpStream;
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "common.hpp"
5
5
  #include "DepLibUV.hpp"
6
+ #include "SharedInterface.hpp"
6
7
  #include "FBS/rtpStream.h"
7
8
  #include "RTC/RTCP/FeedbackPsFir.hpp" // IWYU pragma: export
8
9
  #include "RTC/RTCP/FeedbackPsPli.hpp" // IWYU pragma: export
@@ -61,7 +62,11 @@ namespace RTC
61
62
  };
62
63
 
63
64
  public:
64
- RtpStream(RTP::RtpStream::Listener* listener, RTP::RtpStream::Params& params, uint8_t initialScore);
65
+ RtpStream(
66
+ RTP::RtpStream::Listener* listener,
67
+ SharedInterface* shared,
68
+ RTP::RtpStream::Params& params,
69
+ uint8_t initialScore);
65
70
  virtual ~RtpStream();
66
71
 
67
72
  flatbuffers::Offset<FBS::RtpStream::Dump> FillBuffer(flatbuffers::FlatBufferBuilder& builder) const;
@@ -185,6 +190,7 @@ namespace RTC
185
190
  protected:
186
191
  // Given as argument.
187
192
  RTP::RtpStream::Listener* listener{ nullptr };
193
+ SharedInterface* shared{ nullptr };
188
194
  Params params;
189
195
  // Others.
190
196
  // https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
@@ -5,7 +5,7 @@
5
5
  #include "RTC/RTCP/XrDelaySinceLastRr.hpp"
6
6
  #include "RTC/RTP/RtpStream.hpp"
7
7
  #include "RTC/RateCalculator.hpp"
8
- #include "handles/TimerHandle.hpp"
8
+ #include "handles/TimerHandleInterface.hpp"
9
9
  #include <vector>
10
10
 
11
11
  namespace RTC
@@ -14,7 +14,7 @@ namespace RTC
14
14
  {
15
15
  class RtpStreamRecv : public RTP::RtpStream,
16
16
  public RTC::NackGenerator::Listener,
17
- public TimerHandle::Listener
17
+ public TimerHandleInterface::Listener
18
18
  {
19
19
  public:
20
20
  class Listener : public RTP::RtpStream::Listener
@@ -46,6 +46,7 @@ namespace RTC
46
46
  public:
47
47
  RtpStreamRecv(
48
48
  RTP::RtpStreamRecv::Listener* listener,
49
+ SharedInterface* shared,
49
50
  RTP::RtpStream::Params& params,
50
51
  unsigned int sendNackDelayMs,
51
52
  bool useRtpInactivityCheck);
@@ -92,9 +93,9 @@ namespace RTC
92
93
  public:
93
94
  void UserOnSequenceNumberReset() override;
94
95
 
95
- /* Pure virtual methods inherited from TimerHandle. */
96
+ /* Pure virtual methods inherited from TimerHandleInterface. */
96
97
  protected:
97
- void OnTimer(TimerHandle* timer) override;
98
+ void OnTimer(TimerHandleInterface* timer) override;
98
99
 
99
100
  /* Pure virtual methods inherited from RTC::NackGenerator. */
100
101
  protected:
@@ -124,7 +125,7 @@ namespace RTC
124
125
  uint8_t firSeqNumber{ 0u };
125
126
  int32_t reportedPacketsLost{ 0 };
126
127
  std::unique_ptr<RTC::NackGenerator> nackGenerator;
127
- TimerHandle* inactivityCheckPeriodicTimer{ nullptr };
128
+ TimerHandleInterface* inactivityCheckPeriodicTimer{ nullptr };
128
129
  bool inactive{ false };
129
130
  // Valid media + valid RTX.
130
131
  TransmissionCounter transmissionCounter;
@@ -36,7 +36,10 @@ namespace RTC
36
36
 
37
37
  public:
38
38
  RtpStreamSend(
39
- RTP::RtpStreamSend::Listener* listener, RTP::RtpStream::Params& params, std::string& mid);
39
+ RTP::RtpStreamSend::Listener* listener,
40
+ SharedInterface* shared,
41
+ RTP::RtpStream::Params& params,
42
+ std::string& mid);
40
43
  ~RtpStreamSend() override;
41
44
 
42
45
  flatbuffers::Offset<FBS::RtpStream::Stats> FillBufferStats(
@@ -2,6 +2,7 @@
2
2
  #define MS_RTC_ROUTER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "Channel/ChannelRequest.hpp"
6
7
  #include "RTC/Consumer.hpp"
7
8
  #include "RTC/DataConsumer.hpp"
@@ -10,7 +11,6 @@
10
11
  #include "RTC/RTP/Packet.hpp"
11
12
  #include "RTC/RTP/RtpStreamRecv.hpp"
12
13
  #include "RTC/RtpObserver.hpp"
13
- #include "RTC/Shared.hpp"
14
14
  #include "RTC/Transport.hpp"
15
15
  #include "RTC/WebRtcServer.hpp"
16
16
  #include <absl/container/flat_hash_map.h>
@@ -36,7 +36,7 @@ namespace RTC
36
36
  };
37
37
 
38
38
  public:
39
- explicit Router(RTC::Shared* shared, const std::string& id, Listener* listener);
39
+ explicit Router(SharedInterface* shared, const std::string& id, Listener* listener);
40
40
  ~Router() override;
41
41
 
42
42
  public:
@@ -120,7 +120,7 @@ namespace RTC
120
120
 
121
121
  private:
122
122
  // Passed by argument.
123
- RTC::Shared* shared{ nullptr };
123
+ SharedInterface* shared{ nullptr };
124
124
  Listener* listener{ nullptr };
125
125
  // Allocated by this.
126
126
  absl::flat_hash_map<std::string, RTC::Transport*> mapTransports;
@@ -1,9 +1,9 @@
1
1
  #ifndef MS_RTC_RTP_OBSERVER_HPP
2
2
  #define MS_RTC_RTP_OBSERVER_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "RTC/Producer.hpp"
5
6
  #include "RTC/RTP/Packet.hpp"
6
- #include "RTC/Shared.hpp"
7
7
  #include <string>
8
8
 
9
9
  namespace RTC
@@ -25,7 +25,7 @@ namespace RTC
25
25
  };
26
26
 
27
27
  public:
28
- RtpObserver(RTC::Shared* shared, const std::string& id, RTC::RtpObserver::Listener* listener);
28
+ RtpObserver(SharedInterface* shared, const std::string& id, RTC::RtpObserver::Listener* listener);
29
29
  ~RtpObserver() override;
30
30
 
31
31
  public:
@@ -55,7 +55,7 @@ namespace RTC
55
55
 
56
56
  protected:
57
57
  // Passed by argument.
58
- RTC::Shared* shared{ nullptr };
58
+ SharedInterface* shared{ nullptr };
59
59
 
60
60
  private:
61
61
  // Passed by argument.
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Related to mediasoup SCTP implementation
4
4
 
5
+ - `DataChunk`, IDataChunk`and`AnyDataChunk`: Add `SetUserData(UserData)`.
6
+
7
+ - Remove all default values of class memners in .hpp of all classes in case the constructor must give them initial value.
8
+
9
+ - Lot of stuff missing in `TransmissionControlBock` class and I forgot to add "TODO: SCTP" in them.
10
+
11
+ - dcsctp uses µs (webrtc::Timestamp::Micros()) internally, while mediasoup uses ms (`DepLibUV::GetTimeMs()`). When porting dcsctp timeout/duration logic, make sure to convert accordingly. Do not mix units in the same field.
12
+
5
13
  - `Association`: When transitioning to CLOSED (due to failure while connecting or closure) we should emit a new event "stcpclosed" in all `DataProducers/Consumers`.
6
14
 
7
15
  - When receiving SCTP RE-CONFIG, we should emit "streamclosed" in those `DataProducers/DataConsumers` whose stream ID have been closed.
@@ -19,6 +27,10 @@
19
27
  - We must also remove `device.sctpCapabilities` getter from mediasoup-client because anyway we are making up those values!
20
28
  - Also must update the website documentation.
21
29
 
30
+ - Replicate `retransmission_queue_test.cc` of dcsctp.
31
+
32
+ - When we invoke `close()` on a `DataProducer/Consumer` in server, we must end calling `sctpAssociation->ResetStream([streamId])` so it sends `ReConfig` to peer.
33
+
22
34
  - In `transport.dump()` (maybe also in `getStats()`) we must properly obtain `OS` and `MIS` according to the number of SCTP streams negotiated via INIT + INIT_ACK. And if SCTP is not yet established, then... not sure.
23
35
  - In `Association::FillBuffer()` we should not pass `this->sctpOptions.negotiatedMaxOutboundStreams/negotiatedMaxInboundStreams` but the current values.
24
36
 
@@ -34,10 +46,10 @@
34
46
 
35
47
  - Look for "TODO: SCTP" everywhere.
36
48
 
37
- - Test Chrome with I-DATA (message interleaving):
38
-
39
- ```
40
- open -a "Google Chrome Canary" \
41
- --args \
42
- --force-fieldtrials="WebRTC-DataChannelMessageInterleaving/Enabled/"
49
+ - Test Chrome/Canary with I-DATA (message interleaving):
50
+ ```bash
51
+ /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary \
52
+ --force-fieldtrials="WebRTC-DataChannelMessageInterleaving/Enabled/" \
53
+ --enable-logging=stderr \
54
+ --v=1 \
43
55
  ```
@@ -2,6 +2,7 @@
2
2
  #define MS_RTC_SCTP_ASSOCIATION_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/SCTP/association/AssociationListenerDeferrer.hpp"
6
7
  #include "RTC/SCTP/association/NegotiatedCapabilities.hpp"
7
8
  #include "RTC/SCTP/association/PacketSender.hpp"
@@ -36,7 +37,7 @@
36
37
  #include "RTC/SCTP/public/Message.hpp"
37
38
  #include "RTC/SCTP/public/SctpOptions.hpp"
38
39
  #include "RTC/SCTP/public/SctpTypes.hpp"
39
- #include "handles/BackoffTimerHandle.hpp"
40
+ #include "handles/BackoffTimerHandleInterface.hpp"
40
41
  #include <FBS/sctpParameters.h>
41
42
  #include <span>
42
43
  #include <string_view>
@@ -51,7 +52,7 @@ namespace RTC
51
52
  */
52
53
  class Association : public AssociationInterface,
53
54
  public PacketSender::Listener,
54
- public BackoffTimerHandle::Listener
55
+ public BackoffTimerHandleInterface::Listener
55
56
  {
56
57
  public:
57
58
  /**
@@ -166,7 +167,8 @@ namespace RTC
166
167
  };
167
168
 
168
169
  public:
169
- explicit Association(const SctpOptions& sctpOptions, AssociationListener* listener);
170
+ explicit Association(
171
+ const SctpOptions& sctpOptions, AssociationListener* listener, SharedInterface* shared);
170
172
 
171
173
  ~Association() override;
172
174
 
@@ -460,9 +462,9 @@ namespace RTC
460
462
  public:
461
463
  void OnPacketSenderPacketSent(PacketSender* packetSender, const Packet* packet, bool sent) override;
462
464
 
463
- /* Pure virtual methods inherited from BackoffTimerHandle::Listener. */
465
+ /* Pure virtual methods inherited from BackoffTimerHandleInterface::Listener. */
464
466
  public:
465
- void OnTimer(BackoffTimerHandle* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
467
+ void OnTimer(BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
466
468
 
467
469
  private:
468
470
  // SCTP options given in the constructor.
@@ -470,6 +472,7 @@ namespace RTC
470
472
  // Listener. It's not an `AssociationListener` but an
471
473
  // `AssociationListenerDeferrer` which inherits from `AssociationListener`.
472
474
  AssociationListenerDeferrer listener;
475
+ SharedInterface* shared;
473
476
  // SCTP association internal state.
474
477
  State state{ State::NEW };
475
478
  // Packet sender.
@@ -487,11 +490,11 @@ namespace RTC
487
490
  // Private metrics.
488
491
  AssociationPrivateMetrics privateMetrics{};
489
492
  // T1-init timer.
490
- const std::unique_ptr<BackoffTimerHandle> t1InitTimer;
493
+ const std::unique_ptr<BackoffTimerHandleInterface> t1InitTimer;
491
494
  // T1-cookie timer.
492
- const std::unique_ptr<BackoffTimerHandle> t1CookieTimer;
495
+ const std::unique_ptr<BackoffTimerHandleInterface> t1CookieTimer;
493
496
  // T2-shutdown timer.
494
- const std::unique_ptr<BackoffTimerHandle> t2ShutdownTimer;
497
+ const std::unique_ptr<BackoffTimerHandleInterface> t2ShutdownTimer;
495
498
  };
496
499
  } // namespace SCTP
497
500
  } // namespace RTC
@@ -2,12 +2,13 @@
2
2
  #define MS_RTC_SCTP_HEARTBEAT_HANDLER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/SCTP/association/TCBContext.hpp"
6
7
  #include "RTC/SCTP/packet/chunks/HeartbeatAckChunk.hpp"
7
8
  #include "RTC/SCTP/packet/chunks/HeartbeatRequestChunk.hpp"
8
9
  #include "RTC/SCTP/public/AssociationListener.hpp"
9
10
  #include "RTC/SCTP/public/SctpOptions.hpp"
10
- #include "handles/BackoffTimerHandle.hpp"
11
+ #include "handles/BackoffTimerHandleInterface.hpp"
11
12
 
12
13
  namespace RTC
13
14
  {
@@ -21,12 +22,13 @@ namespace RTC
21
22
  * still healthy and to measure the RTT. If a number of heartbeats time out,
22
23
  * the connection will eventually be closed.
23
24
  */
24
- class HeartbeatHandler : public BackoffTimerHandle::Listener
25
+ class HeartbeatHandler : public BackoffTimerHandleInterface::Listener
25
26
  {
26
27
  public:
27
28
  HeartbeatHandler(
28
29
  AssociationListener& associationListener,
29
30
  const SctpOptions& sctpOptions,
31
+ SharedInterface* shared,
30
32
  TCBContext* tcbContext);
31
33
 
32
34
  ~HeartbeatHandler() override;
@@ -55,21 +57,22 @@ namespace RTC
55
57
 
56
58
  void OnTimeoutTimer(uint64_t& baseTimeoutMs, bool& stop);
57
59
 
58
- /* Pure virtual methods inherited from BackoffTimerHandle::Listener. */
60
+ /* Pure virtual methods inherited from BackoffTimerHandleInterface::Listener. */
59
61
  public:
60
- void OnTimer(BackoffTimerHandle* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
62
+ void OnTimer(BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
61
63
 
62
64
  private:
63
65
  AssociationListener& associationListener;
64
66
  const SctpOptions sctpOptions;
67
+ SharedInterface* shared;
65
68
  TCBContext* tcbContext{ nullptr };
66
69
  // The time for a connection to be idle before a heartbeat is sent.
67
70
  const uint64_t intervalDurationMs{ 0 };
68
71
  // Adding RTT to the duration will add some jitter, which is good in
69
72
  // production, but less good in unit tests, which is why it can be disabled.
70
73
  const bool intervalDurationShouldIncludeRtt{ false };
71
- const std::unique_ptr<BackoffTimerHandle> intervalTimer;
72
- const std::unique_ptr<BackoffTimerHandle> timeoutTimer;
74
+ const std::unique_ptr<BackoffTimerHandleInterface> intervalTimer;
75
+ const std::unique_ptr<BackoffTimerHandleInterface> timeoutTimer;
73
76
  };
74
77
  } // namespace SCTP
75
78
  } // namespace RTC
@@ -2,6 +2,7 @@
2
2
  #define MS_RTC_SCTP_STREAM_RESET_HANDLER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/SCTP/association/TCBContext.hpp"
6
7
  #include "RTC/SCTP/common/UnwrappedSequenceNumber.hpp"
7
8
  #include "RTC/SCTP/packet/Packet.hpp"
@@ -10,7 +11,8 @@
10
11
  #include "RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp"
11
12
  #include "RTC/SCTP/packet/parameters/ReconfigurationResponseParameter.hpp"
12
13
  #include "RTC/SCTP/public/AssociationListener.hpp"
13
- #include "handles/BackoffTimerHandle.hpp"
14
+ #include "RTC/SCTP/tx/RetransmissionQueue.hpp"
15
+ #include "handles/BackoffTimerHandleInterface.hpp"
14
16
  #include <span>
15
17
  #include <vector>
16
18
 
@@ -49,7 +51,7 @@ namespace RTC
49
51
  * not-yet-sent messages will be discarded, but that may change in the future.
50
52
  * RFC8831 allows both behaviors.
51
53
  */
52
- class StreamResetHandler : public TCBContext, public BackoffTimerHandle::Listener
54
+ class StreamResetHandler : public BackoffTimerHandleInterface::Listener
53
55
  {
54
56
  private:
55
57
  enum class ReqSeqNbrValidationResult : uint8_t
@@ -164,12 +166,13 @@ namespace RTC
164
166
 
165
167
  public:
166
168
  StreamResetHandler(
167
- AssociationListener& associationListener, TCBContext* tcbContext
169
+ AssociationListener& associationListener,
170
+ SharedInterface* shared,
171
+ TCBContext* tcbContext,
168
172
  // TODO: SCTP: Implement
169
173
  // DataTracker* dataTracker,
170
174
  // ReassemblyQueue* reassemblyQueue,
171
- // RetransmissionQueue* retransmissionQueue
172
- );
175
+ RetransmissionQueue* retransmissionQueue);
173
176
 
174
177
  ~StreamResetHandler() override;
175
178
 
@@ -183,6 +186,23 @@ namespace RTC
183
186
  */
184
187
  void ResetStreams(std::span<const uint16_t> outgoingStreamIds);
185
188
 
189
+ /**
190
+ * Whether a Reset Streams request should be send. Will return `false` if
191
+ * there is no need to create a request (no streams to reset) or if there
192
+ * already is an ongoing stream reset request that hasn't completed yet.
193
+ */
194
+ bool ShouldCreateStreamResetRequest() const;
195
+
196
+ /**
197
+ * Creates a Reset Streams request that must be sent if returned. Will
198
+ * start the reconfig timer.
199
+ *
200
+ * @remarks
201
+ * - The caller must check `ShouldCreateStreamResetRequest()` first and
202
+ * only invoke this method if the former returns `true`.
203
+ */
204
+ void CreateStreamResetRequest(Packet* packet);
205
+
186
206
  /**
187
207
  * Called when handling and incoming RE-CONFIG chunk. Processes a stream
188
208
  * reconfiguration chunk and may send a RE-CONFIG back to the peer with
@@ -197,18 +217,10 @@ namespace RTC
197
217
  bool ValidateReceivedReConfigChunk(const ReConfigChunk* receivedReConfigChunk);
198
218
 
199
219
  /**
200
- * Creates a Reset Streams request that must be sent if returned. Will
201
- * start the reconfig timer. Will return `nullptr` if there is no need
202
- * to create a request (no streams to reset) or if there already is an
203
- * ongoing stream reset request that hasn't completed yet.
204
- */
205
- ReConfigChunk* CreateStreamResetRequest();
206
-
207
- /**
208
- * Creates the actual RE-CONFIG chunk. A request (which set
209
- * `currentRequest`) must have been created prior.
220
+ * Adds the actual RE-CONFIG chunk to the given Packet. A request (which
221
+ * set `this->currentRequest`) must have been created prior.
210
222
  */
211
- ReConfigChunk* CreateReconfigChunk();
223
+ void CreateReConfigChunk(Packet* packet);
212
224
 
213
225
  /**
214
226
  * Called to validate the `reqSeqNbr`, that it's the next in sequence.
@@ -244,19 +256,21 @@ namespace RTC
244
256
 
245
257
  void OnReConfigTimer(uint64_t& baseTimeoutMs, bool& stop);
246
258
 
247
- /* Pure virtual methods inherited from BackoffTimerHandle::Listener. */
259
+ /* Pure virtual methods inherited from BackoffTimerHandleInterface::Listener. */
248
260
  public:
249
- void OnTimer(BackoffTimerHandle* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
261
+ void OnTimer(BackoffTimerHandleInterface* backoffTimer, uint64_t& baseTimeoutMs, bool& stop) override;
250
262
 
251
263
  private:
252
264
  AssociationListener& associationListener;
253
- TCBContext* tcbContext{ nullptr };
265
+ SharedInterface* shared;
266
+ TCBContext* tcbContext;
267
+ // TODO: SCTP: Implement
268
+ // DataTracker* dataTracker;,
254
269
  // TODO: SCTP: Implement
255
- // DataTracker* dataTracker{ nullptr };,
256
- // ReassemblyQueue* reassemblyQueue{ nullptr };,
257
- // RetransmissionQueue* retransmissionQueue{ nullptr };
270
+ // ReassemblyQueue* reassemblyQueue;,
271
+ RetransmissionQueue* retransmissionQueue;
258
272
  UnwrappedReConfigRequestSn::Unwrapper incomingReConfigRequestSnUnwrapper;
259
- const std::unique_ptr<BackoffTimerHandle> reConfigTimer;
273
+ const std::unique_ptr<BackoffTimerHandleInterface> reConfigTimer;
260
274
  // The next sequence number for outgoing stream requests.
261
275
  uint32_t nextOutgoingReqSeqNbr{ 0 };
262
276
  // The current stream request operation.
@@ -32,9 +32,10 @@ namespace RTC
32
32
  virtual uint32_t GetRemoteInitialTsn() const = 0;
33
33
 
34
34
  /**
35
- * To be called when a RTT has been measured, to update the RTO value.
35
+ * To be called when a RTT (ms) has been measured, to update the RTO
36
+ * value.
36
37
  */
37
- virtual void ObserveRtt(uint64_t rtt) = 0;
38
+ virtual void ObserveRttMs(uint64_t rttMs) = 0;
38
39
 
39
40
  /**
40
41
  * Returns the Retransmission Timeout (RTO) value.