Documentation ¶
Overview ¶
Package packetio provides packet buffer
Index ¶
- Variables
- type Buffer
- func (b *Buffer) Close() (err error)
- func (b *Buffer) Count() int
- func (b *Buffer) Read(packet []byte) (n int, err error)
- func (b *Buffer) SetLimitCount(limit int)
- func (b *Buffer) SetLimitSize(limit int)
- func (b *Buffer) SetReadDeadline(t time.Time) error
- func (b *Buffer) Size() int
- func (b *Buffer) Write(packet []byte) (int, error)
- type BufferPacketType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFull is returned when the buffer has hit the configured limits. ErrFull = errors.New("packetio.Buffer is full, discarding write") // ErrTimeout is returned when a deadline has expired ErrTimeout = errors.New("i/o timeout") )
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer allows writing packets to an intermediate buffer, which can then be read form. This is verify similar to bytes.Buffer but avoids combining multiple writes into a single read.
func (*Buffer) Close ¶
Close the buffer, unblocking any pending reads. Data in the buffer can still be read, Read will return io.EOF only when empty.
func (*Buffer) Read ¶
Read populates the given byte slice, returning the number of bytes read. Blocks until data is available or the buffer is closed. Returns io.ErrShortBuffer is the packet is too small to copy the Write. Returns io.EOF if the buffer is closed.
func (*Buffer) SetLimitCount ¶
SetLimitCount controls the maximum number of packets that can be buffered. Causes Write to return ErrFull when this limit is reached. A zero value will disable this limit.
func (*Buffer) SetLimitSize ¶
SetLimitSize controls the maximum number of bytes that can be buffered. Causes Write to return ErrFull when this limit is reached. A zero value means 4MB since v0.11.0.
User can set packetioSizeHardLimit build tag to enable 4MB hard limit. When packetioSizeHardLimit build tag is set, SetLimitSize exceeding the hard limit will be silently discarded.
func (*Buffer) SetReadDeadline ¶
SetReadDeadline sets the deadline for the Read operation. Setting to zero means no deadline.
type BufferPacketType ¶
type BufferPacketType int
BufferPacketType allow the Buffer to know which packet protocol is writing.
const ( // RTPBufferPacket indicates the Buffer that is handling RTP packets RTPBufferPacket BufferPacketType = 1 // RTCPBufferPacket indicates the Buffer that is handling RTCP packets RTCPBufferPacket BufferPacketType = 2 )