mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-06 09:06:52 +08:00
改变avcc类型
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user