av/revid/config/parameter/parameters.go

918 lines
18 KiB
Go
Raw Normal View History

/*
DESCRIPTION
Code generated by "go run generate_parameters.go; DO NOT EDIT.
parameters.go contains implementations of the Parameter interface for all
parameter types required by the configuration struct.
AUTHORS
Saxon Nelson-Milton <saxon@ausocean.org>
LICENSE
Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
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
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
// Package parameter is autogenerated code for config parameters - DO NOT EDIT.
package parameter
import (
"fmt"
"strconv"
"strings"
"time"
)
type Parameter interface {
Type() string
Set(val string) error
}
type AutoWhiteBalance uint8
const (
AutoWhiteBalanceOff AutoWhiteBalance = iota
AutoWhiteBalanceAuto
AutoWhiteBalanceSun
AutoWhiteBalanceCloud
AutoWhiteBalanceShade
AutoWhiteBalanceTungsten
AutoWhiteBalanceFluorescent
AutoWhiteBalanceIncandescent
AutoWhiteBalanceFlash
AutoWhiteBalanceHorizon
)
func (a *AutoWhiteBalance) Type() string {
return "enum:Off,Auto,Sun,Cloud,Shade,Tungsten,Fluorescent,Incandescent,Flash,Horizon"
}
func (a *AutoWhiteBalance) Set(val string) error {
switch val {
case "Off":
*a = AutoWhiteBalanceOff
case "Auto":
*a = AutoWhiteBalanceAuto
case "Sun":
*a = AutoWhiteBalanceSun
case "Cloud":
*a = AutoWhiteBalanceCloud
case "Shade":
*a = AutoWhiteBalanceShade
case "Tungsten":
*a = AutoWhiteBalanceTungsten
case "Fluorescent":
*a = AutoWhiteBalanceFluorescent
case "Incandescent":
*a = AutoWhiteBalanceIncandescent
case "Flash":
*a = AutoWhiteBalanceFlash
case "Horizon":
*a = AutoWhiteBalanceHorizon
default:
return fmt.Errorf("unrecognised AutoWhiteBalance: %s", val)
}
return nil
}
type BitDepth uint
func (b *BitDepth) Type() string { return "uint" }
func (b *BitDepth) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*b = BitDepth(_v)
return nil
}
type Bitrate uint
func (b *Bitrate) Type() string { return "uint" }
func (b *Bitrate) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1000 || _v > 10000000 {
return fmt.Errorf("invalid value %v", _v)
}
*b = Bitrate(_v)
return nil
}
type Brightness uint
func (b *Brightness) Type() string { return "uint" }
func (b *Brightness) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 0 || _v > 100 {
return fmt.Errorf("invalid value %v", _v)
}
*b = Brightness(_v)
return nil
}
type BurstPeriod time.Duration
func (b *BurstPeriod) Type() string { return "time.Duration" }
func (b *BurstPeriod) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*b = BurstPeriod(time.Duration(_v) * time.Second)
return nil
}
type CBR bool
func (c *CBR) Type() string { return "bool" }
func (c *CBR) Set(val string) error {
switch val {
case "true":
*c = true
case "false":
*c = false
default:
return fmt.Errorf("not boolean value: %s", val)
}
return nil
}
type CameraChan uint8
const (
CameraChanChannel1 CameraChan = iota
CameraChanChannel2
)
func (c *CameraChan) Type() string { return "enum:Channel1,Channel2" }
func (c *CameraChan) Set(val string) error {
switch val {
case "Channel1":
*c = CameraChanChannel1
case "Channel2":
*c = CameraChanChannel2
default:
return fmt.Errorf("unrecognised CameraChan: %s", val)
}
return nil
}
type CameraIP string
func (c *CameraIP) Type() string { return "string" }
func (c *CameraIP) Set(val string) error {
*c = CameraIP(val)
return nil
}
type Channels uint
func (c *Channels) Type() string { return "uint" }
func (c *Channels) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*c = Channels(_v)
return nil
}
type ClipDuration time.Duration
func (c *ClipDuration) Type() string { return "time.Duration" }
func (c *ClipDuration) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*c = ClipDuration(time.Duration(_v) * time.Second)
return nil
}
type Codec uint8
const (
CodecH264 Codec = iota
CodecH265
CodecMJPEG
CodecPCM
CodecADPCM
)
func (c *Codec) Type() string { return "enum:H264,H265,MJPEG,PCM,ADPCM" }
func (c *Codec) Set(val string) error {
switch val {
case "H264":
*c = CodecH264
case "H265":
*c = CodecH265
case "MJPEG":
*c = CodecMJPEG
case "PCM":
*c = CodecPCM
case "ADPCM":
*c = CodecADPCM
default:
return fmt.Errorf("unrecognised Codec: %s", val)
}
return nil
}
type Exposure uint8
const (
ExposureAuto Exposure = iota
ExposureNight
ExposureNightPreview
ExposureBackLight
ExposureSpotLight
ExposureSports
ExposureSnow
ExposureBeach
ExposureVeryLong
ExposureFixedFPS
ExposureAntiShake
ExposureFireworks
)
func (e *Exposure) Type() string {
return "enum:Auto,Night,NightPreview,BackLight,SpotLight,Sports,Snow,Beach,VeryLong,FixedFPS,AntiShake,Fireworks"
}
func (e *Exposure) Set(val string) error {
switch val {
case "Auto":
*e = ExposureAuto
case "Night":
*e = ExposureNight
case "NightPreview":
*e = ExposureNightPreview
case "BackLight":
*e = ExposureBackLight
case "SpotLight":
*e = ExposureSpotLight
case "Sports":
*e = ExposureSports
case "Snow":
*e = ExposureSnow
case "Beach":
*e = ExposureBeach
case "VeryLong":
*e = ExposureVeryLong
case "FixedFPS":
*e = ExposureFixedFPS
case "AntiShake":
*e = ExposureAntiShake
case "Fireworks":
*e = ExposureFireworks
default:
return fmt.Errorf("unrecognised Exposure: %s", val)
}
return nil
}
type FileFPS uint
func (f *FileFPS) Type() string { return "uint" }
func (f *FileFPS) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1 || _v > 30 {
return fmt.Errorf("invalid value %v", _v)
}
*f = FileFPS(_v)
return nil
}
type Filter uint8
const (
FilterNoOp Filter = iota
FilterMOG
FilterVariableFPS
FilterKNN
FilterDifference
FilterBasic
)
func (f *Filter) Type() string { return "enum:NoOp,MOG,VariableFPS,KNN,Difference,Basic" }
func (f *Filter) Set(val string) error {
switch val {
case "NoOp":
*f = FilterNoOp
case "MOG":
*f = FilterMOG
case "VariableFPS":
*f = FilterVariableFPS
case "KNN":
*f = FilterKNN
case "Difference":
*f = FilterDifference
case "Basic":
*f = FilterBasic
default:
return fmt.Errorf("unrecognised Filter: %s", val)
}
return nil
}
type FrameRate uint
func (f *FrameRate) Type() string { return "uint" }
func (f *FrameRate) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1 || _v > 30 {
return fmt.Errorf("invalid value %v", _v)
}
*f = FrameRate(_v)
return nil
}
type HTTPAddress string
func (h *HTTPAddress) Type() string { return "string" }
func (h *HTTPAddress) Set(val string) error {
*h = HTTPAddress(val)
return nil
}
type Height uint
func (h *Height) Type() string { return "uint" }
func (h *Height) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 360 || _v > 1080 {
return fmt.Errorf("invalid value %v", _v)
}
*h = Height(_v)
return nil
}
type HorizontalFlip bool
func (h *HorizontalFlip) Type() string { return "bool" }
func (h *HorizontalFlip) Set(val string) error {
switch val {
case "true":
*h = true
case "false":
*h = false
default:
return fmt.Errorf("not boolean value: %s", val)
}
return nil
}
type Input uint8
const (
InputFile Input = iota
InputRaspivid
InputWebcam
InputRTSP
)
func (i *Input) Type() string { return "enum:File,Raspivid,Webcam,RTSP" }
func (i *Input) Set(val string) error {
switch val {
case "File":
*i = InputFile
case "Raspivid":
*i = InputRaspivid
case "Webcam":
*i = InputWebcam
case "RTSP":
*i = InputRTSP
default:
return fmt.Errorf("unrecognised Input: %s", val)
}
return nil
}
type InputPath string
func (i *InputPath) Type() string { return "string" }
func (i *InputPath) Set(val string) error {
*i = InputPath(val)
return nil
}
type Level uint8
const (
LevelDebug Level = iota
LevelInfo
LevelWarning
LevelError
LevelFatal
)
func (l *Level) Type() string { return "enum:Debug,Info,Warning,Error,Fatal" }
func (l *Level) Set(val string) error {
switch val {
case "Debug":
*l = LevelDebug
case "Info":
*l = LevelInfo
case "Warning":
*l = LevelWarning
case "Error":
*l = LevelError
case "Fatal":
*l = LevelFatal
default:
return fmt.Errorf("unrecognised Level: %s", val)
}
return nil
}
type MinFPS uint
func (m *MinFPS) Type() string { return "uint" }
func (m *MinFPS) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1 || _v > 30 {
return fmt.Errorf("invalid value %v", _v)
}
*m = MinFPS(_v)
return nil
}
type MinFrames uint
func (m *MinFrames) Type() string { return "uint" }
func (m *MinFrames) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 0 || _v > 1000 {
return fmt.Errorf("invalid value %v", _v)
}
*m = MinFrames(_v)
return nil
}
type Mode uint8
const (
ModeNormal Mode = iota
ModePaused
ModeBurst
ModeLoop
)
func (m *Mode) Type() string { return "enum:Normal,Paused,Burst,Loop" }
func (m *Mode) Set(val string) error {
switch val {
case "Normal":
*m = ModeNormal
case "Paused":
*m = ModePaused
case "Burst":
*m = ModeBurst
case "Loop":
*m = ModeLoop
default:
return fmt.Errorf("unrecognised Mode: %s", val)
}
return nil
}
type MotionDownscaling uint
func (m *MotionDownscaling) Type() string { return "uint" }
func (m *MotionDownscaling) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*m = MotionDownscaling(_v)
return nil
}
type MotionHistory uint
func (m *MotionHistory) Type() string { return "uint" }
func (m *MotionHistory) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*m = MotionHistory(_v)
return nil
}
type MotionInterval uint
func (m *MotionInterval) Type() string { return "uint" }
func (m *MotionInterval) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 0 || _v > 30 {
return fmt.Errorf("invalid value %v", _v)
}
*m = MotionInterval(_v)
return nil
}
type MotionKernel uint
func (m *MotionKernel) Type() string { return "uint" }
func (m *MotionKernel) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*m = MotionKernel(_v)
return nil
}
type MotionMinArea float64
func (m *MotionMinArea) Type() string { return "float64" }
func (m *MotionMinArea) Set(val string) error {
_v, err := strconv.ParseFloat(val, 64)
if err != nil {
return fmt.Errorf("could not convert set string to float: %w", err)
}
*m = MotionMinArea(_v)
return nil
}
type MotionPixels uint
func (m *MotionPixels) Type() string { return "uint" }
func (m *MotionPixels) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*m = MotionPixels(_v)
return nil
}
type MotionThreshold float64
func (m *MotionThreshold) Type() string { return "float64" }
func (m *MotionThreshold) Set(val string) error {
_v, err := strconv.ParseFloat(val, 64)
if err != nil {
return fmt.Errorf("could not convert set string to float: %w", err)
}
*m = MotionThreshold(_v)
return nil
}
type Output uint8
const (
OutputHTTP Output = iota
OutputRTMP
OutputRTP
OutputFile
)
func (o *Output) Type() string { return "enum:HTTP,RTMP,RTP,File" }
func (o *Output) Set(val string) error {
switch val {
case "HTTP":
*o = OutputHTTP
case "RTMP":
*o = OutputRTMP
case "RTP":
*o = OutputRTP
case "File":
*o = OutputFile
default:
return fmt.Errorf("unrecognised Output: %s", val)
}
return nil
}
type OutputPath string
func (o *OutputPath) Type() string { return "string" }
func (o *OutputPath) Set(val string) error {
*o = OutputPath(val)
return nil
}
type Outputs []Output
func (o *Outputs) Type() string { return "enum:HTTP,RTMP,RTP,File" }
func (o *Outputs) Set(val string) error {
vals := strings.Split(val, ",")
*o = make([]Output, len(vals))
for i, v := range vals {
switch v {
case "HTTP":
(*o)[i] = OutputHTTP
case "RTMP":
(*o)[i] = OutputRTMP
case "RTP":
(*o)[i] = OutputRTP
case "File":
(*o)[i] = OutputFile
default:
return fmt.Errorf("unrecognised Outputs: %s", val)
}
}
return nil
}
type PSITime time.Duration
func (p *PSITime) Type() string { return "time.Duration" }
func (p *PSITime) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*p = PSITime(time.Duration(_v) * time.Second)
return nil
}
type Quantization uint
func (q *Quantization) Type() string { return "uint" }
func (q *Quantization) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*q = Quantization(_v)
return nil
}
type PoolCapacity uint
func (r *PoolCapacity) Type() string { return "uint" }
func (r *PoolCapacity) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1000000 || _v > 100000000 {
return fmt.Errorf("invalid value %v", _v)
}
*r = PoolCapacity(_v)
return nil
}
type PoolMaxElements uint
func (r *PoolMaxElements) Type() string { return "uint" }
func (r *PoolMaxElements) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 0 || _v > 4294967295 {
return fmt.Errorf("invalid value %v", _v)
}
*r = PoolMaxElements(_v)
return nil
}
type PoolWriteTimeout time.Duration
func (r *PoolWriteTimeout) Type() string { return "time.Duration" }
func (r *PoolWriteTimeout) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*r = PoolWriteTimeout(time.Duration(_v) * time.Second)
return nil
}
type RTMPURL string
func (r *RTMPURL) Type() string { return "string" }
func (r *RTMPURL) Set(val string) error {
*r = RTMPURL(val)
return nil
}
type RTPAddress string
func (r *RTPAddress) Type() string { return "string" }
func (r *RTPAddress) Set(val string) error {
*r = RTPAddress(val)
return nil
}
type RecPeriod float64
func (r *RecPeriod) Type() string { return "float64" }
func (r *RecPeriod) Set(val string) error {
_v, err := strconv.ParseFloat(val, 64)
if err != nil {
return fmt.Errorf("could not convert set string to float: %w", err)
}
*r = RecPeriod(_v)
return nil
}
type Rotation uint
func (r *Rotation) Type() string { return "uint" }
func (r *Rotation) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 0 || _v > 359 {
return fmt.Errorf("invalid value %v", _v)
}
*r = Rotation(_v)
return nil
}
type SampleRate uint
func (s *SampleRate) Type() string { return "uint" }
func (s *SampleRate) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
*s = SampleRate(_v)
return nil
}
type Saturation int
func (s *Saturation) Type() string { return "int" }
func (s *Saturation) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < -50 || _v > 50 {
return fmt.Errorf("invalid value %v", _v)
}
*s = Saturation(_v)
return nil
}
type ShowWindows bool
func (s *ShowWindows) Type() string { return "bool" }
func (s *ShowWindows) Set(val string) error {
switch val {
case "true":
*s = true
case "false":
*s = false
default:
return fmt.Errorf("not boolean value: %s", val)
}
return nil
}
type VBRBitrate uint
func (v *VBRBitrate) Type() string { return "uint" }
func (v *VBRBitrate) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 1 || _v > 30 {
return fmt.Errorf("invalid value %v", _v)
}
*v = VBRBitrate(_v)
return nil
}
type VBRQuality uint8
const (
VBRQualityStandard VBRQuality = iota
VBRQualityFair
VBRQualityGood
VBRQualityGreat
VBRQualityExcellent
)
func (v *VBRQuality) Type() string { return "enum:Standard,Fair,Good,Great,Excellent" }
func (v *VBRQuality) Set(val string) error {
switch val {
case "Standard":
*v = VBRQualityStandard
case "Fair":
*v = VBRQualityFair
case "Good":
*v = VBRQualityGood
case "Great":
*v = VBRQualityGreat
case "Excellent":
*v = VBRQualityExcellent
default:
return fmt.Errorf("unrecognised VBRQuality: %s", val)
}
return nil
}
type VerticalFlip bool
func (v *VerticalFlip) Type() string { return "bool" }
func (v *VerticalFlip) Set(val string) error {
switch val {
case "true":
*v = true
case "false":
*v = false
default:
return fmt.Errorf("not boolean value: %s", val)
}
return nil
}
type Width uint
func (w *Width) Type() string { return "uint" }
func (w *Width) Set(val string) error {
_v, err := strconv.Atoi(val)
if err != nil {
return fmt.Errorf("could not convert set string to int: %w", err)
}
if _v < 640 || _v > 1920 {
return fmt.Errorf("invalid value %v", _v)
}
*w = Width(_v)
return nil
}