From 04f3c79fe4b29098e0ac836f740e962d88b12e2a Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:19:32 +0100 Subject: [PATCH] simplify examples --- examples/client-read-options.go | 5 +---- examples/client-read-partial.go | 5 +---- examples/client-read.go | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/examples/client-read-options.go b/examples/client-read-options.go index 100aecbe..516b536f 100644 --- a/examples/client-read-options.go +++ b/examples/client-read-options.go @@ -33,11 +33,8 @@ func main() { defer conn.Close() // read track frames - done := conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { + err = <-conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { fmt.Printf("frame from track %d, type %v: %v\n", id, typ, buf) }) - - // catch any error - err = <-done panic(err) } diff --git a/examples/client-read-partial.go b/examples/client-read-partial.go index 4bbd1a36..9a065f2f 100644 --- a/examples/client-read-partial.go +++ b/examples/client-read-partial.go @@ -53,11 +53,8 @@ func main() { } // read track frames - done := conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { + err = <-conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { fmt.Printf("frame from track %d, type %v: %v\n", id, typ, buf) }) - - // catch any error - err = <-done panic(err) } diff --git a/examples/client-read.go b/examples/client-read.go index c72f819e..39d537a6 100644 --- a/examples/client-read.go +++ b/examples/client-read.go @@ -21,11 +21,8 @@ func main() { defer conn.Close() // read track frames - done := conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { + err = <-conn.ReadFrames(func(id int, typ gortsplib.StreamType, buf []byte) { fmt.Printf("frame from track %d, type %v: %v\n", id, typ, buf) }) - - // catch any error - err = <-done panic(err) }