mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
update examples
This commit is contained in:
@@ -49,7 +49,7 @@ func main() {
|
||||
|
||||
buf = make([]byte, 2048)
|
||||
for {
|
||||
// read RTP packets from the source
|
||||
// read packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -50,7 +50,7 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP packets from the source
|
||||
// read packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -61,7 +61,7 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP packets from the source
|
||||
// read packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -49,7 +49,7 @@ func main() {
|
||||
|
||||
buf = make([]byte, 2048)
|
||||
for {
|
||||
// read RTP packets from the source
|
||||
// read packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -57,7 +57,7 @@ func main() {
|
||||
|
||||
buf := make([]byte, 2048)
|
||||
for {
|
||||
// read RTP packets from the source
|
||||
// read packets from the source
|
||||
n, _, err := pc.ReadFrom(buf)
|
||||
if err != nil {
|
||||
break
|
||||
|
@@ -71,7 +71,7 @@ func main() {
|
||||
})
|
||||
mux.SetPCRPID(256)
|
||||
|
||||
// read RTP packets
|
||||
// read packets
|
||||
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
|
||||
if trackID != h264TrackID {
|
||||
return
|
||||
|
@@ -38,7 +38,7 @@ func main() {
|
||||
// instantiate a RTP/H264 decoder
|
||||
dec := rtph264.NewDecoder()
|
||||
|
||||
// read RTP packets
|
||||
// read packets
|
||||
err = conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) {
|
||||
if streamType != gortsplib.StreamTypeRTP {
|
||||
return
|
||||
|
@@ -29,9 +29,9 @@ func main() {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// read RTP packets
|
||||
// read packets
|
||||
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)
|
||||
}
|
||||
|
@@ -51,9 +51,9 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// read RTP packets
|
||||
// read packets
|
||||
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)
|
||||
}
|
||||
|
@@ -22,12 +22,12 @@ func main() {
|
||||
defer conn.Close()
|
||||
|
||||
for {
|
||||
// read RTP packets
|
||||
// read packets
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
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))
|
||||
})
|
||||
}()
|
||||
|
||||
|
@@ -17,9 +17,9 @@ func main() {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// read RTP packets
|
||||
// read packets
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user