update examples

This commit is contained in:
aler9
2021-11-01 10:36:45 +01:00
parent a59f840d81
commit 7e978595b5
11 changed files with 15 additions and 15 deletions

View File

@@ -49,7 +49,7 @@ func main() {
buf = make([]byte, 2048) buf = make([]byte, 2048)
for { for {
// read RTP packets from the source // read packets from the source
n, _, err := pc.ReadFrom(buf) n, _, err := pc.ReadFrom(buf)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -50,7 +50,7 @@ func main() {
buf := make([]byte, 2048) buf := make([]byte, 2048)
for { for {
// read RTP packets from the source // read packets from the source
n, _, err := pc.ReadFrom(buf) n, _, err := pc.ReadFrom(buf)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -61,7 +61,7 @@ func main() {
buf := make([]byte, 2048) buf := make([]byte, 2048)
for { for {
// read RTP packets from the source // read packets from the source
n, _, err := pc.ReadFrom(buf) n, _, err := pc.ReadFrom(buf)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -49,7 +49,7 @@ func main() {
buf = make([]byte, 2048) buf = make([]byte, 2048)
for { for {
// read RTP packets from the source // read packets from the source
n, _, err := pc.ReadFrom(buf) n, _, err := pc.ReadFrom(buf)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -57,7 +57,7 @@ func main() {
buf := make([]byte, 2048) buf := make([]byte, 2048)
for { for {
// read RTP packets from the source // read packets from the source
n, _, err := pc.ReadFrom(buf) n, _, err := pc.ReadFrom(buf)
if err != nil { if err != nil {
break break

View File

@@ -71,7 +71,7 @@ func main() {
}) })
mux.SetPCRPID(256) mux.SetPCRPID(256)
// read RTP packets // read packets
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
if trackID != h264TrackID { if trackID != h264TrackID {
return return

View File

@@ -38,7 +38,7 @@ func main() {
// instantiate a RTP/H264 decoder // instantiate a RTP/H264 decoder
dec := rtph264.NewDecoder() dec := rtph264.NewDecoder()
// read RTP packets // read packets
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
if streamType != gortsplib.StreamTypeRTP { if streamType != gortsplib.StreamTypeRTP {
return return

View File

@@ -29,9 +29,9 @@ func main() {
} }
defer conn.Close() defer conn.Close()
// read RTP packets // read packets
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) fmt.Printf("packet from track %d, type %v, size %d\n", trackID, streamType, len(payload))
}) })
panic(err) panic(err)
} }

View File

@@ -51,9 +51,9 @@ func main() {
panic(err) panic(err)
} }
// read RTP packets // read packets
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) fmt.Printf("packet from track %d, type %v, size %d\n", trackID, streamType, len(payload))
}) })
panic(err) panic(err)
} }

View File

@@ -22,12 +22,12 @@ func main() {
defer conn.Close() defer conn.Close()
for { for {
// read RTP packets // read packets
done := make(chan struct{}) done := make(chan struct{})
go func() { go func() {
defer close(done) defer close(done)
conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) fmt.Printf("packet from track %d, type %v, size %d\n", trackID, streamType, len(payload))
}) })
}() }()

View File

@@ -17,9 +17,9 @@ func main() {
} }
defer conn.Close() defer conn.Close()
// read RTP packets // read packets
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
fmt.Printf("frame from track %d, type %v, size %d\n", trackID, streamType, len(payload)) fmt.Printf("packet from track %d, type %v, size %d\n", trackID, streamType, len(payload))
}) })
panic(err) panic(err)
} }