servertransport

package
v1.0.2-0...-0a9ac6a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO reduce this.
	ReceiveMTU int = 8192
)

Variables

View Source
var (
	ErrNoData        = errors.Errorf("cannot handle empty buffer")
	ErrUnknownPacket = errors.Errorf("unknown packet")
)

Functions

func MatchRTCP

func MatchRTCP(buf []byte) bool

MatchSRTCP is a MatchFunc that only matches SRTCP and not SRTP

func MatchRTP

func MatchRTP(buf []byte) bool

MatchRTP is a MatchFunc that only matches SRTP and not SRTCP

func MatchRTPOrRTCP

func MatchRTPOrRTCP(b []byte) bool

MatchRTPOrRTCP is a MatchFunc that accepts packets with the first byte in [128..191] as defied in RFC7983

func RandUint32

func RandUint32() uint32

RandUint32 generates a mathmatical random uint32.

Types

type BufferFactory

type BufferFactory func(packetType packetio.BufferPacketType, ssrc uint32) *packetio.Buffer

type DataTransport

type DataTransport struct {
	// contains filtered or unexported fields
}

func NewDataTransport

func NewDataTransport(params DataTransportParams) *DataTransport

func (*DataTransport) Close

func (t *DataTransport) Close() error

func (*DataTransport) MessagesChannel

func (t *DataTransport) MessagesChannel() <-chan webrtc.DataChannelMessage

func (*DataTransport) Send

func (t *DataTransport) Send(message webrtc.DataChannelMessage) <-chan error

func (*DataTransport) SendText

func (t *DataTransport) SendText(message string) error

type DataTransportParams

type DataTransportParams struct {
	Log  logger.Logger
	Conn io.ReadWriteCloser
}

type MatchFunc

type MatchFunc func([]byte) bool

MatchFunc allows custom logic for mapping packets to an Endpoint

func MatchRange

func MatchRange(lower byte, upper byte) MatchFunc

MatchRange is a MatchFunc that accepts packets with the first byte in [lower..upper]

type MediaStream

type MediaStream struct {
	// contains filtered or unexported fields
}

func NewMediaStream

func NewMediaStream(params MediaStreamParams) *MediaStream

func (*MediaStream) Close

func (t *MediaStream) Close() error

func (*MediaStream) GetOrCreateBuffer

func (t *MediaStream) GetOrCreateBuffer(
	packetType packetio.BufferPacketType, ssrc webrtc.SSRC,
) *packetio.Buffer

func (*MediaStream) RemoveBuffer

func (t *MediaStream) RemoveBuffer(
	packetType packetio.BufferPacketType, ssrc webrtc.SSRC,
)

func (*MediaStream) WriteRTCP

func (t *MediaStream) WriteRTCP(p []rtcp.Packet) error

func (*MediaStream) Writer

func (t *MediaStream) Writer() io.Writer

type MediaStreamParams

type MediaStreamParams struct {
	Log  logger.Logger
	Conn io.ReadWriteCloser

	// BufferFactory is optional.
	BufferFactory BufferFactory
	// Interceptor is optional.
	Interceptor interceptor.Interceptor
}

type MetadataTransport

type MetadataTransport struct {
	// contains filtered or unexported fields
}

func NewMetadataTransport

func NewMetadataTransport(params MetadataTransportParams) *MetadataTransport

func (*MetadataTransport) AddTrack

func (*MetadataTransport) Close

func (t *MetadataTransport) Close() error

func (*MetadataTransport) LocalTracks

func (t *MetadataTransport) LocalTracks() []transport.TrackWithMID

func (*MetadataTransport) RemoteTracksChannel

func (t *MetadataTransport) RemoteTracksChannel() <-chan transport.TrackRemoteWithRTCPReader

func (*MetadataTransport) RemoveTrack

func (t *MetadataTransport) RemoveTrack(trackID identifiers.TrackID) error

type MetadataTransportParams

type MetadataTransportParams struct {
	Log           logger.Logger
	Conn          io.ReadWriteCloser
	MediaStream   *MediaStream
	ClientID      identifiers.ClientID
	Interceptor   interceptor.Interceptor
	CodecRegistry *codecs.Registry
}

type Params

type Params struct {
	Log                 logger.Logger
	MediaConn           io.ReadWriteCloser
	DataConn            io.ReadWriteCloser
	MetadataConn        io.ReadWriteCloser
	CodecRegistry       *codecs.Registry
	InterceptorRegistry *interceptor.Registry
}

type ServerTrack

type ServerTrack struct {
	transport.SimpleTrack
	// contains filtered or unexported fields
}

func (*ServerTrack) Sub

func (s *ServerTrack) Sub() error

func (*ServerTrack) Unsub

func (s *ServerTrack) Unsub() error

type Transport

type Transport struct {
	*MetadataTransport
	*MediaStream
	*DataTransport
	// contains filtered or unexported fields
}

Transport is used for server to server communication. The underlying transport protocol is SCTP, and the following data is transferred:

  1. Ordered Metadata stream on ID 0. This stream will contain track, as well as application level metadata.
  2. Unordered Media (RTP and RTCP) streams will use odd numbered stream IDs, starting from 1.
  3. Ordered DataChannel messages on even stream IDs, starting from 2.

A single Media stream transports all RTP and RTCP packets for a single room, and a single DataChannel stream will transport all datachannel messages for a single room.

A single SCTP connection can be used to transport packets from multiple rooms. Each room will take exactly one Media stream and one DataChannel stream. Following the rules above, the stream IDs for a specific room will always be N and N+1, but the metadata for all rooms will be sent on stream 0.

Track metadata is JSON encoded.

TODO subject to change

func New

func New(params Params) *Transport

func (*Transport) ClientID

func (t *Transport) ClientID() identifiers.ClientID

func (*Transport) Close

func (t *Transport) Close() (err error)

func (*Transport) Done

func (t *Transport) Done() <-chan struct{}

func (*Transport) Type

func (t *Transport) Type() transport.Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL