mediasoup 3.27.0 → 3.28.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 +19 -0
- package/node/lib/Consumer.d.ts.map +1 -1
- package/node/lib/Consumer.js +4 -51
- package/node/lib/Producer.d.ts.map +1 -1
- package/node/lib/Producer.js +4 -8
- package/node/lib/ProducerTypes.d.ts +4 -2
- package/node/lib/ProducerTypes.d.ts.map +1 -1
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +4 -0
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +7 -10
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts +3 -4
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts.map +1 -1
- package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.js +3 -4
- package/node/lib/ortc.d.ts +0 -2
- package/node/lib/ortc.d.ts.map +1 -1
- package/node/lib/ortc.js +11 -21
- package/node/lib/rtpMappingFbsUtils.d.ts +6 -0
- package/node/lib/rtpMappingFbsUtils.d.ts.map +1 -0
- package/node/lib/rtpMappingFbsUtils.js +65 -0
- package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
- package/node/lib/rtpParametersFbsUtils.js +0 -6
- package/node/lib/rtpParametersTypes.d.ts +1 -1
- package/node/lib/rtpParametersTypes.d.ts.map +1 -1
- package/node/lib/rtpStreamFbsUtils.d.ts +4 -0
- package/node/lib/rtpStreamFbsUtils.d.ts.map +1 -0
- package/node/lib/rtpStreamFbsUtils.js +51 -0
- package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
- package/node/lib/supportedRtpCapabilities.js +6 -13
- package/node/lib/test/test-Consumer.js +1 -13
- package/node/lib/test/test-DataConsumer.js +9 -0
- package/node/lib/test/test-DataProducer.js +38 -0
- package/node/lib/test/test-PipeTransport.js +27 -29
- package/node/lib/test/test-Producer.js +97 -0
- package/node/lib/test/test-ortc.js +34 -14
- package/package.json +10 -10
- package/worker/fbs/FBS/meson.build +25 -0
- package/worker/fbs/meson.build +15 -18
- package/worker/fbs/rtpParameters.fbs +0 -1
- package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
- package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +16 -2
- package/worker/include/DepLibUV.hpp +13 -0
- package/worker/include/RTC/BWE/AlrDetector.hpp +97 -0
- package/worker/include/RTC/BWE/BitrateProber.hpp +217 -0
- package/worker/include/RTC/BWE/BitrateUtils.hpp +39 -0
- package/worker/include/RTC/BWE/BweTypes.hpp +171 -3
- package/worker/include/RTC/BWE/FeedbackAdapter.hpp +0 -14
- package/worker/include/RTC/BWE/InterArrival.hpp +117 -0
- package/worker/include/RTC/BWE/IntervalBudget.hpp +81 -0
- package/worker/include/RTC/BWE/LossBasedController.hpp +625 -0
- package/worker/include/RTC/BWE/OveruseDetector.hpp +71 -0
- package/worker/include/RTC/BWE/OveruseEstimator.hpp +115 -0
- package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +84 -0
- package/worker/include/RTC/BWE/ProbeController.hpp +379 -0
- package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +130 -0
- package/worker/include/RTC/BWE/ProbingScheduler.hpp +187 -0
- package/worker/include/RTC/BWE/RembGenerator.hpp +96 -0
- package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +237 -0
- package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +26 -0
- package/worker/include/RTC/BWE/SendPacketHistory.hpp +161 -25
- package/worker/include/RTC/BWE/TargetRateController.hpp +306 -0
- package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +146 -0
- package/worker/include/RTC/BWE/TrendlineEstimator.hpp +73 -16
- package/worker/include/RTC/Consts.hpp +70 -0
- package/worker/include/RTC/DataConsumer.hpp +3 -5
- package/worker/include/RTC/DirectTransport.hpp +4 -5
- package/worker/include/RTC/PipeTransport.hpp +4 -5
- package/worker/include/RTC/PlainTransport.hpp +4 -5
- package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +6 -7
- package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +3 -1
- package/worker/include/RTC/RTP/Codecs/Tools.hpp +1 -1
- package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +0 -1
- package/worker/include/RTC/RTP/Packet.hpp +16 -4
- package/worker/include/RTC/RTP/ProbationGenerator.hpp +0 -8
- package/worker/include/RTC/RTP/RtpStream.hpp +12 -9
- package/worker/include/RTC/RTP/RtpStreamRecv.hpp +22 -4
- package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -2
- package/worker/include/RTC/RTP/RtxStream.hpp +10 -4
- package/worker/include/RTC/RateCalculator.hpp +103 -24
- package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +33 -3
- package/worker/include/RTC/{RtcLogger.hpp → RtcLogger/RtpPacket.hpp} +5 -3
- package/worker/include/RTC/RtcLogger/SendBurst.hpp +88 -0
- package/worker/include/RTC/RtpDictionaries.hpp +3 -4
- package/worker/include/RTC/SCTP/association/Association.hpp +1 -1
- package/worker/include/RTC/SCTP/association/StreamResetHandler.hpp +36 -0
- package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +0 -1
- package/worker/include/RTC/SCTP/public/SctpTypes.hpp +9 -9
- package/worker/include/RTC/SCTP/rx/DataTracker.hpp +1 -1
- package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +11 -1
- package/worker/include/RTC/SctpDictionaries.hpp +2 -2
- package/worker/include/RTC/TcpConnection.hpp +2 -1
- package/worker/include/RTC/Transport.hpp +23 -8
- package/worker/include/RTC/TransportTuple.hpp +61 -6
- package/worker/include/RTC/WebRtcTransport.hpp +4 -5
- package/worker/include/Shared.hpp +5 -0
- package/worker/include/SharedInterface.hpp +10 -0
- package/worker/include/Utils.hpp +72 -3
- package/worker/include/common.hpp +12 -4
- package/worker/include/handles/SendCallbacks.hpp +34 -0
- package/worker/include/handles/TcpConnectionHandle.hpp +4 -12
- package/worker/include/handles/UdpSocketHandle.hpp +4 -8
- package/worker/meson.build +45 -1
- package/worker/meson_options.txt +1 -0
- package/worker/mocks/include/MockShared.hpp +16 -2
- package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +1 -1
- package/worker/scripts/package-lock.json +6 -6
- package/worker/src/RTC/BWE/AimdRateControl.cpp +4 -5
- package/worker/src/RTC/BWE/AlrDetector.cpp +80 -0
- package/worker/src/RTC/BWE/BitrateProber.cpp +256 -0
- package/worker/src/RTC/BWE/BitrateUtils.cpp +54 -0
- package/worker/src/RTC/BWE/DelayBasedBwe.cpp +2 -2
- package/worker/src/RTC/BWE/FeedbackAdapter.cpp +20 -37
- package/worker/src/RTC/BWE/InterArrival.cpp +216 -0
- package/worker/src/RTC/BWE/IntervalBudget.cpp +93 -0
- package/worker/src/RTC/BWE/LossBasedController.cpp +1194 -0
- package/worker/src/RTC/BWE/OveruseDetector.cpp +128 -0
- package/worker/src/RTC/BWE/OveruseEstimator.cpp +166 -0
- package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +222 -0
- package/worker/src/RTC/BWE/ProbeController.cpp +645 -0
- package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +140 -0
- package/worker/src/RTC/BWE/ProbingScheduler.cpp +196 -0
- package/worker/src/RTC/BWE/RembGenerator.cpp +169 -0
- package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +497 -0
- package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +47 -0
- package/worker/src/RTC/BWE/SendPacketHistory.cpp +173 -50
- package/worker/src/RTC/BWE/TargetRateController.cpp +433 -0
- package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +377 -0
- package/worker/src/RTC/BWE/TrendlineEstimator.cpp +102 -5
- package/worker/src/RTC/Consumer.cpp +7 -5
- package/worker/src/RTC/DataConsumer.cpp +8 -10
- package/worker/src/RTC/DirectTransport.cpp +14 -8
- package/worker/src/RTC/DtlsTransport.cpp +8 -8
- package/worker/src/RTC/ICE/IceCandidate.cpp +4 -4
- package/worker/src/RTC/ICE/IceServer.cpp +1 -1
- package/worker/src/RTC/PipeTransport.cpp +13 -8
- package/worker/src/RTC/PlainTransport.cpp +13 -8
- package/worker/src/RTC/Producer.cpp +14 -31
- package/worker/src/RTC/RTCP/Bye.cpp +1 -1
- package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +18 -0
- package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +2 -2
- package/worker/src/RTC/RTCP/FeedbackPsVbcm.cpp +2 -1
- package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +2 -2
- package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
- package/worker/src/RTC/RTP/Codecs/DependencyDescriptor.cpp +2 -1
- package/worker/src/RTC/RTP/Packet.cpp +26 -11
- package/worker/src/RTC/RTP/ProbationGenerator.cpp +5 -6
- package/worker/src/RTC/RTP/RtpStream.cpp +1 -1
- package/worker/src/RTC/RTP/RtpStreamRecv.cpp +69 -48
- package/worker/src/RTC/RTP/RtpStreamSend.cpp +31 -31
- package/worker/src/RTC/RTP/RtxStream.cpp +22 -7
- package/worker/src/RTC/RateCalculator.cpp +133 -28
- package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +56 -1
- package/worker/src/RTC/{RtcLogger.cpp → RtcLogger/RtpPacket.cpp} +2 -2
- package/worker/src/RTC/RtcLogger/SendBurst.cpp +124 -0
- package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +2 -12
- package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +1 -1
- package/worker/src/RTC/SCTP/association/Association.cpp +16 -2
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +106 -1
- package/worker/src/RTC/SCTP/public/AssociationMetrics.cpp +1 -1
- package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +3 -3
- package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
- package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +4 -4
- package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +4 -4
- package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +6 -10
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +2 -2
- package/worker/src/RTC/SrtpSession.cpp +2 -2
- package/worker/src/RTC/SvcProducerStreamManager.cpp +2 -2
- package/worker/src/RTC/TcpConnection.cpp +2 -2
- package/worker/src/RTC/Transport.cpp +112 -75
- package/worker/src/RTC/TransportTuple.cpp +4 -4
- package/worker/src/RTC/WebRtcServer.cpp +4 -3
- package/worker/src/RTC/WebRtcTransport.cpp +20 -13
- package/worker/src/Utils/BitStream.cpp +24 -0
- package/worker/src/handles/BackoffTimerHandle.cpp +1 -1
- package/worker/src/handles/TcpConnectionHandle.cpp +13 -23
- package/worker/src/handles/UdpSocketHandle.cpp +14 -21
- package/worker/tasks.py +43 -18
- package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +68 -14
- package/worker/test/include/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.hpp +125 -0
- package/worker/test/src/RTC/BWE/TestAlrDetector.cpp +110 -0
- package/worker/test/src/RTC/BWE/TestBitrateProber.cpp +418 -0
- package/worker/test/src/RTC/BWE/TestBitrateUtils.cpp +61 -0
- package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +4 -4
- package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +53 -37
- package/worker/test/src/RTC/BWE/TestInterArrival.cpp +643 -0
- package/worker/test/src/RTC/BWE/TestIntervalBudget.cpp +130 -0
- package/worker/test/src/RTC/BWE/TestLossBasedController.cpp +1199 -0
- package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +519 -0
- package/worker/test/src/RTC/BWE/TestProbeBitrateEstimator.cpp +266 -0
- package/worker/test/src/RTC/BWE/TestProbeController.cpp +1682 -0
- package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +265 -0
- package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +260 -0
- package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +285 -0
- package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +414 -0
- package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +296 -77
- package/worker/test/src/RTC/BWE/TestTargetRateController.cpp +337 -0
- package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +578 -0
- package/worker/test/src/RTC/BWE/TestTrendlineEstimator.cpp +45 -0
- package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +133 -29
- package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +625 -0
- package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +19 -0
- package/worker/test/src/RTC/RTP/TestPacket.cpp +58 -4
- package/worker/test/src/RTC/RTP/TestProbationGenerator.cpp +3 -2
- package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +50 -0
- package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +59 -0
- package/worker/test/src/RTC/SCTP/association/TestStreamResetHandler.cpp +111 -0
- package/worker/test/src/RTC/TestRateCalculator.cpp +322 -60
- package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +95 -7
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +34 -16
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +31 -13
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +37 -19
- package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +10 -10
- package/worker/test/src/Utils/TestTime.cpp +120 -21
|
@@ -16,12 +16,25 @@ namespace RTC
|
|
|
16
16
|
* and GetRate() are O(1) amortized.
|
|
17
17
|
*
|
|
18
18
|
* It is considered that the time source increases monotonically. Timestamps
|
|
19
|
-
* going backwards are however tolerated (time comparisons are wrap safe):
|
|
20
|
-
* data
|
|
21
|
-
*
|
|
19
|
+
* going backwards are however tolerated (time comparisons are wrap safe): no
|
|
20
|
+
* data is ever lost nor expired ahead of time, and whatever is given with an
|
|
21
|
+
* instant that is not newer than the newest item is added to that item.
|
|
22
22
|
*/
|
|
23
23
|
class RateCalculator
|
|
24
24
|
{
|
|
25
|
+
private:
|
|
26
|
+
struct Item
|
|
27
|
+
{
|
|
28
|
+
/**
|
|
29
|
+
* Sum of the sizes given to Update() within this item.
|
|
30
|
+
*/
|
|
31
|
+
uint64_t count{ 0 };
|
|
32
|
+
/**
|
|
33
|
+
* Number of Update() calls accounted for within this item.
|
|
34
|
+
*/
|
|
35
|
+
uint64_t samples{ 0 };
|
|
36
|
+
};
|
|
37
|
+
|
|
25
38
|
public:
|
|
26
39
|
static constexpr int64_t DefaultWindowSizeMs{ 1000 };
|
|
27
40
|
static constexpr float DefaultBpsScale{ 8000.0f };
|
|
@@ -33,11 +46,43 @@ namespace RTC
|
|
|
33
46
|
float scale = DefaultBpsScale,
|
|
34
47
|
uint16_t windowItems = DefaultWindowItems);
|
|
35
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Accounts for `size` units of data taken at `nowMs`.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* - A sample that arrives when the window holds none starts a new measured
|
|
54
|
+
* period, unless the previous sample is recent enough for both to be taken
|
|
55
|
+
* as the same stretch of traffic. That is what keeps a stream which sends
|
|
56
|
+
* less often than the window from restarting its period at every sample and
|
|
57
|
+
* hence never being measured at all.
|
|
58
|
+
*/
|
|
36
59
|
void Update(size_t size, int64_t nowMs);
|
|
37
60
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Rate of the data within the window ending at `nowMs`, computed over the
|
|
63
|
+
* period the data actually spans rather than over the whole window, so that
|
|
64
|
+
* a window which has not filled yet is not reported as a fraction of the
|
|
65
|
+
* rate it is measuring.
|
|
66
|
+
*
|
|
67
|
+
* While that period starts at a sample rather than at the edge of the window,
|
|
68
|
+
* the data of that sample is left out, since the period does not cover the
|
|
69
|
+
* time it took to arrive.
|
|
70
|
+
*
|
|
71
|
+
* Returns no value when there is nothing to measure, which is any of:
|
|
72
|
+
*
|
|
73
|
+
* - Not a single sample within the window.
|
|
74
|
+
* - A period of a single millisecond, which gives no duration to divide by.
|
|
75
|
+
* - A single sample while the window has not filled, since one sample says
|
|
76
|
+
* how much data arrived at an instant but nothing about how fast it is
|
|
77
|
+
* arriving.
|
|
78
|
+
*
|
|
79
|
+
* Returns zero when there are enough samples to measure but the data they
|
|
80
|
+
* add up to rounds down to zero at the configured scale, which takes
|
|
81
|
+
* Update() calls of size zero.
|
|
82
|
+
*/
|
|
83
|
+
std::optional<int64_t> GetRate(int64_t nowMs);
|
|
84
|
+
|
|
85
|
+
uint64_t GetBytes() const
|
|
41
86
|
{
|
|
42
87
|
return this->bytes;
|
|
43
88
|
}
|
|
@@ -52,31 +97,56 @@ namespace RTC
|
|
|
52
97
|
int64_t windowSizeMs{ DefaultWindowSizeMs };
|
|
53
98
|
// Item size (in milliseconds). Always >= 1.
|
|
54
99
|
int64_t itemSizeMs{ 1 };
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
|
|
100
|
+
// Factor the in-window count is multiplied by before being divided by the
|
|
101
|
+
// period it spans.
|
|
102
|
+
double scale{ 0.0 };
|
|
103
|
+
// How long after a sample the next one still counts as the same stretch of
|
|
104
|
+
// traffic (in milliseconds). Derived from the window size.
|
|
105
|
+
int64_t recentSampleMarginMs{ 0 };
|
|
106
|
+
// Ring of items. Never empty, and always long enough to cover the whole
|
|
107
|
+
// window.
|
|
108
|
+
std::vector<Item> buffer;
|
|
60
109
|
// Index of the newest item. Always < buffer.size().
|
|
61
110
|
size_t newestItemIndex{ 0 };
|
|
62
111
|
// Time (in milliseconds) at which the newest item starts.
|
|
63
112
|
int64_t newestItemStartTimeMs{ 0 };
|
|
113
|
+
// Time (in milliseconds) at which the measured period starts. Unset until the
|
|
114
|
+
// very first sample, and from then on only ever moved forward by a sample
|
|
115
|
+
// that finds the window empty after long enough without traffic.
|
|
116
|
+
// NOTE: Expiration does not move it, so once the data reaches back beyond the
|
|
117
|
+
// window it names a sample that is already gone. That is on purpose: from
|
|
118
|
+
// that point on the period is the window itself, which is what the reader
|
|
119
|
+
// clamps it to.
|
|
120
|
+
std::optional<int64_t> firstSampleTimeMs;
|
|
121
|
+
// Count of the sample that starts the measured period, which is left out of
|
|
122
|
+
// the rate for as long as the period is anchored to it.
|
|
123
|
+
uint64_t firstSampleCount{ 0 };
|
|
124
|
+
// Time (in milliseconds) of the latest sample, which together with the window
|
|
125
|
+
// still holding it is what tells a stream that simply sends less often than
|
|
126
|
+
// the window apart from one that stopped.
|
|
127
|
+
std::optional<int64_t> lastSampleTimeMs;
|
|
64
128
|
// Sum of the count of every item.
|
|
65
|
-
|
|
129
|
+
uint64_t totalCount{ 0 };
|
|
130
|
+
// Sum of the samples of every item.
|
|
131
|
+
uint64_t totalSamples{ 0 };
|
|
66
132
|
// Total bytes accounted for. Not affected by Reset().
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
//
|
|
133
|
+
// NOTE: Nothing bounds this one, unlike the in-window total above, so it is
|
|
134
|
+
// as wide as the stats field it ends up in.
|
|
135
|
+
uint64_t bytes{ 0 };
|
|
136
|
+
// Rate memoized by GetRate(), only valid while `lastTimeMs`,
|
|
137
|
+
// `lastTotalCount` and `lastTotalSamples` below all still match.
|
|
138
|
+
// `lastTotalSamples` is the one that makes any Update() invalidate this
|
|
139
|
+
// implicitly, so that the hot path needs no memoization store.
|
|
72
140
|
// NOTE: No "not calculated yet" mark is needed, since the initial and post
|
|
73
|
-
// Reset() state is a valid entry on its own:
|
|
74
|
-
int64_t lastRate
|
|
141
|
+
// Reset() state is a valid entry on its own: no rate for no samples.
|
|
142
|
+
std::optional<int64_t> lastRate;
|
|
75
143
|
// Time of the latest GetRate() call. Prevents reusing `lastRate` once time
|
|
76
144
|
// has moved on and there is data pending expiration.
|
|
77
145
|
int64_t lastTimeMs{ 0 };
|
|
78
146
|
// Total count at the latest GetRate() call.
|
|
79
|
-
|
|
147
|
+
uint64_t lastTotalCount{ 0 };
|
|
148
|
+
// Total samples at the latest GetRate() call.
|
|
149
|
+
uint64_t lastTotalSamples{ 0 };
|
|
80
150
|
};
|
|
81
151
|
|
|
82
152
|
class RtpDataCounter
|
|
@@ -91,17 +161,25 @@ namespace RTC
|
|
|
91
161
|
public:
|
|
92
162
|
void Update(const RTC::RTP::Packet* packet);
|
|
93
163
|
|
|
94
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Bitrate (bps) of the RTP traffic within the window ending at `nowMs`,
|
|
166
|
+
* measured over the period that traffic actually spans.
|
|
167
|
+
*
|
|
168
|
+
* @returns No value while there is nothing to measure, which is any of: no
|
|
169
|
+
* packet within the window, a period of a single millisecond, and a single
|
|
170
|
+
* packet while the window has not filled.
|
|
171
|
+
*/
|
|
172
|
+
std::optional<int64_t> GetBitrate(int64_t nowMs)
|
|
95
173
|
{
|
|
96
174
|
return this->rate.GetRate(nowMs);
|
|
97
175
|
}
|
|
98
176
|
|
|
99
|
-
|
|
177
|
+
uint64_t GetPacketCount() const
|
|
100
178
|
{
|
|
101
179
|
return this->packets;
|
|
102
180
|
}
|
|
103
181
|
|
|
104
|
-
|
|
182
|
+
uint64_t GetBytes() const
|
|
105
183
|
{
|
|
106
184
|
return this->rate.GetBytes();
|
|
107
185
|
}
|
|
@@ -112,7 +190,8 @@ namespace RTC
|
|
|
112
190
|
// account.
|
|
113
191
|
bool ignorePaddingOnlyPackets{ false };
|
|
114
192
|
RateCalculator rate;
|
|
115
|
-
|
|
193
|
+
// Total packets accounted for, which nothing bounds either.
|
|
194
|
+
uint64_t packets{ 0 };
|
|
116
195
|
};
|
|
117
196
|
} // namespace RTC
|
|
118
197
|
|
|
@@ -14,14 +14,19 @@ namespace RTC
|
|
|
14
14
|
* The capture instant is read from one of two sources, and the same one is used
|
|
15
15
|
* for every stream of the sender. Mixing them would reintroduce the very inter
|
|
16
16
|
* stream skew this is meant to remove, since they do not carry the same residual
|
|
17
|
-
* error:
|
|
17
|
+
* error: 'abs-capture-time' is exact while a Sender Report is biased by its own
|
|
18
18
|
* one way delay.
|
|
19
19
|
*
|
|
20
20
|
* The source is chosen from what the Producers of the sender negotiated. The
|
|
21
21
|
* first Producer chooses it, and a single Producer that did not negotiate
|
|
22
|
-
*
|
|
22
|
+
* 'abs-capture-time' moves it to Sender Report for the rest of the life of this
|
|
23
23
|
* object, never back.
|
|
24
24
|
*
|
|
25
|
+
* A sender may negotiate that extension and then never send it, which would
|
|
26
|
+
* leave every stream of it without a capture instant forever. So the source also
|
|
27
|
+
* falls back to Sender Report when no stream of this sender has carried the
|
|
28
|
+
* extension for long enough since its first packet.
|
|
29
|
+
*
|
|
25
30
|
* A single instance is meant to be shared by all the RTP streams of a given
|
|
26
31
|
* CNAME, which is what identifies media coming from a same machine and hence
|
|
27
32
|
* from a same wall clock.
|
|
@@ -76,17 +81,42 @@ namespace RTC
|
|
|
76
81
|
*
|
|
77
82
|
* @param rtpStream - RTP stream the RTP timestamp belongs to.
|
|
78
83
|
* @param ts - RTP timestamp whose capture instant is wanted.
|
|
84
|
+
* @param nowUs - Current instant, which is also what the fall back to Sender
|
|
85
|
+
* Report is timed against.
|
|
79
86
|
*
|
|
80
87
|
* @returns No value while the capture instant cannot be told yet.
|
|
81
88
|
*/
|
|
82
89
|
std::optional<int64_t> GetLocalCaptureAtUs(
|
|
83
|
-
const RTC::RTP::RtpStreamRecv* rtpStream, uint32_t ts)
|
|
90
|
+
const RTC::RTP::RtpStreamRecv* rtpStream, uint32_t ts, int64_t nowUs);
|
|
91
|
+
|
|
92
|
+
private:
|
|
93
|
+
/**
|
|
94
|
+
* Move the source to Sender Report when 'abs-capture-time' was negotiated but
|
|
95
|
+
* no stream of this sender has ever carried it, which is told apart from it
|
|
96
|
+
* being merely early by how long this sender has been sending.
|
|
97
|
+
*
|
|
98
|
+
* @param rtpStream - RTP stream whose packet is being looked at.
|
|
99
|
+
* @param nowUs - Current instant.
|
|
100
|
+
*/
|
|
101
|
+
void MayFallBackToSenderReport(const RTC::RTP::RtpStreamRecv* rtpStream, int64_t nowUs);
|
|
84
102
|
|
|
85
103
|
private:
|
|
86
104
|
// Offset between the wall clock of the sender and our monotonic one.
|
|
87
105
|
RTC::RemoteClockOffsetEstimator clockOffsetEstimator;
|
|
88
106
|
// Source the capture instant is read from, for every stream of this sender.
|
|
89
107
|
std::optional<Source> source;
|
|
108
|
+
// Instant the first packet of this sender was asked about, or no value until
|
|
109
|
+
// then. The fall back to Sender Report is measured against it, so it must be
|
|
110
|
+
// something that exists even when the extension never arrives.
|
|
111
|
+
//
|
|
112
|
+
// NOTE: Not every packet is asked about, only the one holding the highest RTP
|
|
113
|
+
// timestamp of its stream, so this is the first one that got here rather than
|
|
114
|
+
// the first one that arrived.
|
|
115
|
+
std::optional<int64_t> firstPacketAtUs;
|
|
116
|
+
// Whether any stream of this sender has ever carried 'abs-capture-time', which
|
|
117
|
+
// is what tells a sender that does not send it from a stream whose first
|
|
118
|
+
// packets carrying it are still on their way.
|
|
119
|
+
bool absCaptureTimeReceived{ false };
|
|
90
120
|
};
|
|
91
121
|
} // namespace RTC
|
|
92
122
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
#ifndef
|
|
2
|
-
#define
|
|
1
|
+
#ifndef MS_RTC_RTC_LOGGER_RTP_PACKET_HPP
|
|
2
|
+
#define MS_RTC_RTC_LOGGER_RTP_PACKET_HPP
|
|
3
3
|
|
|
4
4
|
#include "common.hpp"
|
|
5
5
|
#include <ankerl/unordered_dense.h>
|
|
6
|
+
#include <string>
|
|
6
7
|
|
|
7
8
|
namespace RTC
|
|
8
9
|
{
|
|
@@ -55,6 +56,7 @@ namespace RTC
|
|
|
55
56
|
bool discarded{};
|
|
56
57
|
DiscardReason discardReason{ DiscardReason::NONE };
|
|
57
58
|
};
|
|
58
|
-
}
|
|
59
|
+
} // namespace RtcLogger
|
|
59
60
|
} // namespace RTC
|
|
61
|
+
|
|
60
62
|
#endif
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#ifndef MS_RTC_RTC_LOGGER_SEND_BURST_HPP
|
|
2
|
+
#define MS_RTC_RTC_LOGGER_SEND_BURST_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace RtcLogger
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* How many RTP packets a transport sends within a single iteration of the event
|
|
14
|
+
* loop.
|
|
15
|
+
*
|
|
16
|
+
* Nothing spaces those packets out, so a whole iteration's worth of them reaches
|
|
17
|
+
* the wire back to back and lands in the first queue of the path as a single
|
|
18
|
+
* lump. This gathers how big those lumps are and how much of each one is
|
|
19
|
+
* retransmissions, which is what says whether there is anything worth pacing.
|
|
20
|
+
*/
|
|
21
|
+
class SendBurst
|
|
22
|
+
{
|
|
23
|
+
private:
|
|
24
|
+
/**
|
|
25
|
+
* What all the bursts of a given size added up to.
|
|
26
|
+
*/
|
|
27
|
+
struct Counters
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* How many of them there were.
|
|
31
|
+
*/
|
|
32
|
+
uint64_t count{ 0 };
|
|
33
|
+
/**
|
|
34
|
+
* Retransmissions they carried between all of them, so that the tail of
|
|
35
|
+
* the distribution can be attributed.
|
|
36
|
+
*/
|
|
37
|
+
uint64_t retransmissions{ 0 };
|
|
38
|
+
/**
|
|
39
|
+
* Probation packets they carried between all of them.
|
|
40
|
+
*/
|
|
41
|
+
uint64_t probations{ 0 };
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
SendBurst() = default;
|
|
46
|
+
~SendBurst() = default;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Account for a packet that is about to be sent.
|
|
50
|
+
*
|
|
51
|
+
* @param loopTimeMs - Time at which the current iteration of the event loop
|
|
52
|
+
* began, which is what tells one burst from the next.
|
|
53
|
+
*/
|
|
54
|
+
void Sent(uint64_t loopTimeMs, size_t length, bool isRetransmission, bool isProbation);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Print what has been gathered so far and start over.
|
|
58
|
+
*/
|
|
59
|
+
void Log();
|
|
60
|
+
|
|
61
|
+
private:
|
|
62
|
+
/**
|
|
63
|
+
* Add the burst in progress, if there is one, to the distribution.
|
|
64
|
+
*/
|
|
65
|
+
void CloseBurst();
|
|
66
|
+
|
|
67
|
+
void Clear();
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
std::string transportId;
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
// Time of the iteration of the event loop that the burst in progress belongs
|
|
74
|
+
// to.
|
|
75
|
+
uint64_t loopTimeMs{ 0 };
|
|
76
|
+
size_t packets{ 0 };
|
|
77
|
+
size_t retransmissions{ 0 };
|
|
78
|
+
size_t probations{ 0 };
|
|
79
|
+
size_t bytes{ 0 };
|
|
80
|
+
// Bursts seen, keyed by how many packets each of them carried.
|
|
81
|
+
std::map<size_t /*packets*/, Counters> bursts;
|
|
82
|
+
size_t maxPackets{ 0 };
|
|
83
|
+
size_t maxBytes{ 0 };
|
|
84
|
+
};
|
|
85
|
+
} // namespace RtcLogger
|
|
86
|
+
} // namespace RTC
|
|
87
|
+
|
|
88
|
+
#endif
|
|
@@ -123,10 +123,9 @@ namespace RTC
|
|
|
123
123
|
SSRC_AUDIO_LEVEL = 6,
|
|
124
124
|
DEPENDENCY_DESCRIPTOR = 7,
|
|
125
125
|
VIDEO_ORIENTATION = 8,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
MEDIASOUP_PACKET_ID = 12
|
|
126
|
+
ABS_CAPTURE_TIME = 9,
|
|
127
|
+
PLAYOUT_DELAY = 10,
|
|
128
|
+
MEDIASOUP_PACKET_ID = 11
|
|
130
129
|
};
|
|
131
130
|
|
|
132
131
|
public:
|
|
@@ -163,6 +163,25 @@ namespace RTC
|
|
|
163
163
|
bool isDeferred{ false };
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Represents a received outgoing stream reset request whose processing
|
|
168
|
+
* had to be deferred because the sender's last assigned TSN had not been
|
|
169
|
+
* reached yet (aka "deferred reset processing").
|
|
170
|
+
*/
|
|
171
|
+
struct DeferredIncomingRequest
|
|
172
|
+
{
|
|
173
|
+
/**
|
|
174
|
+
* The sender's (that's the peer) last assigned TSN. Deferred reset
|
|
175
|
+
* processing must end once the cumulative ack TSN reaches it.
|
|
176
|
+
*/
|
|
177
|
+
uint32_t senderLastAssignedTsn;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The streams that are to be reset.
|
|
181
|
+
*/
|
|
182
|
+
std::vector<uint16_t> streamIds;
|
|
183
|
+
};
|
|
184
|
+
|
|
166
185
|
private:
|
|
167
186
|
using UnwrappedReConfigRequestSn = Utils::UnwrappedSequenceNumber<uint32_t>;
|
|
168
187
|
|
|
@@ -211,6 +230,18 @@ namespace RTC
|
|
|
211
230
|
*/
|
|
212
231
|
void HandleReceivedReConfigChunk(const ReConfigChunk* receivedReConfigChunk);
|
|
213
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Called at the end of processing a received SCTP packet. If this
|
|
235
|
+
* association is in "deferred reset processing" and the cumulative ack TSN
|
|
236
|
+
* has reached the sender's last assigned TSN, the deferred stream reset is
|
|
237
|
+
* performed and deferred reset processing ends.
|
|
238
|
+
*
|
|
239
|
+
* Returns `true` if deferred reset processing ended, in which case the
|
|
240
|
+
* chunks queued while it lasted have been released and there may be
|
|
241
|
+
* messages to deliver.
|
|
242
|
+
*/
|
|
243
|
+
bool MayLeaveDeferredReset();
|
|
244
|
+
|
|
214
245
|
private:
|
|
215
246
|
/**
|
|
216
247
|
* Called to validate a received RE-CONFIG chunk.
|
|
@@ -279,6 +310,11 @@ namespace RTC
|
|
|
279
310
|
ReconfigurationResponseParameter::Result lastProcessedReqResult;
|
|
280
311
|
// The current stream request operation.
|
|
281
312
|
std::optional<CurrentRequest> currentRequest;
|
|
313
|
+
// The received request being deferred, if in deferred reset processing.
|
|
314
|
+
std::optional<DeferredIncomingRequest> deferredIncomingRequest;
|
|
315
|
+
// The received request that was performed when deferred reset processing
|
|
316
|
+
// ended, until the peer retries it and gets the final response.
|
|
317
|
+
std::optional<DeferredIncomingRequest> performedDeferredRequest;
|
|
282
318
|
};
|
|
283
319
|
} // namespace SCTP
|
|
284
320
|
} // namespace RTC
|
|
@@ -48,7 +48,7 @@ namespace RTC
|
|
|
48
48
|
SHUTTING_DOWN
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
constexpr std::string_view
|
|
51
|
+
constexpr std::string_view associationStateToString(AssociationState associationState)
|
|
52
52
|
{
|
|
53
53
|
switch (associationState)
|
|
54
54
|
{
|
|
@@ -77,7 +77,7 @@ namespace RTC
|
|
|
77
77
|
return "SHUTTING_DOWN";
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
NO_DEFAULT();
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -128,7 +128,7 @@ namespace RTC
|
|
|
128
128
|
UNSUPPORTED_OPERATION
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
constexpr std::string_view
|
|
131
|
+
constexpr std::string_view errorKindToString(ErrorKind errorKind)
|
|
132
132
|
{
|
|
133
133
|
switch (errorKind)
|
|
134
134
|
{
|
|
@@ -179,7 +179,7 @@ namespace RTC
|
|
|
179
179
|
return "UNSUPPORTED_OPERATION";
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
NO_DEFAULT();
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -195,7 +195,7 @@ namespace RTC
|
|
|
195
195
|
USRSCTP
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
constexpr std::string_view
|
|
198
|
+
constexpr std::string_view sctpImplementationToString(SctpImplementation sctpImplementation)
|
|
199
199
|
{
|
|
200
200
|
switch (sctpImplementation)
|
|
201
201
|
{
|
|
@@ -219,7 +219,7 @@ namespace RTC
|
|
|
219
219
|
return "usrsctp";
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
NO_DEFAULT();
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -246,7 +246,7 @@ namespace RTC
|
|
|
246
246
|
NOT_SUPPORTED
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
constexpr std::string_view
|
|
249
|
+
constexpr std::string_view resetStreamsStatusToString(ResetStreamsStatus status)
|
|
250
250
|
{
|
|
251
251
|
switch (status)
|
|
252
252
|
{
|
|
@@ -303,7 +303,7 @@ namespace RTC
|
|
|
303
303
|
ERROR_SHUTTING_DOWN
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
-
constexpr std::string_view
|
|
306
|
+
constexpr std::string_view sendMessageStatusToString(SendMessageStatus status)
|
|
307
307
|
{
|
|
308
308
|
switch (status)
|
|
309
309
|
{
|
|
@@ -332,7 +332,7 @@ namespace RTC
|
|
|
332
332
|
return "ERROR_SHUTTING_DOWN";
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
NO_DEFAULT();
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
|
|
@@ -57,7 +57,7 @@ namespace RTC
|
|
|
57
57
|
* SCTP association should restrict incoming data to avoid filling up the
|
|
58
58
|
* queue.
|
|
59
59
|
*/
|
|
60
|
-
static constexpr
|
|
60
|
+
static constexpr double HighWatermarkLimit{ 0.9 };
|
|
61
61
|
|
|
62
62
|
private:
|
|
63
63
|
struct DeferredResetStreams
|
|
@@ -141,9 +141,19 @@ namespace RTC
|
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* The remaining bytes until the queue has reached the watermark limit.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* - The queued bytes are allowed to go above the watermark limit (data is
|
|
147
|
+
* only rejected once the queue is full), so this returns 0 rather than
|
|
148
|
+
* wrapping around.
|
|
144
149
|
*/
|
|
145
150
|
size_t GetRemainingBytes() const
|
|
146
151
|
{
|
|
152
|
+
if (this->queuedBytes >= this->watermarkBytes)
|
|
153
|
+
{
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
return this->watermarkBytes - this->queuedBytes;
|
|
148
158
|
}
|
|
149
159
|
|
|
@@ -18,8 +18,8 @@ namespace RTC
|
|
|
18
18
|
public:
|
|
19
19
|
uint16_t streamId{ 0 };
|
|
20
20
|
bool ordered{ true };
|
|
21
|
-
uint16_t maxPacketLifeTime
|
|
22
|
-
uint16_t maxRetransmits
|
|
21
|
+
std::optional<uint16_t> maxPacketLifeTime;
|
|
22
|
+
std::optional<uint16_t> maxRetransmits;
|
|
23
23
|
};
|
|
24
24
|
} // namespace RTC
|
|
25
25
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define MS_RTC_TCP_CONNECTION_HPP
|
|
3
3
|
|
|
4
4
|
#include "common.hpp"
|
|
5
|
+
#include "handles/SendCallbacks.hpp"
|
|
5
6
|
#include "handles/TcpConnectionHandle.hpp"
|
|
6
7
|
#include "SharedInterface.hpp"
|
|
7
8
|
|
|
@@ -29,7 +30,7 @@ namespace RTC
|
|
|
29
30
|
~TcpConnection() override;
|
|
30
31
|
|
|
31
32
|
public:
|
|
32
|
-
void Send(const uint8_t* data, size_t len,
|
|
33
|
+
void Send(const uint8_t* data, size_t len, onSendCallback cb);
|
|
33
34
|
|
|
34
35
|
/* Pure virtual methods inherited from ::TcpConnectionHandle. */
|
|
35
36
|
public:
|