revid: using h265 lexer now in the case of RTSPCamera input

This commit is contained in:
Saxon 2019-05-14 11:56:04 +09:30
parent 1059b5e738
commit 25bb49bce7
2 changed files with 20 additions and 10 deletions

View File

@ -133,6 +133,7 @@ const (
Udp Udp
MpegtsRtp MpegtsRtp
Rtp Rtp
RTSPCamera
) )
// Default config settings // Default config settings
@ -175,7 +176,7 @@ func (c *Config) Validate(r *Revid) error {
} }
switch c.Input { switch c.Input {
case Raspivid, V4L, File: case Raspivid, V4L, File, RTSPCamera:
case NothingDefined: case NothingDefined:
c.Logger.Log(logger.Info, pkg+"no input type defined, defaulting", "input", defaultInput) c.Logger.Log(logger.Info, pkg+"no input type defined, defaulting", "input", defaultInput)
c.Input = defaultInput c.Input = defaultInput

View File

@ -40,6 +40,7 @@ import (
"sync" "sync"
"time" "time"
"bitbucket.org/ausocean/av/codec/h265"
"bitbucket.org/ausocean/av/codec/lex" "bitbucket.org/ausocean/av/codec/lex"
"bitbucket.org/ausocean/av/container/flv" "bitbucket.org/ausocean/av/container/flv"
"bitbucket.org/ausocean/av/container/mts" "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 { switch r.config.Input {
case Raspivid: case Raspivid:
r.setupInput = r.startRaspivid r.setupInput = r.startRaspivid
r.lexTo = lex.H264
case V4L: case V4L:
r.setupInput = r.startV4L r.setupInput = r.startV4L
r.lexTo = lex.H264
case File: case File:
r.setupInput = r.setupInputForFile 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 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()) 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) resp, err = rtspClt.Setup("track1", transport)
if err != nil { if err != nil {
return nil, err return nil, err