diff --git a/worker/include/RTC/SeqManager.hpp b/worker/include/RTC/SeqManager.hpp index ec20b96e88..791faa26c2 100644 --- a/worker/include/RTC/SeqManager.hpp +++ b/worker/include/RTC/SeqManager.hpp @@ -36,7 +36,7 @@ namespace RTC SeqManager() = default; public: - void Sync(T input); + void Sync(T input, bool skip = false); void Drop(T input); void Offset(T offset); bool Input(const T input, T& output); diff --git a/worker/include/RTC/SimulcastConsumer.hpp b/worker/include/RTC/SimulcastConsumer.hpp index fad2728c88..5f75056173 100644 --- a/worker/include/RTC/SimulcastConsumer.hpp +++ b/worker/include/RTC/SimulcastConsumer.hpp @@ -101,6 +101,7 @@ namespace RTC std::vector rtpStreams; std::vector producerRtpStreams; // Indexed by spatial layer. bool syncRequired{ false }; + bool lastSentPacketHasMarker{ false }; RTC::SeqManager rtpSeqManager; int16_t preferredSpatialLayer{ -1 }; int16_t preferredTemporalLayer{ -1 }; diff --git a/worker/src/RTC/SeqManager.cpp b/worker/src/RTC/SeqManager.cpp index 61b5aa729b..a463ea3ff4 100644 --- a/worker/src/RTC/SeqManager.cpp +++ b/worker/src/RTC/SeqManager.cpp @@ -40,11 +40,14 @@ namespace RTC } template - void SeqManager::Sync(T input) + void SeqManager::Sync(T input, bool skip) { // Update base. this->base = this->maxOutput - input; + if (skip) + this->base += 1; + // Update maxInput. this->maxInput = input; diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index 36fdef4946..f6afa9c58c 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -791,7 +791,7 @@ namespace RTC this->tsOffset = tsOffset; // Sync our RTP stream's sequence number. - this->rtpSeqManager.Sync(packet->GetSequenceNumber() - 1); + this->rtpSeqManager.Sync(packet->GetSequenceNumber() - 1, !this->lastSentPacketHasMarker); this->encodingContext->SyncRequired(); @@ -869,6 +869,8 @@ namespace RTC // Process the packet. if (this->rtpStream->ReceivePacket(packet)) { + this->lastSentPacketHasMarker = packet->HasMarker(); + // Send the packet. this->listener->OnConsumerSendRtpPacket(this, packet);