samplebuilder

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 5 Imported by: 0

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 WithJitterBufferMinimumLength

func WithJitterBufferMinimumLength(length uint16) Option

WithJitterBufferMinimumLength sets the minimum number of packets which must first be received before starting any playback

func WithMaxTimeDelay

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

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 WithRTPHeaders

func WithRTPHeaders(enable bool) Option

WithRTPHeaders enables to collect RTP headers forming a Sample. Useful for accessing RTP extensions associated to the Sample.

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) Flush

func (s *SampleBuilder) Flush()

Flush marks all samples in the buffer to be popped.

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) 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