diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dda6f6800..ae24b981d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### NEXT - `SimulcastConsumer`: Fix increase layer when current layer has not receive SR ([PR #1098](https://github.com/versatica/mediasoup/pull/1098) by @penguinol). +- Ignore RTP packets with empty payload ([PR #1403](https://github.com/versatica/mediasoup/pull/1403), credits to @ggarber). ### 3.14.6 diff --git a/worker/include/RTC/RtcLogger.hpp b/worker/include/RTC/RtcLogger.hpp index a241d407c2..334e9df552 100644 --- a/worker/include/RTC/RtcLogger.hpp +++ b/worker/include/RTC/RtcLogger.hpp @@ -21,6 +21,7 @@ namespace RTC INVALID_TARGET_LAYER, UNSUPPORTED_PAYLOAD_TYPE, NOT_A_KEYFRAME, + EMPTY_PAYLOAD, SPATIAL_LAYER_MISMATCH, TOO_HIGH_TIMESTAMP_EXTRA_NEEDED, PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH, diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index 2312ed87c9..35a0c3d1a9 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -250,6 +250,18 @@ 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) + { + rtpSeqManager.Drop(packet->GetSequenceNumber()); + +#ifdef MS_RTC_LOGGER_RTP + packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::EMPTY_PAYLOAD); +#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()) diff --git a/worker/src/RTC/RtcLogger.cpp b/worker/src/RTC/RtcLogger.cpp index 2b7a72b093..4237dcd90f 100644 --- a/worker/src/RTC/RtcLogger.cpp +++ b/worker/src/RTC/RtcLogger.cpp @@ -18,6 +18,7 @@ namespace RTC { RtpPacket::DropReason::INVALID_TARGET_LAYER, "InvalidTargetLayer" }, { RtpPacket::DropReason::UNSUPPORTED_PAYLOAD_TYPE, "UnsupportedPayloadType" }, { RtpPacket::DropReason::NOT_A_KEYFRAME, "NotAKeyframe" }, + { RtpPacket::DropReason::EMPTY_PAYLOAD, "EmptyPayload" }, { RtpPacket::DropReason::SPATIAL_LAYER_MISMATCH, "SpatialLayerMismatch" }, { RtpPacket::DropReason::TOO_HIGH_TIMESTAMP_EXTRA_NEEDED, "TooHighTimestampExtraNeeded" }, { RtpPacket::DropReason::PACKET_PREVIOUS_TO_SPATIAL_LAYER_SWITCH, "PacketPreviousToSpatialLayerSwitch" }, diff --git a/worker/src/RTC/RtpStreamRecv.cpp b/worker/src/RTC/RtpStreamRecv.cpp index 70917e04ff..439f186908 100644 --- a/worker/src/RTC/RtpStreamRecv.cpp +++ b/worker/src/RTC/RtpStreamRecv.cpp @@ -303,6 +303,13 @@ namespace RTC // Calculate Jitter. CalculateJitter(packet->GetTimestamp()); + // Padding only packet, do not consider it for counter increase nor + // stream activation. + if (packet->GetPayloadLength() == 0) + { + return true; + } + // Increase transmission counter. this->transmissionCounter.Update(packet); @@ -413,6 +420,13 @@ namespace RTC // NACKed packet. if (this->nackGenerator->ReceivePacket(packet, /*isRecovered*/ true)) { + // Padding only packet, do not consider it for counter increase nor + // stream activation. + if (packet->GetPayloadLength() == 0) + { + return true; + } + // Mark the packet as repaired. RTC::RtpStream::PacketRepaired(packet); diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index 9523ce3f71..ce7fa9283c 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -314,6 +314,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; + } + auto payloadType = packet->GetPayloadType(); // NOTE: This may happen if this Consumer supports just some codecs of those diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index c0633ca636..d55ba6af58 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -724,6 +724,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; + } + if (this->targetTemporalLayer == -1) { #ifdef MS_RTC_LOGGER_RTP diff --git a/worker/src/RTC/SvcConsumer.cpp b/worker/src/RTC/SvcConsumer.cpp index 24ddf2418c..bc0ce1417b 100644 --- a/worker/src/RTC/SvcConsumer.cpp +++ b/worker/src/RTC/SvcConsumer.cpp @@ -639,6 +639,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; + } + // clang-format off if ( this->encodingContext->GetTargetSpatialLayer() == -1 ||