diff --git a/revid/config.go b/revid/config.go index 72400c60..784ab02c 100644 --- a/revid/config.go +++ b/revid/config.go @@ -133,6 +133,7 @@ const ( Udp MpegtsRtp Rtp + RTSPCamera ) // Default config settings @@ -175,7 +176,7 @@ func (c *Config) Validate(r *Revid) error { } switch c.Input { - case Raspivid, V4L, File: + case Raspivid, V4L, File, RTSPCamera: case NothingDefined: c.Logger.Log(logger.Info, pkg+"no input type defined, defaulting", "input", defaultInput) c.Input = defaultInput diff --git a/revid/revid.go b/revid/revid.go index 25453257..47b7ce7c 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -40,6 +40,7 @@ import ( "sync" "time" + "bitbucket.org/ausocean/av/codec/h265" "bitbucket.org/ausocean/av/codec/lex" "bitbucket.org/ausocean/av/container/flv" "bitbucket.org/ausocean/av/container/mts" @@ -264,20 +265,18 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int) switch r.config.Input { case Raspivid: r.setupInput = r.startRaspivid + r.lexTo = lex.H264 case V4L: r.setupInput = r.startV4L + r.lexTo = lex.H264 case File: r.setupInput = r.setupInputForFile + r.lexTo = lex.H264 + case RTSPCamera: + r.setupInput = r.startRTSPCamera + r.lexTo = h265.NewLexer(false).Lex } - switch r.config.InputCodec { - case H264: - r.config.Logger.Log(logger.Info, pkg+"using H264 lexer") - r.lexTo = lex.H264 - case Mjpeg: - r.config.Logger.Log(logger.Info, pkg+"using MJPEG lexer") - r.lexTo = lex.MJPEG - } return nil } @@ -624,7 +623,17 @@ func (r *Revid) startRTSPCamera() (func() error, error) { } 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]) + rtpPort, err := strconv.Atoi(strings.Split(r.config.RTPRecvAddr, ":")[0]) + if err != nil { + return nil, err + } + + rtcpPort, err := strconv.Atoi(strings.Split(r.config.RTCPAddr, ":")[0]) + if err != nil { + return nil, err + } + + transport := fmt.Sprintf("RTP/AVP;unicast;client_port=%d-%d", rtpPort, rtcpPort) resp, err = rtspClt.Setup("track1", transport) if err != nil { return nil, err