mediasoup 3.20.4 → 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/SeqManager.hpp +2 -2
- 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 +142 -3
- package/worker/src/RTC/SCTP/association/StateCookie.cpp +96 -31
- package/worker/src/RTC/SCTP/association/StreamResetHandler.cpp +4 -0
- 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/SCTP/rx/DataTracker.cpp +4 -1
- package/worker/src/RTC/SeqManager.cpp +42 -29
- 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
|
@@ -419,7 +419,7 @@ namespace RTC
|
|
|
419
419
|
|
|
420
420
|
auto crc32c = GetChecksum();
|
|
421
421
|
|
|
422
|
-
// NOTE: Cannot use SetChecksum() because
|
|
422
|
+
// NOTE: Cannot use `SetChecksum()` because this is a `const` method.
|
|
423
423
|
GetHeaderPointer()->checksum = 0;
|
|
424
424
|
|
|
425
425
|
auto computedCrc32c = Utils::Crypto::GetCRC32c(GetBuffer(), GetLength());
|
|
@@ -122,7 +122,10 @@ namespace RTC
|
|
|
122
122
|
uint32_t remoteInitialTsn,
|
|
123
123
|
uint32_t remoteAdvertisedReceiverWindowCredit,
|
|
124
124
|
uint64_t tieTag,
|
|
125
|
-
const NegotiatedCapabilities& negotiatedCapabilities
|
|
125
|
+
const NegotiatedCapabilities& negotiatedCapabilities,
|
|
126
|
+
uint64_t creationTimestampMs,
|
|
127
|
+
const uint8_t* macKey,
|
|
128
|
+
size_t macKeyLength)
|
|
126
129
|
{
|
|
127
130
|
MS_TRACE();
|
|
128
131
|
|
|
@@ -144,9 +147,15 @@ namespace RTC
|
|
|
144
147
|
remoteInitialTsn,
|
|
145
148
|
remoteAdvertisedReceiverWindowCredit,
|
|
146
149
|
tieTag,
|
|
147
|
-
negotiatedCapabilities
|
|
150
|
+
negotiatedCapabilities,
|
|
151
|
+
creationTimestampMs,
|
|
152
|
+
macKey,
|
|
153
|
+
macKeyLength);
|
|
148
154
|
|
|
149
|
-
|
|
155
|
+
const size_t cookieLength = macKey != nullptr ? StateCookie::AuthenticatedStateCookieLength
|
|
156
|
+
: StateCookie::StateCookieLength;
|
|
157
|
+
|
|
158
|
+
SetVariableLengthValueLength(cookieLength);
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
StateCookieParameter* StateCookieParameter::SoftClone(const uint8_t* buffer) const
|
|
@@ -84,6 +84,10 @@ namespace RTC
|
|
|
84
84
|
ZeroChecksumAcceptableParameter::AlternateErrorDetectionMethodToString(
|
|
85
85
|
this->zeroChecksumAlternateErrorDetectionMethod)
|
|
86
86
|
.c_str());
|
|
87
|
+
MS_DUMP_CLEAN(
|
|
88
|
+
indentation,
|
|
89
|
+
" require authenticated cookie: %s",
|
|
90
|
+
this->requireAuthenticatedCookie ? "yes" : "no");
|
|
87
91
|
MS_DUMP_CLEAN(indentation, "</SCTP::SctpOptions>");
|
|
88
92
|
}
|
|
89
93
|
} // namespace SCTP
|
|
@@ -268,7 +268,9 @@ namespace RTC
|
|
|
268
268
|
{
|
|
269
269
|
MS_TRACE();
|
|
270
270
|
|
|
271
|
-
UpdateAckState(
|
|
271
|
+
// NOTE: Assign directly instead of going through UpdateAckState() to avoid
|
|
272
|
+
// its side effect of stopping the delayed-ack timer.
|
|
273
|
+
this->ackState = AckState::IMMEDIATE;
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
bool DataTracker::WillIncreaseCumAckTsn(uint32_t tsn) const
|
|
@@ -359,6 +361,7 @@ namespace RTC
|
|
|
359
361
|
{
|
|
360
362
|
this->delayedAckTimer->Start();
|
|
361
363
|
}
|
|
364
|
+
|
|
362
365
|
this->ackState = newAckState;
|
|
363
366
|
}
|
|
364
367
|
}
|
|
@@ -63,9 +63,15 @@ namespace RTC
|
|
|
63
63
|
{
|
|
64
64
|
this->maxInput = input;
|
|
65
65
|
this->maxDropped = input;
|
|
66
|
-
// Insert input in
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// Insert input in sorted order, if not present.
|
|
67
|
+
const SeqLowerThan seqLowerThan;
|
|
68
|
+
const auto it =
|
|
69
|
+
std::lower_bound(this->dropped.begin(), this->dropped.end(), input, seqLowerThan);
|
|
70
|
+
|
|
71
|
+
if (it == this->dropped.end() || *it != input)
|
|
72
|
+
{
|
|
73
|
+
this->dropped.insert(it, input);
|
|
74
|
+
}
|
|
69
75
|
|
|
70
76
|
ClearDropped();
|
|
71
77
|
}
|
|
@@ -74,7 +80,15 @@ namespace RTC
|
|
|
74
80
|
// Allows for properly accounting for out of order drops until an input is forwarded.
|
|
75
81
|
else if (this->maxInput == this->maxDropped && SeqManager<T, N>::IsSeqHigherThan(input, this->maxForwarded))
|
|
76
82
|
{
|
|
77
|
-
|
|
83
|
+
// Insert input in sorted order, if not present.
|
|
84
|
+
const SeqLowerThan seqLowerThan;
|
|
85
|
+
const auto it =
|
|
86
|
+
std::lower_bound(this->dropped.begin(), this->dropped.end(), input, seqLowerThan);
|
|
87
|
+
|
|
88
|
+
if (it == this->dropped.end() || *it != input)
|
|
89
|
+
{
|
|
90
|
+
this->dropped.insert(it, input);
|
|
91
|
+
}
|
|
78
92
|
|
|
79
93
|
ClearDropped();
|
|
80
94
|
}
|
|
@@ -112,22 +126,24 @@ namespace RTC
|
|
|
112
126
|
{
|
|
113
127
|
goto done;
|
|
114
128
|
}
|
|
115
|
-
// This input was dropped.
|
|
116
|
-
else if (this->dropped.find(input) != this->dropped.end())
|
|
117
|
-
{
|
|
118
|
-
MS_DEBUG_DEV("trying to send a dropped input");
|
|
119
|
-
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
// There are dropped inputs, calculate 'base' for this input.
|
|
123
129
|
else
|
|
124
130
|
{
|
|
125
|
-
|
|
131
|
+
const SeqLowerThan seqLowerThan;
|
|
132
|
+
const auto it =
|
|
133
|
+
std::lower_bound(this->dropped.begin(), this->dropped.end(), input, seqLowerThan);
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
if (it != this->dropped.end() && *it == input)
|
|
136
|
+
{
|
|
137
|
+
MS_DEBUG_DEV("trying to send a dropped input");
|
|
138
|
+
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// There are dropped inputs, calculate 'base' for this input.
|
|
143
|
+
auto droppedCount = std::distance(
|
|
144
|
+
this->dropped.begin(),
|
|
145
|
+
std::lower_bound(this->dropped.begin(), this->dropped.end(), input, SeqLowerThan()));
|
|
129
146
|
|
|
130
|
-
droppedCount -= std::distance(it, this->dropped.end());
|
|
131
147
|
base = (this->base - droppedCount) & SeqManager::MaxValue;
|
|
132
148
|
}
|
|
133
149
|
|
|
@@ -191,19 +207,16 @@ namespace RTC
|
|
|
191
207
|
|
|
192
208
|
const size_t previousDroppedSize = this->dropped.size();
|
|
193
209
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
210
|
+
// Cleanup dropped values.
|
|
211
|
+
this->dropped.erase(
|
|
212
|
+
this->dropped.begin(),
|
|
213
|
+
std::find_if(
|
|
214
|
+
this->dropped.begin(),
|
|
215
|
+
this->dropped.end(),
|
|
216
|
+
[this](T value)
|
|
217
|
+
{
|
|
218
|
+
return !SeqManager<T, N>::IsSeqHigherThan(value, this->maxInput);
|
|
219
|
+
}));
|
|
207
220
|
|
|
208
221
|
// Adapt base.
|
|
209
222
|
this->base = (this->base - (previousDroppedSize - this->dropped.size())) & SeqManager::MaxValue;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
#define MS_CLASS "RTC::SimpleProducerStreamManager"
|
|
2
|
+
// #define MS_LOG_DEV_LEVEL 3
|
|
3
|
+
|
|
4
|
+
#include "RTC/SimpleProducerStreamManager.hpp"
|
|
5
|
+
#include "Logger.hpp"
|
|
6
|
+
|
|
7
|
+
namespace RTC
|
|
8
|
+
{
|
|
9
|
+
/* Instance methods. */
|
|
10
|
+
|
|
11
|
+
SimpleProducerStreamManager::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
|
+
: ProducerStreamManager(
|
|
20
|
+
consumableRtpEncodings,
|
|
21
|
+
preferredLayers,
|
|
22
|
+
std::move(encodingContext),
|
|
23
|
+
kind,
|
|
24
|
+
keyFrameSupported,
|
|
25
|
+
listener,
|
|
26
|
+
shared)
|
|
27
|
+
{
|
|
28
|
+
MS_TRACE();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
RTC::RTP::RtpStreamRecv* SimpleProducerStreamManager::GetProducerCurrentRtpStream() const
|
|
32
|
+
{
|
|
33
|
+
MS_TRACE();
|
|
34
|
+
|
|
35
|
+
return this->producerRtpStream;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
RTC::RTP::RtpStreamRecv* SimpleProducerStreamManager::GetProducerTargetRtpStream() const
|
|
39
|
+
{
|
|
40
|
+
MS_TRACE();
|
|
41
|
+
|
|
42
|
+
return this->producerRtpStream;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
bool SimpleProducerStreamManager::IsActive() const
|
|
46
|
+
{
|
|
47
|
+
MS_TRACE();
|
|
48
|
+
|
|
49
|
+
// clang-format off
|
|
50
|
+
return (
|
|
51
|
+
this->listener->IsActive() &&
|
|
52
|
+
this->producerRtpStream &&
|
|
53
|
+
// If there is no RTP inactivity check do not consider the stream
|
|
54
|
+
// inactive despite it has score 0.
|
|
55
|
+
(this->producerRtpStream->GetScore() > 0u || !this->producerRtpStream->HasRtpInactivityCheckEnabled())
|
|
56
|
+
);
|
|
57
|
+
// clang-format on
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void SimpleProducerStreamManager::ProducerRtpStream(
|
|
61
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
|
|
62
|
+
{
|
|
63
|
+
MS_TRACE();
|
|
64
|
+
|
|
65
|
+
this->producerRtpStream = rtpStream;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void SimpleProducerStreamManager::ProducerNewRtpStream(
|
|
69
|
+
RTC::RTP::RtpStreamRecv* rtpStream, uint32_t /*mappedSsrc*/)
|
|
70
|
+
{
|
|
71
|
+
MS_TRACE();
|
|
72
|
+
|
|
73
|
+
this->producerRtpStream = rtpStream;
|
|
74
|
+
|
|
75
|
+
// Emit the score event.
|
|
76
|
+
this->listener->OnProducerStreamManagerScore();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void SimpleProducerStreamManager::ProducerRtpStreamScore(
|
|
80
|
+
RTC::RTP::RtpStreamRecv* /*rtpStream*/, uint8_t /*score*/, uint8_t /*previousScore*/)
|
|
81
|
+
{
|
|
82
|
+
MS_TRACE();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void SimpleProducerStreamManager::ProducerRtcpSenderReport(
|
|
86
|
+
RTC::RTP::RtpStreamRecv* /*rtpStream*/, bool /*first*/)
|
|
87
|
+
{
|
|
88
|
+
MS_TRACE();
|
|
89
|
+
|
|
90
|
+
// Do nothing.
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
uint32_t SimpleProducerStreamManager::IncreaseLayer(
|
|
94
|
+
uint32_t bitrate, bool /*considerLoss*/, float /*lossPercentage*/, uint64_t nowMs)
|
|
95
|
+
{
|
|
96
|
+
MS_TRACE();
|
|
97
|
+
|
|
98
|
+
MS_ASSERT(this->externallyManagedBitrate, "bitrate is not externally managed");
|
|
99
|
+
MS_ASSERT(this->kind == RTC::Media::Kind::VIDEO, "should be video");
|
|
100
|
+
MS_ASSERT(IsActive(), "should be active");
|
|
101
|
+
|
|
102
|
+
// If this is not the first time this method is called within the same
|
|
103
|
+
// iteration, return 0 since a video Simple consumer does not keep state
|
|
104
|
+
// about this.
|
|
105
|
+
if (this->managingBitrate)
|
|
106
|
+
{
|
|
107
|
+
return 0u;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this->managingBitrate = true;
|
|
111
|
+
|
|
112
|
+
if (!this->producerRtpStream)
|
|
113
|
+
{
|
|
114
|
+
return 0u;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Video Simple consumer does not really play the BWE game. However, let's
|
|
118
|
+
// be honest and try to be nice.
|
|
119
|
+
auto desiredBitrate = this->producerRtpStream->GetBitrate(nowMs);
|
|
120
|
+
|
|
121
|
+
if (desiredBitrate < bitrate)
|
|
122
|
+
{
|
|
123
|
+
return desiredBitrate;
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
{
|
|
127
|
+
return bitrate;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
void SimpleProducerStreamManager::ApplyLayers(uint64_t /*rtpStreamActiveMs*/)
|
|
132
|
+
{
|
|
133
|
+
MS_TRACE();
|
|
134
|
+
|
|
135
|
+
MS_ASSERT(this->externallyManagedBitrate, "bitrate is not externally managed");
|
|
136
|
+
MS_ASSERT(this->kind == RTC::Media::Kind::VIDEO, "should be video");
|
|
137
|
+
MS_ASSERT(IsActive(), "should be active");
|
|
138
|
+
|
|
139
|
+
this->managingBitrate = false;
|
|
140
|
+
|
|
141
|
+
// Simple does not play the BWE game (even if video kind).
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
uint32_t SimpleProducerStreamManager::GetDesiredBitrate(uint64_t nowMs) const
|
|
145
|
+
{
|
|
146
|
+
MS_TRACE();
|
|
147
|
+
|
|
148
|
+
MS_ASSERT(this->externallyManagedBitrate, "bitrate is not externally managed");
|
|
149
|
+
|
|
150
|
+
// Audio does not play the BWE game.
|
|
151
|
+
if (this->kind != RTC::Media::Kind::VIDEO)
|
|
152
|
+
{
|
|
153
|
+
return 0u;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!IsActive())
|
|
157
|
+
{
|
|
158
|
+
return 0u;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return this->producerRtpStream->GetBitrate(nowMs);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
ProducerStreamManager::RtpPacketProcessResult SimpleProducerStreamManager::ProcessRtpPacket(
|
|
165
|
+
RTC::RTP::Packet* packet,
|
|
166
|
+
bool /*lastSentPacketHasMarker*/,
|
|
167
|
+
uint32_t /*clockRate*/,
|
|
168
|
+
uint32_t /*maxPacketTs*/)
|
|
169
|
+
{
|
|
170
|
+
MS_TRACE();
|
|
171
|
+
|
|
172
|
+
RtpPacketProcessResult result;
|
|
173
|
+
|
|
174
|
+
// If we need to sync, support key frames and this is not a key frame,
|
|
175
|
+
// ignore the packet.
|
|
176
|
+
if (this->syncRequired && this->keyFrameSupported && !packet->IsKeyFrame())
|
|
177
|
+
{
|
|
178
|
+
// NOTE: No need to drop the packet in the RTP sequence manager since here
|
|
179
|
+
// we are blocking all packets but the key frame that would trigger sync
|
|
180
|
+
// below.
|
|
181
|
+
|
|
182
|
+
// Store the packet for the scenario in which this packet is part of the
|
|
183
|
+
// key frame and it arrived before the first packet of the key frame.
|
|
184
|
+
result.type = RtpPacketProcessResult::Type::BUFFER;
|
|
185
|
+
|
|
186
|
+
#ifdef MS_RTC_LOGGER_RTP
|
|
187
|
+
packet->logger.Discarded(RTC::RtcLogger::RtpPacket::DiscardReason::NOT_A_KEYFRAME);
|
|
188
|
+
#endif
|
|
189
|
+
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Packets with only padding are not forwarded.
|
|
194
|
+
if (packet->GetPayloadLength() == 0)
|
|
195
|
+
{
|
|
196
|
+
result.type = RtpPacketProcessResult::Type::DROP;
|
|
197
|
+
|
|
198
|
+
#ifdef MS_RTC_LOGGER_RTP
|
|
199
|
+
packet->logger.Discarded(RTC::RtcLogger::RtpPacket::DiscardReason::EMPTY_PAYLOAD);
|
|
200
|
+
#endif
|
|
201
|
+
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Preserve the original marker bit. ProcessPayload may update it.
|
|
206
|
+
bool marker{ packet->HasMarker() };
|
|
207
|
+
|
|
208
|
+
// Process the payload if needed. Drop packet if necessary.
|
|
209
|
+
if (this->encodingContext && !packet->ProcessPayload(this->encodingContext.get(), marker))
|
|
210
|
+
{
|
|
211
|
+
MS_DEBUG_DEV(
|
|
212
|
+
"discarding packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
|
|
213
|
+
packet->GetSsrc(),
|
|
214
|
+
packet->GetSequenceNumber(),
|
|
215
|
+
packet->GetTimestamp());
|
|
216
|
+
|
|
217
|
+
result.type = RtpPacketProcessResult::Type::DROP;
|
|
218
|
+
|
|
219
|
+
#ifdef MS_RTC_LOGGER_RTP
|
|
220
|
+
packet->logger.Discarded(RTC::RtcLogger::RtpPacket::DiscardReason::DROPPED_BY_CODEC);
|
|
221
|
+
#endif
|
|
222
|
+
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Whether this is the first packet after re-sync.
|
|
227
|
+
const bool isSyncPacket = this->syncRequired;
|
|
228
|
+
|
|
229
|
+
// Whether packets stored in the target layer retransmission buffer must be
|
|
230
|
+
// sent once this packet is sent.
|
|
231
|
+
bool sendBufferedPackets{ false };
|
|
232
|
+
|
|
233
|
+
// Sync sequence number and timestamp if required.
|
|
234
|
+
if (isSyncPacket)
|
|
235
|
+
{
|
|
236
|
+
if (packet->IsKeyFrame())
|
|
237
|
+
{
|
|
238
|
+
MS_DEBUG_TAG(
|
|
239
|
+
rtp,
|
|
240
|
+
"sync key frame received [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "]",
|
|
241
|
+
packet->GetSsrc(),
|
|
242
|
+
packet->GetSequenceNumber(),
|
|
243
|
+
packet->GetTimestamp());
|
|
244
|
+
|
|
245
|
+
sendBufferedPackets = true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
result.isSyncPacket = true;
|
|
249
|
+
result.syncSeqValue = packet->GetSequenceNumber() - 1;
|
|
250
|
+
|
|
251
|
+
this->syncRequired = false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Set forward action.
|
|
255
|
+
result.type = RtpPacketProcessResult::Type::FORWARD;
|
|
256
|
+
result.tsOffset = 0u;
|
|
257
|
+
result.marker = marker;
|
|
258
|
+
result.sendBufferedPackets = sendBufferedPackets;
|
|
259
|
+
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
void SimpleProducerStreamManager::RequestKeyFrame()
|
|
264
|
+
{
|
|
265
|
+
MS_TRACE();
|
|
266
|
+
|
|
267
|
+
if (this->kind != RTC::Media::Kind::VIDEO)
|
|
268
|
+
{
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
auto mappedSsrc = this->consumableRtpEncodings[0].ssrc;
|
|
273
|
+
|
|
274
|
+
this->listener->OnProducerStreamManagerKeyFrameRequested(mappedSsrc);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void SimpleProducerStreamManager::RequestKeyFrameForTargetSpatialLayer()
|
|
278
|
+
{
|
|
279
|
+
MS_TRACE();
|
|
280
|
+
|
|
281
|
+
RequestKeyFrame();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
void SimpleProducerStreamManager::RequestKeyFrameForCurrentSpatialLayer()
|
|
285
|
+
{
|
|
286
|
+
MS_TRACE();
|
|
287
|
+
|
|
288
|
+
RequestKeyFrame();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
void SimpleProducerStreamManager::UpdateTargetLayers(int16_t /*spatial*/, int16_t /*temporal*/)
|
|
292
|
+
{
|
|
293
|
+
MS_TRACE();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
bool SimpleProducerStreamManager::RecalculateTargetLayers(
|
|
297
|
+
RTC::ConsumerTypes::VideoLayers& /*newTargetLayers*/) const
|
|
298
|
+
{
|
|
299
|
+
MS_TRACE();
|
|
300
|
+
|
|
301
|
+
// No layer changes possible for Simple.
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void SimpleProducerStreamManager::OnTransportConnected()
|
|
306
|
+
{
|
|
307
|
+
MS_TRACE();
|
|
308
|
+
|
|
309
|
+
this->syncRequired = true;
|
|
310
|
+
|
|
311
|
+
if (IsActive())
|
|
312
|
+
{
|
|
313
|
+
RequestKeyFrame();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
void SimpleProducerStreamManager::OnTransportDisconnected()
|
|
318
|
+
{
|
|
319
|
+
MS_TRACE();
|
|
320
|
+
|
|
321
|
+
// Nothing specific for Simple.
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
void SimpleProducerStreamManager::OnPaused()
|
|
325
|
+
{
|
|
326
|
+
MS_TRACE();
|
|
327
|
+
|
|
328
|
+
// Nothing specific for Simple.
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
void SimpleProducerStreamManager::OnResumed()
|
|
332
|
+
{
|
|
333
|
+
MS_TRACE();
|
|
334
|
+
|
|
335
|
+
this->syncRequired = true;
|
|
336
|
+
|
|
337
|
+
if (IsActive())
|
|
338
|
+
{
|
|
339
|
+
RequestKeyFrame();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
} // namespace RTC
|