mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
use log.Print instead of fmt.Print in examples
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user