samplebuilder

package
v3.2.32 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 4 Imported by: 43

Documentation

Overview

Package samplebuilder provides functionality to reconstruct media frames from RTP packets.

Package samplebuilder provides functionality to reconstruct media frames from RTP packets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *SampleBuilder)

An Option configures a SampleBuilder.

func WithMaxTimeDelay added in v3.0.29

func WithMaxTimeDelay(maxLateDuration time.Duration) Option

WithMaxTimeDelay ensures that packets that are too old in the buffer get purged based on time rather than building up an extraordinarily long delay.

func WithPacketHeadHandler added in v3.2.15

func WithPacketHeadHandler(h func(headPacket interface{}) interface{}) Option

WithPacketHeadHandler set a head packet handler to allow inspecting the packet to extract certain information and return as custom metadata

func WithPacketReleaseHandler

func WithPacketReleaseHandler(h func(*rtp.Packet)) Option

WithPacketReleaseHandler set a callback when the builder is about to release some packet.

func WithPartitionHeadChecker

func WithPartitionHeadChecker(interface{}) Option

WithPartitionHeadChecker is obsolete, it does nothing.

type SampleBuilder

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

SampleBuilder buffers packets until media frames are complete.

func New

func New(maxLate uint16, depacketizer rtp.Depacketizer, sampleRate uint32, opts ...Option) *SampleBuilder

New constructs a new SampleBuilder. maxLate is how long to wait until we can construct a completed media.Sample. maxLate is measured in RTP packet sequence numbers. A large maxLate will result in less packet loss but higher latency. The depacketizer extracts media samples from RTP packets. Several depacketizers are available in package github.com/pion/rtp/codecs.

func (*SampleBuilder) Pop

func (s *SampleBuilder) Pop() *media.Sample

Pop compiles pushed RTP packets into media samples and then returns the next valid sample (or nil if no sample is compiled).

func (*SampleBuilder) PopWithTimestamp deprecated

func (s *SampleBuilder) PopWithTimestamp() (*media.Sample, uint32)

PopWithTimestamp compiles pushed RTP packets into media samples and then returns the next valid sample with its associated RTP timestamp (or nil, 0 if no sample is compiled).

Deprecated: PopWithTimestamp will be removed in v4. Use Sample.PacketTimestamp field instead.

func (*SampleBuilder) Push

func (s *SampleBuilder) Push(p *rtp.Packet)

Push adds an RTP Packet to s's buffer.

Push does not copy the input. If you wish to reuse this memory make sure to copy before calling Push

Jump to

Keyboard shortcuts

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