track

package
v4.0.0-alpha9 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 12 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AAC

type AAC struct {
	Audio
}

func NewAAC

func NewAAC(stream IStream) (aac *AAC)

func (*AAC) Flush

func (aac *AAC) Flush()

func (*AAC) WriteAVCC

func (aac *AAC) WriteAVCC(ts uint32, frame AVCCFrame)

func (*AAC) WriteRTP

func (aac *AAC) WriteRTP(raw []byte)

type Audio

type Audio struct {
	Media[AudioSlice]
	CodecID  codec.AudioCodecID
	Channels byte
	// contains filtered or unexported fields
}

func (*Audio) Attach

func (a *Audio) Attach()

func (*Audio) Detach

func (a *Audio) Detach()

func (*Audio) Flush

func (a *Audio) Flush()

func (*Audio) GetInfo

func (a *Audio) GetInfo() *Audio

func (*Audio) GetName

func (a *Audio) GetName() string

func (*Audio) IsAAC

func (a *Audio) IsAAC() bool

func (*Audio) WriteADTS

func (a *Audio) WriteADTS(adts []byte)

type Base

type Base struct {
	Name   string
	Stream IStream `json:"-"`
	BPS
}

Base 基础Track类

func (*Base) Flush

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

func (*Base) GetName

func (bt *Base) GetName() string

type Data

type Data struct {
	Base
	LockRing[any]
	sync.Locker // 写入锁,可选,单一协程写入可以不加锁
}

func (*Data) LastWriteTime

func (d *Data) LastWriteTime() time.Time

func (*Data) Play

func (d *Data) Play(ctx context.Context, onData func(any) error) error

func (*Data) Push

func (dt *Data) Push(data any)

func (*Data) ReadRing

func (d *Data) ReadRing() *LockRing[any]

type G711

type G711 struct {
	Audio
}

func NewG711

func NewG711(stream IStream, alaw bool) (g711 *G711)

func (*G711) WriteAVCC

func (g711 *G711) WriteAVCC(ts uint32, frame AVCCFrame)

func (*G711) WriteRTP

func (g711 *G711) WriteRTP(raw []byte)

type H264

type H264 struct {
	Video
	// contains filtered or unexported fields
}

func NewH264

func NewH264(stream IStream) (vt *H264)

func (*H264) Flush

func (vt *H264) Flush()

func (*H264) WriteAVCC

func (vt *H264) WriteAVCC(ts uint32, frame AVCCFrame)

func (*H264) WriteAnnexB

func (vt *H264) WriteAnnexB(pts uint32, dts uint32, frame AnnexBFrame)

func (*H264) WriteRTP

func (vt *H264) WriteRTP(raw []byte)

func (*H264) WriteSlice

func (vt *H264) WriteSlice(slice NALUSlice)

type H265

type H265 struct {
	Video
}

func NewH265

func NewH265(stream IStream) (vt *H265)

func (*H265) Flush

func (vt *H265) Flush()

func (*H265) WriteAVCC

func (vt *H265) WriteAVCC(ts uint32, frame AVCCFrame)

func (*H265) WriteAnnexB

func (vt *H265) WriteAnnexB(pts uint32, dts uint32, frame AnnexBFrame)

func (*H265) WriteRTP

func (vt *H265) WriteRTP(raw []byte)

func (*H265) WriteSlice

func (vt *H265) WriteSlice(slice NALUSlice)

type Media

type Media[T RawSlice] struct {
	Base
	AVRing[T]            `json:"-"`
	SampleRate           uint32
	SampleSize           byte
	DecoderConfiguration DecoderConfiguration[T] `json:"-"` //H264(SPS、PPS) H265(VPS、SPS、PPS) AAC(config)
	// contains filtered or unexported fields
}

Media 基础媒体Track类

func (*Media[T]) CurrentFrame

func (av *Media[T]) CurrentFrame() *AVFrame[T]

func (*Media[T]) Flush

func (av *Media[T]) Flush()

func (*Media[T]) GetDecoderConfiguration

func (av *Media[T]) GetDecoderConfiguration() DecoderConfiguration[T]

func (*Media[T]) LastWriteTime

func (av *Media[T]) LastWriteTime() time.Time

func (*Media[T]) PacketizeRTP

func (av *Media[T]) PacketizeRTP(payloads ...[]byte)

Packetize packetizes the payload of an RTP packet and returns one or more RTP packets

func (*Media[T]) Play

func (av *Media[T]) Play(ctx context.Context, onMedia func(*AVFrame[T]) error) error

func (*Media[T]) PreFrame

func (av *Media[T]) PreFrame() *AVFrame[T]

func (*Media[T]) ReadRing

func (av *Media[T]) ReadRing() *AVRing[T]

func (*Media[T]) UnmarshalRTP

func (av *Media[T]) UnmarshalRTP(raw []byte) (frame *RTPFrame)

func (*Media[T]) WriteAVCC

func (av *Media[T]) WriteAVCC(ts uint32, frame AVCCFrame)

func (*Media[T]) WriteSlice

func (av *Media[T]) WriteSlice(slice T)

type UnknowAudio

type UnknowAudio struct {
	Base
	AudioTrack
}

func (*UnknowAudio) Flush

func (ua *UnknowAudio) Flush()

func (*UnknowAudio) GetName

func (ua *UnknowAudio) GetName() string

func (*UnknowAudio) WriteAVCC

func (ua *UnknowAudio) WriteAVCC(ts uint32, frame AVCCFrame)

type UnknowVideo

type UnknowVideo struct {
	Base
	VideoTrack
}

func (*UnknowVideo) Flush

func (uv *UnknowVideo) Flush()

func (*UnknowVideo) GetName

func (uv *UnknowVideo) GetName() string

func (*UnknowVideo) WriteAVCC

func (vt *UnknowVideo) WriteAVCC(ts uint32, frame AVCCFrame)

func (*UnknowVideo) WriteAnnexB

func (vt *UnknowVideo) WriteAnnexB(pts uint32, dts uint32, frame AnnexBFrame)

Access Unit的首个nalu是4字节起始码。 这里举个例子说明,用JM可以生成这样一段码流(不要使用JM8.6,它在这部分与标准不符),这个码流可以见本楼附件:

SPS          (4字节头)
PPS          (4字节头)
SEI          (4字节头)
I0(slice0)     (4字节头)
I0(slice1)   (3字节头)
P1(slice0)     (4字节头)
P1(slice1)   (3字节头)
P2(slice0)     (4字节头)
P2(slice1)   (3字节头)

I0(slice0)是序列第一帧(I帧)的第一个slice,是当前Access Unit的首个nalu,所以是4字节头。而I0(slice1)表示第一帧的第二个slice,所以是3字节头。P1(slice0) 、P1(slice1)同理。

type Video

type Video struct {
	Media[NALUSlice]
	CodecID codec.VideoCodecID
	IDRing  *util.Ring[AVFrame[NALUSlice]] `json:"-"` //最近的关键帧位置,首屏渲染
	SPSInfo codec.SPSInfo
	GOP     int //关键帧间隔
	// contains filtered or unexported fields
}

func (*Video) Attach

func (t *Video) Attach()

func (*Video) ComputeGOP

func (t *Video) ComputeGOP()

func (*Video) Detach

func (t *Video) Detach()

func (*Video) Flush

func (vt *Video) Flush()

func (*Video) GetName

func (t *Video) GetName() string

func (*Video) ReadRing

func (vt *Video) ReadRing() *AVRing[NALUSlice]

func (*Video) WriteAVCC

func (vt *Video) WriteAVCC(ts uint32, frame AVCCFrame)

func (*Video) WriteAnnexB

func (vt *Video) WriteAnnexB(pts uint32, dts uint32, frame AnnexBFrame)

Jump to

Keyboard shortcuts

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