diff --git a/revid/config.go b/revid/config.go index d9bd4877..9c317e9b 100644 --- a/revid/config.go +++ b/revid/config.go @@ -211,36 +211,37 @@ func (c *Config) Validate(r *Revid) error { return errors.New("bad input codec defined in config") } - for i, o := range c.Outputs { - switch o { - case File: - case Udp: - case Rtmp, FfmpegRtmp: - if c.RtmpUrl == "" { - c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") - c.Outputs[i] = Http - // FIXME(kortschak): Does this want the same line as below? - // c.FramesPerClip = httpFramesPerClip - break + 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: + case Udp: + case Rtmp, FfmpegRtmp: + if c.RtmpUrl == "" { + c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") + c.Outputs[i] = Http + // FIXME(kortschak): Does this want the same line as below? + // c.FramesPerClip = httpFramesPerClip + break + } + c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for rtmp out", + "framesPerClip", defaultFramesPerClip) + c.FramesPerClip = defaultFramesPerClip + c.Packetization = Flv + c.SendRetry = true + case Http, Rtp: + c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out", + "framesPerClip", httpFramesPerClip) + c.FramesPerClip = httpFramesPerClip + c.Packetization = Mpegts + default: + return errors.New("bad output type defined in config") } - c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for rtmp out", - "framesPerClip", defaultFramesPerClip) - 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) - c.FramesPerClip = httpFramesPerClip - c.Packetization = Mpegts - default: - return errors.New("bad output type defined in config") } } diff --git a/revid/revid_test.go b/revid/revid_test.go index 08c8521a..18086912 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -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 {