Merge branch 'master' into ringbuffer-move

This commit is contained in:
Saxon 2019-03-18 11:08:01 +10:30
commit 72d0683162
1 changed files with 22 additions and 7 deletions

View File

@ -152,6 +152,9 @@ const (
defaultRtpAddr = "localhost:6970" defaultRtpAddr = "localhost:6970"
defaultBurstPeriod = 10 // Seconds defaultBurstPeriod = 10 // Seconds
defaultRotation = 0 // Degrees defaultRotation = 0 // Degrees
defaultBrightness = 50
defaultExposure = "auto"
defaultAutoWhiteBalance = "auto"
) )
// Validate checks for any errors in the config fields and defaults settings // Validate checks for any errors in the config fields and defaults settings
@ -292,20 +295,32 @@ func (c *Config) Validate(r *Revid) error {
c.RtpAddress = defaultRtpAddr c.RtpAddress = defaultRtpAddr
} }
if c.Brightness < 0 || c.Brightness > 100 { switch {
return errors.New("bad brightness setting in config") case c.Brightness == 0:
c.Logger.Log(logger.Info, pkg+"brightness undefined, defaulting", "brightness", defaultBrightness)
c.Brightness = defaultBrightness
case c.Brightness < 0 || c.Brightness > 100:
return errors.New(pkg + "bad brightness defined in config")
} }
if c.Saturation < -100 || c.Saturation > 100 { if c.Saturation < -100 || c.Saturation > 100 {
return errors.New("bad saturation setting in config") return errors.New(pkg + "bad saturation setting in config")
} }
if !stringInSlice(c.Exposure, ExposureModes[:]) { switch {
return errors.New("bad exposure setting in config") case c.Exposure == "":
c.Logger.Log(logger.Info, pkg+"exposure undefined, defaulting", "exposure", defaultExposure)
c.Exposure = defaultExposure
case !stringInSlice(c.Exposure, ExposureModes[:]):
return errors.New(pkg + "bad exposure setting in config")
} }
if !stringInSlice(c.AutoWhiteBalance, AutoWhiteBalanceModes[:]) { switch {
return errors.New("bad awb setting in config") case c.AutoWhiteBalance == "":
c.Logger.Log(logger.Info, pkg+"auto white balance undefined, defaulting", "autoWhiteBalance", defaultAutoWhiteBalance)
c.AutoWhiteBalance = defaultAutoWhiteBalance
case !stringInSlice(c.AutoWhiteBalance, AutoWhiteBalanceModes[:]):
return errors.New(pkg + "bad auto white balance setting in config")
} }
return nil return nil