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 ¶
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 ¶
WithPacketReleaseHandler set a callback when the builder is about to release some packet.
func WithRTPHeaders ¶
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