diff --git a/device/raspivid/raspivid.go b/device/raspivid/raspivid.go index 3c5ba7bc..baf1a148 100644 --- a/device/raspivid/raspivid.go +++ b/device/raspivid/raspivid.go @@ -35,6 +35,7 @@ import ( "bitbucket.org/ausocean/av/device" "bitbucket.org/ausocean/av/revid/config" "bitbucket.org/ausocean/utils/logger" + "bitbucket.org/ausocean/utils/sliceutils" ) // To indicate package when logging. @@ -180,12 +181,12 @@ func (r *Raspivid) Set(c config.Config) error { c.Saturation = defaultRaspividSaturation } - if c.Exposure == "" || !stringInSlice(c.Exposure, ExposureModes[:]) { + if c.Exposure == "" || !sliceutils.ContainsString(ExposureModes[:], c.Exposure) { errs = append(errs, errBadExposure) c.Exposure = defaultRaspividExposure } - if c.AutoWhiteBalance == "" || !stringInSlice(c.AutoWhiteBalance, AutoWhiteBalanceModes[:]) { + if c.AutoWhiteBalance == "" || !sliceutils.ContainsString(AutoWhiteBalanceModes[:], c.AutoWhiteBalance) { errs = append(errs, errBadAutoWhiteBalance) c.AutoWhiteBalance = defaultRaspividAutoWhiteBalance } @@ -277,13 +278,3 @@ func (r *Raspivid) Stop() error { } return r.out.Close() } - -// stringInSlice returns true if want is in slice. -func stringInSlice(want string, slice []string) bool { - for _, s := range slice { - if s == want { - return true - } - } - return false -}