mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00

* split tracks from medias * move tracks into dedicated package * move media into dedicated package * edit Medias.Marshal() in order to return SDP * add medias.Find() and simplify examples * improve coverage * fix rebase errors * replace TrackIDs with MediaIDs * implement media-specific and track-specific callbacks for reading RTCP and RTP packets * rename publish into record, read into play * add v2 tag * rename tracks into formats
35 lines
565 B
Go
35 lines
565 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/aler9/gortsplib/v2"
|
|
"github.com/aler9/gortsplib/v2/pkg/url"
|
|
)
|
|
|
|
// 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 := url.Parse("rtsp://localhost:8554/mypath")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
err = c.Start(u.Scheme, u.Host)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer c.Close()
|
|
|
|
medias, _, _, err := c.Describe(u)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
log.Printf("available medias: %v\n", medias)
|
|
}
|