base

package
v4.0.0-...-0ef4ac4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package base contains the primitives of the RTSP protocol.

Index

Constants

View Source
const (
	// InterleavedFrameMagicByte is the first byte of an interleaved frame.
	InterleavedFrameMagicByte = 0x24
)

Variables

View Source
var StatusMessages = statusMessages

StatusMessages contains the status messages associated with each status code.

Functions

func PathSplitQuery

func PathSplitQuery(pathAndQuery string) (string, string)

PathSplitQuery splits a path from a query.

Types

type Header map[string]HeaderValue

Header is a RTSP reader, present in both Requests and Responses.

type HeaderValue

type HeaderValue []string

HeaderValue is an header value.

type InterleavedFrame

type InterleavedFrame struct {
	// channel ID
	Channel int

	// payload
	Payload []byte
}

InterleavedFrame is an interleaved frame, and allows to transfer binary data within RTSP/TCP connections. It is used to send and receive RTP and RTCP packets with TCP.

func (InterleavedFrame) Marshal

func (f InterleavedFrame) Marshal() ([]byte, error)

Marshal writes an InterleavedFrame.

func (InterleavedFrame) MarshalSize

func (f InterleavedFrame) MarshalSize() int

MarshalSize returns the size of an InterleavedFrame.

func (InterleavedFrame) MarshalTo

func (f InterleavedFrame) MarshalTo(buf []byte) (int, error)

MarshalTo writes an InterleavedFrame.

func (*InterleavedFrame) Unmarshal

func (f *InterleavedFrame) Unmarshal(br *bufio.Reader) error

Unmarshal decodes an interleaved frame.

type Method

type Method string

Method is the method of a RTSP request.

const (
	Announce     Method = "ANNOUNCE"
	Describe     Method = "DESCRIBE"
	GetParameter Method = "GET_PARAMETER"
	Options      Method = "OPTIONS"
	Pause        Method = "PAUSE"
	Play         Method = "PLAY"
	Record       Method = "RECORD"
	Setup        Method = "SETUP"
	SetParameter Method = "SET_PARAMETER"
	Teardown     Method = "TEARDOWN"
)

methods.

type Request

type Request struct {
	// request method
	Method Method

	// request url
	URL *URL

	// map of header values
	Header Header

	// optional body
	Body []byte
}

Request is a RTSP request.

func (Request) Marshal

func (req Request) Marshal() ([]byte, error)

Marshal writes a Request.

func (Request) MarshalSize

func (req Request) MarshalSize() int

MarshalSize returns the size of a Request.

func (Request) MarshalTo

func (req Request) MarshalTo(buf []byte) (int, error)

MarshalTo writes a Request.

func (Request) String

func (req Request) String() string

String implements fmt.Stringer.

func (*Request) Unmarshal

func (req *Request) Unmarshal(br *bufio.Reader) error

Unmarshal reads a request.

type Response

type Response struct {
	// numeric status code
	StatusCode StatusCode

	// status message
	StatusMessage string

	// map of header values
	Header Header

	// optional body
	Body []byte
}

Response is a RTSP response.

func (Response) Marshal

func (res Response) Marshal() ([]byte, error)

Marshal writes a Response.

func (Response) MarshalSize

func (res Response) MarshalSize() int

MarshalSize returns the size of a Response.

func (Response) MarshalTo

func (res Response) MarshalTo(buf []byte) (int, error)

MarshalTo writes a Response.

func (Response) String

func (res Response) String() string

String implements fmt.Stringer.

func (*Response) Unmarshal

func (res *Response) Unmarshal(br *bufio.Reader) error

Unmarshal reads a response.

type StatusCode

type StatusCode int

StatusCode is the status code of a RTSP response.

const (
	StatusContinue                           StatusCode = 100
	StatusOK                                 StatusCode = 200
	StatusMovedPermanently                   StatusCode = 301
	StatusFound                              StatusCode = 302
	StatusSeeOther                           StatusCode = 303
	StatusNotModified                        StatusCode = 304
	StatusUseProxy                           StatusCode = 305
	StatusBadRequest                         StatusCode = 400
	StatusUnauthorized                       StatusCode = 401
	StatusPaymentRequired                    StatusCode = 402
	StatusForbidden                          StatusCode = 403
	StatusNotFound                           StatusCode = 404
	StatusMethodNotAllowed                   StatusCode = 405
	StatusNotAcceptable                      StatusCode = 406
	StatusProxyAuthRequired                  StatusCode = 407
	StatusRequestTimeout                     StatusCode = 408
	StatusGone                               StatusCode = 410
	StatusPreconditionFailed                 StatusCode = 412
	StatusRequestEntityTooLarge              StatusCode = 413
	StatusRequestURITooLong                  StatusCode = 414
	StatusUnsupportedMediaType               StatusCode = 415
	StatusParameterNotUnderstood             StatusCode = 451
	StatusNotEnoughBandwidth                 StatusCode = 453
	StatusSessionNotFound                    StatusCode = 454
	StatusMethodNotValidInThisState          StatusCode = 455
	StatusHeaderFieldNotValidForResource     StatusCode = 456
	StatusInvalidRange                       StatusCode = 457
	StatusParameterIsReadOnly                StatusCode = 458
	StatusAggregateOperationNotAllowed       StatusCode = 459
	StatusOnlyAggregateOperationAllowed      StatusCode = 460
	StatusUnsupportedTransport               StatusCode = 461
	StatusDestinationUnreachable             StatusCode = 462
	StatusDestinationProhibited              StatusCode = 463
	StatusDataTransportNotReadyYet           StatusCode = 464
	StatusNotificationReasonUnknown          StatusCode = 465
	StatusKeyManagementError                 StatusCode = 466
	StatusConnectionAuthorizationRequired    StatusCode = 470
	StatusConnectionCredentialsNotAccepted   StatusCode = 471
	StatusFailureToEstablishSecureConnection StatusCode = 472
	StatusInternalServerError                StatusCode = 500
	StatusNotImplemented                     StatusCode = 501
	StatusBadGateway                         StatusCode = 502
	StatusServiceUnavailable                 StatusCode = 503
	StatusGatewayTimeout                     StatusCode = 504
	StatusRTSPVersionNotSupported            StatusCode = 505
	StatusOptionNotSupported                 StatusCode = 551
	StatusProxyUnavailable                   StatusCode = 553
)

status codes.

type URL

type URL url.URL

URL is a RTSP URL. This is basically an HTTP URL with some additional functions to handle control attributes.

func ParseURL

func ParseURL(s string) (*URL, error)

ParseURL parses a RTSP URL.

func (*URL) Clone

func (u *URL) Clone() *URL

Clone clones a URL.

func (*URL) CloneWithoutCredentials

func (u *URL) CloneWithoutCredentials() *URL

CloneWithoutCredentials clones a URL without its credentials.

func (*URL) Hostname

func (u *URL) Hostname() string

Hostname returns u.Host, stripping any valid port number if present.

If the result is enclosed in square brackets, as literal IPv6 addresses are, the square brackets are removed from the result.

func (*URL) Port

func (u *URL) Port() string

Port returns the port part of u.Host, without the leading colon.

If u.Host doesn't contain a valid numeric port, Port returns an empty string.

func (*URL) RTSPPathAndQuery

func (u *URL) RTSPPathAndQuery() (string, bool)

RTSPPathAndQuery returns the path and query of a RTSP URL.

func (*URL) String

func (u *URL) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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