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

@@ -45,7 +45,7 @@ func main() {
c := gortsplib.Client{}
// connect to the server and start publishing the track
err = c.DialPublish("rtsp://localhost:8554/mystream",
err = c.StartPublishing("rtsp://localhost:8554/mystream",
gortsplib.Tracks{track})
if err != nil {
panic(err)
@@ -53,10 +53,7 @@ func main() {
defer c.Close()
for {
writerDone := make(chan struct{})
go func() {
defer close(writerDone)
buf := make([]byte, 2048)
for {
// read packets from the source
@@ -82,9 +79,6 @@ func main() {
panic(err)
}
// join writer
<-writerDone
// wait
time.Sleep(5 * time.Second)