Versions in this module Expand all Collapse all v1 v1.0.1 Jul 20, 2023 Changes in this version + var BufferAllocError = errors.New("RTP缓冲区申请失败") + var FrequentParseError = errors.New("RTP解析错误太频繁") + var TooManyParseError = errors.New("RTP连续解析错误太多") + func WithChannelOptions(options ...option.AnyOption) option.AnyOption + func WithCloseOnStreamClosed(enable bool) option.AnyOption + func WithLogger(logger *log.Logger) option.AnyOption + func WithOnAccept(onAccept func(s *TCPServer, conn *net.TCPConn) []option.AnyOption) option.AnyOption + func WithOnChannelCreated(onChannelCreated func(s *TCPServer, channel *TCPChannel)) option.AnyOption + func WithOnChannelError(onError func(c *TCPChannel, err error)) option.AnyOption + func WithOnChannelTimeout(onTimeout func(*TCPChannel)) option.AnyOption + func WithOnError(onError func(s Server, err error)) option.AnyOption + func WithOnLossPacket(onLossPacket func(stream Stream, loss int)) option.AnyOption + func WithOnStreamTimeout(onTimeout func(Stream)) option.AnyOption + func WithPacketPoolProvider(provider pool.PoolProvider[*rtp.IncomingPacket]) option.AnyOption + func WithReadBufferPool(bufferPool pool.BufferPool) option.AnyOption + func WithReadBufferPoolProvider(provider func() pool.BufferPool) option.AnyOption + func WithStreamCloseConn(closeConn bool) option.AnyOption + func WithTimeout(timeout time.Duration) option.AnyOption + func WithWriteBufferPool(bufferPool pool.DataPool) option.AnyOption + func WithWriteBufferPoolProvider(provider func() pool.DataPool) option.AnyOption + type Err struct + Err error + func (e *Err) Error() string + type Handler interface + HandlePacket func(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) + OnParseError func(stream Stream, err error) (keep bool) + OnStreamClosed func(stream Stream) + func DefaultKeepChooserHandler(handler Handler, secMaxErr int, maxSerializedErr int) Handler + func KeepChooserHandler(handler Handler, chooser KeepChooser) Handler + type HandlerFunc struct + HandlePacketFn func(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) + OnParseErrorFn func(stream Stream, err error) (keep bool) + OnStreamClosedFn func(stream Stream) + func (h HandlerFunc) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) + func (h HandlerFunc) OnParseError(stream Stream, err error) (keep bool) + func (h HandlerFunc) OnStreamClosed(stream Stream) + type KeepChooser interface + OnError func(err error) (keep bool) + OnSuccess func() + Reset func() + func NewDefaultKeepChooser(secMaxErr int, maxSerializedErr int, onError func(err error) bool) KeepChooser + type Manager struct + func NewManager(addr *net.IPAddr, serverProvider ServerProvider, options ...ManagerOption) *Manager + func (m *Manager) Addr() *net.IPAddr + func (m *Manager) Alloc() Server + func (m *Manager) Free(s Server) + type ManagerOption option.CustomOption[*Manager] + func WithAllocMaxRetry(maxRetry int) ManagerOption + func WithPort(rtp uint16, rtcp uint16) ManagerOption + func WithPortRange(start uint16, end uint16, excludes ...uint16) ManagerOption + func WithServerMaxUsed(maxUsed uint) ManagerOption + func WithServerOptions(options ...option.AnyOption) ManagerOption + func WithServerRestartInterval(interval time.Duration) ManagerOption + type Port struct + RTCP uint16 + RTP uint16 + type Ports []Port + type Server interface + Addr func() net.Addr + RemoveStream func(stream Stream) + Stream func(remoteAddr net.Addr, ssrc int64, handler Handler, options ...option.AnyOption) (Stream, error) + type ServerProvider func(m *Manager, port uint16, options ...option.AnyOption) Server + func UDPServerProvider(options ...option.AnyOption) ServerProvider + type SetKeepaliveError struct + Keepalive bool + type SetKeepalivePeriodError struct + KeepalivePeriod time.Duration + type SetNoDelayError struct + NoDelay bool + type SetReadBufferError struct + ReadBuffer int + type SetWriteBufferError struct + WriteBuffer int + type Stream interface + Close func() + CloseConn func() bool + GetOnTimeout func() func(Stream) + Handler func() Handler + LocalAddr func() net.Addr + OnLossPacket func() func(stream Stream, loss int) + RemoteAddr func() net.Addr + SSRC func() int64 + Send func(layer rtp.Layer) error + SetCloseConn func(enable bool) Stream + SetHandler func(handler Handler) Stream + SetOnLossPacket func(onLossPacket func(stream Stream, loss int)) Stream + SetOnTimeout func(onTimeout func(Stream)) Stream + SetRemoteAddr func(addr net.Addr) Stream + SetSSRC func(ssrc int64) Stream + SetTimeout func(timeout time.Duration) Stream + Timeout func() time.Duration + type TCPAcceptError struct + type TCPChannel struct + func (c *TCPChannel) CloseOnStreamClosed() bool + func (c *TCPChannel) Conn() *net.TCPConn + func (c *TCPChannel) GetOnError() func(s *TCPChannel, err error) + func (c *TCPChannel) GetOnTimeout() func(*TCPChannel) + func (c *TCPChannel) LocalAddr() *net.TCPAddr + func (c *TCPChannel) RemoteAddr() *net.TCPAddr + func (c *TCPChannel) Send(layer rtp.Layer) error + func (c *TCPChannel) SetCloseOnStreamClosed(enable bool) *TCPChannel + func (c *TCPChannel) SetOnError(onError func(s *TCPChannel, err error)) *TCPChannel + func (c *TCPChannel) SetOnTimeout(onTimeout func(*TCPChannel)) *TCPChannel + func (c *TCPChannel) SetTimeout(timeout time.Duration) *TCPChannel + func (c *TCPChannel) Timeout() time.Duration + type TCPChannelCloseError struct + type TCPCloseError struct + Listener *net.TCPListener + type TCPListenError struct + Addr *net.TCPAddr + type TCPReadError struct + type TCPReadTimeout struct + type TCPServer struct + func NewTCPServer(addr *net.TCPAddr, options ...option.AnyOption) *TCPServer + func NewTCPServerWithListener(listener *net.TCPListener, options ...option.AnyOption) *TCPServer + func (s *TCPServer) Addr() net.Addr + func (s *TCPServer) GetOnAccept() func(s *TCPServer, conn *net.TCPConn) []option.AnyOption + func (s *TCPServer) GetOnChannelCreated() func(s *TCPServer, channel *TCPChannel) + func (s *TCPServer) GetOnError() func(s Server, err error) + func (s *TCPServer) Listener() *net.TCPListener + func (s *TCPServer) RemoveStream(stream Stream) + func (s *TCPServer) SetOnAccept(onAccept func(s *TCPServer, conn *net.TCPConn) []option.AnyOption) *TCPServer + func (s *TCPServer) SetOnChannelCreated(onChannelCreated func(s *TCPServer, channel *TCPChannel)) *TCPServer + func (s *TCPServer) SetOnError(onError func(s Server, err error)) Server + func (s *TCPServer) Stream(remoteAddr net.Addr, ssrc int64, handler Handler, options ...option.AnyOption) (Stream, error) + type TCPStream struct + func (s *TCPStream) Close() + func (s *TCPStream) CloseConn() bool + func (s *TCPStream) GetOnTimeout() func(Stream) + func (s *TCPStream) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) + func (s *TCPStream) Handler() Handler + func (s *TCPStream) LocalAddr() net.Addr + func (s *TCPStream) OnLossPacket() func(stream Stream, loss int) + func (s *TCPStream) OnParseError(stream Stream, err error) (keep bool) + func (s *TCPStream) OnStreamClosed(stream Stream) + func (s *TCPStream) RemoteAddr() net.Addr + func (s *TCPStream) SSRC() int64 + func (s *TCPStream) Send(layer rtp.Layer) error + func (s *TCPStream) SetCloseConn(enable bool) Stream + func (s *TCPStream) SetHandler(handler Handler) Stream + func (s *TCPStream) SetOnLossPacket(onLossPacket func(stream Stream, loss int)) Stream + func (s *TCPStream) SetOnTimeout(onTimeout func(Stream)) Stream + func (s *TCPStream) SetRemoteAddr(addr net.Addr) Stream + func (s *TCPStream) SetSSRC(ssrc int64) Stream + func (s *TCPStream) SetSelf(self Stream) + func (s *TCPStream) SetTimeout(timeout time.Duration) Stream + func (s *TCPStream) Timeout() time.Duration + type TimeoutManager struct + func (m *TimeoutManager) Close() + func (m *TimeoutManager) Deadline() timePkg.Time + func (m *TimeoutManager) Init(f func()) + func (m *TimeoutManager) SetTime(time timePkg.Time) + func (m *TimeoutManager) SetTimeout(timeout timePkg.Duration) + func (m *TimeoutManager) Time() timePkg.Time + func (m *TimeoutManager) Timeout() timePkg.Duration + func (m *TimeoutManager) UpdateTime(time timePkg.Time) + func (m *TimeoutManager) UpdateTimeout(timeout timePkg.Duration) + type UDPCloseError struct + Listener *net.UDPConn + type UDPListenError struct + Addr *net.UDPAddr + type UDPReadError struct + type UDPServer struct + func NewUDPServer(addr *net.UDPAddr, options ...option.AnyOption) *UDPServer + func NewUDPServerWithListener(listener *net.UDPConn, options ...option.AnyOption) *UDPServer + func (s *UDPServer) Addr() net.Addr + func (s *UDPServer) CloseOnStreamClosed() bool + func (s *UDPServer) GetOnError() func(s Server, err error) + func (s *UDPServer) Listener() *net.UDPConn + func (s *UDPServer) RemoveStream(stream Stream) + func (s *UDPServer) SendTo(layer rtp.Layer, addr *net.UDPAddr) error + func (s *UDPServer) SetCloseOnStreamClosed(enable bool) Server + func (s *UDPServer) SetOnError(onError func(s Server, err error)) Server + func (s *UDPServer) Stream(remoteAddr net.Addr, ssrc int64, handler Handler, options ...option.AnyOption) (Stream, error) + type UDPStream struct + func (s *UDPStream) Close() + func (s *UDPStream) CloseConn() bool + func (s *UDPStream) GetOnTimeout() func(Stream) + func (s *UDPStream) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) + func (s *UDPStream) Handler() Handler + func (s *UDPStream) LocalAddr() net.Addr + func (s *UDPStream) OnLossPacket() func(stream Stream, loss int) + func (s *UDPStream) OnParseError(stream Stream, err error) (keep bool) + func (s *UDPStream) OnStreamClosed(stream Stream) + func (s *UDPStream) RemoteAddr() net.Addr + func (s *UDPStream) SSRC() int64 + func (s *UDPStream) Send(layer rtp.Layer) error + func (s *UDPStream) SetCloseConn(enable bool) Stream + func (s *UDPStream) SetHandler(handler Handler) Stream + func (s *UDPStream) SetOnLossPacket(onLossPacket func(stream Stream, loss int)) Stream + func (s *UDPStream) SetOnTimeout(onTimeout func(Stream)) Stream + func (s *UDPStream) SetRemoteAddr(addr net.Addr) Stream + func (s *UDPStream) SetSSRC(ssrc int64) Stream + func (s *UDPStream) SetSelf(self Stream) + func (s *UDPStream) SetTimeout(timeout time.Duration) Stream + func (s *UDPStream) Timeout() time.Duration