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
@@ -56,7 +56,7 @@ namespace RTC
56
56
  MS_DUMP_CLEAN(indentation, "</SCTP::RetransmissionTimeout>");
57
57
  }
58
58
 
59
- void RetransmissionTimeout::ObserveRtt(uint64_t rttMs)
59
+ void RetransmissionTimeout::ObserveRttMs(uint64_t rttMs)
60
60
  {
61
61
  MS_TRACE();
62
62
 
@@ -120,7 +120,7 @@ namespace RTC
120
120
  os(os),
121
121
  mis(mis),
122
122
  maxSctpMessageSize(maxSctpMessageSize),
123
- sctpSendBufferSize(sctpSendBufferSize),
123
+ sctpSendBufferSize(std::max(sctpSendBufferSize, maxSctpMessageSize)),
124
124
  isDataChannel(isDataChannel)
125
125
  {
126
126
  MS_TRACE();
@@ -22,7 +22,7 @@ namespace RTC
22
22
  /* Instance methods. */
23
23
 
24
24
  SimpleConsumer::SimpleConsumer(
25
- RTC::Shared* shared,
25
+ SharedInterface* shared,
26
26
  const std::string& id,
27
27
  const std::string& producerId,
28
28
  RTC::Consumer::Listener* listener,
@@ -69,7 +69,7 @@ namespace RTC
69
69
  }
70
70
 
71
71
  // NOTE: This may throw.
72
- this->shared->channelMessageRegistrator->RegisterHandler(
72
+ this->shared->GetChannelMessageRegistrator()->RegisterHandler(
73
73
  this->id,
74
74
  /*channelRequestHandler*/ this,
75
75
  /*channelNotificationHandler*/ nullptr);
@@ -79,7 +79,7 @@ namespace RTC
79
79
  {
80
80
  MS_TRACE();
81
81
 
82
- this->shared->channelMessageRegistrator->UnregisterHandler(this->id);
82
+ this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
83
83
 
84
84
  delete this->rtpStream;
85
85
  this->targetLayerRetransmissionBuffer.clear();
@@ -780,7 +780,8 @@ namespace RTC
780
780
  }
781
781
  }
782
782
 
783
- this->rtpStream = new RTC::RTP::RtpStreamSend(this, params, this->rtpParameters.mid);
783
+ this->rtpStream =
784
+ new RTC::RTP::RtpStreamSend(this, this->shared, params, this->rtpParameters.mid);
784
785
  this->rtpStreams.push_back(this->rtpStream);
785
786
 
786
787
  // If the Consumer is paused, tell the RtpStreamSend.
@@ -848,12 +849,12 @@ namespace RTC
848
849
  {
849
850
  MS_TRACE();
850
851
 
851
- auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder());
852
+ auto scoreOffset = FillBufferScore(this->shared->GetChannelNotifier()->GetBufferBuilder());
852
853
 
853
854
  auto notificationOffset = FBS::Consumer::CreateScoreNotification(
854
- this->shared->channelNotifier->GetBufferBuilder(), scoreOffset);
855
+ this->shared->GetChannelNotifier()->GetBufferBuilder(), scoreOffset);
855
856
 
856
- this->shared->channelNotifier->Emit(
857
+ this->shared->GetChannelNotifier()->Emit(
857
858
  this->id,
858
859
  FBS::Notification::Event::CONSUMER_SCORE,
859
860
  FBS::Notification::Body::Consumer_ScoreNotification,
@@ -25,7 +25,7 @@ namespace RTC
25
25
  /* Instance methods. */
26
26
 
27
27
  SimulcastConsumer::SimulcastConsumer(
28
- RTC::Shared* shared,
28
+ SharedInterface* shared,
29
29
  const std::string& id,
30
30
  const std::string& producerId,
31
31
  RTC::Consumer::Listener* listener,
@@ -126,7 +126,7 @@ namespace RTC
126
126
  CreateRtpStream();
127
127
 
128
128
  // NOTE: This may throw.
129
- this->shared->channelMessageRegistrator->RegisterHandler(
129
+ this->shared->GetChannelMessageRegistrator()->RegisterHandler(
130
130
  this->id,
131
131
  /*channelRequestHandler*/ this,
132
132
  /*channelRequestHandler*/ nullptr);
@@ -136,7 +136,7 @@ namespace RTC
136
136
  {
137
137
  MS_TRACE();
138
138
 
139
- this->shared->channelMessageRegistrator->UnregisterHandler(this->id);
139
+ this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
140
140
 
141
141
  delete this->rtpStream;
142
142
  this->targetLayerRetransmissionBuffer.clear();
@@ -1462,7 +1462,8 @@ namespace RTC
1462
1462
  }
1463
1463
  }
1464
1464
 
1465
- this->rtpStream = new RTC::RTP::RtpStreamSend(this, params, this->rtpParameters.mid);
1465
+ this->rtpStream =
1466
+ new RTC::RTP::RtpStreamSend(this, this->shared, params, this->rtpParameters.mid);
1466
1467
  this->rtpStreams.push_back(this->rtpStream);
1467
1468
 
1468
1469
  // If the Consumer is paused, tell the RtpStreamSend.
@@ -1773,12 +1774,12 @@ namespace RTC
1773
1774
  {
1774
1775
  MS_TRACE();
1775
1776
 
1776
- auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder());
1777
+ auto scoreOffset = FillBufferScore(this->shared->GetChannelNotifier()->GetBufferBuilder());
1777
1778
 
1778
1779
  auto notificationOffset = FBS::Consumer::CreateScoreNotification(
1779
- this->shared->channelNotifier->GetBufferBuilder(), scoreOffset);
1780
+ this->shared->GetChannelNotifier()->GetBufferBuilder(), scoreOffset);
1780
1781
 
1781
- this->shared->channelNotifier->Emit(
1782
+ this->shared->GetChannelNotifier()->Emit(
1782
1783
  this->id,
1783
1784
  FBS::Notification::Event::CONSUMER_SCORE,
1784
1785
  FBS::Notification::Body::Consumer_ScoreNotification,
@@ -1800,15 +1801,15 @@ namespace RTC
1800
1801
  if (this->currentSpatialLayer >= 0)
1801
1802
  {
1802
1803
  layersOffset = FBS::Consumer::CreateConsumerLayers(
1803
- this->shared->channelNotifier->GetBufferBuilder(),
1804
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
1804
1805
  this->currentSpatialLayer,
1805
1806
  this->encodingContext->GetCurrentTemporalLayer());
1806
1807
  }
1807
1808
 
1808
1809
  auto notificationOffset = FBS::Consumer::CreateLayersChangeNotification(
1809
- this->shared->channelNotifier->GetBufferBuilder(), layersOffset);
1810
+ this->shared->GetChannelNotifier()->GetBufferBuilder(), layersOffset);
1810
1811
 
1811
- this->shared->channelNotifier->Emit(
1812
+ this->shared->GetChannelNotifier()->Emit(
1812
1813
  this->id,
1813
1814
  FBS::Notification::Event::CONSUMER_LAYERS_CHANGE,
1814
1815
  FBS::Notification::Body::Consumer_LayersChangeNotification,
@@ -23,7 +23,7 @@ namespace RTC
23
23
  /* Instance methods. */
24
24
 
25
25
  SvcConsumer::SvcConsumer(
26
- RTC::Shared* shared,
26
+ SharedInterface* shared,
27
27
  const std::string& id,
28
28
  const std::string& producerId,
29
29
  RTC::Consumer::Listener* listener,
@@ -107,7 +107,7 @@ namespace RTC
107
107
  CreateRtpStream();
108
108
 
109
109
  // NOTE: This may throw.
110
- this->shared->channelMessageRegistrator->RegisterHandler(
110
+ this->shared->GetChannelMessageRegistrator()->RegisterHandler(
111
111
  this->id,
112
112
  /*channelRequestHandler*/ this,
113
113
  /*channelNotificationHandler*/ nullptr);
@@ -117,7 +117,7 @@ namespace RTC
117
117
  {
118
118
  MS_TRACE();
119
119
 
120
- this->shared->channelMessageRegistrator->UnregisterHandler(this->id);
120
+ this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
121
121
 
122
122
  delete this->rtpStream;
123
123
  this->targetLayerRetransmissionBuffer.clear();
@@ -1090,7 +1090,8 @@ namespace RTC
1090
1090
  }
1091
1091
  }
1092
1092
 
1093
- this->rtpStream = new RTC::RTP::RtpStreamSend(this, params, this->rtpParameters.mid);
1093
+ this->rtpStream =
1094
+ new RTC::RTP::RtpStreamSend(this, this->shared, params, this->rtpParameters.mid);
1094
1095
  this->rtpStreams.push_back(this->rtpStream);
1095
1096
 
1096
1097
  // If the Consumer is paused, tell the RtpStreamSend.
@@ -1305,12 +1306,12 @@ namespace RTC
1305
1306
  {
1306
1307
  MS_TRACE();
1307
1308
 
1308
- auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder());
1309
+ auto scoreOffset = FillBufferScore(this->shared->GetChannelNotifier()->GetBufferBuilder());
1309
1310
 
1310
1311
  auto notificationOffset = FBS::Consumer::CreateScoreNotification(
1311
- this->shared->channelNotifier->GetBufferBuilder(), scoreOffset);
1312
+ this->shared->GetChannelNotifier()->GetBufferBuilder(), scoreOffset);
1312
1313
 
1313
- this->shared->channelNotifier->Emit(
1314
+ this->shared->GetChannelNotifier()->Emit(
1314
1315
  this->id,
1315
1316
  FBS::Notification::Event::CONSUMER_SCORE,
1316
1317
  FBS::Notification::Body::Consumer_ScoreNotification,
@@ -1332,15 +1333,15 @@ namespace RTC
1332
1333
  if (this->encodingContext->GetCurrentSpatialLayer() >= 0)
1333
1334
  {
1334
1335
  layersOffset = FBS::Consumer::CreateConsumerLayers(
1335
- this->shared->channelNotifier->GetBufferBuilder(),
1336
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
1336
1337
  this->encodingContext->GetCurrentSpatialLayer(),
1337
1338
  this->encodingContext->GetCurrentTemporalLayer());
1338
1339
  }
1339
1340
 
1340
1341
  auto notificationOffset = FBS::Consumer::CreateLayersChangeNotification(
1341
- this->shared->channelNotifier->GetBufferBuilder(), layersOffset);
1342
+ this->shared->GetChannelNotifier()->GetBufferBuilder(), layersOffset);
1342
1343
 
1343
- this->shared->channelNotifier->Emit(
1344
+ this->shared->GetChannelNotifier()->Emit(
1344
1345
  this->id,
1345
1346
  FBS::Notification::Event::CONSUMER_LAYERS_CHANGE,
1346
1347
  FBS::Notification::Body::Consumer_LayersChangeNotification,
@@ -40,7 +40,7 @@ namespace RTC
40
40
  /* Instance methods. */
41
41
 
42
42
  Transport::Transport(
43
- RTC::Shared* shared,
43
+ SharedInterface* shared,
44
44
  const std::string& id,
45
45
  RTC::Transport::Listener* listener,
46
46
  const FBS::Transport::Options* options)
@@ -120,7 +120,8 @@ namespace RTC
120
120
  .maxSendBufferSize = sctpSendBufferSize
121
121
  };
122
122
 
123
- this->sctpAssociation = std::make_unique<RTC::SCTP::Association>(sctpOptions, this);
123
+ this->sctpAssociation =
124
+ std::make_unique<RTC::SCTP::Association>(sctpOptions, this, this->shared);
124
125
  }
125
126
  // TODO: Remove once we only use built-in SCTP stack.
126
127
  else
@@ -137,7 +138,7 @@ namespace RTC
137
138
  }
138
139
 
139
140
  // Create the RTCP timer.
140
- this->rtcpTimer = new TimerHandle(this);
141
+ this->rtcpTimer = this->shared->CreateTimer(this);
141
142
  }
142
143
 
143
144
  Transport::~Transport()
@@ -880,7 +881,7 @@ namespace RTC
880
881
  if (createTccServer)
881
882
  {
882
883
  this->tccServer = std::make_shared<RTC::TransportCongestionControlServer>(
883
- this, bweType, RTC::Consts::RtcpPacketMaxSize);
884
+ this, this->shared, bweType, RTC::Consts::RtcpPacketMaxSize);
884
885
 
885
886
  if (this->maxIncomingBitrate != 0u)
886
887
  {
@@ -1073,6 +1074,7 @@ namespace RTC
1073
1074
 
1074
1075
  this->tccClient = std::make_shared<RTC::TransportCongestionControlClient>(
1075
1076
  this,
1077
+ this->shared,
1076
1078
  bweType,
1077
1079
  this->initialAvailableOutgoingBitrate,
1078
1080
  this->maxOutgoingBitrate,
@@ -2553,12 +2555,12 @@ namespace RTC
2553
2555
 
2554
2556
  // TODO: Missing trace info (RTP packet dump).
2555
2557
  auto notification = FBS::Transport::CreateTraceNotification(
2556
- this->shared->channelNotifier->GetBufferBuilder(),
2558
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
2557
2559
  FBS::Transport::TraceEventType::PROBATION,
2558
2560
  DepLibUV::GetTimeMs(),
2559
2561
  FBS::Common::TraceDirection::DIRECTION_OUT);
2560
2562
 
2561
- this->shared->channelNotifier->Emit(
2563
+ this->shared->GetChannelNotifier()->Emit(
2562
2564
  this->id,
2563
2565
  FBS::Notification::Event::TRANSPORT_TRACE,
2564
2566
  FBS::Notification::Body::Transport_TraceNotification,
@@ -2576,7 +2578,7 @@ namespace RTC
2576
2578
  }
2577
2579
 
2578
2580
  auto traceInfo = FBS::Transport::CreateBweTraceInfo(
2579
- this->shared->channelNotifier->GetBufferBuilder(),
2581
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
2580
2582
  this->tccClient->GetBweType() == RTC::BweType::TRANSPORT_CC
2581
2583
  ? FBS::Transport::BweType::TRANSPORT_CC
2582
2584
  : FBS::Transport::BweType::REMB,
@@ -2589,14 +2591,14 @@ namespace RTC
2589
2591
  bitrates.availableBitrate);
2590
2592
 
2591
2593
  auto notification = FBS::Transport::CreateTraceNotification(
2592
- this->shared->channelNotifier->GetBufferBuilder(),
2594
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
2593
2595
  FBS::Transport::TraceEventType::BWE,
2594
2596
  DepLibUV::GetTimeMs(),
2595
2597
  FBS::Common::TraceDirection::DIRECTION_OUT,
2596
2598
  FBS::Transport::TraceInfo::BweTraceInfo,
2597
2599
  traceInfo.Union());
2598
2600
 
2599
- this->shared->channelNotifier->Emit(
2601
+ this->shared->GetChannelNotifier()->Emit(
2600
2602
  this->id,
2601
2603
  FBS::Notification::Event::TRANSPORT_TRACE,
2602
2604
  FBS::Notification::Body::Transport_TraceNotification,
@@ -3032,9 +3034,10 @@ namespace RTC
3032
3034
 
3033
3035
  // Notify the Node Transport.
3034
3036
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3035
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTING);
3037
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3038
+ FBS::SctpAssociation::SctpState::CONNECTING);
3036
3039
 
3037
- this->shared->channelNotifier->Emit(
3040
+ this->shared->GetChannelNotifier()->Emit(
3038
3041
  this->id,
3039
3042
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3040
3043
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3058,9 +3061,10 @@ namespace RTC
3058
3061
 
3059
3062
  // Notify the Node Transport.
3060
3063
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3061
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTED);
3064
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3065
+ FBS::SctpAssociation::SctpState::CONNECTED);
3062
3066
 
3063
- this->shared->channelNotifier->Emit(
3067
+ this->shared->GetChannelNotifier()->Emit(
3064
3068
  this->id,
3065
3069
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3066
3070
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3089,9 +3093,10 @@ namespace RTC
3089
3093
 
3090
3094
  // Notify the Node Transport.
3091
3095
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3092
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::FAILED);
3096
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3097
+ FBS::SctpAssociation::SctpState::FAILED);
3093
3098
 
3094
- this->shared->channelNotifier->Emit(
3099
+ this->shared->GetChannelNotifier()->Emit(
3095
3100
  this->id,
3096
3101
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3097
3102
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3116,9 +3121,10 @@ namespace RTC
3116
3121
 
3117
3122
  // Notify the Node Transport.
3118
3123
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3119
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CLOSED);
3124
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3125
+ FBS::SctpAssociation::SctpState::CLOSED);
3120
3126
 
3121
- this->shared->channelNotifier->Emit(
3127
+ this->shared->GetChannelNotifier()->Emit(
3122
3128
  this->id,
3123
3129
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3124
3130
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3213,9 +3219,10 @@ namespace RTC
3213
3219
 
3214
3220
  // Notify the Node Transport.
3215
3221
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3216
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTING);
3222
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3223
+ FBS::SctpAssociation::SctpState::CONNECTING);
3217
3224
 
3218
- this->shared->channelNotifier->Emit(
3225
+ this->shared->GetChannelNotifier()->Emit(
3219
3226
  this->id,
3220
3227
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3221
3228
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3239,9 +3246,10 @@ namespace RTC
3239
3246
 
3240
3247
  // Notify the Node Transport.
3241
3248
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3242
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTED);
3249
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3250
+ FBS::SctpAssociation::SctpState::CONNECTED);
3243
3251
 
3244
- this->shared->channelNotifier->Emit(
3252
+ this->shared->GetChannelNotifier()->Emit(
3245
3253
  this->id,
3246
3254
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3247
3255
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3265,9 +3273,10 @@ namespace RTC
3265
3273
 
3266
3274
  // Notify the Node Transport.
3267
3275
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3268
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::FAILED);
3276
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3277
+ FBS::SctpAssociation::SctpState::FAILED);
3269
3278
 
3270
- this->shared->channelNotifier->Emit(
3279
+ this->shared->GetChannelNotifier()->Emit(
3271
3280
  this->id,
3272
3281
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3273
3282
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3291,9 +3300,10 @@ namespace RTC
3291
3300
 
3292
3301
  // Notify the Node Transport.
3293
3302
  auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification(
3294
- this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CLOSED);
3303
+ this->shared->GetChannelNotifier()->GetBufferBuilder(),
3304
+ FBS::SctpAssociation::SctpState::CLOSED);
3295
3305
 
3296
- this->shared->channelNotifier->Emit(
3306
+ this->shared->GetChannelNotifier()->Emit(
3297
3307
  this->id,
3298
3308
  FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE,
3299
3309
  FBS::Notification::Body::Transport_SctpStateChangeNotification,
@@ -3518,7 +3528,7 @@ namespace RTC
3518
3528
  }
3519
3529
  #endif
3520
3530
 
3521
- void Transport::OnTimer(TimerHandle* timer)
3531
+ void Transport::OnTimer(TimerHandleInterface* timer)
3522
3532
  {
3523
3533
  MS_TRACE();
3524
3534
 
@@ -24,11 +24,13 @@ namespace RTC
24
24
 
25
25
  TransportCongestionControlClient::TransportCongestionControlClient(
26
26
  RTC::TransportCongestionControlClient::Listener* listener,
27
+ SharedInterface* shared,
27
28
  RTC::BweType bweType,
28
29
  uint32_t initialAvailableBitrate,
29
30
  uint32_t maxOutgoingBitrate,
30
31
  uint32_t minOutgoingBitrate)
31
32
  : listener(listener),
33
+ shared(shared),
32
34
  bweType(bweType),
33
35
  initialAvailableBitrate(
34
36
  std::max<uint32_t>(
@@ -75,7 +77,7 @@ namespace RTC
75
77
  // videos are muted or using screensharing with still images)
76
78
  this->rtpTransportControllerSend->EnablePeriodicAlrProbing(true);
77
79
 
78
- this->processTimer = new TimerHandle(this);
80
+ this->processTimer = this->shared->CreateTimer(this);
79
81
 
80
82
  this->processTimer->Start(
81
83
  std::min(
@@ -552,7 +554,7 @@ namespace RTC
552
554
  return this->probationGenerator->GetNextPacket(size);
553
555
  }
554
556
 
555
- void TransportCongestionControlClient::OnTimer(TimerHandle* timer)
557
+ void TransportCongestionControlClient::OnTimer(TimerHandleInterface* timer)
556
558
  {
557
559
  MS_TRACE();
558
560
 
@@ -20,9 +20,10 @@ namespace RTC
20
20
 
21
21
  TransportCongestionControlServer::TransportCongestionControlServer(
22
22
  RTC::TransportCongestionControlServer::Listener* listener,
23
+ SharedInterface* shared,
23
24
  RTC::BweType bweType,
24
25
  size_t maxRtcpPacketLen)
25
- : listener(listener), bweType(bweType), maxRtcpPacketLen(maxRtcpPacketLen)
26
+ : listener(listener), shared(shared), bweType(bweType), maxRtcpPacketLen(maxRtcpPacketLen)
26
27
  {
27
28
  MS_TRACE();
28
29
 
@@ -34,7 +35,7 @@ namespace RTC
34
35
  ResetTransportCcFeedback(0u);
35
36
 
36
37
  // Create the feedback send periodic timer.
37
- this->transportCcFeedbackSendPeriodicTimer = new TimerHandle(this);
38
+ this->transportCcFeedbackSendPeriodicTimer = this->shared->CreateTimer(this);
38
39
 
39
40
  break;
40
41
  }
@@ -468,7 +469,7 @@ namespace RTC
468
469
  this->listener->OnTransportCongestionControlServerSendRtcpPacket(this, &packet);
469
470
  }
470
471
 
471
- void TransportCongestionControlServer::OnTimer(TimerHandle* timer)
472
+ void TransportCongestionControlServer::OnTimer(TimerHandleInterface* timer)
472
473
  {
473
474
  MS_TRACE();
474
475
 
@@ -1,11 +1,12 @@
1
+ #include "SharedInterface.hpp"
1
2
  #define MS_CLASS "RTC::WebRtcServer"
2
3
  // #define MS_LOG_DEV_LEVEL 3
3
4
 
4
- #include "RTC/WebRtcServer.hpp"
5
5
  #include "Logger.hpp"
6
6
  #include "MediaSoupErrors.hpp"
7
7
  #include "Settings.hpp"
8
8
  #include "Utils.hpp"
9
+ #include "RTC/WebRtcServer.hpp"
9
10
  #include <cmath> // std::pow()
10
11
 
11
12
  namespace RTC
@@ -53,7 +54,7 @@ namespace RTC
53
54
  /* Instance methods. */
54
55
 
55
56
  WebRtcServer::WebRtcServer(
56
- RTC::Shared* shared,
57
+ SharedInterface* shared,
57
58
  const std::string& id,
58
59
  const flatbuffers::Vector<flatbuffers::Offset<FBS::Transport::ListenInfo>>* listenInfos)
59
60
  : id(id), shared(shared)
@@ -205,7 +206,7 @@ namespace RTC
205
206
  }
206
207
 
207
208
  // NOTE: This may throw.
208
- this->shared->channelMessageRegistrator->RegisterHandler(
209
+ this->shared->GetChannelMessageRegistrator()->RegisterHandler(
209
210
  this->id,
210
211
  /*channelRequestHandler*/ this,
211
212
  /*channelNotificationHandler*/ nullptr);
@@ -234,7 +235,7 @@ namespace RTC
234
235
 
235
236
  this->closing = true;
236
237
 
237
- this->shared->channelMessageRegistrator->UnregisterHandler(this->id);
238
+ this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
238
239
 
239
240
  // NOTE: We need to close WebRtcTransports first since they may need to
240
241
  // send DTLS Close Alert so UDP sockets and TCP connections must remain