client: simplify API, add StartReadingWait

This commit is contained in:
aler9
2021-11-12 15:48:50 +01:00
committed by Alessandro Ros
parent d04381d787
commit e13b4289ec
16 changed files with 82 additions and 199 deletions

View File

@@ -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)