mediasoup 3.20.1 → 3.20.3

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 (49) hide show
  1. package/node/lib/DataConsumer.d.ts +2 -3
  2. package/node/lib/DataConsumer.d.ts.map +1 -1
  3. package/node/lib/DataConsumer.js +8 -6
  4. package/node/lib/DataConsumerTypes.d.ts +5 -4
  5. package/node/lib/DataConsumerTypes.d.ts.map +1 -1
  6. package/node/lib/fbs/data-consumer/send-response.d.ts +21 -0
  7. package/node/lib/fbs/data-consumer/send-response.d.ts.map +1 -0
  8. package/node/lib/fbs/data-consumer/send-response.js +91 -0
  9. package/node/lib/fbs/data-consumer.d.ts +1 -0
  10. package/node/lib/fbs/data-consumer.d.ts.map +1 -1
  11. package/node/lib/fbs/data-consumer.js +4 -1
  12. package/node/lib/fbs/response/body.d.ts +7 -5
  13. package/node/lib/fbs/response/body.d.ts.map +1 -1
  14. package/node/lib/fbs/response/body.js +7 -3
  15. package/node/lib/fbs/response/response.d.ts +3 -2
  16. package/node/lib/fbs/response/response.d.ts.map +1 -1
  17. package/node/lib/test/test-DataConsumer.js +6 -0
  18. package/node/lib/test/test-werift-sctp.js +7 -0
  19. package/npm-scripts.mjs +26 -0
  20. package/package.json +6 -5
  21. package/worker/Makefile +5 -1
  22. package/worker/fbs/dataConsumer.fbs +4 -0
  23. package/worker/fbs/response.fbs +1 -0
  24. package/worker/include/RTC/PortManager.hpp +91 -11
  25. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +3 -3
  26. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +3 -3
  27. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +3 -3
  28. package/worker/include/RTC/TcpServer.hpp +3 -2
  29. package/worker/include/RTC/UdpSocket.hpp +3 -2
  30. package/worker/meson.build +1 -0
  31. package/worker/src/RTC/DataConsumer.cpp +12 -2
  32. package/worker/src/RTC/PipeTransport.cpp +5 -4
  33. package/worker/src/RTC/PlainTransport.cpp +9 -8
  34. package/worker/src/RTC/PortManager.cpp +174 -114
  35. package/worker/src/RTC/SCTP/association/Association.cpp +17 -14
  36. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +15 -5
  37. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +11 -6
  38. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +15 -5
  39. package/worker/src/RTC/TcpServer.cpp +4 -4
  40. package/worker/src/RTC/Transport.cpp +33 -10
  41. package/worker/src/RTC/UdpSocket.cpp +4 -4
  42. package/worker/src/RTC/WebRtcServer.cpp +8 -8
  43. package/worker/src/RTC/WebRtcTransport.cpp +9 -8
  44. package/worker/tasks.py +293 -196
  45. package/worker/test/src/RTC/SCTP/association/TestHeartbeatHandler.cpp +4 -1
  46. package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +5 -2
  47. package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
  48. package/worker/test/src/RTC/TestPortManager.cpp +126 -0
  49. package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
@@ -21,7 +21,7 @@ namespace RTC
21
21
  /* Instance methods. */
22
22
 
23
23
  TransmissionControlBlock::TransmissionControlBlock(
24
- AssociationListenerInterface& associationListener,
24
+ AssociationListenerDeferrer& associationListenerDeferrer,
25
25
  const SctpOptions& sctpOptions,
26
26
  SharedInterface* shared,
27
27
  SendQueueInterface& sendQueue,
@@ -35,7 +35,7 @@ namespace RTC
35
35
  const NegotiatedCapabilities& negotiatedCapabilities,
36
36
  size_t maxPacketLength,
37
37
  std::function<bool()> isAssociationEstablished)
38
- : associationListener(associationListener),
38
+ : associationListenerDeferrer(associationListenerDeferrer),
39
39
  sctpOptions(sctpOptions),
40
40
  shared(shared),
41
41
  packetSender(packetSender),
@@ -71,7 +71,7 @@ namespace RTC
71
71
  sctpOptions.maxReceiverWindowBufferSize, negotiatedCapabilities.messageInterleaving),
72
72
  retransmissionQueue(
73
73
  this,
74
- this->associationListener,
74
+ this->associationListenerDeferrer,
75
75
  localInitialTsn,
76
76
  remoteAdvertisedReceiverWindowCredit,
77
77
  sendQueue,
@@ -80,13 +80,13 @@ namespace RTC
80
80
  negotiatedCapabilities.partialReliability,
81
81
  negotiatedCapabilities.messageInterleaving),
82
82
  streamResetHandler(
83
- this->associationListener,
83
+ this->associationListenerDeferrer,
84
84
  this->shared,
85
85
  this,
86
86
  std::addressof(this->dataTracker),
87
87
  std::addressof(this->reassemblyQueue),
88
88
  std::addressof(this->retransmissionQueue)),
89
- heartbeatHandler(this->associationListener, sctpOptions, this->shared, this)
89
+ heartbeatHandler(this->associationListenerDeferrer, sctpOptions, this->shared, this)
90
90
  {
91
91
  MS_TRACE();
92
92
 
@@ -411,6 +411,11 @@ namespace RTC
411
411
  {
412
412
  MS_TRACE();
413
413
 
414
+ // This is a top-level timer entry point (invoked by libuv outside any other
415
+ // SCTP API call), so it must establish the deferrer scope itself, just like
416
+ // Association does in its own timer handlers.
417
+ const AssociationListenerDeferrer::ScopedDeferrer deferrer(this->associationListenerDeferrer);
418
+
414
419
  // In the COOKIE-ECHO state, let the T1-COOKIE timer trigger
415
420
  // retransmissions, to avoid having two timers doing that.
416
421
  if (this->remoteStateCookie.has_value())
@@ -434,6 +439,11 @@ namespace RTC
434
439
  {
435
440
  MS_TRACE();
436
441
 
442
+ // This is a top-level timer entry point (invoked by libuv outside any other
443
+ // SCTP API call), so it must establish the deferrer scope itself, just like
444
+ // Association does in its own timer handlers.
445
+ const AssociationListenerDeferrer::ScopedDeferrer deferrer(this->associationListenerDeferrer);
446
+
437
447
  this->dataTracker.HandleDelayedAckTimerExpiry();
438
448
 
439
449
  MaySendSackChunk();
@@ -36,16 +36,16 @@ namespace RTC
36
36
  uint16_t minPort,
37
37
  uint16_t maxPort,
38
38
  RTC::Transport::SocketFlags& flags,
39
- uint64_t& portRangeHash)
39
+ RTC::PortManager::PortRangeKey& portRangeKey)
40
40
  : // This may throw.
41
41
  ::TcpServerHandle::TcpServerHandle(
42
- RTC::PortManager::BindTcp(ip, minPort, maxPort, flags, portRangeHash)),
42
+ RTC::PortManager::BindTcp(ip, minPort, maxPort, flags, portRangeKey)),
43
43
  listener(listener),
44
44
  connListener(connListener)
45
45
  {
46
46
  MS_TRACE();
47
47
 
48
- this->portRangeHash = portRangeHash;
48
+ this->portRangeKey = portRangeKey;
49
49
  }
50
50
 
51
51
  TcpServer::~TcpServer()
@@ -54,7 +54,7 @@ namespace RTC
54
54
 
55
55
  if (!this->fixedPort)
56
56
  {
57
- RTC::PortManager::Unbind(this->portRangeHash, this->localPort);
57
+ RTC::PortManager::Unbind(this->portRangeKey, this->localPort);
58
58
  }
59
59
  }
60
60
 
@@ -3058,13 +3058,26 @@ namespace RTC
3058
3058
 
3059
3059
  const auto errorKindStringView = RTC::SCTP::Types::ErrorKindToString(errorKind);
3060
3060
 
3061
- MS_WARN_TAG(
3062
- sctp,
3063
- "SCTP association failed [errorKind:%.*s, message:%.*s]",
3064
- static_cast<int>(errorKindStringView.size()),
3065
- errorKindStringView.data(),
3066
- static_cast<int>(errorMessage.size()),
3067
- errorMessage.data());
3061
+ if (errorKind == RTC::SCTP::Types::ErrorKind::SUCCESS || errorKind == RTC::SCTP::Types::ErrorKind::PEER_REPORTED)
3062
+ {
3063
+ MS_DEBUG_TAG(
3064
+ sctp,
3065
+ "SCTP association failed [errorKind:%.*s, message:%.*s]",
3066
+ static_cast<int>(errorKindStringView.size()),
3067
+ errorKindStringView.data(),
3068
+ static_cast<int>(errorMessage.size()),
3069
+ errorMessage.data());
3070
+ }
3071
+ else
3072
+ {
3073
+ MS_WARN_TAG(
3074
+ sctp,
3075
+ "SCTP association failed [errorKind:%.*s, message:%.*s]",
3076
+ static_cast<int>(errorKindStringView.size()),
3077
+ errorKindStringView.data(),
3078
+ static_cast<int>(errorMessage.size()),
3079
+ errorMessage.data());
3080
+ }
3068
3081
 
3069
3082
  // Tell all DataConsumers.
3070
3083
  for (auto& kv : this->mapDataConsumers)
@@ -3093,10 +3106,20 @@ namespace RTC
3093
3106
  {
3094
3107
  MS_TRACE();
3095
3108
 
3096
- if (errorKind != RTC::SCTP::Types::ErrorKind::SUCCESS)
3097
- {
3098
- const auto errorKindStringView = RTC::SCTP::Types::ErrorKindToString(errorKind);
3109
+ const auto errorKindStringView = RTC::SCTP::Types::ErrorKindToString(errorKind);
3099
3110
 
3111
+ if (errorKind == RTC::SCTP::Types::ErrorKind::SUCCESS || errorKind == RTC::SCTP::Types::ErrorKind::PEER_REPORTED)
3112
+ {
3113
+ MS_DEBUG_TAG(
3114
+ sctp,
3115
+ "SCTP association closed [errorKind:%.*s, message:%.*s]",
3116
+ static_cast<int>(errorKindStringView.size()),
3117
+ errorKindStringView.data(),
3118
+ static_cast<int>(errorMessage.size()),
3119
+ errorMessage.data());
3120
+ }
3121
+ else
3122
+ {
3100
3123
  MS_WARN_TAG(
3101
3124
  sctp,
3102
3125
  "SCTP association closed [errorKind:%.*s, message:%.*s]",
@@ -26,15 +26,15 @@ namespace RTC
26
26
  uint16_t minPort,
27
27
  uint16_t maxPort,
28
28
  RTC::Transport::SocketFlags& flags,
29
- uint64_t& portRangeHash)
29
+ RTC::PortManager::PortRangeKey& portRangeKey)
30
30
  : // This may throw.
31
31
  ::UdpSocketHandle::UdpSocketHandle(
32
- RTC::PortManager::BindUdp(ip, minPort, maxPort, flags, portRangeHash)),
32
+ RTC::PortManager::BindUdp(ip, minPort, maxPort, flags, portRangeKey)),
33
33
  listener(listener)
34
34
  {
35
35
  MS_TRACE();
36
36
 
37
- this->portRangeHash = portRangeHash;
37
+ this->portRangeKey = portRangeKey;
38
38
  }
39
39
 
40
40
  UdpSocket::~UdpSocket()
@@ -43,7 +43,7 @@ namespace RTC
43
43
 
44
44
  if (!this->fixedPort)
45
45
  {
46
- RTC::PortManager::Unbind(this->portRangeHash, this->localPort);
46
+ RTC::PortManager::Unbind(this->portRangeKey, this->localPort);
47
47
  }
48
48
  }
49
49
 
@@ -96,7 +96,7 @@ namespace RTC
96
96
 
97
97
  if (listenInfo->portRange()->min() != 0 && listenInfo->portRange()->max() != 0)
98
98
  {
99
- uint64_t portRangeHash{ 0u };
99
+ RTC::PortManager::PortRangeKey portRangeKey{};
100
100
 
101
101
  udpSocket = new RTC::UdpSocket(
102
102
  this,
@@ -104,7 +104,7 @@ namespace RTC
104
104
  listenInfo->portRange()->min(),
105
105
  listenInfo->portRange()->max(),
106
106
  flags,
107
- portRangeHash);
107
+ portRangeKey);
108
108
  }
109
109
  else if (listenInfo->port() != 0)
110
110
  {
@@ -115,7 +115,7 @@ namespace RTC
115
115
  // required.
116
116
  else
117
117
  {
118
- uint64_t portRangeHash{ 0u };
118
+ RTC::PortManager::PortRangeKey portRangeKey{};
119
119
 
120
120
  udpSocket = new RTC::UdpSocket(
121
121
  this,
@@ -123,7 +123,7 @@ namespace RTC
123
123
  Settings::configuration.rtcMinPort,
124
124
  Settings::configuration.rtcMaxPort,
125
125
  flags,
126
- portRangeHash);
126
+ portRangeKey);
127
127
  }
128
128
 
129
129
  this->udpSocketOrTcpServers.emplace_back(
@@ -152,7 +152,7 @@ namespace RTC
152
152
 
153
153
  if (listenInfo->portRange()->min() != 0 && listenInfo->portRange()->max() != 0)
154
154
  {
155
- uint64_t portRangeHash{ 0u };
155
+ RTC::PortManager::PortRangeKey portRangeKey{};
156
156
 
157
157
  tcpServer = new RTC::TcpServer(
158
158
  this,
@@ -161,7 +161,7 @@ namespace RTC
161
161
  listenInfo->portRange()->min(),
162
162
  listenInfo->portRange()->max(),
163
163
  flags,
164
- portRangeHash);
164
+ portRangeKey);
165
165
  }
166
166
  else if (listenInfo->port() != 0)
167
167
  {
@@ -172,7 +172,7 @@ namespace RTC
172
172
  // required.
173
173
  else
174
174
  {
175
- uint64_t portRangeHash{ 0u };
175
+ RTC::PortManager::PortRangeKey portRangeKey{};
176
176
 
177
177
  tcpServer = new RTC::TcpServer(
178
178
  this,
@@ -181,7 +181,7 @@ namespace RTC
181
181
  Settings::configuration.rtcMinPort,
182
182
  Settings::configuration.rtcMaxPort,
183
183
  flags,
184
- portRangeHash);
184
+ portRangeKey);
185
185
  }
186
186
 
187
187
  this->udpSocketOrTcpServers.emplace_back(
@@ -5,6 +5,7 @@
5
5
  #include "FBS/webRtcTransport.h"
6
6
  #include "Logger.hpp"
7
7
  #include "MediaSoupErrors.hpp"
8
+ #include "RTC/PortManager.hpp"
8
9
  #include "Settings.hpp"
9
10
  #include "Utils.hpp"
10
11
  #include <cmath> // std::pow()
@@ -81,7 +82,7 @@ namespace RTC
81
82
 
82
83
  if (listenInfo->portRange()->min() != 0 && listenInfo->portRange()->max() != 0)
83
84
  {
84
- uint64_t portRangeHash{ 0u };
85
+ RTC::PortManager::PortRangeKey portRangeKey;
85
86
 
86
87
  udpSocket = new RTC::UdpSocket(
87
88
  this,
@@ -89,7 +90,7 @@ namespace RTC
89
90
  listenInfo->portRange()->min(),
90
91
  listenInfo->portRange()->max(),
91
92
  flags,
92
- portRangeHash);
93
+ portRangeKey);
93
94
  }
94
95
  else if (listenInfo->port() != 0)
95
96
  {
@@ -100,7 +101,7 @@ namespace RTC
100
101
  // required.
101
102
  else
102
103
  {
103
- uint64_t portRangeHash{ 0u };
104
+ RTC::PortManager::PortRangeKey portRangeKey;
104
105
 
105
106
  udpSocket = new RTC::UdpSocket(
106
107
  this,
@@ -108,7 +109,7 @@ namespace RTC
108
109
  Settings::configuration.rtcMinPort,
109
110
  Settings::configuration.rtcMaxPort,
110
111
  flags,
111
- portRangeHash);
112
+ portRangeKey);
112
113
  }
113
114
 
114
115
  this->udpSockets[udpSocket] = announcedAddress;
@@ -151,7 +152,7 @@ namespace RTC
151
152
 
152
153
  if (listenInfo->portRange()->min() != 0 && listenInfo->portRange()->max() != 0)
153
154
  {
154
- uint64_t portRangeHash{ 0u };
155
+ RTC::PortManager::PortRangeKey portRangeKey{};
155
156
 
156
157
  tcpServer = new RTC::TcpServer(
157
158
  this,
@@ -160,7 +161,7 @@ namespace RTC
160
161
  listenInfo->portRange()->min(),
161
162
  listenInfo->portRange()->max(),
162
163
  flags,
163
- portRangeHash);
164
+ portRangeKey);
164
165
  }
165
166
  else if (listenInfo->port() != 0)
166
167
  {
@@ -171,7 +172,7 @@ namespace RTC
171
172
  // required.
172
173
  else
173
174
  {
174
- uint64_t portRangeHash{ 0u };
175
+ RTC::PortManager::PortRangeKey portRangeKey{};
175
176
 
176
177
  tcpServer = new RTC::TcpServer(
177
178
  this,
@@ -180,7 +181,7 @@ namespace RTC
180
181
  Settings::configuration.rtcMinPort,
181
182
  Settings::configuration.rtcMaxPort,
182
183
  flags,
183
- portRangeHash);
184
+ portRangeKey);
184
185
  }
185
186
 
186
187
  this->tcpServers[tcpServer] = announcedAddress;