From 9a96abc11fe0b095de81e8eb43bbad39dac5d367 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Tue, 8 Aug 2023 23:44:03 +0530 Subject: [PATCH] Intermediate signed type casting (#1944) --- pkg/sfu/forwarder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index 6ab522da1..68c646808 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -1512,7 +1512,7 @@ func (f *Forwarder) processSourceSwitch(extPkt *buffer.ExtPacket, layer int32) e // Ideally, refTS should not be ahead of expectedTS, but expectedTS uses the first packet's // wall clock time. So, if the first packet experienced abmormal latency, it is possible // for refTS > expectedTS - diffSeconds := float64(expectedTS-refTS) / float64(f.codec.ClockRate) + diffSeconds := float64(int32(expectedTS-refTS)) / float64(f.codec.ClockRate) if diffSeconds >= 0.0 { if diffSeconds > ResumeBehindThresholdSeconds { f.logger.Infow("resume, reference too far behind", "expectedTS", expectedTS, "refTS", refTS, "diffSeconds", diffSeconds) @@ -1530,7 +1530,7 @@ func (f *Forwarder) processSourceSwitch(extPkt *buffer.ExtPacket, layer int32) e } } else { // switching between layers, check if refTS is too far behind the last sent - diffSeconds := float64(refTS-lastTS) / float64(f.codec.ClockRate) + diffSeconds := float64(int32(refTS-lastTS)) / float64(f.codec.ClockRate) if diffSeconds < 0.0 { if math.Abs(diffSeconds) > LayerSwitchBehindThresholdSeconds { // AVSYNC-TODO: This could be due to pacer trickling out this layer. Should potentially return error here and wait for a more opportune time @@ -1541,7 +1541,7 @@ func (f *Forwarder) processSourceSwitch(extPkt *buffer.ExtPacket, layer int32) e // use a nominal increase to ensure that timestamp is always moving forward nextTS = lastTS + 1 } else { - diffSeconds = float64(expectedTS-refTS) / float64(f.codec.ClockRate) + diffSeconds = float64(int32(expectedTS-refTS)) / float64(f.codec.ClockRate) if diffSeconds < 0.0 && math.Abs(diffSeconds) > SwitchAheadThresholdSeconds { f.logger.Infow("layer switch, reference too far ahead", "expectedTS", expectedTS, "refTS", refTS, "diffSeconds", math.Abs(diffSeconds)) nextTS = expectedTS