rtpbuffer

package
v0.1.40 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package rtpbuffer provides a buffer for storing RTP packets

Index

Constants

View Source
const (
	// Uint16SizeHalf is half of a math.Uint16.
	Uint16SizeHalf = 1 << 15
)

Variables

View Source
var ErrInvalidSize = errors.New("invalid buffer size")

ErrInvalidSize is returned by newReceiveLog/newRTPBuffer, when an incorrect buffer size is supplied.

Functions

This section is empty.

Types

type PacketFactory

type PacketFactory interface {
	NewPacket(header *rtp.Header, payload []byte, rtxSsrc uint32, rtxPayloadType uint8) (*RetainablePacket, error)
}

PacketFactory allows custom logic around the handle of RTP Packets before they added to the RTPBuffer. The NoOpPacketFactory doesn't copy packets, while the RetainablePacket will take a copy before adding.

type PacketFactoryCopy

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

PacketFactoryCopy is PacketFactory that takes a copy of packets when added to the RTPBuffer.

func NewPacketFactoryCopy

func NewPacketFactoryCopy() *PacketFactoryCopy

NewPacketFactoryCopy constructs a PacketFactory that takes a copy of packets when added to the RTPBuffer.

func (*PacketFactoryCopy) NewPacket

func (m *PacketFactoryCopy) NewPacket(
	header *rtp.Header, payload []byte, rtxSsrc uint32, rtxPayloadType uint8,
) (*RetainablePacket, error)

NewPacket constructs a new RetainablePacket that can be added to the RTPBuffer.

type PacketFactoryNoOp

type PacketFactoryNoOp struct{}

PacketFactoryNoOp is a PacketFactory implementation that doesn't copy packets.

func (*PacketFactoryNoOp) NewPacket

func (f *PacketFactoryNoOp) NewPacket(
	header *rtp.Header, payload []byte, _ uint32, _ uint8,
) (*RetainablePacket, error)

NewPacket constructs a new RetainablePacket that can be added to the RTPBuffer.

type RTPBuffer

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

RTPBuffer stores RTP packets and allows custom logic around the lifetime of them via the PacketFactory.

func NewRTPBuffer

func NewRTPBuffer(size uint16) (*RTPBuffer, error)

NewRTPBuffer constructs a new RTPBuffer.

func (*RTPBuffer) Add

func (r *RTPBuffer) Add(packet *RetainablePacket)

Add places the RetainablePacket in the RTPBuffer.

func (*RTPBuffer) Get

func (r *RTPBuffer) Get(seq uint16) *RetainablePacket

Get returns the RetainablePacket for the requested sequence number.

type RetainablePacket

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

RetainablePacket is a referenced counted RTP packet.

func (*RetainablePacket) Header

func (p *RetainablePacket) Header() *rtp.Header

Header returns the RTP Header of the RetainablePacket.

func (*RetainablePacket) Payload

func (p *RetainablePacket) Payload() []byte

Payload returns the RTP Payload of the RetainablePacket.

func (*RetainablePacket) Release

func (p *RetainablePacket) Release()

Release decreases the reference count of the RetainablePacket and frees if needed.

func (*RetainablePacket) Retain

func (p *RetainablePacket) Retain() error

Retain increases the reference count of the RetainablePacket.

Jump to

Keyboard shortcuts

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