common

package
v4.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 12 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitAnnexB added in v4.11.5

func SplitAnnexB[T ~[]byte](frame T, process func(T), delimiter []byte)

Types

type AVFrame

type AVFrame struct {
	BaseFrame
	IFrame  bool
	CanRead bool `json:"-"`
	PTS     uint32
	DTS     uint32
	ADTS    *util.ListItem[util.Buffer] `json:"-"` // ADTS头
	AVCC    util.BLL                    `json:"-"` // 打包好的AVCC格式(MPEG-4格式、Byte-Stream Format)
	RTP     util.List[RTPFrame]         `json:"-"`
	AUList  util.BLLs                   `json:"-"` // 裸数据
}

func (*AVFrame) Reset

func (av *AVFrame) Reset()

Reset 重置数据,复用内存

func (*AVFrame) WriteAVCC added in v4.11.0

func (av *AVFrame) WriteAVCC(ts uint32, frame *util.BLL)

type AVTrack

type AVTrack interface {
	Track
	PreFrame() *AVFrame
	CurrentFrame() *AVFrame
	Attach()
	Detach()
	WriteAVCC(ts uint32, frame *util.BLL) error //写入AVCC格式的数据
	WriteRTP(*util.ListItem[RTPFrame])
	WriteRTPPack(*rtp.Packet)
	Flush()
	SetSpeedLimit(time.Duration)
	GetRTPFromPool() *util.ListItem[RTPFrame]
}

type AudioTrack

type AudioTrack interface {
	AVTrack
	WriteADTS(uint32, []byte)
	WriteRaw(uint32, []byte)
}

type Base added in v4.1.0

type Base struct {
	Name     string
	log.Zap  `json:"-"`
	Stream   IStream     `json:"-"`
	Attached atomic.Bool `json:"-"`
	State    TrackState

	BPS     int
	FPS     int
	RawSize int                 // 裸数据长度
	RawPart []int               // 裸数据片段用于UI上显示
	BPSs    []TimelineData[int] // 10s码率统计
	FPSs    []TimelineData[int] // 10s帧率统计
	// contains filtered or unexported fields
}

Base 基础Track类

func (*Base) ComputeBPS added in v4.1.0

func (bt *Base) ComputeBPS(bytes int)

func (*Base) Flush added in v4.1.0

func (bt *Base) Flush(bf *BaseFrame)

func (*Base) GetBase added in v4.1.0

func (bt *Base) GetBase() *Base

func (*Base) SetStuff added in v4.11.0

func (bt *Base) SetStuff(stuff ...any)

func (*Base) SnapForJson added in v4.5.1

func (bt *Base) SnapForJson()

type BaseFrame

type BaseFrame struct {
	DeltaTime uint32    // 相对上一帧时间戳,毫秒
	AbsTime   uint32    // 绝对时间戳,毫秒
	Timestamp time.Time // 写入时间,可用于比较两个帧的先后
	Sequence  uint32    // 在一个Track中的序号
	BytesIn   int       // 输入字节数用于计算BPS
}

type DTSEstimator

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

DTSEstimator is a DTS estimator.

func NewDTSEstimator

func NewDTSEstimator() *DTSEstimator

NewDTSEstimator allocates a DTSEstimator.

func (*DTSEstimator) Clone added in v4.9.8

func (d *DTSEstimator) Clone() *DTSEstimator

func (*DTSEstimator) Feed

func (d *DTSEstimator) Feed(pts uint32) uint32

Feed provides PTS to the estimator, and returns the estimated DTS.

type DataFrame

type DataFrame[T any] struct {
	BaseFrame
	Value T
}

type IStream

type IStream interface {
	AddTrack(*util.Promise[Track])
	RemoveTrack(Track)
	Close()
	IsClosed() bool
	SSRC() uint32
	log.Zap
	Receive(any) bool
	SetIDR(Track)
	GetPublisherConfig() *config.Publish
}

type LockFrame

type LockFrame[T any] struct {
	DataFrame[T]
	sync.RWMutex
}

type LockRing

type LockRing[T any] struct {
	RingBuffer[LockFrame[T]]
	Flag *int32
}

func (*LockRing[T]) Dispose

func (rb *LockRing[T]) Dispose()

func (*LockRing[T]) Init

func (lr *LockRing[T]) Init(n int) *LockRing[T]

func (*LockRing[T]) Read

func (rb *LockRing[T]) Read() *DataFrame[T]

func (*LockRing[T]) Step

func (rb *LockRing[T]) Step()

func (*LockRing[T]) Write

func (rb *LockRing[T]) Write(value T)

type ParamaterSets added in v4.11.0

type ParamaterSets [][]byte

func (ParamaterSets) GetAnnexB added in v4.11.0

func (v ParamaterSets) GetAnnexB() (r net.Buffers)

func (ParamaterSets) WriteAnnexBTo added in v4.11.0

func (v ParamaterSets) WriteAnnexBTo(w io.Writer) (n int, err error)

type RTPFrame

type RTPFrame struct {
	*rtp.Packet
	Raw []byte
}

func (*RTPFrame) H264Type

func (r *RTPFrame) H264Type() (naluType codec.H264NALUType)

func (*RTPFrame) H265Type

func (r *RTPFrame) H265Type() (naluType codec.H265NALUType)

func (*RTPFrame) Unmarshal

func (r *RTPFrame) Unmarshal(raw []byte) *RTPFrame

type RingBuffer

type RingBuffer[T any] struct {
	*util.Ring[T] `json:"-"`
	Size          int
	MoveCount     uint32
	LastValue     *T
}

func (*RingBuffer[T]) Glow added in v4.11.0

func (rb *RingBuffer[T]) Glow(size int) (newItem *util.Ring[T])

func (*RingBuffer[T]) Init

func (rb *RingBuffer[T]) Init(n int) *RingBuffer[T]

func (*RingBuffer[T]) MoveNext

func (rb *RingBuffer[T]) MoveNext() *T

func (*RingBuffer[T]) Reduce added in v4.11.0

func (rb *RingBuffer[T]) Reduce(size int) (newItem *util.Ring[T])

type TimelineData added in v4.5.6

type TimelineData[T any] struct {
	Timestamp time.Time
	Value     T
}

type Track

type Track interface {
	GetBase() *Base
	LastWriteTime() time.Time
	SnapForJson()
	SetStuff(stuff ...any)
}

type TrackState added in v4.11.2

type TrackState byte
const (
	TrackStateOnline  TrackState = iota // 上线
	TrackStateOffline                   // 下线
)

type VideoTrack

type VideoTrack interface {
	AVTrack
	WriteSliceBytes(slice []byte)
	WriteAnnexB(uint32, uint32, []byte)
	SetLostFlag()
}

Jump to

Keyboard shortcuts

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