av/protocol/rtsp/cmd/stream/main.go

55 lines
1.2 KiB
Go
Raw Normal View History

package main
import (
"flag"
"fmt"
"io"
"log"
"bitbucket.org/ausocean/av/protocol/rtsp"
)
func main() {
rtspServerPtr := flag.String("rtsp-server", "", "The RTSP server we would like to get video from")
clientPortPtr := flag.Uint("port", 6870, "The port on the client we would like to receive RTP on")
trackPtr := flag.String("track", "track1", "The track that we would like to receive media from")
flag.Parse()
sess := rtsp.NewSession()
res, err := sess.Options(*rtspServerPtr)
if err != nil {
log.Fatalln(err)
}
fmt.Println("Options:")
fmt.Println(res)
res, err = sess.Describe(*rtspServerPtr)
if err != nil {
log.Fatalln(err)
}
fmt.Println("Describe:")
fmt.Println(res)
p, err := rtsp.ParseSdp(&io.LimitedReader{R: res.Body, N: res.ContentLength})
if err != nil {
log.Fatalln(err)
}
log.Printf("%+v", p)
res, err = sess.Setup(*rtspServerPtr+"/"+*trackPtr, fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", *clientPortPtr, *clientPortPtr+1))
if err != nil {
log.Fatalln(err)
}
log.Println(res)
res, err = sess.Play(*rtspServerPtr, res.Header.Get("Session"))
if err != nil {
log.Fatalln(err)
}
log.Println(res)
// Send back rtcp
for {
}
}