1
Connect to the server
Parse the URL, populate
Scheme and Host, then call Start().2
Describe available medias
Describe sends a DESCRIBE request and returns a *description.Session that lists every media track on the path.3
Set up all medias
SetupAll sends a SETUP request for each media in the description.4
Register packet callbacks
Register your callbacks before calling
Play. The library delivers packets on these callbacks from a background goroutine.5
Start playing
Play sends the PLAY request. The server begins streaming immediately.c.Wait() blocks the calling goroutine until the connection is terminated — either by a network error, a server close, or your own call to c.Close(). Always call it (or select on a channel) to keep the process alive.Complete example
The following program connects to an RTSP server and logs every incoming RTP and RTCP packet.client-play/main.go
Querying available streams
If you only need to inspect what medias a server offers — without actually receiving packets — callDescribe and inspect the result without proceeding to SetupAll or Play.
client-query/main.go
Reading timestamps
Usec.PacketPTS and c.PacketNTP inside any RTP callback to retrieve timing information for each packet.
client-play-timestamp/main.go
PacketNTP returns a value only when the server sends RTCP sender reports containing NTP timestamps. For streams that don’t send sender reports, ntpAvailable is false.Pause and resume
Callc.Pause() to send a PAUSE request that suspends packet delivery without disconnecting. Call c.Play(nil) again to resume from where you left off.
client-play-pause/main.go
Not all servers honor PAUSE requests. If the server does not support it,
c.Pause() returns an error.