diff --git a/filter/filter.go b/filter/filter.go index d415d64f..ec182531 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -30,6 +30,7 @@ import ( "io" ) +// Interface for all filters. type Filter interface { io.WriteCloser //NB: Filter interface may evolve with more methods as required. diff --git a/revid/config/config.go b/revid/config/config.go index 9bb51322..9a19f4ab 100644 --- a/revid/config/config.go +++ b/revid/config/config.go @@ -108,8 +108,7 @@ const ( QualityExcellent ) -// The different filter methods that can be used (currently these are all motion filters -// that will only send video with motion in it) +// The different media filters. const ( FilterNoOp = iota FilterMOG @@ -255,7 +254,7 @@ type Config struct { HorizontalFlip bool // HorizontalFlip flips video horizontally for Raspivid input. VerticalFlip bool // VerticalFlip flips video vertically for Raspivid input. - FilterMethod int // Defines the method of filtering to be used in between lexing and encoding + Filter int // Defines the method of filtering to be used in between lexing and encoding. PSITime int // Sets the time between a packet being sent // RTMP ring buffer parameters. diff --git a/revid/revid.go b/revid/revid.go index 55b46656..d3cd3cc4 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -328,13 +328,13 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. r.encoders = multiWriter(encoders...) - switch r.cfg.FilterMethod { + switch r.cfg.Filter { case config.FilterNoOp: r.filter = filter.NewNoOp(r.encoders) case config.FilterMOG: r.filter = filter.NewMOGFilter(r.encoders, 25, 20, 500, 3, true) default: - r.filter = filter.NewNoOp(r.encoders) + panic("Undefined Filter") } switch r.cfg.Input { @@ -451,6 +451,7 @@ func (r *Revid) Stop() { r.cfg.Logger.Log(logger.Error, pkg+"failed to close pipeline", "error", err.Error()) } err = r.filter.Close() + if err != nil { r.cfg.Logger.Log(logger.Error, pkg+"failed to close pipeline", "error", err.Error()) } @@ -628,13 +629,13 @@ func (r *Revid) Update(vars map[string]string) error { default: r.cfg.Logger.Log(logger.Warning, pkg+"invalid VerticalFlip param", "value", value) } - case "FilterMethod": + case "Filter": m := map[string]int{"NoOp": config.FilterNoOp, "MOG": config.FilterMOG} v, ok := m[value] if !ok { r.cfg.Logger.Log(logger.Warning, pkg+"invalid FilterMethod param", "value", value) } - r.cfg.FilterMethod = v + r.cfg.Filter = v case "PSITime": v, err := strconv.Atoi(value) if err != nil || v < 0 {