Credentials in the URL
Pass a username and password directly in the RTSP URL. gortsplib extracts and retains the credentials for authentication challenges (Basic and Digest).user:pass@ portion is forwarded on every request that requires authentication. You do not need to configure anything else for plain credential-based auth.
RTSPS (TLS)
Use anrtsps:// URL and supply a *tls.Config to connect to a server that requires TLS. The default RTSPS port is 322; gortsplib adds it automatically when no port is specified in the URL.
Self-signed certificates
If the server uses a self-signed certificate and you accept the security implications, setInsecureSkipVerify:
SRTP / SRTCP
SRTP (Secure RTP) encrypts RTP and RTCP packets at the media layer. When the server advertises SRTP in its SDP (the transport profile isRTP/SAVP), gortsplib enables SRTP automatically — no additional configuration is required.
The library handles:
- Key exchange via MIKEY (embedded in the SDP
key-mgmtattribute) - Encryption and decryption of RTP and RTCP payloads
- SRTP context lifecycle tied to the session
SRTP is independent of TLS. A server can require SRTP without using
rtsps://, and an rtsps:// server does not necessarily use SRTP. Many deployments use both together for defense in depth.Tunneling for firewall traversal
When a firewall blocks the RTSP port (554), you can tunnel the RTSP connection inside HTTP or WebSocket by setting theTunnel field: