Merged in no-nil-outputs-panic (pull request #193)

revid: does not panic when not outputs are defined in a config.
This commit is contained in:
Saxon Milton 2019-05-05 13:24:12 +00:00
commit 408492ae1a
2 changed files with 30 additions and 30 deletions

View File

@ -211,6 +211,12 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("bad input codec defined in config")
}
if c.Outputs == nil {
c.Logger.Log(logger.Info, pkg+"no output defined, defaulting", "output",
defaultOutput)
c.Outputs = append(c.Outputs, defaultOutput)
c.Packetization = defaultPacketization
} else {
for i, o := range c.Outputs {
switch o {
case File:
@ -228,12 +234,6 @@ func (c *Config) Validate(r *Revid) error {
c.FramesPerClip = defaultFramesPerClip
c.Packetization = Flv
c.SendRetry = true
case NothingDefined:
c.Logger.Log(logger.Info, pkg+"no output defined, defaulting", "output",
defaultOutput)
c.Outputs[i] = defaultOutput
c.Packetization = defaultPacketization
fallthrough
case Http, Rtp:
c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out",
"framesPerClip", httpFramesPerClip)
@ -243,6 +243,7 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("bad output type defined in config")
}
}
}
if c.BurstPeriod == 0 {
c.Logger.Log(logger.Info, pkg+"no burst period defined, defaulting", "burstPeriod", defaultBurstPeriod)

View File

@ -59,7 +59,6 @@ func TestRaspivid(t *testing.T) {
var c Config
c.Logger = &logger
c.Input = Raspivid
c.Outputs = make([]uint8, 1)
rv, err := New(c, ns)
if err != nil {