Documentation
¶
Overview ¶
Package samplebuilder builds 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 WithPacketDroppedHandler ¶
func WithPacketDroppedHandler(h func()) Option
func WithPacketReleaseHandler ¶
WithPacketReleaseHandler sets a callback that is called when the builder is about to release some packet.
type SampleBuilder ¶
type SampleBuilder struct {
// contains filtered or unexported fields
}
SampleBuilder buffers packets and produces media frames
func New ¶
func New(maxLate uint16, depacketizer rtp.Depacketizer, sampleRate uint32, opts ...Option) *SampleBuilder
New constructs a new SampleBuilder.
maxLate is the maximum delay, in RTP sequence numbers, that the samplebuilder will wait before dropping a frame. The actual buffer size is twice as large in order to compensate for delays between Push and Pop.
func (*SampleBuilder) ForcePopWithTimestamp ¶
func (s *SampleBuilder) ForcePopWithTimestamp() (*media.Sample, uint32)
ForcePopWithTimestamp is like PopWithTimestamp, but will always pops a sample if any are available, even if it's being blocked by a missing packet. This is useful when the stream ends, or after a link outage. After ForcePopWithTimestamp returns nil, the samplebuilder is guaranteed to be empty.
func (*SampleBuilder) Pop ¶
func (s *SampleBuilder) Pop() *media.Sample
Pop returns a completed packet. If the oldest packet is incomplete and hasn't reached MaxLate yet, Pop returns nil.
func (*SampleBuilder) PopPackets ¶
func (s *SampleBuilder) PopPackets() []*rtp.Packet
PopPackets returns rtp packets of a completed packet(a frame of audio/video). If the oldest packet is incomplete and hasn't reached MaxLate yet, PopPackets returns nil. rtp packets returned is not called release handle by SampleBuilder, so caller is reponsible for release these packets if required.
func (*SampleBuilder) PopWithTimestamp ¶
func (s *SampleBuilder) PopWithTimestamp() (*media.Sample, uint32)
PopWithTimestamp returns a completed packet and its RTP timestamp. If the oldest packet is incomplete and hasn't reached MaxLate yet, Pop returns nil.
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: the packet will be retained by s. If you plan to reuse the packet or its buffer, make sure to perform a copy.