Documentation ¶
Index ¶
- Constants
- Variables
- func BasicAuth(u, p string, next http.Handler) http.Handler
- func BigLittleSwap(v uint) uint
- func Bit1(b byte, index int) bool
- func ByteToUint32(data []byte, bigEndian bool) (ret uint32, err error)
- func ByteToUint32N(data []byte) (ret uint32, err error)
- func ByteToUint64N(data []byte) (ret uint64, err error)
- func CORS(next http.Handler) http.Handler
- func Clone[T any](x T) *T
- func ConcatBuffers[T ~[]byte](input []T) (out []byte)
- func Conditoinal[T any](cond bool, t, f T) T
- func Conf2Listener(conf string) (protocol string, ports []uint16)
- func ConvertNum[F Integer, T Integer](from F, to T) T
- func CreateShutdownScript() error
- func CurrentDir(path ...string) string
- func Exist(filename string) bool
- func FetchValue[T any](t T) func() T
- func GetBE[T Integer](b []byte, num *T) T
- func GetFillBytes(data byte, n int) []byte
- func GetPCR(v uint64) uint64
- func GetPtsDts(v uint64) uint64
- func GetUev(buff []byte, start int) (value int, pos int)
- func IsLANAddr(ip string) (bool, string)
- func IsLANIp(ip net.IP) (bool, string)
- func IsSubdir(baseDir, joinedDir string) bool
- func LastElement[T any](s []T) T
- func ListenUDP(address string, networkBuffer int) (*net.UDPConn, error)
- func MapList[K comparable, V any, R any](m *Map[K, V], f func(K, V) R) (r []R)
- func MarshalAMFs(v ...any) []byte
- func PutBE[T Integer](b []byte, num T) []byte
- func PutPCR(pcr uint64) uint64
- func PutPtsDts(v uint64) uint64
- func ReadAMF[T string | float64 | bool | map[string]any](amf *AMF) (result T)
- func ReadBE[T Integer](b []byte) (num T)
- func ReadByteToUint16(r io.Reader, bigEndian bool) (data uint16, err error)
- func ReadByteToUint24(r io.Reader, bigEndian bool) (data uint32, err error)
- func ReadByteToUint32(r io.Reader, bigEndian bool) (data uint32, err error)
- func ReadByteToUint40(r io.Reader, bigEndian bool) (data uint64, err error)
- func ReadByteToUint48(r io.Reader, bigEndian bool) (data uint64, err error)
- func ReadByteToUint64(r io.Reader, bigEndian bool) (data uint64, err error)
- func ReadByteToUint8(r io.Reader) (data uint8, err error)
- func Retry(attempts int, sleep time.Duration, f func() error) error
- func RetryStopErr(err error) retryStop
- func ReturnError(code int, msg string, rw http.ResponseWriter, r *http.Request)
- func ReturnFetchList[T any](fetch func() []T, rw http.ResponseWriter, r *http.Request)
- func ReturnFetchValue[T any](fetch func() T, rw http.ResponseWriter, r *http.Request)
- func ReturnOK(rw http.ResponseWriter, r *http.Request)
- func ReturnValue(v any, rw http.ResponseWriter, r *http.Request)
- func SizeOfBuffers[T ~[]byte](buf []T) (size int)
- func SplitBuffers[T ~[]byte](buf []T, size int) (result [][]T)
- func ToFloat64(num interface{}) float64
- func Uint32ToByte(data uint32, bigEndian bool) (ret []byte, err error)
- func WaitTerm(cancel context.CancelFunc)
- func WriteUint16ToByte(w io.Writer, data uint16, bigEndian bool) error
- func WriteUint24ToByte(w io.Writer, data uint32, bigEndian bool) error
- func WriteUint32ToByte(w io.Writer, data uint32, bigEndian bool) error
- func WriteUint40ToByte(w io.Writer, data uint64, bigEndian bool) error
- func WriteUint48ToByte(w io.Writer, data uint64, bigEndian bool) error
- func WriteUint64ToByte(w io.Writer, data uint64, bigEndian bool) error
- func WriteUint8ToByte(w io.Writer, data uint8) error
- type AMF
- func (amf *AMF) Marshal(v any) []byte
- func (amf *AMF) Marshals(v ...any) []byte
- func (amf *AMF) ReadBool() (result bool)
- func (amf *AMF) ReadNumber() (result float64)
- func (amf *AMF) ReadObject() (result map[string]any)
- func (amf *AMF) ReadShortString() (result string)
- func (amf *AMF) Unmarshal() (obj any, err error)
- type APIError
- type APIResult
- type BLL
- func (list *BLL) Clear()
- func (list *BLL) GetByte(index int) (b byte)
- func (list *BLL) GetUint24(index int) uint32
- func (list *BLL) GetUintN(index int, n int) (result uint32)
- func (list *BLL) NewReader() *BLLReader
- func (list *BLL) Push(item *ListItem[Buffer])
- func (list *BLL) Recycle()
- func (list *BLL) Shift() (item *ListItem[Buffer])
- func (list *BLL) ToBuffers() (result net.Buffers)
- func (list *BLL) ToBytes() (b []byte)
- func (list *BLL) WriteTo(w io.Writer) (int64, error)
- type BLLReader
- func (r *BLLReader) CanRead() bool
- func (r *BLLReader) GetOffset() int
- func (r *BLLReader) LEB128Unmarshal() (uint, int, error)
- func (r *BLLReader) ReadBE(n int) (be uint32, err error)
- func (r *BLLReader) ReadByte() (b byte, err error)
- func (r *BLLReader) ReadN(n int) (result net.Buffers)
- func (r *BLLReader) Skip(n int) (err error)
- func (r *BLLReader) WriteNTo(n int, result *net.Buffers) (actual int)
- type BLLs
- type BLLsReader
- type Buffer
- func (b Buffer) Bytes() []byte
- func (b Buffer) CanRead() bool
- func (b Buffer) CanReadN(n int) bool
- func (b Buffer) Cap() int
- func (b Buffer) Clone() (result Buffer)
- func (b Buffer) Len() int
- func (b *Buffer) Malloc(count int) Buffer
- func (b *Buffer) MarshalAMFs(v ...any)
- func (b *Buffer) Read(buf []byte) (n int, err error)
- func (b *Buffer) ReadByte() byte
- func (b *Buffer) ReadFloat64() float64
- func (b *Buffer) ReadN(n int) Buffer
- func (b *Buffer) ReadUint16() uint16
- func (b *Buffer) ReadUint24() uint32
- func (b *Buffer) ReadUint32() uint32
- func (b *Buffer) ReadUint64() uint64
- func (b *Buffer) Relloc(count int)
- func (b *Buffer) Reset()
- func (Buffer) Reuse() bool
- func (b *Buffer) Split(n int) (result net.Buffers)
- func (b Buffer) SubBuf(start int, length int) Buffer
- func (b *Buffer) Write(a []byte) (n int, err error)
- func (b *Buffer) WriteByte(v byte)
- func (b *Buffer) WriteFloat64(v float64)
- func (b *Buffer) WriteString(a string)
- func (b *Buffer) WriteUint16(v uint16)
- func (b *Buffer) WriteUint24(v uint32)
- func (b *Buffer) WriteUint32(v uint32)
- type Builder
- type BytesPool
- type Crc32Reader
- type Crc32Writer
- type EcmaArray
- type IBytes
- type IList
- type IOVec
- type IOVecWriter
- type Instance
- func (i *Instance) Addr() interface{}
- func (in Instance) Field(name string) (reflect.Value, error)
- func (i *Instance) Interface() interface{}
- func (in *Instance) SetBool(name string, value bool)
- func (in *Instance) SetFloat64(name string, value float64)
- func (in *Instance) SetInt64(name string, value int64)
- func (in *Instance) SetString(name, value string)
- type Integer
- type LimitBuffer
- type List
- func (p *List[T]) Clear()
- func (p *List[T]) PoolShift() (head *ListItem[T])
- func (p *List[T]) Push(item *ListItem[T])
- func (p *List[T]) PushValue(value T)
- func (p *List[T]) Range(do func(value T) bool)
- func (p *List[T]) RangeItem(do func(*ListItem[T]) bool)
- func (p *List[T]) Recycle()
- func (p *List[T]) Shift() (head *ListItem[T])
- func (p *List[T]) ShiftValue() T
- func (p *List[T]) Transfer(target IList[T])
- func (p *List[T]) Unshift(item *ListItem[T])
- func (p *List[T]) UnshiftValue(value T)
- type ListItem
- func (item *ListItem[T]) InsertAfter(insert *ListItem[T])
- func (item *ListItem[T]) InsertAfterValue(value T) (result *ListItem[T])
- func (item *ListItem[T]) InsertBefore(insert *ListItem[T])
- func (item *ListItem[T]) InsertBeforeValue(value T) (result *ListItem[T])
- func (item *ListItem[T]) IsRoot() bool
- func (item *ListItem[T]) Range(do func(value T) bool)
- func (item *ListItem[T]) RangeItem(do func(*ListItem[T]) bool)
- func (item *ListItem[T]) Recycle()
- type Map
- func (m *Map[K, V]) Add(k K, v V) bool
- func (m *Map[K, V]) Delete(k K) (v V, ok bool)
- func (m *Map[K, V]) Get(k K) (result V)
- func (m *Map[K, V]) Has(k K) (ok bool)
- func (m *Map[K, V]) Len() (l int)
- func (m *Map[K, V]) Range(f func(K, V))
- func (m *Map[K, V]) Set(k K, v V)
- func (m *Map[K, V]) ToList() (r []V)
- type Pool
- type Promise
- type RTPReorder
- type Recyclable
- type ReuseBuffer
- type Ring
- type SSE
- type SafeChan
- type Slice
- type Struct
- type SysIOVec
Constants ¶
const ( AMF0_NUMBER = iota // 浮点数 AMF0_BOOLEAN AMF0_STRING AMF0_OBJECT AMF0_MOVIECLIP AMF0_NULL AMF0_UNDEFINED AMF0_REFERENCE AMF0_ECMA_ARRAY AMF0_END_OBJECT AMF0_STRICT_ARRAY AMF0_DATE AMF0_LONG_STRING AMF0_UNSUPPORTED AMF0_RECORDSET AMF0_XML_DOCUMENT AMF0_TYPED_OBJECT AMF0_AVMPLUS_OBJECT )
const ( AMF3_UNDEFINED = iota AMF3_NULL AMF3_FALSE AMF3_TRUE AMF3_INTEGER AMF3_DOUBLE AMF3_STRING AMF3_XML_DOC AMF3_DATE AMF3_ARRAY AMF3_OBJECT AMF3_XML AMF3_BYTE_ARRAY AMF3_VECTOR_INT AMF3_VECTOR_UINT AMF3_VECTOR_DOUBLE AMF3_VECTOR_OBJECT AMF3_DICTIONARY )
const ( APIErrorNone = 0 APIErrorDecode = iota + 4000 APIErrorQueryParse APIErrorNoBody )
const ( APIErrorNotFound = iota + 4040 APIErrorNoStream APIErrorNoConfig APIErrorNoPusher APIErrorNoSubscriber APIErrorNoSEI )
const ( APIErrorInternal = iota + 5000 APIErrorJSONEncode APIErrorPublish APIErrorSave APIErrorOpen )
Variables ¶
var ( END_OBJ = []byte{0, 0, AMF0_END_OBJECT} ObjectEnd = &struct{}{} Undefined = &struct{}{} )
var BigEndian bigEndian
BigEndian is the big-endian implementation of ByteOrder.
var Crc32_Table = []uint32{}/* 256 elements not displayed */
var (
FieldNoExist error = errors.New("field no exist")
)
var LittleEndian littleEndian
var Null = struct{}{}
var PoolSize = 16
var RTPReorderBufferLen uint16 = 50
Functions ¶
func BigLittleSwap ¶
func ByteToUint32 ¶
千万注意大小端,RTMP是大端
func ConcatBuffers ¶
ConcatBuffers 合并碎片内存为一个完整内存
func Conditoinal ¶
func Conf2Listener ¶
func ConvertNum ¶
func CreateShutdownScript ¶
func CreateShutdownScript() error
func CurrentDir ¶
func FetchValue ¶
func FetchValue[T any](t T) func() T
func GetFillBytes ¶
func LastElement ¶
func LastElement[T any](s []T) T
func MarshalAMFs ¶
func RetryStopErr ¶
func RetryStopErr(err error) retryStop
func ReturnError ¶
func ReturnFetchList ¶
func ReturnFetchList[T any](fetch func() []T, rw http.ResponseWriter, r *http.Request)
func ReturnFetchValue ¶
func ReturnFetchValue[T any](fetch func() T, rw http.ResponseWriter, r *http.Request)
func ReturnValue ¶
func ReturnValue(v any, rw http.ResponseWriter, r *http.Request)
func SplitBuffers ¶
SplitBuffers 按照一定大小分割 Buffers
func WaitTerm ¶
func WaitTerm(cancel context.CancelFunc)
Types ¶
type AMF ¶
type AMF struct {
Buffer
}
func (*AMF) ReadNumber ¶
func (*AMF) ReadObject ¶
func (*AMF) ReadShortString ¶
type BLLsReader ¶
func (*BLLsReader) CanRead ¶
func (r *BLLsReader) CanRead() bool
func (*BLLsReader) ReadByte ¶
func (r *BLLsReader) ReadByte() (b byte, err error)
type Buffer ¶
type Buffer []byte
Buffer 用于方便自动扩容的内存写入,已经读取
func (*Buffer) MarshalAMFs ¶
func (*Buffer) ReadFloat64 ¶
func (*Buffer) ReadUint16 ¶
func (*Buffer) ReadUint24 ¶
func (*Buffer) ReadUint32 ¶
func (*Buffer) ReadUint64 ¶
func (*Buffer) WriteFloat64 ¶
func (*Buffer) WriteString ¶
func (*Buffer) WriteUint16 ¶
func (*Buffer) WriteUint24 ¶
func (*Buffer) WriteUint32 ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
构造器
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) AddFloat64 ¶
type Crc32Reader ¶
func (*Crc32Reader) ReadCrc32UIntAndCheck ¶
func (cr *Crc32Reader) ReadCrc32UIntAndCheck() (err error)
type Crc32Writer ¶
type IOVecWriter ¶
type IOVecWriter struct {
// contains filtered or unexported fields
}
func NewIOVecWriter ¶
func NewIOVecWriter(w io.Writer) (iow *IOVecWriter)
func (*IOVecWriter) Flush ¶
func (iow *IOVecWriter) Flush() error
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
结构体的值
func (*Instance) SetFloat64 ¶
type LimitBuffer ¶
type LimitBuffer struct {
Buffer
}
LimitBuffer 限制buffer的长度,不会改变原来的buffer,防止内存泄漏
func (LimitBuffer) Clone ¶
func (b LimitBuffer) Clone() (result LimitBuffer)
func (*LimitBuffer) Malloc ¶
func (b *LimitBuffer) Malloc(count int) (result LimitBuffer)
func (*LimitBuffer) ReadN ¶
func (b *LimitBuffer) ReadN(n int) (result LimitBuffer)
func (LimitBuffer) SubBuf ¶
func (b LimitBuffer) SubBuf(start int, length int) (result LimitBuffer)
type List ¶
func (*List[T]) ShiftValue ¶
func (p *List[T]) ShiftValue() T
func (*List[T]) UnshiftValue ¶
func (p *List[T]) UnshiftValue(value T)
type ListItem ¶
type ListItem[T any] struct { Value T Next, Pre *ListItem[T] `json:"-" yaml:"-"` Pool *List[T] `json:"-" yaml:"-"` // 回收池 // contains filtered or unexported fields }
func NewListItem ¶
func (*ListItem[T]) InsertAfter ¶
func (*ListItem[T]) InsertAfterValue ¶
func (*ListItem[T]) InsertBefore ¶
func (*ListItem[T]) InsertBeforeValue ¶
type Promise ¶
type Promise[S any] struct { context.Context context.CancelCauseFunc context.CancelFunc Value S }
func NewPromise ¶
type RTPReorder ¶
type RTPReorder[T comparable] struct { Total uint32 // 总共收到的包数量 Drop uint32 // 丢弃的包数量 // contains filtered or unexported fields }
RTPReorder RTP包乱序重排
func (*RTPReorder[T]) Push ¶
func (p *RTPReorder[T]) Push(seq uint16, v T) (result T)
type Recyclable ¶
type Recyclable interface {
Recycle()
}
type ReuseBuffer ¶
type ReuseBuffer struct {
Buffer
}
ReuseBuffer 重用buffer,内容可能会被覆盖,要尽早复制
func (ReuseBuffer) Reuse ¶
func (ReuseBuffer) Reuse() bool
type Ring ¶
type Ring[T any] struct { Value T // for use by client; untouched by this library // contains filtered or unexported fields }
A Ring is an element of a circular list, or ring. Rings do not have a beginning or end; a pointer to any ring element serves as reference to the entire ring. Empty rings are represented as nil Ring pointers. The zero value for a Ring is a one-element ring with a nil Value.
func (*Ring[T]) Do ¶
func (r *Ring[T]) Do(f func(T))
Do calls function f on each element of the ring, in forward order. The behavior of Do is undefined if f changes *r.
func (*Ring[T]) Len ¶
Len computes the number of elements in ring r. It executes in time proportional to the number of elements.
func (*Ring[T]) Link ¶
Link connects ring r with ring s such that r.Next() becomes s and returns the original value for r.Next(). r must not be empty.
If r and s point to the same ring, linking them removes the elements between r and s from the ring. The removed elements form a subring and the result is a reference to that subring (if no elements were removed, the result is still the original value for r.Next(), and not nil).
If r and s point to different rings, linking them creates a single ring with the elements of s inserted after r. The result points to the element following the last element of s after insertion.
func (*Ring[T]) Move ¶
Move moves n % r.Len() elements backward (n < 0) or forward (n >= 0) in the ring and returns that ring element. r must not be empty.
type SafeChan ¶
type SafeChan[T any] struct { C chan T // contains filtered or unexported fields }
SafeChan安全的channel,可以防止close后被写入的问题
type Slice ¶
type Slice[T comparable] []T
func (*Slice[T]) ResetAppend ¶
func (s *Slice[T]) ResetAppend(first T)