mediasoup 3.15.3 → 3.15.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.15.3",
3
+ "version": "3.15.4",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -101,7 +101,7 @@
101
101
  "dependencies": {
102
102
  "@types/ini": "^4.1.1",
103
103
  "debug": "^4.4.0",
104
- "flatbuffers": "^25.1.24",
104
+ "flatbuffers": "^25.2.10",
105
105
  "h264-profile-level-id": "^2.0.0",
106
106
  "ini": "^5.0.0",
107
107
  "node-fetch": "^3.3.2",
@@ -109,24 +109,24 @@
109
109
  "tar": "^7.4.3"
110
110
  },
111
111
  "devDependencies": {
112
- "@eslint/js": "^9.19.0",
113
- "@octokit/rest": "^21.1.0",
112
+ "@eslint/js": "^9.20.0",
113
+ "@octokit/rest": "^21.1.1",
114
114
  "@types/debug": "^4.1.12",
115
115
  "@types/jest": "^29.5.14",
116
- "@types/node": "^22.12.0",
117
- "eslint": "^9.19.0",
116
+ "@types/node": "^22.13.4",
117
+ "eslint": "^9.20.1",
118
118
  "eslint-config-prettier": "^10.0.1",
119
119
  "eslint-plugin-jest": "^28.11.0",
120
120
  "eslint-plugin-prettier": "^5.2.3",
121
- "globals": "^15.14.0",
121
+ "globals": "^16.0.0",
122
122
  "jest": "^29.7.0",
123
- "marked": "^15.0.6",
123
+ "marked": "^15.0.7",
124
124
  "open-cli": "^8.0.0",
125
125
  "pick-port": "^2.1.0",
126
- "prettier": "^3.4.2",
126
+ "prettier": "^3.5.1",
127
127
  "sctp": "^1.0.0",
128
128
  "ts-jest": "^29.2.5",
129
129
  "typescript": "^5.7.3",
130
- "typescript-eslint": "^8.22.0"
130
+ "typescript-eslint": "^8.24.1"
131
131
  }
132
132
  }
@@ -1,8 +1,8 @@
1
1
  #include "RTC/FuzzerRateCalculator.hpp"
2
2
  #include "DepLibUV.hpp"
3
3
  #include "Utils.hpp"
4
+ #include "RTC/Consts.hpp"
4
5
  #include "RTC/RateCalculator.hpp"
5
- #include "RTC/RtpPacket.hpp" // RTC::MtuSize
6
6
 
7
7
  static ::RTC::RateCalculator rateCalculator;
8
8
  static uint64_t nowMs;
@@ -25,8 +25,8 @@ void Fuzzer::RTC::RateCalculator::Fuzz(const uint8_t* data, size_t len)
25
25
  return;
26
26
  }
27
27
 
28
- auto size =
29
- static_cast<size_t>(Utils::Crypto::GetRandomUInt(0u, static_cast<uint32_t>(::RTC::MtuSize)));
28
+ auto size = static_cast<size_t>(
29
+ Utils::Crypto::GetRandomUInt(0u, static_cast<uint32_t>(::RTC::Consts::MtuSize)));
30
30
 
31
31
  nowMs += Utils::Crypto::GetRandomUInt(0u, 1000u);
32
32
 
@@ -0,0 +1,32 @@
1
+ #ifndef MS_RTC_CONSTS_HPP
2
+ #define MS_RTC_CONSTS_HPP
3
+
4
+ namespace RTC
5
+ {
6
+ namespace Consts
7
+ {
8
+ /**
9
+ * Max MTU size.
10
+ */
11
+ constexpr size_t MtuSize{ 1500u };
12
+
13
+ /**
14
+ * Maximum size for a RTCP compound packet.
15
+ * IPv4|Ipv6 header size: 20|40 bytes. IPv6 considered.
16
+ * UDP|TCP header size: 8|20 bytes. TCP considered.
17
+ * SRTP Encryption: 148 bytes.
18
+ SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be
19
+ added to an RTCP packet by srtp_protect_rtcp().
20
+ srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN).
21
+ */
22
+ constexpr size_t RtcpPacketMaxSize{ RTC::Consts::MtuSize - 40 - 20 - 148u };
23
+
24
+ /**
25
+ * MID RTP header extension max length (just used when setting/updating MID
26
+ * extension).
27
+ */
28
+ constexpr uint8_t MidRtpExtensionMaxLength{ 8u };
29
+ } // namespace Consts
30
+ } // namespace RTC
31
+
32
+ #endif
@@ -7,7 +7,6 @@
7
7
  #include "RTC/RTCP/SenderReport.hpp"
8
8
  #include "RTC/RTCP/XrDelaySinceLastRr.hpp"
9
9
  #include "RTC/RTCP/XrReceiverReferenceTime.hpp"
10
- #include "RTC/RtpPacket.hpp" // MtuSize.
11
10
  #include <vector>
12
11
 
13
12
  namespace RTC
@@ -16,16 +15,6 @@ namespace RTC
16
15
  {
17
16
  class CompoundPacket
18
17
  {
19
- public:
20
- // Maximum size for a CompundPacket.
21
- // * IPv4|Ipv6 header size: 20|40 bytes. IPv6 considered.
22
- // * UDP|TCP header size: 8|20 bytes. TCP considered.
23
- // * SRTP Encryption: 148 bytes.
24
- // SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be
25
- // added to an RTCP packet by srtp_protect_rtcp().
26
- // srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN)
27
- constexpr static size_t MaxSize{ RTC::MtuSize - 40u - 20u - 148u };
28
-
29
18
  public:
30
19
  CompoundPacket() = default;
31
20
 
@@ -16,12 +16,6 @@
16
16
 
17
17
  namespace RTC
18
18
  {
19
- // Max MTU size.
20
- constexpr size_t MtuSize{ 1500u };
21
- // MID header extension max length (just used when setting/updating MID
22
- // extension).
23
- constexpr uint8_t MidMaxLength{ 8u };
24
-
25
19
  class RtpPacket
26
20
  {
27
21
  public:
@@ -359,7 +359,7 @@ namespace RTC
359
359
  // clang-format off
360
360
  if (
361
361
  this->payloadDescriptor->hasTlIndex &&
362
- this->payloadDescriptor->tlIndex > context->GetCurrentTemporalLayer()
362
+ this->payloadDescriptor->tlIndex == context->GetTargetTemporalLayer()
363
363
  )
364
364
  // clang-format on
365
365
  {
@@ -375,6 +375,12 @@ namespace RTC
375
375
  context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
376
376
  }
377
377
 
378
+ // Do not send tlIndex higher than current one.
379
+ if (this->payloadDescriptor->tlIndex > context->GetCurrentTemporalLayer())
380
+ {
381
+ return false;
382
+ }
383
+
378
384
  // clang-format off
379
385
  if (
380
386
  this->payloadDescriptor->hasPictureId &&
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "RTC/DirectTransport.hpp"
5
5
  #include "Logger.hpp"
6
+ #include "RTC/Consts.hpp"
6
7
 
7
8
  namespace RTC
8
9
  {
@@ -102,7 +103,7 @@ namespace RTC
102
103
  // Increase receive transmission.
103
104
  RTC::Transport::DataReceived(len);
104
105
 
105
- if (len > RTC::MtuSize + 100)
106
+ if (len > RTC::Consts::MtuSize + 100)
106
107
  {
107
108
  MS_WARN_TAG(rtp, "given RTCP packet exceeds maximum size [len:%i]", len);
108
109
 
@@ -7,6 +7,7 @@
7
7
  #include "MediaSoupErrors.hpp"
8
8
  #include "Utils.hpp"
9
9
  #include "RTC/Codecs/Tools.hpp"
10
+ #include "RTC/Consts.hpp"
10
11
  #include "RTC/RTCP/Feedback.hpp"
11
12
  #include "RTC/RTCP/XrReceiverReferenceTime.hpp"
12
13
  #include <absl/container/inlined_vector.h>
@@ -524,7 +525,7 @@ namespace RTC
524
525
  // Increase receive transmission.
525
526
  this->listener->OnProducerReceiveData(this, len);
526
527
 
527
- if (len > RTC::MtuSize + 100)
528
+ if (len > RTC::Consts::MtuSize + 100)
528
529
  {
529
530
  MS_WARN_TAG(rtp, "given RTP packet exceeds maximum size [len:%i]", len);
530
531
 
@@ -535,7 +536,7 @@ namespace RTC
535
536
  // receiving buffer now.
536
537
  if (!Producer::buffer)
537
538
  {
538
- Producer::buffer = new uint8_t[RTC::MtuSize + 100];
539
+ Producer::buffer = new uint8_t[RTC::Consts::MtuSize + 100];
539
540
  }
540
541
 
541
542
  // Copy the received packet into this buffer so it can be expanded later.
@@ -1246,7 +1247,7 @@ namespace RTC
1246
1247
 
1247
1248
  // Add urn:ietf:params:rtp-hdrext:sdes:mid.
1248
1249
  {
1249
- extenLen = RTC::MidMaxLength;
1250
+ extenLen = RTC::Consts::MidRtpExtensionMaxLength;
1250
1251
 
1251
1252
  extensions.emplace_back(
1252
1253
  static_cast<uint8_t>(RTC::RtpHeaderExtensionUri::Type::MID), extenLen, bufferPtr);
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include "RTC/RTCP/CompoundPacket.hpp"
5
5
  #include "Logger.hpp"
6
+ #include "RTC/Consts.hpp"
6
7
 
7
8
  namespace RTC
8
9
  {
@@ -101,7 +102,7 @@ namespace RTC
101
102
  }
102
103
 
103
104
  // New items can hold in the packet, report it.
104
- if (GetSize() <= MaxSize)
105
+ if (GetSize() <= RTC::Consts::RtcpPacketMaxSize)
105
106
  {
106
107
  return true;
107
108
  }
@@ -160,7 +161,7 @@ namespace RTC
160
161
  }
161
162
 
162
163
  // New items can hold in the packet, report it.
163
- if (GetSize() <= MaxSize)
164
+ if (GetSize() <= RTC::Consts::RtcpPacketMaxSize)
164
165
  {
165
166
  return true;
166
167
  }
@@ -206,7 +207,7 @@ namespace RTC
206
207
  }
207
208
 
208
209
  // New items can hold in the packet, report it.
209
- if (GetSize() <= MaxSize)
210
+ if (GetSize() <= RTC::Consts::RtcpPacketMaxSize)
210
211
  {
211
212
  return true;
212
213
  }
@@ -4,6 +4,7 @@
4
4
  #include "RTC/RtpPacket.hpp"
5
5
  #include "DepLibUV.hpp"
6
6
  #include "Logger.hpp"
7
+ #include "RTC/Consts.hpp"
7
8
  #include <cstring> // std::memcpy(), std::memmove(), std::memset()
8
9
  #include <iterator> // std::ostream_iterator
9
10
  #include <sstream> // std::ostringstream
@@ -580,13 +581,13 @@ namespace RTC
580
581
 
581
582
  const size_t midLen = mid.length();
582
583
 
583
- // Here we assume that there is MidMaxLength available bytes, even if now
584
- // they are padding bytes.
585
- if (midLen > RTC::MidMaxLength)
584
+ // Here we assume that there is MidRtpExtensionMaxLength available bytes,
585
+ // even if now they are padding bytes.
586
+ if (midLen > RTC::Consts::MidRtpExtensionMaxLength)
586
587
  {
587
588
  MS_ERROR(
588
589
  "no enough space for MID value [MidMaxLength:%" PRIu8 ", mid:'%s']",
589
- RTC::MidMaxLength,
590
+ RTC::Consts::MidRtpExtensionMaxLength,
590
591
  mid.c_str());
591
592
 
592
593
  return;
@@ -692,7 +693,7 @@ namespace RTC
692
693
  {
693
694
  MS_TRACE();
694
695
 
695
- auto* buffer = new uint8_t[MtuSize + 100];
696
+ auto* buffer = new uint8_t[RTC::Consts::MtuSize + 100];
696
697
  auto* ptr = const_cast<uint8_t*>(buffer);
697
698
 
698
699
  size_t numBytes{ 0 };
@@ -191,7 +191,7 @@ namespace RTC
191
191
  RtpStreamRecv::RtpStreamRecv(
192
192
  RTC::RtpStreamRecv::Listener* listener,
193
193
  RTC::RtpStream::Params& params,
194
- unsigned int sendNackDelayMs,
194
+ uint32_t sendNackDelayMs,
195
195
  bool useRtpInactivityCheck)
196
196
  : RTC::RtpStream::RtpStream(listener, params, 10), sendNackDelayMs(sendNackDelayMs),
197
197
  useRtpInactivityCheck(useRtpInactivityCheck),
@@ -7,6 +7,7 @@
7
7
  #endif
8
8
  #include "Logger.hpp"
9
9
  #include "Utils.hpp"
10
+ #include "RTC/Consts.hpp"
10
11
  #include "RTC/RtpDictionaries.hpp"
11
12
 
12
13
  namespace RTC
@@ -374,7 +375,7 @@ namespace RTC
374
375
  {
375
376
  MS_TRACE();
376
377
 
377
- if (packet->GetSize() > RTC::MtuSize)
378
+ if (packet->GetSize() > RTC::Consts::MtuSize)
378
379
  {
379
380
  MS_WARN_TAG(
380
381
  rtp,
@@ -471,7 +472,7 @@ namespace RTC
471
472
  MS_DEBUG_TAG(
472
473
  rtx,
473
474
  "ignoring retransmission for a packet already resent in the last RTT ms "
474
- "[seq:%" PRIu16 ", rtt:%" PRIu32 "]",
475
+ "[seq:%" PRIu16 ", rtt:%" PRIu16 "]",
475
476
  packet->GetSequenceNumber(),
476
477
  rtt);
477
478
  }
@@ -11,6 +11,7 @@
11
11
  #include "Utils.hpp"
12
12
  #include "FBS/transport.h"
13
13
  #include "RTC/BweType.hpp"
14
+ #include "RTC/Consts.hpp"
14
15
  #include "RTC/PipeConsumer.hpp"
15
16
  #include "RTC/RTCP/FeedbackPs.hpp"
16
17
  #include "RTC/RTCP/FeedbackPsAfb.hpp"
@@ -758,8 +759,8 @@ namespace RTC
758
759
 
759
760
  if (createTccServer)
760
761
  {
761
- this->tccServer =
762
- std::make_shared<RTC::TransportCongestionControlServer>(this, bweType, RTC::MtuSize);
762
+ this->tccServer = std::make_shared<RTC::TransportCongestionControlServer>(
763
+ this, bweType, RTC::Consts::RtcpPacketMaxSize);
763
764
 
764
765
  if (this->maxIncomingBitrate != 0u)
765
766
  {
@@ -233,14 +233,20 @@ namespace RTC
233
233
 
234
234
  case RTC::RTCP::FeedbackRtpTransportPacket::AddPacketResult::MAX_SIZE_EXCEEDED:
235
235
  {
236
- // This should not happen.
237
- MS_WARN_TAG(rtcp, "transport-cc feedback packet is exceeded");
236
+ // Send ongoing feedback packet.
237
+ auto sent = SendTransportCcFeedback();
238
+
239
+ if (sent)
240
+ {
241
+ ++this->transportCcFeedbackPacketCount;
242
+ }
238
243
 
239
244
  // Create a new feedback packet.
240
- // NOTE: Do not increment packet count it since the previous ongoing
241
- // feedback packet was not sent.
242
245
  ResetTransportCcFeedback(this->transportCcFeedbackPacketCount);
243
246
 
247
+ // Decrease iterator to add current packet again.
248
+ --it;
249
+
244
250
  break;
245
251
  }
246
252
 
@@ -322,4 +322,68 @@ SCENARIO("process VP8 payload descriptor", "[codecs][vp8]")
322
322
  forwarded = ProcessPacket(context, 1, 0, 1);
323
323
  REQUIRE_FALSE(forwarded);
324
324
  }
325
+
326
+ SECTION("old packets with higher temporal layer than current are dropped")
327
+ {
328
+ RTC::Codecs::EncodingContext::Params params;
329
+ params.spatialLayers = 0;
330
+ params.temporalLayers = 2;
331
+ Codecs::VP8::EncodingContext context(params);
332
+ context.SyncRequired();
333
+
334
+ context.SetCurrentTemporalLayer(0);
335
+ context.SetTargetTemporalLayer(0);
336
+
337
+ // Frame 1.
338
+ auto forwarded = ProcessPacket(context, 1, 0, 0);
339
+ REQUIRE(forwarded);
340
+ REQUIRE(forwarded->pictureId == 1);
341
+ REQUIRE(forwarded->tlIndex == 0);
342
+ REQUIRE(forwarded->tl0PictureIndex == 1);
343
+
344
+ // Frame 2.
345
+ forwarded = ProcessPacket(context, 2, 0, 0);
346
+ REQUIRE(forwarded);
347
+ REQUIRE(forwarded->pictureId == 2);
348
+ REQUIRE(forwarded->tlIndex == 0);
349
+ REQUIRE(forwarded->tl0PictureIndex == 1);
350
+
351
+ // Frame 3. Old packet with higher temporal layer than current.
352
+ forwarded = ProcessPacket(context, 0, 0, 1);
353
+ REQUIRE_FALSE(forwarded);
354
+ REQUIRE(context.GetCurrentTemporalLayer() == 0);
355
+ }
356
+
357
+ SECTION("packets with higher temporal layer than current are dropped")
358
+ {
359
+ RTC::Codecs::EncodingContext::Params params;
360
+ params.spatialLayers = 0;
361
+ params.temporalLayers = 2;
362
+ Codecs::VP8::EncodingContext context(params);
363
+ context.SyncRequired();
364
+
365
+ context.SetCurrentTemporalLayer(0);
366
+ context.SetTargetTemporalLayer(0);
367
+
368
+ // Frame 1.
369
+ auto forwarded = ProcessPacket(context, 1, 0, 0);
370
+ REQUIRE(forwarded);
371
+ REQUIRE(forwarded->pictureId == 1);
372
+ REQUIRE(forwarded->tlIndex == 0);
373
+ REQUIRE(forwarded->tl0PictureIndex == 1);
374
+
375
+ // Frame 2.
376
+ forwarded = ProcessPacket(context, 2, 0, 0);
377
+ REQUIRE(forwarded);
378
+ REQUIRE(forwarded->pictureId == 2);
379
+ REQUIRE(forwarded->tlIndex == 0);
380
+ REQUIRE(forwarded->tl0PictureIndex == 1);
381
+
382
+ context.SetTargetTemporalLayer(2);
383
+
384
+ // Frame 3. Old packet with higher temporal layer than current.
385
+ forwarded = ProcessPacket(context, 3, 0, 1);
386
+ REQUIRE_FALSE(forwarded);
387
+ REQUIRE(context.GetCurrentTemporalLayer() == 0);
388
+ }
325
389
  }
@@ -1,5 +1,6 @@
1
1
  #include "common.hpp"
2
2
  #include "DepLibUV.hpp"
3
+ #include "RTC/Consts.hpp"
3
4
  #include "RTC/TransportCongestionControlServer.hpp"
4
5
  #include <catch2/catch_test_macros.hpp>
5
6
 
@@ -88,7 +89,7 @@ void validate(std::vector<TestTransportCongestionControlServerInput>& inputs, Te
88
89
  {
89
90
  TestTransportCongestionControlServerListener listener;
90
91
  auto tccServer =
91
- TransportCongestionControlServer(&listener, RTC::BweType::TRANSPORT_CC, RTC::MtuSize);
92
+ TransportCongestionControlServer(&listener, RTC::BweType::TRANSPORT_CC, RTC::Consts::MtuSize);
92
93
 
93
94
  tccServer.SetMaxIncomingBitrate(150000);
94
95
  tccServer.TransportConnected();