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
@@ -30,5 +30,6 @@ export declare class WorkerImpl<WorkerAppData extends AppData = AppData> extends
30
30
  createRouter<RouterAppData extends AppData = AppData>({ mediaCodecs, appData, }?: RouterOptions<RouterAppData>): Promise<Router<RouterAppData>>;
31
31
  private workerDied;
32
32
  private handleListenerError;
33
+ private onSignal;
33
34
  }
34
35
  //# sourceMappingURL=Worker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../src/Worker.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,cAAc,EAEd,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAM3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAWvC,eAAO,MAAM,gBAAgB,EAAE,MAA8B,CAAC;AAE9D,qBAAa,UAAU,CAAC,aAAa,SAAS,OAAO,GAAG,OAAO,CAC9D,SAAQ,oBAAoB,CAAC,YAAY,CACzC,YAAW,MAAM;;gBAiCL,EACX,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,kBA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QAAQ,EACR,OAAO,GACP,GAAE,wBAAwB,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD,kBAAkB,CAAC,mBAAmB,SAAS,OAAO,GAAG,OAAO,EAAE,EACvE,WAAW,EACX,OAAO,GACP,EAAE,mBAAmB,CAAC,mBAAmB,CAAC,GAAG,OAAO,CACpD,YAAY,CAAC,mBAAmB,CAAC,CACjC;IA0DK,YAAY,CAAC,aAAa,SAAS,OAAO,GAAG,OAAO,EAAE,EAC3D,WAAW,EACX,OAAO,GACP,GAAE,aAAa,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAgDrE,OAAO,CAAC,UAAU;IAmClB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,QAAQ,CAMd;CACF"}
@@ -192,6 +192,13 @@ class WorkerImpl extends enhancedEvents_1.EnhancedEventEmitter {
192
192
  }
193
193
  }
194
194
  });
195
+ // NOTE: Avoid "Possible EventEmitter memory leak detected" Node warning.
196
+ const processListenerCount = process.getMaxListeners();
197
+ if (processListenerCount >= 10) {
198
+ process.setMaxListeners(processListenerCount + 2);
199
+ }
200
+ process.once('SIGINT', this.onSignal);
201
+ process.once('SIGTERM', this.onSignal);
195
202
  this.handleListenerError();
196
203
  }
197
204
  get pid() {
@@ -233,6 +240,8 @@ class WorkerImpl extends enhancedEvents_1.EnhancedEventEmitter {
233
240
  }
234
241
  logger.debug('close()');
235
242
  this.#closed = true;
243
+ process.removeListener('SIGINT', this.onSignal);
244
+ process.removeListener('SIGTERM', this.onSignal);
236
245
  // Close every Router.
237
246
  for (const router of this.#routers) {
238
247
  router.workerClosed();
@@ -376,6 +385,11 @@ class WorkerImpl extends enhancedEvents_1.EnhancedEventEmitter {
376
385
  logger.error(`event listener threw an error [eventName:${eventName}]:`, error);
377
386
  });
378
387
  }
388
+ // NOTE: Arrow method on purpose.
389
+ onSignal = (signal) => {
390
+ logger.debug(`signal received, closing the worker process [pid:${this.#pid}, signal:${signal}]`);
391
+ this.close();
392
+ };
379
393
  }
380
394
  exports.WorkerImpl = WorkerImpl;
381
395
  function parseWorkerDumpResponse(binary) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup",
3
- "version": "3.19.21",
3
+ "version": "3.19.22",
4
4
  "description": "Cutting Edge WebRTC Video Conferencing",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -48,6 +48,8 @@
48
48
  "worker/fuzzer/include",
49
49
  "worker/fuzzer/src",
50
50
  "worker/include",
51
+ "worker/mocks/include",
52
+ "worker/mocks/src",
51
53
  "worker/src",
52
54
  "worker/scripts/*.json",
53
55
  "worker/scripts/*.mjs",
@@ -125,7 +127,7 @@
125
127
  "prettier": "^3.8.3",
126
128
  "ts-jest": "^29.4.9",
127
129
  "typescript": "^5.9.3",
128
- "typescript-eslint": "^8.59.0",
130
+ "typescript-eslint": "^8.59.1",
129
131
  "werift-sctp": "^0.0.11"
130
132
  }
131
133
  }
@@ -4,17 +4,22 @@
4
4
  #include "RTC/FuzzerDtlsTransport.hpp"
5
5
  #include "Logger.hpp"
6
6
  #include "Utils.hpp"
7
+ #include "mocks/include/MockShared.hpp"
7
8
 
8
9
  namespace
9
10
  {
10
- // NOLINTBEGIN(readability-identifier-naming)
11
+ // NOLINTNEXTLINE(readability-identifier-naming)
12
+ thread_local mocks::MockShared shared;
13
+
11
14
  // DtlsTransport instance. It's reset every time DTLS handshake fails or DTLS
12
15
  // is closed.
16
+ // NOLINTNEXTLINE(readability-identifier-naming)
13
17
  thread_local RTC::DtlsTransport* dtlsTransportSingleton{ nullptr };
18
+
14
19
  // DtlsTransport Listener instance. It's reset every time the DtlsTransport
15
20
  // singletonDTLS is reset.
21
+ // NOLINTNEXTLINE(readability-identifier-naming)
16
22
  thread_local FuzzerRtcDtlsTransport::DtlsTransportListener* dtlsTransportListenerSingleton{ nullptr };
17
- // NOLINTEND(readability-identifier-naming)
18
23
  } // namespace
19
24
 
20
25
  void FuzzerRtcDtlsTransport::Fuzz(const uint8_t* data, size_t len)
@@ -31,7 +36,8 @@ void FuzzerRtcDtlsTransport::Fuzz(const uint8_t* data, size_t len)
31
36
  delete dtlsTransportListenerSingleton;
32
37
  dtlsTransportListenerSingleton = new DtlsTransportListener();
33
38
 
34
- dtlsTransportSingleton = new RTC::DtlsTransport(dtlsTransportListenerSingleton);
39
+ dtlsTransportSingleton =
40
+ new RTC::DtlsTransport(dtlsTransportListenerSingleton, std::addressof(shared));
35
41
 
36
42
  RTC::DtlsTransport::Role localRole;
37
43
  RTC::DtlsTransport::Fingerprint dtlsRemoteFingerprint;
@@ -1,7 +1,14 @@
1
1
  #include "RTC/RTP/FuzzerRtpStreamSend.hpp"
2
2
  #include "Utils.hpp"
3
+ #include "mocks/include/MockShared.hpp"
3
4
  #include "RTC/RTP/SharedPacket.hpp"
4
5
 
6
+ namespace
7
+ {
8
+ // NOLINTNEXTLINE(readability-identifier-naming)
9
+ thread_local mocks::MockShared shared;
10
+ } // namespace
11
+
5
12
  void FuzzerRtcRtpStreamSend::Fuzz(const uint8_t* data, size_t len)
6
13
  {
7
14
  // clang-format off
@@ -30,7 +37,8 @@ void FuzzerRtcRtpStreamSend::Fuzz(const uint8_t* data, size_t len)
30
37
  packet->SetSsrc(params.ssrc);
31
38
 
32
39
  std::string mid;
33
- auto* stream = new RTC::RTP::RtpStreamSend(&testRtpStreamListener, params, mid);
40
+ auto* stream = new RTC::RTP::RtpStreamSend(
41
+ std::addressof(testRtpStreamListener), std::addressof(shared), params, mid);
34
42
  size_t offset{ 0u };
35
43
 
36
44
  while (len >= 4u)
@@ -0,0 +1,39 @@
1
+ #ifndef MS_CHANNEL_MESSAGE_REGISTRATOR_HPP
2
+ #define MS_CHANNEL_MESSAGE_REGISTRATOR_HPP
3
+
4
+ #include "Channel/ChannelMessageRegistratorInterface.hpp"
5
+ #include "Channel/ChannelSocket.hpp"
6
+ #include <string>
7
+ #include <unordered_map>
8
+
9
+ namespace Channel
10
+ {
11
+ class ChannelMessageRegistrator : public Channel::ChannelMessageRegistratorInterface
12
+ {
13
+ public:
14
+ explicit ChannelMessageRegistrator();
15
+
16
+ ~ChannelMessageRegistrator() override;
17
+
18
+ public:
19
+ flatbuffers::Offset<FBS::Worker::ChannelMessageHandlers> FillBuffer(
20
+ flatbuffers::FlatBufferBuilder& builder) override;
21
+
22
+ void RegisterHandler(
23
+ const std::string& id,
24
+ ChannelSocket::RequestHandler* channelRequestHandler,
25
+ ChannelSocket::NotificationHandler* channelNotificationHandler) override;
26
+
27
+ void UnregisterHandler(const std::string& id) override;
28
+
29
+ ChannelSocket::RequestHandler* GetChannelRequestHandler(const std::string& id) override;
30
+
31
+ ChannelSocket::NotificationHandler* GetChannelNotificationHandler(const std::string& id) override;
32
+
33
+ private:
34
+ std::unordered_map<std::string, ChannelSocket::RequestHandler*> mapChannelRequestHandlers;
35
+ std::unordered_map<std::string, ChannelSocket::NotificationHandler*> mapChannelNotificationHandlers;
36
+ };
37
+ } // namespace Channel
38
+
39
+ #endif
@@ -0,0 +1,32 @@
1
+ #ifndef MS_CHANNEL_MESSAGE_REGISTRATOR_INTERFACE_HPP
2
+ #define MS_CHANNEL_MESSAGE_REGISTRATOR_INTERFACE_HPP
3
+
4
+ // TODO: We should have a ChannelSocketInterface class instead.
5
+ #include "Channel/ChannelSocket.hpp"
6
+ #include <string>
7
+
8
+ namespace Channel
9
+ {
10
+ class ChannelMessageRegistratorInterface
11
+ {
12
+ public:
13
+ virtual ~ChannelMessageRegistratorInterface() = default;
14
+
15
+ public:
16
+ virtual flatbuffers::Offset<FBS::Worker::ChannelMessageHandlers> FillBuffer(
17
+ flatbuffers::FlatBufferBuilder& builder) = 0;
18
+
19
+ virtual void RegisterHandler(
20
+ const std::string& id,
21
+ ChannelSocket::RequestHandler* channelRequestHandler,
22
+ ChannelSocket::NotificationHandler* channelNotificationHandler) = 0;
23
+
24
+ virtual void UnregisterHandler(const std::string& id) = 0;
25
+
26
+ virtual ChannelSocket::RequestHandler* GetChannelRequestHandler(const std::string& id) = 0;
27
+
28
+ virtual ChannelSocket::NotificationHandler* GetChannelNotificationHandler(const std::string& id) = 0;
29
+ };
30
+ } // namespace Channel
31
+
32
+ #endif
@@ -82,7 +82,7 @@ namespace Channel
82
82
  };
83
83
 
84
84
  public:
85
- #ifdef MS_TEST
85
+ #if defined(MS_TEST) || defined(MS_FUZZER)
86
86
  explicit ChannelSocket();
87
87
  #endif
88
88
  explicit ChannelSocket(int consumerFd, int producerFd);
@@ -2,36 +2,37 @@
2
2
  #define MS_DEP_USRSCTP_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "RTC/SctpAssociation.hpp"
6
- #include "handles/TimerHandle.hpp"
7
+ #include "handles/TimerHandleInterface.hpp"
7
8
  #include <absl/container/flat_hash_map.h>
8
9
 
9
10
  class DepUsrSCTP
10
11
  {
11
12
  private:
12
- class Checker : public TimerHandle::Listener
13
+ class Checker : public TimerHandleInterface::Listener
13
14
  {
14
15
  public:
15
- Checker();
16
+ Checker(SharedInterface* shared);
16
17
  ~Checker() override;
17
18
 
18
19
  public:
19
20
  void Start();
20
21
  void Stop();
21
22
 
22
- /* Pure virtual methods inherited from TimerHandle::Listener. */
23
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
23
24
  public:
24
- void OnTimer(TimerHandle* timer) override;
25
+ void OnTimer(TimerHandleInterface* timer) override;
25
26
 
26
27
  private:
27
- TimerHandle* timer{ nullptr };
28
+ TimerHandleInterface* timer{ nullptr };
28
29
  uint64_t lastCalledAtMs{ 0u };
29
30
  };
30
31
 
31
32
  public:
32
33
  static void ClassInit();
33
34
  static void ClassDestroy();
34
- static void CreateChecker();
35
+ static void CreateChecker(SharedInterface* shared);
35
36
  static void CloseChecker();
36
37
  static uintptr_t GetNextSctpAssociationId();
37
38
  static void RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation);
@@ -1,9 +1,9 @@
1
1
  #ifndef MS_RTC_ACTIVE_SPEAKER_OBSERVER_HPP
2
2
  #define MS_RTC_ACTIVE_SPEAKER_OBSERVER_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "RTC/RtpObserver.hpp"
5
- #include "RTC/Shared.hpp"
6
- #include "handles/TimerHandle.hpp"
6
+ #include "handles/TimerHandleInterface.hpp"
7
7
  #include <absl/container/flat_hash_map.h>
8
8
  #include <vector>
9
9
 
@@ -14,7 +14,7 @@
14
14
  // https://github.com/jitsi/jitsi-utils/blob/master/src/main/java/org/jitsi/utils/dsi/DominantSpeakerIdentification.java
15
15
  namespace RTC
16
16
  {
17
- class ActiveSpeakerObserver : public RTC::RtpObserver, public TimerHandle::Listener
17
+ class ActiveSpeakerObserver : public RTC::RtpObserver, public TimerHandleInterface::Listener
18
18
  {
19
19
  private:
20
20
  class Speaker
@@ -69,7 +69,7 @@ namespace RTC
69
69
 
70
70
  public:
71
71
  ActiveSpeakerObserver(
72
- RTC::Shared* shared,
72
+ SharedInterface* shared,
73
73
  const std::string& id,
74
74
  RTC::RtpObserver::Listener* listener,
75
75
  const FBS::ActiveSpeakerObserver::ActiveSpeakerObserverOptions* options);
@@ -89,14 +89,14 @@ namespace RTC
89
89
  bool CalculateActiveSpeaker();
90
90
  void TimeoutIdleLevels(uint64_t now);
91
91
 
92
- /* Pure virtual methods inherited from TimerHandle. */
92
+ /* Pure virtual methods inherited from TimerHandleInterface. */
93
93
  protected:
94
- void OnTimer(TimerHandle* timer) override;
94
+ void OnTimer(TimerHandleInterface* timer) override;
95
95
 
96
96
  private:
97
97
  double relativeSpeachActivities[RelativeSpeachActivitiesLen]{};
98
98
  std::string dominantId;
99
- TimerHandle* periodicTimer{ nullptr };
99
+ TimerHandleInterface* periodicTimer{ nullptr };
100
100
  uint16_t interval{ 300u };
101
101
  // Map of ProducerSpeakers indexed by Producer id.
102
102
  absl::flat_hash_map<std::string, ProducerSpeaker*> mapProducerSpeakers;
@@ -1,14 +1,14 @@
1
1
  #ifndef MS_RTC_AUDIO_LEVEL_OBSERVER_HPP
2
2
  #define MS_RTC_AUDIO_LEVEL_OBSERVER_HPP
3
3
 
4
+ #include "SharedInterface.hpp"
4
5
  #include "RTC/RtpObserver.hpp"
5
- #include "RTC/Shared.hpp"
6
- #include "handles/TimerHandle.hpp"
6
+ #include "handles/TimerHandleInterface.hpp"
7
7
  #include <absl/container/flat_hash_map.h>
8
8
 
9
9
  namespace RTC
10
10
  {
11
- class AudioLevelObserver : public RTC::RtpObserver, public TimerHandle::Listener
11
+ class AudioLevelObserver : public RTC::RtpObserver, public TimerHandleInterface::Listener
12
12
  {
13
13
  private:
14
14
  struct DBovs
@@ -19,7 +19,7 @@ namespace RTC
19
19
 
20
20
  public:
21
21
  AudioLevelObserver(
22
- RTC::Shared* shared,
22
+ SharedInterface* shared,
23
23
  const std::string& id,
24
24
  RTC::RtpObserver::Listener* listener,
25
25
  const FBS::AudioLevelObserver::AudioLevelObserverOptions* options);
@@ -38,9 +38,9 @@ namespace RTC
38
38
  void Update();
39
39
  void ResetMapProducerDBovs();
40
40
 
41
- /* Pure virtual methods inherited from TimerHandle. */
41
+ /* Pure virtual methods inherited from TimerHandleInterface. */
42
42
  protected:
43
- void OnTimer(TimerHandle* timer) override;
43
+ void OnTimer(TimerHandleInterface* timer) override;
44
44
 
45
45
  private:
46
46
  // Passed by argument.
@@ -48,7 +48,7 @@ namespace RTC
48
48
  int8_t threshold{ -80 };
49
49
  uint16_t interval{ 1000u };
50
50
  // Allocated by this.
51
- TimerHandle* periodicTimer{ nullptr };
51
+ TimerHandleInterface* periodicTimer{ nullptr };
52
52
  // Others.
53
53
  absl::flat_hash_map<RTC::Producer*, DBovs> mapProducerDBovs;
54
54
  bool silence{ true };
@@ -2,6 +2,7 @@
2
2
  #define MS_RTC_CONSUMER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "Channel/ChannelRequest.hpp"
6
7
  #include "Channel/ChannelSocket.hpp"
7
8
  #include "FBS/consumer.h"
@@ -16,7 +17,6 @@
16
17
  #include "RTC/RTP/RtpStreamSend.hpp"
17
18
  #include "RTC/RTP/SharedPacket.hpp"
18
19
  #include "RTC/RtpDictionaries.hpp"
19
- #include "RTC/Shared.hpp"
20
20
  #include <absl/container/flat_hash_set.h>
21
21
  #include <string>
22
22
  #include <vector>
@@ -52,7 +52,7 @@ namespace RTC
52
52
 
53
53
  public:
54
54
  Consumer(
55
- RTC::Shared* shared,
55
+ SharedInterface* shared,
56
56
  const std::string& id,
57
57
  const std::string& producerId,
58
58
  RTC::Consumer::Listener* listener,
@@ -177,7 +177,7 @@ namespace RTC
177
177
 
178
178
  protected:
179
179
  // Passed by argument.
180
- RTC::Shared* shared{ nullptr };
180
+ SharedInterface* shared{ nullptr };
181
181
  RTC::Consumer::Listener* listener{ nullptr };
182
182
  RTC::Media::Kind kind;
183
183
  RTC::RtpParameters rtpParameters;
@@ -2,10 +2,10 @@
2
2
  #define MS_RTC_DATA_CONSUMER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "Channel/ChannelRequest.hpp"
6
7
  #include "Channel/ChannelSocket.hpp"
7
8
  #include "RTC/SctpDictionaries.hpp"
8
- #include "RTC/Shared.hpp"
9
9
  #include <absl/container/flat_hash_set.h>
10
10
  #include <string>
11
11
 
@@ -43,7 +43,7 @@ namespace RTC
43
43
 
44
44
  public:
45
45
  DataConsumer(
46
- RTC::Shared* shared,
46
+ SharedInterface* shared,
47
47
  const std::string& id,
48
48
  const std::string& dataProducerId,
49
49
  RTC::DataConsumer::Listener* listener,
@@ -114,7 +114,7 @@ namespace RTC
114
114
 
115
115
  private:
116
116
  // Passed by argument.
117
- RTC::Shared* shared{ nullptr };
117
+ SharedInterface* shared{ nullptr };
118
118
  RTC::DataConsumer::Listener* listener{ nullptr };
119
119
  size_t maxMessageSize{ 0u };
120
120
  // Others.
@@ -2,10 +2,10 @@
2
2
  #define MS_RTC_DATA_PRODUCER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "Channel/ChannelRequest.hpp"
6
7
  #include "Channel/ChannelSocket.hpp"
7
8
  #include "RTC/SctpDictionaries.hpp"
8
- #include "RTC/Shared.hpp"
9
9
  #include <string>
10
10
  #include <vector>
11
11
 
@@ -42,7 +42,7 @@ namespace RTC
42
42
 
43
43
  public:
44
44
  DataProducer(
45
- RTC::Shared* shared,
45
+ SharedInterface* shared,
46
46
  const std::string& id,
47
47
  size_t maxMessageSize,
48
48
  RTC::DataProducer::Listener* listener,
@@ -87,7 +87,7 @@ namespace RTC
87
87
 
88
88
  private:
89
89
  // Passed by argument.
90
- RTC::Shared* shared{ nullptr };
90
+ SharedInterface* shared{ nullptr };
91
91
  size_t maxMessageSize{ 0u };
92
92
  RTC::DataProducer::Listener* listener{ nullptr };
93
93
  // Others.
@@ -1,7 +1,7 @@
1
1
  #ifndef MS_RTC_DIRECT_TRANSPORT_HPP
2
2
  #define MS_RTC_DIRECT_TRANSPORT_HPP
3
3
 
4
- #include "RTC/Shared.hpp"
4
+ #include "SharedInterface.hpp"
5
5
  #include "RTC/Transport.hpp"
6
6
 
7
7
  namespace RTC
@@ -10,7 +10,7 @@ namespace RTC
10
10
  {
11
11
  public:
12
12
  DirectTransport(
13
- RTC::Shared* shared,
13
+ SharedInterface* shared,
14
14
  const std::string& id,
15
15
  RTC::Transport::Listener* listener,
16
16
  const FBS::DirectTransport::DirectTransportOptions* options);
@@ -2,9 +2,10 @@
2
2
  #define MS_RTC_DTLS_TRANSPORT_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "FBS/webRtcTransport.h"
6
7
  #include "RTC/SrtpSession.hpp"
7
- #include "handles/TimerHandle.hpp"
8
+ #include "handles/TimerHandleInterface.hpp"
8
9
  #include <openssl/bio.h>
9
10
  #include <openssl/ssl.h>
10
11
  #include <openssl/x509.h>
@@ -14,7 +15,7 @@
14
15
 
15
16
  namespace RTC
16
17
  {
17
- class DtlsTransport : public TimerHandle::Listener
18
+ class DtlsTransport : public TimerHandleInterface::Listener
18
19
  {
19
20
  public:
20
21
  enum class DtlsState : uint8_t
@@ -135,7 +136,7 @@ namespace RTC
135
136
  static const std::vector<SrtpCryptoSuiteMapEntry> SrtpCryptoSuites;
136
137
 
137
138
  public:
138
- explicit DtlsTransport(Listener* listener);
139
+ explicit DtlsTransport(Listener* listener, SharedInterface* shared);
139
140
  ~DtlsTransport() override;
140
141
 
141
142
  public:
@@ -195,18 +196,19 @@ namespace RTC
195
196
  public:
196
197
  void OnSslInfo(int where, int ret);
197
198
 
198
- /* Pure virtual methods inherited from TimerHandle::Listener. */
199
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
199
200
  public:
200
- void OnTimer(TimerHandle* timer) override;
201
+ void OnTimer(TimerHandleInterface* timer) override;
201
202
 
202
203
  private:
203
204
  // Passed by argument.
204
205
  Listener* listener{ nullptr };
206
+ SharedInterface* shared{ nullptr };
205
207
  // Allocated by this.
206
208
  SSL* ssl{ nullptr };
207
209
  BIO* sslBioFromNetwork{ nullptr }; // The BIO from which ssl reads.
208
210
  BIO* sslBioToNetwork{ nullptr }; // The BIO in which ssl writes.
209
- TimerHandle* timer{ nullptr };
211
+ TimerHandleInterface* timer{ nullptr };
210
212
  // Others.
211
213
  DtlsState state{ DtlsState::NEW };
212
214
  std::optional<Role> localRole;
@@ -2,10 +2,11 @@
2
2
  #define MS_RTC_ICE_ICE_SERVER_HPP
3
3
 
4
4
  #include "common.hpp"
5
+ #include "SharedInterface.hpp"
5
6
  #include "FBS/webRtcTransport.h"
6
7
  #include "RTC/ICE/StunPacket.hpp"
7
8
  #include "RTC/TransportTuple.hpp"
8
- #include "handles/TimerHandle.hpp"
9
+ #include "handles/TimerHandleInterface.hpp"
9
10
  #include <list>
10
11
  #include <string>
11
12
  #include <unordered_map>
@@ -14,7 +15,7 @@ namespace RTC
14
15
  {
15
16
  namespace ICE
16
17
  {
17
- class IceServer : public TimerHandle::Listener
18
+ class IceServer : public TimerHandleInterface::Listener
18
19
  {
19
20
  public:
20
21
  enum class IceState : uint8_t
@@ -65,6 +66,7 @@ namespace RTC
65
66
  public:
66
67
  IceServer(
67
68
  Listener* listener,
69
+ SharedInterface* shared,
68
70
  const std::string& usernameFragment,
69
71
  const std::string& password,
70
72
  uint8_t consentTimeoutSec);
@@ -129,13 +131,14 @@ namespace RTC
129
131
  void RestartConsentCheck();
130
132
  void StopConsentCheck();
131
133
 
132
- /* Pure virtual methods inherited from TimerHandle::Listener. */
134
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
133
135
  public:
134
- void OnTimer(TimerHandle* timer) override;
136
+ void OnTimer(TimerHandleInterface* timer) override;
135
137
 
136
138
  private:
137
139
  // Passed by argument.
138
140
  Listener* listener{ nullptr };
141
+ SharedInterface* shared{ nullptr };
139
142
  std::string usernameFragment;
140
143
  std::string password;
141
144
  uint16_t consentTimeoutMs{ 30000u };
@@ -146,7 +149,7 @@ namespace RTC
146
149
  uint32_t remoteNomination{ 0u };
147
150
  std::list<RTC::TransportTuple> tuples;
148
151
  RTC::TransportTuple* selectedTuple{ nullptr };
149
- TimerHandle* consentCheckTimer{ nullptr };
152
+ TimerHandleInterface* consentCheckTimer{ nullptr };
150
153
  bool isRemovingTuples{ false };
151
154
  };
152
155
  } // namespace ICE
@@ -1,12 +1,13 @@
1
1
  #ifndef MS_KEY_FRAME_REQUEST_MANAGER_HPP
2
2
  #define MS_KEY_FRAME_REQUEST_MANAGER_HPP
3
3
 
4
- #include "handles/TimerHandle.hpp"
4
+ #include "SharedInterface.hpp"
5
+ #include "handles/TimerHandleInterface.hpp"
5
6
  #include <absl/container/flat_hash_map.h>
6
7
 
7
8
  namespace RTC
8
9
  {
9
- class PendingKeyFrameInfo : public TimerHandle::Listener
10
+ class PendingKeyFrameInfo : public TimerHandleInterface::Listener
10
11
  {
11
12
  public:
12
13
  class Listener
@@ -19,7 +20,7 @@ namespace RTC
19
20
  };
20
21
 
21
22
  public:
22
- PendingKeyFrameInfo(Listener* listener, uint32_t ssrc);
23
+ PendingKeyFrameInfo(Listener* listener, SharedInterface* shared, uint32_t ssrc);
23
24
  ~PendingKeyFrameInfo() override;
24
25
 
25
26
  uint32_t GetSsrc() const
@@ -39,18 +40,18 @@ namespace RTC
39
40
  this->timer->Restart();
40
41
  }
41
42
 
42
- /* Pure virtual methods inherited from TimerHandle::Listener. */
43
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
43
44
  public:
44
- void OnTimer(TimerHandle* timer) override;
45
+ void OnTimer(TimerHandleInterface* timer) override;
45
46
 
46
47
  private:
47
48
  Listener* listener{ nullptr };
48
49
  uint32_t ssrc;
49
- TimerHandle* timer{ nullptr };
50
+ TimerHandleInterface* timer{ nullptr };
50
51
  bool retryOnTimeout{ true };
51
52
  };
52
53
 
53
- class KeyFrameRequestDelayer : public TimerHandle::Listener
54
+ class KeyFrameRequestDelayer : public TimerHandleInterface::Listener
54
55
  {
55
56
  public:
56
57
  class Listener
@@ -63,7 +64,7 @@ namespace RTC
63
64
  };
64
65
 
65
66
  public:
66
- KeyFrameRequestDelayer(Listener* listener, uint32_t ssrc, uint32_t delay);
67
+ KeyFrameRequestDelayer(Listener* listener, SharedInterface* shared, uint32_t ssrc, uint32_t delay);
67
68
  ~KeyFrameRequestDelayer() override;
68
69
 
69
70
  uint32_t GetSsrc() const
@@ -79,14 +80,14 @@ namespace RTC
79
80
  this->keyFrameRequested = flag;
80
81
  }
81
82
 
82
- /* Pure virtual methods inherited from TimerHandle::Listener. */
83
+ /* Pure virtual methods inherited from TimerHandleInterface::Listener. */
83
84
  public:
84
- void OnTimer(TimerHandle* timer) override;
85
+ void OnTimer(TimerHandleInterface* timer) override;
85
86
 
86
87
  private:
87
88
  Listener* listener{ nullptr };
88
89
  uint32_t ssrc;
89
- TimerHandle* timer{ nullptr };
90
+ TimerHandleInterface* timer{ nullptr };
90
91
  bool keyFrameRequested{ false };
91
92
  };
92
93
 
@@ -104,7 +105,8 @@ namespace RTC
104
105
  };
105
106
 
106
107
  public:
107
- explicit KeyFrameRequestManager(Listener* listener, uint32_t keyFrameRequestDelay);
108
+ explicit KeyFrameRequestManager(
109
+ Listener* listener, SharedInterface* shared, uint32_t keyFrameRequestDelay);
108
110
  ~KeyFrameRequestManager() override;
109
111
 
110
112
  void KeyFrameNeeded(uint32_t ssrc);
@@ -121,6 +123,7 @@ namespace RTC
121
123
 
122
124
  private:
123
125
  Listener* listener{ nullptr };
126
+ SharedInterface* shared{ nullptr };
124
127
  uint32_t keyFrameRequestDelay{ 0u }; // 0 means disabled.
125
128
  absl::flat_hash_map<uint32_t, PendingKeyFrameInfo*> mapSsrcPendingKeyFrameInfo;
126
129
  absl::flat_hash_map<uint32_t, KeyFrameRequestDelayer*> mapSsrcKeyFrameRequestDelayer;