mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
improve performance
This commit is contained in:
@@ -22,15 +22,18 @@ func main() {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
readerDone := make(chan struct{})
|
||||
defer func() { <-readerDone }()
|
||||
|
||||
// read frames
|
||||
for {
|
||||
id, typ, buf, err := conn.ReadFrame()
|
||||
conn.OnFrame(func(id int, typ gortsplib.StreamType, buf []byte, err error) {
|
||||
if err != nil {
|
||||
fmt.Printf("connection is closed (%s)\n", err)
|
||||
break
|
||||
fmt.Printf("ERR: %v\n", err)
|
||||
close(readerDone)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("frame from track %d, type %v: %v\n",
|
||||
id, typ, buf)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user