mediasoup 3.23.2 → 3.24.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 (70) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/node/lib/DataProducer.d.ts +1 -1
  3. package/node/lib/DataProducer.d.ts.map +1 -1
  4. package/node/lib/DataProducer.js +2 -2
  5. package/node/lib/DataProducerTypes.d.ts +1 -1
  6. package/node/lib/DataProducerTypes.d.ts.map +1 -1
  7. package/node/lib/fbs/data-producer/send-notification.d.ts +5 -2
  8. package/node/lib/fbs/data-producer/send-notification.d.ts.map +1 -1
  9. package/node/lib/fbs/data-producer/send-notification.js +17 -5
  10. package/node/lib/test/test-PipeTransport.js +18 -4
  11. package/package.json +3 -3
  12. package/worker/fbs/dataProducer.fbs +1 -0
  13. package/worker/include/RTC/DataConsumer.hpp +1 -0
  14. package/worker/include/RTC/DataProducer.hpp +4 -2
  15. package/worker/include/RTC/RateCalculator.hpp +5 -5
  16. package/worker/include/RTC/Router.hpp +2 -1
  17. package/worker/include/RTC/SubchannelsCodec.hpp +27 -17
  18. package/worker/include/RTC/Transport.hpp +4 -2
  19. package/worker/src/Channel/ChannelMessageRegistrator.cpp +2 -0
  20. package/worker/src/Channel/ChannelRequest.cpp +2 -0
  21. package/worker/src/Channel/ChannelSocket.cpp +4 -0
  22. package/worker/src/DepLibUV.cpp +6 -3
  23. package/worker/src/RTC/ActiveSpeakerObserver.cpp +8 -0
  24. package/worker/src/RTC/AudioLevelObserver.cpp +4 -0
  25. package/worker/src/RTC/DataConsumer.cpp +19 -2
  26. package/worker/src/RTC/DataProducer.cpp +11 -4
  27. package/worker/src/RTC/DirectTransport.cpp +4 -0
  28. package/worker/src/RTC/DtlsTransport.cpp +16 -0
  29. package/worker/src/RTC/ICE/IceCandidate.cpp +8 -0
  30. package/worker/src/RTC/ICE/StunPacket.cpp +2 -0
  31. package/worker/src/RTC/NackGenerator.cpp +2 -0
  32. package/worker/src/RTC/PipeTransport.cpp +4 -0
  33. package/worker/src/RTC/PlainTransport.cpp +10 -0
  34. package/worker/src/RTC/PortManager.cpp +8 -0
  35. package/worker/src/RTC/Producer.cpp +4 -0
  36. package/worker/src/RTC/RTCP/CompoundPacket.cpp +8 -0
  37. package/worker/src/RTC/RTCP/Feedback.cpp +8 -0
  38. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +2 -0
  39. package/worker/src/RTC/RTCP/FeedbackPsSli.cpp +2 -0
  40. package/worker/src/RTC/RTCP/FeedbackPsVbcm.cpp +2 -0
  41. package/worker/src/RTC/RTCP/FeedbackRtpNack.cpp +2 -0
  42. package/worker/src/RTC/RTCP/FeedbackRtpTllei.cpp +2 -0
  43. package/worker/src/RTC/RTCP/FeedbackRtpTmmb.cpp +5 -0
  44. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +8 -0
  45. package/worker/src/RTC/RTCP/Sdes.cpp +2 -0
  46. package/worker/src/RTC/RTP/Codecs/AV1.cpp +2 -0
  47. package/worker/src/RTC/RTP/Codecs/DependencyDescriptor.cpp +6 -0
  48. package/worker/src/RTC/RTP/Codecs/VP8.cpp +2 -0
  49. package/worker/src/RTC/RateCalculator.cpp +42 -37
  50. package/worker/src/RTC/Router.cpp +12 -3
  51. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +5 -0
  52. package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +2 -0
  53. package/worker/src/RTC/SCTP/association/Association.cpp +2 -0
  54. package/worker/src/RTC/SCTP/rx/DataTracker.cpp +2 -0
  55. package/worker/src/RTC/SeqManager.cpp +12 -0
  56. package/worker/src/RTC/SrtpSession.cpp +6 -0
  57. package/worker/src/RTC/SubchannelsCodec.cpp +38 -6
  58. package/worker/src/RTC/Transport.cpp +12 -6
  59. package/worker/src/RTC/TransportCongestionControlClient.cpp +12 -0
  60. package/worker/src/RTC/TransportCongestionControlServer.cpp +2 -0
  61. package/worker/src/Utils/BitStream.cpp +2 -0
  62. package/worker/src/Worker.cpp +2 -0
  63. package/worker/src/handles/SignalHandle.cpp +4 -0
  64. package/worker/src/handles/TcpConnectionHandle.cpp +12 -0
  65. package/worker/src/handles/TcpServerHandle.cpp +6 -0
  66. package/worker/src/handles/TimerHandle.cpp +4 -0
  67. package/worker/src/handles/UdpSocketHandle.cpp +10 -0
  68. package/worker/src/handles/UnixStreamSocketHandle.cpp +10 -0
  69. package/worker/test/src/RTC/TestRateCalculator.cpp +45 -45
  70. package/worker/test/src/RTC/TestSubchannelsCodec.cpp +161 -19
@@ -30,9 +30,9 @@ namespace RTC
30
30
  MS_TRACE();
31
31
 
32
32
  // Ignore too old data. Should never happen.
33
- if (this->oldestItemStartTime.has_value() && Utils::Number::IsLowerThan<uint64_t>(nowMs, *this->oldestItemStartTime))
33
+ if (this->oldestItemStartTimeMs.has_value() && Utils::Number::IsLowerThan<uint64_t>(nowMs, *this->oldestItemStartTimeMs))
34
34
  {
35
- MS_WARN_DEV("nowMs < this->oldestItemStartTime, should never happen");
35
+ MS_WARN_DEV("nowMs < this->oldestItemStartTimeMs, should never happen");
36
36
 
37
37
  return;
38
38
  }
@@ -45,12 +45,12 @@ namespace RTC
45
45
  // If the elapsed time from the newest item start time is greater than the
46
46
  // item size (in milliseconds), increase the item index.
47
47
  if (
48
- this->newestItemIndex < 0 || !this->newestItemStartTime.has_value() ||
48
+ this->newestItemIndex < 0 || !this->newestItemStartTimeMs.has_value() ||
49
49
  Utils::Number::IsHigherOrEqualThan<uint64_t>(
50
- nowMs - *this->newestItemStartTime, this->itemSizeMs))
50
+ nowMs - *this->newestItemStartTimeMs, this->itemSizeMs))
51
51
  {
52
52
  this->newestItemIndex++;
53
- this->newestItemStartTime = nowMs;
53
+ this->newestItemStartTimeMs = nowMs;
54
54
 
55
55
  if (this->newestItemIndex >= this->windowItems)
56
56
  {
@@ -79,13 +79,15 @@ namespace RTC
79
79
 
80
80
  // Set the newest item.
81
81
  BufferItem& item = this->buffer[this->newestItemIndex];
82
- item.count = size;
83
- item.time = nowMs;
82
+
83
+ item.count = size;
84
+ item.timeMs = nowMs;
84
85
  }
85
86
  else
86
87
  {
87
88
  // Update the newest item.
88
89
  BufferItem& item = this->buffer[this->newestItemIndex];
90
+
89
91
  item.count += size;
90
92
  }
91
93
 
@@ -93,27 +95,27 @@ namespace RTC
93
95
  if (this->oldestItemIndex < 0)
94
96
  {
95
97
  MS_DEBUG_DEV(
96
- "this->oldestItemIndex < 0, setting this->oldestItemIndex and this->oldestItemStartTime");
98
+ "this->oldestItemIndex < 0, setting this->oldestItemIndex and this->oldestItemStartTimeMs");
97
99
 
98
- this->oldestItemIndex = this->newestItemIndex;
99
- this->oldestItemStartTime = nowMs;
100
+ this->oldestItemIndex = this->newestItemIndex;
101
+ this->oldestItemStartTimeMs = nowMs;
100
102
  }
101
103
 
102
104
  this->totalCount += size;
103
105
 
104
- // Reset lastRate and lastTime so GetRate() will calculate rate again even
105
- // if called with same now in the same loop iteration.
106
- this->lastRate = 0;
107
- this->lastTime = std::nullopt;
106
+ // Reset `lastRate` and `lastTimeMs` so `GetRate()` will calculate rate
107
+ // again even if called with same now in the same loop iteration.
108
+ this->lastRate = 0;
109
+ this->lastTimeMs = std::nullopt;
108
110
  }
109
111
 
110
112
  uint32_t RateCalculator::GetRate(uint64_t nowMs)
111
113
  {
112
114
  MS_TRACE();
113
115
 
114
- if (this->lastTime.has_value() && nowMs == *this->lastTime)
116
+ if (this->lastTimeMs.has_value() && nowMs == *this->lastTimeMs)
115
117
  {
116
- MS_DEBUG_DEV("nowMs == this->lastTime, early return");
118
+ MS_DEBUG_DEV("nowMs == this->lastTimeMs, early return");
117
119
 
118
120
  return this->lastRate;
119
121
  }
@@ -122,8 +124,8 @@ namespace RTC
122
124
 
123
125
  const float scale = this->scale / this->windowSizeMs;
124
126
 
125
- this->lastTime = nowMs;
126
- this->lastRate = static_cast<uint32_t>(std::trunc((this->totalCount * scale) + 0.5f));
127
+ this->lastTimeMs = nowMs;
128
+ this->lastRate = static_cast<uint32_t>(std::trunc((this->totalCount * scale) + 0.5f));
127
129
 
128
130
  return this->lastRate;
129
131
  }
@@ -137,20 +139,20 @@ namespace RTC
137
139
  0,
138
140
  sizeof(BufferItem) * this->buffer.size());
139
141
 
140
- this->newestItemStartTime = std::nullopt;
141
- this->newestItemIndex = -1;
142
- this->oldestItemStartTime = std::nullopt;
143
- this->oldestItemIndex = -1;
144
- this->totalCount = 0u;
145
- this->lastRate = 0u;
146
- this->lastTime = std::nullopt;
142
+ this->newestItemStartTimeMs = std::nullopt;
143
+ this->newestItemIndex = -1;
144
+ this->oldestItemStartTimeMs = std::nullopt;
145
+ this->oldestItemIndex = -1;
146
+ this->totalCount = 0u;
147
+ this->lastRate = 0u;
148
+ this->lastTimeMs = std::nullopt;
147
149
  }
148
150
 
149
151
  void RateCalculator::RemoveOldData(uint64_t nowMs)
150
152
  {
151
153
  MS_TRACE();
152
154
 
153
- if (!this->oldestItemStartTime.has_value())
155
+ if (!this->oldestItemStartTimeMs.has_value())
154
156
  {
155
157
  return;
156
158
  }
@@ -164,29 +166,31 @@ namespace RTC
164
166
  const uint64_t newOldestTime = nowMs - this->windowSizeMs;
165
167
 
166
168
  // Oldest item already removed.
167
- if (Utils::Number::IsLowerThan<uint64_t>(newOldestTime, *this->oldestItemStartTime))
169
+ if (Utils::Number::IsLowerThan<uint64_t>(newOldestTime, *this->oldestItemStartTimeMs))
168
170
  {
169
171
  return;
170
172
  }
171
173
 
172
174
  // A whole window size time has elapsed since last entry. Reset the buffer.
173
175
  if (
174
- this->newestItemStartTime.has_value() &&
175
- Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->newestItemStartTime))
176
+ this->newestItemStartTimeMs.has_value() &&
177
+ Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->newestItemStartTimeMs))
176
178
  {
177
- MS_DEBUG_DEV("newOldestTime >= this->newestItemStartTime, resetting the buffer");
179
+ MS_DEBUG_DEV("newOldestTime >= this->newestItemStartTimeMs, resetting the buffer");
178
180
 
179
181
  Reset();
180
182
 
181
183
  return;
182
184
  }
183
185
 
184
- while (Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->oldestItemStartTime))
186
+ while (Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->oldestItemStartTimeMs))
185
187
  {
186
188
  BufferItem& oldestItem = this->buffer[this->oldestItemIndex];
189
+
187
190
  this->totalCount -= oldestItem.count;
188
- oldestItem.count = 0u;
189
- oldestItem.time = 0u;
191
+
192
+ oldestItem.count = 0u;
193
+ oldestItem.timeMs = 0u;
190
194
 
191
195
  if (++this->oldestItemIndex >= this->windowItems)
192
196
  {
@@ -194,19 +198,20 @@ namespace RTC
194
198
  }
195
199
 
196
200
  const BufferItem& newOldestItem = this->buffer[this->oldestItemIndex];
197
- this->oldestItemStartTime = newOldestItem.time;
201
+
202
+ this->oldestItemStartTimeMs = newOldestItem.timeMs;
198
203
  }
199
204
  }
200
205
 
201
206
  void RtpDataCounter::Update(const RTC::RTP::Packet* packet)
202
207
  {
208
+ MS_TRACE();
209
+
203
210
  this->packets++;
204
211
 
205
212
  if (!this->ignorePaddingOnlyPackets || packet->GetPayloadLength() > 0)
206
213
  {
207
- const uint64_t nowMs = this->shared->GetTimeMs();
208
-
209
- this->rate.Update(packet->GetLength(), nowMs);
214
+ this->rate.Update(packet->GetLength(), this->shared->GetTimeMs());
210
215
  }
211
216
  }
212
217
  } // namespace RTC
@@ -910,7 +910,8 @@ namespace RTC
910
910
  RTC::DataProducer* dataProducer,
911
911
  RTC::SCTP::Message message,
912
912
  std::vector<uint16_t>& subchannels,
913
- std::optional<uint16_t> requiredSubchannel)
913
+ std::optional<uint16_t> requiredSubchannel,
914
+ std::optional<uint16_t> ignoredSubchannel)
914
915
  {
915
916
  MS_TRACE();
916
917
 
@@ -936,7 +937,8 @@ namespace RTC
936
937
  // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move, bugprone-use-after-move, hicpp-invalid-access-moved)
937
938
  message.SetStreamId(streamId);
938
939
 
939
- dataConsumer->SendMessage(std::move(message), subchannels, requiredSubchannel);
940
+ dataConsumer->SendMessage(
941
+ std::move(message), subchannels, requiredSubchannel, ignoredSubchannel);
940
942
  }
941
943
  // NOTE: Here we are cloning the message before passing it to each
942
944
  // DataConsumer because each DataConsumer will pass std::move(message)
@@ -949,7 +951,8 @@ namespace RTC
949
951
  // DataConsumer.
950
952
  clonedMessage.SetStreamId(streamId);
951
953
 
952
- dataConsumer->SendMessage(std::move(clonedMessage), subchannels, requiredSubchannel);
954
+ dataConsumer->SendMessage(
955
+ std::move(clonedMessage), subchannels, requiredSubchannel, ignoredSubchannel);
953
956
  }
954
957
  }
955
958
  }
@@ -1063,12 +1066,16 @@ namespace RTC
1063
1066
 
1064
1067
  void Router::OnRtpObserverAddProducer(RTC::RtpObserver* rtpObserver, RTC::Producer* producer)
1065
1068
  {
1069
+ MS_TRACE();
1070
+
1066
1071
  // Add to the map.
1067
1072
  this->mapProducerRtpObservers[producer].insert(rtpObserver);
1068
1073
  }
1069
1074
 
1070
1075
  void Router::OnRtpObserverRemoveProducer(RTC::RtpObserver* rtpObserver, RTC::Producer* producer)
1071
1076
  {
1077
+ MS_TRACE();
1078
+
1072
1079
  // Remove from the map.
1073
1080
  this->mapProducerRtpObservers[producer].erase(rtpObserver);
1074
1081
  }
@@ -1076,6 +1083,8 @@ namespace RTC
1076
1083
  RTC::Producer* Router::RtpObserverGetProducer(
1077
1084
  RTC::RtpObserver* /* rtpObserver */, const std::string& id)
1078
1085
  {
1086
+ MS_TRACE();
1087
+
1079
1088
  const auto it = this->mapProducers.find(id);
1080
1089
 
1081
1090
  if (it == this->mapProducers.end())
@@ -1,6 +1,7 @@
1
1
  #define MS_CLASS "RTC::RtpHeaderExtensionUri"
2
2
  // #define MS_LOG_DEV_LEVEL 3
3
3
 
4
+ #include "Logger.hpp"
4
5
  #include "RTC/RtpDictionaries.hpp"
5
6
 
6
7
  namespace RTC
@@ -10,6 +11,8 @@ namespace RTC
10
11
  RtpHeaderExtensionUri::Type RtpHeaderExtensionUri::TypeFromFbs(
11
12
  FBS::RtpParameters::RtpHeaderExtensionUri uri)
12
13
  {
14
+ MS_TRACE();
15
+
13
16
  switch (uri)
14
17
  {
15
18
  case FBS::RtpParameters::RtpHeaderExtensionUri::Mid:
@@ -79,6 +82,8 @@ namespace RTC
79
82
  FBS::RtpParameters::RtpHeaderExtensionUri RtpHeaderExtensionUri::TypeToFbs(
80
83
  RtpHeaderExtensionUri::Type uri)
81
84
  {
85
+ MS_TRACE();
86
+
82
87
  switch (uri)
83
88
  {
84
89
  case RtpHeaderExtensionUri::Type::MID:
@@ -308,6 +308,8 @@ namespace RTC
308
308
 
309
309
  void RtpParameters::ValidateEncodings()
310
310
  {
311
+ MS_TRACE();
312
+
311
313
  uint8_t firstMediaPayloadType{ 0 };
312
314
 
313
315
  {
@@ -345,6 +345,8 @@ namespace RTC
345
345
 
346
346
  std::optional<AssociationMetrics> Association::MakeMetrics() const
347
347
  {
348
+ MS_TRACE();
349
+
348
350
  if (!this->tcb)
349
351
  {
350
352
  return std::nullopt;
@@ -176,6 +176,8 @@ namespace RTC
176
176
 
177
177
  bool DataTracker::HandleForwardTsn(uint32_t newCumulativeTsn)
178
178
  {
179
+ MS_TRACE();
180
+
179
181
  // Forward-TSN is sent to make the receiver (this association) "forget"
180
182
  // about partly received (or not received at all) data, up until
181
183
  // `newCumulativeTsn`.
@@ -11,24 +11,32 @@ namespace RTC
11
11
  template<typename T, uint8_t N>
12
12
  bool SeqManager<T, N>::SeqLowerThan::operator()(T lhs, T rhs) const
13
13
  {
14
+ MS_TRACE();
15
+
14
16
  return Utils::Number::IsLowerThan<T, N>(lhs, rhs);
15
17
  }
16
18
 
17
19
  template<typename T, uint8_t N>
18
20
  bool SeqManager<T, N>::SeqHigherThan::operator()(T lhs, T rhs) const
19
21
  {
22
+ MS_TRACE();
23
+
20
24
  return Utils::Number::IsHigherThan<T, N>(lhs, rhs);
21
25
  }
22
26
 
23
27
  template<typename T, uint8_t N>
24
28
  bool SeqManager<T, N>::IsSeqHigherThan(T lhs, T rhs)
25
29
  {
30
+ MS_TRACE();
31
+
26
32
  return Utils::Number::IsHigherThan<T, N>(lhs, rhs);
27
33
  }
28
34
 
29
35
  template<typename T, uint8_t N>
30
36
  bool SeqManager<T, N>::IsSeqLowerThan(T lhs, T rhs)
31
37
  {
38
+ MS_TRACE();
39
+
32
40
  return Utils::Number::IsLowerThan<T, N>(lhs, rhs);
33
41
  }
34
42
 
@@ -179,12 +187,16 @@ namespace RTC
179
187
  template<typename T, uint8_t N>
180
188
  T SeqManager<T, N>::GetMaxInput() const
181
189
  {
190
+ MS_TRACE();
191
+
182
192
  return this->maxInput;
183
193
  }
184
194
 
185
195
  template<typename T, uint8_t N>
186
196
  T SeqManager<T, N>::GetMaxOutput() const
187
197
  {
198
+ MS_TRACE();
199
+
188
200
  // 'maxOutput' is stored in the offset-less space (as 'base' and comparisons
189
201
  // use it), so apply 'initialOutput' here, just like `Input()` does before
190
202
  // returning the output to the caller.
@@ -17,6 +17,8 @@ namespace RTC
17
17
 
18
18
  void SrtpSession::ClassInit()
19
19
  {
20
+ MS_TRACE();
21
+
20
22
  // Set libsrtp event handler.
21
23
  const srtp_err_status_t err =
22
24
  srtp_install_event_handler(static_cast<srtp_event_handler_func_t*>(OnSrtpEvent));
@@ -30,6 +32,8 @@ namespace RTC
30
32
 
31
33
  FBS::SrtpParameters::SrtpCryptoSuite SrtpSession::CryptoSuiteToFbs(CryptoSuite cryptoSuite)
32
34
  {
35
+ MS_TRACE();
36
+
33
37
  switch (cryptoSuite)
34
38
  {
35
39
  case SrtpSession::CryptoSuite::AEAD_AES_256_GCM:
@@ -58,6 +62,8 @@ namespace RTC
58
62
 
59
63
  SrtpSession::CryptoSuite SrtpSession::CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite)
60
64
  {
65
+ MS_TRACE();
66
+
61
67
  switch (cryptoSuite)
62
68
  {
63
69
  case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM:
@@ -12,12 +12,13 @@ namespace RTC
12
12
  bool SubchannelsCodec::EncodeSubchannels(
13
13
  RTC::SCTP::Message& message,
14
14
  const std::vector<uint16_t>& subchannels,
15
- std::optional<uint16_t> requiredSubchannel)
15
+ std::optional<uint16_t> requiredSubchannel,
16
+ std::optional<uint16_t> ignoredSubchannel)
16
17
  {
17
18
  MS_TRACE();
18
19
 
19
20
  // Nothing to encode.
20
- if (subchannels.empty() && !requiredSubchannel.has_value())
21
+ if (subchannels.empty() && !requiredSubchannel.has_value() && !ignoredSubchannel.has_value())
21
22
  {
22
23
  return false;
23
24
  }
@@ -31,6 +32,7 @@ namespace RTC
31
32
 
32
33
  const auto subchannelsCount = static_cast<uint16_t>(subchannels.size());
33
34
  const bool requiredSubchannelFlag = requiredSubchannel.has_value();
35
+ const bool ignoredSubchannelFlag = ignoredSubchannel.has_value();
34
36
 
35
37
  // Length of the header to prepend.
36
38
  size_t headerLen =
@@ -41,6 +43,11 @@ namespace RTC
41
43
  headerLen += 2;
42
44
  }
43
45
 
46
+ if (ignoredSubchannelFlag)
47
+ {
48
+ headerLen += 2;
49
+ }
50
+
44
51
  const auto payload = message.GetPayload();
45
52
 
46
53
  // Build the whole new payload at once (header followed by the original
@@ -54,6 +61,11 @@ namespace RTC
54
61
  magicToken |= SubchannelsCodec::RequiredSubchannelFlagMask;
55
62
  }
56
63
 
64
+ if (ignoredSubchannelFlag)
65
+ {
66
+ magicToken |= SubchannelsCodec::IgnoredSubchannelFlagMask;
67
+ }
68
+
57
69
  size_t offset = 0;
58
70
 
59
71
  Utils::Byte::Set8Bytes(newPayload.data(), offset, magicToken);
@@ -74,6 +86,12 @@ namespace RTC
74
86
  offset += 2;
75
87
  }
76
88
 
89
+ if (ignoredSubchannelFlag)
90
+ {
91
+ Utils::Byte::Set2Bytes(newPayload.data(), offset, ignoredSubchannel.value());
92
+ offset += 2;
93
+ }
94
+
77
95
  // Append the original payload right after the encoded header.
78
96
  std::ranges::copy(payload, newPayload.begin() + offset);
79
97
 
@@ -85,7 +103,8 @@ namespace RTC
85
103
  bool SubchannelsCodec::DecodeSubchannels(
86
104
  RTC::SCTP::Message& message,
87
105
  std::vector<uint16_t>& subchannels,
88
- std::optional<uint16_t>& requiredSubchannel)
106
+ std::optional<uint16_t>& requiredSubchannel,
107
+ std::optional<uint16_t>& ignoredSubchannel)
89
108
  {
90
109
  MS_TRACE();
91
110
 
@@ -102,13 +121,15 @@ namespace RTC
102
121
  const uint64_t magicToken = Utils::Byte::Get8Bytes(payload.data(), 0);
103
122
 
104
123
  // The message does not start with the Magic Token, so nothing to decode.
105
- if ((magicToken & ~SubchannelsCodec::RequiredSubchannelFlagMask) != SubchannelsCodec::MagicToken)
124
+ if ((magicToken & ~SubchannelsCodec::FlagsMask) != SubchannelsCodec::MagicToken)
106
125
  {
107
126
  return false;
108
127
  }
109
128
 
110
129
  const bool requiredSubchannelFlag =
111
130
  (magicToken & SubchannelsCodec::RequiredSubchannelFlagMask) != 0;
131
+ const bool ignoredSubchannelFlag =
132
+ (magicToken & SubchannelsCodec::IgnoredSubchannelFlagMask) != 0;
112
133
 
113
134
  const uint16_t subchannelsCount = Utils::Byte::Get2Bytes(payload.data(), 8);
114
135
 
@@ -116,7 +137,7 @@ namespace RTC
116
137
  size_t offset = 10;
117
138
 
118
139
  // Bytes needed to hold all announced subchannels and, if present, the
119
- // requiredSubchannel.
140
+ // requiredSubchannel and the ignoredSubchannel.
120
141
  size_t neededLen = offset + (static_cast<size_t>(subchannelsCount) * 2);
121
142
 
122
143
  if (requiredSubchannelFlag)
@@ -124,9 +145,14 @@ namespace RTC
124
145
  neededLen += 2;
125
146
  }
126
147
 
148
+ if (ignoredSubchannelFlag)
149
+ {
150
+ neededLen += 2;
151
+ }
152
+
127
153
  if (len < neededLen)
128
154
  {
129
- MS_WARN_DEV("message too short to hold announced subchannels, ignoring");
155
+ MS_WARN_DEV("message too short to hold announced fields, ignoring");
130
156
 
131
157
  return false;
132
158
  }
@@ -145,6 +171,12 @@ namespace RTC
145
171
  offset += 2;
146
172
  }
147
173
 
174
+ if (ignoredSubchannelFlag)
175
+ {
176
+ ignoredSubchannel = Utils::Byte::Get2Bytes(payload.data(), offset);
177
+ offset += 2;
178
+ }
179
+
148
180
  // Remove the decoded header from the beginning of the message payload.
149
181
  message.RemovePayloadFront(offset);
150
182
 
@@ -2826,12 +2826,13 @@ namespace RTC
2826
2826
  RTC::DataProducer* dataProducer,
2827
2827
  RTC::SCTP::Message message,
2828
2828
  std::vector<uint16_t>& subchannels,
2829
- std::optional<uint16_t> requiredSubchannel)
2829
+ std::optional<uint16_t> requiredSubchannel,
2830
+ std::optional<uint16_t> ignoredSubchannel)
2830
2831
  {
2831
2832
  MS_TRACE();
2832
2833
 
2833
2834
  this->listener->OnTransportDataProducerMessageReceived(
2834
- this, dataProducer, std::move(message), subchannels, requiredSubchannel);
2835
+ this, dataProducer, std::move(message), subchannels, requiredSubchannel, ignoredSubchannel);
2835
2836
  }
2836
2837
 
2837
2838
  void Transport::OnDataProducerPaused(RTC::DataProducer* dataProducer)
@@ -2875,6 +2876,8 @@ namespace RTC
2875
2876
  void Transport::OnDataConsumerNeedBufferedAmountLowThreshold(
2876
2877
  const RTC::DataConsumer* dataConsumer, uint32_t& bufferedAmountLowThreshold) const
2877
2878
  {
2879
+ MS_TRACE();
2880
+
2878
2881
  if (this->sctpAssociation)
2879
2882
  {
2880
2883
  bufferedAmountLowThreshold =
@@ -3150,15 +3153,18 @@ namespace RTC
3150
3153
  {
3151
3154
  std::vector<uint16_t> subchannels;
3152
3155
  std::optional<uint16_t> requiredSubchannel;
3156
+ std::optional<uint16_t> ignoredSubchannel;
3153
3157
 
3154
- // When this is a pipe transport, the subchannels and required subchannel
3155
- // may be encoded at the beginning of the message payload.
3158
+ // When this is a pipe transport, the subchannels, required subchannel and
3159
+ // ignored subchannel may be encoded at the beginning of the message payload.
3156
3160
  if (this->IsPipe())
3157
3161
  {
3158
- RTC::SubchannelsCodec::DecodeSubchannels(message, subchannels, requiredSubchannel);
3162
+ RTC::SubchannelsCodec::DecodeSubchannels(
3163
+ message, subchannels, requiredSubchannel, ignoredSubchannel);
3159
3164
  }
3160
3165
 
3161
- dataProducer->ReceiveMessage(std::move(message), subchannels, requiredSubchannel);
3166
+ dataProducer->ReceiveMessage(
3167
+ std::move(message), subchannels, requiredSubchannel, ignoredSubchannel);
3162
3168
  }
3163
3169
  catch (std::exception& error)
3164
3170
  {
@@ -59,6 +59,8 @@ namespace RTC
59
59
 
60
60
  void TransportCongestionControlClient::InitializeController()
61
61
  {
62
+ MS_TRACE();
63
+
62
64
  MS_ASSERT(this->rtpTransportControllerSend == nullptr, "transport controller already initialized");
63
65
 
64
66
  webrtc::BitrateConstraints bitrateConfig;
@@ -88,6 +90,8 @@ namespace RTC
88
90
 
89
91
  void TransportCongestionControlClient::DestroyController()
90
92
  {
93
+ MS_TRACE();
94
+
91
95
  delete this->rtpTransportControllerSend;
92
96
  this->rtpTransportControllerSend = nullptr;
93
97
 
@@ -243,6 +247,8 @@ namespace RTC
243
247
 
244
248
  void TransportCongestionControlClient::UpdatePacketLoss(double packetLoss)
245
249
  {
250
+ MS_TRACE();
251
+
246
252
  // Add the lost into the histogram.
247
253
  if (this->packetLossHistory.size() == PacketLossHistogramLength)
248
254
  {
@@ -282,6 +288,8 @@ namespace RTC
282
288
 
283
289
  void TransportCongestionControlClient::SetMaxOutgoingBitrate(uint32_t maxBitrate)
284
290
  {
291
+ MS_TRACE();
292
+
285
293
  this->maxOutgoingBitrate = maxBitrate;
286
294
 
287
295
  ApplyBitrateUpdates();
@@ -295,6 +303,8 @@ namespace RTC
295
303
 
296
304
  void TransportCongestionControlClient::SetMinOutgoingBitrate(uint32_t minBitrate)
297
305
  {
306
+ MS_TRACE();
307
+
298
308
  this->minOutgoingBitrate = minBitrate;
299
309
 
300
310
  ApplyBitrateUpdates();
@@ -344,6 +354,8 @@ namespace RTC
344
354
 
345
355
  void TransportCongestionControlClient::ApplyBitrateUpdates()
346
356
  {
357
+ MS_TRACE();
358
+
347
359
  auto currentMaxBitrate = this->bitrates.maxBitrate;
348
360
  uint32_t newMaxBitrate = 0;
349
361
 
@@ -394,6 +394,8 @@ namespace RTC
394
394
 
395
395
  void TransportCongestionControlServer::UpdatePacketLoss(double packetLoss)
396
396
  {
397
+ MS_TRACE();
398
+
397
399
  // Add the lost into the histogram.
398
400
  if (this->packetLossHistory.size() == PacketLossHistogramLength)
399
401
  {
@@ -98,6 +98,8 @@ namespace Utils
98
98
  */
99
99
  std::optional<uint32_t> BitStream::ReadNs(uint32_t n)
100
100
  {
101
+ MS_TRACE();
102
+
101
103
  unsigned w = 0;
102
104
  unsigned x = n;
103
105
 
@@ -88,6 +88,8 @@ void Worker::Close()
88
88
  flatbuffers::Offset<FBS::Worker::DumpResponse> Worker::FillBuffer(
89
89
  flatbuffers::FlatBufferBuilder& builder) const
90
90
  {
91
+ MS_TRACE();
92
+
91
93
  // Add webRtcServerIds.
92
94
  std::vector<flatbuffers::Offset<flatbuffers::String>> webRtcServerIds;
93
95
  webRtcServerIds.reserve(this->mapWebRtcServers.size());
@@ -10,11 +10,15 @@
10
10
 
11
11
  inline static void onSignal(uv_signal_t* handle, int signum)
12
12
  {
13
+ MS_TRACE();
14
+
13
15
  static_cast<SignalHandle*>(handle->data)->OnUvSignal(signum);
14
16
  }
15
17
 
16
18
  inline static void onCloseSignal(uv_handle_t* handle)
17
19
  {
20
+ MS_TRACE();
21
+
18
22
  delete reinterpret_cast<uv_signal_t*>(handle);
19
23
  }
20
24