Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultLayerProvider(payloadProvider func() Payload) func() Layer
- func DefaultPacketProvider(payloadProvider func() Payload) func(pool pool.Pool[*DefaultPacket]) *DefaultPacket
- type Buffer
- type BufferPool
- type Data
- type DefaultLayer
- func (l *DefaultLayer) Bytes() []byte
- func (l *DefaultLayer) Init(payload Payload)
- func (l *DefaultLayer) Payload() Payload
- func (l *DefaultLayer) Read(p []byte) (n int, err error)
- func (l *DefaultLayer) SetPayload(payload Payload)
- func (l *DefaultLayer) Size() int
- func (l *DefaultLayer) String() string
- func (l *DefaultLayer) WriteTo(w io.Writer) (n int64, err error)
- type DefaultPacket
- type Header
- func (l *Header) AddCSRC(csrc uint32)
- func (l *Header) AddCSRCList(csrcList ...uint32)
- func (l *Header) AddExtensionContent(content uint32)
- func (l *Header) AddExtensionContents(contents ...uint32)
- func (l *Header) CSRCCount() uint8
- func (l *Header) CSRCList() []uint32
- func (l *Header) Clear()
- func (l *Header) DumpHeader(header *Header)
- func (l *Header) ExtensionContents() []uint32
- func (l *Header) ExtensionLength() uint16
- func (l *Header) ExtensionProfile() uint16
- func (l *Header) HasExtension() bool
- func (l *Header) HasPadding() bool
- func (l *Header) Marker() bool
- func (l *Header) PaddingLength() uint8
- func (l *Header) PayloadType() uint8
- func (l *Header) SSRC() uint32
- func (l *Header) SequenceNumber() uint16
- func (l *Header) SetCSRCList(csrcList []uint32)
- func (l *Header) SetExtensionContents(contents []uint32)
- func (l *Header) SetExtensionProfile(profile uint16)
- func (l *Header) SetMarker(maker bool)
- func (l *Header) SetPaddingLength(length uint8)
- func (l *Header) SetPayloadType(payloadType uint8)
- func (l *Header) SetSSRC(ssrc uint32)
- func (l *Header) SetSequenceNumber(seq uint16)
- func (l *Header) SetTimestamp(timestamp uint32)
- func (l *Header) Timestamp() uint32
- func (l *Header) Version() uint8
- type IncomingLayer
- func (l *IncomingLayer) Bytes() []byte
- func (l *IncomingLayer) Payload() Payload
- func (l *IncomingLayer) Read(p []byte) (n int, err error)
- func (l *IncomingLayer) Size() int
- func (l *IncomingLayer) String() string
- func (l *IncomingLayer) Unmarshal(data []byte) error
- func (l *IncomingLayer) UnmarshalChunks(cs [][]byte) error
- func (l *IncomingLayer) WriteTo(w io.Writer) (n int64, err error)
- type IncomingLayerConfig
- type IncomingPacket
- func (p *IncomingPacket) AddRef()
- func (p *IncomingPacket) AddRelation(relation pool.Reference)
- func (p *IncomingPacket) Addr() net.Addr
- func (p *IncomingPacket) Clear()
- func (p *IncomingPacket) Release() bool
- func (p *IncomingPacket) SetAddr(addr net.Addr)
- func (p *IncomingPacket) SetTime(t time.Time)
- func (p *IncomingPacket) Time() time.Time
- func (p *IncomingPacket) Use() *IncomingPacket
- type IncomingPayload
- func (p *IncomingPayload) AddContent(content []byte) *IncomingPayload
- func (p *IncomingPayload) AddContents(contents ...[]byte) *IncomingPayload
- func (p *IncomingPayload) Bytes() []byte
- func (p *IncomingPayload) Clear()
- func (p *IncomingPayload) Content() []byte
- func (p *IncomingPayload) Extends() [][]byte
- func (p *IncomingPayload) Range(f func(chunk []byte) bool) bool
- func (p *IncomingPayload) Read(buf []byte) (n int, err error)
- func (p *IncomingPayload) SetContent(content []byte) *IncomingPayload
- func (p *IncomingPayload) SetContents(contents [][]byte) *IncomingPayload
- func (p *IncomingPayload) Size() int
- func (p *IncomingPayload) WriteTo(w io.Writer) (n int64, err error)
- type Layer
- type Packet
- type Parser
- type Payload
- type Reader
- type Writer
Constants ¶
View Source
const ( DefaultBufferPoolSize = unit.KiBiByte * 256 DefaultBufferReverse = 2048 DefaultWriteBufferSize = 2048 )
View Source
const RtpHeaderMinSize = 12
Variables ¶
View Source
var ( InvalidVersionError = errors.New("RTP版本号必须为2") CSRCLengthOutOfRange = errors.New("RTP CSRC长度超过限制(0, 15)") ExtensionLengthOutOfRange = errors.New("RTP扩展头部长度超过限制(0, 65535)") PayloadLengthOutOfRange = errors.New("RTP负载长度超过限制(0, 65535)") ZeroPaddingLengthError = errors.New("RTP填充长度不能为0") PacketSizeNotEnoughError = errors.New("RTP包大小不够") )
View Source
var DebugLogger = assert.Must(log.Config{ Level: log.NewAtomicLevelAt(log.DebugLevel), Encoder: log.NewConsoleEncoder(log.ConsoleEncoderConfig{ EncodeLevel: log.CapitalColorLevelEncoder, }), }.Build())
View Source
var InvalidTCPHeaderIDError = errors.New("invalid tcp header id")
Functions ¶
func DefaultLayerProvider ¶
func DefaultPacketProvider ¶
func DefaultPacketProvider(payloadProvider func() Payload) func(pool pool.Pool[*DefaultPacket]) *DefaultPacket
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
func NewBufferPool ¶
func NewBufferPool(size uint) BufferPool
func (BufferPool) Get ¶
func (p BufferPool) Get() *Buffer
type DefaultLayer ¶
type DefaultLayer struct { Header // contains filtered or unexported fields }
func NewDefaultLayer ¶
func NewDefaultLayer(payload Payload) *DefaultLayer
func (*DefaultLayer) Bytes ¶
func (l *DefaultLayer) Bytes() []byte
func (*DefaultLayer) Init ¶
func (l *DefaultLayer) Init(payload Payload)
func (*DefaultLayer) Payload ¶
func (l *DefaultLayer) Payload() Payload
func (*DefaultLayer) SetPayload ¶
func (l *DefaultLayer) SetPayload(payload Payload)
func (*DefaultLayer) Size ¶
func (l *DefaultLayer) Size() int
func (*DefaultLayer) String ¶
func (l *DefaultLayer) String() string
type DefaultPacket ¶
type DefaultPacket struct { DefaultLayer // contains filtered or unexported fields }
func NewDefaultPacket ¶
func NewDefaultPacket(pool pool.Pool[*DefaultPacket], payload Payload) *DefaultPacket
func (*DefaultPacket) AddRef ¶
func (p *DefaultPacket) AddRef()
func (*DefaultPacket) AddRelation ¶
func (p *DefaultPacket) AddRelation(relation pool.Reference)
func (*DefaultPacket) Clear ¶
func (p *DefaultPacket) Clear()
func (*DefaultPacket) Release ¶
func (p *DefaultPacket) Release() bool
func (*DefaultPacket) Use ¶
func (p *DefaultPacket) Use() *DefaultPacket
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func (*Header) AddCSRCList ¶
func (*Header) AddExtensionContent ¶
func (*Header) AddExtensionContents ¶
func (*Header) DumpHeader ¶
func (*Header) ExtensionContents ¶
func (*Header) ExtensionLength ¶
func (*Header) ExtensionProfile ¶
func (*Header) HasExtension ¶
func (*Header) HasPadding ¶
func (*Header) PaddingLength ¶
func (*Header) PayloadType ¶
func (*Header) SequenceNumber ¶
func (*Header) SetCSRCList ¶
func (*Header) SetExtensionContents ¶
func (*Header) SetExtensionProfile ¶
func (*Header) SetPaddingLength ¶
func (*Header) SetPayloadType ¶
func (*Header) SetSequenceNumber ¶
func (*Header) SetTimestamp ¶
type IncomingLayer ¶
type IncomingLayer struct { Header // contains filtered or unexported fields }
func BuildIncomingLayer ¶
func BuildIncomingLayer(cfg *IncomingLayerConfig) *IncomingLayer
func NewIncomingLayer ¶
func NewIncomingLayer() *IncomingLayer
func (*IncomingLayer) Bytes ¶
func (l *IncomingLayer) Bytes() []byte
func (*IncomingLayer) Payload ¶
func (l *IncomingLayer) Payload() Payload
func (*IncomingLayer) Size ¶
func (l *IncomingLayer) Size() int
func (*IncomingLayer) String ¶
func (l *IncomingLayer) String() string
func (*IncomingLayer) Unmarshal ¶
func (l *IncomingLayer) Unmarshal(data []byte) error
func (*IncomingLayer) UnmarshalChunks ¶
func (l *IncomingLayer) UnmarshalChunks(cs [][]byte) error
type IncomingLayerConfig ¶
type IncomingPacket ¶
type IncomingPacket struct { *IncomingLayer // contains filtered or unexported fields }
func NewIncomingPacket ¶
func NewIncomingPacket(layer *IncomingLayer, pool pool.Pool[*IncomingPacket]) *IncomingPacket
func ProvideIncomingPacket ¶
func ProvideIncomingPacket(p pool.Pool[*IncomingPacket]) *IncomingPacket
func (*IncomingPacket) AddRef ¶
func (p *IncomingPacket) AddRef()
func (*IncomingPacket) AddRelation ¶
func (p *IncomingPacket) AddRelation(relation pool.Reference)
func (*IncomingPacket) Addr ¶
func (p *IncomingPacket) Addr() net.Addr
func (*IncomingPacket) Clear ¶
func (p *IncomingPacket) Clear()
func (*IncomingPacket) Release ¶
func (p *IncomingPacket) Release() bool
func (*IncomingPacket) SetAddr ¶
func (p *IncomingPacket) SetAddr(addr net.Addr)
func (*IncomingPacket) SetTime ¶
func (p *IncomingPacket) SetTime(t time.Time)
func (*IncomingPacket) Time ¶
func (p *IncomingPacket) Time() time.Time
func (*IncomingPacket) Use ¶
func (p *IncomingPacket) Use() *IncomingPacket
type IncomingPayload ¶
type IncomingPayload struct {
// contains filtered or unexported fields
}
func NewIncomingPayload ¶
func NewIncomingPayload() *IncomingPayload
func (*IncomingPayload) AddContent ¶
func (p *IncomingPayload) AddContent(content []byte) *IncomingPayload
func (*IncomingPayload) AddContents ¶
func (p *IncomingPayload) AddContents(contents ...[]byte) *IncomingPayload
func (*IncomingPayload) Bytes ¶
func (p *IncomingPayload) Bytes() []byte
func (*IncomingPayload) Clear ¶
func (p *IncomingPayload) Clear()
func (*IncomingPayload) Content ¶
func (p *IncomingPayload) Content() []byte
func (*IncomingPayload) Extends ¶
func (p *IncomingPayload) Extends() [][]byte
func (*IncomingPayload) SetContent ¶
func (p *IncomingPayload) SetContent(content []byte) *IncomingPayload
func (*IncomingPayload) SetContents ¶
func (p *IncomingPayload) SetContents(contents [][]byte) *IncomingPayload
func (*IncomingPayload) Size ¶
func (p *IncomingPayload) Size() int
type Layer ¶
type Layer interface { Version() uint8 HasPadding() bool HasExtension() bool CSRCCount() uint8 Marker() bool SetMarker(maker bool) PayloadType() uint8 SetPayloadType(payloadType uint8) SequenceNumber() uint16 SetSequenceNumber(seq uint16) Timestamp() uint32 SetTimestamp(timestamp uint32) SSRC() uint32 SetSSRC(ssrc uint32) CSRCList() []uint32 SetCSRCList(csrcList []uint32) AddCSRC(csrc uint32) AddCSRCList(csrcList ...uint32) ExtensionProfile() uint16 SetExtensionProfile(profile uint16) ExtensionLength() uint16 ExtensionContents() []uint32 SetExtensionContents(contents []uint32) AddExtensionContent(content uint32) AddExtensionContents(contents ...uint32) PaddingLength() uint8 SetPaddingLength(length uint8) DumpHeader(header *Header) Payload() Payload Size() int Bytes() []byte io.Reader io.WriterTo fmt.Stringer }
func ProvideIncomingLayer ¶
func ProvideIncomingLayer() Layer
type Parser ¶
type Parser struct { //ID byte Layer *IncomingLayer Length uint16 // contains filtered or unexported fields }
type Payload ¶
func ProvideIncomingPayload ¶
func ProvideIncomingPayload() Payload
Click to show internal directories.
Click to hide internal directories.