From 13c6b69d302df3793336b433b2a33a89d8e93d64 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Thu, 23 Sep 2021 20:07:21 +0200 Subject: [PATCH] cleanup example --- examples/client-read-h264/main.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/examples/client-read-h264/main.go b/examples/client-read-h264/main.go index bfb79164..c913913f 100644 --- a/examples/client-read-h264/main.go +++ b/examples/client-read-h264/main.go @@ -39,17 +39,23 @@ func main() { // read RTP packets err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { - if streamType == gortsplib.StreamTypeRTP && trackID == h264Track { - // convert RTP packets into H264 NALUs - nalus, _, err := dec.Decode(payload) - if err != nil { - return - } + if streamType != gortsplib.StreamTypeRTP { + return + } - // print NALUs - for _, nalu := range nalus { - fmt.Printf("received H264 NALU of size %d\n", len(nalu)) - } + if trackID != h264Track { + return + } + + // convert RTP packets into H264 NALUs + nalus, _, err := dec.Decode(payload) + if err != nil { + return + } + + // print NALUs + for _, nalu := range nalus { + fmt.Printf("received H264 NALU of size %d\n", len(nalu)) } }) panic(err)