From 8d95f9f406e30bc1793978b0ea37b58aeef0c852 Mon Sep 17 00:00:00 2001 From: OrlandoCo Date: Mon, 4 Oct 2021 09:56:51 -0500 Subject: [PATCH] feat(sfu): sequencer set correct meta close #592 --- pkg/sfu/sequencer.go | 7 ++++--- pkg/sfu/sequencer_test.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/sfu/sequencer.go b/pkg/sfu/sequencer.go index aee06a819..dc26bf3cd 100644 --- a/pkg/sfu/sequencer.go +++ b/pkg/sfu/sequencer.go @@ -34,11 +34,11 @@ type packetMeta struct { misc uint32 } -func (p packetMeta) setVP8PayloadMeta(tlz0Idx uint8, picID uint16) { +func (p *packetMeta) setVP8PayloadMeta(tlz0Idx uint8, picID uint16) { p.misc = uint32(tlz0Idx)<<16 | uint32(picID) } -func (p packetMeta) getVP8PayloadMeta() (uint8, uint16) { +func (p *packetMeta) getVP8PayloadMeta() (uint8, uint16) { return uint8(p.misc >> 16), uint16(p.misc) } @@ -96,11 +96,12 @@ func (n *sequencer) push(sn, offSn uint16, timeStamp uint32, layer uint8, head b timestamp: timeStamp, layer: layer, } + pm := &n.seq[n.step] n.step++ if n.step >= n.max { n.step = 0 } - return &n.seq[n.step] + return pm } func (n *sequencer) getSeqNoPairs(seqNo []uint16) []packetMeta { diff --git a/pkg/sfu/sequencer_test.go b/pkg/sfu/sequencer_test.go index 3d1c2b491..ab97d9d3b 100644 --- a/pkg/sfu/sequencer_test.go +++ b/pkg/sfu/sequencer_test.go @@ -35,6 +35,19 @@ func Test_sequencer(t *testing.T) { assert.Equal(t, val.sourceSeqNo, req[i]-off) assert.Equal(t, val.layer, uint8(2)) } + + s := seq.push(521, 521+off, 123, 1, true) + var ( + tlzIdx = uint8(15) + picID = uint16(16) + ) + s.setVP8PayloadMeta(tlzIdx, picID) + s.sourceSeqNo = 12 + m := seq.getSeqNoPairs([]uint16{521 + off}) + assert.Equal(t, 1, len(m)) + tlz0, pID := m[0].getVP8PayloadMeta() + assert.Equal(t, tlzIdx, tlz0) + assert.Equal(t, picID, pID) } func Test_sequencer_getNACKSeqNo(t *testing.T) {