From 79fdb2b7b436f883996b4d13d614895dccf05005 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Mon, 31 Jan 2022 18:39:36 +0100 Subject: [PATCH] use log.Print instead of fmt.Print in examples --- examples/client-publish-aac/main.go | 6 +++--- examples/client-publish-h264/main.go | 6 +++--- examples/client-publish-options/main.go | 6 +++--- examples/client-publish-opus/main.go | 6 +++--- examples/client-publish-pause/main.go | 6 +++--- examples/client-query/main.go | 4 ++-- examples/client-read-aac/main.go | 6 +++--- examples/client-read-h264-convert-to-jpeg/main.go | 4 ++-- examples/client-read-h264-save-to-disk/main.go | 2 +- examples/client-read-h264-save-to-disk/mpegtsencoder.go | 3 ++- examples/client-read-h264/main.go | 6 +++--- examples/client-read-options/main.go | 6 +++--- examples/client-read-partial/main.go | 6 +++--- examples/client-read-pause/main.go | 6 +++--- examples/client-read/main.go | 6 +++--- 15 files changed, 40 insertions(+), 39 deletions(-) diff --git a/examples/client-publish-aac/main.go b/examples/client-publish-aac/main.go index 7f0fbc86..60713d02 100644 --- a/examples/client-publish-aac/main.go +++ b/examples/client-publish-aac/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "net" "github.com/aler9/gortsplib" @@ -20,7 +20,7 @@ func main() { } defer pc.Close() - fmt.Println("Waiting for a RTP/AAC stream on UDP port 9000 - you can send one with Gstreamer:\n" + + log.Println("Waiting for a RTP/AAC stream on UDP port 9000 - you can send one with Gstreamer:\n" + "gst-launch-1.0 audiotestsrc freq=300 ! audioconvert ! audioresample ! audio/x-raw,rate=48000" + " ! avenc_aac bitrate=128000" + " ! rtpmp4gpay ! udpsink host=127.0.0.1 port=9000") @@ -31,7 +31,7 @@ func main() { if err != nil { panic(err) } - fmt.Println("stream connected") + log.Println("stream connected") // create an AAC track track, err := gortsplib.NewTrackAAC(96, 2, 48000, 2, nil) diff --git a/examples/client-publish-h264/main.go b/examples/client-publish-h264/main.go index 5bc82bc6..14d4fda6 100644 --- a/examples/client-publish-h264/main.go +++ b/examples/client-publish-h264/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "net" "github.com/aler9/gortsplib" @@ -21,7 +21,7 @@ func main() { } defer pc.Close() - fmt.Println("Waiting for a RTP/H264 stream on UDP port 9000 - you can send one with Gstreamer:\n" + + log.Println("Waiting for a RTP/H264 stream on UDP port 9000 - you can send one with Gstreamer:\n" + "gst-launch-1.0 videotestsrc ! video/x-raw,width=1920,height=1080" + " ! x264enc speed-preset=veryfast tune=zerolatency bitrate=600000" + " ! rtph264pay ! udpsink host=127.0.0.1 port=9000") @@ -32,7 +32,7 @@ func main() { if err != nil { panic(err) } - fmt.Println("stream connected") + log.Println("stream connected") // create an H264 track track, err := gortsplib.NewTrackH264(96, sps, pps, nil) diff --git a/examples/client-publish-options/main.go b/examples/client-publish-options/main.go index dcb1e89d..51ec66bf 100644 --- a/examples/client-publish-options/main.go +++ b/examples/client-publish-options/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "net" "time" @@ -23,7 +23,7 @@ func main() { } defer pc.Close() - fmt.Println("Waiting for a rtp/h264 stream on port 9000 - you can send one with gstreamer:\n" + + log.Println("Waiting for a rtp/h264 stream on port 9000 - you can send one with gstreamer:\n" + "gst-launch-1.0 filesrc location=video.mp4 ! qtdemux ! video/x-h264" + " ! h264parse config-interval=1 ! rtph264pay ! udpsink host=127.0.0.1 port=9000") @@ -33,7 +33,7 @@ func main() { if err != nil { panic(err) } - fmt.Println("stream connected") + log.Println("stream connected") // create an H264 track track, err := gortsplib.NewTrackH264(96, sps, pps, nil) diff --git a/examples/client-publish-opus/main.go b/examples/client-publish-opus/main.go index 2429755b..bf7000a6 100644 --- a/examples/client-publish-opus/main.go +++ b/examples/client-publish-opus/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "net" "github.com/aler9/gortsplib" @@ -20,7 +20,7 @@ func main() { } defer pc.Close() - fmt.Println("Waiting for a RTP/Opus stream on UDP port 9000 - you can send one with Gstreamer:\n" + + log.Println("Waiting for a RTP/Opus stream on UDP port 9000 - you can send one with Gstreamer:\n" + "gst-launch-1.0 audiotestsrc freq=300 ! audioconvert ! audioresample ! audio/x-raw,rate=48000" + " ! opusenc" + " ! rtpopuspay ! udpsink host=127.0.0.1 port=9000") @@ -31,7 +31,7 @@ func main() { if err != nil { panic(err) } - fmt.Println("stream connected") + log.Println("stream connected") // create an Opus track track, err := gortsplib.NewTrackOpus(96, 48000, 2) diff --git a/examples/client-publish-pause/main.go b/examples/client-publish-pause/main.go index 49cf8950..dab273fd 100644 --- a/examples/client-publish-pause/main.go +++ b/examples/client-publish-pause/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "net" "time" @@ -24,7 +24,7 @@ func main() { } defer pc.Close() - fmt.Println("Waiting for a rtp/h264 stream on port 9000 - you can send one with gstreamer:\n" + + log.Println("Waiting for a rtp/h264 stream on port 9000 - you can send one with gstreamer:\n" + "gst-launch-1.0 filesrc location=video.mp4 ! qtdemux ! video/x-h264" + " ! h264parse config-interval=1 ! rtph264pay ! udpsink host=127.0.0.1 port=9000") @@ -34,7 +34,7 @@ func main() { if err != nil { panic(err) } - fmt.Println("stream connected") + log.Println("stream connected") // create an H264 track track, err := gortsplib.NewTrackH264(96, sps, pps, nil) diff --git a/examples/client-query/main.go b/examples/client-query/main.go index c0522581..da876408 100644 --- a/examples/client-query/main.go +++ b/examples/client-query/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "github.com/aler9/gortsplib" "github.com/aler9/gortsplib/pkg/base" @@ -35,5 +35,5 @@ func main() { panic(err) } - fmt.Println("available tracks: %v\n", tracks) + log.Println("available tracks: %v\n", tracks) } diff --git a/examples/client-read-aac/main.go b/examples/client-read-aac/main.go index 105632c5..99d79079 100644 --- a/examples/client-read-aac/main.go +++ b/examples/client-read-aac/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "github.com/aler9/gortsplib" "github.com/aler9/gortsplib/pkg/base" @@ -73,7 +73,7 @@ func main() { return } - // decode AAC AUs from RTP packets + // decode AAC AUs from the RTP packet aus, _, err := dec.Decode(&pkt) if err != nil { return @@ -81,7 +81,7 @@ func main() { // print AUs for _, au := range aus { - fmt.Printf("received AAC AU of size %d\n", len(au)) + log.Printf("received AAC AU of size %d\n", len(au)) } } diff --git a/examples/client-read-h264-convert-to-jpeg/main.go b/examples/client-read-h264-convert-to-jpeg/main.go index 5718cca0..95dd2bdb 100644 --- a/examples/client-read-h264-convert-to-jpeg/main.go +++ b/examples/client-read-h264-convert-to-jpeg/main.go @@ -104,14 +104,14 @@ func main() { return } - // decode H264 NALUs from RTP packet + // decode H264 NALUs from the RTP packet nalus, _, err := dec.Decode(&pkt) if err != nil { return } - // decode raw frames from H264 NALUs for _, nalu := range nalus { + // decode raw frames from H264 NALUs img, err := h264dec.decode(nalu) if err != nil { panic(err) diff --git a/examples/client-read-h264-save-to-disk/main.go b/examples/client-read-h264-save-to-disk/main.go index b26f8be4..e4e39c64 100644 --- a/examples/client-read-h264-save-to-disk/main.go +++ b/examples/client-read-h264-save-to-disk/main.go @@ -79,7 +79,7 @@ func main() { return } - // decode H264 NALUs from RTP packets + // decode H264 NALUs from the RTP packet nalus, pts, err := dec.DecodeUntilMarker(&pkt) if err != nil { return diff --git a/examples/client-read-h264-save-to-disk/mpegtsencoder.go b/examples/client-read-h264-save-to-disk/mpegtsencoder.go index 5bd7791c..b020b385 100644 --- a/examples/client-read-h264-save-to-disk/mpegtsencoder.go +++ b/examples/client-read-h264-save-to-disk/mpegtsencoder.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "log" "os" "time" @@ -138,6 +139,6 @@ func (e *mpegtsEncoder) encode(nalus [][]byte, pts time.Duration) error { return err } - fmt.Println("wrote TS packet") + log.Println("wrote TS packet") return nil } diff --git a/examples/client-read-h264/main.go b/examples/client-read-h264/main.go index cc0a92e6..e89576c6 100644 --- a/examples/client-read-h264/main.go +++ b/examples/client-read-h264/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "github.com/aler9/gortsplib" "github.com/aler9/gortsplib/pkg/base" @@ -71,7 +71,7 @@ func main() { return } - // decode H264 NALUs from RTP packets + // decode H264 NALUs from the RTP packet nalus, _, err := dec.Decode(&pkt) if err != nil { return @@ -79,7 +79,7 @@ func main() { // print NALUs for _, nalu := range nalus { - fmt.Printf("received H264 NALU of size %d\n", len(nalu)) + log.Printf("received H264 NALU of size %d\n", len(nalu)) } } diff --git a/examples/client-read-options/main.go b/examples/client-read-options/main.go index 401a8b2e..f8829183 100644 --- a/examples/client-read-options/main.go +++ b/examples/client-read-options/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "time" "github.com/aler9/gortsplib" @@ -22,11 +22,11 @@ func main() { WriteTimeout: 10 * time.Second, // called when a RTP packet arrives OnPacketRTP: func(trackID int, payload []byte) { - fmt.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) }, // called when a RTCP packet arrives OnPacketRTCP: func(trackID int, payload []byte) { - fmt.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) }, } diff --git a/examples/client-read-partial/main.go b/examples/client-read-partial/main.go index c53aad09..a67a39d7 100644 --- a/examples/client-read-partial/main.go +++ b/examples/client-read-partial/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "github.com/aler9/gortsplib" "github.com/aler9/gortsplib/pkg/base" @@ -16,11 +16,11 @@ func main() { c := gortsplib.Client{ // called when a RTP packet arrives OnPacketRTP: func(trackID int, payload []byte) { - fmt.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) }, // called when a RTCP packet arrives OnPacketRTCP: func(trackID int, payload []byte) { - fmt.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) }, } diff --git a/examples/client-read-pause/main.go b/examples/client-read-pause/main.go index 43e3c56b..ea3031fe 100644 --- a/examples/client-read-pause/main.go +++ b/examples/client-read-pause/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "time" "github.com/aler9/gortsplib" @@ -17,11 +17,11 @@ func main() { c := gortsplib.Client{ // called when a RTP packet arrives OnPacketRTP: func(trackID int, payload []byte) { - fmt.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) }, // called when a RTCP packet arrives OnPacketRTCP: func(trackID int, payload []byte) { - fmt.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) }, } diff --git a/examples/client-read/main.go b/examples/client-read/main.go index 7335b59b..bf35aedc 100644 --- a/examples/client-read/main.go +++ b/examples/client-read/main.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "log" "github.com/aler9/gortsplib" ) @@ -13,11 +13,11 @@ func main() { c := gortsplib.Client{ // called when a RTP packet arrives OnPacketRTP: func(trackID int, payload []byte) { - fmt.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTP packet from track %d, size %d\n", trackID, len(payload)) }, // called when a RTCP packet arrives OnPacketRTCP: func(trackID int, payload []byte) { - fmt.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) + log.Printf("RTCP packet from track %d, size %d\n", trackID, len(payload)) }, }