mirror of https://bitbucket.org/ausocean/av.git
revid: fixed case and removed exclamation marks in error/logging messages in config.go
This commit is contained in:
parent
6e773abd4e
commit
108344f882
|
@ -112,32 +112,32 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
case No:
|
case No:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Verbosity = defaultVerbosity
|
c.Verbosity = defaultVerbosity
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No verbosity mode defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no verbosity mode defined, defaulting",
|
||||||
"verbosity", defaultVerbosity)
|
"verbosity", defaultVerbosity)
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad Verbosity defined in config!")
|
return errors.New("bad Verbosity defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.QuantizationMode {
|
switch c.QuantizationMode {
|
||||||
case QuantizationOn:
|
case QuantizationOn:
|
||||||
case QuantizationOff:
|
case QuantizationOff:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No quantization mode defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no quantization mode defined, defaulting",
|
||||||
"quantizationMode", QuantizationOff)
|
"quantizationMode", QuantizationOff)
|
||||||
c.QuantizationMode = QuantizationOff
|
c.QuantizationMode = QuantizationOff
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad QuantizationMode defined in config!")
|
return errors.New("bad QuantizationMode defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.Input {
|
switch c.Input {
|
||||||
case Raspivid:
|
case Raspivid:
|
||||||
case File:
|
case File:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No input type defined, defaulting", "input",
|
c.Logger.Log(smartlogger.Warning, pkg+"no input type defined, defaulting", "input",
|
||||||
defaultInput)
|
defaultInput)
|
||||||
c.Input = defaultInput
|
c.Input = defaultInput
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad input type defined in config!")
|
return errors.New("bad input type defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.InputCodec {
|
switch c.InputCodec {
|
||||||
|
@ -145,59 +145,59 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
if c.Bitrate != "" && c.Quantization != "" {
|
if c.Bitrate != "" && c.Quantization != "" {
|
||||||
bitrate, err := strconv.Atoi(c.Bitrate)
|
bitrate, err := strconv.Atoi(c.Bitrate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Something is wrong with bitrate in conig!")
|
return errors.New("something is wrong with bitrate in config")
|
||||||
}
|
}
|
||||||
quantization, err := strconv.Atoi(c.Quantization)
|
quantization, err := strconv.Atoi(c.Quantization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Something is wrong with quantization in config!")
|
return errors.New("something is wrong with quantization in config")
|
||||||
}
|
}
|
||||||
if (bitrate > 0 && quantization > 0) || (bitrate == 0 && quantization == 0) {
|
if (bitrate > 0 && quantization > 0) || (bitrate == 0 && quantization == 0) {
|
||||||
return errors.New("Bad bitrate and quantization combination for H264 input!")
|
return errors.New("bad bitrate and quantization combination for H264 input")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Mjpeg:
|
case Mjpeg:
|
||||||
if c.Quantization != "" {
|
if c.Quantization != "" {
|
||||||
quantization, err := strconv.Atoi(c.Quantization)
|
quantization, err := strconv.Atoi(c.Quantization)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("Something is wrong with quantization in config!")
|
return errors.New("something is wrong with quantization in config")
|
||||||
}
|
}
|
||||||
if quantization > 0 || c.Bitrate == "" {
|
if quantization > 0 || c.Bitrate == "" {
|
||||||
return errors.New("Bad bitrate or quantization for mjpeg input!")
|
return errors.New("bad bitrate or quantization for mjpeg input")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No input codec defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no input codec defined, defaulting",
|
||||||
"inputCodec", defaultInputCodec)
|
"inputCodec", defaultInputCodec)
|
||||||
c.InputCodec = defaultInputCodec
|
c.InputCodec = defaultInputCodec
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"Defaulting quantization", "quantization",
|
c.Logger.Log(smartlogger.Warning, pkg+"defaulting quantization", "quantization",
|
||||||
defaultQuantization)
|
defaultQuantization)
|
||||||
c.Quantization = defaultQuantization
|
c.Quantization = defaultQuantization
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad input codec defined in config!")
|
return errors.New("bad input codec defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.Output {
|
switch c.Output {
|
||||||
case File:
|
case File:
|
||||||
case Rtmp, FfmpegRtmp:
|
case Rtmp, FfmpegRtmp:
|
||||||
if c.RtmpUrl == "" {
|
if c.RtmpUrl == "" {
|
||||||
c.Logger.Log(smartlogger.Info, pkg+"No RTMP URL: falling back to HTTP")
|
c.Logger.Log(smartlogger.Info, pkg+"no RTMP URL: falling back to HTTP")
|
||||||
c.Output = Http
|
c.Output = Http
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
c.Logger.Log(smartlogger.Info, pkg+"Defaulting frames per clip for rtmp out",
|
c.Logger.Log(smartlogger.Info, pkg+"defaulting frames per clip for rtmp out",
|
||||||
"framesPerClip", defaultFramesPerClip)
|
"framesPerClip", defaultFramesPerClip)
|
||||||
c.FramesPerClip = defaultFramesPerClip
|
c.FramesPerClip = defaultFramesPerClip
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No output defined, defaulting", "output",
|
c.Logger.Log(smartlogger.Warning, pkg+"no output defined, defaulting", "output",
|
||||||
defaultOutput)
|
defaultOutput)
|
||||||
c.Output = defaultOutput
|
c.Output = defaultOutput
|
||||||
fallthrough
|
fallthrough
|
||||||
case Http:
|
case Http:
|
||||||
c.Logger.Log(smartlogger.Info, pkg+"Defaulting frames per clip for http out",
|
c.Logger.Log(smartlogger.Info, pkg+"defaulting frames per clip for http out",
|
||||||
"framesPerClip", httpFramesPerClip)
|
"framesPerClip", httpFramesPerClip)
|
||||||
c.FramesPerClip = httpFramesPerClip
|
c.FramesPerClip = httpFramesPerClip
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad output type defined in config!")
|
return errors.New("bad output type defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.Packetization {
|
switch c.Packetization {
|
||||||
|
@ -205,107 +205,107 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
case Mpegts:
|
case Mpegts:
|
||||||
case Flv:
|
case Flv:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No packetization option defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no packetization option defined, defaulting",
|
||||||
"packetization", defaultPacketization)
|
"packetization", defaultPacketization)
|
||||||
c.Packetization = defaultPacketization
|
c.Packetization = defaultPacketization
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad packetization option defined in config!")
|
return errors.New("bad packetization option defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.HorizontalFlip {
|
switch c.HorizontalFlip {
|
||||||
case Yes:
|
case Yes:
|
||||||
case No:
|
case No:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No horizontal flip option defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no horizontal flip option defined, defaulting",
|
||||||
"horizontalFlip", defaultHorizontalFlip)
|
"horizontalFlip", defaultHorizontalFlip)
|
||||||
c.HorizontalFlip = defaultHorizontalFlip
|
c.HorizontalFlip = defaultHorizontalFlip
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad horizontal flip option defined in config!")
|
return errors.New("bad horizontal flip option defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.VerticalFlip {
|
switch c.VerticalFlip {
|
||||||
case Yes:
|
case Yes:
|
||||||
case No:
|
case No:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No vertical flip option defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no vertical flip option defined, defaulting",
|
||||||
"verticalFlip", defaultVerticalFlip)
|
"verticalFlip", defaultVerticalFlip)
|
||||||
c.VerticalFlip = defaultVerticalFlip
|
c.VerticalFlip = defaultVerticalFlip
|
||||||
default:
|
default:
|
||||||
return errors.New("Bad vertical flip option defined in config!")
|
return errors.New("bad vertical flip option defined in config")
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.FramesPerClip < 1 {
|
if c.FramesPerClip < 1 {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No FramesPerClip defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no FramesPerClip defined, defaulting",
|
||||||
"framesPerClip", defaultFramesPerClip)
|
"framesPerClip", defaultFramesPerClip)
|
||||||
c.FramesPerClip = defaultFramesPerClip
|
c.FramesPerClip = defaultFramesPerClip
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Width == "" {
|
if c.Width == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No width defined, defaulting", "width",
|
c.Logger.Log(smartlogger.Warning, pkg+"no width defined, defaulting", "width",
|
||||||
defaultWidth)
|
defaultWidth)
|
||||||
c.Width = defaultWidth
|
c.Width = defaultWidth
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.Width); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.Width); integer < 0 || err != nil {
|
||||||
return errors.New("Bad width defined in config!")
|
return errors.New("bad width defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Height == "" {
|
if c.Height == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No height defined, defaulting", "height",
|
c.Logger.Log(smartlogger.Warning, pkg+"no height defined, defaulting", "height",
|
||||||
defaultHeight)
|
defaultHeight)
|
||||||
c.Height = defaultHeight
|
c.Height = defaultHeight
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.Height); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.Height); integer < 0 || err != nil {
|
||||||
return errors.New("Bad height defined in config!")
|
return errors.New("bad height defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.FrameRate == "" {
|
if c.FrameRate == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No frame rate defined, defaulting", "fps",
|
c.Logger.Log(smartlogger.Warning, pkg+"no frame rate defined, defaulting", "fps",
|
||||||
defaultFrameRate)
|
defaultFrameRate)
|
||||||
c.FrameRate = defaultFrameRate
|
c.FrameRate = defaultFrameRate
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.FrameRate); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.FrameRate); integer < 0 || err != nil {
|
||||||
return errors.New("Bad frame rate defined in config!")
|
return errors.New("bad frame rate defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Bitrate == "" {
|
if c.Bitrate == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No bitrate defined, defaulting", "bitrate",
|
c.Logger.Log(smartlogger.Warning, pkg+"no bitrate defined, defaulting", "bitrate",
|
||||||
defaultBitrate)
|
defaultBitrate)
|
||||||
c.Bitrate = defaultBitrate
|
c.Bitrate = defaultBitrate
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.Bitrate); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.Bitrate); integer < 0 || err != nil {
|
||||||
return errors.New("Bad bitrate defined in config!")
|
return errors.New("bad bitrate defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Timeout == "" {
|
if c.Timeout == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No timeout defined, defaulting", "timeout", defaultTimeout)
|
c.Logger.Log(smartlogger.Warning, pkg+"no timeout defined, defaulting", "timeout", defaultTimeout)
|
||||||
c.Timeout = defaultTimeout
|
c.Timeout = defaultTimeout
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.Timeout); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.Timeout); integer < 0 || err != nil {
|
||||||
return errors.New("Bad timeout defined in config!")
|
return errors.New("bad timeout defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IntraRefreshPeriod == "" {
|
if c.IntraRefreshPeriod == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No intra refresh defined, defaulting", "intraRefresh",
|
c.Logger.Log(smartlogger.Warning, pkg+"no intra refresh defined, defaulting", "intraRefresh",
|
||||||
defaultIntraRefreshPeriod)
|
defaultIntraRefreshPeriod)
|
||||||
c.IntraRefreshPeriod = defaultIntraRefreshPeriod
|
c.IntraRefreshPeriod = defaultIntraRefreshPeriod
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.IntraRefreshPeriod); integer < 0 || err != nil {
|
if integer, err := strconv.Atoi(c.IntraRefreshPeriod); integer < 0 || err != nil {
|
||||||
return errors.New("Bad intra refresh defined in config!")
|
return errors.New("bad intra refresh defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Quantization == "" {
|
if c.Quantization == "" {
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"No quantization defined, defaulting", "quantization",
|
c.Logger.Log(smartlogger.Warning, pkg+"no quantization defined, defaulting", "quantization",
|
||||||
defaultQuantization)
|
defaultQuantization)
|
||||||
c.Quantization = defaultQuantization
|
c.Quantization = defaultQuantization
|
||||||
} else {
|
} else {
|
||||||
if integer, err := strconv.Atoi(c.Quantization); integer < 0 || integer > 51 || err != nil {
|
if integer, err := strconv.Atoi(c.Quantization); integer < 0 || integer > 51 || err != nil {
|
||||||
return errors.New("Bad quantization defined in config!")
|
return errors.New("bad quantization defined in config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue