From e48c8185329959278b5b08590631d3e7c421901e Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 3 Mar 2023 12:18:25 +0530 Subject: [PATCH] Resync on pub muted for audio to avoid jump in sequence numbers on (#1487) unmute. --- pkg/sfu/forwarder.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index bc6c6cd6..272fd80e 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -347,11 +347,19 @@ func (f *Forwarder) PubMute(pubMuted bool) (bool, VideoLayers) { f.logger.Debugw("setting forwarder pub mute", "pubMuted", pubMuted) f.pubMuted = pubMuted - // Do not resync on publisher mute as forwarding can continue on unmute using same layers. - // On unmute, park current layers as streaming can continue without a key frame when publisher starts the stream. - if !pubMuted && f.targetLayers.IsValid() && f.currentLayers.Spatial == f.targetLayers.Spatial { - f.setupParkedLayers(f.targetLayers) - f.currentLayers = InvalidLayers + if f.kind == webrtc.RTPCodecTypeAudio { + // for audio resync when pub muted so that sequence numbers do not jump on unmute + // audio stops forwarding during pub mute too + if pubMuted { + f.resyncLocked() + } + } else { + // Do not resync on publisher mute as forwarding can continue on unmute using same layers. + // On unmute, park current layers as streaming can continue without a key frame when publisher starts the stream. + if !pubMuted && f.targetLayers.IsValid() && f.currentLayers.Spatial == f.targetLayers.Spatial { + f.setupParkedLayers(f.targetLayers) + f.currentLayers = InvalidLayers + } } return true, f.maxLayers