mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
new client api
This commit is contained in:
42
examples/client-query.go
Normal file
42
examples/client-query.go
Normal file
@@ -0,0 +1,42 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
)
|
||||
|
||||
// This example shows how to connect to a server and print informations about
|
||||
// tracks published on a certain path.
|
||||
|
||||
func main() {
|
||||
u, err := base.ParseURL("rtsp://myserver/mypath")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conn, err := gortsplib.Dial(u.Host)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
_, err = conn.Options(u)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tracks, res, err := conn.Describe(u)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if res.StatusCode != base.StatusOK {
|
||||
panic(fmt.Errorf("server returned status %d", res.StatusCode))
|
||||
}
|
||||
|
||||
fmt.Println("tracks: %v\n", tracks)
|
||||
}
|
Reference in New Issue
Block a user