Documentation ¶
Index ¶
- Constants
- Variables
- func OutputLayerProvider(payloadProvider func() Payload) func() Layer
- func OutputPacketProvider(payloadProvider func() Payload) func(pool pool.Pool[*OutputPacket]) *OutputPacket
- type CSRCs
- type DefaultExtension
- func (e *DefaultExtension) Append(contents ...uint32)
- func (e *DefaultExtension) Clear()
- func (e *DefaultExtension) Get(i int) uint32
- func (e *DefaultExtension) Len() int
- func (e *DefaultExtension) Profile() uint16
- func (e *DefaultExtension) Replace(contents ...uint32)
- func (e *DefaultExtension) Set(i int, content uint32)
- func (e *DefaultExtension) SetProfile(profile uint16)
- func (e *DefaultExtension) Size() int
- type DefaultHeader
- func (h *DefaultHeader) CSRCs() CSRCs
- func (h *DefaultHeader) Clear()
- func (h *DefaultHeader) Extension() Extension
- func (h *DefaultHeader) HasExtension() bool
- func (h *DefaultHeader) HasPadding() bool
- func (h *DefaultHeader) Marker() bool
- func (h *DefaultHeader) PayloadType() uint8
- func (h *DefaultHeader) SSRC() uint32
- func (h *DefaultHeader) SequenceNumber() uint16
- func (h *DefaultHeader) SetMarker(maker bool)
- func (h *DefaultHeader) SetPayloadType(payloadType uint8)
- func (h *DefaultHeader) SetSSRC(ssrc uint32)
- func (h *DefaultHeader) SetSequenceNumber(seq uint16)
- func (h *DefaultHeader) SetTimestamp(timestamp uint32)
- func (h *DefaultHeader) Timestamp() uint32
- func (h *DefaultHeader) Version() uint8
- func (h *DefaultHeader) WriteTo(w io.Writer) (n int64, err error)
- type Extension
- type Handler
- type Header
- type IncomingPayload
- func (p *IncomingPayload) AddContents(contents ...[]byte) *IncomingPayload
- func (p *IncomingPayload) Bytes() []byte
- func (p *IncomingPayload) Clear()
- func (p *IncomingPayload) Range(f func(chunk []byte) bool) bool
- func (p *IncomingPayload) SetContents(contents ...[]byte) *IncomingPayload
- func (p *IncomingPayload) Size() int
- func (p *IncomingPayload) WriteTo(w io.Writer) (n int64, err error)
- type InputLayer
- func (l *InputLayer) Bytes() []byte
- func (l *InputLayer) Clear()
- func (l *InputLayer) PaddingLength() uint8
- func (l *InputLayer) Payload() Payload
- func (l *InputLayer) SetPaddingLength(length uint8)
- func (l *InputLayer) Size() int
- func (l *InputLayer) String() string
- func (l *InputLayer) Unmarshal(data []byte) error
- func (l *InputLayer) UnmarshalChunks(cs [][]byte) error
- func (l *InputLayer) WriteTo(w io.Writer) (n int64, err error)
- type InputPacket
- func (p *InputPacket) AddRef()
- func (p *InputPacket) AddRelation(relation pool.Reference)
- func (p *InputPacket) Addr() net.Addr
- func (p *InputPacket) Clear()
- func (p *InputPacket) Release() bool
- func (p *InputPacket) SetAddr(addr net.Addr)
- func (p *InputPacket) SetTime(t time.Time)
- func (p *InputPacket) Time() time.Time
- func (p *InputPacket) Use() *InputPacket
- type Layer
- type OutputLayer
- func (l *OutputLayer) Bytes() []byte
- func (l *OutputLayer) Clear()
- func (l *OutputLayer) Init(payload Payload)
- func (l *OutputLayer) PaddingLength() uint8
- func (l *OutputLayer) Payload() Payload
- func (l *OutputLayer) SetPaddingLength(length uint8)
- func (l *OutputLayer) SetPayload(payload Payload)
- func (l *OutputLayer) Size() int
- func (l *OutputLayer) String() string
- func (l *OutputLayer) WriteTo(w io.Writer) (n int64, err error)
- type OutputPacket
- type Packet
- type Padding
- type Parser
- type Payload
- type Server
- type SliceCSRCs
- type Stream
Constants ¶
View Source
const ( DefaultBufferPoolSize = unit.KiBiByte * 256 DefaultBufferReverse = 2048 )
View Source
const ( BaseHeaderSize = 12 MaxCSRCs = 15 MaxExtensions = math.MaxUint16 )
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包大小不够") )
Functions ¶
func OutputLayerProvider ¶
func OutputPacketProvider ¶
func OutputPacketProvider(payloadProvider func() Payload) func(pool pool.Pool[*OutputPacket]) *OutputPacket
Types ¶
type DefaultExtension ¶
type DefaultExtension struct {
// contains filtered or unexported fields
}
func (*DefaultExtension) Append ¶
func (e *DefaultExtension) Append(contents ...uint32)
func (*DefaultExtension) Clear ¶
func (e *DefaultExtension) Clear()
func (*DefaultExtension) Get ¶
func (e *DefaultExtension) Get(i int) uint32
func (*DefaultExtension) Len ¶
func (e *DefaultExtension) Len() int
func (*DefaultExtension) Profile ¶
func (e *DefaultExtension) Profile() uint16
func (*DefaultExtension) Replace ¶
func (e *DefaultExtension) Replace(contents ...uint32)
func (*DefaultExtension) Set ¶
func (e *DefaultExtension) Set(i int, content uint32)
func (*DefaultExtension) SetProfile ¶
func (e *DefaultExtension) SetProfile(profile uint16)
func (*DefaultExtension) Size ¶
func (e *DefaultExtension) Size() int
type DefaultHeader ¶
type DefaultHeader struct {
// contains filtered or unexported fields
}
func (*DefaultHeader) CSRCs ¶
func (h *DefaultHeader) CSRCs() CSRCs
func (*DefaultHeader) Clear ¶
func (h *DefaultHeader) Clear()
func (*DefaultHeader) Extension ¶
func (h *DefaultHeader) Extension() Extension
func (*DefaultHeader) HasExtension ¶
func (h *DefaultHeader) HasExtension() bool
func (*DefaultHeader) HasPadding ¶
func (h *DefaultHeader) HasPadding() bool
func (*DefaultHeader) Marker ¶
func (h *DefaultHeader) Marker() bool
func (*DefaultHeader) PayloadType ¶
func (h *DefaultHeader) PayloadType() uint8
func (*DefaultHeader) SSRC ¶
func (h *DefaultHeader) SSRC() uint32
func (*DefaultHeader) SequenceNumber ¶
func (h *DefaultHeader) SequenceNumber() uint16
func (*DefaultHeader) SetMarker ¶
func (h *DefaultHeader) SetMarker(maker bool)
func (*DefaultHeader) SetPayloadType ¶
func (h *DefaultHeader) SetPayloadType(payloadType uint8)
func (*DefaultHeader) SetSSRC ¶
func (h *DefaultHeader) SetSSRC(ssrc uint32)
func (*DefaultHeader) SetSequenceNumber ¶
func (h *DefaultHeader) SetSequenceNumber(seq uint16)
func (*DefaultHeader) SetTimestamp ¶
func (h *DefaultHeader) SetTimestamp(timestamp uint32)
func (*DefaultHeader) Timestamp ¶
func (h *DefaultHeader) Timestamp() uint32
func (*DefaultHeader) Version ¶
func (h *DefaultHeader) Version() uint8
type Header ¶
type Header interface { Version() uint8 HasPadding() bool HasExtension() bool 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) CSRCs() CSRCs Extension() Extension io.WriterTo Clear() }
type IncomingPayload ¶
type IncomingPayload struct {
// contains filtered or unexported fields
}
func NewIncomingPayload ¶
func NewIncomingPayload() *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) SetContents ¶
func (p *IncomingPayload) SetContents(contents ...[]byte) *IncomingPayload
func (*IncomingPayload) Size ¶
func (p *IncomingPayload) Size() int
type InputLayer ¶
type InputLayer struct { DefaultHeader // contains filtered or unexported fields }
func NewInputLayer ¶
func NewInputLayer() *InputLayer
func (*InputLayer) Bytes ¶
func (l *InputLayer) Bytes() []byte
func (*InputLayer) Clear ¶
func (l *InputLayer) Clear()
func (*InputLayer) PaddingLength ¶
func (l *InputLayer) PaddingLength() uint8
func (*InputLayer) Payload ¶
func (l *InputLayer) Payload() Payload
func (*InputLayer) SetPaddingLength ¶
func (l *InputLayer) SetPaddingLength(length uint8)
func (*InputLayer) Size ¶
func (l *InputLayer) Size() int
func (*InputLayer) String ¶
func (l *InputLayer) String() string
func (*InputLayer) Unmarshal ¶
func (l *InputLayer) Unmarshal(data []byte) error
func (*InputLayer) UnmarshalChunks ¶
func (l *InputLayer) UnmarshalChunks(cs [][]byte) error
type InputPacket ¶
type InputPacket struct { *InputLayer // contains filtered or unexported fields }
InputPacket 通常用于承载外部接受到的RTP包,可以标记对端地址、接收时间戳等信息,并且使用 InputLayer 作为RTP包的载体
func NewInputPacket ¶
func NewInputPacket(layer *InputLayer, pool pool.Pool[*InputPacket]) *InputPacket
func ProvideInputPacket ¶
func ProvideInputPacket(p pool.Pool[*InputPacket]) *InputPacket
func (*InputPacket) AddRef ¶
func (p *InputPacket) AddRef()
func (*InputPacket) AddRelation ¶
func (p *InputPacket) AddRelation(relation pool.Reference)
func (*InputPacket) Addr ¶
func (p *InputPacket) Addr() net.Addr
func (*InputPacket) Clear ¶
func (p *InputPacket) Clear()
func (*InputPacket) Release ¶
func (p *InputPacket) Release() bool
func (*InputPacket) SetAddr ¶
func (p *InputPacket) SetAddr(addr net.Addr)
func (*InputPacket) SetTime ¶
func (p *InputPacket) SetTime(t time.Time)
func (*InputPacket) Time ¶
func (p *InputPacket) Time() time.Time
func (*InputPacket) Use ¶
func (p *InputPacket) Use() *InputPacket
type Layer ¶
type Layer interface { Header Payload() Payload PaddingLength() uint8 SetPaddingLength(length uint8) Size() int Bytes() []byte fmt.Stringer }
Layer 接口为RTP报文的结构化接口,通过此接口可以获取或修改RTP报文的结构
func ProvideInputLayer ¶
func ProvideInputLayer() Layer
type OutputLayer ¶
type OutputLayer struct { DefaultHeader // contains filtered or unexported fields }
func NewOutputLayer ¶
func NewOutputLayer(payload Payload) *OutputLayer
func (*OutputLayer) Bytes ¶
func (l *OutputLayer) Bytes() []byte
func (*OutputLayer) Clear ¶
func (l *OutputLayer) Clear()
func (*OutputLayer) Init ¶
func (l *OutputLayer) Init(payload Payload)
func (*OutputLayer) PaddingLength ¶
func (l *OutputLayer) PaddingLength() uint8
func (*OutputLayer) Payload ¶
func (l *OutputLayer) Payload() Payload
func (*OutputLayer) SetPaddingLength ¶
func (l *OutputLayer) SetPaddingLength(length uint8)
func (*OutputLayer) SetPayload ¶
func (l *OutputLayer) SetPayload(payload Payload)
func (*OutputLayer) Size ¶
func (l *OutputLayer) Size() int
func (*OutputLayer) String ¶
func (l *OutputLayer) String() string
type OutputPacket ¶
type OutputPacket struct { OutputLayer // contains filtered or unexported fields }
func NewOutputPacket ¶
func NewOutputPacket(pool pool.Pool[*OutputPacket], payload Payload) *OutputPacket
func (*OutputPacket) AddRef ¶
func (p *OutputPacket) AddRef()
func (*OutputPacket) AddRelation ¶
func (p *OutputPacket) AddRelation(relation pool.Reference)
func (*OutputPacket) Clear ¶
func (p *OutputPacket) Clear()
func (*OutputPacket) Release ¶
func (p *OutputPacket) Release() bool
func (*OutputPacket) Use ¶
func (p *OutputPacket) Use() *OutputPacket
type Packet ¶
type Packet interface { Layer pool.RelationsReference }
Packet 接口在 Layer 接口的基础上定义了关联引用计数的相关行为
type Parser ¶
type Parser struct { Layer *InputLayer Length uint16 // contains filtered or unexported fields }
type Payload ¶
func ProvideIncomingPayload ¶
func ProvideIncomingPayload() Payload
type SliceCSRCs ¶
type SliceCSRCs []uint32
func (*SliceCSRCs) Append ¶
func (cs *SliceCSRCs) Append(csrcs ...uint32)
func (*SliceCSRCs) Clear ¶
func (cs *SliceCSRCs) Clear()
func (*SliceCSRCs) Get ¶
func (cs *SliceCSRCs) Get(i int) uint32
func (*SliceCSRCs) Len ¶
func (cs *SliceCSRCs) Len() int
func (*SliceCSRCs) Replace ¶
func (cs *SliceCSRCs) Replace(csrcs ...uint32)
func (*SliceCSRCs) Set ¶
func (cs *SliceCSRCs) Set(i int, csrc uint32)
func (*SliceCSRCs) Size ¶
func (cs *SliceCSRCs) Size() int
type Stream ¶
type Stream interface { Handler() Handler SetHandler(handler Handler) Stream SSRC() int64 SetSSRC(ssrc int64) Stream LocalAddr() net.Addr RemoteAddr() net.Addr SetRemoteAddr(addr net.Addr) Stream Timeout() time.Duration SetTimeout(timeout time.Duration) Stream GetOnTimeout() func(Stream) SetOnTimeout(onTimeout func(Stream)) Stream OnLossPacket() func(stream Stream, loss int) SetOnLossPacket(onLossPacket func(stream Stream, loss int)) Stream CloseConn() bool SetCloseConn(enable bool) Stream Send(layer rtp.Layer) error Close() log.LoggerProvider }
Click to show internal directories.
Click to hide internal directories.