mediasoup 3.28.0 → 3.29.0
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/CHANGELOG.md +12 -0
- package/node/lib/PipeTransportTypes.d.ts +6 -1
- package/node/lib/PipeTransportTypes.d.ts.map +1 -1
- package/node/lib/PlainTransportTypes.d.ts +6 -1
- package/node/lib/PlainTransportTypes.d.ts.map +1 -1
- package/node/lib/Router.d.ts +4 -4
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +10 -7
- package/node/lib/RouterTypes.d.ts +7 -1
- package/node/lib/RouterTypes.d.ts.map +1 -1
- package/node/lib/Transport.d.ts +2 -1
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +17 -6
- package/node/lib/TransportTypes.d.ts +12 -2
- package/node/lib/TransportTypes.d.ts.map +1 -1
- package/node/lib/WebRtcTransportTypes.d.ts +6 -1
- package/node/lib/WebRtcTransportTypes.d.ts.map +1 -1
- package/node/lib/fbs/transport/options.d.ts +6 -2
- package/node/lib/fbs/transport/options.d.ts.map +1 -1
- package/node/lib/fbs/transport/options.js +19 -7
- package/node/lib/fbs/transport/sctp-zero-checksum.d.ts +6 -0
- package/node/lib/fbs/transport/sctp-zero-checksum.d.ts.map +1 -0
- package/node/lib/fbs/transport/sctp-zero-checksum.js +11 -0
- package/node/lib/fbs/transport/stats.d.ts +2 -8
- package/node/lib/fbs/transport/stats.d.ts.map +1 -1
- package/node/lib/fbs/transport/stats.js +5 -29
- package/node/lib/fbs/transport.d.ts +1 -0
- package/node/lib/fbs/transport.d.ts.map +1 -1
- package/node/lib/fbs/transport.js +4 -2
- package/npm-scripts.mjs +35 -44
- package/package.json +10 -6
- package/worker/fbs/transport.fbs +9 -2
- package/worker/fuzzer/src/RTC/RTP/FuzzerRetransmissionBuffer.cpp +14 -1
- package/worker/fuzzer/src/RTC/RTP/FuzzerRtpStreamSend.cpp +17 -4
- package/worker/include/RTC/BWE/AimdRateControl.hpp +9 -9
- package/worker/include/RTC/BWE/BweTypes.hpp +54 -17
- package/worker/include/RTC/BWE/DelayBasedBwe.hpp +3 -3
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +2 -2
- package/worker/include/RTC/BWE/LossBasedController.hpp +4 -4
- package/worker/include/RTC/BWE/OveruseDetector.hpp +5 -4
- package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +1 -1
- package/worker/include/RTC/BWE/ProbeController.hpp +6 -6
- package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +2 -6
- package/worker/include/RTC/BWE/ProbingScheduler.hpp +3 -7
- package/worker/include/RTC/BWE/ReceiverTransportCongestionController.hpp +148 -0
- package/worker/include/RTC/BWE/RembGenerator.hpp +4 -3
- package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +1 -1
- package/worker/include/RTC/BWE/SenderTransportCongestionController.hpp +343 -0
- package/worker/include/RTC/BWE/TargetRateController.hpp +4 -1
- package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +5 -4
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +3 -3
- package/worker/include/RTC/Consumer.hpp +8 -1
- package/worker/include/RTC/RTP/RetransmissionBuffer.hpp +36 -10
- package/worker/include/RTC/RTP/RtpStream.hpp +21 -0
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +1 -0
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +122 -9
- package/worker/include/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.hpp +12 -3
- package/worker/include/RTC/TransportCongestionControlClient.hpp +0 -5
- package/worker/include/RTC/TransportCongestionControlServer.hpp +0 -5
- package/worker/include/Utils.hpp +9 -2
- package/worker/meson.build +4 -0
- package/worker/src/RTC/BWE/AimdRateControl.cpp +22 -22
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +16 -20
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +1 -1
- package/worker/src/RTC/BWE/OveruseDetector.cpp +8 -8
- package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +2 -2
- package/worker/src/RTC/BWE/ProbeController.cpp +1 -1
- package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +1 -6
- package/worker/src/RTC/BWE/ProbingScheduler.cpp +2 -7
- package/worker/src/RTC/BWE/ReceiverTransportCongestionController.cpp +207 -0
- package/worker/src/RTC/BWE/RembGenerator.cpp +1 -1
- package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +1 -1
- package/worker/src/RTC/BWE/SenderTransportCongestionController.cpp +599 -0
- package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +2 -3
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +5 -5
- package/worker/src/RTC/Consumer.cpp +3 -2
- package/worker/src/RTC/DataConsumer.cpp +2 -2
- package/worker/src/RTC/RTP/RetransmissionBuffer.cpp +21 -8
- package/worker/src/RTC/RTP/RtpStream.cpp +0 -3
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +57 -71
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +428 -244
- package/worker/src/RTC/RTP/RtxStream.cpp +14 -19
- package/worker/src/RTC/SCTP/association/Association.cpp +3 -2
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +26 -6
- package/worker/src/RTC/SCTP/packet/parameters/ZeroChecksumAcceptableParameter.cpp +4 -3
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
- package/worker/src/RTC/SCTP/tx/RetransmissionQueue.cpp +4 -2
- package/worker/src/RTC/Transport.cpp +49 -20
- package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -66
- package/worker/src/RTC/TransportCongestionControlServer.cpp +0 -55
- package/worker/src/Utils/Crypto.cpp +114 -98
- package/worker/subprojects/catch2.wrap +6 -6
- package/worker/subprojects/openssl.wrap +11 -12
- package/worker/subprojects/packagefiles/ankerl-unordered-dense/meson.build +1 -1
- package/worker/subprojects/unordered-dense.wrap +4 -4
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +5 -5
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +26 -23
- package/worker/test/src/RTC/BWE/TestInterArrivalDelta.cpp +8 -8
- package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +4 -4
- package/worker/test/src/RTC/BWE/TestProbeController.cpp +35 -32
- package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +2 -17
- package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +1 -25
- package/worker/test/src/RTC/BWE/TestReceiverTransportCongestionController.cpp +346 -0
- package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +1 -1
- package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +9 -9
- package/worker/test/src/RTC/BWE/TestSenderTransportCongestionController.cpp +510 -0
- package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +16 -14
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +6 -6
- package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +1 -2
- package/worker/test/src/RTC/RTCP/TestBye.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsAfb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsFir.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsLei.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsPli.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRpsi.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsSli.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsTst.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackPsVbcm.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpEcn.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpNack.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpSrReq.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTllei.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTmmb.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestReceiverReport.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestSenderReport.cpp +1 -1
- package/worker/test/src/RTC/RTP/TestRetransmissionBuffer.cpp +60 -28
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +1 -1
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +746 -24
- package/worker/test/src/RTC/RTP/TestSharedPacket.cpp +1 -1
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +42 -0
- package/worker/test/src/RTC/SCTP/association/TestNegotiatedCapabilities.cpp +54 -5
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +80 -15
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +410 -3
- package/worker/test/src/RTC/SCTP/association/TestTransmissionControlBlock.cpp +1 -1
- package/worker/test/src/RTC/SCTP/packet/parameters/TestZeroChecksumAcceptableParameter.cpp +37 -5
- package/worker/test/src/RTC/SCTP/rx/TestDataTracker.cpp +5 -4
- package/worker/test/src/RTC/SCTP/rx/TestInterleavedReassemblyStreams.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestReassemblyQueue.cpp +1 -1
- package/worker/test/src/RTC/SCTP/rx/TestTraditionalReassemblyStreams.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestOutstandingData.cpp +1 -1
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionQueue.cpp +11 -10
- package/worker/test/src/RTC/SCTP/tx/TestRetransmissionTimeout.cpp +1 -1
- package/worker/test/src/RTC/TestNackGenerator.cpp +1 -1
- package/worker/test/src/RTC/TestPortManager.cpp +2 -2
- package/worker/test/src/RTC/TestRateCalculator.cpp +1 -1
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +21 -15
- package/worker/test/src/RTC/TestRemoteClockOffsetEstimator.cpp +13 -13
- package/worker/test/src/RTC/TestRtpEncodingParameters.cpp +1 -1
- package/worker/test/src/RTC/TestSubchannelsCodec.cpp +2 -2
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +1 -1
- package/worker/test/src/RTC/TestTransportTuple.cpp +3 -2
- package/worker/test/src/Utils/TestCrypto.cpp +71 -2
- package/worker/test/src/Utils/TestTime.cpp +2 -2
|
@@ -13,7 +13,10 @@ namespace RTC
|
|
|
13
13
|
/* Class methods. */
|
|
14
14
|
|
|
15
15
|
RetransmissionBuffer::Item* RetransmissionBuffer::FillItem(
|
|
16
|
-
RetransmissionBuffer::Item* item,
|
|
16
|
+
RetransmissionBuffer::Item* item,
|
|
17
|
+
RTP::Packet* packet,
|
|
18
|
+
const RTP::SharedPacket& sharedPacket,
|
|
19
|
+
int64_t nowMs)
|
|
17
20
|
{
|
|
18
21
|
MS_TRACE();
|
|
19
22
|
|
|
@@ -27,6 +30,7 @@ namespace RTC
|
|
|
27
30
|
item->sequenceNumber = packet->GetSequenceNumber();
|
|
28
31
|
item->timestamp = packet->GetTimestamp();
|
|
29
32
|
item->marker = packet->HasMarker();
|
|
33
|
+
item->storedAtMs = nowMs;
|
|
30
34
|
|
|
31
35
|
return item;
|
|
32
36
|
}
|
|
@@ -113,7 +117,8 @@ namespace RTC
|
|
|
113
117
|
* not properly fit (by ensuring that elements in the buffer are not only
|
|
114
118
|
* ordered by increasing seq but also that their timestamp are incremental).
|
|
115
119
|
*/
|
|
116
|
-
bool RetransmissionBuffer::Insert(
|
|
120
|
+
bool RetransmissionBuffer::Insert(
|
|
121
|
+
RTP::Packet* packet, const RTP::SharedPacket& sharedPacket, int64_t nowMs)
|
|
117
122
|
{
|
|
118
123
|
MS_TRACE();
|
|
119
124
|
|
|
@@ -130,7 +135,7 @@ namespace RTC
|
|
|
130
135
|
|
|
131
136
|
auto* item = new Item();
|
|
132
137
|
|
|
133
|
-
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket));
|
|
138
|
+
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs));
|
|
134
139
|
|
|
135
140
|
return true;
|
|
136
141
|
}
|
|
@@ -156,7 +161,7 @@ namespace RTC
|
|
|
156
161
|
|
|
157
162
|
auto* item = new Item();
|
|
158
163
|
|
|
159
|
-
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket));
|
|
164
|
+
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs));
|
|
160
165
|
|
|
161
166
|
return true;
|
|
162
167
|
}
|
|
@@ -185,7 +190,7 @@ namespace RTC
|
|
|
185
190
|
|
|
186
191
|
auto* item = new Item();
|
|
187
192
|
|
|
188
|
-
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket));
|
|
193
|
+
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs));
|
|
189
194
|
|
|
190
195
|
return true;
|
|
191
196
|
}
|
|
@@ -267,7 +272,7 @@ namespace RTC
|
|
|
267
272
|
// Push the packet, which becomes the newest one in the buffer.
|
|
268
273
|
auto* item = new Item();
|
|
269
274
|
|
|
270
|
-
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket));
|
|
275
|
+
this->buffer.push_back(RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs));
|
|
271
276
|
}
|
|
272
277
|
// Packet arrived out order and its seq is less than seq of the oldest
|
|
273
278
|
// stored packet, so will become the oldest one in the buffer.
|
|
@@ -333,7 +338,7 @@ namespace RTC
|
|
|
333
338
|
// Insert the packet, which becomes the oldest one in the buffer.
|
|
334
339
|
auto* item = new Item();
|
|
335
340
|
|
|
336
|
-
this->buffer.push_front(RetransmissionBuffer::FillItem(item, packet, sharedPacket));
|
|
341
|
+
this->buffer.push_front(RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs));
|
|
337
342
|
}
|
|
338
343
|
// Otherwise packet must be inserted between oldest and newest stored items
|
|
339
344
|
// so there is already an allocated slot for it.
|
|
@@ -427,7 +432,7 @@ namespace RTC
|
|
|
427
432
|
// Store the packet.
|
|
428
433
|
item = new Item();
|
|
429
434
|
|
|
430
|
-
this->buffer[idx] = RetransmissionBuffer::FillItem(item, packet, sharedPacket);
|
|
435
|
+
this->buffer[idx] = RetransmissionBuffer::FillItem(item, packet, sharedPacket, nowMs);
|
|
431
436
|
}
|
|
432
437
|
|
|
433
438
|
MS_ASSERT(
|
|
@@ -459,6 +464,13 @@ namespace RTC
|
|
|
459
464
|
this->buffer.clear();
|
|
460
465
|
}
|
|
461
466
|
|
|
467
|
+
bool RetransmissionBuffer::IsTooOld(const Item* item, int64_t nowMs) const
|
|
468
|
+
{
|
|
469
|
+
MS_TRACE();
|
|
470
|
+
|
|
471
|
+
return nowMs - item->storedAtMs > this->maxRetransmissionDelayMs;
|
|
472
|
+
}
|
|
473
|
+
|
|
462
474
|
RetransmissionBuffer::Item* RetransmissionBuffer::GetOldest() const
|
|
463
475
|
{
|
|
464
476
|
MS_TRACE();
|
|
@@ -592,6 +604,7 @@ namespace RTC
|
|
|
592
604
|
this->ssrc = 0;
|
|
593
605
|
this->sequenceNumber = 0;
|
|
594
606
|
this->timestamp = 0;
|
|
607
|
+
this->storedAtMs = 0;
|
|
595
608
|
this->resentAtMs = 0;
|
|
596
609
|
this->sentTimes = 0;
|
|
597
610
|
}
|
|
@@ -11,9 +11,6 @@ namespace RTC
|
|
|
11
11
|
{
|
|
12
12
|
/* Static. */
|
|
13
13
|
|
|
14
|
-
static constexpr uint16_t MaxDropout{ 3000 };
|
|
15
|
-
static constexpr uint16_t MaxMisorder{ 1500 };
|
|
16
|
-
static constexpr uint32_t RtpSeqMod{ 1 << 16 };
|
|
17
14
|
static constexpr size_t ScoreHistogramLength{ 24 };
|
|
18
15
|
|
|
19
16
|
/* Instance methods. */
|
|
@@ -531,18 +531,19 @@ namespace RTC
|
|
|
531
531
|
const int32_t prevPacketsLost = this->packetsLost;
|
|
532
532
|
|
|
533
533
|
// Calculate packets expected and lost.
|
|
534
|
-
auto
|
|
534
|
+
auto expectedPackets = GetExpectedPackets();
|
|
535
535
|
|
|
536
536
|
// NOTE: The expected count is the extended sequence number arithmetic of RFC
|
|
537
537
|
// 3550, so it wraps at 32 bits, whereas the received one does not wrap at
|
|
538
538
|
// all. Each subtraction below is therefore made in the width that keeps it
|
|
539
539
|
// right: this one truncates the received count so that both wrap together,
|
|
540
540
|
// and the interval further down is taken in full width, where it is exact.
|
|
541
|
-
const auto
|
|
541
|
+
const auto receivedPackets =
|
|
542
|
+
static_cast<uint32_t>(this->mediaTransmissionCounter.GetPacketCount());
|
|
542
543
|
|
|
543
|
-
if (
|
|
544
|
+
if (expectedPackets > receivedPackets)
|
|
544
545
|
{
|
|
545
|
-
this->packetsLost = static_cast<int32_t>(
|
|
546
|
+
this->packetsLost = static_cast<int32_t>(expectedPackets - receivedPackets);
|
|
546
547
|
}
|
|
547
548
|
else
|
|
548
549
|
{
|
|
@@ -553,9 +554,9 @@ namespace RTC
|
|
|
553
554
|
//
|
|
554
555
|
// NOTE: Reading the difference of the expected count as signed makes a
|
|
555
556
|
// sequence number re-sync, which restarts the count, come out negative.
|
|
556
|
-
const int64_t expectedInterval = static_cast<int32_t>(
|
|
557
|
+
const int64_t expectedInterval = static_cast<int32_t>(expectedPackets - this->expectedPrior);
|
|
557
558
|
|
|
558
|
-
this->expectedPrior =
|
|
559
|
+
this->expectedPrior = expectedPackets;
|
|
559
560
|
|
|
560
561
|
const auto receivedInterval =
|
|
561
562
|
static_cast<int64_t>(this->mediaTransmissionCounter.GetPacketCount() - this->receivedPrior);
|
|
@@ -911,43 +912,24 @@ namespace RTC
|
|
|
911
912
|
{
|
|
912
913
|
MS_TRACE();
|
|
913
914
|
|
|
914
|
-
// Calculate
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const auto
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
else
|
|
934
|
-
{
|
|
935
|
-
lost = expected - received;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// Calculate number of packets repaired in this interval.
|
|
939
|
-
const auto totalRepaired = this->packetsRepaired;
|
|
940
|
-
|
|
941
|
-
auto repaired = totalRepaired - this->repairedPriorScore;
|
|
942
|
-
|
|
943
|
-
this->repairedPriorScore = totalRepaired;
|
|
944
|
-
|
|
945
|
-
// Calculate number of packets retransmitted in this interval.
|
|
946
|
-
const auto totatRetransmitted = this->packetsRetransmitted;
|
|
947
|
-
|
|
948
|
-
auto retransmitted = totatRetransmitted - this->retransmittedPriorScore;
|
|
949
|
-
|
|
950
|
-
this->retransmittedPriorScore = totatRetransmitted;
|
|
915
|
+
// Calculate the packets of this interval, which is what each counter has
|
|
916
|
+
// grown by since the previous score update.
|
|
917
|
+
const auto totalExpectedPackets = GetExpectedPackets();
|
|
918
|
+
const auto totalReceivedPackets = this->mediaTransmissionCounter.GetPacketCount();
|
|
919
|
+
const auto totalRepairedPackets = this->packetsRepaired;
|
|
920
|
+
const auto totalRetransmittedPackets = this->packetsRetransmitted;
|
|
921
|
+
const uint32_t expectedPackets = totalExpectedPackets - this->expectedPriorScore;
|
|
922
|
+
const auto receivedPackets = totalReceivedPackets - this->receivedPriorScore;
|
|
923
|
+
|
|
924
|
+
uint64_t lostPackets =
|
|
925
|
+
expectedPackets < receivedPackets ? 0 : expectedPackets - receivedPackets;
|
|
926
|
+
auto repairedPackets = totalRepairedPackets - this->repairedPriorScore;
|
|
927
|
+
auto retransmittedPackets = totalRetransmittedPackets - this->retransmittedPriorScore;
|
|
928
|
+
|
|
929
|
+
this->expectedPriorScore = totalExpectedPackets;
|
|
930
|
+
this->receivedPriorScore = totalReceivedPackets;
|
|
931
|
+
this->repairedPriorScore = totalRepairedPackets;
|
|
932
|
+
this->retransmittedPriorScore = totalRetransmittedPackets;
|
|
951
933
|
|
|
952
934
|
if (this->inactive)
|
|
953
935
|
{
|
|
@@ -955,7 +937,7 @@ namespace RTC
|
|
|
955
937
|
}
|
|
956
938
|
|
|
957
939
|
// We didn't expect more packets to come.
|
|
958
|
-
if (
|
|
940
|
+
if (expectedPackets == 0)
|
|
959
941
|
{
|
|
960
942
|
RTP::RtpStream::UpdateScore(10);
|
|
961
943
|
|
|
@@ -964,73 +946,77 @@ namespace RTC
|
|
|
964
946
|
|
|
965
947
|
// We expected packets but received none of them, so there is nothing to
|
|
966
948
|
// compute (and ratios below would divide by zero).
|
|
967
|
-
if (
|
|
949
|
+
if (receivedPackets == 0)
|
|
968
950
|
{
|
|
969
951
|
RTP::RtpStream::UpdateScore(0);
|
|
970
952
|
|
|
971
953
|
return;
|
|
972
954
|
}
|
|
973
955
|
|
|
974
|
-
|
|
956
|
+
lostPackets = std::min(lostPackets, receivedPackets);
|
|
975
957
|
|
|
976
|
-
if (
|
|
958
|
+
if (repairedPackets > lostPackets)
|
|
977
959
|
{
|
|
978
960
|
if (HasRtx())
|
|
979
961
|
{
|
|
980
962
|
// NOTE: The excess has to be discounted before clamping, since once
|
|
981
|
-
// `
|
|
982
|
-
|
|
983
|
-
|
|
963
|
+
// `repairedPackets` has been clamped there is no excess left to tell.
|
|
964
|
+
retransmittedPackets -= repairedPackets - lostPackets;
|
|
965
|
+
repairedPackets = lostPackets;
|
|
984
966
|
}
|
|
985
967
|
else
|
|
986
968
|
{
|
|
987
|
-
|
|
969
|
+
lostPackets = repairedPackets;
|
|
988
970
|
}
|
|
989
971
|
}
|
|
990
972
|
|
|
991
973
|
#if MS_LOG_DEV_LEVEL == 3
|
|
992
974
|
MS_DEBUG_TAG(
|
|
993
975
|
score,
|
|
994
|
-
"[
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
976
|
+
"[totalExpectedPackets:%" PRIu32 ", totalReceivedPackets:%" PRIu64
|
|
977
|
+
", totalRepairedPackets:%" PRIu64,
|
|
978
|
+
totalExpectedPackets,
|
|
979
|
+
totalReceivedPackets,
|
|
980
|
+
totalRepairedPackets);
|
|
998
981
|
|
|
999
982
|
MS_DEBUG_TAG(
|
|
1000
983
|
score,
|
|
1001
|
-
"fixed values [
|
|
1002
|
-
",
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
984
|
+
"fixed values [expectedPackets:%" PRIu32 ", receivedPackets:%" PRIu64
|
|
985
|
+
", lostPackets:%" PRIu64 ", repairedPackets:%" PRIu64 ", retransmittedPackets:%" PRIu64,
|
|
986
|
+
expectedPackets,
|
|
987
|
+
receivedPackets,
|
|
988
|
+
lostPackets,
|
|
989
|
+
repairedPackets,
|
|
990
|
+
retransmittedPackets);
|
|
1008
991
|
#endif
|
|
1009
992
|
|
|
1010
|
-
auto repairedRatio
|
|
993
|
+
auto repairedRatio = static_cast<float>(repairedPackets) / static_cast<float>(receivedPackets);
|
|
1011
994
|
auto repairedWeight = std::pow(1 / (repairedRatio + 1), 4);
|
|
1012
995
|
|
|
1013
|
-
MS_ASSERT(
|
|
996
|
+
MS_ASSERT(
|
|
997
|
+
retransmittedPackets >= repairedPackets,
|
|
998
|
+
"repaired packets cannot be more than retransmitted ones");
|
|
1014
999
|
|
|
1015
|
-
if (
|
|
1000
|
+
if (retransmittedPackets > 0)
|
|
1016
1001
|
{
|
|
1017
|
-
repairedWeight *= static_cast<float>(
|
|
1002
|
+
repairedWeight *= static_cast<float>(repairedPackets) / retransmittedPackets;
|
|
1018
1003
|
}
|
|
1019
1004
|
|
|
1020
|
-
|
|
1005
|
+
lostPackets = static_cast<uint64_t>(lostPackets - (repairedPackets * repairedWeight));
|
|
1021
1006
|
|
|
1022
|
-
auto deliveredRatio =
|
|
1023
|
-
|
|
1007
|
+
auto deliveredRatio =
|
|
1008
|
+
static_cast<float>(receivedPackets - lostPackets) / static_cast<float>(receivedPackets);
|
|
1009
|
+
auto score = static_cast<uint8_t>(std::round(std::pow(deliveredRatio, 4) * 10));
|
|
1024
1010
|
|
|
1025
1011
|
#if MS_LOG_DEV_LEVEL == 3
|
|
1026
1012
|
MS_DEBUG_TAG(
|
|
1027
1013
|
score,
|
|
1028
|
-
"[deliveredRatio:%f, repairedRatio:%f, repairedWeight:%f, new
|
|
1014
|
+
"[deliveredRatio:%f, repairedRatio:%f, repairedWeight:%f, new lostPackets:%" PRIu64
|
|
1029
1015
|
", score:%" PRIu8 "]",
|
|
1030
1016
|
deliveredRatio,
|
|
1031
1017
|
repairedRatio,
|
|
1032
1018
|
repairedWeight,
|
|
1033
|
-
|
|
1019
|
+
lostPackets,
|
|
1034
1020
|
score);
|
|
1035
1021
|
#endif
|
|
1036
1022
|
|