改变avcc类型

This commit is contained in:
dexter
2023-01-19 20:33:20 +08:00
parent 5c5747e669
commit b77e57b1bb
11 changed files with 241 additions and 70 deletions

View File

@@ -3,6 +3,7 @@ package util
import (
"encoding/binary"
"math"
"net"
)
type Buffer []byte
@@ -83,15 +84,35 @@ func (b *Buffer) Malloc(count int) Buffer {
}
return b.SubBuf(l, count)
}
func (b *Buffer) Reset() {
*b = b.SubBuf(0, 0)
}
func (b *Buffer) Glow(n int) {
l := b.Len()
b.Malloc(n)
*b = b.SubBuf(0, l)
}
func (b *Buffer) Split(n int) (result net.Buffers) {
origin := *b
for {
if b.CanReadN(n) {
result = append(result, b.ReadN(n))
} else {
result = append(result, *b)
*b = origin
return
}
}
}
func (b *Buffer) MarshalAMFs(v ...any) {
amf := AMF{*b}
*b = amf.Marshals(v...)
}
// MallocSlice 用来对容量够的slice进行长度扩展+1并返回新的位置的指针用于写入
func MallocSlice[T any](slice *[]T) *T {
oslice := *slice