From 7d556cfefeffaf5192e0d5c5fd0234d2e41d1d8c Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Thu, 13 Aug 2026 19:32:21 +0800 Subject: [PATCH] sample codec payload mismatch error log (#4751) --- pkg/sfu/buffer/buffer_base.go | 21 +++++++++++++-------- pkg/sfu/receiver_base.go | 16 +++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pkg/sfu/buffer/buffer_base.go b/pkg/sfu/buffer/buffer_base.go index 68980ea05..bf373a8e5 100644 --- a/pkg/sfu/buffer/buffer_base.go +++ b/pkg/sfu/buffer/buffer_base.go @@ -204,9 +204,10 @@ type BufferBase struct { frameRateCalculator [DefaultMaxLayerSpatial + 1]FrameRateCalculator frameRateCalculated bool - packetNotFoundCount atomic.Uint32 - packetTooOldCount atomic.Uint32 - extPacketTooMuchCount atomic.Uint32 + packetNotFoundCount atomic.Uint32 + packetTooOldCount atomic.Uint32 + extPacketTooMuchCount atomic.Uint32 + codecPayloadTypeNotFoundCount atomic.Uint32 absCaptureTimeExtID uint8 @@ -986,11 +987,15 @@ func (b *BufferBase) handleCodecChange(newPT uint8) { } } if !codecFound { - b.logger.Errorw( - "could not find codec for new payload type", nil, - "pt", newPT, - "rtpParameters", b.rtpParameters, - ) + codecNotFoundCount := b.codecPayloadTypeNotFoundCount.Inc() + if (codecNotFoundCount-1)%100 == 0 { + b.logger.Errorw( + "could not find codec for new payload type", nil, + "pt", newPT, + "rtpParameters", b.rtpParameters, + "count", codecNotFoundCount, + ) + } return } diff --git a/pkg/sfu/receiver_base.go b/pkg/sfu/receiver_base.go index 891566820..ecc08d04b 100644 --- a/pkg/sfu/receiver_base.go +++ b/pkg/sfu/receiver_base.go @@ -155,6 +155,8 @@ type ReceiverBase struct { restartInProgress bool isClosed atomic.Bool + + dropPayloadTypeMismatchCount atomic.Uint32 } func NewReceiverBase(params ReceiverBaseParams, trackInfo *livekit.TrackInfo, codecState ReceiverCodecState) *ReceiverBase { @@ -932,11 +934,15 @@ func (r *ReceiverBase) forwardRTP( if extPkt.Packet.PayloadType != uint8(r.params.Codec.PayloadType) { // drop packets as we don't support codec fallback directly - r.params.Logger.Debugw( - "dropping packet - payload mismatch", - "packetPayloadType", extPkt.Packet.PayloadType, - "payloadType", r.params.Codec.PayloadType, - ) + dropPayloadTypeMismatchCount := r.dropPayloadTypeMismatchCount.Inc() + if (dropPayloadTypeMismatchCount-1)%100 == 0 { + r.params.Logger.Debugw( + "dropping packet - payload mismatch", + "packetPayloadType", extPkt.Packet.PayloadType, + "payloadType", r.params.Codec.PayloadType, + "count", dropPayloadTypeMismatchCount, + ) + } numPacketsDropped++ continue }