cmd/rv: did some cleaning and commenting

Modified profile.go file header. Updated binary name in run.sh.
This commit is contained in:
Saxon 2020-01-27 15:31:14 +10:30
parent 7033d62cc6
commit ed626e02ab
16 changed files with 88 additions and 67 deletions

View File

@ -218,13 +218,13 @@ func handleFlags() config.Config {
switch *inputCodecPtr { switch *inputCodecPtr {
case "H264": case "H264":
cfg.InputCodec = codecutil.CodecH264 cfg.InputCodec = codecutil.H264
case "PCM": case "PCM":
cfg.InputCodec = codecutil.CodecPCM cfg.InputCodec = codecutil.PCM
case "ADPCM": case "ADPCM":
cfg.InputCodec = codecutil.CodecADPCM cfg.InputCodec = codecutil.ADPCM
case "MJPEG": case "MJPEG":
cfg.InputCodec = codecutil.CodecMJPEG cfg.InputCodec = codecutil.MJPEG
default: default:
log.Log(logger.Error, pkg+"bad input codec argument") log.Log(logger.Error, pkg+"bad input codec argument")
} }

View File

@ -1,17 +1,19 @@
/* /*
NAME
revid-cli - command line interface for revid.
DESCRIPTION DESCRIPTION
See Readme.md rv is a netsender client using the revid package to perform media collection
and forwarding whos behaviour is controllable via the cloud interfaces
netreceiver and vidgrind.
AUTHORS AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org> Saxon A. Nelson-Milton <saxon@ausocean.org>
Alan Noble <alan@ausocean.org>
Dan Kortschak <dan@ausocean.org>
Jack Richardson <jack@ausocean.org> Jack Richardson <jack@ausocean.org>
Trek Hopton <trek@ausocean.org> Trek Hopton <trek@ausocean.org>
Scott Barnard <scott@ausocean.org>
LICENSE LICENSE
revid-cli is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean) Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the
@ -38,6 +40,8 @@ import (
"strconv" "strconv"
"time" "time"
"gopkg.in/natefinch/lumberjack.v2"
"bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/container/mts"
"bitbucket.org/ausocean/av/container/mts/meta" "bitbucket.org/ausocean/av/container/mts/meta"
"bitbucket.org/ausocean/av/revid" "bitbucket.org/ausocean/av/revid"
@ -46,7 +50,6 @@ import (
"bitbucket.org/ausocean/iot/pi/netsender" "bitbucket.org/ausocean/iot/pi/netsender"
"bitbucket.org/ausocean/iot/pi/sds" "bitbucket.org/ausocean/iot/pi/sds"
"bitbucket.org/ausocean/utils/logger" "bitbucket.org/ausocean/utils/logger"
"gopkg.in/natefinch/lumberjack.v2"
) )
// Copyright information prefixed to all metadata. // Copyright information prefixed to all metadata.
@ -70,9 +73,10 @@ const (
modeNormal = "Normal" modeNormal = "Normal"
modePaused = "Paused" modePaused = "Paused"
modeBurst = "Burst" modeBurst = "Burst"
modeLoop = "Loop"
) )
// Misc consts. // Misc constants.
const ( const (
netSendRetryTime = 5 * time.Second netSendRetryTime = 5 * time.Second
defaultSleepTime = 60 // Seconds defaultSleepTime = 60 // Seconds
@ -80,12 +84,13 @@ const (
pkg = "revid-cli:" pkg = "revid-cli:"
) )
// canProfile is set to false with revid-cli is built with "-tags profile". // This is set to true if the 'profile' build tag is provided on build.
var canProfile = true var canProfile = false
func main() { func main() {
mts.Meta = meta.NewWith([][2]string{{metaPreambleKey, metaPreambleData}}) mts.Meta = meta.NewWith([][2]string{{metaPreambleKey, metaPreambleData}})
// Create lumberjack logger to handle logging to file.
fileLog := &lumberjack.Logger{ fileLog := &lumberjack.Logger{
Filename: logPath, Filename: logPath,
MaxSize: logMaxSize, MaxSize: logMaxSize,
@ -93,10 +98,14 @@ func main() {
MaxAge: logMaxAge, MaxAge: logMaxAge,
} }
// Create netlogger to handle logging to cloud.
netLog := netlogger.New() netLog := netlogger.New()
// Create logger that we call methods on to log, which in turn writes to the
// lumberjack and netloggers.
log := logger.New(logVerbosity, io.MultiWriter(fileLog, netLog), logSuppress) log := logger.New(logVerbosity, io.MultiWriter(fileLog, netLog), logSuppress)
// If rv has been built with the profile tag, then we'll start a CPU profile.
if canProfile { if canProfile {
profile(log) profile(log)
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
@ -112,6 +121,8 @@ func main() {
run(rv, ns, log, netLog) run(rv, ns, log, netLog)
} }
// run starts the main loop. This will run netsender on every pass of the loop
// (sleeping inbetween), check vars, and if changed, update revid as appropriate.
func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.Logger) { func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.Logger) {
var vs int var vs int
for { for {
@ -127,7 +138,7 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
l.Log(logger.Warning, pkg+"Logs could not be sent", "error", err.Error()) l.Log(logger.Warning, pkg+"Logs could not be sent", "error", err.Error())
} }
// If var sum hasn't changed we continue. // If var sum hasn't changed we skip rest of loop.
newVs := ns.VarSum() newVs := ns.VarSum()
if vs == newVs { if vs == newVs {
sleep(ns, l) sleep(ns, l)
@ -142,6 +153,7 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
continue continue
} }
// If first time running loop, i.e. rv == nil, then we create a new Revid.
if rv == nil { if rv == nil {
rv, err = revid.New(config.Config{Logger: l}, ns) rv, err = revid.New(config.Config{Logger: l}, ns)
if err != nil { if err != nil {
@ -151,6 +163,7 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
} }
} }
// Configure revid based on the vars.
err = rv.Update(vars) err = rv.Update(vars)
if err != nil { if err != nil {
l.Log(logger.Warning, pkg+"Couldn't update revid", "error", err.Error()) l.Log(logger.Warning, pkg+"Couldn't update revid", "error", err.Error())
@ -161,7 +174,7 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
switch ns.Mode() { switch ns.Mode() {
case modePaused: case modePaused:
rv.Stop() rv.Stop()
case modeNormal: case modeNormal, modeLoop:
err = rv.Start() err = rv.Start()
if err != nil { if err != nil {
l.Log(logger.Warning, pkg+"could not start revid", "error", err.Error()) l.Log(logger.Warning, pkg+"could not start revid", "error", err.Error())
@ -182,6 +195,8 @@ func run(rv *revid.Revid, ns *netsender.Sender, l *logger.Logger, nl *netlogger.
} }
} }
// profile opens a file to hold CPU profiling metrics and then starts the
// CPU profiler.
func profile(l *logger.Logger) { func profile(l *logger.Logger) {
f, err := os.Create(profilePath) f, err := os.Create(profilePath)
if err != nil { if err != nil {
@ -192,6 +207,8 @@ func profile(l *logger.Logger) {
} }
} }
// sleep uses a delay to halt the program based on the monitoring period
// netsender parameter (mp) defined in the netsender.conf config.
func sleep(ns *netsender.Sender, l *logger.Logger) { func sleep(ns *netsender.Sender, l *logger.Logger) {
t, err := strconv.Atoi(ns.Param("mp")) t, err := strconv.Atoi(ns.Param("mp"))
if err != nil { if err != nil {
@ -201,6 +218,8 @@ func sleep(ns *netsender.Sender, l *logger.Logger) {
time.Sleep(time.Duration(t) * time.Second) time.Sleep(time.Duration(t) * time.Second)
} }
// readPin provides a callback function of consistent signature for use by
// netsender to retrieve software defined pin values e.g. revid bitrate (X23).
func readPin(rv *revid.Revid) func(pin *netsender.Pin) error { func readPin(rv *revid.Revid) func(pin *netsender.Pin) error {
return func(pin *netsender.Pin) error { return func(pin *netsender.Pin) error {
switch { switch {
@ -218,6 +237,10 @@ func readPin(rv *revid.Revid) func(pin *netsender.Pin) error {
} }
} }
// burst starts revid, waits for time specified in the Config.BurstPeriod
// field, and then stops revid.
//
// TODO: move this functionality to the revid API into a Revid.Burst(time) method.
func burst(l *logger.Logger, r *revid.Revid, s *netsender.Sender) error { func burst(l *logger.Logger, r *revid.Revid, s *netsender.Sender) error {
l.Log(logger.Info, pkg+"starting burst") l.Log(logger.Info, pkg+"starting burst")

View File

@ -1,17 +1,15 @@
// +build profile // +build profile
/* /*
NAME
revid-cli - command line interface for Revid.
DESCRIPTION DESCRIPTION
See Readme.md profile.go provides an init to change canProfile flag to true if profile tag
provided on build.
AUTHORS AUTHORS
Dan Kortschak <dan@ausocean.org> Dan Kortschak <dan@ausocean.org>
LICENSE LICENSE
revid-cli is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean) Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the
@ -32,5 +30,5 @@ package main
import _ "net/http/pprof" import _ "net/http/pprof"
func init() { func init() {
canProfile = false canProfile = true
} }

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
REVIDPATH=$HOME/go/src/bitbucket.org/ausocean/av/cmd/revid-cli REVIDPATH=$HOME/go/src/bitbucket.org/ausocean/av/cmd/rv
cd $REVIDPATH cd $REVIDPATH
sudo "PATH=$PATH:$REVIDPATH" ./revid-cli -NetSender & sudo "PATH=$PATH:$REVIDPATH" ./rv &

BIN
cmd/rv/rv

Binary file not shown.

View File

View File

@ -30,12 +30,12 @@ const numCodecs = 5
// A global list containing all available codecs for reference in any application. // A global list containing all available codecs for reference in any application.
// When adding or removing a codec from this list, the numCodecs const must be updated. // When adding or removing a codec from this list, the numCodecs const must be updated.
const ( const (
CodecUndef = iota Undef = iota
CodecPCM PCM
CodecADPCM ADPCM
CodecH264 H264
CodecH265 H265
CodecMJPEG MJPEG
) )
// IsValid recieves an int representing a codec and checks if it is valid. // IsValid recieves an int representing a codec and checks if it is valid.

View File

@ -70,7 +70,7 @@ type Buffer struct {
// DataSize takes audio attributes describing audio data and returns the size of that data. // DataSize takes audio attributes describing audio data and returns the size of that data.
func DataSize(rate, channels, bitDepth int, period float64, codec uint8) int { func DataSize(rate, channels, bitDepth int, period float64, codec uint8) int {
s := int(float64(channels) * float64(rate) * float64(bitDepth/8) * period) s := int(float64(channels) * float64(rate) * float64(bitDepth/8) * period)
if codec == codecutil.CodecADPCM { if codec == codecutil.ADPCM {
s = adpcm.EncBytes(s) s = adpcm.EncBytes(s)
} }
return s return s

View File

@ -421,8 +421,8 @@ func (d *ALSA) formatBuffer() pcm.Buffer {
} }
switch d.Codec { switch d.Codec {
case codecutil.CodecPCM: case codecutil.PCM:
case codecutil.CodecADPCM: case codecutil.ADPCM:
b := bytes.NewBuffer(make([]byte, 0, adpcm.EncBytes(len(formatted.Data)))) b := bytes.NewBuffer(make([]byte, 0, adpcm.EncBytes(len(formatted.Data))))
enc := adpcm.NewEncoder(b) enc := adpcm.NewEncoder(b)
_, err = enc.Write(formatted.Data) _, err = enc.Write(formatted.Data)

View File

@ -44,7 +44,7 @@ func TestDevice(t *testing.T) {
Channels: 1, Channels: 1,
RecPeriod: 0.3, RecPeriod: 0.3,
BitDepth: 16, BitDepth: 16,
InputCodec: codecutil.CodecADPCM, InputCodec: codecutil.ADPCM,
} }
n := 2 // Number of periods to wait while recording. n := 2 // Number of periods to wait while recording.

View File

@ -63,7 +63,7 @@ const (
// Configuration defaults. // Configuration defaults.
const ( const (
defaultCameraIP = "192.168.1.50" defaultCameraIP = "192.168.1.50"
defaultCodec = codecutil.CodecH264 defaultCodec = codecutil.H264
defaultHeight = 720 defaultHeight = 720
defaultFrameRate = 25 defaultFrameRate = 25
defaultBitrate = 400 defaultBitrate = 400
@ -115,7 +115,7 @@ func (g *GeoVision) Set(c avconfig.Config) error {
} }
switch c.InputCodec { switch c.InputCodec {
case codecutil.CodecH264, codecutil.CodecH265, codecutil.CodecMJPEG: case codecutil.H264, codecutil.H265, codecutil.MJPEG:
default: default:
errs = append(errs, errGVBadCodec) errs = append(errs, errGVBadCodec)
c.InputCodec = defaultCodec c.InputCodec = defaultCodec
@ -171,9 +171,9 @@ func (g *GeoVision) Set(c avconfig.Config) error {
gvconfig.Channel(g.cfg.CameraChan), gvconfig.Channel(g.cfg.CameraChan),
gvconfig.CodecOut( gvconfig.CodecOut(
map[uint8]gvconfig.Codec{ map[uint8]gvconfig.Codec{
codecutil.CodecH264: gvconfig.CodecH264, codecutil.H264: gvconfig.CodecH264,
codecutil.CodecH265: gvconfig.CodecH265, codecutil.H265: gvconfig.CodecH265,
codecutil.CodecMJPEG: gvconfig.CodecMJPEG, codecutil.MJPEG: gvconfig.CodecMJPEG,
}[g.cfg.InputCodec], }[g.cfg.InputCodec],
), ),
gvconfig.Height(int(g.cfg.Height)), gvconfig.Height(int(g.cfg.Height)),

View File

@ -44,7 +44,7 @@ const pkg = "raspivid: "
// Raspivid configuration defaults. // Raspivid configuration defaults.
const ( const (
defaultRaspividCodec = codecutil.CodecH264 defaultRaspividCodec = codecutil.H264
defaultRaspividRotation = 0 defaultRaspividRotation = 0
defaultRaspividWidth = 1280 defaultRaspividWidth = 1280
defaultRaspividHeight = 720 defaultRaspividHeight = 720
@ -133,7 +133,7 @@ func (r *Raspivid) Name() string {
func (r *Raspivid) Set(c config.Config) error { func (r *Raspivid) Set(c config.Config) error {
var errs device.MultiError var errs device.MultiError
switch c.InputCodec { switch c.InputCodec {
case codecutil.CodecH264, codecutil.CodecMJPEG: case codecutil.H264, codecutil.MJPEG:
default: default:
c.InputCodec = defaultRaspividCodec c.InputCodec = defaultRaspividCodec
errs = append(errs, errBadCodec) errs = append(errs, errBadCodec)
@ -236,7 +236,7 @@ func (r *Raspivid) Start() error {
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
default: default:
return fmt.Errorf("revid: invalid input codec: %v", r.cfg.InputCodec) return fmt.Errorf("revid: invalid input codec: %v", r.cfg.InputCodec)
case codecutil.CodecH264: case codecutil.H264:
args = append(args, args = append(args,
"--codec", "H264", "--codec", "H264",
"--inline", "--inline",
@ -245,7 +245,7 @@ func (r *Raspivid) Start() error {
if !r.cfg.CBR { if !r.cfg.CBR {
args = append(args, "-qp", fmt.Sprint(r.cfg.Quantization)) args = append(args, "-qp", fmt.Sprint(r.cfg.Quantization))
} }
case codecutil.CodecMJPEG: case codecutil.MJPEG:
args = append(args, "--codec", "MJPEG") args = append(args, "--codec", "MJPEG")
} }
r.cfg.Logger.Log(logger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " ")) r.cfg.Logger.Log(logger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " "))

View File

@ -131,13 +131,13 @@ func (w *Webcam) Start() error {
switch w.cfg.InputCodec { switch w.cfg.InputCodec {
default: default:
return fmt.Errorf("revid: invalid input codec: %v", w.cfg.InputCodec) return fmt.Errorf("revid: invalid input codec: %v", w.cfg.InputCodec)
case codecutil.CodecH264: case codecutil.H264:
args = append(args, args = append(args,
"-f", "h264", "-f", "h264",
"-maxrate", fmt.Sprint(br), "-maxrate", fmt.Sprint(br),
"-bufsize", fmt.Sprint(br/2), "-bufsize", fmt.Sprint(br/2),
) )
case codecutil.CodecMJPEG: case codecutil.MJPEG:
args = append(args, args = append(args,
"-f", "mjpeg", "-f", "mjpeg",
) )

View File

@ -42,9 +42,9 @@ func (r *Revid) setupAudio() error {
mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth)) mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth))
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecPCM: case codecutil.PCM:
mts.Meta.Add("codec", "pcm") mts.Meta.Add("codec", "pcm")
case codecutil.CodecADPCM: case codecutil.ADPCM:
mts.Meta.Add("codec", "adpcm") mts.Meta.Add("codec", "adpcm")
default: default:
r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config") r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config")

View File

@ -74,7 +74,7 @@ const (
defaultInput = InputRaspivid defaultInput = InputRaspivid
defaultOutput = OutputHTTP defaultOutput = OutputHTTP
defaultTimeout = 0 defaultTimeout = 0
defaultInputCodec = codecutil.CodecH264 defaultInputCodec = codecutil.H264
defaultVerbosity = logger.Error defaultVerbosity = logger.Error
defaultRtpAddr = "localhost:6970" defaultRtpAddr = "localhost:6970"
defaultCameraIP = "192.168.1.50" defaultCameraIP = "192.168.1.50"
@ -83,7 +83,7 @@ const (
defaultFrameRate = 25 defaultFrameRate = 25
defaultWriteRate = 25 defaultWriteRate = 25
defaultClipDuration = 0 defaultClipDuration = 0
defaultAudioInputCodec = codecutil.CodecADPCM defaultAudioInputCodec = codecutil.ADPCM
defaultPSITime = 2 defaultPSITime = 2
defaultMotionInterval = 5 defaultMotionInterval = 5
defaultFileFPS = 0 defaultFileFPS = 0
@ -392,7 +392,7 @@ func (c *Config) Validate() error {
} }
switch c.InputCodec { switch c.InputCodec {
case codecutil.CodecH264, codecutil.CodecMJPEG, codecutil.CodecPCM, codecutil.CodecADPCM: case codecutil.H264, codecutil.MJPEG, codecutil.PCM, codecutil.ADPCM:
default: default:
switch c.Input { switch c.Input {
case OutputAudio: case OutputAudio:

View File

@ -176,9 +176,9 @@ func (r *Revid) reset(c config.Config) error {
switch r.cfg.Input { switch r.cfg.Input {
case config.InputRaspivid: case config.InputRaspivid:
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
st = mts.EncodeH264 st = mts.EncodeH264
case codecutil.CodecMJPEG: case codecutil.MJPEG:
st = mts.EncodeMJPEG st = mts.EncodeMJPEG
encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second)) encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second))
r.cfg.CBR = true r.cfg.CBR = true
@ -187,9 +187,9 @@ func (r *Revid) reset(c config.Config) error {
} }
case config.InputFile, config.InputV4L: case config.InputFile, config.InputV4L:
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
st = mts.EncodeH264 st = mts.EncodeH264
case codecutil.CodecMJPEG: case codecutil.MJPEG:
st = mts.EncodeMJPEG st = mts.EncodeMJPEG
encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second)) encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second))
r.cfg.CBR = true r.cfg.CBR = true
@ -198,11 +198,11 @@ func (r *Revid) reset(c config.Config) error {
} }
case config.InputRTSP: case config.InputRTSP:
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH265: case codecutil.H265:
st = mts.EncodeH265 st = mts.EncodeH265
case codecutil.CodecH264: case codecutil.H264:
st = mts.EncodeH264 st = mts.EncodeH264
case codecutil.CodecMJPEG: case codecutil.MJPEG:
st = mts.EncodeMJPEG st = mts.EncodeMJPEG
encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second)) encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second))
r.cfg.CBR = true r.cfg.CBR = true
@ -361,27 +361,27 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
r.input = raspivid.New(r.cfg.Logger) r.input = raspivid.New(r.cfg.Logger)
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
r.lexTo = h264.Lex r.lexTo = h264.Lex
case codecutil.CodecMJPEG: case codecutil.MJPEG:
r.lexTo = mjpeg.Lex r.lexTo = mjpeg.Lex
} }
case config.InputV4L: case config.InputV4L:
r.input = webcam.New(r.cfg.Logger) r.input = webcam.New(r.cfg.Logger)
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
r.lexTo = h264.Lex r.lexTo = h264.Lex
case codecutil.CodecMJPEG: case codecutil.MJPEG:
r.lexTo = mjpeg.Lex r.lexTo = mjpeg.Lex
} }
case config.InputFile: case config.InputFile:
r.input = file.New() r.input = file.New()
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
r.lexTo = h264.Lex r.lexTo = h264.Lex
case codecutil.CodecMJPEG: case codecutil.MJPEG:
r.lexTo = mjpeg.Lex r.lexTo = mjpeg.Lex
} }
@ -389,11 +389,11 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
r.input = geovision.New(r.cfg.Logger) r.input = geovision.New(r.cfg.Logger)
switch r.cfg.InputCodec { switch r.cfg.InputCodec {
case codecutil.CodecH264: case codecutil.H264:
r.lexTo = h264.NewExtractor().Extract r.lexTo = h264.NewExtractor().Extract
case codecutil.CodecH265: case codecutil.H265:
r.lexTo = h265.NewLexer(false).Lex r.lexTo = h265.NewLexer(false).Lex
case codecutil.CodecMJPEG: case codecutil.MJPEG:
r.lexTo = mjpeg.NewExtractor().Extract r.lexTo = mjpeg.NewExtractor().Extract
} }
@ -540,9 +540,9 @@ func (r *Revid) Update(vars map[string]string) error {
case "InputCodec": case "InputCodec":
switch value { switch value {
case "H264": case "H264":
r.cfg.InputCodec = codecutil.CodecH264 r.cfg.InputCodec = codecutil.H264
case "MJPEG": case "MJPEG":
r.cfg.InputCodec = codecutil.CodecMJPEG r.cfg.InputCodec = codecutil.MJPEG
default: default:
r.cfg.Logger.Log(logger.Warning, pkg+"invalid InputCodec variable value", "value", value) r.cfg.Logger.Log(logger.Warning, pkg+"invalid InputCodec variable value", "value", value)
} }