mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
client: simplify API, add StartReadingWait
This commit is contained in:
@@ -26,20 +26,13 @@ func main() {
|
||||
}
|
||||
|
||||
// connect to the server and start reading all tracks
|
||||
err := c.DialRead("rtsp://localhost:8554/mystream")
|
||||
err := c.StartReading("rtsp://localhost:8554/mystream")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
for {
|
||||
// read packets
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
c.ReadFrames()
|
||||
}()
|
||||
|
||||
// wait
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
@@ -49,9 +42,6 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// join reader
|
||||
<-done
|
||||
|
||||
// wait
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
|
Reference in New Issue
Block a user