utils

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UDPTransfer        int = 0
	TCPTransferActive  int = 1
	TCPTransferPassive int = 2
	LocalCache         int = 3

	StreamTypeH264 = 0x1b
	StreamTypeH265 = 0x24
	G711A          = 0x90 //PCMA
	AAC            = 0x67 //AAC
	AAC_LOW        = 0xF  //AAC_LOW
	G7221AUDIOTYPE = 0x92
	G7231AUDIOTYPE = 0x93
	G729AUDIOTYPE  = 0x99

	StreamIDVideo = 0xe0
	StreamIDAudio = 0xc0

	StartCodePS        = 0x000001ba
	StartCodeSYS       = 0x000001bb
	StartCodeMAP       = 0x000001bc
	StartCodeVideo     = 0x000001e0
	StartCodeAudio     = 0x000001c0
	HaiKangCode        = 0x000001bd
	MEPGProgramEndCode = 0x000001b9

	RTPHeaderLength    int = 12
	PSHeaderLength     int = 14
	SystemHeaderLength int = 18
	MAPHeaderLength    int = 24
	PESHeaderLength    int = 19
	RtpLoadLength      int = 1460
	PESLoadLength      int = 0xFFFF
	MAXFrameLen        int = 1024 * 1024 * 2
)
View Source
const MaxRtpDiff = 65000 //相邻两个包之间的最大差值

Variables

View Source
var (
	ErrNotFoundStartCode = errors.New("not found the need start code flag")
	ErrMarkerBit         = errors.New("marker bit value error")
	ErrFormatPack        = errors.New("not package standard")
	ErrParsePakcet       = errors.New("parse ps packet error")
)
View Source
var BigEndian bigEndian

BigEndian is the big-endian implementation of ByteOrder.

View Source
var ErrTooLarge = errors.New("IOBuffer: too large")
View Source
var LittleEndian littleEndian

Functions

func BigLittleSwap added in v1.0.1

func BigLittleSwap(v uint) uint

func DecodeGbk

func DecodeGbk(v interface{}, body []byte) error

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func Get

func Get() *bytes.Buffer

Get returns an empty byte buffer from the pool.

Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.

func GetUev added in v1.0.1

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

哥伦布解码

func NewError

func NewError(err error, params ...interface{}) error

NewError NewError

func PrintStack

func PrintStack()

func Put

func Put(b *bytes.Buffer)

Put returns byte buffer to the pool.

bytes.Buffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.

func RandNum16String

func RandNum16String(n int) string

func RandNumString

func RandNumString(n int) string

func RandString

func RandString(n int) string

func ResolveSelfIP

func ResolveSelfIP() (net.IP, error)

ResolveSelfIP ResolveSelfIP

func ToJSONString

func ToJSONString(v interface{}) string

func ToPrettyString

func ToPrettyString(v interface{}) string

Types

type DecPSPackage

type DecPSPackage struct {
	VideoStreamType uint32
	AudioStreamType uint32
	IOBuffer
	Payload []byte
	PTS     uint32
	DTS     uint32
	// contains filtered or unexported fields
}

https://github.com/videolan/vlc/blob/master/modules/demux/mpeg

func (*DecPSPackage) Read

func (dec *DecPSPackage) Read(ts uint32, pusher Pusher) error

read the buffer and push video or audio

func (*DecPSPackage) ReadPayload

func (dec *DecPSPackage) ReadPayload() (payload []byte, err error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error Error

func (*Error) Error

func (err *Error) Error() string

type IOBuffer

type IOBuffer struct {
	MaxBufSize        int
	InitialBufferSize int
	// contains filtered or unexported fields
}

func (*IOBuffer) Len

func (b *IOBuffer) Len() int

func (*IOBuffer) Next

func (b *IOBuffer) Next(n int) []byte

func (*IOBuffer) ReadByte

func (b *IOBuffer) ReadByte() (byte, error)

func (*IOBuffer) ReadN

func (b *IOBuffer) ReadN(length int) ([]byte, error)

func (*IOBuffer) Reset

func (b *IOBuffer) Reset()

func (*IOBuffer) Skip

func (b *IOBuffer) Skip(n int) (err error)

func (*IOBuffer) Uint16

func (b *IOBuffer) Uint16() (uint16, error)

func (*IOBuffer) Uint32

func (b *IOBuffer) Uint32() (uint32, error)

func (*IOBuffer) Write

func (b *IOBuffer) Write(p []byte) (n int, err error)

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents byte buffer pool.

Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.

func (*Pool) Get

func (p *Pool) Get() *bytes.Buffer

Get returns new byte buffer with zero length.

The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.

func (*Pool) Put

func (p *Pool) Put(b *bytes.Buffer)

Put releases byte buffer obtained via Get to the pool.

The buffer mustn't be accessed after returning to the pool.

type PriorityQueueRtp

type PriorityQueueRtp struct {
	// contains filtered or unexported fields
}

func NewPqRtp

func NewPqRtp() *PriorityQueueRtp

func (*PriorityQueueRtp) Empty

func (p *PriorityQueueRtp) Empty()

func (*PriorityQueueRtp) Len

func (p *PriorityQueueRtp) Len() int

func (*PriorityQueueRtp) Pop

func (p *PriorityQueueRtp) Pop() (rtp.Packet, error)

func (*PriorityQueueRtp) Push

func (p *PriorityQueueRtp) Push(v rtp.Packet)

type Pusher

type Pusher interface {
	PushVideo(uint32, uint32, []byte)
	PushAudio(uint32, []byte)
}

Jump to

Keyboard shortcuts

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