mediasoup 3.20.6 → 3.20.7
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 -1
- package/node/lib/Worker.d.ts.map +1 -1
- package/node/lib/Worker.js +1 -11
- package/node/lib/WorkerTypes.d.ts +0 -9
- package/node/lib/WorkerTypes.d.ts.map +1 -1
- package/node/lib/fbs/plain-transport/connect-response.d.ts.map +1 -1
- package/node/lib/fbs/plain-transport/connect-response.js +0 -1
- package/node/lib/fbs/worker/dump-response.d.ts +1 -5
- package/node/lib/fbs/worker/dump-response.d.ts.map +1 -1
- package/node/lib/fbs/worker/dump-response.js +3 -16
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.d.ts.map +1 -1
- package/node/lib/index.js +1 -2
- package/node/lib/test/test-PlainTransport.js +30 -0
- package/node/lib/test/test-Worker.js +0 -1
- package/npm-scripts.mjs +13 -8
- package/package.json +6 -6
- package/worker/fbs/meson.build +0 -1
- package/worker/fbs/plainTransport.fbs +1 -1
- package/worker/fbs/worker.fbs +0 -2
- package/worker/include/RTC/ICE/StunPacket.hpp +8 -9
- package/worker/include/RTC/RTP/Packet.hpp +1 -1
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/Chunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/ErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/Packet.hpp +1 -2
- package/worker/include/RTC/SCTP/packet/Parameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/TLV.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/DataChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/ForwardTsnChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/IDataChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/IForwardTsnChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/InitAckChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/InitChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/SackChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/chunks/ShutdownChunk.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/InvalidStreamIdentifierErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/MissingMandatoryParameterErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/NoUserDataErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/errorCauses/StaleCookieErrorCause.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/AddIncomingStreamsRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/AddOutgoingStreamsRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/CookiePreservativeParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/IPv4AddressParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/IPv6AddressParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/ReconfigurationResponseParameter.hpp +2 -2
- package/worker/include/RTC/SCTP/packet/parameters/SsnTsnResetRequestParameter.hpp +1 -1
- package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +1 -1
- package/worker/include/Settings.hpp +0 -1
- package/worker/include/handles/TcpConnectionHandle.hpp +0 -4
- package/worker/include/handles/UdpSocketHandle.hpp +0 -4
- package/worker/meson.build +0 -34
- package/worker/meson_options.txt +0 -1
- package/worker/src/RTC/PipeTransport.cpp +5 -5
- package/worker/src/RTC/PlainTransport.cpp +5 -5
- package/worker/src/RTC/RTP/Packet.cpp +0 -2
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +0 -20
- package/worker/src/RTC/Router.cpp +0 -37
- package/worker/src/RTC/SCTP/association/Association.cpp +12 -7
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +2 -2
- package/worker/src/RTC/SrtpSession.cpp +0 -24
- package/worker/src/RTC/Transport.cpp +3 -22
- package/worker/src/RTC/WebRtcTransport.cpp +5 -5
- package/worker/src/Settings.cpp +0 -14
- package/worker/src/Utils/Crypto.cpp +3 -3
- package/worker/src/Utils/String.cpp +1 -1
- package/worker/src/Worker.cpp +5 -38
- package/worker/src/handles/TcpConnectionHandle.cpp +1 -42
- package/worker/src/handles/UdpSocketHandle.cpp +1 -42
- package/worker/src/lib.cpp +1 -10
- package/worker/fbs/liburing.fbs +0 -7
- package/worker/include/DepLibUring.hpp +0 -143
- package/worker/src/DepLibUring.cpp +0 -638
- package/worker/subprojects/liburing.wrap +0 -14
|
@@ -785,7 +785,7 @@ namespace RTC
|
|
|
785
785
|
const uint8_t* data = packet->GetBuffer();
|
|
786
786
|
auto len = packet->GetLength();
|
|
787
787
|
|
|
788
|
-
if (!this->srtpSendSession->EncryptRtp(&data,
|
|
788
|
+
if (!this->srtpSendSession->EncryptRtp(&data, std::addressof(len)))
|
|
789
789
|
{
|
|
790
790
|
if (cb)
|
|
791
791
|
{
|
|
@@ -822,7 +822,7 @@ namespace RTC
|
|
|
822
822
|
return;
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
-
if (!this->srtpSendSession->EncryptRtcp(&data,
|
|
825
|
+
if (!this->srtpSendSession->EncryptRtcp(&data, std::addressof(len)))
|
|
826
826
|
{
|
|
827
827
|
return;
|
|
828
828
|
}
|
|
@@ -855,7 +855,7 @@ namespace RTC
|
|
|
855
855
|
return;
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
-
if (!this->srtpSendSession->EncryptRtcp(&data,
|
|
858
|
+
if (!this->srtpSendSession->EncryptRtcp(&data, std::addressof(len)))
|
|
859
859
|
{
|
|
860
860
|
return;
|
|
861
861
|
}
|
|
@@ -1025,7 +1025,7 @@ namespace RTC
|
|
|
1025
1025
|
}
|
|
1026
1026
|
|
|
1027
1027
|
// Decrypt the SRTP packet.
|
|
1028
|
-
if (!this->srtpRecvSession->DecryptSrtp(const_cast<uint8_t*>(data),
|
|
1028
|
+
if (!this->srtpRecvSession->DecryptSrtp(const_cast<uint8_t*>(data), std::addressof(len)))
|
|
1029
1029
|
{
|
|
1030
1030
|
const auto* packet = RTC::RTP::Packet::Parse(data, len, bufferLen);
|
|
1031
1031
|
|
|
@@ -1094,7 +1094,7 @@ namespace RTC
|
|
|
1094
1094
|
}
|
|
1095
1095
|
|
|
1096
1096
|
// Decrypt the SRTCP packet.
|
|
1097
|
-
if (!this->srtpRecvSession->DecryptSrtcp(const_cast<uint8_t*>(data),
|
|
1097
|
+
if (!this->srtpRecvSession->DecryptSrtcp(const_cast<uint8_t*>(data), std::addressof(len)))
|
|
1098
1098
|
{
|
|
1099
1099
|
return;
|
|
1100
1100
|
}
|
package/worker/src/Settings.cpp
CHANGED
|
@@ -59,7 +59,6 @@ void Settings::SetConfiguration(int argc, char* argv[])
|
|
|
59
59
|
{ .name="dtlsCertificateFile", .has_arg=optional_argument, .flag=nullptr, .val='c' },
|
|
60
60
|
{ .name="dtlsPrivateKeyFile", .has_arg=optional_argument, .flag=nullptr, .val='p' },
|
|
61
61
|
{ .name="libwebrtcFieldTrials", .has_arg=optional_argument, .flag=nullptr, .val='W' },
|
|
62
|
-
{ .name="disableLiburing", .has_arg=optional_argument, .flag=nullptr, .val='d' },
|
|
63
62
|
{ .name=nullptr, .has_arg=0, .flag=nullptr, .val=0 }
|
|
64
63
|
};
|
|
65
64
|
// clang-format on
|
|
@@ -159,18 +158,6 @@ void Settings::SetConfiguration(int argc, char* argv[])
|
|
|
159
158
|
break;
|
|
160
159
|
}
|
|
161
160
|
|
|
162
|
-
case 'd':
|
|
163
|
-
{
|
|
164
|
-
stringValue = std::string(optarg);
|
|
165
|
-
|
|
166
|
-
if (stringValue == "true")
|
|
167
|
-
{
|
|
168
|
-
Settings::configuration.disableLiburing = true;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
161
|
// Invalid option.
|
|
175
162
|
case '?':
|
|
176
163
|
{
|
|
@@ -382,7 +369,6 @@ void Settings::PrintConfiguration()
|
|
|
382
369
|
MS_DEBUG_TAG(
|
|
383
370
|
info, " libwebrtcFieldTrials: %s", Settings::configuration.libwebrtcFieldTrials.c_str());
|
|
384
371
|
}
|
|
385
|
-
MS_DEBUG_TAG(info, " disableLiburing: %s", Settings::configuration.disableLiburing ? "yes" : "no");
|
|
386
372
|
|
|
387
373
|
MS_DEBUG_TAG(info, "</configuration>");
|
|
388
374
|
}
|
|
@@ -125,9 +125,9 @@ namespace Utils
|
|
|
125
125
|
MS_TRACE();
|
|
126
126
|
|
|
127
127
|
char buffer[64];
|
|
128
|
-
static
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
static constexpr char Chars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
|
|
129
|
+
'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
|
130
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
|
|
131
131
|
|
|
132
132
|
len = std::min<size_t>(len, 64);
|
|
133
133
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
static constexpr size_t BufferOutSize{ 65536 };
|
|
22
22
|
static thread_local uint8_t BufferOut[BufferOutSize];
|
|
23
|
-
static
|
|
23
|
+
static constexpr uint8_t Base64Table[65] =
|
|
24
24
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
25
25
|
|
|
26
26
|
namespace Utils
|
package/worker/src/Worker.cpp
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// #define MS_LOG_DEV_LEVEL 3
|
|
3
3
|
|
|
4
4
|
#include "Worker.hpp"
|
|
5
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
6
|
-
#include "DepLibUring.hpp"
|
|
7
|
-
#endif
|
|
8
5
|
#include "FBS/response.h"
|
|
9
6
|
#include "FBS/worker.h"
|
|
10
7
|
#include "DepLibUV.hpp"
|
|
@@ -33,14 +30,6 @@ Worker::Worker(::Channel::ChannelSocket* channel, SharedInterface* shared)
|
|
|
33
30
|
}
|
|
34
31
|
#endif
|
|
35
32
|
|
|
36
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
37
|
-
if (DepLibUring::IsEnabled())
|
|
38
|
-
{
|
|
39
|
-
// Start polling CQEs, which will create a uv_pool_t handle.
|
|
40
|
-
DepLibUring::StartPollingCQEs();
|
|
41
|
-
}
|
|
42
|
-
#endif
|
|
43
|
-
|
|
44
33
|
// Tell the Node process that we are running.
|
|
45
34
|
this->shared->GetChannelNotifier()->Emit(
|
|
46
35
|
std::to_string(Logger::Pid), FBS::Notification::Event::WORKER_RUNNING);
|
|
@@ -92,14 +81,6 @@ void Worker::Close()
|
|
|
92
81
|
}
|
|
93
82
|
this->mapWebRtcServers.clear();
|
|
94
83
|
|
|
95
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
96
|
-
if (DepLibUring::IsEnabled())
|
|
97
|
-
{
|
|
98
|
-
// Stop polling CQEs, which will close the uv_pool_t handle.
|
|
99
|
-
DepLibUring::StopPollingCQEs();
|
|
100
|
-
}
|
|
101
|
-
#endif
|
|
102
|
-
|
|
103
84
|
// Close the Channel.
|
|
104
85
|
this->channel->Close();
|
|
105
86
|
}
|
|
@@ -132,26 +113,12 @@ flatbuffers::Offset<FBS::Worker::DumpResponse> Worker::FillBuffer(
|
|
|
132
113
|
// Add channelMessageHandlers.
|
|
133
114
|
auto channelMessageHandlers = this->shared->GetChannelMessageRegistrator()->FillBuffer(builder);
|
|
134
115
|
|
|
135
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
136
|
-
if (DepLibUring::IsEnabled())
|
|
137
|
-
{
|
|
138
|
-
return FBS::Worker::CreateDumpResponseDirect(
|
|
139
|
-
builder,
|
|
140
|
-
Logger::Pid,
|
|
141
|
-
&webRtcServerIds,
|
|
142
|
-
&routerIds,
|
|
143
|
-
channelMessageHandlers,
|
|
144
|
-
DepLibUring::FillBuffer(builder));
|
|
145
|
-
}
|
|
146
|
-
else
|
|
147
|
-
{
|
|
148
|
-
return FBS::Worker::CreateDumpResponseDirect(
|
|
149
|
-
builder, Logger::Pid, &webRtcServerIds, &routerIds, channelMessageHandlers);
|
|
150
|
-
}
|
|
151
|
-
#else
|
|
152
116
|
return FBS::Worker::CreateDumpResponseDirect(
|
|
153
|
-
builder,
|
|
154
|
-
|
|
117
|
+
builder,
|
|
118
|
+
Logger::Pid,
|
|
119
|
+
std::addressof(webRtcServerIds),
|
|
120
|
+
std::addressof(routerIds),
|
|
121
|
+
channelMessageHandlers);
|
|
155
122
|
}
|
|
156
123
|
|
|
157
124
|
flatbuffers::Offset<FBS::Worker::ResourceUsageResponse> Worker::FillBufferResourceUsage(
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
#include "handles/TcpConnectionHandle.hpp"
|
|
5
5
|
#include "DepLibUV.hpp"
|
|
6
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
7
|
-
#include "DepLibUring.hpp"
|
|
8
|
-
#endif
|
|
9
6
|
#include "Logger.hpp"
|
|
10
7
|
#include "MediaSoupErrors.hpp"
|
|
11
8
|
#include "Utils.hpp"
|
|
@@ -151,7 +148,7 @@ void TcpConnectionHandle::Start()
|
|
|
151
148
|
}
|
|
152
149
|
|
|
153
150
|
// NOLINTNEXTLINE(misc-const-correctness)
|
|
154
|
-
int err = uv_read_start(
|
|
151
|
+
const int err = uv_read_start(
|
|
155
152
|
reinterpret_cast<uv_stream_t*>(this->uvHandle),
|
|
156
153
|
static_cast<uv_alloc_cb>(onAlloc),
|
|
157
154
|
static_cast<uv_read_cb>(onRead));
|
|
@@ -166,18 +163,6 @@ void TcpConnectionHandle::Start()
|
|
|
166
163
|
{
|
|
167
164
|
MS_THROW_ERROR("error setting peer IP and port");
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
171
|
-
if (DepLibUring::IsEnabled())
|
|
172
|
-
{
|
|
173
|
-
err = uv_fileno(reinterpret_cast<uv_handle_t*>(this->uvHandle), std::addressof(this->fd));
|
|
174
|
-
|
|
175
|
-
if (err != 0)
|
|
176
|
-
{
|
|
177
|
-
MS_THROW_ERROR("uv_fileno() failed: %s", uv_strerror(err));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
#endif
|
|
181
166
|
}
|
|
182
167
|
|
|
183
168
|
void TcpConnectionHandle::Write(
|
|
@@ -211,32 +196,6 @@ void TcpConnectionHandle::Write(
|
|
|
211
196
|
return;
|
|
212
197
|
}
|
|
213
198
|
|
|
214
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
215
|
-
if (DepLibUring::IsEnabled())
|
|
216
|
-
{
|
|
217
|
-
if (!DepLibUring::IsActive())
|
|
218
|
-
{
|
|
219
|
-
goto write_libuv;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Prepare the data to be sent.
|
|
223
|
-
// NOTE: If all SQEs are currently in use or no UserData entry is available we'll
|
|
224
|
-
// fall back to libuv.
|
|
225
|
-
auto prepared = DepLibUring::PrepareWrite(this->fd, data1, len1, data2, len2, cb);
|
|
226
|
-
|
|
227
|
-
if (!prepared)
|
|
228
|
-
{
|
|
229
|
-
MS_DEBUG_DEV("cannot write via liburing, fallback to libuv");
|
|
230
|
-
|
|
231
|
-
goto write_libuv;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
write_libuv:
|
|
238
|
-
#endif
|
|
239
|
-
|
|
240
199
|
// First try uv_try_write(). In case it can not directly write all the given
|
|
241
200
|
// data then build a uv_req_t and use uv_write().
|
|
242
201
|
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// #define MS_LOG_DEV_LEVEL 3
|
|
3
3
|
|
|
4
4
|
#include "handles/UdpSocketHandle.hpp"
|
|
5
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
6
|
-
#include "DepLibUring.hpp"
|
|
7
|
-
#endif
|
|
8
5
|
#include "Logger.hpp"
|
|
9
6
|
#include "MediaSoupErrors.hpp"
|
|
10
7
|
#include "Utils.hpp"
|
|
@@ -73,7 +70,7 @@ UdpSocketHandle::UdpSocketHandle(uv_udp_t* uvHandle) : uvHandle(uvHandle)
|
|
|
73
70
|
this->uvHandle->data = static_cast<void*>(this);
|
|
74
71
|
|
|
75
72
|
// NOLINTNEXTLINE(misc-const-correctness)
|
|
76
|
-
int err = uv_udp_recv_start(
|
|
73
|
+
const int err = uv_udp_recv_start(
|
|
77
74
|
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
|
|
78
75
|
|
|
79
76
|
if (err != 0)
|
|
@@ -90,18 +87,6 @@ UdpSocketHandle::UdpSocketHandle(uv_udp_t* uvHandle) : uvHandle(uvHandle)
|
|
|
90
87
|
|
|
91
88
|
MS_THROW_ERROR("error setting local IP and port");
|
|
92
89
|
}
|
|
93
|
-
|
|
94
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
95
|
-
if (DepLibUring::IsEnabled())
|
|
96
|
-
{
|
|
97
|
-
err = uv_fileno(reinterpret_cast<uv_handle_t*>(this->uvHandle), std::addressof(this->fd));
|
|
98
|
-
|
|
99
|
-
if (err != 0)
|
|
100
|
-
{
|
|
101
|
-
MS_THROW_ERROR("uv_fileno() failed: %s", uv_strerror(err));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
#endif
|
|
105
90
|
}
|
|
106
91
|
|
|
107
92
|
UdpSocketHandle::~UdpSocketHandle()
|
|
@@ -157,32 +142,6 @@ void UdpSocketHandle::Send(
|
|
|
157
142
|
return;
|
|
158
143
|
}
|
|
159
144
|
|
|
160
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
161
|
-
if (DepLibUring::IsEnabled())
|
|
162
|
-
{
|
|
163
|
-
if (!DepLibUring::IsActive())
|
|
164
|
-
{
|
|
165
|
-
goto send_libuv;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Prepare the data to be sent.
|
|
169
|
-
// NOTE: If all SQEs are currently in use or no UserData entry is available we'll
|
|
170
|
-
// fall back to libuv.
|
|
171
|
-
auto prepared = DepLibUring::PrepareSend(this->fd, data, len, addr, cb);
|
|
172
|
-
|
|
173
|
-
if (!prepared)
|
|
174
|
-
{
|
|
175
|
-
MS_DEBUG_DEV("cannot send via liburing, fallback to libuv");
|
|
176
|
-
|
|
177
|
-
goto send_libuv;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
send_libuv:
|
|
184
|
-
#endif
|
|
185
|
-
|
|
186
145
|
// First try uv_udp_try_send(). In case it can not directly send the datagram
|
|
187
146
|
// then build a uv_req_t and use uv_udp_send().
|
|
188
147
|
|
package/worker/src/lib.cpp
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
#include "lib.hpp"
|
|
5
5
|
#include "common.hpp"
|
|
6
|
-
#include "DepLibSRTP.hpp"
|
|
7
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
8
|
-
#include "DepLibUring.hpp"
|
|
9
|
-
#endif
|
|
10
6
|
#include "Channel/ChannelMessageRegistrator.hpp"
|
|
11
7
|
#include "Channel/ChannelNotifier.hpp"
|
|
12
8
|
#include "Channel/ChannelSocket.hpp"
|
|
9
|
+
#include "DepLibSRTP.hpp"
|
|
13
10
|
#include "DepLibUV.hpp"
|
|
14
11
|
#include "DepLibWebRTC.hpp"
|
|
15
12
|
#include "DepOpenSSL.hpp"
|
|
@@ -153,9 +150,6 @@ extern "C" int mediasoup_worker_run(
|
|
|
153
150
|
// Initialize static stuff.
|
|
154
151
|
DepOpenSSL::ClassInit();
|
|
155
152
|
DepLibSRTP::ClassInit();
|
|
156
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
157
|
-
DepLibUring::ClassInit();
|
|
158
|
-
#endif
|
|
159
153
|
DepLibWebRTC::ClassInit();
|
|
160
154
|
Utils::Crypto::ClassInit();
|
|
161
155
|
RTC::DtlsTransport::ClassInit();
|
|
@@ -175,9 +169,6 @@ extern "C" int mediasoup_worker_run(
|
|
|
175
169
|
DepLibSRTP::ClassDestroy();
|
|
176
170
|
Utils::Crypto::ClassDestroy();
|
|
177
171
|
DepLibWebRTC::ClassDestroy();
|
|
178
|
-
#ifdef MS_LIBURING_SUPPORTED
|
|
179
|
-
DepLibUring::ClassDestroy();
|
|
180
|
-
#endif
|
|
181
172
|
RTC::DtlsTransport::ClassDestroy();
|
|
182
173
|
DepLibUV::ClassDestroy();
|
|
183
174
|
|
package/worker/fbs/liburing.fbs
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#ifndef MS_DEP_LIBURING_HPP
|
|
2
|
-
#define MS_DEP_LIBURING_HPP
|
|
3
|
-
|
|
4
|
-
#include "FBS/liburing.h"
|
|
5
|
-
#include <uv.h>
|
|
6
|
-
#include <functional>
|
|
7
|
-
#include <liburing.h>
|
|
8
|
-
#include <queue>
|
|
9
|
-
|
|
10
|
-
class DepLibUring
|
|
11
|
-
{
|
|
12
|
-
public:
|
|
13
|
-
using onSendCallback = const std::function<void(bool sent)>;
|
|
14
|
-
|
|
15
|
-
/* Struct for the user data field of SQE and CQE. */
|
|
16
|
-
struct UserData
|
|
17
|
-
{
|
|
18
|
-
// Pointer to send buffer.
|
|
19
|
-
uint8_t* store{ nullptr };
|
|
20
|
-
// Frame len buffer for TCP.
|
|
21
|
-
uint8_t frameLen[2] = { 0 };
|
|
22
|
-
// iovec for TCP, first item for framing, second item for payload.
|
|
23
|
-
struct iovec iov[2];
|
|
24
|
-
// Send callback.
|
|
25
|
-
onSendCallback* cb{ nullptr };
|
|
26
|
-
// Index in userDatas array.
|
|
27
|
-
size_t idx{ 0 };
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/* Number of submission queue entries (SQE). */
|
|
31
|
-
static constexpr size_t QueueDepth{ 1024 * 4 };
|
|
32
|
-
static constexpr size_t SendBufferSize{ 1500 };
|
|
33
|
-
|
|
34
|
-
using SendBuffer = uint8_t[SendBufferSize];
|
|
35
|
-
|
|
36
|
-
static void ClassInit();
|
|
37
|
-
static void ClassDestroy();
|
|
38
|
-
static bool CheckRuntimeSupport();
|
|
39
|
-
static bool IsEnabled();
|
|
40
|
-
static flatbuffers::Offset<FBS::LibUring::Dump> FillBuffer(flatbuffers::FlatBufferBuilder& builder);
|
|
41
|
-
static void StartPollingCQEs();
|
|
42
|
-
static void StopPollingCQEs();
|
|
43
|
-
static uint8_t* GetSendBuffer();
|
|
44
|
-
static bool PrepareSend(
|
|
45
|
-
int sockfd, const uint8_t* data, size_t len, const struct sockaddr* addr, onSendCallback* cb);
|
|
46
|
-
static bool PrepareWrite(
|
|
47
|
-
int sockfd, const uint8_t* data1, size_t len1, const uint8_t* data2, size_t len2, onSendCallback* cb);
|
|
48
|
-
static void Submit();
|
|
49
|
-
static void SetActive();
|
|
50
|
-
static bool IsActive();
|
|
51
|
-
|
|
52
|
-
class LibUring;
|
|
53
|
-
|
|
54
|
-
// Whether liburing is enabled or not after runtime checks.
|
|
55
|
-
static thread_local bool enabled;
|
|
56
|
-
static thread_local LibUring* liburing;
|
|
57
|
-
|
|
58
|
-
public:
|
|
59
|
-
// Singleton.
|
|
60
|
-
class LibUring
|
|
61
|
-
{
|
|
62
|
-
public:
|
|
63
|
-
LibUring();
|
|
64
|
-
~LibUring();
|
|
65
|
-
flatbuffers::Offset<FBS::LibUring::Dump> FillBuffer(flatbuffers::FlatBufferBuilder& builder) const;
|
|
66
|
-
void StartPollingCQEs();
|
|
67
|
-
void StopPollingCQEs();
|
|
68
|
-
uint8_t* GetSendBuffer();
|
|
69
|
-
bool PrepareSend(
|
|
70
|
-
int sockfd, const uint8_t* data, size_t len, const struct sockaddr* addr, onSendCallback* cb);
|
|
71
|
-
bool PrepareWrite(
|
|
72
|
-
int sockfd,
|
|
73
|
-
const uint8_t* data1,
|
|
74
|
-
size_t len1,
|
|
75
|
-
const uint8_t* data2,
|
|
76
|
-
size_t len2,
|
|
77
|
-
onSendCallback* cb);
|
|
78
|
-
void Submit();
|
|
79
|
-
void SetActive()
|
|
80
|
-
{
|
|
81
|
-
this->active = true;
|
|
82
|
-
}
|
|
83
|
-
bool IsActive() const
|
|
84
|
-
{
|
|
85
|
-
return this->active;
|
|
86
|
-
}
|
|
87
|
-
bool IsZeroCopyEnabled() const
|
|
88
|
-
{
|
|
89
|
-
return this->zeroCopyEnabled;
|
|
90
|
-
}
|
|
91
|
-
io_uring* GetRing()
|
|
92
|
-
{
|
|
93
|
-
return std::addressof(this->ring);
|
|
94
|
-
}
|
|
95
|
-
int GetEventFd() const
|
|
96
|
-
{
|
|
97
|
-
return this->efd;
|
|
98
|
-
}
|
|
99
|
-
void ReleaseUserDataEntry(size_t idx)
|
|
100
|
-
{
|
|
101
|
-
this->availableUserDataEntries.push(idx);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private:
|
|
105
|
-
void SetInactive()
|
|
106
|
-
{
|
|
107
|
-
this->active = false;
|
|
108
|
-
}
|
|
109
|
-
UserData* GetUserData();
|
|
110
|
-
bool IsDataInSendBuffers(const uint8_t* data) const
|
|
111
|
-
{
|
|
112
|
-
return data >= this->sendBuffers[0] && data <= this->sendBuffers[DepLibUring::QueueDepth - 1];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private:
|
|
116
|
-
// io_uring instance.
|
|
117
|
-
io_uring ring;
|
|
118
|
-
// Event file descriptor to watch for io_uring completions.
|
|
119
|
-
int efd;
|
|
120
|
-
// libuv handle used to poll io_uring completions.
|
|
121
|
-
uv_poll_t* uvHandle{ nullptr };
|
|
122
|
-
// Whether we are currently sending RTP over io_uring.
|
|
123
|
-
bool active{ false };
|
|
124
|
-
// Whether Zero Copy feature is enabled.
|
|
125
|
-
bool zeroCopyEnabled{ true };
|
|
126
|
-
// Pre-allocated UserData's.
|
|
127
|
-
UserData userDatas[QueueDepth]{};
|
|
128
|
-
// Indexes of available UserData entries.
|
|
129
|
-
std::queue<size_t> availableUserDataEntries;
|
|
130
|
-
// Pre-allocated SendBuffer's.
|
|
131
|
-
SendBuffer sendBuffers[QueueDepth];
|
|
132
|
-
// iovec structs to be registered for Zero Copy.
|
|
133
|
-
struct iovec iovecs[QueueDepth];
|
|
134
|
-
// Submission queue entry process count.
|
|
135
|
-
uint64_t sqeProcessCount{ 0u };
|
|
136
|
-
// Submission queue entry miss count.
|
|
137
|
-
uint64_t sqeMissCount{ 0u };
|
|
138
|
-
// User data miss count.
|
|
139
|
-
uint64_t userDataMissCount{ 0u };
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
#endif
|