mirror of https://bitbucket.org/ausocean/av.git
Merged in config-fix (pull request #174)
revid: improved logic in config.Validate for raspivid options
This commit is contained in:
commit
78894ae972
|
@ -152,6 +152,9 @@ const (
|
|||
defaultRtpAddr = "localhost:6970"
|
||||
defaultBurstPeriod = 10 // Seconds
|
||||
defaultRotation = 0 // Degrees
|
||||
defaultBrightness = 50
|
||||
defaultExposure = "auto"
|
||||
defaultAutoWhiteBalance = "auto"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
if c.Brightness < 0 || c.Brightness > 100 {
|
||||
return errors.New("bad brightness setting in config")
|
||||
switch {
|
||||
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 {
|
||||
return errors.New("bad saturation setting in config")
|
||||
return errors.New(pkg + "bad saturation setting in config")
|
||||
}
|
||||
|
||||
if !stringInSlice(c.Exposure, ExposureModes[:]) {
|
||||
return errors.New("bad exposure setting in config")
|
||||
switch {
|
||||
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[:]) {
|
||||
return errors.New("bad awb setting in config")
|
||||
switch {
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue