diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2f166941..d8c305d495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Worker: Test, fix buffer overflow ([PR #1419](https://github.com/versatica/mediasoup/pull/1419)). - Bump up Meson from 1.3.0 to 1.5.0 ([PR #1424](https://github.com/versatica/mediasoup/pull/1424)). - Node: Export new `WorkerObserver`, `ProducerObserver`, etc. TypeScript types ([PR #1430](https://github.com/versatica/mediasoup/pull/1430)). +- Fix frozen video in simulcast due to wrong dropping of padding only packets ([PR #1431](https://github.com/versatica/mediasoup/pull/1431), thanks to @quanli168). ### 3.14.8 diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index 35a0c3d1a9..cde4fbfc76 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -250,24 +250,24 @@ namespace RTC auto& syncRequired = this->mapRtpStreamSyncRequired.at(rtpStream); auto& rtpSeqManager = this->mapRtpStreamRtpSeqManager.at(rtpStream); - // Packets with only padding are not forwarded. - if (packet->GetPayloadLength() == 0) + // If we need to sync, support key frames and this is not a key frame, ignore + // the packet. + if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame()) { - rtpSeqManager.Drop(packet->GetSequenceNumber()); - #ifdef MS_RTC_LOGGER_RTP - packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); #endif return; } - // If we need to sync, support key frames and this is not a key frame, ignore - // the packet. - if (syncRequired && this->keyFrameSupported && !packet->IsKeyFrame()) + // Packets with only padding are not forwarded. + if (packet->GetPayloadLength() == 0) { + rtpSeqManager.Drop(packet->GetSequenceNumber()); + #ifdef MS_RTC_LOGGER_RTP - packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::NOT_A_KEYFRAME); + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); #endif return; diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index ce7fa9283c..d2b635babe 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -314,18 +314,6 @@ namespace RTC return; } - // Packets with only padding are not forwarded. - if (packet->GetPayloadLength() == 0) - { - this->rtpSeqManager.Drop(packet->GetSequenceNumber()); - -#ifdef MS_RTC_LOGGER_RTP - packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); -#endif - - return; - } - auto payloadType = packet->GetPayloadType(); // NOTE: This may happen if this Consumer supports just some codecs of those @@ -372,6 +360,18 @@ namespace RTC return; } + // Packets with only padding are not forwarded. + if (packet->GetPayloadLength() == 0) + { + this->rtpSeqManager.Drop(packet->GetSequenceNumber()); + +#ifdef MS_RTC_LOGGER_RTP + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); +#endif + + return; + } + // Whether this is the first packet after re-sync. const bool isSyncPacket = this->syncRequired; diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index 847d4beb64..bc54bf3424 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -730,18 +730,6 @@ namespace RTC return; } - // Packets with only padding are not forwarded. - if (packet->GetPayloadLength() == 0) - { - this->rtpSeqManager.Drop(packet->GetSequenceNumber()); - -#ifdef MS_RTC_LOGGER_RTP - packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); -#endif - - return; - } - if (this->targetTemporalLayer == -1) { #ifdef MS_RTC_LOGGER_RTP @@ -810,6 +798,19 @@ namespace RTC return; } + // If the packet belongs to current spatial layer being sent and packet does + // not have payload other than padding, then drop it. + if (spatialLayer == this->currentSpatialLayer && packet->GetPayloadLength() == 0) + { + this->rtpSeqManager.Drop(packet->GetSequenceNumber()); + +#ifdef MS_RTC_LOGGER_RTP + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); +#endif + + return; + } + // Whether this is the first packet after re-sync. const bool isSyncPacket = this->syncRequired; diff --git a/worker/src/RTC/SvcConsumer.cpp b/worker/src/RTC/SvcConsumer.cpp index bc0ce1417b..a2337b4f81 100644 --- a/worker/src/RTC/SvcConsumer.cpp +++ b/worker/src/RTC/SvcConsumer.cpp @@ -639,18 +639,6 @@ namespace RTC return; } - // Packets with only padding are not forwarded. - if (packet->GetPayloadLength() == 0) - { - this->rtpSeqManager.Drop(packet->GetSequenceNumber()); - -#ifdef MS_RTC_LOGGER_RTP - packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); -#endif - - return; - } - // clang-format off if ( this->encodingContext->GetTargetSpatialLayer() == -1 || @@ -690,6 +678,18 @@ namespace RTC return; } + // Packets with only padding are not forwarded. + if (packet->GetPayloadLength() == 0) + { + this->rtpSeqManager.Drop(packet->GetSequenceNumber()); + +#ifdef MS_RTC_LOGGER_RTP + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); +#endif + + return; + } + // Whether this is the first packet after re-sync. const bool isSyncPacket = this->syncRequired;