Skip to content

Commit

Permalink
feat(sfu): sequencer set correct meta close #592
Browse files Browse the repository at this point in the history
  • Loading branch information
OrlandoCo committed Oct 4, 2021
1 parent 7e18c95 commit 8d95f9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/sfu/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions pkg/sfu/sequencer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8d95f9f

Please sign in to comment.