mediasoup 3.20.7 → 3.20.9
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/README.md +8 -2
- package/node/lib/WebRtcServer.d.ts.map +1 -1
- package/node/lib/WebRtcServer.js +0 -7
- package/node/lib/WebRtcServerTypes.d.ts +0 -5
- package/node/lib/WebRtcServerTypes.d.ts.map +1 -1
- package/node/lib/fbs/web-rtc-server/dump-response.d.ts +2 -9
- package/node/lib/fbs/web-rtc-server/dump-response.d.ts.map +1 -1
- package/node/lib/fbs/web-rtc-server/dump-response.js +5 -33
- package/node/lib/fbs/web-rtc-server.d.ts +0 -1
- package/node/lib/fbs/web-rtc-server.d.ts.map +1 -1
- package/node/lib/fbs/web-rtc-server.js +1 -4
- package/node/lib/test/test-WebRtcServer.js +0 -7
- package/npm-scripts.mjs +132 -55
- package/package.json +6 -4
- package/worker/fbs/webRtcServer.fbs +0 -6
- package/worker/include/RTC/TransportTuple.hpp +70 -14
- package/worker/include/RTC/WebRtcServer.hpp +5 -2
- package/worker/include/Utils.hpp +6 -0
- package/worker/src/RTC/PortManager.cpp +16 -20
- package/worker/src/RTC/SeqManager.cpp +4 -1
- package/worker/src/RTC/SimpleProducerStreamManager.cpp +6 -3
- package/worker/src/RTC/TransportTuple.cpp +87 -50
- package/worker/src/RTC/WebRtcServer.cpp +20 -29
- package/worker/test/src/RTC/TestSeqManager.cpp +167 -62
- package/worker/test/src/RTC/TestTransportTuple.cpp +21 -14
- package/node/lib/fbs/consumer/degrade-request.d.ts +0 -30
- package/node/lib/fbs/consumer/degrade-request.d.ts.map +0 -1
- package/node/lib/fbs/consumer/degrade-request.js +0 -124
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts +0 -24
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.d.ts.map +0 -1
- package/node/lib/fbs/consumer/enable-delay-and-loss-request.js +0 -102
- package/node/lib/fbs/lib-uring/dump.d.ts +0 -27
- package/node/lib/fbs/lib-uring/dump.d.ts.map +0 -1
- package/node/lib/fbs/lib-uring/dump.js +0 -113
- package/node/lib/fbs/lib-uring.d.ts +0 -2
- package/node/lib/fbs/lib-uring.d.ts.map +0 -1
- package/node/lib/fbs/lib-uring.js +0 -8
- package/node/lib/fbs/producer/degrade-request.d.ts +0 -30
- package/node/lib/fbs/producer/degrade-request.d.ts.map +0 -1
- package/node/lib/fbs/producer/degrade-request.js +0 -124
- package/node/lib/fbs/sctp-parameters/num-sctp-streams.d.ts +0 -24
- package/node/lib/fbs/sctp-parameters/num-sctp-streams.d.ts.map +0 -1
- package/node/lib/fbs/sctp-parameters/num-sctp-streams.js +0 -102
- package/node/lib/fbs/transport/sctp-negotiated-max-streams-notification.d.ts +0 -24
- package/node/lib/fbs/transport/sctp-negotiated-max-streams-notification.d.ts.map +0 -1
- package/node/lib/fbs/transport/sctp-negotiated-max-streams-notification.js +0 -102
- package/node/lib/fbs/transport/sctp-negotiated-options-notification.d.ts +0 -24
- package/node/lib/fbs/transport/sctp-negotiated-options-notification.d.ts.map +0 -1
- package/node/lib/fbs/transport/sctp-negotiated-options-notification.js +0 -102
- package/node/lib/fbs/web-rtc-server/tuple-hash.d.ts +0 -25
- package/node/lib/fbs/web-rtc-server/tuple-hash.d.ts.map +0 -1
- package/node/lib/fbs/web-rtc-server/tuple-hash.js +0 -104
- package/node/lib/fbs/worker/close-notification.d.ts +0 -18
- package/node/lib/fbs/worker/close-notification.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-notification.js +0 -78
- package/node/lib/fbs/worker/close-request.d.ts +0 -18
- package/node/lib/fbs/worker/close-request.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-request.js +0 -78
- package/node/lib/fbs/worker/close-worker-notification.d.ts +0 -18
- package/node/lib/fbs/worker/close-worker-notification.d.ts.map +0 -1
- package/node/lib/fbs/worker/close-worker-notification.js +0 -78
|
@@ -49,22 +49,6 @@ namespace RTC
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
uint64_t TransportTuple::GenerateFnv1aHash(const uint8_t* data, size_t size)
|
|
53
|
-
{
|
|
54
|
-
MS_TRACE();
|
|
55
|
-
|
|
56
|
-
const uint64_t fnvOffsetBasis = 14695981039346656037ull;
|
|
57
|
-
const uint64_t fnvPrime = 1099511628211ull;
|
|
58
|
-
uint64_t hash = fnvOffsetBasis;
|
|
59
|
-
|
|
60
|
-
for (size_t i = 0; i < size; ++i)
|
|
61
|
-
{
|
|
62
|
-
hash = (hash ^ data[i]) * fnvPrime;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return hash;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
52
|
/* Instance methods. */
|
|
69
53
|
|
|
70
54
|
void TransportTuple::CloseTcpConnection()
|
|
@@ -143,54 +127,107 @@ namespace RTC
|
|
|
143
127
|
}
|
|
144
128
|
}
|
|
145
129
|
|
|
146
|
-
MS_DUMP_CLEAN(indentation, " hash: %" PRIu64, this->hash);
|
|
147
|
-
|
|
148
130
|
MS_DUMP_CLEAN(indentation, "</TransportTuple>");
|
|
149
131
|
}
|
|
150
132
|
|
|
151
|
-
|
|
133
|
+
bool TransportTuple::TupleKey::operator==(const TupleKey& other) const noexcept
|
|
152
134
|
{
|
|
153
135
|
MS_TRACE();
|
|
154
136
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
static constexpr size_t BufferSize = ((16 + 2) * 2) + 1;
|
|
160
|
-
uint8_t buffer[BufferSize] = {};
|
|
161
|
-
size_t idx = 0;
|
|
137
|
+
if (this->protocol != other.protocol)
|
|
138
|
+
{
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
162
141
|
|
|
163
|
-
|
|
142
|
+
switch (this->protocol)
|
|
164
143
|
{
|
|
165
|
-
|
|
144
|
+
// For UDP compare the remote address first (it discriminates faster) and then
|
|
145
|
+
// the socket.
|
|
146
|
+
case Protocol::UDP:
|
|
166
147
|
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const uint16_t port = ntohs(in->sin_port);
|
|
170
|
-
|
|
171
|
-
std::memcpy(buffer + idx, ip, 4);
|
|
172
|
-
idx += 4;
|
|
173
|
-
buffer[idx++] = (port >> 8) & 0xFF;
|
|
174
|
-
buffer[idx++] = port & 0xFF;
|
|
148
|
+
return Utils::IP::CompareAddresses(this->udpRemoteAddr, other.udpRemoteAddr) &&
|
|
149
|
+
this->udpSocketOrTcpConnection == other.udpSocketOrTcpConnection;
|
|
175
150
|
}
|
|
176
|
-
|
|
151
|
+
|
|
152
|
+
// For TCP the connection pointer fully identifies the tuple.
|
|
153
|
+
case Protocol::TCP:
|
|
177
154
|
{
|
|
178
|
-
|
|
179
|
-
const auto* ip = reinterpret_cast<const uint8_t*>(&in6->sin6_addr);
|
|
180
|
-
const uint16_t port = ntohs(in6->sin6_port);
|
|
181
|
-
|
|
182
|
-
std::memcpy(buffer + idx, ip, 16);
|
|
183
|
-
idx += 16;
|
|
184
|
-
buffer[idx++] = (port >> 8) & 0xFF;
|
|
185
|
-
buffer[idx++] = port & 0xFF;
|
|
155
|
+
return this->udpSocketOrTcpConnection == other.udpSocketOrTcpConnection;
|
|
186
156
|
}
|
|
187
|
-
};
|
|
188
157
|
|
|
189
|
-
|
|
190
|
-
|
|
158
|
+
NO_DEFAULT_GCC();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
size_t TransportTuple::TupleKeyHash::operator()(const TupleKey& key) const noexcept
|
|
163
|
+
{
|
|
164
|
+
MS_TRACE();
|
|
165
|
+
|
|
166
|
+
const auto protocolBits = static_cast<uint8_t>(key.protocol);
|
|
191
167
|
|
|
192
|
-
|
|
168
|
+
size_t seed = 0;
|
|
193
169
|
|
|
194
|
-
|
|
170
|
+
Utils::Crypto::HashCombine(seed, ankerl::unordered_dense::hash<uint8_t>{}(protocolBits));
|
|
171
|
+
Utils::Crypto::HashCombine(
|
|
172
|
+
seed,
|
|
173
|
+
ankerl::unordered_dense::hash<uintptr_t>{}(
|
|
174
|
+
reinterpret_cast<uintptr_t>(key.udpSocketOrTcpConnection)));
|
|
175
|
+
|
|
176
|
+
switch (key.protocol)
|
|
177
|
+
{
|
|
178
|
+
case Protocol::UDP:
|
|
179
|
+
{
|
|
180
|
+
// For UDP also combine the remote address.
|
|
181
|
+
const auto familyBits = static_cast<uint16_t>(key.udpRemoteAddr->sa_family);
|
|
182
|
+
|
|
183
|
+
Utils::Crypto::HashCombine(seed, ankerl::unordered_dense::hash<uint16_t>{}(familyBits));
|
|
184
|
+
|
|
185
|
+
switch (key.udpRemoteAddr->sa_family)
|
|
186
|
+
{
|
|
187
|
+
case AF_INET:
|
|
188
|
+
{
|
|
189
|
+
const auto* remoteIn = reinterpret_cast<const sockaddr_in*>(key.udpRemoteAddr);
|
|
190
|
+
|
|
191
|
+
Utils::Crypto::HashCombine(
|
|
192
|
+
seed, ankerl::unordered_dense::hash<uint32_t>{}(remoteIn->sin_addr.s_addr));
|
|
193
|
+
Utils::Crypto::HashCombine(
|
|
194
|
+
seed, ankerl::unordered_dense::hash<uint16_t>{}(remoteIn->sin_port));
|
|
195
|
+
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
case AF_INET6:
|
|
200
|
+
{
|
|
201
|
+
const auto* remoteIn6 = reinterpret_cast<const sockaddr_in6*>(key.udpRemoteAddr);
|
|
202
|
+
const auto* addr = remoteIn6->sin6_addr.s6_addr;
|
|
203
|
+
|
|
204
|
+
uint64_t hi;
|
|
205
|
+
uint64_t lo;
|
|
206
|
+
|
|
207
|
+
std::memcpy(std::addressof(hi), addr, sizeof(uint64_t));
|
|
208
|
+
std::memcpy(std::addressof(lo), addr + sizeof(uint64_t), sizeof(uint64_t));
|
|
209
|
+
|
|
210
|
+
Utils::Crypto::HashCombine(seed, ankerl::unordered_dense::hash<uint64_t>{}(hi));
|
|
211
|
+
Utils::Crypto::HashCombine(seed, ankerl::unordered_dense::hash<uint64_t>{}(lo));
|
|
212
|
+
Utils::Crypto::HashCombine(
|
|
213
|
+
seed, ankerl::unordered_dense::hash<uint16_t>{}(remoteIn6->sin6_port));
|
|
214
|
+
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
default:;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return seed;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
case Protocol::TCP:
|
|
225
|
+
{
|
|
226
|
+
// For TCP the connection pointer is enough.
|
|
227
|
+
return seed;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
NO_DEFAULT_GCC();
|
|
231
|
+
}
|
|
195
232
|
}
|
|
196
233
|
} // namespace RTC
|
|
@@ -303,26 +303,13 @@ namespace RTC
|
|
|
303
303
|
builder, localIceUsernameFragment.c_str(), webRtcTransport->id.c_str()));
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
// Add tupleHashes.
|
|
307
|
-
std::vector<flatbuffers::Offset<FBS::WebRtcServer::TupleHash>> tupleHashes;
|
|
308
|
-
|
|
309
|
-
for (const auto& kv : this->mapTupleWebRtcTransport)
|
|
310
|
-
{
|
|
311
|
-
const auto& tupleHash = kv.first;
|
|
312
|
-
const auto* webRtcTransport = kv.second;
|
|
313
|
-
|
|
314
|
-
tupleHashes.emplace_back(
|
|
315
|
-
FBS::WebRtcServer::CreateTupleHashDirect(builder, tupleHash, webRtcTransport->id.c_str()));
|
|
316
|
-
}
|
|
317
|
-
|
|
318
306
|
return FBS::WebRtcServer::CreateDumpResponseDirect(
|
|
319
307
|
builder,
|
|
320
308
|
this->id.c_str(),
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
&tupleHashes);
|
|
309
|
+
std::addressof(udpSockets),
|
|
310
|
+
std::addressof(tcpServers),
|
|
311
|
+
std::addressof(webRtcTransportIds),
|
|
312
|
+
std::addressof(localIceUsernameFragments));
|
|
326
313
|
}
|
|
327
314
|
|
|
328
315
|
void WebRtcServer::HandleRequest(Channel::ChannelRequest* request)
|
|
@@ -450,7 +437,7 @@ namespace RTC
|
|
|
450
437
|
}
|
|
451
438
|
|
|
452
439
|
// First try doing lookup in the tuples table.
|
|
453
|
-
auto it1 = this->mapTupleWebRtcTransport.find(tuple->
|
|
440
|
+
auto it1 = this->mapTupleWebRtcTransport.find(tuple->GetTupleKey());
|
|
454
441
|
|
|
455
442
|
if (it1 != this->mapTupleWebRtcTransport.end())
|
|
456
443
|
{
|
|
@@ -488,7 +475,7 @@ namespace RTC
|
|
|
488
475
|
{
|
|
489
476
|
MS_TRACE();
|
|
490
477
|
|
|
491
|
-
auto it = this->mapTupleWebRtcTransport.find(tuple->
|
|
478
|
+
auto it = this->mapTupleWebRtcTransport.find(tuple->GetTupleKey());
|
|
492
479
|
|
|
493
480
|
if (it == this->mapTupleWebRtcTransport.end())
|
|
494
481
|
{
|
|
@@ -562,14 +549,16 @@ namespace RTC
|
|
|
562
549
|
{
|
|
563
550
|
MS_TRACE();
|
|
564
551
|
|
|
565
|
-
|
|
552
|
+
auto tupleKey = tuple->GetTupleKey();
|
|
553
|
+
|
|
554
|
+
if (this->mapTupleWebRtcTransport.contains(tupleKey))
|
|
566
555
|
{
|
|
567
|
-
MS_WARN_TAG(ice, "tuple
|
|
556
|
+
MS_WARN_TAG(ice, "tuple key already exists in the table");
|
|
568
557
|
|
|
569
558
|
return;
|
|
570
559
|
}
|
|
571
560
|
|
|
572
|
-
this->mapTupleWebRtcTransport[
|
|
561
|
+
this->mapTupleWebRtcTransport[tupleKey] = webRtcTransport;
|
|
573
562
|
}
|
|
574
563
|
|
|
575
564
|
inline void WebRtcServer::OnWebRtcTransportTransportTupleRemoved(
|
|
@@ -577,14 +566,16 @@ namespace RTC
|
|
|
577
566
|
{
|
|
578
567
|
MS_TRACE();
|
|
579
568
|
|
|
580
|
-
|
|
569
|
+
auto it = this->mapTupleWebRtcTransport.find(tuple->GetTupleKey());
|
|
570
|
+
|
|
571
|
+
if (it == this->mapTupleWebRtcTransport.end())
|
|
581
572
|
{
|
|
582
|
-
MS_DEBUG_TAG(ice, "tuple
|
|
573
|
+
MS_DEBUG_TAG(ice, "tuple key not found in the table");
|
|
583
574
|
|
|
584
575
|
return;
|
|
585
576
|
}
|
|
586
577
|
|
|
587
|
-
this->mapTupleWebRtcTransport.erase(
|
|
578
|
+
this->mapTupleWebRtcTransport.erase(it);
|
|
588
579
|
}
|
|
589
580
|
|
|
590
581
|
inline void WebRtcServer::OnUdpSocketPacketReceived(
|
|
@@ -598,7 +589,7 @@ namespace RTC
|
|
|
598
589
|
|
|
599
590
|
RTC::TransportTuple tuple(socket, remoteAddr);
|
|
600
591
|
|
|
601
|
-
OnPacketReceived(
|
|
592
|
+
OnPacketReceived(std::addressof(tuple), data, len, bufferLen);
|
|
602
593
|
}
|
|
603
594
|
|
|
604
595
|
inline void WebRtcServer::OnRtcTcpConnectionClosed(
|
|
@@ -612,7 +603,7 @@ namespace RTC
|
|
|
612
603
|
// mapTupleWebRtcTransport because this event may be called after the tuple
|
|
613
604
|
// was removed from it.
|
|
614
605
|
|
|
615
|
-
auto it = this->mapTupleWebRtcTransport.find(tuple.
|
|
606
|
+
auto it = this->mapTupleWebRtcTransport.find(tuple.GetTupleKey());
|
|
616
607
|
|
|
617
608
|
if (it == this->mapTupleWebRtcTransport.end())
|
|
618
609
|
{
|
|
@@ -621,7 +612,7 @@ namespace RTC
|
|
|
621
612
|
|
|
622
613
|
auto* webRtcTransport = it->second;
|
|
623
614
|
|
|
624
|
-
webRtcTransport->RemoveTuple(
|
|
615
|
+
webRtcTransport->RemoveTuple(std::addressof(tuple));
|
|
625
616
|
}
|
|
626
617
|
|
|
627
618
|
inline void WebRtcServer::OnTcpConnectionPacketReceived(
|
|
@@ -631,6 +622,6 @@ namespace RTC
|
|
|
631
622
|
|
|
632
623
|
RTC::TransportTuple tuple(connection);
|
|
633
624
|
|
|
634
|
-
OnPacketReceived(
|
|
625
|
+
OnPacketReceived(std::addressof(tuple), data, len, bufferLen);
|
|
635
626
|
}
|
|
636
627
|
} // namespace RTC
|