mediasoup 3.20.5 → 3.20.6
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/package.json +4 -4
- package/worker/include/RTC/Consumer.hpp +80 -45
- package/worker/include/RTC/PipeProducerStreamManager.hpp +78 -0
- package/worker/include/RTC/ProducerStreamManager.hpp +181 -0
- package/worker/include/RTC/SCTP/association/Association.hpp +24 -0
- package/worker/include/RTC/SCTP/association/StateCookie.hpp +104 -11
- package/worker/include/RTC/SCTP/packet/parameters/StateCookieParameter.hpp +4 -1
- package/worker/include/RTC/SCTP/public/SctpOptions.hpp +13 -0
- package/worker/include/RTC/SimpleProducerStreamManager.hpp +72 -0
- package/worker/include/RTC/SimulcastProducerStreamManager.hpp +93 -0
- package/worker/include/RTC/SvcProducerStreamManager.hpp +72 -0
- package/worker/include/RTC/Transport.hpp +7 -1
- package/worker/meson.build +9 -5
- package/worker/src/RTC/Consumer.cpp +1404 -30
- package/worker/src/RTC/DirectTransport.cpp +4 -1
- package/worker/src/RTC/PipeProducerStreamManager.cpp +266 -0
- package/worker/src/RTC/PipeTransport.cpp +4 -1
- package/worker/src/RTC/PlainTransport.cpp +4 -1
- package/worker/src/RTC/SCTP/association/Association.cpp +138 -1
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +96 -31
- package/worker/src/RTC/SCTP/packet/Packet.cpp +1 -1
- package/worker/src/RTC/SCTP/packet/parameters/StateCookieParameter.cpp +12 -3
- package/worker/src/RTC/SCTP/public/SctpOptions.cpp +4 -0
- package/worker/src/RTC/SimpleProducerStreamManager.cpp +343 -0
- package/worker/src/RTC/SimulcastProducerStreamManager.cpp +1068 -0
- package/worker/src/RTC/SvcProducerStreamManager.cpp +664 -0
- package/worker/src/RTC/Transport.cpp +7 -44
- package/worker/src/RTC/WebRtcTransport.cpp +8 -2
- package/worker/test/include/RTC/SCTP/sctpCommon.hpp +1 -1
- package/worker/test/src/RTC/SCTP/association/TestAssociation.cpp +115 -0
- package/worker/test/src/RTC/SCTP/association/TestStateCookie.cpp +123 -0
- package/worker/test/src/RTC/SCTP/packet/TestPacket.cpp +4 -4
- package/worker/test/src/RTC/{TestSimpleConsumer.cpp → TestConsumer.cpp} +6 -7
- package/worker/test/src/RTC/TestPipeProducerStreamManager.cpp +471 -0
- package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +531 -0
- package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +1040 -0
- package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +1278 -0
- package/worker/include/RTC/PipeConsumer.hpp +0 -95
- package/worker/include/RTC/SimpleConsumer.hpp +0 -102
- package/worker/include/RTC/SimulcastConsumer.hpp +0 -141
- package/worker/include/RTC/SvcConsumer.hpp +0 -118
- package/worker/src/RTC/PipeConsumer.cpp +0 -874
- package/worker/src/RTC/SimpleConsumer.cpp +0 -882
- package/worker/src/RTC/SimulcastConsumer.cpp +0 -1887
- package/worker/src/RTC/SvcConsumer.cpp +0 -1384
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
#include "RTC/SCTP/public/SctpTypes.hpp"
|
|
7
7
|
#include "RTC/Serializable.hpp"
|
|
8
8
|
#include "Utils.hpp"
|
|
9
|
-
#include <string_view>
|
|
10
9
|
|
|
11
10
|
namespace RTC
|
|
12
11
|
{
|
|
@@ -58,6 +57,28 @@ namespace RTC
|
|
|
58
57
|
* Interleaving (I-DATA).
|
|
59
58
|
* - Flag C (reconfig): Stream Reconfiguration.
|
|
60
59
|
* - Flag D (zeroChecksum): Zero Checksum.
|
|
60
|
+
*
|
|
61
|
+
* When State Cookie authentication is enabled (see
|
|
62
|
+
* `SctpOptions::requireAuthenticatedCookie`), two extra fields are appended
|
|
63
|
+
* after the Negotiated Capabilities so the receiver can verify that the
|
|
64
|
+
* cookie was generated by itself and is not stale:
|
|
65
|
+
*
|
|
66
|
+
* 0 1 2 3
|
|
67
|
+
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
68
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
69
|
+
* | Creation Timestamp |
|
|
70
|
+
* | |
|
|
71
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
72
|
+
* \ \
|
|
73
|
+
* / MAC (HMAC-SHA1 over all preceding bytes) /
|
|
74
|
+
* \ \
|
|
75
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
76
|
+
*
|
|
77
|
+
* The MAC is keyed with a per-association secret that never leaves the
|
|
78
|
+
* worker, making the cookie unforgeable. The Creation Timestamp (in ms) is
|
|
79
|
+
* used to detect stale cookies.
|
|
80
|
+
*
|
|
81
|
+
* @see RFC 9260 sections 5.1.3 and 5.1.4.
|
|
61
82
|
*/
|
|
62
83
|
class StateCookie : public Serializable
|
|
63
84
|
{
|
|
@@ -84,7 +105,8 @@ namespace RTC
|
|
|
84
105
|
};
|
|
85
106
|
|
|
86
107
|
public:
|
|
87
|
-
// Fixed
|
|
108
|
+
// Fixed length of our generated State Cookies when authentication is
|
|
109
|
+
// disabled.
|
|
88
110
|
static constexpr size_t StateCookieLength{ 44 };
|
|
89
111
|
// Offset in the State Cookie where the Negotiated Capabilitied are
|
|
90
112
|
// located.
|
|
@@ -95,13 +117,27 @@ namespace RTC
|
|
|
95
117
|
static constexpr size_t Magic1Length{ 8 };
|
|
96
118
|
// Magic value used within the Negotiated Capabilities block.
|
|
97
119
|
static constexpr uint16_t Magic2{ 0xAD81 };
|
|
120
|
+
// Offset of the creation timestamp present in authenticated State
|
|
121
|
+
// Cookies.
|
|
122
|
+
static constexpr size_t TimestampOffset{ StateCookie::StateCookieLength };
|
|
123
|
+
// Length of the creation timestamp field (a uint64_t with the time in
|
|
124
|
+
// milliseconds).
|
|
125
|
+
static constexpr size_t TimestampLength{ 8 };
|
|
126
|
+
// Offset of the MAC present in authenticated State Cookies.
|
|
127
|
+
static constexpr size_t MacOffset{ StateCookie::TimestampOffset + StateCookie::TimestampLength };
|
|
128
|
+
// Length of the MAC. We use HMAC-SHA1 so it's 20 bytes.
|
|
129
|
+
static constexpr size_t MacLength{ 20 };
|
|
130
|
+
// Fixed length of our generated State Cookies when authentication is
|
|
131
|
+
// enabled.
|
|
132
|
+
static constexpr size_t AuthenticatedStateCookieLength{ StateCookie::MacOffset +
|
|
133
|
+
StateCookie::MacLength };
|
|
134
|
+
// State Cookie lifespan (Valid.Cookie.Life) in milliseconds. Used to
|
|
135
|
+
// reject stale authenticated cookies.
|
|
136
|
+
//
|
|
137
|
+
// @see RFC 9260 section 16.
|
|
138
|
+
static constexpr uint64_t ValidCookieLifeMs{ 60000 };
|
|
98
139
|
|
|
99
140
|
public:
|
|
100
|
-
/**
|
|
101
|
-
* Whether the given buffer is a StateCookie generated by mediasoup.
|
|
102
|
-
*/
|
|
103
|
-
static bool IsMediasoupStateCookie(const uint8_t* buffer, size_t bufferLength);
|
|
104
|
-
|
|
105
141
|
/**
|
|
106
142
|
* Parse a StateCookie supposely generated by mediasoup.
|
|
107
143
|
*
|
|
@@ -114,8 +150,11 @@ namespace RTC
|
|
|
114
150
|
* Create a StateCookie.
|
|
115
151
|
*
|
|
116
152
|
* @remarks
|
|
117
|
-
* `bufferLength` could be greater than the real length of the State
|
|
118
|
-
*
|
|
153
|
+
* - `bufferLength` could be greater than the real length of the State
|
|
154
|
+
* cookie.
|
|
155
|
+
* - If `macKey` is not nullptr, an authenticated cookie (with creation
|
|
156
|
+
* timestamp and MAC) is generated. Otherwise a plain cookie is
|
|
157
|
+
* generated and `creationTimestampMs`/`macKey` are ignored.
|
|
119
158
|
*/
|
|
120
159
|
static StateCookie* Factory(
|
|
121
160
|
uint8_t* buffer,
|
|
@@ -126,10 +165,18 @@ namespace RTC
|
|
|
126
165
|
uint32_t remoteInitialTsn,
|
|
127
166
|
uint32_t remoteAdvertisedReceiverWindowCredit,
|
|
128
167
|
uint64_t tieTag,
|
|
129
|
-
const NegotiatedCapabilities& negotiatedCapabilities
|
|
168
|
+
const NegotiatedCapabilities& negotiatedCapabilities,
|
|
169
|
+
uint64_t creationTimestampMs = 0,
|
|
170
|
+
const uint8_t* macKey = nullptr,
|
|
171
|
+
size_t macKeyLength = 0);
|
|
130
172
|
|
|
131
173
|
/**
|
|
132
174
|
* Serialize a StateCookie (based on given arguments) in the given buffer.
|
|
175
|
+
*
|
|
176
|
+
* @remarks
|
|
177
|
+
* - If `macKey` is not nullptr, an authenticated cookie (with creation
|
|
178
|
+
* timestamp and MAC) is generated. Otherwise a plain cookie is
|
|
179
|
+
* generated and `creationTimestampMs`/`macKey` are ignored.
|
|
133
180
|
*/
|
|
134
181
|
static void Write(
|
|
135
182
|
uint8_t* buffer,
|
|
@@ -140,7 +187,33 @@ namespace RTC
|
|
|
140
187
|
uint32_t remoteInitialTsn,
|
|
141
188
|
uint32_t remoteAdvertisedReceiverWindowCredit,
|
|
142
189
|
uint64_t tieTag,
|
|
143
|
-
const NegotiatedCapabilities& negotiatedCapabilities
|
|
190
|
+
const NegotiatedCapabilities& negotiatedCapabilities,
|
|
191
|
+
uint64_t creationTimestampMs = 0,
|
|
192
|
+
const uint8_t* macKey = nullptr,
|
|
193
|
+
size_t macKeyLength = 0);
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Whether the given buffer is a StateCookie generated by mediasoup.
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* - This only checks magic values and length. It does NOT verify the
|
|
200
|
+
* MAC of authenticated cookies (which requires the per-association
|
|
201
|
+
* secret). Use `VerifyMac()` for that.
|
|
202
|
+
*/
|
|
203
|
+
static bool IsMediasoupStateCookie(const uint8_t* buffer, size_t bufferLength);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Verify the MAC of an authenticated StateCookie generated by mediasoup.
|
|
207
|
+
*
|
|
208
|
+
* @remarks
|
|
209
|
+
* - Returns false if the buffer is not an authenticated cookie (i.e. its
|
|
210
|
+
* length is not `AuthenticatedStateCookieLength`) or if the MAC doesn't
|
|
211
|
+
* match the one computed with the given secret key.
|
|
212
|
+
*
|
|
213
|
+
* @see RFC 9260 section 5.1.4.
|
|
214
|
+
*/
|
|
215
|
+
static bool VerifyMac(
|
|
216
|
+
const uint8_t* buffer, size_t bufferLength, const uint8_t* macKey, size_t macKeyLength);
|
|
144
217
|
|
|
145
218
|
/**
|
|
146
219
|
* Determine the SCTP implementation of the generator of State Cookie
|
|
@@ -218,6 +291,26 @@ namespace RTC
|
|
|
218
291
|
*/
|
|
219
292
|
NegotiatedCapabilities GetNegotiatedCapabilities() const;
|
|
220
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Whether this is an authenticated StateCookie (i.e. it carries a
|
|
296
|
+
* creation timestamp and a MAC).
|
|
297
|
+
*/
|
|
298
|
+
bool IsAuthenticated() const
|
|
299
|
+
{
|
|
300
|
+
return GetLength() == StateCookie::AuthenticatedStateCookieLength;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The time (in milliseconds) at which this StateCookie was created.
|
|
305
|
+
*
|
|
306
|
+
* @remarks
|
|
307
|
+
* - Only meaningful in authenticated cookies (see `IsAuthenticated()`).
|
|
308
|
+
*/
|
|
309
|
+
uint64_t GetCreationTimestampMs() const
|
|
310
|
+
{
|
|
311
|
+
return Utils::Byte::Get8Bytes(GetBuffer(), StateCookie::TimestampOffset);
|
|
312
|
+
}
|
|
313
|
+
|
|
221
314
|
private:
|
|
222
315
|
NegotiatedCapabilitiesField* GetNegotiatedCapabilitiesField() const
|
|
223
316
|
{
|
|
@@ -104,7 +104,10 @@ namespace RTC
|
|
|
104
104
|
uint32_t remoteInitialTsn,
|
|
105
105
|
uint32_t remoteAdvertisedReceiverWindowCredit,
|
|
106
106
|
uint64_t tieTag,
|
|
107
|
-
const NegotiatedCapabilities& negotiatedCapabilities
|
|
107
|
+
const NegotiatedCapabilities& negotiatedCapabilities,
|
|
108
|
+
uint64_t creationTimestampMs = 0,
|
|
109
|
+
const uint8_t* macKey = nullptr,
|
|
110
|
+
size_t macKeyLength = 0);
|
|
108
111
|
|
|
109
112
|
protected:
|
|
110
113
|
StateCookieParameter* SoftClone(const uint8_t* buffer) const final;
|
|
@@ -264,6 +264,19 @@ namespace RTC
|
|
|
264
264
|
ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethod::NONE
|
|
265
265
|
};
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Whether received State Cookies must be authenticated with a MAC keyed
|
|
269
|
+
* by a per-association secret, and checked for staleness.
|
|
270
|
+
*
|
|
271
|
+
* This MUST be enabled in transports whose SCTP traffic is not protected
|
|
272
|
+
* by DTLS to comply with RFC 9260 section 5.1.3 and prevent State Cookie
|
|
273
|
+
* forgery (an on-path attacker could otherwise craft a COOKIE-ECHO chunk
|
|
274
|
+
* that passes validation and establish an unauthorized association).
|
|
275
|
+
*
|
|
276
|
+
* @see RFC 9260 sections 5.1.3 and 5.1.4.
|
|
277
|
+
*/
|
|
278
|
+
bool requireAuthenticatedCookie{ false };
|
|
279
|
+
|
|
267
280
|
void Dump(int indentation = 0) const;
|
|
268
281
|
};
|
|
269
282
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#ifndef MS_RTC_SIMPLE_CONSUMER_STREAM_HPP
|
|
2
|
+
#define MS_RTC_SIMPLE_CONSUMER_STREAM_HPP
|
|
3
|
+
|
|
4
|
+
#include "RTC/ProducerStreamManager.hpp"
|
|
5
|
+
|
|
6
|
+
namespace RTC
|
|
7
|
+
{
|
|
8
|
+
class SimpleProducerStreamManager : public ProducerStreamManager
|
|
9
|
+
{
|
|
10
|
+
public:
|
|
11
|
+
SimpleProducerStreamManager(
|
|
12
|
+
const std::vector<RTC::RtpEncodingParameters>& consumableRtpEncodings,
|
|
13
|
+
const RTC::ConsumerTypes::VideoLayers& preferredLayers,
|
|
14
|
+
std::unique_ptr<RTC::RTP::Codecs::EncodingContext> encodingContext,
|
|
15
|
+
RTC::Media::Kind kind,
|
|
16
|
+
bool keyFrameSupported,
|
|
17
|
+
Listener* listener,
|
|
18
|
+
SharedInterface* shared);
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
RTC::ConsumerTypes::VideoLayers GetTargetLayers() const override
|
|
22
|
+
{
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
int16_t GetCurrentSpatialLayer() const override
|
|
26
|
+
{
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
int16_t GetCurrentTemporalLayer() const override
|
|
30
|
+
{
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
RTC::RTP::RtpStreamRecv* GetProducerCurrentRtpStream() const override;
|
|
34
|
+
RTC::RTP::RtpStreamRecv* GetProducerTargetRtpStream() const override;
|
|
35
|
+
bool IsPacketForCurrentStream(const RTC::RTP::Packet* /*packet*/) const override
|
|
36
|
+
{
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
bool IsActive() const override;
|
|
40
|
+
void ProducerRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
41
|
+
void ProducerNewRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
42
|
+
void ProducerRtpStreamScore(
|
|
43
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
|
|
44
|
+
void ProducerRtcpSenderReport(RTC::RTP::RtpStreamRecv* rtpStream, bool first) override;
|
|
45
|
+
uint32_t IncreaseLayer(
|
|
46
|
+
uint32_t bitrate, bool considerLoss, float lossPercentage, uint64_t nowMs) override;
|
|
47
|
+
void ApplyLayers(uint64_t rtpStreamActiveMs) override;
|
|
48
|
+
uint32_t GetDesiredBitrate(uint64_t nowMs) const override;
|
|
49
|
+
RtpPacketProcessResult ProcessRtpPacket(
|
|
50
|
+
RTC::RTP::Packet* packet,
|
|
51
|
+
bool lastSentPacketHasMarker,
|
|
52
|
+
uint32_t clockRate,
|
|
53
|
+
uint32_t maxPacketTs) override;
|
|
54
|
+
void RequestKeyFrame() override;
|
|
55
|
+
void RequestKeyFrameForTargetSpatialLayer() override;
|
|
56
|
+
void RequestKeyFrameForCurrentSpatialLayer() override;
|
|
57
|
+
void UpdateTargetLayers(int16_t spatial, int16_t temporal) override;
|
|
58
|
+
bool RecalculateTargetLayers(RTC::ConsumerTypes::VideoLayers& newTargetLayers) const override;
|
|
59
|
+
void OnTransportConnected() override;
|
|
60
|
+
void OnTransportDisconnected() override;
|
|
61
|
+
void OnPaused() override;
|
|
62
|
+
void OnResumed() override;
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
// Producer RTP stream (single stream for Simple).
|
|
66
|
+
RTC::RTP::RtpStreamRecv* producerRtpStream{ nullptr };
|
|
67
|
+
// Prevents double IncreaseLayer in one BWE round.
|
|
68
|
+
bool managingBitrate{ false };
|
|
69
|
+
};
|
|
70
|
+
} // namespace RTC
|
|
71
|
+
|
|
72
|
+
#endif
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#ifndef MS_RTC_SIMULCAST_CONSUMER_STREAM_HPP
|
|
2
|
+
#define MS_RTC_SIMULCAST_CONSUMER_STREAM_HPP
|
|
3
|
+
|
|
4
|
+
#include "RTC/ProducerStreamManager.hpp"
|
|
5
|
+
#include <ankerl/unordered_dense.h>
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
class SimulcastProducerStreamManager : public ProducerStreamManager
|
|
10
|
+
{
|
|
11
|
+
public:
|
|
12
|
+
SimulcastProducerStreamManager(
|
|
13
|
+
const std::vector<RTC::RtpEncodingParameters>& consumableRtpEncodings,
|
|
14
|
+
const RTC::ConsumerTypes::VideoLayers& preferredLayers,
|
|
15
|
+
std::unique_ptr<RTC::RTP::Codecs::EncodingContext> encodingContext,
|
|
16
|
+
RTC::Media::Kind kind,
|
|
17
|
+
bool keyFrameSupported,
|
|
18
|
+
Listener* listener,
|
|
19
|
+
SharedInterface* shared);
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
RTC::ConsumerTypes::VideoLayers GetTargetLayers() const override
|
|
23
|
+
{
|
|
24
|
+
return this->targetLayers;
|
|
25
|
+
}
|
|
26
|
+
int16_t GetCurrentSpatialLayer() const override
|
|
27
|
+
{
|
|
28
|
+
return this->currentSpatialLayer;
|
|
29
|
+
}
|
|
30
|
+
int16_t GetCurrentTemporalLayer() const override
|
|
31
|
+
{
|
|
32
|
+
return this->encodingContext->GetCurrentTemporalLayer();
|
|
33
|
+
}
|
|
34
|
+
RTC::RTP::RtpStreamRecv* GetProducerCurrentRtpStream() const override;
|
|
35
|
+
RTC::RTP::RtpStreamRecv* GetProducerTargetRtpStream() const override;
|
|
36
|
+
bool IsPacketForCurrentStream(const RTC::RTP::Packet* packet) const override
|
|
37
|
+
{
|
|
38
|
+
const auto it = this->mapMappedSsrcSpatialLayer.find(packet->GetSsrc());
|
|
39
|
+
if (it == this->mapMappedSsrcSpatialLayer.end())
|
|
40
|
+
{
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return it->second == this->currentSpatialLayer;
|
|
44
|
+
}
|
|
45
|
+
bool IsActive() const override;
|
|
46
|
+
void ProducerRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
47
|
+
void ProducerNewRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
48
|
+
void ProducerRtpStreamScore(
|
|
49
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
|
|
50
|
+
void ProducerRtcpSenderReport(RTC::RTP::RtpStreamRecv* rtpStream, bool first) override;
|
|
51
|
+
uint32_t IncreaseLayer(
|
|
52
|
+
uint32_t bitrate, bool considerLoss, float lossPercentage, uint64_t nowMs) override;
|
|
53
|
+
void ApplyLayers(uint64_t rtpStreamActiveMs) override;
|
|
54
|
+
uint32_t GetDesiredBitrate(uint64_t nowMs) const override;
|
|
55
|
+
RtpPacketProcessResult ProcessRtpPacket(
|
|
56
|
+
RTC::RTP::Packet* packet,
|
|
57
|
+
bool lastSentPacketHasMarker,
|
|
58
|
+
uint32_t clockRate,
|
|
59
|
+
uint32_t maxPacketTs) override;
|
|
60
|
+
void RequestKeyFrame() override;
|
|
61
|
+
void RequestKeyFrameForTargetSpatialLayer() override;
|
|
62
|
+
void RequestKeyFrameForCurrentSpatialLayer() override;
|
|
63
|
+
void UpdateTargetLayers(int16_t newTargetSpatialLayer, int16_t newTargetTemporalLayer) override;
|
|
64
|
+
bool RecalculateTargetLayers(RTC::ConsumerTypes::VideoLayers& newTargetLayers) const override;
|
|
65
|
+
void OnTransportConnected() override;
|
|
66
|
+
void OnTransportDisconnected() override;
|
|
67
|
+
void OnPaused() override;
|
|
68
|
+
void OnResumed() override;
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
bool CanSwitchToSpatialLayer(int16_t spatialLayer) const;
|
|
72
|
+
RTC::RTP::RtpStreamRecv* GetProducerTsReferenceRtpStream() const;
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
// Producer RTP streams (multiple for Simulcast).
|
|
76
|
+
std::vector<RTC::RTP::RtpStreamRecv*> producerRtpStreams;
|
|
77
|
+
ankerl::unordered_dense::map<uint32_t, int16_t> mapMappedSsrcSpatialLayer;
|
|
78
|
+
RTC::ConsumerTypes::VideoLayers targetLayers;
|
|
79
|
+
int16_t currentSpatialLayer{ -1 };
|
|
80
|
+
int16_t spatialLayerToSync{ -1 };
|
|
81
|
+
// Timestamp synchronization.
|
|
82
|
+
int16_t tsReferenceSpatialLayer{ -1 };
|
|
83
|
+
uint32_t tsOffset{ 0u };
|
|
84
|
+
bool keyFrameForTsOffsetRequested{ false };
|
|
85
|
+
// Old-packet filtering after spatial switch.
|
|
86
|
+
uint16_t snReferenceSpatialLayer{ 0u };
|
|
87
|
+
bool checkingForOldPacketsInSpatialLayer{ false };
|
|
88
|
+
// BWE downgrade tracking.
|
|
89
|
+
uint64_t lastBweDowngradeAtMs{ 0u };
|
|
90
|
+
};
|
|
91
|
+
} // namespace RTC
|
|
92
|
+
|
|
93
|
+
#endif
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#ifndef MS_RTC_SVC_CONSUMER_STREAM_HPP
|
|
2
|
+
#define MS_RTC_SVC_CONSUMER_STREAM_HPP
|
|
3
|
+
|
|
4
|
+
#include "RTC/ProducerStreamManager.hpp"
|
|
5
|
+
|
|
6
|
+
namespace RTC
|
|
7
|
+
{
|
|
8
|
+
class SvcProducerStreamManager : public ProducerStreamManager
|
|
9
|
+
{
|
|
10
|
+
public:
|
|
11
|
+
SvcProducerStreamManager(
|
|
12
|
+
const std::vector<RTC::RtpEncodingParameters>& consumableRtpEncodings,
|
|
13
|
+
const RTC::ConsumerTypes::VideoLayers& preferredLayers,
|
|
14
|
+
std::unique_ptr<RTC::RTP::Codecs::EncodingContext> encodingContext,
|
|
15
|
+
RTC::Media::Kind kind,
|
|
16
|
+
bool keyFrameSupported,
|
|
17
|
+
Listener* listener,
|
|
18
|
+
SharedInterface* shared);
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
RTC::ConsumerTypes::VideoLayers GetTargetLayers() const override
|
|
22
|
+
{
|
|
23
|
+
return this->encodingContext->GetTargetLayers();
|
|
24
|
+
}
|
|
25
|
+
int16_t GetCurrentSpatialLayer() const override
|
|
26
|
+
{
|
|
27
|
+
return this->encodingContext->GetCurrentSpatialLayer();
|
|
28
|
+
}
|
|
29
|
+
int16_t GetCurrentTemporalLayer() const override
|
|
30
|
+
{
|
|
31
|
+
return this->encodingContext->GetCurrentTemporalLayer();
|
|
32
|
+
}
|
|
33
|
+
RTC::RTP::RtpStreamRecv* GetProducerCurrentRtpStream() const override;
|
|
34
|
+
RTC::RTP::RtpStreamRecv* GetProducerTargetRtpStream() const override;
|
|
35
|
+
bool IsPacketForCurrentStream(const RTC::RTP::Packet* /*packet*/) const override
|
|
36
|
+
{
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
bool IsActive() const override;
|
|
40
|
+
void ProducerRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
41
|
+
void ProducerNewRtpStream(RTC::RTP::RtpStreamRecv* rtpStream, uint32_t mappedSsrc) override;
|
|
42
|
+
void ProducerRtpStreamScore(
|
|
43
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint8_t score, uint8_t previousScore) override;
|
|
44
|
+
void ProducerRtcpSenderReport(RTC::RTP::RtpStreamRecv* rtpStream, bool first) override;
|
|
45
|
+
uint32_t IncreaseLayer(
|
|
46
|
+
uint32_t bitrate, bool considerLoss, float lossPercentage, uint64_t nowMs) override;
|
|
47
|
+
void ApplyLayers(uint64_t rtpStreamActiveMs) override;
|
|
48
|
+
uint32_t GetDesiredBitrate(uint64_t nowMs) const override;
|
|
49
|
+
RtpPacketProcessResult ProcessRtpPacket(
|
|
50
|
+
RTC::RTP::Packet* packet,
|
|
51
|
+
bool lastSentPacketHasMarker,
|
|
52
|
+
uint32_t clockRate,
|
|
53
|
+
uint32_t maxPacketTs) override;
|
|
54
|
+
void RequestKeyFrame() override;
|
|
55
|
+
void RequestKeyFrameForTargetSpatialLayer() override;
|
|
56
|
+
void RequestKeyFrameForCurrentSpatialLayer() override;
|
|
57
|
+
void UpdateTargetLayers(int16_t newTargetSpatialLayer, int16_t newTargetTemporalLayer) override;
|
|
58
|
+
bool RecalculateTargetLayers(RTC::ConsumerTypes::VideoLayers& newTargetLayers) const override;
|
|
59
|
+
void OnTransportConnected() override;
|
|
60
|
+
void OnTransportDisconnected() override;
|
|
61
|
+
void OnPaused() override;
|
|
62
|
+
void OnResumed() override;
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
// Producer RTP stream (single stream for SVC).
|
|
66
|
+
RTC::RTP::RtpStreamRecv* producerRtpStream{ nullptr };
|
|
67
|
+
// BWE downgrade tracking.
|
|
68
|
+
uint64_t lastBweDowngradeAtMs{ 0u };
|
|
69
|
+
};
|
|
70
|
+
} // namespace RTC
|
|
71
|
+
|
|
72
|
+
#endif
|
|
@@ -154,7 +154,13 @@ namespace RTC
|
|
|
154
154
|
SharedInterface* shared,
|
|
155
155
|
const std::string& id,
|
|
156
156
|
RTC::Transport::Listener* listener,
|
|
157
|
-
const FBS::Transport::Options* options
|
|
157
|
+
const FBS::Transport::Options* options,
|
|
158
|
+
/**
|
|
159
|
+
* Whether the SCTP association (if enabled) must authenticate received
|
|
160
|
+
* State Cookies. This must be `true` for transports whose SCTP traffic
|
|
161
|
+
* is not protected by DTLS (PlainTransport and PipeTransport).
|
|
162
|
+
*/
|
|
163
|
+
bool requireSctpStateCookieAuthentication);
|
|
158
164
|
~Transport() override;
|
|
159
165
|
|
|
160
166
|
public:
|
package/worker/meson.build
CHANGED
|
@@ -119,7 +119,6 @@ common_sources = [
|
|
|
119
119
|
'src/RTC/DtlsTransport.cpp',
|
|
120
120
|
'src/RTC/KeyFrameRequestManager.cpp',
|
|
121
121
|
'src/RTC/NackGenerator.cpp',
|
|
122
|
-
'src/RTC/PipeConsumer.cpp',
|
|
123
122
|
'src/RTC/PipeTransport.cpp',
|
|
124
123
|
'src/RTC/PlainTransport.cpp',
|
|
125
124
|
'src/RTC/PortManager.cpp',
|
|
@@ -133,10 +132,11 @@ common_sources = [
|
|
|
133
132
|
'src/RTC/SenderBandwidthEstimator.cpp',
|
|
134
133
|
'src/RTC/SeqManager.cpp',
|
|
135
134
|
'src/RTC/Serializable.cpp',
|
|
136
|
-
'src/RTC/
|
|
137
|
-
'src/RTC/
|
|
135
|
+
'src/RTC/PipeProducerStreamManager.cpp',
|
|
136
|
+
'src/RTC/SimpleProducerStreamManager.cpp',
|
|
137
|
+
'src/RTC/SimulcastProducerStreamManager.cpp',
|
|
138
138
|
'src/RTC/SrtpSession.cpp',
|
|
139
|
-
'src/RTC/
|
|
139
|
+
'src/RTC/SvcProducerStreamManager.cpp',
|
|
140
140
|
'src/RTC/TcpConnection.cpp',
|
|
141
141
|
'src/RTC/TcpServer.cpp',
|
|
142
142
|
'src/RTC/Transport.cpp',
|
|
@@ -449,13 +449,17 @@ mock_sources = [
|
|
|
449
449
|
test_sources = [
|
|
450
450
|
'test/src/tests.cpp',
|
|
451
451
|
'test/src/testHelpers.cpp',
|
|
452
|
+
'test/src/RTC/TestConsumer.cpp',
|
|
453
|
+
'test/src/RTC/TestPipeProducerStreamManager.cpp',
|
|
454
|
+
'test/src/RTC/TestSimpleProducerStreamManager.cpp',
|
|
455
|
+
'test/src/RTC/TestSimulcastProducerStreamManager.cpp',
|
|
456
|
+
'test/src/RTC/TestSvcProducerStreamManager.cpp',
|
|
452
457
|
'test/src/RTC/TestKeyFrameRequestManager.cpp',
|
|
453
458
|
'test/src/RTC/TestNackGenerator.cpp',
|
|
454
459
|
'test/src/RTC/TestPortManager.cpp',
|
|
455
460
|
'test/src/RTC/TestRateCalculator.cpp',
|
|
456
461
|
'test/src/RTC/TestRtpEncodingParameters.cpp',
|
|
457
462
|
'test/src/RTC/TestSeqManager.cpp',
|
|
458
|
-
'test/src/RTC/TestSimpleConsumer.cpp',
|
|
459
463
|
'test/src/RTC/TestTransportCongestionControlServer.cpp',
|
|
460
464
|
'test/src/RTC/TestTransportTuple.cpp',
|
|
461
465
|
'test/src/RTC/TestTrendCalculator.cpp',
|