av/device: AVDevice Flags method

Issue #189 resolved
Alan Noble created an issue

AVDevice implementations should be responsible for creating their own command-line flag vars, not their callers. In fact, strictly speaking, only the implementations need know what flags are acceptable to them.

Code such as the following:

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[:], ",")+")")

becomes simply:

raspipid.Flags()

Flags would create a FlagSet.

Callers then call Flags and Parse for each device package they intend to use. If Flags returns *FlagSet, then Parse() can be called, e.g.,:

raspipid.Flags().Parse()
geovision.Flags().Parse()
alsa.Flags().Parse()

An advantage of this approach is that each device has direct access to command-line flags and can configure itself accordingly.

Considerations:

Different devices may use the name flag names.

Comments (4)

  1. Alan Noble reporter

    Can we revisit moving the processing of flags from revid to AVDevice implementations@Saxon Milton ?

  2. Log in to comment