mirror of https://bitbucket.org/ausocean/av.git
Merge branch 'master' into channel-and-rate-conversion
This commit is contained in:
commit
72f0b009fe
|
@ -129,6 +129,10 @@ func handleFlags() revid.Config {
|
|||
quantizationPtr = flag.Uint("Quantization", 0, "Desired quantization value: 0-40")
|
||||
intraRefreshPeriodPtr = flag.Uint("IntraRefreshPeriod", 0, "The IntraRefreshPeriod i.e. how many keyframes we send")
|
||||
rotationPtr = flag.Uint("Rotatation", 0, "Rotate video output. (0-359 degrees)")
|
||||
brightnessPtr = flag.Uint("Brightness", 50, "Set brightness. (0-100) ")
|
||||
saturationPtr = flag.Int("Saturation", 0, "Set Saturation. (100-100)")
|
||||
exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(revid.ExposureModes[:], ",")+")")
|
||||
autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(revid.AutoWhiteBalanceModes[:], ",")+")")
|
||||
)
|
||||
|
||||
var outputs flagStrings
|
||||
|
@ -256,6 +260,10 @@ func handleFlags() revid.Config {
|
|||
cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr
|
||||
cfg.RtpAddress = *rtpAddrPtr
|
||||
cfg.SendRetry = *sendRetryPtr
|
||||
cfg.Brightness = *brightnessPtr
|
||||
cfg.Saturation = *saturationPtr
|
||||
cfg.Exposure = *exposurePtr
|
||||
cfg.AutoWhiteBalance = *autoWhiteBalancePtr
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
|
|
@ -70,6 +70,40 @@ type Config struct {
|
|||
SendRetry bool
|
||||
BurstPeriod uint
|
||||
Rotation uint
|
||||
Brightness uint
|
||||
Saturation int
|
||||
Exposure string
|
||||
AutoWhiteBalance string
|
||||
}
|
||||
|
||||
// Possible modes for raspivid --exposure parameter.
|
||||
var ExposureModes = [...]string{
|
||||
"auto",
|
||||
"night",
|
||||
"nightpreview",
|
||||
"backlight",
|
||||
"spotlight",
|
||||
"sports",
|
||||
"snow",
|
||||
"beach",
|
||||
"verylong",
|
||||
"fixedfps",
|
||||
"antishake",
|
||||
"fireworks",
|
||||
}
|
||||
|
||||
// Possible modes for raspivid --awb parameter.
|
||||
var AutoWhiteBalanceModes = [...]string{
|
||||
"off",
|
||||
"auto",
|
||||
"sun",
|
||||
"cloud",
|
||||
"shade",
|
||||
"tungsten",
|
||||
"fluorescent",
|
||||
"incandescent",
|
||||
"flash",
|
||||
"horizon",
|
||||
}
|
||||
|
||||
// Enums for config struct
|
||||
|
@ -118,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
|
||||
|
@ -257,5 +294,44 @@ func (c *Config) Validate(r *Revid) error {
|
|||
if c.RtpAddress == "" {
|
||||
c.RtpAddress = defaultRtpAddr
|
||||
}
|
||||
|
||||
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(pkg + "bad saturation 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")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
|
@ -358,6 +358,22 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
//look through the vars and update revid where needed
|
||||
for key, value := range vars {
|
||||
switch key {
|
||||
case "Saturation":
|
||||
s, err := strconv.ParseInt(value, 10, 0)
|
||||
if err != nil {
|
||||
r.config.Logger.Log(logger.Warning, pkg+"invalid saturation param", "value", value)
|
||||
}
|
||||
r.config.Saturation = int(s)
|
||||
case "Brightness":
|
||||
b, err := strconv.ParseUint(value, 10, 0)
|
||||
if err != nil {
|
||||
r.config.Logger.Log(logger.Warning, pkg+"invalid brightness param", "value", value)
|
||||
}
|
||||
r.config.Brightness = uint(b)
|
||||
case "Exposure":
|
||||
r.config.Exposure = value
|
||||
case "AutoWhiteBalance":
|
||||
r.config.AutoWhiteBalance = value
|
||||
case "Output":
|
||||
outputs := strings.Split(value, ",")
|
||||
r.config.Outputs = make([]uint8, len(outputs))
|
||||
|
@ -594,6 +610,14 @@ func (r *Revid) startRaspivid() error {
|
|||
"--bitrate", fmt.Sprint(r.config.Bitrate),
|
||||
"--framerate", fmt.Sprint(r.config.FrameRate),
|
||||
"--rotation", fmt.Sprint(r.config.Rotation),
|
||||
"--brightness", fmt.Sprint(r.config.Brightness),
|
||||
"--saturation", fmt.Sprint(r.config.Saturation),
|
||||
"--exposure", fmt.Sprint(r.config.Exposure),
|
||||
"--awb", fmt.Sprint(r.config.AutoWhiteBalance),
|
||||
}
|
||||
|
||||
if r.config.FlipHorizontal {
|
||||
args = append(args, "--hflip")
|
||||
}
|
||||
|
||||
if r.config.FlipVertical {
|
||||
|
|
Loading…
Reference in New Issue