mediasoup 3.19.19 → 3.19.21

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 (91) hide show
  1. package/README.md +4 -4
  2. package/node/lib/Worker.d.ts +1 -1
  3. package/node/lib/Worker.d.ts.map +1 -1
  4. package/node/lib/Worker.js +8 -2
  5. package/node/lib/WorkerTypes.d.ts +8 -4
  6. package/node/lib/WorkerTypes.d.ts.map +1 -1
  7. package/node/lib/index.d.ts +1 -1
  8. package/node/lib/index.d.ts.map +1 -1
  9. package/node/lib/index.js +2 -1
  10. package/node/lib/sctpParametersTypes.d.ts +3 -13
  11. package/node/lib/sctpParametersTypes.d.ts.map +1 -1
  12. package/node/lib/test/test-PlainTransport.js +8 -3
  13. package/node/lib/test/test-WebRtcTransport.js +9 -4
  14. package/package.json +10 -10
  15. package/worker/Makefile +0 -4
  16. package/worker/fuzzer/src/fuzzer.cpp +6 -5
  17. package/worker/include/RTC/DataConsumer.hpp +4 -14
  18. package/worker/include/RTC/SCTP/TODO_SCTP.md +18 -10
  19. package/worker/include/RTC/SCTP/association/Association.hpp +39 -31
  20. package/worker/include/RTC/SCTP/association/{AssociationDeferredListener.hpp → AssociationListenerDeferrer.hpp} +10 -8
  21. package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +77 -0
  22. package/worker/include/RTC/SCTP/association/NegotiatedCapabilities.hpp +2 -2
  23. package/worker/include/RTC/SCTP/association/PacketSender.hpp +2 -2
  24. package/worker/include/RTC/SCTP/association/StateCookie.hpp +2 -2
  25. package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +272 -0
  26. package/worker/include/RTC/SCTP/association/TCBContext.hpp +67 -0
  27. package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +81 -11
  28. package/worker/include/RTC/SCTP/common/UnwrappedSequenceNumber.hpp +274 -0
  29. package/worker/include/RTC/SCTP/packet/Chunk.hpp +0 -1
  30. package/worker/include/RTC/SCTP/packet/UserData.hpp +1 -0
  31. package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +14 -10
  32. package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +14 -10
  33. package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +13 -2
  34. package/worker/include/RTC/SCTP/public/AssociationInterface.hpp +7 -1
  35. package/worker/include/RTC/SCTP/public/AssociationListener.hpp +11 -0
  36. package/worker/include/RTC/SCTP/public/Message.hpp +1 -0
  37. package/worker/include/RTC/SCTP/public/SctpOptions.hpp +4 -4
  38. package/worker/include/RTC/SctpAssociation.hpp +2 -2
  39. package/worker/include/RTC/Transport.hpp +9 -13
  40. package/worker/include/Settings.hpp +2 -1
  41. package/worker/include/Utils.hpp +130 -6
  42. package/worker/meson.build +10 -39
  43. package/worker/meson_options.txt +0 -1
  44. package/worker/scripts/package-lock.json +6 -6
  45. package/worker/src/DepLibUring.cpp +1 -1
  46. package/worker/src/RTC/DataConsumer.cpp +5 -29
  47. package/worker/src/RTC/PipeTransport.cpp +15 -12
  48. package/worker/src/RTC/PlainTransport.cpp +15 -12
  49. package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +5 -5
  50. package/worker/src/RTC/RTP/RtpStream.cpp +2 -2
  51. package/worker/src/RTC/RTP/RtxStream.cpp +1 -1
  52. package/worker/src/RTC/RateCalculator.cpp +5 -5
  53. package/worker/src/RTC/SCTP/association/Association.cpp +218 -148
  54. package/worker/src/RTC/SCTP/association/{AssociationDeferredListener.cpp → AssociationListenerDeferrer.cpp} +38 -30
  55. package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +244 -0
  56. package/worker/src/RTC/SCTP/association/NegotiatedCapabilities.cpp +8 -6
  57. package/worker/src/RTC/SCTP/association/PacketSender.cpp +7 -2
  58. package/worker/src/RTC/SCTP/association/StateCookie.cpp +8 -8
  59. package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +512 -0
  60. package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +45 -39
  61. package/worker/src/RTC/SCTP/packet/chunks/SackChunk.cpp +1 -1
  62. package/worker/src/RTC/SCTP/packet/errorCauses/UserInitiatedAbortErrorCause.cpp +1 -1
  63. package/worker/src/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.cpp +22 -5
  64. package/worker/src/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.cpp +22 -5
  65. package/worker/src/RTC/SCTP/tx/RetransmissionErrorCounter.cpp +1 -1
  66. package/worker/src/RTC/SctpAssociation.cpp +1 -2
  67. package/worker/src/RTC/SeqManager.cpp +4 -4
  68. package/worker/src/RTC/Transport.cpp +247 -134
  69. package/worker/src/RTC/WebRtcTransport.cpp +9 -5
  70. package/worker/src/Settings.cpp +21 -1
  71. package/worker/src/Worker.cpp +13 -10
  72. package/worker/src/lib.cpp +11 -8
  73. package/worker/tasks.py +2 -35
  74. package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +13 -12
  75. package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +20 -20
  76. package/worker/test/src/RTC/SCTP/common/TestUnwrappedSequenceNumber.cpp +210 -0
  77. package/worker/test/src/RTC/SCTP/packet/chunks/TestAbortAssociationChunk.cpp +2 -2
  78. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatAckChunk.cpp +9 -4
  79. package/worker/test/src/RTC/SCTP/packet/chunks/TestHeartbeatRequestChunk.cpp +5 -0
  80. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitAckChunk.cpp +1 -1
  81. package/worker/test/src/RTC/SCTP/packet/chunks/TestInitChunk.cpp +5 -5
  82. package/worker/test/src/RTC/SCTP/packet/chunks/TestReConfigChunk.cpp +19 -20
  83. package/worker/test/src/RTC/SCTP/packet/chunks/TestUnknownChunk.cpp +3 -0
  84. package/worker/test/src/RTC/SCTP/packet/errorCauses/TestUnknownErrorCause.cpp +3 -0
  85. package/worker/test/src/RTC/SCTP/packet/parameters/TestIncomingSsnResetRequestParameter.cpp +24 -27
  86. package/worker/test/src/RTC/SCTP/packet/parameters/TestOutgoingSsnResetRequestParameter.cpp +25 -30
  87. package/worker/test/src/RTC/SCTP/packet/parameters/TestStateCookieParameter.cpp +8 -6
  88. package/worker/test/src/RTC/SCTP/packet/parameters/TestSupportedExtensionsParameter.cpp +12 -0
  89. package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +5 -8
  90. package/worker/test/src/Utils/TestNumber.cpp +119 -49
  91. package/worker/test/src/tests.cpp +11 -8
@@ -4,6 +4,7 @@
4
4
  #include "common.hpp"
5
5
  #include "RTC/Consts.hpp"
6
6
  #include <openssl/evp.h>
7
+ #include <cassert>
7
8
  #include <cmath>
8
9
  #include <cstring> // std::memcmp(), std::memcpy()
9
10
  #include <limits> // std::numeric_limits
@@ -283,15 +284,12 @@ namespace Utils
283
284
  static uint8_t* Base64Decode(const std::string& str, size_t& outLen);
284
285
  };
285
286
 
286
- // T is the base type (uint16_t, uint32_t, ...).
287
- // N is the max number of bits used in T.
288
- template<typename T, uint8_t N = 0>
289
287
  class Number
290
288
  {
291
- private:
292
- static constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
293
-
294
289
  public:
290
+ // T is the base type (uint16_t, uint32_t, ...).
291
+ // N is the max number of bits used in T.
292
+ template<typename T, uint8_t N = 0>
295
293
  static bool IsEqualThan(T lhs, T rhs)
296
294
  {
297
295
  static_assert(
@@ -299,12 +297,17 @@ namespace Utils
299
297
  std::is_same_v<T, uint64_t>,
300
298
  "T must be uint8_t, uint16_t, uint32_t or uint64_t");
301
299
 
300
+ constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
301
+
302
302
  lhs &= MaxValue;
303
303
  rhs &= MaxValue;
304
304
 
305
305
  return (lhs == rhs);
306
306
  }
307
307
 
308
+ // T is the base type (uint16_t, uint32_t, ...).
309
+ // N is the max number of bits used in T.
310
+ template<typename T, uint8_t N = 0>
308
311
  static bool IsHigherThan(T lhs, T rhs)
309
312
  {
310
313
  static_assert(
@@ -312,6 +315,8 @@ namespace Utils
312
315
  std::is_same_v<T, uint64_t>,
313
316
  "T must be uint8_t, uint16_t, uint32_t or uint64_t");
314
317
 
318
+ constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
319
+
315
320
  lhs &= MaxValue;
316
321
  rhs &= MaxValue;
317
322
 
@@ -319,6 +324,9 @@ namespace Utils
319
324
  ((rhs > lhs) && (rhs - lhs > MaxValue / 2));
320
325
  }
321
326
 
327
+ // T is the base type (uint16_t, uint32_t, ...).
328
+ // N is the max number of bits used in T.
329
+ template<typename T, uint8_t N = 0>
322
330
  static bool IsLowerThan(T lhs, T rhs)
323
331
  {
324
332
  static_assert(
@@ -326,6 +334,8 @@ namespace Utils
326
334
  std::is_same_v<T, uint64_t>,
327
335
  "T must be uint8_t, uint16_t, uint32_t or uint64_t");
328
336
 
337
+ constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
338
+
329
339
  lhs &= MaxValue;
330
340
  rhs &= MaxValue;
331
341
 
@@ -333,6 +343,9 @@ namespace Utils
333
343
  ((lhs > rhs) && (lhs - rhs > MaxValue / 2));
334
344
  }
335
345
 
346
+ // T is the base type (uint16_t, uint32_t, ...).
347
+ // N is the max number of bits used in T.
348
+ template<typename T, uint8_t N = 0>
336
349
  static bool IsHigherOrEqualThan(T lhs, T rhs)
337
350
  {
338
351
  static_assert(
@@ -340,6 +353,8 @@ namespace Utils
340
353
  std::is_same_v<T, uint64_t>,
341
354
  "T must be uint8_t, uint16_t, uint32_t or uint64_t");
342
355
 
356
+ constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
357
+
343
358
  lhs &= MaxValue;
344
359
  rhs &= MaxValue;
345
360
 
@@ -347,6 +362,9 @@ namespace Utils
347
362
  ((rhs > lhs) && (rhs - lhs > MaxValue / 2));
348
363
  }
349
364
 
365
+ // T is the base type (uint16_t, uint32_t, ...).
366
+ // N is the max number of bits used in T.
367
+ template<typename T, uint8_t N = 0>
350
368
  static bool IsLowerOrEqualThan(T lhs, T rhs)
351
369
  {
352
370
  static_assert(
@@ -354,12 +372,118 @@ namespace Utils
354
372
  std::is_same_v<T, uint64_t>,
355
373
  "T must be uint8_t, uint16_t, uint32_t or uint64_t");
356
374
 
375
+ constexpr T MaxValue = (N == 0) ? std::numeric_limits<T>::max() : ((1 << N) - 1);
376
+
357
377
  lhs &= MaxValue;
358
378
  rhs &= MaxValue;
359
379
 
360
380
  return (lhs == rhs) || ((rhs > lhs) && (rhs - lhs <= MaxValue / 2)) ||
361
381
  ((lhs > rhs) && (lhs - rhs > MaxValue / 2));
362
382
  }
383
+
384
+ /**
385
+ * Calculates the forward difference between two wrapping numbers.
386
+ *
387
+ * Example:
388
+ * ```c++
389
+ * uint8_t x = 253;
390
+ * uint8_t y = 2;
391
+ *
392
+ * ForwardDiff(x, y) == 5
393
+ * ```
394
+ *
395
+ * 252 253 254 255 0 1 2 3
396
+ * #################################################
397
+ * | | x | | | | | y | |
398
+ * #################################################
399
+ * |----->----->----->----->----->
400
+ *
401
+ * ForwardDiff(y, x) == 251
402
+ *
403
+ * 252 253 254 255 0 1 2 3
404
+ * #################################################
405
+ * | | x | | | | | y | |
406
+ * #################################################
407
+ * -->-----> |----->---
408
+ *
409
+ * If M > 0 then wrapping occurs at M, if M == 0 then wrapping occurs at the
410
+ * largest value representable by T.
411
+ */
412
+ template<typename T, T M>
413
+ static T ForwardDiff(T a, T b) requires(M > 0)
414
+ {
415
+ static_assert(std::is_unsigned<T>::value, "type must be an unsigned integer");
416
+
417
+ assert(a < M);
418
+ assert(b < M);
419
+
420
+ return a <= b ? b - a : M - (a - b);
421
+ }
422
+
423
+ template<typename T, T M>
424
+ static T ForwardDiff(T a, T b) requires(M == 0)
425
+ {
426
+ static_assert(std::is_unsigned<T>::value, "type must be an unsigned integer");
427
+
428
+ return b - a;
429
+ }
430
+
431
+ template<typename T>
432
+ static T ForwardDiff(T a, T b)
433
+ {
434
+ return ForwardDiff<T, 0>(a, b);
435
+ }
436
+
437
+ /**
438
+ * Calculates the reverse difference between two wrapping numbers.
439
+ *
440
+ * Example:
441
+ * ```c++
442
+ * uint8_t x = 253;
443
+ * uint8_t y = 2;
444
+ *
445
+ * ReverseDiff(y, x) == 5
446
+ *
447
+ * 252 253 254 255 0 1 2 3
448
+ * #################################################
449
+ * | | x | | | | | y | |
450
+ * #################################################
451
+ * <-----<-----<-----<-----<-----|
452
+ *
453
+ * ReverseDiff(x, y) == 251
454
+ *
455
+ * 252 253 254 255 0 1 2 3
456
+ * #################################################
457
+ * | | x | | | | | y | |
458
+ * #################################################
459
+ * ---<-----| |<-----<--
460
+ *
461
+ * If M > 0 then wrapping occurs at M, if M == 0 then wrapping occurs at the
462
+ * largest value representable by T.
463
+ */
464
+ template<typename T, T M>
465
+ static T ReverseDiff(T a, T b) requires(M > 0)
466
+ {
467
+ static_assert(std::is_unsigned<T>::value, "type must be an unsigned integer");
468
+
469
+ assert(a < M);
470
+ assert(b < M);
471
+
472
+ return b <= a ? a - b : M - (b - a);
473
+ }
474
+
475
+ template<typename T, T M>
476
+ static T ReverseDiff(T a, T b) requires(M == 0)
477
+ {
478
+ static_assert(std::is_unsigned<T>::value, "type must be an unsigned integer");
479
+ return a - b;
480
+ }
481
+
482
+ template<typename T>
483
+ static T ReverseDiff(T a, T b)
484
+ {
485
+ return ReverseDiff<T, 0>(a, b);
486
+ }
363
487
  };
364
488
 
365
489
  class Time
@@ -63,12 +63,6 @@ if get_option('ms_dump_rtp_shared_packet_memory_usage')
63
63
  ]
64
64
  endif
65
65
 
66
- if get_option('ms_sctp_stack')
67
- cpp_args += [
68
- '-DMS_SCTP_STACK',
69
- ]
70
- endif
71
-
72
66
  cpp = meson.get_compiler('cpp')
73
67
 
74
68
  # This is a workaround to define FLATBUFFERS_LOCALE_INDEPENDENT=0 outside
@@ -87,6 +81,7 @@ common_sources = [
87
81
  'src/DepLibUV.cpp',
88
82
  'src/DepLibWebRTC.cpp',
89
83
  'src/DepOpenSSL.cpp',
84
+ # TODO: Remove once we only use built-in SCTP stack.
90
85
  'src/DepUsrSCTP.cpp',
91
86
  'src/Logger.cpp',
92
87
  'src/MediaSoupErrors.cpp',
@@ -128,6 +123,7 @@ common_sources = [
128
123
  'src/RTC/RtcLogger.cpp',
129
124
  'src/RTC/RtpListener.cpp',
130
125
  'src/RTC/RtpObserver.cpp',
126
+ # TODO: Remove once we only use built-in SCTP stack.
131
127
  'src/RTC/SctpAssociation.cpp',
132
128
  'src/RTC/SctpListener.cpp',
133
129
  'src/RTC/SenderBandwidthEstimator.cpp',
@@ -204,11 +200,13 @@ common_sources = [
204
200
  'src/RTC/RTCP/XrDelaySinceLastRr.cpp',
205
201
  'src/RTC/RTCP/XrReceiverReferenceTime.cpp',
206
202
  'src/RTC/SCTP/association/Association.cpp',
207
- 'src/RTC/SCTP/association/AssociationDeferredListener.cpp',
203
+ 'src/RTC/SCTP/association/AssociationListenerDeferrer.cpp',
204
+ 'src/RTC/SCTP/association/HeartbeatHandler.cpp',
208
205
  'src/RTC/SCTP/association/NegotiatedCapabilities.cpp',
209
206
  'src/RTC/SCTP/association/PacketSender.cpp',
210
- 'src/RTC/SCTP/association/TransmissionControlBlock.cpp',
211
207
  'src/RTC/SCTP/association/StateCookie.cpp',
208
+ 'src/RTC/SCTP/association/StreamResetHandler.cpp',
209
+ 'src/RTC/SCTP/association/TransmissionControlBlock.cpp',
212
210
  'src/RTC/SCTP/tx/RetransmissionErrorCounter.cpp',
213
211
  'src/RTC/SCTP/tx/RetransmissionTimeout.cpp',
214
212
  'src/RTC/SCTP/packet/Packet.cpp',
@@ -374,10 +372,10 @@ if host_machine.system() == 'linux' and not get_option('ms_disable_liburing')
374
372
  default_options: [
375
373
  'default_library=static',
376
374
  # NOTE: We need to add this to disable ASAN in liburing, otherwise when
377
- # building `mediasoup-test-asan-undefined & -thread` binaries, liburing
378
- # receives `use_ubsan: true` and tries to compile its `sanitize.c` file
375
+ # building `mediasoup-test-asan-undefined` binary, liburing receives
376
+ # `use_ubsan: true` and tries to compile its `sanitize.c` file
379
377
  # that contains references to `__asan_*` functions, but we don't enable
380
- # ASAN (`-fsanitize=address) in those binaries so liburing fails to
378
+ # ASAN (`-fsanitize=address) in that binaries so liburing fails to
381
379
  # compile.
382
380
  'b_sanitize=none',
383
381
  ],
@@ -484,6 +482,7 @@ test_sources = [
484
482
  'test/src/RTC/SCTP/sctpCommon.cpp',
485
483
  'test/src/RTC/SCTP/association/TestStateCookie.cpp',
486
484
  'test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp',
485
+ 'test/src/RTC/SCTP/common/TestUnwrappedSequenceNumber.cpp',
487
486
  'test/src/RTC/SCTP/tx/TestRetransmissionErrorCounter.cpp',
488
487
  'test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp',
489
488
  'test/src/RTC/SCTP/packet/TestPacket.cpp',
@@ -624,34 +623,6 @@ test(
624
623
  workdir: meson.project_source_root(),
625
624
  )
626
625
 
627
- mediasoup_worker_test_asan_thread = executable(
628
- 'mediasoup-worker-test-asan-thread',
629
- build_by_default: false,
630
- install: true,
631
- install_tag: 'mediasoup-worker-test-asan-thread',
632
- dependencies: dependencies,
633
- sources: common_sources + test_sources,
634
- include_directories: include_directories(
635
- 'include',
636
- 'test/include',
637
- ),
638
- cpp_args: cpp_args + [
639
- '-g',
640
- '-O3',
641
- '-fno-omit-frame-pointer',
642
- '-fsanitize=thread',
643
- ],
644
- link_args: [
645
- '-fsanitize=thread',
646
- ],
647
- )
648
-
649
- test(
650
- 'mediasoup-worker-test-asan-thread',
651
- mediasoup_worker_test_asan_thread,
652
- workdir: meson.project_source_root(),
653
- )
654
-
655
626
  fuzzer_sources = common_sources + [
656
627
  'fuzzer/src/fuzzer.cpp',
657
628
  'fuzzer/src/FuzzerUtils.cpp',
@@ -5,4 +5,3 @@ option('ms_rtc_logger_rtp', type: 'boolean', value: false, description: 'Prints
5
5
  option('ms_dump_rtp_payload_descriptor', type: 'boolean', value: false, description: 'RTC::RTP::Packet::Dump() method also dumps payload descriptor details')
6
6
  option('ms_dump_rtp_shared_packet_memory_usage', type: 'boolean', value: false, description: 'prints information about total memory allocated by RTC::RTP::SharedPacket instances')
7
7
  option('ms_disable_liburing', type: 'boolean', value: false, description: 'When set to true, disables liburing integration despite current host supports it')
8
- option('ms_sctp_stack', type: 'boolean', value: false, description: 'When set to true, uses mediasoup SCTP stack instead of usrsctp library (not implemented yet)')
@@ -21,9 +21,9 @@
21
21
  }
22
22
  },
23
23
  "node_modules/brace-expansion": {
24
- "version": "5.0.3",
25
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.3.tgz",
26
- "integrity": "sha512-fy6KJm2RawA5RcHkLa1z/ScpBeA762UF9KmZQxwIbDtRJrgLzM10depAiEQ+CXYcoiqW1/m96OAAoke2nE9EeA==",
24
+ "version": "5.0.5",
25
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
26
+ "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "balanced-match": "^4.0.2"
@@ -105,9 +105,9 @@
105
105
  "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="
106
106
  },
107
107
  "brace-expansion": {
108
- "version": "5.0.3",
109
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.3.tgz",
110
- "integrity": "sha512-fy6KJm2RawA5RcHkLa1z/ScpBeA762UF9KmZQxwIbDtRJrgLzM10depAiEQ+CXYcoiqW1/m96OAAoke2nE9EeA==",
108
+ "version": "5.0.5",
109
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
110
+ "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
111
111
  "requires": {
112
112
  "balanced-match": "^4.0.2"
113
113
  }
@@ -123,7 +123,7 @@ void DepLibUring::ClassInit()
123
123
 
124
124
  MS_DEBUG_TAG(info, "io_uring version: \"%i.%i\"", mayor, minor);
125
125
 
126
- if (Settings::configuration.liburingDisabled)
126
+ if (Settings::configuration.disableLiburing)
127
127
  {
128
128
  MS_DEBUG_TAG(info, "io_uring disabled by user settings");
129
129
 
@@ -5,9 +5,6 @@
5
5
  #include "DepLibUV.hpp"
6
6
  #include "Logger.hpp"
7
7
  #include "MediaSoupErrors.hpp"
8
- #ifndef MS_SCTP_STACK
9
- #include "RTC/SctpAssociation.hpp"
10
- #endif
11
8
 
12
9
  namespace RTC
13
10
  {
@@ -17,18 +14,12 @@ namespace RTC
17
14
  RTC::Shared* shared,
18
15
  const std::string& id,
19
16
  const std::string& dataProducerId,
20
- #ifndef MS_SCTP_STACK
21
- RTC::SctpAssociation* sctpAssociation,
22
- #endif
23
17
  RTC::DataConsumer::Listener* listener,
24
18
  const FBS::Transport::ConsumeDataRequest* data,
25
19
  size_t maxMessageSize)
26
20
  : id(id),
27
21
  dataProducerId(dataProducerId),
28
22
  shared(shared),
29
- #ifndef MS_SCTP_STACK
30
- sctpAssociation(sctpAssociation),
31
- #endif
32
23
  listener(listener),
33
24
  maxMessageSize(maxMessageSize)
34
25
  {
@@ -222,20 +213,14 @@ namespace RTC
222
213
  MS_THROW_TYPE_ERROR("invalid DataConsumer type");
223
214
  }
224
215
 
225
- #ifdef MS_SCTP_STACK
226
- // TODO: SCTP
227
- #else
228
- if (!this->sctpAssociation)
229
- {
230
- MS_THROW_ERROR("no SCTP association present");
231
- }
216
+ uint32_t bufferedAmount{ 0 };
217
+
218
+ this->listener->OnDataConsumerNeedBufferedAmount(this, bufferedAmount);
232
219
 
233
- // Create status response.
234
220
  auto responseOffset = FBS::DataConsumer::CreateGetBufferedAmountResponse(
235
- request->GetBufferBuilder(), this->sctpAssociation->GetSctpBufferedAmount());
221
+ request->GetBufferBuilder(), bufferedAmount);
236
222
 
237
223
  request->Accept(FBS::Response::Body::DataConsumer_GetBufferedAmountResponse, responseOffset);
238
- #endif
239
224
 
240
225
  break;
241
226
  }
@@ -285,15 +270,6 @@ namespace RTC
285
270
  MS_THROW_TYPE_ERROR("invalid DataConsumer type");
286
271
  }
287
272
 
288
- #ifdef MS_SCTP_STACK
289
- // TODO: SCTP
290
- #else
291
- if (!this->sctpAssociation)
292
- {
293
- MS_THROW_ERROR("no SCTP association present");
294
- }
295
- #endif
296
-
297
273
  const auto* body = request->data->body_as<FBS::DataConsumer::SendRequest>();
298
274
  const uint8_t* data = body->data()->Data();
299
275
  const size_t len = body->data()->size();
@@ -480,7 +456,7 @@ namespace RTC
480
456
  MS_DEBUG_DEV("SctpAssociation closed [dataConsumerId:%s]", this->id.c_str());
481
457
  }
482
458
 
483
- void DataConsumer::SctpAssociationBufferedAmount(uint32_t bufferedAmount)
459
+ void DataConsumer::SetSctpAssociationBufferedAmount(uint32_t bufferedAmount)
484
460
  {
485
461
  MS_TRACE();
486
462
 
@@ -6,9 +6,7 @@
6
6
  #include "MediaSoupErrors.hpp"
7
7
  #include "Settings.hpp"
8
8
  #include "Utils.hpp"
9
- #ifdef MS_SCTP_STACK
10
9
  #include "RTC/SCTP/packet/Packet.hpp"
11
- #endif
12
10
  #include <cstring> // std::memcpy()
13
11
 
14
12
  namespace RTC
@@ -585,11 +583,15 @@ namespace RTC
585
583
  {
586
584
  MS_TRACE();
587
585
 
588
- #ifdef MS_SCTP_STACK
589
- // TODO: SCTP
590
- #else
591
- this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb);
592
- #endif
586
+ if (Settings::configuration.useBuiltInSctpStack)
587
+ {
588
+ // TODO: SCTP
589
+ }
590
+ // TODO: Remove once we only use built-in SCTP stack.
591
+ else
592
+ {
593
+ this->oldSctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb);
594
+ }
593
595
  }
594
596
 
595
597
  bool PipeTransport::SendSctpData(const uint8_t* data, size_t len)
@@ -648,11 +650,12 @@ namespace RTC
648
650
  OnRtpDataReceived(tuple, data, len, bufferLen);
649
651
  }
650
652
  // Check if it's SCTP.
651
- #ifdef MS_SCTP_STACK
652
- else if (RTC::SCTP::Packet::IsSctp(data, len))
653
- #else
654
- else if (RTC::SctpAssociation::IsSctp(data, len))
655
- #endif
653
+ else if (Settings::configuration.useBuiltInSctpStack && RTC::SCTP::Packet::IsSctp(data, len))
654
+ {
655
+ OnSctpDataReceived(tuple, data, len);
656
+ }
657
+ // TODO: Remove once we only use built-in SCTP stack.
658
+ else if (!Settings::configuration.useBuiltInSctpStack && RTC::SctpAssociation::IsSctp(data, len))
656
659
  {
657
660
  OnSctpDataReceived(tuple, data, len);
658
661
  }
@@ -6,9 +6,7 @@
6
6
  #include "MediaSoupErrors.hpp"
7
7
  #include "Settings.hpp"
8
8
  #include "Utils.hpp"
9
- #ifdef MS_SCTP_STACK
10
9
  #include "RTC/SCTP/packet/Packet.hpp"
11
- #endif
12
10
  #include <cstring> // std::memcpy()
13
11
 
14
12
  namespace RTC
@@ -905,11 +903,15 @@ namespace RTC
905
903
  {
906
904
  MS_TRACE();
907
905
 
908
- #ifdef MS_SCTP_STACK
909
- // TODO: SCTP
910
- #else
911
- this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb);
912
- #endif
906
+ if (Settings::configuration.useBuiltInSctpStack)
907
+ {
908
+ // TODO: SCTP
909
+ }
910
+ // TODO: Remove once we only use built-in SCTP stack.
911
+ else
912
+ {
913
+ this->oldSctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb);
914
+ }
913
915
  }
914
916
 
915
917
  bool PlainTransport::SendSctpData(const uint8_t* data, size_t len)
@@ -970,11 +972,12 @@ namespace RTC
970
972
  OnRtpDataReceived(tuple, data, len, bufferLen);
971
973
  }
972
974
  // Check if it's SCTP.
973
- #ifdef MS_SCTP_STACK
974
- else if (RTC::SCTP::Packet::IsSctp(data, len))
975
- #else
976
- else if (RTC::SctpAssociation::IsSctp(data, len))
977
- #endif
975
+ else if (Settings::configuration.useBuiltInSctpStack && RTC::SCTP::Packet::IsSctp(data, len))
976
+ {
977
+ OnSctpDataReceived(tuple, data, len);
978
+ }
979
+ // TODO: Remove once we only use built-in SCTP stack.
980
+ else if (!Settings::configuration.useBuiltInSctpStack && RTC::SctpAssociation::IsSctp(data, len))
978
981
  {
979
982
  OnSctpDataReceived(tuple, data, len);
980
983
  }
@@ -142,7 +142,7 @@ namespace RTC
142
142
  // buffer, however its timestamp is higher. If so, clear the whole buffer.
143
143
  if (
144
144
  RTC::SeqManager<uint16_t>::IsSeqLowerThan(seq, newestItem->sequenceNumber) &&
145
- Utils::Number<uint32_t>::IsHigherThan(timestamp, newestItem->timestamp))
145
+ Utils::Number::IsHigherThan<uint32_t>(timestamp, newestItem->timestamp))
146
146
  {
147
147
  MS_WARN_TAG(
148
148
  rtp,
@@ -166,7 +166,7 @@ namespace RTC
166
166
  // packet loss, received packet has higher timestamp but "older" seq number
167
167
  // than the newest packet in the buffer and, if so, use it to clear too old
168
168
  // packets rather than the newest packet in the buffer.
169
- auto newestTimestamp = Utils::Number<uint32_t>::IsHigherThan(timestamp, newestItem->timestamp)
169
+ auto newestTimestamp = Utils::Number::IsHigherThan<uint32_t>(timestamp, newestItem->timestamp)
170
170
  ? timestamp
171
171
  : newestItem->timestamp;
172
172
 
@@ -205,7 +205,7 @@ namespace RTC
205
205
 
206
206
  // Ensure that the timestamp of the packet is equal or higher than the
207
207
  // timestamp of the newest stored packet.
208
- if (Utils::Number<uint32_t>::IsLowerThan(timestamp, newestItem->timestamp))
208
+ if (Utils::Number::IsLowerThan<uint32_t>(timestamp, newestItem->timestamp))
209
209
  {
210
210
  MS_WARN_TAG(
211
211
  rtp,
@@ -292,7 +292,7 @@ namespace RTC
292
292
 
293
293
  // Ensure that the timestamp of the packet is equal or less than the
294
294
  // timestamp of the oldest stored packet.
295
- if (Utils::Number<uint32_t>::IsHigherThan(timestamp, oldestItem->timestamp))
295
+ if (Utils::Number::IsHigherThan<uint32_t>(timestamp, oldestItem->timestamp))
296
296
  {
297
297
  MS_WARN_TAG(
298
298
  rtp,
@@ -571,7 +571,7 @@ namespace RTC
571
571
  {
572
572
  MS_TRACE();
573
573
 
574
- if (Utils::Number<uint32_t>::IsHigherThan(timestamp, newestTimestamp))
574
+ if (Utils::Number::IsHigherThan<uint32_t>(timestamp, newestTimestamp))
575
575
  {
576
576
  return false;
577
577
  }
@@ -149,7 +149,7 @@ namespace RTC
149
149
  }
150
150
 
151
151
  // Update highest seen RTP timestamp.
152
- if (Utils::Number<uint32_t>::IsHigherThan(packet->GetTimestamp(), this->maxPacketTs))
152
+ if (Utils::Number::IsHigherThan<uint32_t>(packet->GetTimestamp(), this->maxPacketTs))
153
153
  {
154
154
  this->maxPacketTs = packet->GetTimestamp();
155
155
  this->maxPacketMs = DepLibUV::GetTimeMs();
@@ -208,7 +208,7 @@ namespace RTC
208
208
 
209
209
  // Timestamp moved backwards despite in-order sequence number. Likely
210
210
  // caused by prolonged Producer inactivity (e.g., overnight pause).
211
- if (Utils::Number<uint32_t>::IsLowerThan(packet->GetTimestamp(), this->maxPacketTs))
211
+ if (Utils::Number::IsLowerThan<uint32_t>(packet->GetTimestamp(), this->maxPacketTs))
212
212
  {
213
213
  MS_DEBUG_TAG(
214
214
  rtp,
@@ -73,7 +73,7 @@ namespace RTC
73
73
  }
74
74
 
75
75
  // Update highest seen RTP timestamp.
76
- if (Utils::Number<uint32_t>::IsHigherThan(packet->GetTimestamp(), this->maxPacketTs))
76
+ if (Utils::Number::IsHigherThan<uint32_t>(packet->GetTimestamp(), this->maxPacketTs))
77
77
  {
78
78
  this->maxPacketTs = packet->GetTimestamp();
79
79
  this->maxPacketMs = DepLibUV::GetTimeMs();
@@ -31,7 +31,7 @@ namespace RTC
31
31
  MS_TRACE();
32
32
 
33
33
  // Ignore too old data. Should never happen.
34
- if (this->oldestItemStartTime.has_value() && Utils::Number<uint64_t>::IsLowerThan(nowMs, *this->oldestItemStartTime))
34
+ if (this->oldestItemStartTime.has_value() && Utils::Number::IsLowerThan<uint64_t>(nowMs, *this->oldestItemStartTime))
35
35
  {
36
36
  MS_WARN_DEV("nowMs < this->oldestItemStartTime, should never happen");
37
37
 
@@ -47,7 +47,7 @@ namespace RTC
47
47
  // item size (in milliseconds), increase the item index.
48
48
  if (
49
49
  this->newestItemIndex < 0 || !this->newestItemStartTime.has_value() ||
50
- Utils::Number<uint64_t>::IsHigherOrEqualThan(
50
+ Utils::Number::IsHigherOrEqualThan<uint64_t>(
51
51
  nowMs - *this->newestItemStartTime, this->itemSizeMs))
52
52
  {
53
53
  this->newestItemIndex++;
@@ -165,7 +165,7 @@ namespace RTC
165
165
  const uint64_t newOldestTime = nowMs - this->windowSizeMs;
166
166
 
167
167
  // Oldest item already removed.
168
- if (Utils::Number<uint64_t>::IsLowerThan(newOldestTime, *this->oldestItemStartTime))
168
+ if (Utils::Number::IsLowerThan<uint64_t>(newOldestTime, *this->oldestItemStartTime))
169
169
  {
170
170
  return;
171
171
  }
@@ -173,7 +173,7 @@ namespace RTC
173
173
  // A whole window size time has elapsed since last entry. Reset the buffer.
174
174
  if (
175
175
  this->newestItemStartTime.has_value() &&
176
- Utils::Number<uint64_t>::IsHigherOrEqualThan(newOldestTime, *this->newestItemStartTime))
176
+ Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->newestItemStartTime))
177
177
  {
178
178
  MS_DEBUG_DEV("newOldestTime >= this->newestItemStartTime, resetting the buffer");
179
179
 
@@ -182,7 +182,7 @@ namespace RTC
182
182
  return;
183
183
  }
184
184
 
185
- while (Utils::Number<uint64_t>::IsHigherOrEqualThan(newOldestTime, *this->oldestItemStartTime))
185
+ while (Utils::Number::IsHigherOrEqualThan<uint64_t>(newOldestTime, *this->oldestItemStartTime))
186
186
  {
187
187
  BufferItem& oldestItem = this->buffer[this->oldestItemIndex];
188
188
  this->totalCount -= oldestItem.count;