buffer

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 16 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

Logger is an implementation of logr.Logger. If is not provided - will be turned off.

Functions

func IsLaterTimestamp added in v1.7.1

func IsLaterTimestamp(timestamp1 uint32, timestamp2 uint32) bool

IsLaterTimestamp returns true if timestamp1 is later in time than timestamp2 factoring in timestamp wrap-around

func IsTimestampWrapAround added in v1.7.1

func IsTimestampWrapAround(timestamp1 uint32, timestamp2 uint32) bool

IsTimestampWrapAround returns true if wrap around happens from timestamp1 to timestamp2

Types

type Bucket added in v1.7.0

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

func NewBucket added in v1.7.0

func NewBucket(buf *[]byte) *Bucket

func (*Bucket) AddPacket added in v1.9.1

func (b *Bucket) AddPacket(pkt []byte, sn uint16, latest bool) ([]byte, error)

func (*Bucket) GetPacket added in v1.9.1

func (b *Bucket) GetPacket(buf []byte, sn uint16) (i int, err error)

type Buffer

type Buffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Buffer contains all packets

func NewBuffer

func NewBuffer(ssrc uint32, vp, ap *sync.Pool, logger logr.Logger) *Buffer

NewBuffer constructs a new Buffer

func (*Buffer) Bind added in v1.7.0

func (b *Buffer) Bind(params webrtc.RTPParameters, o Options)

func (*Buffer) Bitrate added in v1.8.2

func (b *Buffer) Bitrate() uint64

Bitrate returns the current publisher stream bitrate.

func (*Buffer) Close added in v1.7.0

func (b *Buffer) Close() error

func (*Buffer) GetClockRate added in v1.7.1

func (b *Buffer) GetClockRate() uint32

GetClockRate returns the RTP clock rate

func (*Buffer) GetLatestTimestamp added in v1.7.1

func (b *Buffer) GetLatestTimestamp() (latestTimestamp uint32, latestTimestampTimeInNanosSinceEpoch int64)

GetLatestTimestamp returns the latest RTP timestamp factoring in potential RTP timestamp wrap-around

func (*Buffer) GetMediaSSRC added in v1.7.1

func (b *Buffer) GetMediaSSRC() uint32

GetMediaSSRC returns the associated SSRC of the RTP stream

func (*Buffer) GetPacket added in v1.7.0

func (b *Buffer) GetPacket(buff []byte, sn uint16) (int, error)

func (*Buffer) GetSenderReportData added in v1.7.1

func (b *Buffer) GetSenderReportData() (rtpTime uint32, ntpTime uint64, lastReceivedTimeInNanosSinceEpoch int64)

GetSenderReportData returns the rtp, ntp and nanos of the last sender report

func (*Buffer) GetStats added in v1.7.1

func (b *Buffer) GetStats() (stats Stats)

GetStats returns the raw statistics about a particular buffer state

func (*Buffer) MaxTemporalLayer added in v1.8.2

func (b *Buffer) MaxTemporalLayer() int32

func (*Buffer) OnAudioLevel added in v1.8.2

func (b *Buffer) OnAudioLevel(fn func(level uint8))

func (*Buffer) OnClose added in v1.7.0

func (b *Buffer) OnClose(fn func())

func (*Buffer) OnFeedback added in v1.7.0

func (b *Buffer) OnFeedback(fn func(fb []rtcp.Packet))

func (*Buffer) OnTransportWideCC added in v1.7.0

func (b *Buffer) OnTransportWideCC(fn func(sn uint16, timeNS int64, marker bool))

func (*Buffer) Read added in v1.7.0

func (b *Buffer) Read(buff []byte) (n int, err error)

func (*Buffer) ReadExtended added in v1.9.1

func (b *Buffer) ReadExtended() (*ExtPacket, error)

func (*Buffer) SetSenderReportData added in v1.7.0

func (b *Buffer) SetSenderReportData(rtpTime uint32, ntpTime uint64)

func (*Buffer) Write added in v1.7.0

func (b *Buffer) Write(pkt []byte) (n int, err error)

Write adds a RTP Packet, out of order, new packet may be arrived later

type ExtPacket added in v1.8.2

type ExtPacket struct {
	Head     bool
	Cycle    uint32
	Arrival  int64
	Packet   rtp.Packet
	Payload  interface{}
	KeyFrame bool
}

type Factory added in v1.7.0

type Factory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewBufferFactory added in v1.7.0

func NewBufferFactory(trackingPackets int, logger logr.Logger) *Factory

func (*Factory) GetBuffer added in v1.7.1

func (f *Factory) GetBuffer(ssrc uint32) *Buffer

func (*Factory) GetBufferPair added in v1.7.0

func (f *Factory) GetBufferPair(ssrc uint32) (*Buffer, *RTCPReader)

func (*Factory) GetOrNew added in v1.7.0

func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser

func (*Factory) GetRTCPReader added in v1.7.0

func (f *Factory) GetRTCPReader(ssrc uint32) *RTCPReader

type Options

type Options struct {
	MaxBitRate uint64
}

BufferOptions provides configuration options for the buffer

type RTCPReader added in v1.7.0

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

func NewRTCPReader added in v1.7.0

func NewRTCPReader(ssrc uint32) *RTCPReader

func (*RTCPReader) Close added in v1.7.0

func (r *RTCPReader) Close() error

func (*RTCPReader) OnClose added in v1.7.0

func (r *RTCPReader) OnClose(fn func())

func (*RTCPReader) OnPacket added in v1.7.0

func (r *RTCPReader) OnPacket(f func([]byte))

func (*RTCPReader) Read added in v1.7.0

func (r *RTCPReader) Read(_ []byte) (n int, err error)

func (*RTCPReader) Write added in v1.7.0

func (r *RTCPReader) Write(p []byte) (n int, err error)

type Stats added in v1.7.1

type Stats struct {
	LastExpected uint32
	LastReceived uint32
	LostRate     float32
	PacketCount  uint32  // Number of packets received from this source.
	Jitter       float64 // An estimate of the statistical variance of the RTP data packet inter-arrival time.
	TotalByte    uint64
}

type VP8 added in v1.8.2

type VP8 struct {
	TemporalSupported bool
	// Optional Header
	PictureID uint16 /* 8 or 16 bits, picture ID */
	PicIDIdx  int
	MBit      bool
	TL0PICIDX uint8 /* 8 bits temporal level zero index */
	TlzIdx    int

	// Optional Header If either of the T or K bits are set to 1,
	// the TID/Y/KEYIDX extension field MUST be present.
	TID uint8 /* 2 bits temporal layer idx*/
	// IsKeyFrame is a helper to detect if current packet is a keyframe
	IsKeyFrame bool
}

VP8 is a helper to get temporal data from VP8 packet header

VP8 Payload Descriptor
		0 1 2 3 4 5 6 7                      0 1 2 3 4 5 6 7
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
		|X|R|N|S|R| PID | (REQUIRED)        |X|R|N|S|R| PID | (REQUIRED)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	X:  |I|L|T|K| RSV   | (OPTIONAL)   X:   |I|L|T|K| RSV   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	I:  |M| PictureID   | (OPTIONAL)   I:   |M| PictureID   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	L:  |   TL0PICIDX   | (OPTIONAL)        |   PictureID   |
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	T/K:|TID|Y| KEYIDX  | (OPTIONAL)   L:   |   TL0PICIDX   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	T/K:|TID|Y| KEYIDX  | (OPTIONAL)
		+-+-+-+-+-+-+-+-+

func (*VP8) Unmarshal added in v1.8.2

func (p *VP8) Unmarshal(payload []byte) error

Unmarshal parses the passed byte slice and stores the result in the VP8 this method is called upon

Jump to

Keyboard shortcuts

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