mirror of https://bitbucket.org/ausocean/av.git
fix webcam bug and also consider webcam Input var value
This commit is contained in:
parent
1a65dc9da4
commit
91e5e765f5
|
@ -60,5 +60,5 @@ type AVDevice interface {
|
||||||
type MultiError []error
|
type MultiError []error
|
||||||
|
|
||||||
func (me MultiError) Error() string {
|
func (me MultiError) Error() string {
|
||||||
return fmt.Sprintf("%v", me)
|
return fmt.Sprintf("%v", []error(me))
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ var (
|
||||||
errBadBitrate = errors.New("bitrate bad or unset, defaulting")
|
errBadBitrate = errors.New("bitrate bad or unset, defaulting")
|
||||||
errBadWidth = errors.New("width bad or unset, defaulting")
|
errBadWidth = errors.New("width bad or unset, defaulting")
|
||||||
errBadHeight = errors.New("height bad or unset, defaulting")
|
errBadHeight = errors.New("height bad or unset, defaulting")
|
||||||
|
errBadInputPath = errors.New("input path bad or unset, defaulting")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Webcam is an implementation of the AVDevice interface for a Webcam. Webcam
|
// Webcam is an implementation of the AVDevice interface for a Webcam. Webcam
|
||||||
|
@ -75,6 +76,12 @@ func New(l config.Logger) *Webcam {
|
||||||
// added to the multiError and a default value is used.
|
// added to the multiError and a default value is used.
|
||||||
func (w *Webcam) Set(c config.Config) error {
|
func (w *Webcam) Set(c config.Config) error {
|
||||||
var errs device.MultiError
|
var errs device.MultiError
|
||||||
|
if c.InputPath == "" {
|
||||||
|
const defaultInputPath = "/dev/video0"
|
||||||
|
errs = append(errs, errBadInputPath)
|
||||||
|
c.InputPath = defaultInputPath
|
||||||
|
}
|
||||||
|
|
||||||
if c.Width == 0 {
|
if c.Width == 0 {
|
||||||
errs = append(errs, errBadWidth)
|
errs = append(errs, errBadWidth)
|
||||||
c.Width = defaultWidth
|
c.Width = defaultWidth
|
||||||
|
|
|
@ -467,7 +467,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
||||||
for key, value := range vars {
|
for key, value := range vars {
|
||||||
switch key {
|
switch key {
|
||||||
case "Input":
|
case "Input":
|
||||||
v, ok := map[string]uint8{"raspivid": config.InputRaspivid, "rtsp": config.InputRTSP}[strings.ToLower(value)]
|
v, ok := map[string]uint8{"raspivid": config.InputRaspivid, "rtsp": config.InputRTSP, "v4l": config.InputV4L}[strings.ToLower(value)]
|
||||||
if !ok {
|
if !ok {
|
||||||
r.cfg.Logger.Log(logger.Warning, pkg+"invalid input var", "value", value)
|
r.cfg.Logger.Log(logger.Warning, pkg+"invalid input var", "value", value)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue