Documentation
¶
Overview ¶
Package rtpbuffer provides a buffer for storing RTP packets
Index ¶
- Constants
- Variables
- type PacketFactory
- type PacketFactoryCopy
- type PacketFactoryNoOp
- type RTPBuffer
- type Resend
- type ResendKey
- type RetainablePacket
- func (p *RetainablePacket) BeginResend(now time.Time, interval time.Duration) bool
- func (p *RetainablePacket) EndResend(now time.Time, sent bool)
- func (p *RetainablePacket) Header() *rtp.Header
- func (p *RetainablePacket) Payload() []byte
- func (p *RetainablePacket) Release()
- func (p *RetainablePacket) Retain() error
- func (p *RetainablePacket) SetUnwrapped(pkt *rtp.Packet)
- func (p *RetainablePacket) Unwrapped() *rtp.Packet
Constants ¶
const (
// Uint16SizeHalf is half of a math.Uint16.
Uint16SizeHalf = 1 << 15
)
Variables ¶
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 ¶
NewRTPBuffer constructs a new RTPBuffer.
func (*RTPBuffer) Add ¶
func (r *RTPBuffer) Add(packet *RetainablePacket)
Add places the RetainablePacket in the RTPBuffer, taking ownership of the caller's reference. A packet for a sequence number that is already buffered, or that is too old to fit the window, is released instead of stored.
func (*RTPBuffer) Clear ¶ added in v0.1.45
func (r *RTPBuffer) Clear()
Clear releases all retained packets in the buffer.
func (*RTPBuffer) Get ¶
func (r *RTPBuffer) Get(seq uint16) *RetainablePacket
Get returns the RetainablePacket for the requested sequence number.
func (*RTPBuffer) Peek ¶
func (r *RTPBuffer) Peek(seq uint16) *RetainablePacket
Peek returns the RetainablePacket for the requested sequence number without retaining it. The result is only valid until the packet is next released, so callers must not use it concurrently with Add, Remove or Clear.
func (*RTPBuffer) Remove ¶
func (r *RTPBuffer) Remove(seq uint16) *RetainablePacket
Remove takes the RetainablePacket for the requested sequence number out of the buffer, transferring the buffer's reference to the caller.
type Resend ¶ added in v0.1.51
type Resend struct {
// contains filtered or unexported fields
}
Resend tracks a retransmission through asynchronous writers.
func NewResend ¶ added in v0.1.51
NewResend creates a resend with one owner and a completion callback.
type ResendKey ¶ added in v0.1.51
type ResendKey struct{}
ResendKey identifies retransmission completion in interceptor attributes.
type RetainablePacket ¶
type RetainablePacket struct {
// contains filtered or unexported fields
}
RetainablePacket is a referenced counted RTP packet.
func (*RetainablePacket) BeginResend ¶ added in v0.1.51
BeginResend reserves a packet unless it is pending or was recently resent.
func (*RetainablePacket) EndResend ¶ added in v0.1.51
func (p *RetainablePacket) EndResend(now time.Time, sent bool)
EndResend clears pending and records successful retransmissions.
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.
func (*RetainablePacket) SetUnwrapped ¶
func (p *RetainablePacket) SetUnwrapped(pkt *rtp.Packet)
SetUnwrapped caches an *rtp.Packet view for reuse by later reads.
func (*RetainablePacket) Unwrapped ¶
func (p *RetainablePacket) Unwrapped() *rtp.Packet
Unwrapped returns the cached *rtp.Packet view, or nil if none is cached yet.