Documentation
¶
Overview ¶
Package packetizer provides RTP packetization for encoded media.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPacketizerClosed = errors.New("packetizer is closed") ErrBufferTooSmall = errors.New("buffer too small") ErrInvalidData = errors.New("invalid data") )
Errors
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Codec codec.Type // Codec selects the RTP payloader and timestamp behavior.
SSRC uint32 // SSRC is the synchronization source written into output packets.
PayloadType uint8 // PayloadType is the negotiated RTP payload type to emit.
MTU uint16 // Maximum transmission unit (typically 1200)
ClockRate uint32 // RTP clock rate (90000 for video, 48000 for Opus)
}
Config configures an RTP packetizer.
type PacketInfo ¶
type PacketInfo struct {
Offset int // Offset into the buffer where this packet starts
Size int // Size of this packet
}
PacketInfo describes a single RTP packet in the output buffer.
type Packetizer ¶
type Packetizer interface {
// PacketizeInto packetizes encoded data into RTP packets.
// dst is a pre-allocated buffer to hold all packets contiguously.
// packets is a pre-allocated slice to receive packet info (offset/size).
// Returns the number of packets written.
PacketizeInto(data []byte, timestamp uint32, isKeyframe bool, dst []byte, packets []PacketInfo) (int, error)
// MaxPackets returns the maximum number of packets that could be generated
// for a frame of the given size.
MaxPackets(frameSize int) int
// MaxPacketSize returns the maximum size of a single RTP packet.
MaxPacketSize() int
// SequenceNumber returns the next sequence number that will be used.
SequenceNumber() uint16
// Close releases resources.
Close() error
}
Packetizer converts encoded frames into RTP packets. All operations are allocation-free from the caller's perspective - caller provides the output buffer and packet metadata slices.
Click to show internal directories.
Click to hide internal directories.