mirror of https://bitbucket.org/ausocean/av.git
revid: wrote basics of a startRTSPCamera func
Currently just connecting to RTSP server, requesting OPTIONS, DESCRIBE, SETUP and PLAY. Also creating RTP client and giving this to process from for the lexer.
This commit is contained in:
parent
6b64314d71
commit
1059b5e738
|
@ -74,6 +74,9 @@ type Config struct {
|
|||
Saturation int
|
||||
Exposure string
|
||||
AutoWhiteBalance string
|
||||
RTSPURL string
|
||||
RTPRecvAddr string
|
||||
RTCPAddr string
|
||||
}
|
||||
|
||||
// Possible modes for raspivid --exposure parameter.
|
||||
|
|
|
@ -43,6 +43,8 @@ import (
|
|||
"bitbucket.org/ausocean/av/codec/lex"
|
||||
"bitbucket.org/ausocean/av/container/flv"
|
||||
"bitbucket.org/ausocean/av/container/mts"
|
||||
"bitbucket.org/ausocean/av/protocol/rtp"
|
||||
"bitbucket.org/ausocean/av/protocol/rtsp"
|
||||
"bitbucket.org/ausocean/iot/pi/netsender"
|
||||
"bitbucket.org/ausocean/utils/ioext"
|
||||
"bitbucket.org/ausocean/utils/logger"
|
||||
|
@ -604,6 +606,48 @@ func (r *Revid) setupInputForFile() (func() error, error) {
|
|||
return func() error { return f.Close() }, nil
|
||||
}
|
||||
|
||||
func (r *Revid) startRTSPCamera() (func() error, error) {
|
||||
rtspClt, err := rtsp.NewClient(r.config.RTSPURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := rtspClt.Options()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.config.Logger.Log(logger.Info, pkg+"RTSP server OPTIONS response", "response", resp.String())
|
||||
|
||||
resp, err = rtspClt.Describe()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.config.Logger.Log(logger.Info, pkg+"RTSP server DESCRIBE response", "response", resp.String())
|
||||
|
||||
transport := fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", strings.Split(r.config.RTPRecvAddr, ":")[1], strings.Split(r.config.RTCPAddr, ":")[1])
|
||||
resp, err = rtspClt.Setup("track1", transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.config.Logger.Log(logger.Info, pkg+"RTSP server SETUP response", "response", resp.String())
|
||||
|
||||
resp, err = rtspClt.Play()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO(saxon): use rtcp client to maintain rtp stream.
|
||||
|
||||
rtpClt, err := rtp.NewClient(r.config.RTPRecvAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.wg.Add(1)
|
||||
go r.processFrom(rtpClt, time.Second/time.Duration(r.config.FrameRate))
|
||||
return func() error { return nil }, nil
|
||||
}
|
||||
|
||||
func (r *Revid) processFrom(read io.Reader, delay time.Duration) {
|
||||
r.config.Logger.Log(logger.Info, pkg+"reading input data")
|
||||
r.err <- r.lexTo(r.encoders, read, delay)
|
||||
|
|
Loading…
Reference in New Issue