common

package
v4.15.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitAnnexB

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

Types

type AVFrame

type AVFrame struct {
	DataFrame[any]
	IFrame    bool
	PTS       time.Duration
	DTS       time.Duration
	Timestamp time.Duration       // 绝对时间戳
	ADTS      util.LIBP           `json:"-" yaml:"-"` // ADTS头
	AVCC      util.BLL            `json:"-" yaml:"-"` // 打包好的AVCC格式(MPEG-4格式、Byte-Stream Format)
	RTP       util.List[RTPFrame] `json:"-" yaml:"-"`
	AUList    util.BLLs           `json:"-" yaml:"-"` // 裸数据
}

func NewAVFrame

func NewAVFrame() *AVFrame

func (*AVFrame) Assign

func (av *AVFrame) Assign(source *AVFrame)

func (*AVFrame) Reset

func (av *AVFrame) Reset()

Reset 重置数据,复用内存

func (*AVFrame) WriteAVCC

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(*LIRTP)
	WriteRTPPack(*rtp.Packet)
	WriteSequenceHead(sh []byte) error
	Flush()
	SetSpeedLimit(time.Duration)
	GetRTPFromPool() *LIRTP
	GetFromPool(util.IBytes) util.LIBP
}

type AudioTrack

type AudioTrack interface {
	AVTrack
	GetCodec() codec.AudioCodecID
	WriteADTS(uint32, util.IBytes)
	WriteRawBytes(uint32, util.IBytes)
	Narrow()
}

type DataFrame

type DataFrame[T any] struct {
	DeltaTime uint32    // 相对上一帧时间戳,毫秒
	WriteTime time.Time // 写入时间,可用于比较两个帧的先后
	Sequence  uint32    // 在一个Track中的序号
	BytesIn   int       // 输入字节数用于计算BPS
	CanRead   bool      `json:"-" yaml:"-"` // 是否可读取

	Data      T `json:"-" yaml:"-"`
	sync.Cond `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

func NewDataFrame

func NewDataFrame[T any]() *DataFrame[T]

func (*DataFrame[T]) Discard

func (df *DataFrame[T]) Discard() int32

func (*DataFrame[T]) GetSequence

func (df *DataFrame[T]) GetSequence() uint32

func (*DataFrame[T]) Init

func (df *DataFrame[T]) Init()

func (*DataFrame[T]) IsDiscarded

func (df *DataFrame[T]) IsDiscarded() bool

func (*DataFrame[T]) IsWriting

func (df *DataFrame[T]) IsWriting() bool

func (*DataFrame[T]) ReaderCount

func (df *DataFrame[T]) ReaderCount() int32

func (*DataFrame[T]) ReaderEnter

func (df *DataFrame[T]) ReaderEnter() int32

func (*DataFrame[T]) ReaderLeave

func (df *DataFrame[T]) ReaderLeave() int32

func (*DataFrame[T]) Ready

func (df *DataFrame[T]) Ready()

func (*DataFrame[T]) Reset

func (df *DataFrame[T]) Reset()

func (*DataFrame[T]) SetSequence

func (df *DataFrame[T]) SetSequence(sequence uint32)

func (*DataFrame[T]) StartWrite

func (df *DataFrame[T]) StartWrite() bool

type IIO

type IIO interface {
	IsClosed() bool
	OnEvent(any)
	Stop(reason ...zapcore.Field)
	SetIO(any)
	SetParentCtx(context.Context)
	SetLogger(*log.Logger)
	IsShutdown() bool
	GetStream() IStream
	log.Zap
}

type IPuber

type IPuber interface {
	IIO
	GetAudioTrack() AudioTrack
	GetVideoTrack() VideoTrack
	GetConfig() *config.Publish
	Publish(streamPath string, pub IPuber) error
}

type IStream

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

type LIRTP

type LIRTP = util.ListItem[RTPFrame]

type ParamaterSets

type ParamaterSets [][]byte

func (ParamaterSets) GetAnnexB

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

func (ParamaterSets) WriteAnnexBTo

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 TimelineData

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

type Track

type Track interface {
	GetPublisher() IPuber
	GetReaderCount() int32
	GetName() string
	GetBPS() int
	GetFPS() int
	GetDrops() int
	LastWriteTime() time.Time
	SnapForJson()
	SetStuff(stuff ...any)
	GetRBSize() int
	Dispose()
}

type TrackState

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

type VideoTrack

type VideoTrack interface {
	AVTrack
	GetCodec() codec.VideoCodecID
	WriteSliceBytes(slice []byte)
	WriteNalu(uint32, uint32, []byte)
	WriteAnnexB(uint32, uint32, []byte)
	SetLostFlag()
}

Jump to

Keyboard shortcuts

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