utils

package module
v3.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 20 Imported by: 0

README

monibuca-utils

源自于 https://github.com/Monibuca/utils。 只为对付一些不知道原因的越界问题,又搞不定本地替换模块子目录问题,只能 fork 一个然后十分粗暴的修改了一下。因为修改的太烂,就不搞成rp了。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BigEndian bigEndian

BigEndian is the big-endian implementation of ByteOrder.

View Source
var Crc32_Table = []uint32{}/* 256 elements not displayed */
View Source
var LittleEndian littleEndian

Functions

func AddWriter

func AddWriter(wn io.Writer)

AddWriter 添加日志输出端

func BigLittleSwap

func BigLittleSwap(v uint) uint

func ByteToUint32

func ByteToUint32(data []byte, bigEndian bool) (ret uint32, err error)

千万注意大小端,RTMP是大端

func ByteToUint32N

func ByteToUint32N(data []byte) (ret uint32, err error)

// 千万注意大小端,RTMP是大端

func ByteToUint64N

func ByteToUint64N(data []byte) (ret uint64, err error)

// 千万注意大小端,RTMP是大端

func CORS

func CORS(w http.ResponseWriter, r *http.Request)

func CurrentDir

func CurrentDir(path ...string) string

func Exist

func Exist(filename string) bool

检查文件或目录是否存在 如果由 filename 指定的文件或目录存在则返回 true,否则返回 false

func GetFillBytes

func GetFillBytes(data byte, n int) []byte

func GetPCR

func GetPCR(v uint64) uint64

func GetPtsDts

func GetPtsDts(v uint64) uint64

func GetSlice

func GetSlice(s int) []byte

func GetUev

func GetUev(buff []byte, start int) (value int, pos int)

哥伦布解码

func ListenAddrs

func ListenAddrs(addr, addTLS, cert, key string, handler http.Handler)

ListenAddrs Listen http and https

func ListenTCP

func ListenTCP(addr string, process func(net.Conn)) error

func ListenUDP

func ListenUDP(address string, networkBuffer int) (*net.UDPConn, error)

func MayBeError

func MayBeError(info error) (hasError bool)

MayBeError 优雅错误判断加日志辅助函数

func Print

func Print(v ...interface{})

Print 带颜色识别

func Printf

func Printf(format string, v ...interface{})

Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...interface{})

Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.

func PutPCR

func PutPCR(pcr uint64) uint64

func PutPtsDts

func PutPtsDts(v uint64) uint64

func ReadByteToUint16

func ReadByteToUint16(r io.Reader, bigEndian bool) (data uint16, err error)

func ReadByteToUint24

func ReadByteToUint24(r io.Reader, bigEndian bool) (data uint32, err error)

func ReadByteToUint32

func ReadByteToUint32(r io.Reader, bigEndian bool) (data uint32, err error)

func ReadByteToUint40

func ReadByteToUint40(r io.Reader, bigEndian bool) (data uint64, err error)

func ReadByteToUint48

func ReadByteToUint48(r io.Reader, bigEndian bool) (data uint64, err error)

func ReadByteToUint64

func ReadByteToUint64(r io.Reader, bigEndian bool) (data uint64, err error)

func ReadByteToUint8

func ReadByteToUint8(r io.Reader) (data uint8, err error)

func ReadFileLines

func ReadFileLines(filename string) (lines []string, err error)

func RecycleSlice

func RecycleSlice(slice []byte)

func ToFloat64

func ToFloat64(num interface{}) float64

func Uint32ToByte

func Uint32ToByte(data uint32, bigEndian bool) (ret []byte, err error)

func WriteUint16ToByte

func WriteUint16ToByte(w io.Writer, data uint16, bigEndian bool) error

func WriteUint24ToByte

func WriteUint24ToByte(w io.Writer, data uint32, bigEndian bool) error

func WriteUint32ToByte

func WriteUint32ToByte(w io.Writer, data uint32, bigEndian bool) error

func WriteUint40ToByte

func WriteUint40ToByte(w io.Writer, data uint64, bigEndian bool) error

func WriteUint48ToByte

func WriteUint48ToByte(w io.Writer, data uint64, bigEndian bool) error

func WriteUint64ToByte

func WriteUint64ToByte(w io.Writer, data uint64, bigEndian bool) error

func WriteUint8ToByte

func WriteUint8ToByte(w io.Writer, data uint8) error

Types

type Crc32Reader

type Crc32Reader struct {
	R     io.Reader
	Crc32 uint32
}

func (*Crc32Reader) Read

func (cr *Crc32Reader) Read(b []byte) (n int, err error)

func (*Crc32Reader) ReadCrc32UIntAndCheck

func (cr *Crc32Reader) ReadCrc32UIntAndCheck() (err error)

type Crc32Writer

type Crc32Writer struct {
	W     io.Writer
	Crc32 uint32
}

func (*Crc32Writer) Write

func (wr *Crc32Writer) Write(b []byte) (n int, err error)

type Event

type Event struct {
	Timestamp time.Time
	Level     int
	Label     string
	Tag       string
}

type EventContext

type EventContext struct {
	Name string
	context.Context
	EventChan chan *Event
}

type IOVec

type IOVec struct {
	Data   [][]byte
	Length int
	// contains filtered or unexported fields
}

func (*IOVec) Append

func (iov *IOVec) Append(b []byte)

func (*IOVec) WriteTo

func (iov *IOVec) WriteTo(w io.Writer, n int) (written int, err error)

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

func (*IOVecWriter) Write

func (iow *IOVecWriter) Write(data []byte) (written int, err error)

type MultiLogWriter

type MultiLogWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

MultiLogWriter 多端写日志类

type SSE

type SSE struct {
	http.ResponseWriter
	context.Context
}

func NewSSE

func NewSSE(w http.ResponseWriter, ctx context.Context) *SSE

func (*SSE) Write

func (sse *SSE) Write(data []byte) (n int, err error)

func (*SSE) WriteEvent

func (sse *SSE) WriteEvent(event string, data []byte) (err error)

func (*SSE) WriteExec

func (sse *SSE) WriteExec(cmd *exec.Cmd) error

func (*SSE) WriteJSON

func (sse *SSE) WriteJSON(data interface{}) error

type SysIOVec

type SysIOVec struct {
	Base   uintptr
	Length uint64
}

Directories

Path Synopsis
pio

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL