mirror of
https://github.com/aler9/gortsplib
synced 2025-10-02 22:12:18 +08:00
35 lines
580 B
Go
35 lines
580 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/bluenviron/gortsplib/v4"
|
|
"github.com/bluenviron/gortsplib/v4/pkg/base"
|
|
)
|
|
|
|
// This example shows how to
|
|
// 1. connect to a RTSP server
|
|
// 2. get and print informations about medias published on a path.
|
|
|
|
func main() {
|
|
c := gortsplib.Client{}
|
|
|
|
u, err := base.ParseURL("rtsp://localhost:8554/mypath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
err = c.Start(u.Scheme, u.Host)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer c.Close()
|
|
|
|
desc, _, err := c.Describe(u)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
log.Printf("available medias: %v\n", desc.Medias)
|
|
}
|