Skip to main content
Import path: github.com/bluenviron/gortsplib/v5/pkg/base

URL

URL is an RTSP URL. It is a thin alias over the standard library’s net/url.URL, with RTSP-specific validation and helpers.

ParseURL

Parses a raw RTSP URL string. Returns an error if:
  • the scheme is not rtsp or rtsps,
  • the URL contains opaque data,
  • the URL contains a fragment (#).

URL methods


Request

Request represents an RTSP/1.0 request message.

Fields

Method
required
The RTSP method (e.g., Describe, Setup, Play). See the Methods table.
*URL
The request URL. May be nil when the request targets * (used in some OPTIONS requests).
Header
Map of header fields. Keys are canonical header names; values are HeaderValue ([]string).
[]byte
Optional request body. When non-empty, Content-Length is set automatically during marshaling.

Request methods


Response

Response represents an RTSP/1.0 response message.

Fields

StatusCode
required
Numeric status code. See the Status codes table.
string
Human-readable status message (e.g., "OK"). If empty during marshaling, the standard message for the status code is filled in automatically from StatusMessages.
Header
Map of header fields.
[]byte
Optional response body. Content-Length is set automatically during marshaling.

Response methods


Header is a map from canonical header name to one or more string values. The same header key can appear more than once in a request or response; all values are collected into the HeaderValue slice. Key normalization follows net/http.CanonicalHeaderKey with RTSP-specific overrides: CSeq, RTP-Info, WWW-Authenticate, and KeyMgmt.

Methods

Method is a string type.

Status codes

StatusCode is an int type. StatusMessages is a map[StatusCode]string that maps each code to its standard reason phrase.

1xx Informational

2xx Success

3xx Redirection

4xx Client errors

5xx Server errors


Code example

Parsing a URL and constructing a response: