common

package
v4.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 13 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 {
	DataFrame[any]
	IFrame    bool
	PTS       time.Duration
	DTS       time.Duration
	Timestamp time.Duration               // 绝对时间戳
	ADTS      *util.ListItem[util.Buffer] `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 added in v4.13.5

func NewAVFrame() *AVFrame

func (*AVFrame) Assign added in v4.15.0

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

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)
	WriteSequenceHead(sh []byte) error
	Flush()
	SetSpeedLimit(time.Duration)
	GetRTPFromPool() *util.ListItem[RTPFrame]
	GetFromPool(util.IBytes) *util.ListItem[util.Buffer]
}

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 added in v4.13.5

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

func (*DataFrame[T]) Discard added in v4.13.5

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

func (*DataFrame[T]) GetSequence added in v4.13.5

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

func (*DataFrame[T]) Init added in v4.13.5

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

func (*DataFrame[T]) IsDiscarded added in v4.13.5

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

func (*DataFrame[T]) IsWriting added in v4.13.5

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

func (*DataFrame[T]) ReaderCount added in v4.13.5

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

func (*DataFrame[T]) ReaderEnter added in v4.13.5

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

func (*DataFrame[T]) ReaderLeave added in v4.13.5

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

func (*DataFrame[T]) Ready added in v4.13.5

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

func (*DataFrame[T]) Reset added in v4.13.3

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

func (*DataFrame[T]) SetSequence added in v4.13.5

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

func (*DataFrame[T]) StartWrite added in v4.13.5

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

type IIO added in v4.15.0

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 added in v4.15.0

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 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 TimelineData added in v4.5.6

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 added in v4.11.2

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