mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
move examples in dedicated folders to follow conventions
This commit is contained in:
26
examples/client-read/main.go
Normal file
26
examples/client-read/main.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
)
|
||||
|
||||
// This example shows how to
|
||||
// 1. connect to a RTSP server
|
||||
// 2. read all tracks on a path
|
||||
|
||||
func main() {
|
||||
// connect to the server and start reading all tracks
|
||||
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// read track frames
|
||||
err = <-conn.ReadFrames(func(trackID int, typ gortsplib.StreamType, buf []byte) {
|
||||
fmt.Printf("frame from track %d, type %v: %v\n", trackID, typ, buf)
|
||||
})
|
||||
panic(err)
|
||||
}
|
Reference in New Issue
Block a user