gortsplib

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 40 Imported by: 21

README

gortsplib

Test Lint Go Report Card CodeCov PkgGoDev

RTSP 1.0 client and server library for the Go programming language, written for rtsp-simple-server.

Go ≥ 1.17 is required.

Features:

  • Client
    • Query servers about available streams and tracks
    • Read
      • Read streams from servers with the UDP, UDP-multicast or TCP transport protocol
      • Read TLS-encrypted streams (TCP only)
      • Switch transport protocol automatically
      • Read only selected tracks of a stream
      • Pause or seek without disconnecting from the server
      • Generate RTCP receiver reports (UDP only)
      • Reorder incoming RTP packets (UDP only)
    • Publish
      • Publish streams to servers with the UDP or TCP transport protocol
      • Publish TLS-encrypted streams (TCP only)
      • Switch transport protocol automatically
      • Pause without disconnecting from the server
      • Generate RTCP sender reports
  • Server
    • Handle requests from clients
    • Sessions and connections are independent
    • Publish
      • Read streams from clients with the UDP or TCP transport protocol
      • Read TLS-encrypted streams (TCP only)
      • Generate RTCP receiver reports (UDP only)
      • Reorder incoming RTP packets (UDP only)
    • Read
      • Write streams to clients with the UDP, UDP-multicast or TCP transport protocol
      • Write TLS-encrypted streams
      • Compute and provide SSRC, RTP-Info to clients
      • Generate RTCP sender reports
  • Utilities
    • Encode and decode codec-specific frames into/from RTP packets. The following codecs are supported:
      • Video
        • H264
        • H265
        • VP8
        • VP9
      • Audio
        • G711
        • G722
        • LPCM
        • MPEG4-audio (AAC)
        • Opus
    • Parse RTSP elements: requests, responses, SDP
    • Parse H264 elements and formats: Annex-B, AVCC, anti-competition, DTS
    • Parse MPEG4-audio (AAC) element and formats: ADTS, MPEG4-audio configurations

Table of contents

Examples

API Documentation

https://pkg.go.dev/github.com/aler9/gortsplib#pkg-index

Related projects

Standards

Documentation

Overview

Package gortsplib is a RTSP 1.0 library for the Go programming language, written for rtsp-simple-server.

Examples are available at https://github.com/aler9/gortsplib/tree/master/examples

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	//
	// RTSP parameters (all optional)
	//
	// timeout of read operations.
	// It defaults to 10 seconds.
	ReadTimeout time.Duration
	// timeout of write operations.
	// It defaults to 10 seconds.
	WriteTimeout time.Duration
	// a TLS configuration to connect to TLS (RTSPS) servers.
	// It defaults to nil.
	TLSConfig *tls.Config
	// disable being redirected to other servers, that can happen during Describe().
	// It defaults to false.
	RedirectDisable bool
	// enable communication with servers which don't provide server ports or use
	// different server ports than the ones announced.
	// This can be a security issue.
	// It defaults to false.
	AnyPortEnable bool
	// the stream transport (UDP, Multicast or TCP).
	// If nil, it is chosen automatically (first UDP, then, if it fails, TCP).
	// It defaults to nil.
	Transport *Transport
	// If the client is reading with UDP, it must receive
	// at least a packet within this timeout.
	// It defaults to 3 seconds.
	InitialUDPReadTimeout time.Duration
	// read buffer count.
	// If greater than 1, allows to pass buffers to routines different than the one
	// that is reading frames.
	// It defaults to 256.
	ReadBufferCount int
	// write buffer count.
	// It allows to queue packets before sending them.
	// It defaults to 256.
	WriteBufferCount int
	// user agent header
	// It defaults to "gortsplib"
	UserAgent string
	// disable automatic RTCP sender reports.
	DisableRTCPSenderReports bool
	// pointer to a variable that stores received bytes.
	BytesReceived *uint64
	// pointer to a variable that stores sent bytes.
	BytesSent *uint64

	//
	// system functions (all optional)
	//
	// function used to initialize the TCP client.
	// It defaults to (&net.Dialer{}).DialContext.
	DialContext func(ctx context.Context, network, address string) (net.Conn, error)
	// function used to initialize UDP listeners.
	// It defaults to net.ListenPacket.
	ListenPacket func(network, address string) (net.PacketConn, error)

	//
	// callbacks (all optional)
	//
	// called before every request.
	OnRequest func(*base.Request)
	// called after every response.
	OnResponse func(*base.Response)
	// called when receiving a RTP packet.
	OnPacketRTP func(*ClientOnPacketRTPCtx)
	// called when receiving a RTCP packet.
	OnPacketRTCP func(*ClientOnPacketRTCPCtx)
	// called when there's a non-fatal decoding error of RTP or RTCP packets.
	OnDecodeError func(error)
	// contains filtered or unexported fields
}

Client is a RTSP client.

func (*Client) Announce

func (c *Client) Announce(u *url.URL, tracks Tracks) (*base.Response, error)

Announce writes an ANNOUNCE request and reads a Response.

func (*Client) Close

func (c *Client) Close() error

Close closes all client resources and waits for them to close.

func (*Client) Describe

func (c *Client) Describe(u *url.URL) (Tracks, *url.URL, *base.Response, error)

Describe writes a DESCRIBE request and reads a Response.

func (*Client) Options

func (c *Client) Options(u *url.URL) (*base.Response, error)

Options writes an OPTIONS request and reads a response.

func (*Client) Pause

func (c *Client) Pause() (*base.Response, error)

Pause writes a PAUSE request and reads a Response. This can be called only after Play() or Record().

func (*Client) Play

func (c *Client) Play(ra *headers.Range) (*base.Response, error)

Play writes a PLAY request and reads a Response. This can be called only after Setup().

func (*Client) Record

func (c *Client) Record() (*base.Response, error)

Record writes a RECORD request and reads a Response. This can be called only after Announce() and Setup().

func (*Client) Seek

func (c *Client) Seek(ra *headers.Range) (*base.Response, error)

Seek asks the server to re-start the stream from a specific timestamp.

func (*Client) Setup

func (c *Client) Setup(
	track Track,
	baseURL *url.URL,
	rtpPort int,
	rtcpPort int,
) (*base.Response, error)

Setup writes a SETUP request and reads a Response. rtpPort and rtcpPort are used only if transport is UDP. if rtpPort and rtcpPort are zero, they are chosen automatically.

func (*Client) SetupAll

func (c *Client) SetupAll(tracks Tracks, baseURL *url.URL) error

SetupAll setups all the given tracks.

func (*Client) SetupAndPlay

func (c *Client) SetupAndPlay(tracks Tracks, baseURL *url.URL) error

SetupAndPlay setups and play the given tracks.

func (*Client) Start

func (c *Client) Start(scheme string, host string) error

Start initializes the connection to a server.

func (*Client) StartPublishing

func (c *Client) StartPublishing(address string, tracks Tracks) error

StartPublishing connects to the address and starts publishing the tracks.

func (*Client) Tracks

func (c *Client) Tracks() Tracks

Tracks returns all the tracks that the client is reading or publishing.

func (*Client) Wait

func (c *Client) Wait() error

Wait waits until all client resources are closed. This can happen when a fatal error occurs or when Close() is called.

func (*Client) WritePacketRTCP

func (c *Client) WritePacketRTCP(trackID int, pkt rtcp.Packet) error

WritePacketRTCP writes a RTCP packet.

func (*Client) WritePacketRTP

func (c *Client) WritePacketRTP(trackID int, pkt *rtp.Packet) error

WritePacketRTP writes a RTP packet to all the readers of the stream.

func (*Client) WritePacketRTPWithNTP

func (c *Client) WritePacketRTPWithNTP(trackID int, pkt *rtp.Packet, ntp time.Time) error

WritePacketRTPWithNTP writes a RTP packet. ntp is the absolute time of the packet, and is needed to generate RTCP sender reports that allows the receiver to reconstruct the absolute time of the packet.

type ClientOnPacketRTCPCtx

type ClientOnPacketRTCPCtx struct {
	TrackID int
	Packet  rtcp.Packet
}

ClientOnPacketRTCPCtx is the context of a RTCP packet.

type ClientOnPacketRTPCtx

type ClientOnPacketRTPCtx struct {
	TrackID int
	Packet  *rtp.Packet
}

ClientOnPacketRTPCtx is the context of a RTP packet.

type Server

type Server struct {
	//
	// RTSP parameters (all optional except RTSPAddress)
	//
	// the RTSP address of the server, to accept connections and send and receive
	// packets with the TCP transport.
	RTSPAddress string
	// a port to send and receive RTP packets with the UDP transport.
	// If UDPRTPAddress and UDPRTCPAddress are filled, the server can support the UDP transport.
	UDPRTPAddress string
	// a port to send and receive RTCP packets with the UDP transport.
	// If UDPRTPAddress and UDPRTCPAddress are filled, the server can support the UDP transport.
	UDPRTCPAddress string
	// a range of multicast IPs to use with the UDP-multicast transport.
	// If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server
	// can support the UDP-multicast transport.
	MulticastIPRange string
	// a port to send RTP packets with the UDP-multicast transport.
	// If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server
	// can support the UDP-multicast transport.
	MulticastRTPPort int
	// a port to send RTCP packets with the UDP-multicast transport.
	// If MulticastIPRange, MulticastRTPPort, MulticastRTCPPort are filled, the server
	// can support the UDP-multicast transport.
	MulticastRTCPPort int
	// timeout of read operations.
	// It defaults to 10 seconds
	ReadTimeout time.Duration
	// timeout of write operations.
	// It defaults to 10 seconds
	WriteTimeout time.Duration
	// a TLS configuration to accept TLS (RTSPS) connections.
	TLSConfig *tls.Config
	// read buffer count.
	// If greater than 1, allows to pass buffers to routines different than the one
	// that is reading frames.
	// It also allows to buffer routed frames and mitigate network fluctuations
	// that are particularly relevant when using UDP.
	// It defaults to 256.
	ReadBufferCount int
	// write buffer count.
	// It allows to queue packets before sending them.
	// It defaults to 256.
	WriteBufferCount int
	// disable automatic RTCP sender reports.
	DisableRTCPSenderReports bool

	//
	// handler (optional)
	//
	// an handler to handle server events.
	Handler ServerHandler

	//
	// system functions (all optional)
	//
	// function used to initialize the TCP listener.
	// It defaults to net.Listen.
	Listen func(network string, address string) (net.Listener, error)
	// function used to initialize UDP listeners.
	// It defaults to net.ListenPacket.
	ListenPacket func(network, address string) (net.PacketConn, error)
	// contains filtered or unexported fields
}

Server is a RTSP server.

func (*Server) Close

func (s *Server) Close() error

Close closes all the server resources and waits for them to close.

func (*Server) Start

func (s *Server) Start() error

Start starts the server.

func (*Server) StartAndWait

func (s *Server) StartAndWait() error

StartAndWait starts the server and waits until a fatal error.

func (*Server) Wait

func (s *Server) Wait() error

Wait waits until all server resources are closed. This can happen when a fatal error occurs or when Close() is called.

type ServerConn

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

ServerConn is a server-side RTSP connection.

func (*ServerConn) BytesReceived

func (sc *ServerConn) BytesReceived() uint64

BytesReceived returns the number of read bytes.

func (*ServerConn) BytesSent

func (sc *ServerConn) BytesSent() uint64

BytesSent returns the number of written bytes.

func (*ServerConn) Close

func (sc *ServerConn) Close() error

Close closes the ServerConn.

func (*ServerConn) NetConn

func (sc *ServerConn) NetConn() net.Conn

NetConn returns the underlying net.Conn.

func (*ServerConn) SetUserData

func (sc *ServerConn) SetUserData(v interface{})

SetUserData sets some user data associated to the connection.

func (*ServerConn) UserData

func (sc *ServerConn) UserData() interface{}

UserData returns some user data associated to the connection.

type ServerHandler

type ServerHandler interface{}

ServerHandler is the interface implemented by all the server handlers.

type ServerHandlerOnAnnounce

type ServerHandlerOnAnnounce interface {
	// called after receiving an ANNOUNCE request.
	OnAnnounce(*ServerHandlerOnAnnounceCtx) (*base.Response, error)
}

ServerHandlerOnAnnounce can be implemented by a ServerHandler.

type ServerHandlerOnAnnounceCtx

type ServerHandlerOnAnnounceCtx struct {
	Server  *Server
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
	Tracks  Tracks
}

ServerHandlerOnAnnounceCtx is the context of OnAnnounce.

type ServerHandlerOnConnClose

type ServerHandlerOnConnClose interface {
	// called when a connection is closed.
	OnConnClose(*ServerHandlerOnConnCloseCtx)
}

ServerHandlerOnConnClose can be implemented by a ServerHandler.

type ServerHandlerOnConnCloseCtx

type ServerHandlerOnConnCloseCtx struct {
	Conn  *ServerConn
	Error error
}

ServerHandlerOnConnCloseCtx is the context of OnConnClose.

type ServerHandlerOnConnOpen

type ServerHandlerOnConnOpen interface {
	// called when a connection is opened.
	OnConnOpen(*ServerHandlerOnConnOpenCtx)
}

ServerHandlerOnConnOpen can be implemented by a ServerHandler.

type ServerHandlerOnConnOpenCtx

type ServerHandlerOnConnOpenCtx struct {
	Conn *ServerConn
}

ServerHandlerOnConnOpenCtx is the context of OnConnOpen.

type ServerHandlerOnDecodeError

type ServerHandlerOnDecodeError interface {
	// called when there's a non-fatal decoding error of RTP or RTCP packets.
	OnDecodeError(*ServerHandlerOnDecodeErrorCtx)
}

ServerHandlerOnDecodeError can be implemented by a ServerHandler.

type ServerHandlerOnDecodeErrorCtx

type ServerHandlerOnDecodeErrorCtx struct {
	Session *ServerSession
	Error   error
}

ServerHandlerOnDecodeErrorCtx is the context of OnDecodeError.

type ServerHandlerOnDescribe

type ServerHandlerOnDescribe interface {
	// called after receiving a DESCRIBE request.
	OnDescribe(*ServerHandlerOnDescribeCtx) (*base.Response, *ServerStream, error)
}

ServerHandlerOnDescribe can be implemented by a ServerHandler.

type ServerHandlerOnDescribeCtx

type ServerHandlerOnDescribeCtx struct {
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnDescribeCtx is the context of OnDescribe.

type ServerHandlerOnGetParameter

type ServerHandlerOnGetParameter interface {
	// called after receiving a GET_PARAMETER request.
	OnGetParameter(*ServerHandlerOnGetParameterCtx) (*base.Response, error)
}

ServerHandlerOnGetParameter can be implemented by a ServerHandler.

type ServerHandlerOnGetParameterCtx

type ServerHandlerOnGetParameterCtx struct {
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnGetParameterCtx is the context of OnGetParameter.

type ServerHandlerOnPacketRTCP

type ServerHandlerOnPacketRTCP interface {
	// called when receiving a RTCP packet.
	OnPacketRTCP(*ServerHandlerOnPacketRTCPCtx)
}

ServerHandlerOnPacketRTCP can be implemented by a ServerHandler.

type ServerHandlerOnPacketRTCPCtx

type ServerHandlerOnPacketRTCPCtx struct {
	Session *ServerSession
	TrackID int
	Packet  rtcp.Packet
}

ServerHandlerOnPacketRTCPCtx is the context of OnPacketRTCP.

type ServerHandlerOnPacketRTP

type ServerHandlerOnPacketRTP interface {
	// called when receiving a RTP packet.
	OnPacketRTP(*ServerHandlerOnPacketRTPCtx)
}

ServerHandlerOnPacketRTP can be implemented by a ServerHandler.

type ServerHandlerOnPacketRTPCtx

type ServerHandlerOnPacketRTPCtx struct {
	Session *ServerSession
	TrackID int
	Packet  *rtp.Packet
}

ServerHandlerOnPacketRTPCtx is the context of OnPacketRTP.

type ServerHandlerOnPause

type ServerHandlerOnPause interface {
	// called after receiving a PAUSE request.
	OnPause(*ServerHandlerOnPauseCtx) (*base.Response, error)
}

ServerHandlerOnPause can be implemented by a ServerHandler.

type ServerHandlerOnPauseCtx

type ServerHandlerOnPauseCtx struct {
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnPauseCtx is the context of OnPause.

type ServerHandlerOnPlay

type ServerHandlerOnPlay interface {
	// called after receiving a PLAY request.
	OnPlay(*ServerHandlerOnPlayCtx) (*base.Response, error)
}

ServerHandlerOnPlay can be implemented by a ServerHandler.

type ServerHandlerOnPlayCtx

type ServerHandlerOnPlayCtx struct {
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnPlayCtx is the context of OnPlay.

type ServerHandlerOnRecord

type ServerHandlerOnRecord interface {
	// called after receiving a RECORD request.
	OnRecord(*ServerHandlerOnRecordCtx) (*base.Response, error)
}

ServerHandlerOnRecord can be implemented by a ServerHandler.

type ServerHandlerOnRecordCtx

type ServerHandlerOnRecordCtx struct {
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnRecordCtx is the context of OnRecord.

type ServerHandlerOnRequest

type ServerHandlerOnRequest interface {
	// called before every request.
	OnRequest(*ServerConn, *base.Request)
}

ServerHandlerOnRequest can be implemented by a ServerHandler.

type ServerHandlerOnResponse

type ServerHandlerOnResponse interface {
	// called after every response.
	OnResponse(*ServerConn, *base.Response)
}

ServerHandlerOnResponse can be implemented by a ServerHandler.

type ServerHandlerOnSessionClose

type ServerHandlerOnSessionClose interface {
	// called when a session is closed.
	OnSessionClose(*ServerHandlerOnSessionCloseCtx)
}

ServerHandlerOnSessionClose can be implemented by a ServerHandler.

type ServerHandlerOnSessionCloseCtx

type ServerHandlerOnSessionCloseCtx struct {
	Session *ServerSession
	Error   error
}

ServerHandlerOnSessionCloseCtx is the context of ServerHandlerOnSessionClose.

type ServerHandlerOnSessionOpen

type ServerHandlerOnSessionOpen interface {
	// called when a session is opened.
	OnSessionOpen(*ServerHandlerOnSessionOpenCtx)
}

ServerHandlerOnSessionOpen can be implemented by a ServerHandler.

type ServerHandlerOnSessionOpenCtx

type ServerHandlerOnSessionOpenCtx struct {
	Session *ServerSession
	Conn    *ServerConn
}

ServerHandlerOnSessionOpenCtx is the context OnSessionOpen.

type ServerHandlerOnSetParameter

type ServerHandlerOnSetParameter interface {
	// called after receiving a SET_PARAMETER request.
	OnSetParameter(*ServerHandlerOnSetParameterCtx) (*base.Response, error)
}

ServerHandlerOnSetParameter can be implemented by a ServerHandler.

type ServerHandlerOnSetParameterCtx

type ServerHandlerOnSetParameterCtx struct {
	Session *ServerSession
	Conn    *ServerConn
	Request *base.Request
	Path    string
	Query   string
}

ServerHandlerOnSetParameterCtx is the context of OnSetParameter.

type ServerHandlerOnSetup

type ServerHandlerOnSetup interface {
	// called after receiving a SETUP request.
	// must return a Response and a stream.
	// the stream is needed to
	// - add the session the the stream's readers
	// - send the stream SSRC to the session
	OnSetup(*ServerHandlerOnSetupCtx) (*base.Response, *ServerStream, error)
}

ServerHandlerOnSetup can be implemented by a ServerHandler.

type ServerHandlerOnSetupCtx

type ServerHandlerOnSetupCtx struct {
	Server    *Server
	Session   *ServerSession
	Conn      *ServerConn
	Request   *base.Request
	Path      string
	Query     string
	TrackID   int
	Transport Transport
}

ServerHandlerOnSetupCtx is the context of OnSetup.

type ServerSession

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

ServerSession is a server-side RTSP session.

func (*ServerSession) AnnouncedTracks

func (ss *ServerSession) AnnouncedTracks() Tracks

AnnouncedTracks returns the announced tracks.

func (*ServerSession) BytesReceived

func (ss *ServerSession) BytesReceived() uint64

BytesReceived returns the number of read bytes.

func (*ServerSession) BytesSent

func (ss *ServerSession) BytesSent() uint64

BytesSent returns the number of written bytes.

func (*ServerSession) Close

func (ss *ServerSession) Close() error

Close closes the ServerSession.

func (*ServerSession) SetUserData

func (ss *ServerSession) SetUserData(v interface{})

SetUserData sets some user data associated to the session.

func (*ServerSession) SetuppedTracks

func (ss *ServerSession) SetuppedTracks() map[int]*ServerSessionSetuppedTrack

SetuppedTracks returns the setupped tracks.

func (*ServerSession) SetuppedTransport

func (ss *ServerSession) SetuppedTransport() *Transport

SetuppedTransport returns the transport of the setupped tracks.

func (*ServerSession) State

func (ss *ServerSession) State() ServerSessionState

State returns the state of the session.

func (*ServerSession) UserData

func (ss *ServerSession) UserData() interface{}

UserData returns some user data associated to the session.

func (*ServerSession) WritePacketRTCP

func (ss *ServerSession) WritePacketRTCP(trackID int, pkt rtcp.Packet)

WritePacketRTCP writes a RTCP packet to the session.

func (*ServerSession) WritePacketRTP

func (ss *ServerSession) WritePacketRTP(trackID int, pkt *rtp.Packet)

WritePacketRTP writes a RTP packet to the session.

type ServerSessionSetuppedTrack

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

ServerSessionSetuppedTrack is a setupped track of a ServerSession.

type ServerSessionState

type ServerSessionState int

ServerSessionState is a state of a ServerSession.

const (
	ServerSessionStateInitial ServerSessionState = iota
	ServerSessionStatePrePlay
	ServerSessionStatePlay
	ServerSessionStatePreRecord
	ServerSessionStateRecord
)

states.

func (ServerSessionState) String

func (s ServerSessionState) String() string

String implements fmt.Stringer.

type ServerStream

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

ServerStream represents a data stream. This is in charge of - distributing the stream to each reader - allocating multicast listeners - gathering infos about the stream in order to generate SSRC and RTP-Info

func NewServerStream

func NewServerStream(tracks Tracks) *ServerStream

NewServerStream allocates a ServerStream.

func (*ServerStream) Close

func (st *ServerStream) Close() error

Close closes a ServerStream.

func (*ServerStream) Tracks

func (st *ServerStream) Tracks() Tracks

Tracks returns the tracks of the stream.

func (*ServerStream) WritePacketRTCP

func (st *ServerStream) WritePacketRTCP(trackID int, pkt rtcp.Packet)

WritePacketRTCP writes a RTCP packet to all the readers of the stream.

func (*ServerStream) WritePacketRTP

func (st *ServerStream) WritePacketRTP(trackID int, pkt *rtp.Packet)

WritePacketRTP writes a RTP packet to all the readers of the stream.

func (*ServerStream) WritePacketRTPWithNTP

func (st *ServerStream) WritePacketRTPWithNTP(trackID int, pkt *rtp.Packet, ntp time.Time)

WritePacketRTPWithNTP writes a RTP packet to all the readers of the stream. ntp is the absolute time of the packet, and is needed to generate RTCP sender reports that allows the receiver to reconstruct the absolute time of the packet.

type Track

type Track interface {
	// String returns the track codec.
	String() string

	// ClockRate returns the track clock rate.
	ClockRate() int

	// GetControl returns the track control attribute.
	GetControl() string

	// SetControl sets the track control attribute.
	SetControl(string)

	// MediaDescription returns the track media description in SDP format.
	MediaDescription() *psdp.MediaDescription
	// contains filtered or unexported methods
}

Track is a RTSP track.

type TrackG711

type TrackG711 struct {
	// whether to use mu-law. Otherwise, A-law is used.
	MULaw bool
	// contains filtered or unexported fields
}

TrackG711 is a PCMA track.

func (*TrackG711) ClockRate

func (t *TrackG711) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackG711) CreateDecoder

func (t *TrackG711) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackG711) CreateEncoder

func (t *TrackG711) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackG711) GetControl

func (t *TrackG711) GetControl() string

GetControl gets the track control attribute.

func (*TrackG711) MediaDescription

func (t *TrackG711) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackG711) SetControl

func (t *TrackG711) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackG711) String

func (t *TrackG711) String() string

String returns the track codec.

type TrackG722

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

TrackG722 is a G722 track.

func (*TrackG722) ClockRate

func (t *TrackG722) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackG722) CreateDecoder

func (t *TrackG722) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackG722) CreateEncoder

func (t *TrackG722) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackG722) GetControl

func (t *TrackG722) GetControl() string

GetControl gets the track control attribute.

func (*TrackG722) MediaDescription

func (t *TrackG722) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackG722) SetControl

func (t *TrackG722) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackG722) String

func (t *TrackG722) String() string

String returns the track codec.

type TrackGeneric

type TrackGeneric struct {
	Media    string
	Payloads []TrackGenericPayload
	// contains filtered or unexported fields
}

TrackGeneric is a generic track.

func (*TrackGeneric) ClockRate

func (t *TrackGeneric) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackGeneric) GetControl

func (t *TrackGeneric) GetControl() string

GetControl gets the track control attribute.

func (*TrackGeneric) Init

func (t *TrackGeneric) Init() error

Init initializes a TrackGeneric

func (*TrackGeneric) MediaDescription

func (t *TrackGeneric) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackGeneric) SetControl

func (t *TrackGeneric) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackGeneric) String

func (t *TrackGeneric) String() string

String returns the track codec.

type TrackGenericPayload

type TrackGenericPayload struct {
	Type   uint8
	RTPMap string
	FMTP   string
}

TrackGenericPayload is a payload of a TrackGeneric.

type TrackH264

type TrackH264 struct {
	PayloadType       uint8
	SPS               []byte
	PPS               []byte
	PacketizationMode int
	// contains filtered or unexported fields
}

TrackH264 is a H264 track.

func (*TrackH264) ClockRate

func (t *TrackH264) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackH264) CreateDecoder

func (t *TrackH264) CreateDecoder() *rtph264.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackH264) CreateEncoder

func (t *TrackH264) CreateEncoder() *rtph264.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackH264) GetControl

func (t *TrackH264) GetControl() string

GetControl gets the track control attribute.

func (*TrackH264) MediaDescription

func (t *TrackH264) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackH264) SafePPS

func (t *TrackH264) SafePPS() []byte

SafePPS returns the track PPS.

func (*TrackH264) SafeSPS

func (t *TrackH264) SafeSPS() []byte

SafeSPS returns the track SPS.

func (*TrackH264) SafeSetPPS

func (t *TrackH264) SafeSetPPS(v []byte)

SafeSetPPS sets the track PPS.

func (*TrackH264) SafeSetSPS

func (t *TrackH264) SafeSetSPS(v []byte)

SafeSetSPS sets the track SPS.

func (*TrackH264) SetControl

func (t *TrackH264) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackH264) String

func (t *TrackH264) String() string

String returns the track codec.

type TrackH265

type TrackH265 struct {
	PayloadType uint8
	VPS         []byte
	SPS         []byte
	PPS         []byte
	MaxDONDiff  int
	// contains filtered or unexported fields
}

TrackH265 is a H265 track.

func (*TrackH265) ClockRate

func (t *TrackH265) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackH265) CreateDecoder

func (t *TrackH265) CreateDecoder() *rtph265.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackH265) CreateEncoder

func (t *TrackH265) CreateEncoder() *rtph265.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackH265) GetControl

func (t *TrackH265) GetControl() string

GetControl gets the track control attribute.

func (*TrackH265) MediaDescription

func (t *TrackH265) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackH265) SafePPS

func (t *TrackH265) SafePPS() []byte

SafePPS returns the track PPS.

func (*TrackH265) SafeSPS

func (t *TrackH265) SafeSPS() []byte

SafeSPS returns the track SPS.

func (*TrackH265) SafeSetPPS

func (t *TrackH265) SafeSetPPS(v []byte)

SafeSetPPS sets the track PPS.

func (*TrackH265) SafeSetSPS

func (t *TrackH265) SafeSetSPS(v []byte)

SafeSetSPS sets the track SPS.

func (*TrackH265) SafeSetVPS

func (t *TrackH265) SafeSetVPS(v []byte)

SafeSetVPS sets the track VPS.

func (*TrackH265) SafeVPS

func (t *TrackH265) SafeVPS() []byte

SafeVPS returns the track VPS.

func (*TrackH265) SetControl

func (t *TrackH265) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackH265) String

func (t *TrackH265) String() string

String returns the track codec.

type TrackJPEG

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

TrackJPEG is a JPEG track.

func (*TrackJPEG) ClockRate

func (t *TrackJPEG) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackJPEG) GetControl

func (t *TrackJPEG) GetControl() string

GetControl gets the track control attribute.

func (*TrackJPEG) MediaDescription

func (t *TrackJPEG) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackJPEG) SetControl

func (t *TrackJPEG) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackJPEG) String

func (t *TrackJPEG) String() string

String returns the track codec.

type TrackLPCM

type TrackLPCM struct {
	PayloadType  uint8
	BitDepth     int
	SampleRate   int
	ChannelCount int
	// contains filtered or unexported fields
}

TrackLPCM is an uncompressed, Linear PCM track.

func (*TrackLPCM) ClockRate

func (t *TrackLPCM) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackLPCM) CreateDecoder

func (t *TrackLPCM) CreateDecoder() *rtplpcm.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackLPCM) CreateEncoder

func (t *TrackLPCM) CreateEncoder() *rtplpcm.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackLPCM) GetControl

func (t *TrackLPCM) GetControl() string

GetControl gets the track control attribute.

func (*TrackLPCM) MediaDescription

func (t *TrackLPCM) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackLPCM) SetControl

func (t *TrackLPCM) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackLPCM) String

func (t *TrackLPCM) String() string

String returns the track codec.

type TrackMPEG2Audio

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

TrackMPEG2Audio is a MPEG-1 or MPEG-2 audio track.

func (*TrackMPEG2Audio) ClockRate

func (t *TrackMPEG2Audio) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackMPEG2Audio) GetControl

func (t *TrackMPEG2Audio) GetControl() string

GetControl gets the track control attribute.

func (*TrackMPEG2Audio) MediaDescription

func (t *TrackMPEG2Audio) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackMPEG2Audio) SetControl

func (t *TrackMPEG2Audio) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackMPEG2Audio) String

func (t *TrackMPEG2Audio) String() string

String returns the track codec.

type TrackMPEG2Video

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

TrackMPEG2Video is a MPEG-1 or MPEG-2 video track.

func (*TrackMPEG2Video) ClockRate

func (t *TrackMPEG2Video) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackMPEG2Video) GetControl

func (t *TrackMPEG2Video) GetControl() string

GetControl gets the track control attribute.

func (*TrackMPEG2Video) MediaDescription

func (t *TrackMPEG2Video) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackMPEG2Video) SetControl

func (t *TrackMPEG2Video) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackMPEG2Video) String

func (t *TrackMPEG2Video) String() string

String returns the track codec.

type TrackMPEG4Audio

type TrackMPEG4Audio struct {
	PayloadType      uint8
	Config           *mpeg4audio.Config
	SizeLength       int
	IndexLength      int
	IndexDeltaLength int
	// contains filtered or unexported fields
}

TrackMPEG4Audio is a MPEG-4 audio track.

func (*TrackMPEG4Audio) ClockRate

func (t *TrackMPEG4Audio) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackMPEG4Audio) CreateDecoder

func (t *TrackMPEG4Audio) CreateDecoder() *rtpmpeg4audio.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackMPEG4Audio) CreateEncoder

func (t *TrackMPEG4Audio) CreateEncoder() *rtpmpeg4audio.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackMPEG4Audio) GetControl

func (t *TrackMPEG4Audio) GetControl() string

GetControl gets the track control attribute.

func (*TrackMPEG4Audio) MediaDescription

func (t *TrackMPEG4Audio) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackMPEG4Audio) SetControl

func (t *TrackMPEG4Audio) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackMPEG4Audio) String

func (t *TrackMPEG4Audio) String() string

String returns the track codec.

type TrackOpus

type TrackOpus struct {
	PayloadType  uint8
	SampleRate   int
	ChannelCount int
	// contains filtered or unexported fields
}

TrackOpus is a Opus track.

func (*TrackOpus) ClockRate

func (t *TrackOpus) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackOpus) CreateDecoder

func (t *TrackOpus) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackOpus) CreateEncoder

func (t *TrackOpus) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the track.

func (*TrackOpus) GetControl

func (t *TrackOpus) GetControl() string

GetControl gets the track control attribute.

func (*TrackOpus) MediaDescription

func (t *TrackOpus) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackOpus) SetControl

func (t *TrackOpus) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackOpus) String

func (t *TrackOpus) String() string

String returns the track codec.

type TrackVP8

type TrackVP8 struct {
	PayloadType uint8
	MaxFR       *int
	MaxFS       *int
	// contains filtered or unexported fields
}

TrackVP8 is a VP8 track.

func (*TrackVP8) ClockRate

func (t *TrackVP8) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackVP8) CreateDecoder

func (t *TrackVP8) CreateDecoder() *rtpvp8.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackVP8) GetControl

func (t *TrackVP8) GetControl() string

GetControl gets the track control attribute.

func (*TrackVP8) MediaDescription

func (t *TrackVP8) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackVP8) SetControl

func (t *TrackVP8) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackVP8) String

func (t *TrackVP8) String() string

String returns the track codec.

type TrackVP9

type TrackVP9 struct {
	PayloadType uint8
	MaxFR       *int
	MaxFS       *int
	ProfileID   *int
	// contains filtered or unexported fields
}

TrackVP9 is a VP9 track.

func (*TrackVP9) ClockRate

func (t *TrackVP9) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackVP9) CreateDecoder

func (t *TrackVP9) CreateDecoder() *rtpvp9.Decoder

CreateDecoder creates a decoder able to decode the content of the track.

func (*TrackVP9) GetControl

func (t *TrackVP9) GetControl() string

GetControl gets the track control attribute.

func (*TrackVP9) MediaDescription

func (t *TrackVP9) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackVP9) SetControl

func (t *TrackVP9) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackVP9) String

func (t *TrackVP9) String() string

String returns the track codec.

type TrackVorbis

type TrackVorbis struct {
	PayloadType   uint8
	SampleRate    int
	ChannelCount  int
	Configuration []byte
	// contains filtered or unexported fields
}

TrackVorbis is a Vorbis track.

func (*TrackVorbis) ClockRate

func (t *TrackVorbis) ClockRate() int

ClockRate returns the track clock rate.

func (*TrackVorbis) GetControl

func (t *TrackVorbis) GetControl() string

GetControl gets the track control attribute.

func (*TrackVorbis) MediaDescription

func (t *TrackVorbis) MediaDescription() *psdp.MediaDescription

MediaDescription returns the track media description in SDP format.

func (*TrackVorbis) SetControl

func (t *TrackVorbis) SetControl(c string)

SetControl sets the track control attribute.

func (*TrackVorbis) String

func (t *TrackVorbis) String() string

String returns the track codec.

type Tracks

type Tracks []Track

Tracks is a list of tracks.

func (Tracks) Marshal

func (ts Tracks) Marshal(multicast bool) []byte

Marshal encodes tracks in the SDP format.

func (*Tracks) Unmarshal

func (ts *Tracks) Unmarshal(byts []byte) (*sdp.SessionDescription, error)

Unmarshal decodes tracks from the SDP format. It returns the decoded SDP.

type Transport

type Transport int

Transport is a RTSP transport protocol.

const (
	TransportUDP Transport = iota
	TransportUDPMulticast
	TransportTCP
)

transport protocols.

func (Transport) String

func (t Transport) String() string

String implements fmt.Stringer.

Directories

Path Synopsis
examples
pkg
auth
Package auth contains utilities to perform authentication.
Package auth contains utilities to perform authentication.
base
Package base contains the primitives of the RTSP protocol.
Package base contains the primitives of the RTSP protocol.
bits
Package bits contains functions to read/write bits from/to buffers.
Package bits contains functions to read/write bits from/to buffers.
bytecounter
Package bytecounter contains a io.ReadWriter wrapper that allows to count read and written bytes.
Package bytecounter contains a io.ReadWriter wrapper that allows to count read and written bytes.
conn
Package conn contains a RTSP connection implementation.
Package conn contains a RTSP connection implementation.
h264
Package h264 contains utilities to work with the H264 codec.
Package h264 contains utilities to work with the H264 codec.
headers
Package headers contains various RTSP headers.
Package headers contains various RTSP headers.
liberrors
Package liberrors contains errors returned by the library.
Package liberrors contains errors returned by the library.
mpeg4audio
Package mpeg4audio contains utilities to work with MPEG-4 audio codecs.
Package mpeg4audio contains utilities to work with MPEG-4 audio codecs.
multibuffer
Package multibuffer contains a buffer with multiple levels.
Package multibuffer contains a buffer with multiple levels.
ringbuffer
Package ringbuffer contains a ring buffer.
Package ringbuffer contains a ring buffer.
rtcpreceiver
Package rtcpreceiver contains a utility to generate RTCP receiver reports.
Package rtcpreceiver contains a utility to generate RTCP receiver reports.
rtcpsender
Package rtcpsender contains a utility to generate RTCP sender reports.
Package rtcpsender contains a utility to generate RTCP sender reports.
rtpcodecs
Package rtpcodecs contains utilities to convert codec-specific elements from/to RTP packets.
Package rtpcodecs contains utilities to convert codec-specific elements from/to RTP packets.
rtpcodecs/rtph264
Package rtph264 contains a RTP/H264 decoder and encoder.
Package rtph264 contains a RTP/H264 decoder and encoder.
rtpcodecs/rtph265
Package rtph265 contains a RTP/H265 decoder and encoder.
Package rtph265 contains a RTP/H265 decoder and encoder.
rtpcodecs/rtplpcm
Package rtplpcm contains a RTP/LPCM decoder and encoder.
Package rtplpcm contains a RTP/LPCM decoder and encoder.
rtpcodecs/rtpmpeg4audio
Package rtpmpeg4audio contains a RTP/MPEG4-audio decoder and encoder.
Package rtpmpeg4audio contains a RTP/MPEG4-audio decoder and encoder.
rtpcodecs/rtpsimpleaudio
Package rtpsimpleaudio contains a RTP decoder and encoder for audio codecs that fit in a single packet.
Package rtpsimpleaudio contains a RTP decoder and encoder for audio codecs that fit in a single packet.
rtpcodecs/rtpvp8
Package rtpvp8 contains a RTP/VP8 decoder and encoder.
Package rtpvp8 contains a RTP/VP8 decoder and encoder.
rtpcodecs/rtpvp9
Package rtpvp9 contains a RTP/VP9 decoder and encoder.
Package rtpvp9 contains a RTP/VP9 decoder and encoder.
rtpreorderer
Package rtpreorderer implements a filter to reorder incoming RTP packets.
Package rtpreorderer implements a filter to reorder incoming RTP packets.
rtptimedec
Package rtptimedec contains a RTP timestamp decoder.
Package rtptimedec contains a RTP timestamp decoder.
sdp
Package sdp contains a SDP encoder/decoder compatible with most RTSP implementations.
Package sdp contains a SDP encoder/decoder compatible with most RTSP implementations.
url
Package url contains the URL structure.
Package url contains the URL structure.

Jump to

Keyboard shortcuts

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