track

package
v4.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 12 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AAC

type AAC struct {
	Audio

	Mode int // 1为lbr,2为hbr
	// contains filtered or unexported fields
}

func NewAAC

func NewAAC(stream IStream) (aac *AAC)

func (*AAC) CompleteRTP added in v4.10.0

func (aac *AAC) CompleteRTP(value *AVFrame[[]byte])

func (*AAC) WriteAVCC

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

func (*AAC) WriteRTPFrame added in v4.10.0

func (aac *AAC) WriteRTPFrame(frame *RTPFrame)

https://datatracker.ietf.org/doc/html/rfc3640#section-3.2.1

type Audio

type Audio struct {
	Media[[]byte]
	CodecID    codec.AudioCodecID
	Channels   byte
	SampleSize byte
	AVCCHead   []byte // 音频包在AVCC格式中,AAC会有两个字节,其他的只有一个字节
	// Profile:
	// 0: Main profile
	// 1: Low Complexity profile(LC)
	// 2: Scalable Sampling Rate profile(SSR)
	// 3: Reserved
	Profile byte
}

func (*Audio) Attach

func (a *Audio) Attach()

func (*Audio) CompleteAVCC added in v4.10.0

func (a *Audio) CompleteAVCC(value *AVFrame[[]byte])

func (*Audio) CompleteRTP added in v4.10.0

func (a *Audio) CompleteRTP(value *AVFrame[[]byte])

func (*Audio) Detach

func (a *Audio) Detach()

func (*Audio) GetDecConfSeq

func (a *Audio) GetDecConfSeq() int

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) SnapForJson added in v4.5.1

func (a *Audio) SnapForJson()

为json序列化而计算的数据

func (*Audio) WriteADTS

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

func (*Audio) WriteAVCC added in v4.7.3

func (av *Audio) WriteAVCC(ts uint32, frame AVCCFrame)

func (*Audio) WriteRaw added in v4.8.4

func (av *Audio) WriteRaw(pts uint32, raw []byte)

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) WriteRTPFrame added in v4.10.0

func (g711 *G711) WriteRTPFrame(frame *RTPFrame)

type H264

type H264 struct {
	Video
}

func NewH264

func NewH264(stream IStream) (vt *H264)

func (*H264) CompleteRTP added in v4.10.0

func (vt *H264) CompleteRTP(value *AVFrame[NALUSlice])

RTP格式补完

func (*H264) WriteAVCC

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

func (*H264) WriteRTPFrame added in v4.10.0

func (vt *H264) WriteRTPFrame(frame *RTPFrame)

func (*H264) WriteSliceBytes added in v4.10.0

func (vt *H264) WriteSliceBytes(slice []byte)

type H265

type H265 struct {
	Video
}

func NewH265

func NewH265(stream IStream) (vt *H265)

func (*H265) CompleteRTP added in v4.10.0

func (vt *H265) CompleteRTP(value *AVFrame[NALUSlice])

RTP格式补完

func (*H265) WriteAVCC

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

func (*H265) WriteRTPFrame added in v4.10.0

func (vt *H265) WriteRTPFrame(frame *RTPFrame)

func (*H265) WriteSliceBytes added in v4.10.0

func (vt *H265) WriteSliceBytes(slice []byte)

type Media

type Media[T RawSlice] struct {
	Base
	AVRing[T]
	SampleRate           uint32
	SSRC                 uint32
	DecoderConfiguration DecoderConfiguration[T] `json:"-"` //H264(SPS、PPS) H265(VPS、SPS、PPS) AAC(config)
	RTPMuxer
	RTPDemuxer
	SpesificTrack[T] `json:"-"`
	// 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)

https://www.cnblogs.com/moonwalk/p/15903760.html 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]) SetSpeedLimit added in v4.8.6

func (av *Media[T]) SetSpeedLimit(value int)

func (*Media[T]) SetStuff added in v4.9.5

func (av *Media[T]) SetStuff(stuff ...any)

func (*Media[T]) UnmarshalRTP

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

func (*Media[T]) UnmarshalRTPPacket

func (av *Media[T]) UnmarshalRTPPacket(p *rtp.Packet) (frame *RTPFrame)

func (*Media[T]) WriteAVCC

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

func (*Media[T]) WriteRTP added in v4.9.5

func (av *Media[T]) WriteRTP(raw []byte)

WriteRTP 写入未反序列化的RTP包

func (*Media[T]) WriteRTPPack added in v4.9.5

func (av *Media[T]) WriteRTPPack(p *rtp.Packet)

WriteRTPPack 写入已反序列化的RTP包

type RTPDemuxer added in v4.8.2

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

type RTPMuxer added in v4.8.2

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

type SpesificTrack added in v4.10.0

type SpesificTrack[T RawSlice] interface {
	CompleteRTP(*AVFrame[T])
	CompleteAVCC(*AVFrame[T])
	WriteSliceBytes([]byte)
	WriteRTPFrame(*RTPFrame)

	Flush()
	// contains filtered or unexported methods
}

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 (vt *Video) Attach()

func (*Video) CompleteAVCC added in v4.10.0

func (vt *Video) CompleteAVCC(rv *AVFrame[NALUSlice])

func (*Video) Detach

func (vt *Video) Detach()

func (*Video) Flush

func (vt *Video) Flush()

func (*Video) GetDecConfSeq

func (vt *Video) GetDecConfSeq() int

func (*Video) GetName

func (vt *Video) GetName() string

func (*Video) PlayFullAnnexB added in v4.7.0

func (vt *Video) PlayFullAnnexB(ctx context.Context, onMedia func(net.Buffers) error) error

PlayFullAnnexB 订阅annex-b格式的流数据,每一个I帧增加sps、pps头

func (*Video) ReadRing

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

func (*Video) SetLostFlag added in v4.8.6

func (vt *Video) SetLostFlag()

func (*Video) SnapForJson added in v4.5.1

func (vt *Video) SnapForJson()

func (*Video) WriteAVCC

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

func (*Video) WriteAnnexB

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

func (*Video) WriteRawBytes added in v4.10.0

func (vt *Video) WriteRawBytes(slice []byte)

func (*Video) WriteSliceByte added in v4.10.0

func (vt *Video) WriteSliceByte(b ...byte)

Jump to

Keyboard shortcuts

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