mirror of https://bitbucket.org/ausocean/av.git
fixing build errors and testing bugs + removed config_test.go as not relevant anymore
This commit is contained in:
parent
0a059058a1
commit
1a65dc9da4
|
@ -41,6 +41,7 @@ import (
|
|||
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||
"bitbucket.org/ausocean/av/container/mts"
|
||||
"bitbucket.org/ausocean/av/container/mts/meta"
|
||||
"bitbucket.org/ausocean/av/device/raspivid"
|
||||
"bitbucket.org/ausocean/av/revid"
|
||||
"bitbucket.org/ausocean/av/revid/config"
|
||||
"bitbucket.org/ausocean/iot/pi/netsender"
|
||||
|
@ -129,8 +130,8 @@ func handleFlags() config.Config {
|
|||
rotationPtr = flag.Uint("Rotation", 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(config.ExposureModes[:], ",")+")")
|
||||
autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(config.AutoWhiteBalanceModes[:], ",")+")")
|
||||
exposurePtr = flag.String("Exposure", "auto", "Set exposure mode. ("+strings.Join(raspivid.ExposureModes[:], ",")+")")
|
||||
autoWhiteBalancePtr = flag.String("Awb", "auto", "Set automatic white balance mode. ("+strings.Join(raspivid.AutoWhiteBalanceModes[:], ",")+")")
|
||||
|
||||
// Audio specific flags.
|
||||
sampleRatePtr = flag.Int("SampleRate", 48000, "Sample rate of recorded audio")
|
||||
|
|
|
@ -175,7 +175,7 @@ func (r *Raspivid) Set(c config.Config) error {
|
|||
c.Saturation = defaultRaspividSaturation
|
||||
}
|
||||
|
||||
if c.Exposure == "" || !stringInSlice(c.Exposure, config.ExposureModes[:]) {
|
||||
if c.Exposure == "" || !stringInSlice(c.Exposure, ExposureModes[:]) {
|
||||
errs = append(errs, errBadExposure)
|
||||
c.Exposure = defaultRaspividExposure
|
||||
}
|
||||
|
|
|
@ -317,7 +317,6 @@ func (c *Config) Validate() error {
|
|||
c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP")
|
||||
c.Outputs[i] = OutputHTTP
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
return errors.New("bad output type defined in config")
|
||||
}
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
DESCRIPTION
|
||||
config_test.go provides testing for configuration functionality found in config.go.
|
||||
|
||||
AUTHORS
|
||||
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
Copyright (C) 2019 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
|
||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type dumbLogger struct{}
|
||||
|
||||
func (dl *dumbLogger) SetLevel(l int8) {}
|
||||
func (dl *dumbLogger) Log(l int8, m string, p ...interface{}) {}
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
tests := []struct {
|
||||
in Config
|
||||
check func(c Config) error
|
||||
err error
|
||||
}{
|
||||
{
|
||||
in: Config{Outputs: []uint8{OutputHTTP}, Quantization: 50, Logger: &dumbLogger{}},
|
||||
check: func(c Config) error { return nil },
|
||||
err: errInvalidQuantization,
|
||||
},
|
||||
{
|
||||
in: Config{Outputs: []uint8{OutputHTTP}, Quantization: 20, Logger: &dumbLogger{}},
|
||||
check: func(c Config) error {
|
||||
if c.Bitrate != 0 {
|
||||
return fmt.Errorf("did not get expected bitrate. Got: %v, Want: %v", c.Bitrate, 0)
|
||||
}
|
||||
if c.Quantization != 20 {
|
||||
return fmt.Errorf("did not get expected quantization. Got: %v, Want: %v", c.Quantization, 20)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
err := (&test.in).Validate()
|
||||
if err != test.err {
|
||||
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
|
||||
}
|
||||
|
||||
err = test.check(test.in)
|
||||
if err != nil {
|
||||
t.Errorf("test %d failed with err: %v", i, err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue