move multibuffer into dedicated folder

This commit is contained in:
aler9
2020-10-04 17:43:13 +02:00
parent 21d5bd9c12
commit 7ad47b8b30
4 changed files with 74 additions and 70 deletions

37
multiframe.go Normal file
View File

@@ -0,0 +1,37 @@
package gortsplib
import (
"github.com/aler9/gortsplib/base"
)
type multiFrame struct {
count int
frames []*base.InterleavedFrame
cur int
}
func newMultiFrame(count int, bufsize int) *multiFrame {
frames := make([]*base.InterleavedFrame, count)
for i := 0; i < count; i++ {
frames[i] = &base.InterleavedFrame{
Content: make([]byte, 0, bufsize),
}
}
return &multiFrame{
count: count,
frames: frames,
}
}
func (mf *multiFrame) next() *base.InterleavedFrame {
ret := mf.frames[mf.cur]
mf.cur += 1
if mf.cur >= mf.count {
mf.cur = 0
}
ret.Content = ret.Content[:cap(ret.Content)]
return ret
}