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)
|
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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
@@ -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))
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@@ -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)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user