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.
- package/node/lib/Worker.d.ts +1 -0
- package/node/lib/Worker.d.ts.map +1 -1
- package/node/lib/Worker.js +14 -0
- package/package.json +4 -2
- package/worker/fuzzer/src/RTC/FuzzerDtlsTransport.cpp +9 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +9 -1
- package/worker/include/Channel/ChannelMessageRegistrator.hpp +39 -0
- package/worker/include/Channel/ChannelMessageRegistratorInterface.hpp +32 -0
- package/worker/include/Channel/ChannelSocket.hpp +1 -1
- package/worker/include/DepUsrSCTP.hpp +8 -7
- package/worker/include/RTC/ActiveSpeakerObserver.hpp +7 -7
- package/worker/include/RTC/AudioLevelObserver.hpp +7 -7
- package/worker/include/RTC/Consumer.hpp +3 -3
- package/worker/include/RTC/DataConsumer.hpp +3 -3
- package/worker/include/RTC/DataProducer.hpp +3 -3
- package/worker/include/RTC/DirectTransport.hpp +2 -2
- package/worker/include/RTC/DtlsTransport.hpp +8 -6
- package/worker/include/RTC/ICE/IceServer.hpp +8 -5
- package/worker/include/RTC/KeyFrameRequestManager.hpp +15 -12
- package/worker/include/RTC/NackGenerator.hpp +7 -6
- package/worker/include/RTC/PipeConsumer.hpp +1 -2
- package/worker/include/RTC/PipeTransport.hpp +2 -2
- package/worker/include/RTC/PlainTransport.hpp +2 -2
- package/worker/include/RTC/Producer.hpp +3 -3
- package/worker/include/RTC/RTP/RtpStream.hpp +7 -1
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +6 -5
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -1
- package/worker/include/RTC/Router.hpp +3 -3
- package/worker/include/RTC/RtpObserver.hpp +3 -3
- package/worker/include/RTC/SCTP/TODO_SCTP.md +18 -6
- package/worker/include/RTC/SCTP/association/Association.hpp +11 -8
- package/worker/include/RTC/SCTP/association/HeartbeatHandler.hpp +9 -6
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +37 -23
- package/worker/include/RTC/SCTP/association/TCBContext.hpp +3 -2
- package/worker/include/RTC/SCTP/association/TransmissionControlBlock.hpp +81 -8
- package/worker/include/RTC/SCTP/packet/UserData.hpp +36 -0
- package/worker/include/RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +2 -1
- package/worker/include/RTC/SCTP/tx/OutstandingData.hpp +604 -0
- package/worker/include/RTC/SCTP/tx/RetransmissionQueue.hpp +336 -0
- package/worker/include/RTC/SCTP/tx/RetransmissionTimeout.hpp +5 -4
- package/worker/include/RTC/Serializable.hpp +8 -0
- package/worker/include/RTC/SimpleConsumer.hpp +1 -2
- package/worker/include/RTC/SimulcastConsumer.hpp +1 -2
- package/worker/include/RTC/SvcConsumer.hpp +1 -2
- package/worker/include/RTC/Transport.hpp +8 -8
- package/worker/include/RTC/TransportCongestionControlClient.hpp +8 -5
- package/worker/include/RTC/TransportCongestionControlServer.hpp +8 -5
- package/worker/include/RTC/WebRtcServer.hpp +3 -3
- package/worker/include/RTC/WebRtcTransport.hpp +3 -3
- package/worker/include/Shared.hpp +40 -0
- package/worker/include/SharedInterface.hpp +44 -0
- package/worker/include/Utils.hpp +6 -0
- package/worker/include/Worker.hpp +3 -3
- package/worker/include/common.hpp +1 -1
- package/worker/include/handles/BackoffTimerHandle.hpp +27 -65
- package/worker/include/handles/BackoffTimerHandleInterface.hpp +116 -0
- package/worker/include/handles/TimerHandle.hpp +36 -20
- package/worker/include/handles/TimerHandleInterface.hpp +43 -0
- package/worker/meson.build +21 -4
- package/worker/meson_options.txt +2 -1
- package/worker/mocks/include/Channel/MockChannelMessageRegistrator.hpp +45 -0
- package/worker/mocks/include/MockShared.hpp +43 -0
- package/worker/mocks/src/Channel/MockChannelMessageRegistrator.cpp +128 -0
- package/worker/mocks/src/MockShared.cpp +26 -0
- package/worker/scripts/clang-scripts.mjs +4 -1
- package/worker/src/Channel/ChannelMessageRegistrator.cpp +125 -0
- package/worker/src/Channel/ChannelSocket.cpp +1 -1
- package/worker/src/DepUsrSCTP.cpp +10 -4
- package/worker/src/RTC/ActiveSpeakerObserver.cpp +7 -7
- package/worker/src/RTC/AudioLevelObserver.cpp +12 -10
- package/worker/src/RTC/Consumer.cpp +23 -20
- package/worker/src/RTC/DataConsumer.cpp +11 -11
- package/worker/src/RTC/DataProducer.cpp +3 -3
- package/worker/src/RTC/DirectTransport.cpp +16 -16
- package/worker/src/RTC/DtlsTransport.cpp +4 -4
- package/worker/src/RTC/ICE/IceServer.cpp +4 -3
- package/worker/src/RTC/KeyFrameRequestManager.cpp +15 -15
- package/worker/src/RTC/NackGenerator.cpp +3 -3
- package/worker/src/RTC/PipeConsumer.cpp +5 -4
- package/worker/src/RTC/PipeTransport.cpp +3 -3
- package/worker/src/RTC/PlainTransport.cpp +10 -9
- package/worker/src/RTC/Producer.cpp +30 -28
- package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +1 -2
- package/worker/src/RTC/RTP/RtpStream.cpp +9 -2
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +5 -4
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +5 -2
- package/worker/src/RTC/Router.cpp +3 -3
- package/worker/src/RTC/RtpObserver.cpp +2 -1
- package/worker/src/RTC/SCTP/association/Association.cpp +94 -114
- package/worker/src/RTC/SCTP/association/HeartbeatHandler.cpp +27 -21
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +52 -55
- package/worker/src/RTC/SCTP/association/TransmissionControlBlock.cpp +144 -25
- package/worker/src/RTC/SCTP/packet/chunks/ForwardTsnChunk.cpp +2 -2
- package/worker/src/RTC/SCTP/packet/chunks/IForwardTsnChunk.cpp +2 -2
- package/worker/src/RTC/SCTP/tx/OutstandingData.cpp +905 -0
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +799 -0
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +1 -1
- package/worker/src/RTC/SctpAssociation.cpp +1 -1
- package/worker/src/RTC/SimpleConsumer.cpp +8 -7
- package/worker/src/RTC/SimulcastConsumer.cpp +11 -10
- package/worker/src/RTC/SvcConsumer.cpp +11 -10
- package/worker/src/RTC/Transport.cpp +36 -26
- package/worker/src/RTC/TransportCongestionControlClient.cpp +4 -2
- package/worker/src/RTC/TransportCongestionControlServer.cpp +4 -3
- package/worker/src/RTC/WebRtcServer.cpp +5 -4
- package/worker/src/RTC/WebRtcTransport.cpp +39 -26
- package/worker/src/Shared.cpp +35 -0
- package/worker/src/Worker.cpp +10 -23
- package/worker/src/handles/BackoffTimerHandle.cpp +11 -16
- package/worker/src/handles/TimerHandle.cpp +5 -4
- package/worker/src/lib.cpp +14 -1
- package/worker/tasks.py +1 -1
- package/worker/test/include/RTC/ICE/iceCommon.hpp +1 -0
- package/worker/test/include/RTC/RTP/rtpCommon.hpp +1 -0
- package/worker/test/include/RTC/SCTP/sctpCommon.hpp +6 -0
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +12 -5
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +34 -23
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1196 -0
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +33 -33
- package/worker/test/src/RTC/TestKeyFrameRequestManager.cpp +14 -6
- package/worker/test/src/RTC/TestNackGenerator.cpp +6 -2
- package/worker/test/src/RTC/TestSimpleConsumer.cpp +6 -10
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +9 -2
- package/worker/test/src/Utils/TestByte.cpp +98 -0
- package/worker/include/ChannelMessageRegistrator.hpp +0 -30
- package/worker/include/RTC/Shared.hpp +0 -23
- package/worker/src/ChannelMessageRegistrator.cpp +0 -119
- package/worker/src/RTC/Shared.cpp +0 -23
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#ifndef MS_MOCKS_MOCK_CHANNEL_MESSAGE_REGISTRATOR_HPP
|
|
2
|
+
#define MS_MOCKS_MOCK_CHANNEL_MESSAGE_REGISTRATOR_HPP
|
|
3
|
+
|
|
4
|
+
#include "Channel/ChannelMessageRegistratorInterface.hpp"
|
|
5
|
+
// TODO: We should have a ChannelSocketInterface class instead.
|
|
6
|
+
#include "Channel/ChannelSocket.hpp"
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <unordered_map>
|
|
9
|
+
|
|
10
|
+
namespace mocks
|
|
11
|
+
{
|
|
12
|
+
namespace Channel
|
|
13
|
+
{
|
|
14
|
+
class MockChannelMessageRegistrator : public ::Channel::ChannelMessageRegistratorInterface
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
explicit MockChannelMessageRegistrator();
|
|
18
|
+
|
|
19
|
+
~MockChannelMessageRegistrator() override;
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
flatbuffers::Offset<FBS::Worker::ChannelMessageHandlers> FillBuffer(
|
|
23
|
+
flatbuffers::FlatBufferBuilder& builder) override;
|
|
24
|
+
|
|
25
|
+
void RegisterHandler(
|
|
26
|
+
const std::string& id,
|
|
27
|
+
::Channel::ChannelSocket::RequestHandler* channelRequestHandler,
|
|
28
|
+
::Channel::ChannelSocket::NotificationHandler* channelNotificationHandler) override;
|
|
29
|
+
|
|
30
|
+
void UnregisterHandler(const std::string& id) override;
|
|
31
|
+
|
|
32
|
+
::Channel::ChannelSocket::RequestHandler* GetChannelRequestHandler(const std::string& id) override;
|
|
33
|
+
|
|
34
|
+
::Channel::ChannelSocket::NotificationHandler* GetChannelNotificationHandler(
|
|
35
|
+
const std::string& id) override;
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
std::unordered_map<std::string, ::Channel::ChannelSocket::RequestHandler*> mapChannelRequestHandlers;
|
|
39
|
+
std::unordered_map<std::string, ::Channel::ChannelSocket::NotificationHandler*>
|
|
40
|
+
mapChannelNotificationHandlers;
|
|
41
|
+
};
|
|
42
|
+
} // namespace Channel
|
|
43
|
+
} // namespace mocks
|
|
44
|
+
|
|
45
|
+
#endif
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#ifndef MS_MOCKS_MOCK_SHARED_HPP
|
|
2
|
+
#define MS_MOCKS_MOCK_SHARED_HPP
|
|
3
|
+
|
|
4
|
+
#include "SharedInterface.hpp"
|
|
5
|
+
#include "mocks/include/Channel/MockChannelMessageRegistrator.hpp"
|
|
6
|
+
#include "Channel/ChannelNotifier.hpp"
|
|
7
|
+
#include "Channel/ChannelSocket.hpp"
|
|
8
|
+
#include "handles/BackoffTimerHandleInterface.hpp"
|
|
9
|
+
#include "handles/TimerHandleInterface.hpp"
|
|
10
|
+
|
|
11
|
+
namespace mocks
|
|
12
|
+
{
|
|
13
|
+
class MockShared : public SharedInterface
|
|
14
|
+
{
|
|
15
|
+
public:
|
|
16
|
+
explicit MockShared();
|
|
17
|
+
|
|
18
|
+
~MockShared() override = default;
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
::Channel::ChannelMessageRegistratorInterface* GetChannelMessageRegistrator() const override
|
|
22
|
+
{
|
|
23
|
+
return this->channelMessageRegistrator.get();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
::Channel::ChannelNotifier* GetChannelNotifier() const override
|
|
27
|
+
{
|
|
28
|
+
return this->channelNotifier.get();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
TimerHandleInterface* CreateTimer(TimerHandleInterface::Listener* listener) const override;
|
|
32
|
+
|
|
33
|
+
BackoffTimerHandleInterface* CreateBackoffTimer(
|
|
34
|
+
const BackoffTimerHandleInterface::BackoffTimerHandleOptions& options) const override;
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
std::unique_ptr<::Channel::ChannelSocket> channelSocket;
|
|
38
|
+
std::unique_ptr<mocks::Channel::MockChannelMessageRegistrator> channelMessageRegistrator;
|
|
39
|
+
std::unique_ptr<::Channel::ChannelNotifier> channelNotifier;
|
|
40
|
+
};
|
|
41
|
+
} // namespace mocks
|
|
42
|
+
|
|
43
|
+
#endif
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#define MS_CLASS "ChannelMessageRegistrator"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "mocks/include/Channel/MockChannelMessageRegistrator.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
#include "MediaSoupErrors.hpp"
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace mocks
|
|
10
|
+
{
|
|
11
|
+
namespace Channel
|
|
12
|
+
{
|
|
13
|
+
MockChannelMessageRegistrator::MockChannelMessageRegistrator()
|
|
14
|
+
{
|
|
15
|
+
MS_TRACE();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
MockChannelMessageRegistrator::~MockChannelMessageRegistrator()
|
|
19
|
+
{
|
|
20
|
+
MS_TRACE();
|
|
21
|
+
|
|
22
|
+
this->mapChannelRequestHandlers.clear();
|
|
23
|
+
this->mapChannelNotificationHandlers.clear();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
flatbuffers::Offset<FBS::Worker::ChannelMessageHandlers> MockChannelMessageRegistrator::FillBuffer(
|
|
27
|
+
flatbuffers::FlatBufferBuilder& builder)
|
|
28
|
+
{
|
|
29
|
+
// Add channelRequestHandlerIds.
|
|
30
|
+
std::vector<flatbuffers::Offset<flatbuffers::String>> channelRequestHandlerIds;
|
|
31
|
+
|
|
32
|
+
for (const auto& kv : this->mapChannelRequestHandlers)
|
|
33
|
+
{
|
|
34
|
+
const auto& handlerId = kv.first;
|
|
35
|
+
|
|
36
|
+
channelRequestHandlerIds.push_back(builder.CreateString(handlerId));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Add channelNotificationHandlerIds.
|
|
40
|
+
std::vector<flatbuffers::Offset<flatbuffers::String>> channelNotificationHandlerIds;
|
|
41
|
+
|
|
42
|
+
for (const auto& kv : this->mapChannelNotificationHandlers)
|
|
43
|
+
{
|
|
44
|
+
const auto& handlerId = kv.first;
|
|
45
|
+
|
|
46
|
+
channelNotificationHandlerIds.push_back(builder.CreateString(handlerId));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return FBS::Worker::CreateChannelMessageHandlersDirect(
|
|
50
|
+
builder, &channelRequestHandlerIds, &channelNotificationHandlerIds);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void MockChannelMessageRegistrator::RegisterHandler(
|
|
54
|
+
const std::string& id,
|
|
55
|
+
::Channel::ChannelSocket::RequestHandler* channelRequestHandler,
|
|
56
|
+
::Channel::ChannelSocket::NotificationHandler* channelNotificationHandler)
|
|
57
|
+
{
|
|
58
|
+
MS_TRACE();
|
|
59
|
+
|
|
60
|
+
if (channelRequestHandler)
|
|
61
|
+
{
|
|
62
|
+
if (this->mapChannelRequestHandlers.contains(id))
|
|
63
|
+
{
|
|
64
|
+
MS_THROW_ERROR("Channel request handler with ID %s already exists", id.c_str());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this->mapChannelRequestHandlers[id] = channelRequestHandler;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (channelNotificationHandler)
|
|
71
|
+
{
|
|
72
|
+
if (this->mapChannelNotificationHandlers.contains(id))
|
|
73
|
+
{
|
|
74
|
+
if (channelRequestHandler)
|
|
75
|
+
{
|
|
76
|
+
this->mapChannelRequestHandlers.erase(id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
MS_THROW_ERROR("Channel notification handler with ID %s already exists", id.c_str());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this->mapChannelNotificationHandlers[id] = channelNotificationHandler;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void MockChannelMessageRegistrator::UnregisterHandler(const std::string& id)
|
|
87
|
+
{
|
|
88
|
+
MS_TRACE();
|
|
89
|
+
|
|
90
|
+
this->mapChannelRequestHandlers.erase(id);
|
|
91
|
+
this->mapChannelNotificationHandlers.erase(id);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
::Channel::ChannelSocket::RequestHandler* MockChannelMessageRegistrator::GetChannelRequestHandler(
|
|
95
|
+
const std::string& id)
|
|
96
|
+
{
|
|
97
|
+
MS_TRACE();
|
|
98
|
+
|
|
99
|
+
auto it = this->mapChannelRequestHandlers.find(id);
|
|
100
|
+
|
|
101
|
+
if (it != this->mapChannelRequestHandlers.end())
|
|
102
|
+
{
|
|
103
|
+
return it->second;
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
{
|
|
107
|
+
return nullptr;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
::Channel::ChannelSocket::NotificationHandler* MockChannelMessageRegistrator::GetChannelNotificationHandler(
|
|
112
|
+
const std::string& id)
|
|
113
|
+
{
|
|
114
|
+
MS_TRACE();
|
|
115
|
+
|
|
116
|
+
auto it = this->mapChannelNotificationHandlers.find(id);
|
|
117
|
+
|
|
118
|
+
if (it != this->mapChannelNotificationHandlers.end())
|
|
119
|
+
{
|
|
120
|
+
return it->second;
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
{
|
|
124
|
+
return nullptr;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} // namespace Channel
|
|
128
|
+
} // namespace mocks
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "mocks/include/MockShared.hpp"
|
|
2
|
+
// TODO: We need MockBackoffTimerHandle class.
|
|
3
|
+
#include "handles/BackoffTimerHandle.hpp"
|
|
4
|
+
// TODO: We need MockTimerHandle class.
|
|
5
|
+
#include "handles/TimerHandle.hpp"
|
|
6
|
+
|
|
7
|
+
namespace mocks
|
|
8
|
+
{
|
|
9
|
+
MockShared::MockShared()
|
|
10
|
+
: channelSocket(new ::Channel::ChannelSocket()),
|
|
11
|
+
channelMessageRegistrator(new mocks::Channel::MockChannelMessageRegistrator()),
|
|
12
|
+
channelNotifier(new ::Channel::ChannelNotifier(this->channelSocket.get()))
|
|
13
|
+
{
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
TimerHandleInterface* MockShared::CreateTimer(TimerHandleInterface::Listener* listener) const
|
|
17
|
+
{
|
|
18
|
+
return new TimerHandle(listener);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BackoffTimerHandleInterface* MockShared::CreateBackoffTimer(
|
|
22
|
+
const BackoffTimerHandleInterface::BackoffTimerHandleOptions& options) const
|
|
23
|
+
{
|
|
24
|
+
return new BackoffTimerHandle(options);
|
|
25
|
+
}
|
|
26
|
+
} // namespace mocks
|
|
@@ -19,12 +19,15 @@ const CLANG_FORMAT_PATHS = [
|
|
|
19
19
|
'../test/include/**/**.hpp',
|
|
20
20
|
'../fuzzer/src/**/*.cpp',
|
|
21
21
|
'../fuzzer/include/**/*.hpp',
|
|
22
|
+
'../mocks/src/**/*.cpp',
|
|
23
|
+
'../mocks/include/**/*.hpp',
|
|
22
24
|
];
|
|
23
25
|
|
|
24
26
|
const CLANG_TIDY_PATHS = [
|
|
25
27
|
'../src/**/*.cpp',
|
|
26
28
|
'../test/src/**/*.cpp',
|
|
27
29
|
'../fuzzer/src/**/*.cpp',
|
|
30
|
+
'../mocks/src/**/*.cpp',
|
|
28
31
|
];
|
|
29
32
|
|
|
30
33
|
const task = process.argv.slice(2).join(' ');
|
|
@@ -287,7 +290,7 @@ function getRootDir() {
|
|
|
287
290
|
}
|
|
288
291
|
|
|
289
292
|
function getBuildDir() {
|
|
290
|
-
const workerDir = path.join(ROOT_DIR, 'worker
|
|
293
|
+
const workerDir = path.join(ROOT_DIR, 'worker');
|
|
291
294
|
const workerOutDir = process.env.MEDIASOUP_OUT_DIR ?? `${workerDir}/out`;
|
|
292
295
|
const mediasoupBuildtype = process.env.MEDIASOUP_BUILDTYPE ?? 'Release';
|
|
293
296
|
const workerInstallDir =
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#define MS_CLASS "ChannelMessageRegistrator"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "Channel/ChannelMessageRegistrator.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
#include "MediaSoupErrors.hpp"
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace Channel
|
|
10
|
+
{
|
|
11
|
+
ChannelMessageRegistrator::ChannelMessageRegistrator()
|
|
12
|
+
{
|
|
13
|
+
MS_TRACE();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
ChannelMessageRegistrator::~ChannelMessageRegistrator()
|
|
17
|
+
{
|
|
18
|
+
MS_TRACE();
|
|
19
|
+
|
|
20
|
+
this->mapChannelRequestHandlers.clear();
|
|
21
|
+
this->mapChannelNotificationHandlers.clear();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
flatbuffers::Offset<FBS::Worker::ChannelMessageHandlers> ChannelMessageRegistrator::FillBuffer(
|
|
25
|
+
flatbuffers::FlatBufferBuilder& builder)
|
|
26
|
+
{
|
|
27
|
+
// Add channelRequestHandlerIds.
|
|
28
|
+
std::vector<flatbuffers::Offset<flatbuffers::String>> channelRequestHandlerIds;
|
|
29
|
+
|
|
30
|
+
for (const auto& kv : this->mapChannelRequestHandlers)
|
|
31
|
+
{
|
|
32
|
+
const auto& handlerId = kv.first;
|
|
33
|
+
|
|
34
|
+
channelRequestHandlerIds.push_back(builder.CreateString(handlerId));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Add channelNotificationHandlerIds.
|
|
38
|
+
std::vector<flatbuffers::Offset<flatbuffers::String>> channelNotificationHandlerIds;
|
|
39
|
+
|
|
40
|
+
for (const auto& kv : this->mapChannelNotificationHandlers)
|
|
41
|
+
{
|
|
42
|
+
const auto& handlerId = kv.first;
|
|
43
|
+
|
|
44
|
+
channelNotificationHandlerIds.push_back(builder.CreateString(handlerId));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return FBS::Worker::CreateChannelMessageHandlersDirect(
|
|
48
|
+
builder, &channelRequestHandlerIds, &channelNotificationHandlerIds);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void ChannelMessageRegistrator::RegisterHandler(
|
|
52
|
+
const std::string& id,
|
|
53
|
+
ChannelSocket::RequestHandler* channelRequestHandler,
|
|
54
|
+
ChannelSocket::NotificationHandler* channelNotificationHandler)
|
|
55
|
+
{
|
|
56
|
+
MS_TRACE();
|
|
57
|
+
|
|
58
|
+
if (channelRequestHandler)
|
|
59
|
+
{
|
|
60
|
+
if (this->mapChannelRequestHandlers.contains(id))
|
|
61
|
+
{
|
|
62
|
+
MS_THROW_ERROR("Channel request handler with ID %s already exists", id.c_str());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this->mapChannelRequestHandlers[id] = channelRequestHandler;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (channelNotificationHandler)
|
|
69
|
+
{
|
|
70
|
+
if (this->mapChannelNotificationHandlers.contains(id))
|
|
71
|
+
{
|
|
72
|
+
if (channelRequestHandler)
|
|
73
|
+
{
|
|
74
|
+
this->mapChannelRequestHandlers.erase(id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
MS_THROW_ERROR("Channel notification handler with ID %s already exists", id.c_str());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this->mapChannelNotificationHandlers[id] = channelNotificationHandler;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void ChannelMessageRegistrator::UnregisterHandler(const std::string& id)
|
|
85
|
+
{
|
|
86
|
+
MS_TRACE();
|
|
87
|
+
|
|
88
|
+
this->mapChannelRequestHandlers.erase(id);
|
|
89
|
+
this->mapChannelNotificationHandlers.erase(id);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ChannelSocket::RequestHandler* ChannelMessageRegistrator::GetChannelRequestHandler(
|
|
93
|
+
const std::string& id)
|
|
94
|
+
{
|
|
95
|
+
MS_TRACE();
|
|
96
|
+
|
|
97
|
+
auto it = this->mapChannelRequestHandlers.find(id);
|
|
98
|
+
|
|
99
|
+
if (it != this->mapChannelRequestHandlers.end())
|
|
100
|
+
{
|
|
101
|
+
return it->second;
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
{
|
|
105
|
+
return nullptr;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ChannelSocket::NotificationHandler* ChannelMessageRegistrator::GetChannelNotificationHandler(
|
|
110
|
+
const std::string& id)
|
|
111
|
+
{
|
|
112
|
+
MS_TRACE();
|
|
113
|
+
|
|
114
|
+
auto it = this->mapChannelNotificationHandlers.find(id);
|
|
115
|
+
|
|
116
|
+
if (it != this->mapChannelNotificationHandlers.end())
|
|
117
|
+
{
|
|
118
|
+
return it->second;
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
{
|
|
122
|
+
return nullptr;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} // namespace Channel
|
|
@@ -75,6 +75,12 @@ void DepUsrSCTP::ClassInit()
|
|
|
75
75
|
{
|
|
76
76
|
usrsctp_init_nothreads(0, onSendSctpData, sctpDebug);
|
|
77
77
|
|
|
78
|
+
// See https://github.com/sctplab/usrsctp/blob/master/Manual.md#usrsctp_sysctl_set_sctp_sendspace.
|
|
79
|
+
//
|
|
80
|
+
// TODO: This doesn't have any effect. So let's comment it.
|
|
81
|
+
// usrsctp_sysctl_set_sctp_sendspace(std::numeric_limits<uint32_t>::max());
|
|
82
|
+
// usrsctp_sysctl_set_sctp_recvspace(std::numeric_limits<uint32_t>::max());
|
|
83
|
+
|
|
78
84
|
// Disable explicit congestion notifications (ecn).
|
|
79
85
|
usrsctp_sysctl_set_sctp_ecn_enable(0);
|
|
80
86
|
|
|
@@ -105,13 +111,13 @@ void DepUsrSCTP::ClassDestroy()
|
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
void DepUsrSCTP::CreateChecker()
|
|
114
|
+
void DepUsrSCTP::CreateChecker(SharedInterface* shared)
|
|
109
115
|
{
|
|
110
116
|
MS_TRACE();
|
|
111
117
|
|
|
112
118
|
MS_ASSERT(DepUsrSCTP::checker == nullptr, "Checker already created");
|
|
113
119
|
|
|
114
|
-
DepUsrSCTP::checker = new DepUsrSCTP::Checker();
|
|
120
|
+
DepUsrSCTP::checker = new DepUsrSCTP::Checker(shared);
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
void DepUsrSCTP::CloseChecker()
|
|
@@ -210,7 +216,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id)
|
|
|
210
216
|
|
|
211
217
|
/* DepUsrSCTP::Checker instance methods. */
|
|
212
218
|
|
|
213
|
-
DepUsrSCTP::Checker::Checker() : timer(
|
|
219
|
+
DepUsrSCTP::Checker::Checker(SharedInterface* shared) : timer(shared->CreateTimer(this))
|
|
214
220
|
{
|
|
215
221
|
MS_TRACE();
|
|
216
222
|
}
|
|
@@ -244,7 +250,7 @@ void DepUsrSCTP::Checker::Stop()
|
|
|
244
250
|
this->timer->Stop();
|
|
245
251
|
}
|
|
246
252
|
|
|
247
|
-
void DepUsrSCTP::Checker::OnTimer(
|
|
253
|
+
void DepUsrSCTP::Checker::OnTimer(TimerHandleInterface* /*timer*/)
|
|
248
254
|
{
|
|
249
255
|
MS_TRACE();
|
|
250
256
|
|
|
@@ -88,7 +88,7 @@ namespace RTC
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
ActiveSpeakerObserver::ActiveSpeakerObserver(
|
|
91
|
-
|
|
91
|
+
SharedInterface* shared,
|
|
92
92
|
const std::string& id,
|
|
93
93
|
RTC::RtpObserver::Listener* listener,
|
|
94
94
|
const FBS::ActiveSpeakerObserver::ActiveSpeakerObserverOptions* options)
|
|
@@ -105,12 +105,12 @@ namespace RTC
|
|
|
105
105
|
this->interval = 5000;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
this->periodicTimer =
|
|
108
|
+
this->periodicTimer = this->shared->CreateTimer(this);
|
|
109
109
|
|
|
110
110
|
this->periodicTimer->Start(interval, interval);
|
|
111
111
|
|
|
112
112
|
// NOTE: This may throw.
|
|
113
|
-
this->shared->
|
|
113
|
+
this->shared->GetChannelMessageRegistrator()->RegisterHandler(
|
|
114
114
|
this->id,
|
|
115
115
|
/*channelRequestHandler*/ this,
|
|
116
116
|
/*channelNotificationHandler*/ nullptr);
|
|
@@ -120,7 +120,7 @@ namespace RTC
|
|
|
120
120
|
{
|
|
121
121
|
MS_TRACE();
|
|
122
122
|
|
|
123
|
-
this->shared->
|
|
123
|
+
this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
|
|
124
124
|
|
|
125
125
|
delete this->periodicTimer;
|
|
126
126
|
|
|
@@ -249,7 +249,7 @@ namespace RTC
|
|
|
249
249
|
this->periodicTimer->Restart();
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
void ActiveSpeakerObserver::OnTimer(
|
|
252
|
+
void ActiveSpeakerObserver::OnTimer(TimerHandleInterface* /*timer*/)
|
|
253
253
|
{
|
|
254
254
|
MS_TRACE();
|
|
255
255
|
|
|
@@ -275,9 +275,9 @@ namespace RTC
|
|
|
275
275
|
if (!this->mapProducerSpeakers.empty() && CalculateActiveSpeaker())
|
|
276
276
|
{
|
|
277
277
|
auto notification = FBS::ActiveSpeakerObserver::CreateDominantSpeakerNotificationDirect(
|
|
278
|
-
this->shared->
|
|
278
|
+
this->shared->GetChannelNotifier()->GetBufferBuilder(), this->dominantId.c_str());
|
|
279
279
|
|
|
280
|
-
this->shared->
|
|
280
|
+
this->shared->GetChannelNotifier()->Emit(
|
|
281
281
|
this->id,
|
|
282
282
|
FBS::Notification::Event::ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER,
|
|
283
283
|
FBS::Notification::Body::ActiveSpeakerObserver_DominantSpeakerNotification,
|
|
@@ -13,7 +13,7 @@ namespace RTC
|
|
|
13
13
|
/* Instance methods. */
|
|
14
14
|
|
|
15
15
|
AudioLevelObserver::AudioLevelObserver(
|
|
16
|
-
|
|
16
|
+
SharedInterface* shared,
|
|
17
17
|
const std::string& id,
|
|
18
18
|
RTC::RtpObserver::Listener* listener,
|
|
19
19
|
const FBS::AudioLevelObserver::AudioLevelObserverOptions* options)
|
|
@@ -39,12 +39,12 @@ namespace RTC
|
|
|
39
39
|
this->interval = 5000;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
this->periodicTimer =
|
|
42
|
+
this->periodicTimer = this->shared->CreateTimer(this);
|
|
43
43
|
|
|
44
44
|
this->periodicTimer->Start(this->interval, this->interval);
|
|
45
45
|
|
|
46
46
|
// NOTE: This may throw.
|
|
47
|
-
this->shared->
|
|
47
|
+
this->shared->GetChannelMessageRegistrator()->RegisterHandler(
|
|
48
48
|
this->id,
|
|
49
49
|
/*channelRequestHandler*/ this,
|
|
50
50
|
/*channelNotificationHandler*/ nullptr);
|
|
@@ -54,7 +54,7 @@ namespace RTC
|
|
|
54
54
|
{
|
|
55
55
|
MS_TRACE();
|
|
56
56
|
|
|
57
|
-
this->shared->
|
|
57
|
+
this->shared->GetChannelMessageRegistrator()->UnregisterHandler(this->id);
|
|
58
58
|
|
|
59
59
|
delete this->periodicTimer;
|
|
60
60
|
}
|
|
@@ -127,7 +127,7 @@ namespace RTC
|
|
|
127
127
|
{
|
|
128
128
|
this->silence = true;
|
|
129
129
|
|
|
130
|
-
this->shared->
|
|
130
|
+
this->shared->GetChannelNotifier()->Emit(
|
|
131
131
|
this->id, FBS::Notification::Event::AUDIOLEVELOBSERVER_SILENCE);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -179,13 +179,15 @@ namespace RTC
|
|
|
179
179
|
{
|
|
180
180
|
volumes.emplace_back(
|
|
181
181
|
FBS::AudioLevelObserver::CreateVolumeDirect(
|
|
182
|
-
this->shared->
|
|
182
|
+
this->shared->GetChannelNotifier()->GetBufferBuilder(),
|
|
183
|
+
rit->second->id.c_str(),
|
|
184
|
+
rit->first));
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
auto notification = FBS::AudioLevelObserver::CreateVolumesNotificationDirect(
|
|
186
|
-
this->shared->
|
|
188
|
+
this->shared->GetChannelNotifier()->GetBufferBuilder(), &volumes);
|
|
187
189
|
|
|
188
|
-
this->shared->
|
|
190
|
+
this->shared->GetChannelNotifier()->Emit(
|
|
189
191
|
this->id,
|
|
190
192
|
FBS::Notification::Event::AUDIOLEVELOBSERVER_VOLUMES,
|
|
191
193
|
FBS::Notification::Body::AudioLevelObserver_VolumesNotification,
|
|
@@ -195,7 +197,7 @@ namespace RTC
|
|
|
195
197
|
{
|
|
196
198
|
this->silence = true;
|
|
197
199
|
|
|
198
|
-
this->shared->
|
|
200
|
+
this->shared->GetChannelNotifier()->Emit(
|
|
199
201
|
this->id, FBS::Notification::Event::AUDIOLEVELOBSERVER_SILENCE);
|
|
200
202
|
}
|
|
201
203
|
}
|
|
@@ -213,7 +215,7 @@ namespace RTC
|
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
|
|
216
|
-
inline void AudioLevelObserver::OnTimer(
|
|
218
|
+
inline void AudioLevelObserver::OnTimer(TimerHandleInterface* /*timer*/)
|
|
217
219
|
{
|
|
218
220
|
MS_TRACE();
|
|
219
221
|
|