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
|
@@ -90,11 +90,11 @@ namespace RTC
|
|
|
90
90
|
* Feed what the delay based detector says about the network.
|
|
91
91
|
*
|
|
92
92
|
* @param input - State of the network plus the acknowledged bitrate.
|
|
93
|
-
* @param
|
|
93
|
+
* @param nowUs - Current time.
|
|
94
94
|
*
|
|
95
95
|
* @returns The new target bitrate (bps).
|
|
96
96
|
*/
|
|
97
|
-
int64_t Update(const Types::RateControlInput& input, int64_t
|
|
97
|
+
int64_t Update(const Types::RateControlInput& input, int64_t nowUs);
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Set the target bitrate from outside the rate control, for instance out of
|
|
@@ -102,7 +102,7 @@ namespace RTC
|
|
|
102
102
|
*
|
|
103
103
|
* @param bitrate - New target bitrate (bps).
|
|
104
104
|
*/
|
|
105
|
-
void SetEstimate(int64_t bitrate, int64_t
|
|
105
|
+
void SetEstimate(int64_t bitrate, int64_t nowUs);
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* @param startBitrate - Bitrate to start from (bps).
|
|
@@ -126,13 +126,13 @@ namespace RTC
|
|
|
126
126
|
* below the current target. It's what keeps a single overuse from
|
|
127
127
|
* collapsing the bitrate in a few milliseconds.
|
|
128
128
|
*/
|
|
129
|
-
bool IsTimeToReduceFurther(int64_t
|
|
129
|
+
bool IsTimeToReduceFurther(int64_t nowUs, int64_t estimatedThroughput) const;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* As above, to be used when overusing before any throughput has been
|
|
133
133
|
* measured.
|
|
134
134
|
*/
|
|
135
|
-
bool IsInitialTimeToReduceFurther(int64_t
|
|
135
|
+
bool IsInitialTimeToReduceFurther(int64_t nowUs) const;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Rate at which the bitrate is increased once it's close to the capacity of
|
|
@@ -147,9 +147,9 @@ namespace RTC
|
|
|
147
147
|
int64_t GetFeedbackIntervalUs() const;
|
|
148
148
|
|
|
149
149
|
private:
|
|
150
|
-
void ChangeBitrate(const Types::RateControlInput& input, int64_t
|
|
150
|
+
void ChangeBitrate(const Types::RateControlInput& input, int64_t nowUs);
|
|
151
151
|
|
|
152
|
-
void ChangeState(const Types::RateControlInput& input, int64_t
|
|
152
|
+
void ChangeState(const Types::RateControlInput& input, int64_t nowUs);
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Apply the configured bounds to a candidate bitrate.
|
|
@@ -161,13 +161,13 @@ namespace RTC
|
|
|
161
161
|
* fast to discover it.
|
|
162
162
|
*/
|
|
163
163
|
int64_t MultiplicativeRateIncrease(
|
|
164
|
-
int64_t
|
|
164
|
+
int64_t nowUs, std::optional<int64_t> lastTimeUs, int64_t currentBitrate) const;
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Increase used once the capacity of the link has been estimated, which
|
|
168
168
|
* approaches it in small steps.
|
|
169
169
|
*/
|
|
170
|
-
int64_t AdditiveRateIncrease(int64_t
|
|
170
|
+
int64_t AdditiveRateIncrease(int64_t nowUs, int64_t lastTimeUs) const;
|
|
171
171
|
|
|
172
172
|
private:
|
|
173
173
|
const AimdRateControlOptions options;
|
|
@@ -23,31 +23,42 @@ namespace RTC
|
|
|
23
23
|
constexpr int64_t TimeUsInfinite{ std::numeric_limits<int64_t>::max() };
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @see https://www.rfc-editor.org/rfc/rfc9331.html
|
|
26
|
+
* Which RTCP mechanism the two endpoints negotiated to deal with
|
|
27
|
+
* congestion, which is what decides on which of them the estimation is
|
|
28
|
+
* computed.
|
|
30
29
|
*/
|
|
31
|
-
enum class
|
|
30
|
+
enum class CongestionControlType : uint8_t
|
|
32
31
|
{
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
NOT_ECT = 0b00,
|
|
37
|
-
/**
|
|
38
|
-
* ECN capable transport, which is the one L4S uses.
|
|
39
|
-
*/
|
|
40
|
-
ECT1 = 0b01,
|
|
41
|
-
/**
|
|
42
|
-
* ECN capable transport, not used by L4S.
|
|
33
|
+
* The receiving endpoint reports when each packet arrived and the
|
|
34
|
+
* sending one estimates from that.
|
|
43
35
|
*/
|
|
44
|
-
|
|
36
|
+
TRANSPORT_CC = 1,
|
|
45
37
|
/**
|
|
46
|
-
*
|
|
38
|
+
* The receiving endpoint estimates and tells the sending one how much
|
|
39
|
+
* it may send.
|
|
47
40
|
*/
|
|
48
|
-
|
|
41
|
+
REMB = 2
|
|
49
42
|
};
|
|
50
43
|
|
|
44
|
+
constexpr std::string_view congestionControlTypeToString(CongestionControlType congestionControlType)
|
|
45
|
+
{
|
|
46
|
+
switch (congestionControlType)
|
|
47
|
+
{
|
|
48
|
+
case CongestionControlType::TRANSPORT_CC:
|
|
49
|
+
{
|
|
50
|
+
return "TRANSPORT_CC";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case CongestionControlType::REMB:
|
|
54
|
+
{
|
|
55
|
+
return "REMB";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
NO_DEFAULT();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
/**
|
|
52
63
|
* How the network is behaving according to the delay based detector.
|
|
53
64
|
*/
|
|
@@ -90,6 +101,32 @@ namespace RTC
|
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The two bits of the IP header with which the network tells that it is
|
|
106
|
+
* congested instead of dropping the packet.
|
|
107
|
+
*
|
|
108
|
+
* @see https://www.rfc-editor.org/rfc/rfc9331.html
|
|
109
|
+
*/
|
|
110
|
+
enum class EcnMarking : uint8_t
|
|
111
|
+
{
|
|
112
|
+
/**
|
|
113
|
+
* Not ECN capable transport.
|
|
114
|
+
*/
|
|
115
|
+
NOT_ECT = 0b00,
|
|
116
|
+
/**
|
|
117
|
+
* ECN capable transport, which is the one L4S uses.
|
|
118
|
+
*/
|
|
119
|
+
ECT1 = 0b01,
|
|
120
|
+
/**
|
|
121
|
+
* ECN capable transport, not used by L4S.
|
|
122
|
+
*/
|
|
123
|
+
ECT0 = 0b10,
|
|
124
|
+
/**
|
|
125
|
+
* Congestion experienced, which is what the network sets on the way.
|
|
126
|
+
*/
|
|
127
|
+
CE = 0b11
|
|
128
|
+
};
|
|
129
|
+
|
|
93
130
|
/**
|
|
94
131
|
* Estimate of the capacity of the link, used to bound the rate control.
|
|
95
132
|
*/
|
|
@@ -138,20 +138,20 @@ namespace RTC
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
private:
|
|
141
|
-
void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t
|
|
141
|
+
void IncomingPacketFeedback(const Types::PacketResult& packetResult, int64_t nowUs);
|
|
142
142
|
|
|
143
143
|
Result MaybeUpdateEstimate(
|
|
144
144
|
std::optional<int64_t> ackedBitrate,
|
|
145
145
|
std::optional<int64_t> probeBitrate,
|
|
146
146
|
bool recoveredFromOveruse,
|
|
147
|
-
int64_t
|
|
147
|
+
int64_t nowUs);
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Recompute the target bitrate.
|
|
151
151
|
*
|
|
152
152
|
* @returns Whether there is a valid estimate.
|
|
153
153
|
*/
|
|
154
|
-
bool UpdateEstimate(int64_t
|
|
154
|
+
bool UpdateEstimate(int64_t nowUs, std::optional<int64_t> ackedBitrate, int64_t& targetBitrate);
|
|
155
155
|
|
|
156
156
|
private:
|
|
157
157
|
const DelayBasedBweOptions options;
|
|
@@ -33,14 +33,14 @@ namespace RTC
|
|
|
33
33
|
explicit FeedbackAdapter(SendPacketHistory* sendPacketHistory);
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Process a transport
|
|
36
|
+
* Process a transport wide cc feedback.
|
|
37
37
|
*
|
|
38
38
|
* @param receivedAtUs - Time at which the feedback was received.
|
|
39
39
|
* @returns What the feedback reports about the packets that were sent, in
|
|
40
40
|
* the order it reports them, or no value if it reports on no packet the
|
|
41
41
|
* history still holds.
|
|
42
42
|
*/
|
|
43
|
-
std::optional<Types::TransportPacketsFeedback>
|
|
43
|
+
std::optional<Types::TransportPacketsFeedback> ProcessTransportWideCcFeedback(
|
|
44
44
|
const RTCP::FeedbackRtpTransportPacket* feedback, int64_t receivedAtUs);
|
|
45
45
|
|
|
46
46
|
private:
|
|
@@ -594,10 +594,10 @@ namespace RTC
|
|
|
594
594
|
std::vector<double> temporalWeights;
|
|
595
595
|
// The same, for the average observed loss.
|
|
596
596
|
std::vector<double> immediateUpperBoundTemporalWeights;
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
597
|
+
PartialObservation partialObservation;
|
|
598
|
+
ChannelParameters currentBestEstimate;
|
|
599
|
+
HoldInfo lastHoldInfo;
|
|
600
|
+
Result result;
|
|
601
601
|
// Observations closed so far, which never decreases and hence also gives
|
|
602
602
|
// the id of the next one.
|
|
603
603
|
int64_t numObservations{ 0 };
|
|
@@ -40,12 +40,13 @@ namespace RTC
|
|
|
40
40
|
* @param sendDeltaMs - Time between the send times of both groups, which
|
|
41
41
|
* is how long this sample is worth.
|
|
42
42
|
* @param numOfDeltas - Number of samples that offset is based on.
|
|
43
|
-
* @param
|
|
43
|
+
* @param arrivalTimeUs - Instant the packet that produced this sample
|
|
44
|
+
* arrived.
|
|
44
45
|
*
|
|
45
46
|
* @returns What the network is taken to be doing after this sample.
|
|
46
47
|
*/
|
|
47
48
|
Types::BandwidthUsage Detect(
|
|
48
|
-
double offsetMs, double sendDeltaMs, int64_t numOfDeltas, int64_t
|
|
49
|
+
double offsetMs, double sendDeltaMs, int64_t numOfDeltas, int64_t arrivalTimeUs);
|
|
49
50
|
|
|
50
51
|
Types::BandwidthUsage GetState() const
|
|
51
52
|
{
|
|
@@ -53,11 +54,11 @@ namespace RTC
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
private:
|
|
56
|
-
void UpdateThreshold(double modifiedOffsetMs, int64_t
|
|
57
|
+
void UpdateThreshold(double modifiedOffsetMs, int64_t arrivalTimeUs);
|
|
57
58
|
|
|
58
59
|
private:
|
|
59
60
|
double threshold{ 12.5 };
|
|
60
|
-
std::optional<int64_t>
|
|
61
|
+
std::optional<int64_t> lastSampleArrivalTimeUs;
|
|
61
62
|
double prevOffsetMs{ 0.0 };
|
|
62
63
|
// How long the trend has been above the threshold, or no value while it
|
|
63
64
|
// isn't.
|
|
@@ -70,7 +70,7 @@ namespace RTC
|
|
|
70
70
|
* Forget the bursts whose last packet arrived long enough ago that they
|
|
71
71
|
* cannot receive anything else.
|
|
72
72
|
*/
|
|
73
|
-
void EraseOldClusters(int64_t
|
|
73
|
+
void EraseOldClusters(int64_t arrivalTimeUs);
|
|
74
74
|
|
|
75
75
|
private:
|
|
76
76
|
// Bursts being gathered, by their id. Nothing looks at them in any
|
|
@@ -108,6 +108,12 @@ namespace RTC
|
|
|
108
108
|
* over to decide how many bytes each of its shots carries.
|
|
109
109
|
*/
|
|
110
110
|
int64_t initialMinProbeDeltaUs{ 20 * 1000 };
|
|
111
|
+
/**
|
|
112
|
+
* Whether bursts keep being sent while the sender is not filling the
|
|
113
|
+
* link, which is the only way the estimate grows when the traffic
|
|
114
|
+
* itself is not enough to measure with.
|
|
115
|
+
*/
|
|
116
|
+
bool enablePeriodicAlrProbing{ false };
|
|
111
117
|
/**
|
|
112
118
|
* How often to probe while the sender is not filling the link.
|
|
113
119
|
*/
|
|
@@ -258,11 +264,6 @@ namespace RTC
|
|
|
258
264
|
[[nodiscard]] std::vector<Types::ProbeClusterConfig> SetEstimatedBitrate(
|
|
259
265
|
int64_t bitrate, BandwidthLimitedCause bandwidthLimitedCause, int64_t nowUs);
|
|
260
266
|
|
|
261
|
-
void EnablePeriodicAlrProbing(bool enable)
|
|
262
|
-
{
|
|
263
|
-
this->enablePeriodicAlrProbing = enable;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
267
|
/**
|
|
267
268
|
* Whether the initial bursts keep being repeated for a while, which only
|
|
268
269
|
* makes sense until there is traffic of its own to measure.
|
|
@@ -347,7 +348,6 @@ namespace RTC
|
|
|
347
348
|
State state{ State::INIT };
|
|
348
349
|
bool networkAvailable{ false };
|
|
349
350
|
bool repeatedInitialProbingEnabled{ false };
|
|
350
|
-
bool enablePeriodicAlrProbing{ false };
|
|
351
351
|
BandwidthLimitedCause bandwidthLimitedCause{ BandwidthLimitedCause::DELAY_BASED_LIMITED };
|
|
352
352
|
// Instant until which the initial bursts keep being repeated.
|
|
353
353
|
std::optional<int64_t> lastAllowedRepeatedInitialProbeAtUs;
|
|
@@ -34,9 +34,6 @@ namespace RTC
|
|
|
34
34
|
/**
|
|
35
35
|
* A packet of the burst is ready.
|
|
36
36
|
*
|
|
37
|
-
* @returns Whether the rest of the burst is still wanted, so that a
|
|
38
|
-
* packet that couldn't be sent stops the ones behind it.
|
|
39
|
-
*
|
|
40
37
|
* @remarks
|
|
41
38
|
* - The packet must be sent before returning, since the next one is
|
|
42
39
|
* built over the very same instance.
|
|
@@ -46,10 +43,9 @@ namespace RTC
|
|
|
46
43
|
* - Whoever measures the burst has to be told how much of it went out,
|
|
47
44
|
* so the length of the packet is reported from here as well.
|
|
48
45
|
* - This must not destroy the `ProbePacketGenerator`, not even
|
|
49
|
-
* indirectly. It goes on reading its own members after this returns
|
|
50
|
-
* so returning false is no way out of it either.
|
|
46
|
+
* indirectly. It goes on reading its own members after this returns.
|
|
51
47
|
*/
|
|
52
|
-
virtual
|
|
48
|
+
virtual void OnProbePacketGeneratorSendRtpPacket(
|
|
53
49
|
ProbePacketGenerator* probePacketGenerator, RTC::RTP::Packet* packet) = 0;
|
|
54
50
|
};
|
|
55
51
|
|
|
@@ -48,9 +48,6 @@ namespace RTC
|
|
|
48
48
|
/**
|
|
49
49
|
* A packet of the burst is ready to go out.
|
|
50
50
|
*
|
|
51
|
-
* @returns Whether the rest of the burst is still wanted, so that a
|
|
52
|
-
* packet that couldn't be sent stops the ones behind it.
|
|
53
|
-
*
|
|
54
51
|
* @remarks
|
|
55
52
|
* - The packet must be sent before returning, since the next one is
|
|
56
53
|
* built over the very same instance.
|
|
@@ -58,10 +55,9 @@ namespace RTC
|
|
|
58
55
|
* sequence number but no value for either, so both have to be written
|
|
59
56
|
* here.
|
|
60
57
|
* - This must not destroy the `ProbingScheduler`, not even indirectly.
|
|
61
|
-
* It goes on reading its own members after this returns
|
|
62
|
-
* returning false is no way out of it either.
|
|
58
|
+
* It goes on reading its own members after this returns.
|
|
63
59
|
*/
|
|
64
|
-
virtual
|
|
60
|
+
virtual void OnProbingSchedulerSendRtpPacket(
|
|
65
61
|
ProbingScheduler* probingScheduler,
|
|
66
62
|
RTC::RTP::Packet* packet,
|
|
67
63
|
const Types::ProbeCluster& probeCluster) = 0;
|
|
@@ -133,7 +129,7 @@ namespace RTC
|
|
|
133
129
|
|
|
134
130
|
/* Pure virtual methods inherited from RTC::BWE::ProbePacketGenerator::Listener. */
|
|
135
131
|
public:
|
|
136
|
-
|
|
132
|
+
void OnProbePacketGeneratorSendRtpPacket(
|
|
137
133
|
ProbePacketGenerator* probePacketGenerator, RTC::RTP::Packet* packet) override;
|
|
138
134
|
|
|
139
135
|
/* Pure virtual methods inherited from TimerHandleInterface::Listener. */
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#ifndef MS_RTC_BWE_RECEIVER_TRANSPORT_CONGESTION_CONTROLLER_HPP
|
|
2
|
+
#define MS_RTC_BWE_RECEIVER_TRANSPORT_CONGESTION_CONTROLLER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/BWE/BweTypes.hpp"
|
|
6
|
+
#include "RTC/BWE/RembGenerator.hpp"
|
|
7
|
+
#include "RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp"
|
|
8
|
+
#include "RTC/BWE/TransportWideCcFeedbackGenerator.hpp"
|
|
9
|
+
#include "RTC/Consts.hpp"
|
|
10
|
+
#include "RTC/RTCP/Packet.hpp"
|
|
11
|
+
#include "RTC/RTP/Packet.hpp"
|
|
12
|
+
#include "RTC/RtpDictionaries.hpp"
|
|
13
|
+
#include "SharedInterface.hpp"
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace RTC
|
|
17
|
+
{
|
|
18
|
+
namespace BWE
|
|
19
|
+
{
|
|
20
|
+
/**
|
|
21
|
+
* Everything the receiving side of a transport does about congestion, which
|
|
22
|
+
* amounts to telling the remote sender how much it may send towards us.
|
|
23
|
+
*
|
|
24
|
+
* How that is said depends on what both endpoints negotiated. With
|
|
25
|
+
* transport-cc nothing is estimated here: the instant each packet arrived is
|
|
26
|
+
* reported back and the remote sender does the estimating. With REMB it is
|
|
27
|
+
* the other way round, and a bitrate is computed here and announced.
|
|
28
|
+
*
|
|
29
|
+
* The cap the application sets is announced as a REMB either way, since that
|
|
30
|
+
* is the only way to tell a remote sender to hold back.
|
|
31
|
+
*/
|
|
32
|
+
class ReceiverTransportCongestionController : public TransportWideCcFeedbackGenerator::Listener,
|
|
33
|
+
public RemoteBitrateEstimatorAbsSendTime::Listener,
|
|
34
|
+
public RembGenerator::Listener
|
|
35
|
+
{
|
|
36
|
+
public:
|
|
37
|
+
class Listener
|
|
38
|
+
{
|
|
39
|
+
public:
|
|
40
|
+
virtual ~Listener() = default;
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
/**
|
|
44
|
+
* An RTCP packet is ready for the remote sender.
|
|
45
|
+
*
|
|
46
|
+
* @param packet - Packet to send. It belongs to the caller, so the
|
|
47
|
+
* listener must neither destroy it nor keep it around after this call
|
|
48
|
+
* returns.
|
|
49
|
+
*/
|
|
50
|
+
virtual void OnReceiverTransportCongestionControllerSendRtcpPacket(
|
|
51
|
+
ReceiverTransportCongestionController* receiverTransportCongestionControl,
|
|
52
|
+
RTC::RTCP::Packet* packet) = 0;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
struct ReceiverTransportCongestionControllerOptions
|
|
56
|
+
{
|
|
57
|
+
/**
|
|
58
|
+
* Mechanism both endpoints negotiated, which decides what is done with
|
|
59
|
+
* every packet that comes in.
|
|
60
|
+
*/
|
|
61
|
+
Types::CongestionControlType congestionControlType;
|
|
62
|
+
/**
|
|
63
|
+
* Largest an RTCP packet may be on this transport (bytes).
|
|
64
|
+
*/
|
|
65
|
+
size_t maxRtcpPacketLen{ RTC::Consts::RtcpPacketMaxSize };
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
ReceiverTransportCongestionController(
|
|
70
|
+
Listener* listener,
|
|
71
|
+
SharedInterface* shared,
|
|
72
|
+
ReceiverTransportCongestionControllerOptions options);
|
|
73
|
+
|
|
74
|
+
~ReceiverTransportCongestionController() override = default;
|
|
75
|
+
|
|
76
|
+
ReceiverTransportCongestionController(const ReceiverTransportCongestionController&) = delete;
|
|
77
|
+
ReceiverTransportCongestionController& operator=(
|
|
78
|
+
const ReceiverTransportCongestionController&) = delete;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Feed a received RTP packet.
|
|
82
|
+
*
|
|
83
|
+
* @param receivedAtUs - Instant the packet arrived.
|
|
84
|
+
* @param kind - Media the stream the packet belongs to carries.
|
|
85
|
+
*/
|
|
86
|
+
void ReceiveRtpPacket(int64_t receivedAtUs, const RTC::RTP::Packet* packet, RTC::Media::Kind kind);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Feed the round trip time towards the remote senders, which bounds how
|
|
90
|
+
* often the estimation of the incoming link may be reduced.
|
|
91
|
+
*/
|
|
92
|
+
void OnRttUpdate(int64_t avgRttUs);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Forget a stream, so that it no longer takes part in the estimation of
|
|
96
|
+
* the incoming link nor in the streams the remote sender is told about.
|
|
97
|
+
*/
|
|
98
|
+
void RemoveStream(uint32_t ssrc);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Cap what the remote sender is told it may send (bps), or zero to let it
|
|
102
|
+
* send whatever the incoming link is estimated to bear.
|
|
103
|
+
*/
|
|
104
|
+
void SetMaxIncomingBitrate(int64_t bitrate);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Latest estimation of the incoming link (bps), or no value while there is
|
|
108
|
+
* none and whenever the estimating is the remote sender's job.
|
|
109
|
+
*/
|
|
110
|
+
std::optional<int64_t> GetAvailableBitrate() const;
|
|
111
|
+
|
|
112
|
+
/* Pure virtual methods inherited from TransportWideCcFeedbackGenerator::Listener. */
|
|
113
|
+
public:
|
|
114
|
+
void OnTransportWideCcFeedbackGeneratorSendPacket(
|
|
115
|
+
TransportWideCcFeedbackGenerator* transportWideCcFeedbackGenerator,
|
|
116
|
+
RTC::RTCP::FeedbackRtpTransportPacket* packet) override;
|
|
117
|
+
|
|
118
|
+
/* Pure virtual methods inherited from RemoteBitrateEstimatorAbsSendTime::Listener. */
|
|
119
|
+
public:
|
|
120
|
+
void OnRemoteBitrateEstimatorAbsSendTimeBitrateChanged(
|
|
121
|
+
RemoteBitrateEstimatorAbsSendTime* remoteBitrateEstimator,
|
|
122
|
+
const std::vector<uint32_t>& ssrcs,
|
|
123
|
+
int64_t bitrate) override;
|
|
124
|
+
|
|
125
|
+
/* Pure virtual methods inherited from RembGenerator::Listener. */
|
|
126
|
+
public:
|
|
127
|
+
void OnRembGeneratorSendPacket(
|
|
128
|
+
RembGenerator* rembGenerator, RTC::RTCP::FeedbackPsRembPacket* packet) override;
|
|
129
|
+
|
|
130
|
+
private:
|
|
131
|
+
const ReceiverTransportCongestionControllerOptions options;
|
|
132
|
+
|
|
133
|
+
// Passed by argument.
|
|
134
|
+
Listener* listener{ nullptr };
|
|
135
|
+
SharedInterface* shared{ nullptr };
|
|
136
|
+
// Allocated by this, the first one only in transport-cc mode and the
|
|
137
|
+
// second one only in REMB mode.
|
|
138
|
+
std::unique_ptr<TransportWideCcFeedbackGenerator> transportWideCcFeedbackGenerator;
|
|
139
|
+
std::unique_ptr<RemoteBitrateEstimatorAbsSendTime> remoteBitrateEstimator;
|
|
140
|
+
// Others.
|
|
141
|
+
// It lives in both modes, since the cap is announced as a REMB whatever
|
|
142
|
+
// was negotiated.
|
|
143
|
+
RembGenerator rembGenerator;
|
|
144
|
+
};
|
|
145
|
+
} // namespace BWE
|
|
146
|
+
} // namespace RTC
|
|
147
|
+
|
|
148
|
+
#endif
|
|
@@ -27,10 +27,11 @@ namespace RTC
|
|
|
27
27
|
/**
|
|
28
28
|
* A REMB packet is ready for the remote sender.
|
|
29
29
|
*
|
|
30
|
-
* @param packet - Packet to send
|
|
31
|
-
* call
|
|
30
|
+
* @param packet - Packet to send. It belongs to the caller, so the
|
|
31
|
+
* listener must neither destroy it nor keep it around after this call
|
|
32
|
+
* returns.
|
|
32
33
|
*/
|
|
33
|
-
virtual void
|
|
34
|
+
virtual void OnRembGeneratorSendPacket(
|
|
34
35
|
RembGenerator* rembGenerator, RTC::RTCP::FeedbackPsRembPacket* packet) = 0;
|
|
35
36
|
};
|
|
36
37
|
|
|
@@ -144,7 +144,7 @@ namespace RTC
|
|
|
144
144
|
* @param nowUs - Current instant, which is not the one above when packets
|
|
145
145
|
* are processed in batches.
|
|
146
146
|
*/
|
|
147
|
-
void
|
|
147
|
+
void ReceiveRtpPacket(const RTC::RTP::Packet* packet, int64_t arrivalTimeUs, int64_t nowUs);
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Feed the round trip time towards the senders, which bounds how often the
|