Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frozen video in simulcast due to wrong dropping of padding only packets #1431

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions worker/src/RTC/PipeConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions worker/src/RTC/SimpleConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
25 changes: 13 additions & 12 deletions worker/src/RTC/SimulcastConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

ibc marked this conversation as resolved.
Show resolved Hide resolved
// Whether this is the first packet after re-sync.
const bool isSyncPacket = this->syncRequired;

Expand Down
24 changes: 12 additions & 12 deletions worker/src/RTC/SvcConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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;

Expand Down
Loading