Documentation
¶
Index ¶
- Variables
- 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
- type Handler
- type HandlerFunc
- type KeepChooser
- type Manager
- type ManagerOption
- 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
- type Ports
- type Server
- type ServerProvider
- type SetKeepaliveError
- type SetKeepalivePeriodError
- type SetNoDelayError
- type SetReadBufferError
- type SetWriteBufferError
- type Stream
- type TCPAcceptError
- type TCPChannel
- 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
- type TCPCloseError
- type TCPListenError
- type TCPReadError
- type TCPReadTimeout
- type 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
- 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
- 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
- type UDPListenError
- type UDPReadError
- type 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
- 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
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func WithCloseOnStreamClosed ¶
func WithOnAccept ¶
func WithOnChannelCreated ¶
func WithOnChannelCreated(onChannelCreated func(s *TCPServer, channel *TCPChannel)) option.AnyOption
func WithOnChannelError ¶
func WithOnChannelError(onError func(c *TCPChannel, err error)) option.AnyOption
func WithOnChannelTimeout ¶
func WithOnChannelTimeout(onTimeout func(*TCPChannel)) option.AnyOption
func WithOnLossPacket ¶
func WithOnStreamTimeout ¶
func WithPacketPoolProvider ¶
func WithPacketPoolProvider(provider pool.PoolProvider[*rtp.IncomingPacket]) option.AnyOption
func WithReadBufferPool ¶
func WithReadBufferPool(bufferPool pool.BufferPool) option.AnyOption
func WithReadBufferPoolProvider ¶
func WithReadBufferPoolProvider(provider func() pool.BufferPool) option.AnyOption
func WithStreamCloseConn ¶
Types ¶
type Handler ¶
type Handler interface { HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool) OnParseError(stream Stream, err error) (keep bool) OnStreamClosed(stream Stream) }
func KeepChooserHandler ¶
func KeepChooserHandler(handler Handler, chooser KeepChooser) Handler
type HandlerFunc ¶
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 (HandlerFunc) HandlePacket ¶
func (h HandlerFunc) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool)
func (HandlerFunc) OnParseError ¶
func (h HandlerFunc) OnParseError(stream Stream, err error) (keep bool)
func (HandlerFunc) OnStreamClosed ¶
func (h HandlerFunc) OnStreamClosed(stream Stream)
type KeepChooser ¶
func NewDefaultKeepChooser ¶
func NewDefaultKeepChooser(secMaxErr int, maxSerializedErr int, onError func(err error) bool) KeepChooser
type Manager ¶
type Manager struct { lifecycle.Lifecycle log.AtomicLogger // contains filtered or unexported fields }
func NewManager ¶
func NewManager(addr *net.IPAddr, serverProvider ServerProvider, options ...ManagerOption) *Manager
type ManagerOption ¶
type ManagerOption option.CustomOption[*Manager]
An ManagerOption configures a MultiStreamManager.
func WithAllocMaxRetry ¶
func WithAllocMaxRetry(maxRetry int) ManagerOption
func WithPort ¶
func WithPort(rtp uint16, rtcp uint16) ManagerOption
func WithPortRange ¶
func WithPortRange(start uint16, end uint16, excludes ...uint16) ManagerOption
func WithServerMaxUsed ¶
func WithServerMaxUsed(maxUsed uint) ManagerOption
func WithServerOptions ¶
func WithServerOptions(options ...option.AnyOption) ManagerOption
func WithServerRestartInterval ¶
func WithServerRestartInterval(interval time.Duration) ManagerOption
type ServerProvider ¶
func UDPServerProvider ¶
func UDPServerProvider(options ...option.AnyOption) ServerProvider
type SetKeepaliveError ¶
type SetKeepalivePeriodError ¶
type SetNoDelayError ¶
type SetReadBufferError ¶
type SetWriteBufferError ¶
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 }
type TCPAcceptError ¶
type TCPAcceptError struct {
Err
}
type TCPChannel ¶
type TCPChannel struct { lifecycle.Lifecycle log.AtomicLogger // contains filtered or unexported fields }
func (*TCPChannel) CloseOnStreamClosed ¶
func (c *TCPChannel) CloseOnStreamClosed() bool
func (*TCPChannel) Conn ¶
func (c *TCPChannel) Conn() *net.TCPConn
func (*TCPChannel) GetOnError ¶
func (c *TCPChannel) GetOnError() func(s *TCPChannel, err error)
func (*TCPChannel) GetOnTimeout ¶
func (c *TCPChannel) GetOnTimeout() func(*TCPChannel)
func (*TCPChannel) LocalAddr ¶
func (c *TCPChannel) LocalAddr() *net.TCPAddr
func (*TCPChannel) RemoteAddr ¶
func (c *TCPChannel) RemoteAddr() *net.TCPAddr
func (*TCPChannel) SetCloseOnStreamClosed ¶
func (c *TCPChannel) SetCloseOnStreamClosed(enable bool) *TCPChannel
func (*TCPChannel) SetOnError ¶
func (c *TCPChannel) SetOnError(onError func(s *TCPChannel, err error)) *TCPChannel
func (*TCPChannel) SetOnTimeout ¶
func (c *TCPChannel) SetOnTimeout(onTimeout func(*TCPChannel)) *TCPChannel
func (*TCPChannel) SetTimeout ¶
func (c *TCPChannel) SetTimeout(timeout time.Duration) *TCPChannel
func (*TCPChannel) Timeout ¶
func (c *TCPChannel) Timeout() time.Duration
type TCPChannelCloseError ¶
type TCPChannelCloseError struct {
Err
}
type TCPCloseError ¶
type TCPCloseError struct { Err Listener *net.TCPListener }
type TCPListenError ¶
type TCPReadError ¶
type TCPReadError struct {
Err
}
type TCPReadTimeout ¶
type TCPReadTimeout struct {
Err
}
type TCPServer ¶
type TCPServer struct { lifecycle.Lifecycle log.AtomicLogger // contains filtered or unexported fields }
func NewTCPServerWithListener ¶
func NewTCPServerWithListener(listener *net.TCPListener, options ...option.AnyOption) *TCPServer
func (*TCPServer) GetOnAccept ¶
func (*TCPServer) GetOnChannelCreated ¶
func (s *TCPServer) GetOnChannelCreated() func(s *TCPServer, channel *TCPChannel)
func (*TCPServer) GetOnError ¶
func (*TCPServer) Listener ¶
func (s *TCPServer) Listener() *net.TCPListener
func (*TCPServer) RemoveStream ¶
RemoveStream 从TCP服务或其管理的TCP通道中移除流
func (*TCPServer) SetOnAccept ¶
func (*TCPServer) SetOnChannelCreated ¶
func (s *TCPServer) SetOnChannelCreated(onChannelCreated func(s *TCPServer, channel *TCPChannel)) *TCPServer
func (*TCPServer) SetOnError ¶
type TCPStream ¶
type TCPStream struct {
// contains filtered or unexported fields
}
func (*TCPStream) GetOnTimeout ¶
func (s *TCPStream) GetOnTimeout() func(Stream)
func (*TCPStream) HandlePacket ¶
func (s *TCPStream) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool)
func (*TCPStream) OnLossPacket ¶
func (*TCPStream) OnParseError ¶
func (*TCPStream) OnStreamClosed ¶
func (s *TCPStream) OnStreamClosed(stream Stream)
func (*TCPStream) RemoteAddr ¶
func (*TCPStream) SetCloseConn ¶
func (*TCPStream) SetHandler ¶
func (*TCPStream) SetOnLossPacket ¶
func (*TCPStream) SetOnTimeout ¶
func (*TCPStream) SetRemoteAddr ¶
func (*TCPStream) SetTimeout ¶
type TimeoutManager ¶
type TimeoutManager struct {
// contains filtered or unexported fields
}
TimeoutManager 超时时间管理器
func (*TimeoutManager) Close ¶
func (m *TimeoutManager) Close()
func (*TimeoutManager) Deadline ¶
func (m *TimeoutManager) Deadline() timePkg.Time
Deadline 获取基于设置时间的超时期限,如果超时时间为0(永不超时),则返回时间的零值
func (*TimeoutManager) SetTime ¶
func (m *TimeoutManager) SetTime(time timePkg.Time)
SetTime 更新当前时间,更新后调用Deadline方法可获取基于更新时间的超时期限,此方法不更新计时器的状态, 一般用于网络IO的超时管理
func (*TimeoutManager) SetTimeout ¶
func (m *TimeoutManager) SetTimeout(timeout timePkg.Duration)
SetTimeout 设置超时时间(设置为0永不超时),设置后调用Deadline方法可获取基于此超时时间的超时期限,此 方法不更新计时器的状态,一般用于网络IO的超时管理
func (*TimeoutManager) Timeout ¶
func (m *TimeoutManager) Timeout() timePkg.Duration
Timeout 获取当前设置的超时时间
func (*TimeoutManager) UpdateTime ¶
func (m *TimeoutManager) UpdateTime(time timePkg.Time)
UpdateTime 与 SetTime 类似,但如果计时器在工作,则会重置计时器的超时时间
func (*TimeoutManager) UpdateTimeout ¶
func (m *TimeoutManager) UpdateTimeout(timeout timePkg.Duration)
UpdateTimeout 与 SetTimeout 方法类似,但如果计时器在工作,则会更新计时器状态。如果需要更新计时器状 态,那么当设置为0时,关闭计时器;否则重置计时器的超时时间
type UDPCloseError ¶
type UDPListenError ¶
type UDPReadError ¶
type UDPReadError struct {
Err
}
type UDPServer ¶
type UDPServer struct { lifecycle.Lifecycle log.AtomicLogger // contains filtered or unexported fields }
func (*UDPServer) CloseOnStreamClosed ¶
func (*UDPServer) GetOnError ¶
func (*UDPServer) RemoveStream ¶
func (*UDPServer) SetCloseOnStreamClosed ¶
func (*UDPServer) SetOnError ¶
type UDPStream ¶
type UDPStream struct {
// contains filtered or unexported fields
}
func (*UDPStream) GetOnTimeout ¶
func (s *UDPStream) GetOnTimeout() func(Stream)
func (*UDPStream) HandlePacket ¶
func (s *UDPStream) HandlePacket(stream Stream, packet *rtp.IncomingPacket) (dropped, keep bool)
func (*UDPStream) OnLossPacket ¶
func (*UDPStream) OnParseError ¶
func (*UDPStream) OnStreamClosed ¶
func (s *UDPStream) OnStreamClosed(stream Stream)
func (*UDPStream) RemoteAddr ¶
func (*UDPStream) SetCloseConn ¶
func (*UDPStream) SetHandler ¶
func (*UDPStream) SetOnLossPacket ¶
func (*UDPStream) SetOnTimeout ¶
func (*UDPStream) SetRemoteAddr ¶
func (*UDPStream) SetTimeout ¶
Click to show internal directories.
Click to hide internal directories.